diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-08-19 12:26:45 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-19 12:26:45 +0530 |
| commit | 490d04bfbcec365533591a5a5bbcd58fcd3f6517 (patch) | |
| tree | eefd28b3ff5e48cdee83a4392b5c9ded992b9de3 /src | |
| parent | 769ad701294401b179e8569625ebeb585cab25ed (diff) | |
| parent | 7b457184849d343d50a3eb56c28396189c696a42 (diff) | |
| download | rust-490d04bfbcec365533591a5a5bbcd58fcd3f6517.tar.gz rust-490d04bfbcec365533591a5a5bbcd58fcd3f6517.zip | |
Rollup merge of #100598 - ouz-a:91633, r=compiler-errors
Don't fix builtin index when Where clause is found Where clause shadows blanket impl for `Index` which causes normalization to not occur, which causes ICE to happen when we typeck. r? `@compiler-errors` Fixes #91633
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/mir-opt/issue-91633.rs | 31 | ||||
| -rw-r--r-- | src/test/mir-opt/issue_91633.bar.mir_map.0.mir | 39 | ||||
| -rw-r--r-- | src/test/mir-opt/issue_91633.foo.mir_map.0.mir | 57 | ||||
| -rw-r--r-- | src/test/mir-opt/issue_91633.fun.mir_map.0.mir | 35 | ||||
| -rw-r--r-- | src/test/mir-opt/issue_91633.hey.mir_map.0.mir | 35 | ||||
| -rw-r--r-- | src/test/ui/typeck/issue-91633.rs | 8 |
6 files changed, 205 insertions, 0 deletions
diff --git a/src/test/mir-opt/issue-91633.rs b/src/test/mir-opt/issue-91633.rs new file mode 100644 index 00000000000..8f66019857f --- /dev/null +++ b/src/test/mir-opt/issue-91633.rs @@ -0,0 +1,31 @@ +// compile-flags: -Z mir-opt-level=0 +// EMIT_MIR issue_91633.hey.mir_map.0.mir +fn hey<T> (it: &[T]) + where + [T] : std::ops::Index<usize>, + { + let _ = &it[0]; + } + +// EMIT_MIR issue_91633.bar.mir_map.0.mir +fn bar<T> (it: Box<[T]>) + where + [T] : std::ops::Index<usize>, + { + let _ = it[0]; + } + +// EMIT_MIR issue_91633.fun.mir_map.0.mir +fn fun<T> (it: &[T]) -> &T + { + let f = &it[0]; + f + } + +// EMIT_MIR issue_91633.foo.mir_map.0.mir +fn foo<T: Clone> (it: Box<[T]>) -> T + { + let f = it[0].clone(); + f + } + fn main(){} diff --git a/src/test/mir-opt/issue_91633.bar.mir_map.0.mir b/src/test/mir-opt/issue_91633.bar.mir_map.0.mir new file mode 100644 index 00000000000..f5092d2ac92 --- /dev/null +++ b/src/test/mir-opt/issue_91633.bar.mir_map.0.mir @@ -0,0 +1,39 @@ +// MIR for `bar` 0 mir_map + +fn bar(_1: Box<[T]>) -> () { + debug it => _1; // in scope 0 at $DIR/issue-91633.rs:+0:12: +0:14 + let mut _0: (); // return place in scope 0 at $DIR/issue-91633.rs:+1:2: +1:2 + let mut _2: &<[T] as std::ops::Index<usize>>::Output; // in scope 0 at $DIR/issue-91633.rs:+4:14: +4:19 + let mut _3: &[T]; // in scope 0 at $DIR/issue-91633.rs:+4:14: +4:16 + scope 1 { + } + + bb0: { + StorageLive(_2); // scope 0 at $DIR/issue-91633.rs:+4:14: +4:19 + StorageLive(_3); // scope 0 at $DIR/issue-91633.rs:+4:14: +4:16 + _3 = &(*_1); // scope 0 at $DIR/issue-91633.rs:+4:14: +4:16 + _2 = <[T] as Index<usize>>::index(move _3, const 0_usize) -> [return: bb1, unwind: bb3]; // scope 0 at $DIR/issue-91633.rs:+4:14: +4:19 + // mir::Constant + // + span: $DIR/issue-91633.rs:15:14: 15:19 + // + literal: Const { ty: for<'r> fn(&'r [T], usize) -> &'r <[T] as Index<usize>>::Output {<[T] as Index<usize>>::index}, val: Value(<ZST>) } + } + + bb1: { + StorageDead(_3); // scope 0 at $DIR/issue-91633.rs:+4:18: +4:19 + StorageDead(_2); // scope 0 at $DIR/issue-91633.rs:+4:19: +4:20 + _0 = const (); // scope 0 at $DIR/issue-91633.rs:+3:2: +5:3 + drop(_1) -> [return: bb2, unwind: bb4]; // scope 0 at $DIR/issue-91633.rs:+5:2: +5:3 + } + + bb2: { + return; // scope 0 at $DIR/issue-91633.rs:+5:3: +5:3 + } + + bb3 (cleanup): { + drop(_1) -> bb4; // scope 0 at $DIR/issue-91633.rs:+5:2: +5:3 + } + + bb4 (cleanup): { + resume; // scope 0 at $DIR/issue-91633.rs:+0:1: +5:3 + } +} diff --git a/src/test/mir-opt/issue_91633.foo.mir_map.0.mir b/src/test/mir-opt/issue_91633.foo.mir_map.0.mir new file mode 100644 index 00000000000..2e8b0feedd3 --- /dev/null +++ b/src/test/mir-opt/issue_91633.foo.mir_map.0.mir @@ -0,0 +1,57 @@ +// MIR for `foo` 0 mir_map + +fn foo(_1: Box<[T]>) -> T { + debug it => _1; // in scope 0 at $DIR/issue-91633.rs:+0:19: +0:21 + let mut _0: T; // return place in scope 0 at $DIR/issue-91633.rs:+0:36: +0:37 + let _2: T; // in scope 0 at $DIR/issue-91633.rs:+2:10: +2:11 + let mut _3: &T; // in scope 0 at $DIR/issue-91633.rs:+2:14: +2:27 + let _4: usize; // in scope 0 at $DIR/issue-91633.rs:+2:17: +2:18 + let mut _5: usize; // in scope 0 at $DIR/issue-91633.rs:+2:14: +2:19 + let mut _6: bool; // in scope 0 at $DIR/issue-91633.rs:+2:14: +2:19 + scope 1 { + debug f => _2; // in scope 1 at $DIR/issue-91633.rs:+2:10: +2:11 + } + + bb0: { + StorageLive(_2); // scope 0 at $DIR/issue-91633.rs:+2:10: +2:11 + StorageLive(_3); // scope 0 at $DIR/issue-91633.rs:+2:14: +2:27 + StorageLive(_4); // scope 0 at $DIR/issue-91633.rs:+2:17: +2:18 + _4 = const 0_usize; // scope 0 at $DIR/issue-91633.rs:+2:17: +2:18 + _5 = Len((*_1)); // scope 0 at $DIR/issue-91633.rs:+2:14: +2:19 + _6 = Lt(_4, _5); // scope 0 at $DIR/issue-91633.rs:+2:14: +2:19 + assert(move _6, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> [success: bb1, unwind: bb5]; // scope 0 at $DIR/issue-91633.rs:+2:14: +2:19 + } + + bb1: { + _3 = &(*_1)[_4]; // scope 0 at $DIR/issue-91633.rs:+2:14: +2:27 + _2 = <T as Clone>::clone(move _3) -> [return: bb2, unwind: bb5]; // scope 0 at $DIR/issue-91633.rs:+2:14: +2:27 + // mir::Constant + // + span: $DIR/issue-91633.rs:28:20: 28:25 + // + literal: Const { ty: for<'r> fn(&'r T) -> T {<T as Clone>::clone}, val: Value(<ZST>) } + } + + bb2: { + StorageDead(_3); // scope 0 at $DIR/issue-91633.rs:+2:26: +2:27 + FakeRead(ForLet(None), _2); // scope 0 at $DIR/issue-91633.rs:+2:10: +2:11 + StorageDead(_4); // scope 0 at $DIR/issue-91633.rs:+2:27: +2:28 + _0 = move _2; // scope 1 at $DIR/issue-91633.rs:+3:6: +3:7 + drop(_2) -> [return: bb3, unwind: bb5]; // scope 0 at $DIR/issue-91633.rs:+4:2: +4:3 + } + + bb3: { + StorageDead(_2); // scope 0 at $DIR/issue-91633.rs:+4:2: +4:3 + drop(_1) -> [return: bb4, unwind: bb6]; // scope 0 at $DIR/issue-91633.rs:+4:2: +4:3 + } + + bb4: { + return; // scope 0 at $DIR/issue-91633.rs:+4:3: +4:3 + } + + bb5 (cleanup): { + drop(_1) -> bb6; // scope 0 at $DIR/issue-91633.rs:+4:2: +4:3 + } + + bb6 (cleanup): { + resume; // scope 0 at $DIR/issue-91633.rs:+0:1: +4:3 + } +} diff --git a/src/test/mir-opt/issue_91633.fun.mir_map.0.mir b/src/test/mir-opt/issue_91633.fun.mir_map.0.mir new file mode 100644 index 00000000000..ded9a4cf7e3 --- /dev/null +++ b/src/test/mir-opt/issue_91633.fun.mir_map.0.mir @@ -0,0 +1,35 @@ +// MIR for `fun` 0 mir_map + +fn fun(_1: &[T]) -> &T { + debug it => _1; // in scope 0 at $DIR/issue-91633.rs:+0:12: +0:14 + let mut _0: &T; // return place in scope 0 at $DIR/issue-91633.rs:+0:25: +0:27 + let _2: &T; // in scope 0 at $DIR/issue-91633.rs:+2:10: +2:11 + let _3: usize; // in scope 0 at $DIR/issue-91633.rs:+2:18: +2:19 + let mut _4: usize; // in scope 0 at $DIR/issue-91633.rs:+2:15: +2:20 + let mut _5: bool; // in scope 0 at $DIR/issue-91633.rs:+2:15: +2:20 + scope 1 { + debug f => _2; // in scope 1 at $DIR/issue-91633.rs:+2:10: +2:11 + } + + bb0: { + StorageLive(_2); // scope 0 at $DIR/issue-91633.rs:+2:10: +2:11 + StorageLive(_3); // scope 0 at $DIR/issue-91633.rs:+2:18: +2:19 + _3 = const 0_usize; // scope 0 at $DIR/issue-91633.rs:+2:18: +2:19 + _4 = Len((*_1)); // scope 0 at $DIR/issue-91633.rs:+2:15: +2:20 + _5 = Lt(_3, _4); // scope 0 at $DIR/issue-91633.rs:+2:15: +2:20 + assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind: bb2]; // scope 0 at $DIR/issue-91633.rs:+2:15: +2:20 + } + + bb1: { + _2 = &(*_1)[_3]; // scope 0 at $DIR/issue-91633.rs:+2:14: +2:20 + FakeRead(ForLet(None), _2); // scope 0 at $DIR/issue-91633.rs:+2:10: +2:11 + _0 = &(*_2); // scope 1 at $DIR/issue-91633.rs:+3:6: +3:7 + StorageDead(_3); // scope 0 at $DIR/issue-91633.rs:+4:2: +4:3 + StorageDead(_2); // scope 0 at $DIR/issue-91633.rs:+4:2: +4:3 + return; // scope 0 at $DIR/issue-91633.rs:+4:3: +4:3 + } + + bb2 (cleanup): { + resume; // scope 0 at $DIR/issue-91633.rs:+0:1: +4:3 + } +} diff --git a/src/test/mir-opt/issue_91633.hey.mir_map.0.mir b/src/test/mir-opt/issue_91633.hey.mir_map.0.mir new file mode 100644 index 00000000000..74f4a5a9761 --- /dev/null +++ b/src/test/mir-opt/issue_91633.hey.mir_map.0.mir @@ -0,0 +1,35 @@ +// MIR for `hey` 0 mir_map + +fn hey(_1: &[T]) -> () { + debug it => _1; // in scope 0 at $DIR/issue-91633.rs:+0:12: +0:14 + let mut _0: (); // return place in scope 0 at $DIR/issue-91633.rs:+1:2: +1:2 + let mut _2: &<[T] as std::ops::Index<usize>>::Output; // in scope 0 at $DIR/issue-91633.rs:+4:14: +4:20 + let _3: &<[T] as std::ops::Index<usize>>::Output; // in scope 0 at $DIR/issue-91633.rs:+4:15: +4:20 + let mut _4: &[T]; // in scope 0 at $DIR/issue-91633.rs:+4:15: +4:17 + scope 1 { + } + + bb0: { + StorageLive(_2); // scope 0 at $DIR/issue-91633.rs:+4:14: +4:20 + StorageLive(_3); // scope 0 at $DIR/issue-91633.rs:+4:15: +4:20 + StorageLive(_4); // scope 0 at $DIR/issue-91633.rs:+4:15: +4:17 + _4 = &(*_1); // scope 0 at $DIR/issue-91633.rs:+4:15: +4:17 + _3 = <[T] as Index<usize>>::index(move _4, const 0_usize) -> [return: bb1, unwind: bb2]; // scope 0 at $DIR/issue-91633.rs:+4:15: +4:20 + // mir::Constant + // + span: $DIR/issue-91633.rs:7:15: 7:20 + // + literal: Const { ty: for<'r> fn(&'r [T], usize) -> &'r <[T] as Index<usize>>::Output {<[T] as Index<usize>>::index}, val: Value(<ZST>) } + } + + bb1: { + StorageDead(_4); // scope 0 at $DIR/issue-91633.rs:+4:19: +4:20 + _2 = &(*_3); // scope 0 at $DIR/issue-91633.rs:+4:14: +4:20 + StorageDead(_2); // scope 0 at $DIR/issue-91633.rs:+4:20: +4:21 + _0 = const (); // scope 0 at $DIR/issue-91633.rs:+3:2: +5:3 + StorageDead(_3); // scope 0 at $DIR/issue-91633.rs:+5:2: +5:3 + return; // scope 0 at $DIR/issue-91633.rs:+5:3: +5:3 + } + + bb2 (cleanup): { + resume; // scope 0 at $DIR/issue-91633.rs:+0:1: +5:3 + } +} diff --git a/src/test/ui/typeck/issue-91633.rs b/src/test/ui/typeck/issue-91633.rs new file mode 100644 index 00000000000..331a798dd7a --- /dev/null +++ b/src/test/ui/typeck/issue-91633.rs @@ -0,0 +1,8 @@ +// check-pass +fn f<T> (it: &[T]) +where + [T] : std::ops::Index<usize>, +{ + let _ = &it[0]; +} +fn main(){} |
