@@ -15,11 +15,11 @@ extern crate rustc_driver;
1515extern crate rustc_interface;
1616extern crate rustc_public;
1717
18- use std:: assert_matches:: assert_matches;
19- use mir:: { mono:: Instance , TerminatorKind :: * } ;
18+ use mir:: { TerminatorKind :: * , mono:: Instance } ;
2019use rustc_public:: mir:: mono:: InstanceKind ;
21- use rustc_public:: ty:: { RigidTy , TyKind , Ty , UintTy } ;
20+ use rustc_public:: ty:: { RigidTy , Ty , TyKind , UintTy } ;
2221use rustc_public:: * ;
22+ use std:: assert_matches:: assert_matches;
2323use std:: io:: Write ;
2424use std:: ops:: ControlFlow ;
2525
@@ -29,7 +29,7 @@ const CRATE_NAME: &str = "input";
2929fn test_stable_mir ( ) -> ControlFlow < ( ) > {
3030 let entry = rustc_public:: entry_fn ( ) . unwrap ( ) ;
3131 let main_fn = Instance :: try_from ( entry) . unwrap ( ) ;
32- assert_eq ! ( main_fn. name( ) , "main" ) ;
32+ assert_eq ! ( main_fn. name( ) , "input:: main" ) ;
3333 assert_eq ! ( main_fn. trimmed_name( ) , "main" ) ;
3434
3535 let instances = get_instances ( main_fn. body ( ) . unwrap ( ) ) ;
@@ -65,10 +65,8 @@ fn test_fn(instance: Instance, expected_trimmed: &str, expected_qualified: &str,
6565
6666fn extract_elem_ty ( ty : Ty ) -> Ty {
6767 match ty. kind ( ) {
68- TyKind :: RigidTy ( RigidTy :: Adt ( _, args) ) => {
69- * args. 0 [ 0 ] . expect_ty ( )
70- }
71- _ => unreachable ! ( "Expected Vec ADT, but found: {ty:?}" )
68+ TyKind :: RigidTy ( RigidTy :: Adt ( _, args) ) => * args. 0 [ 0 ] . expect_ty ( ) ,
69+ _ => unreachable ! ( "Expected Vec ADT, but found: {ty:?}" ) ,
7270 }
7371}
7472
@@ -89,19 +87,19 @@ fn test_vec_new(instance: mir::mono::Instance) {
8987
9088/// Inspect the instance body
9189fn get_instances ( body : mir:: Body ) -> Vec < Instance > {
92- body. blocks . iter ( ) . filter_map ( |bb| {
93- match & bb. terminator . kind {
90+ body. blocks
91+ . iter ( )
92+ . filter_map ( |bb| match & bb. terminator . kind {
9493 Call { func, .. } => {
95- let TyKind :: RigidTy ( ty) = func. ty ( body. locals ( ) ) . unwrap ( ) . kind ( ) else { unreachable !
96- ( ) } ;
94+ let TyKind :: RigidTy ( ty) = func. ty ( body. locals ( ) ) . unwrap ( ) . kind ( ) else {
95+ unreachable ! ( )
96+ } ;
9797 let RigidTy :: FnDef ( def, args) = ty else { unreachable ! ( ) } ;
9898 Instance :: resolve ( def, & args) . ok ( )
9999 }
100- _ => {
101- None
102- }
103- }
104- } ) . collect :: < Vec < _ > > ( )
100+ _ => None ,
101+ } )
102+ . collect :: < Vec < _ > > ( )
105103}
106104
107105/// This test will generate and analyze a dummy crate using the stable mir.
0 commit comments