-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't ICE when ambiguity is found when selecting Index implementation…
… in typeck
- Loading branch information
1 parent
46ecc10
commit 273dc22
Showing
3 changed files
with
56 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Test against ICE in #118111 | ||
|
||
use std::ops::Index; | ||
|
||
struct Map<T, F> { | ||
f: F, | ||
inner: T, | ||
} | ||
|
||
impl<T, F, Idx> Index<Idx> for Map<T, F> | ||
where | ||
T: Index<Idx>, | ||
F: FnOnce(&T, Idx) -> Idx, | ||
{ | ||
type Output = T::Output; | ||
|
||
fn index(&self, index: Idx) -> &Self::Output { | ||
todo!() | ||
} | ||
} | ||
|
||
fn main() { | ||
Map { inner: [0_usize], f: |_, i: usize| 1_usize }[0]; | ||
//~^ ERROR cannot index into a value of type | ||
// Problem here is that | ||
// `f: |_, i: usize| ...` | ||
// should be | ||
// `f: |_: &_, i: usize| ...` | ||
} |
9 changes: 9 additions & 0 deletions
9
tests/ui/typeck/bad-index-modulo-higher-ranked-regions.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
error[E0608]: cannot index into a value of type `Map<[usize; 1], {closure@$DIR/bad-index-modulo-higher-ranked-regions.rs:23:32: 23:45}>` | ||
--> $DIR/bad-index-modulo-higher-ranked-regions.rs:23:55 | ||
| | ||
LL | Map { inner: [0_usize], f: |_, i: usize| 1_usize }[0]; | ||
| ^^^ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0608`. |