-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't resolve type var roots in point_at_expr_source_of_inferred_type
- Loading branch information
1 parent
c8e6a9e
commit bed3bb5
Showing
3 changed files
with
37 additions
and
1 deletion.
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,14 @@ | ||
// The error message here still is pretty confusing. | ||
|
||
fn main() { | ||
let mut result = vec![1]; | ||
// The type of `result` is constrained to be `Vec<{integer}>` here. | ||
// But the logic we use to find what expression constrains a type | ||
// is not sophisticated enough to know this. | ||
|
||
let mut vector = Vec::new(); | ||
vector.sort(); | ||
result.push(vector); | ||
//~^ ERROR mismatched types | ||
// So it thinks that the type of `result` is constrained here. | ||
} |
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,20 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/bad-type-in-vec-push.rs:11:17 | ||
| | ||
LL | vector.sort(); | ||
| ------ here the type of `vector` is inferred to be `Vec<_>` | ||
LL | result.push(vector); | ||
| ---- ^^^^^^ | ||
| | | | ||
| | expected integer, found struct `Vec` | ||
| | this is of type `Vec<_>`, which causes `result` to be inferred as `Vec<{integer}>` | ||
| arguments to this method are incorrect | ||
| | ||
= note: expected type `{integer}` | ||
found struct `Vec<_>` | ||
note: associated function defined here | ||
--> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0308`. |