-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't suggest nonsense suggestions for unconstrained type vars in not…
…e_source_of_type_mismatch_constraint
- Loading branch information
1 parent
8e47113
commit ac5aa8c
Showing
3 changed files
with
43 additions
and
2 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
17 changes: 17 additions & 0 deletions
17
tests/ui/type/type-check/point-at-inference-issue-116155.rs
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,17 @@ | ||
struct S<T>(T); | ||
|
||
impl<T> S<T> { | ||
fn new() -> Self { | ||
loop {} | ||
} | ||
|
||
fn constrain<F: Fn() -> T>(&self, _f: F) {} | ||
} | ||
|
||
fn main() { | ||
let s = S::new(); | ||
let c = || true; | ||
s.constrain(c); | ||
let _: S<usize> = s; | ||
//~^ ERROR mismatched types | ||
} |
18 changes: 18 additions & 0 deletions
18
tests/ui/type/type-check/point-at-inference-issue-116155.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,18 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/point-at-inference-issue-116155.rs:15:23 | ||
| | ||
LL | s.constrain(c); | ||
| - - this argument has type `{closure@$DIR/point-at-inference-issue-116155.rs:13:13: 13:15}`... | ||
| | | ||
| ... which causes `s` to have type `S<bool>` | ||
LL | let _: S<usize> = s; | ||
| -------- ^ expected `S<usize>`, found `S<bool>` | ||
| | | ||
| expected due to this | ||
| | ||
= note: expected struct `S<usize>` | ||
found struct `S<bool>` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0308`. |