From 235929953719661e70e152e63521a1c446d76caf Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Sun, 24 May 2020 02:57:21 +0200 Subject: [PATCH] Clear MIR local type annotations after borrowck --- src/librustc_mir/transform/cleanup_post_borrowck.rs | 4 ++++ src/test/incremental/hashes/let_expressions.rs | 2 +- .../32bit/rustc.main.SimplifyCfg-elaborate-drops.after.mir | 2 +- .../64bit/rustc.main.SimplifyCfg-elaborate-drops.after.mir | 2 +- .../const_prop/array_index/32bit/rustc.main.ConstProp.diff | 2 +- .../const_prop/array_index/64bit/rustc.main.ConstProp.diff | 2 +- .../32bit/rustc.main.ConstProp.diff | 2 +- .../64bit/rustc.main.ConstProp.diff | 2 +- .../mir-opt/const_prop/checked_add/rustc.main.ConstProp.diff | 2 +- .../rustc.main.ConstProp.diff | 2 +- .../mutable_variable_unprop_assign/rustc.main.ConstProp.diff | 2 +- .../mir-opt/const_prop/repeat/32bit/rustc.main.ConstProp.diff | 2 +- .../mir-opt/const_prop/repeat/64bit/rustc.main.ConstProp.diff | 2 +- .../inline/inline-into-box-place/32bit/rustc.main.Inline.diff | 2 +- .../inline/inline-into-box-place/64bit/rustc.main.Inline.diff | 2 +- .../retag/rustc.main.SimplifyCfg-elaborate-drops.after.mir | 2 +- .../32bit/rustc.main.SimplifyArmIdentity.diff | 2 +- .../64bit/rustc.main.SimplifyArmIdentity.diff | 2 +- 18 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/librustc_mir/transform/cleanup_post_borrowck.rs b/src/librustc_mir/transform/cleanup_post_borrowck.rs index e80da4f756c64..3f3d247a8294f 100644 --- a/src/librustc_mir/transform/cleanup_post_borrowck.rs +++ b/src/librustc_mir/transform/cleanup_post_borrowck.rs @@ -35,6 +35,10 @@ impl<'tcx> MirPass<'tcx> for CleanupNonCodegenStatements { let mut delete = DeleteNonCodegenStatements { tcx }; delete.visit_body(body); body.user_type_annotations.raw.clear(); + + for decl in &mut body.local_decls { + decl.user_ty = None; + } } } diff --git a/src/test/incremental/hashes/let_expressions.rs b/src/test/incremental/hashes/let_expressions.rs index 924ed451e59f8..846bfc6d0e4db 100644 --- a/src/test/incremental/hashes/let_expressions.rs +++ b/src/test/incremental/hashes/let_expressions.rs @@ -38,7 +38,7 @@ pub fn add_type() { #[cfg(not(cfail1))] #[rustc_clean(cfg="cfail2", - except="hir_owner_nodes,typeck_tables_of,mir_built,optimized_mir")] + except="hir_owner_nodes,typeck_tables_of,mir_built")] #[rustc_clean(cfg="cfail3")] pub fn add_type() { let _x: u32 = 2u32; diff --git a/src/test/mir-opt/array-index-is-temporary/32bit/rustc.main.SimplifyCfg-elaborate-drops.after.mir b/src/test/mir-opt/array-index-is-temporary/32bit/rustc.main.SimplifyCfg-elaborate-drops.after.mir index c42d5adce4f2b..d39b9b8a3b444 100644 --- a/src/test/mir-opt/array-index-is-temporary/32bit/rustc.main.SimplifyCfg-elaborate-drops.after.mir +++ b/src/test/mir-opt/array-index-is-temporary/32bit/rustc.main.SimplifyCfg-elaborate-drops.after.mir @@ -14,7 +14,7 @@ fn main() -> () { let mut _2: usize; // in scope 1 at $DIR/array-index-is-temporary.rs:14:9: 14:14 scope 2 { debug y => _2; // in scope 2 at $DIR/array-index-is-temporary.rs:14:9: 14:14 - let _3: *mut usize as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 2 at $DIR/array-index-is-temporary.rs:15:9: 15:10 + let _3: *mut usize; // in scope 2 at $DIR/array-index-is-temporary.rs:15:9: 15:10 scope 3 { debug z => _3; // in scope 3 at $DIR/array-index-is-temporary.rs:15:9: 15:10 scope 4 { diff --git a/src/test/mir-opt/array-index-is-temporary/64bit/rustc.main.SimplifyCfg-elaborate-drops.after.mir b/src/test/mir-opt/array-index-is-temporary/64bit/rustc.main.SimplifyCfg-elaborate-drops.after.mir index 05d9b3b9b6f77..381c1ca6f22ef 100644 --- a/src/test/mir-opt/array-index-is-temporary/64bit/rustc.main.SimplifyCfg-elaborate-drops.after.mir +++ b/src/test/mir-opt/array-index-is-temporary/64bit/rustc.main.SimplifyCfg-elaborate-drops.after.mir @@ -14,7 +14,7 @@ fn main() -> () { let mut _2: usize; // in scope 1 at $DIR/array-index-is-temporary.rs:14:9: 14:14 scope 2 { debug y => _2; // in scope 2 at $DIR/array-index-is-temporary.rs:14:9: 14:14 - let _3: *mut usize as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 2 at $DIR/array-index-is-temporary.rs:15:9: 15:10 + let _3: *mut usize; // in scope 2 at $DIR/array-index-is-temporary.rs:15:9: 15:10 scope 3 { debug z => _3; // in scope 3 at $DIR/array-index-is-temporary.rs:15:9: 15:10 scope 4 { diff --git a/src/test/mir-opt/const_prop/array_index/32bit/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/array_index/32bit/rustc.main.ConstProp.diff index e24751d39a7df..d02906132e296 100644 --- a/src/test/mir-opt/const_prop/array_index/32bit/rustc.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/array_index/32bit/rustc.main.ConstProp.diff @@ -3,7 +3,7 @@ fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/array_index.rs:4:11: 4:11 - let _1: u32 as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 0 at $DIR/array_index.rs:5:9: 5:10 + let _1: u32; // in scope 0 at $DIR/array_index.rs:5:9: 5:10 let mut _2: [u32; 4]; // in scope 0 at $DIR/array_index.rs:5:18: 5:30 let _3: usize; // in scope 0 at $DIR/array_index.rs:5:31: 5:32 let mut _4: usize; // in scope 0 at $DIR/array_index.rs:5:18: 5:33 diff --git a/src/test/mir-opt/const_prop/array_index/64bit/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/array_index/64bit/rustc.main.ConstProp.diff index ad9992bb94905..4fe3f08955894 100644 --- a/src/test/mir-opt/const_prop/array_index/64bit/rustc.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/array_index/64bit/rustc.main.ConstProp.diff @@ -3,7 +3,7 @@ fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/array_index.rs:4:11: 4:11 - let _1: u32 as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 0 at $DIR/array_index.rs:5:9: 5:10 + let _1: u32; // in scope 0 at $DIR/array_index.rs:5:9: 5:10 let mut _2: [u32; 4]; // in scope 0 at $DIR/array_index.rs:5:18: 5:30 let _3: usize; // in scope 0 at $DIR/array_index.rs:5:31: 5:32 let mut _4: usize; // in scope 0 at $DIR/array_index.rs:5:18: 5:33 diff --git a/src/test/mir-opt/const_prop/bad_op_unsafe_oob_for_slices/32bit/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/bad_op_unsafe_oob_for_slices/32bit/rustc.main.ConstProp.diff index 8ecb77752bb39..7071f31dbf104 100644 --- a/src/test/mir-opt/const_prop/bad_op_unsafe_oob_for_slices/32bit/rustc.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/bad_op_unsafe_oob_for_slices/32bit/rustc.main.ConstProp.diff @@ -3,7 +3,7 @@ fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:4:11: 4:11 - let _1: *const [i32] as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:9: 5:10 + let _1: *const [i32]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:9: 5:10 let mut _2: *const [i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:25: 5:35 let _3: &[i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:25: 5:35 let _4: [i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:26: 5:35 diff --git a/src/test/mir-opt/const_prop/bad_op_unsafe_oob_for_slices/64bit/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/bad_op_unsafe_oob_for_slices/64bit/rustc.main.ConstProp.diff index 2778ec02724df..15995ab070019 100644 --- a/src/test/mir-opt/const_prop/bad_op_unsafe_oob_for_slices/64bit/rustc.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/bad_op_unsafe_oob_for_slices/64bit/rustc.main.ConstProp.diff @@ -3,7 +3,7 @@ fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:4:11: 4:11 - let _1: *const [i32] as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:9: 5:10 + let _1: *const [i32]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:9: 5:10 let mut _2: *const [i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:25: 5:35 let _3: &[i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:25: 5:35 let _4: [i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:26: 5:35 diff --git a/src/test/mir-opt/const_prop/checked_add/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/checked_add/rustc.main.ConstProp.diff index 92add8bafdc03..f9f7d543d21f5 100644 --- a/src/test/mir-opt/const_prop/checked_add/rustc.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/checked_add/rustc.main.ConstProp.diff @@ -3,7 +3,7 @@ fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/checked_add.rs:4:11: 4:11 - let _1: u32 as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 0 at $DIR/checked_add.rs:5:9: 5:10 + let _1: u32; // in scope 0 at $DIR/checked_add.rs:5:9: 5:10 let mut _2: (u32, bool); // in scope 0 at $DIR/checked_add.rs:5:18: 5:23 scope 1 { debug x => _1; // in scope 1 at $DIR/checked_add.rs:5:9: 5:10 diff --git a/src/test/mir-opt/const_prop/mutable_variable_aggregate_partial_read/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/mutable_variable_aggregate_partial_read/rustc.main.ConstProp.diff index 6834bb6bdd4f7..f6bb72baea419 100644 --- a/src/test/mir-opt/const_prop/mutable_variable_aggregate_partial_read/rustc.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/mutable_variable_aggregate_partial_read/rustc.main.ConstProp.diff @@ -3,7 +3,7 @@ fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/mutable_variable_aggregate_partial_read.rs:4:11: 4:11 - let mut _1: (i32, i32) as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 0 at $DIR/mutable_variable_aggregate_partial_read.rs:5:9: 5:14 + let mut _1: (i32, i32); // in scope 0 at $DIR/mutable_variable_aggregate_partial_read.rs:5:9: 5:14 scope 1 { debug x => _1; // in scope 1 at $DIR/mutable_variable_aggregate_partial_read.rs:5:9: 5:14 let _2: i32; // in scope 1 at $DIR/mutable_variable_aggregate_partial_read.rs:8:9: 8:10 diff --git a/src/test/mir-opt/const_prop/mutable_variable_unprop_assign/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/mutable_variable_unprop_assign/rustc.main.ConstProp.diff index 738343c655e36..e0b9fbe04c387 100644 --- a/src/test/mir-opt/const_prop/mutable_variable_unprop_assign/rustc.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/mutable_variable_unprop_assign/rustc.main.ConstProp.diff @@ -7,7 +7,7 @@ let mut _3: i32; // in scope 0 at $DIR/mutable_variable_unprop_assign.rs:7:11: 7:12 scope 1 { debug a => _1; // in scope 1 at $DIR/mutable_variable_unprop_assign.rs:5:9: 5:10 - let mut _2: (i32, i32) as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 1 at $DIR/mutable_variable_unprop_assign.rs:6:9: 6:14 + let mut _2: (i32, i32); // in scope 1 at $DIR/mutable_variable_unprop_assign.rs:6:9: 6:14 scope 2 { debug x => _2; // in scope 2 at $DIR/mutable_variable_unprop_assign.rs:6:9: 6:14 let _4: i32; // in scope 2 at $DIR/mutable_variable_unprop_assign.rs:8:9: 8:10 diff --git a/src/test/mir-opt/const_prop/repeat/32bit/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/repeat/32bit/rustc.main.ConstProp.diff index 4ccfe1838d9cc..b1c9e22913935 100644 --- a/src/test/mir-opt/const_prop/repeat/32bit/rustc.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/repeat/32bit/rustc.main.ConstProp.diff @@ -3,7 +3,7 @@ fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/repeat.rs:5:11: 5:11 - let _1: u32 as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 0 at $DIR/repeat.rs:6:9: 6:10 + let _1: u32; // in scope 0 at $DIR/repeat.rs:6:9: 6:10 let mut _2: u32; // in scope 0 at $DIR/repeat.rs:6:18: 6:28 let mut _3: [u32; 8]; // in scope 0 at $DIR/repeat.rs:6:18: 6:25 let _4: usize; // in scope 0 at $DIR/repeat.rs:6:26: 6:27 diff --git a/src/test/mir-opt/const_prop/repeat/64bit/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/repeat/64bit/rustc.main.ConstProp.diff index fe9d16c4ffabb..29555b03a8b8e 100644 --- a/src/test/mir-opt/const_prop/repeat/64bit/rustc.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/repeat/64bit/rustc.main.ConstProp.diff @@ -3,7 +3,7 @@ fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/repeat.rs:5:11: 5:11 - let _1: u32 as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 0 at $DIR/repeat.rs:6:9: 6:10 + let _1: u32; // in scope 0 at $DIR/repeat.rs:6:9: 6:10 let mut _2: u32; // in scope 0 at $DIR/repeat.rs:6:18: 6:28 let mut _3: [u32; 8]; // in scope 0 at $DIR/repeat.rs:6:18: 6:25 let _4: usize; // in scope 0 at $DIR/repeat.rs:6:26: 6:27 diff --git a/src/test/mir-opt/inline/inline-into-box-place/32bit/rustc.main.Inline.diff b/src/test/mir-opt/inline/inline-into-box-place/32bit/rustc.main.Inline.diff index 607dd468e598b..f31d5fae9ed37 100644 --- a/src/test/mir-opt/inline/inline-into-box-place/32bit/rustc.main.Inline.diff +++ b/src/test/mir-opt/inline/inline-into-box-place/32bit/rustc.main.Inline.diff @@ -3,7 +3,7 @@ fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/inline-into-box-place.rs:7:11: 7:11 - let _1: std::boxed::Box> as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 0 at $DIR/inline-into-box-place.rs:8:9: 8:11 + let _1: std::boxed::Box>; // in scope 0 at $DIR/inline-into-box-place.rs:8:9: 8:11 let mut _2: std::boxed::Box>; // in scope 0 at $DIR/inline-into-box-place.rs:8:29: 8:43 let mut _3: (); // in scope 0 at $DIR/inline-into-box-place.rs:8:42: 8:43 + let mut _4: &mut std::vec::Vec; // in scope 0 at $DIR/inline-into-box-place.rs:8:33: 8:43 diff --git a/src/test/mir-opt/inline/inline-into-box-place/64bit/rustc.main.Inline.diff b/src/test/mir-opt/inline/inline-into-box-place/64bit/rustc.main.Inline.diff index e83ca36706af7..324ec2d7c5bcd 100644 --- a/src/test/mir-opt/inline/inline-into-box-place/64bit/rustc.main.Inline.diff +++ b/src/test/mir-opt/inline/inline-into-box-place/64bit/rustc.main.Inline.diff @@ -3,7 +3,7 @@ fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/inline-into-box-place.rs:7:11: 7:11 - let _1: std::boxed::Box> as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 0 at $DIR/inline-into-box-place.rs:8:9: 8:11 + let _1: std::boxed::Box>; // in scope 0 at $DIR/inline-into-box-place.rs:8:9: 8:11 let mut _2: std::boxed::Box>; // in scope 0 at $DIR/inline-into-box-place.rs:8:29: 8:43 let mut _3: (); // in scope 0 at $DIR/inline-into-box-place.rs:8:42: 8:43 + let mut _4: &mut std::vec::Vec; // in scope 0 at $DIR/inline-into-box-place.rs:8:33: 8:43 diff --git a/src/test/mir-opt/retag/rustc.main.SimplifyCfg-elaborate-drops.after.mir b/src/test/mir-opt/retag/rustc.main.SimplifyCfg-elaborate-drops.after.mir index f2154ef6b1e91..459c6b7a70a36 100644 --- a/src/test/mir-opt/retag/rustc.main.SimplifyCfg-elaborate-drops.after.mir +++ b/src/test/mir-opt/retag/rustc.main.SimplifyCfg-elaborate-drops.after.mir @@ -24,7 +24,7 @@ fn main() -> () { scope 1 { debug x => _1; // in scope 1 at $DIR/retag.rs:30:9: 30:14 let _3: &mut i32; // in scope 1 at $DIR/retag.rs:32:13: 32:14 - let _13: for<'r> fn(&'r i32) -> &'r i32 as UserTypeProjection { base: UserType(1), projs: [] }; // in scope 1 at $DIR/retag.rs:40:9: 40:10 + let _13: for<'r> fn(&'r i32) -> &'r i32; // in scope 1 at $DIR/retag.rs:40:9: 40:10 scope 2 { debug v => _3; // in scope 2 at $DIR/retag.rs:32:13: 32:14 let _8: &mut i32; // in scope 2 at $DIR/retag.rs:33:13: 33:14 diff --git a/src/test/mir-opt/simplify-arm-identity/32bit/rustc.main.SimplifyArmIdentity.diff b/src/test/mir-opt/simplify-arm-identity/32bit/rustc.main.SimplifyArmIdentity.diff index 6199e2c56625d..dfd6d6f0f2ecd 100644 --- a/src/test/mir-opt/simplify-arm-identity/32bit/rustc.main.SimplifyArmIdentity.diff +++ b/src/test/mir-opt/simplify-arm-identity/32bit/rustc.main.SimplifyArmIdentity.diff @@ -3,7 +3,7 @@ fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/simplify-arm-identity.rs:17:11: 17:11 - let _1: Src as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 0 at $DIR/simplify-arm-identity.rs:18:9: 18:10 + let _1: Src; // in scope 0 at $DIR/simplify-arm-identity.rs:18:9: 18:10 let mut _2: Dst; // in scope 0 at $DIR/simplify-arm-identity.rs:19:18: 22:6 let mut _3: isize; // in scope 0 at $DIR/simplify-arm-identity.rs:20:9: 20:20 let mut _5: u8; // in scope 0 at $DIR/simplify-arm-identity.rs:20:33: 20:34 diff --git a/src/test/mir-opt/simplify-arm-identity/64bit/rustc.main.SimplifyArmIdentity.diff b/src/test/mir-opt/simplify-arm-identity/64bit/rustc.main.SimplifyArmIdentity.diff index bf875c6a555fe..f2bbd19586993 100644 --- a/src/test/mir-opt/simplify-arm-identity/64bit/rustc.main.SimplifyArmIdentity.diff +++ b/src/test/mir-opt/simplify-arm-identity/64bit/rustc.main.SimplifyArmIdentity.diff @@ -3,7 +3,7 @@ fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/simplify-arm-identity.rs:17:11: 17:11 - let _1: Src as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 0 at $DIR/simplify-arm-identity.rs:18:9: 18:10 + let _1: Src; // in scope 0 at $DIR/simplify-arm-identity.rs:18:9: 18:10 let mut _2: Dst; // in scope 0 at $DIR/simplify-arm-identity.rs:19:18: 22:6 let mut _3: isize; // in scope 0 at $DIR/simplify-arm-identity.rs:20:9: 20:20 let mut _5: u8; // in scope 0 at $DIR/simplify-arm-identity.rs:20:33: 20:34