diff options
| author | Michael Goulet <michael@errs.io> | 2023-01-21 21:54:49 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2023-01-23 17:02:50 +0000 |
| commit | bed3bb53d207c1bf92c26833e8d3d4280550f83e (patch) | |
| tree | 4b566b202437a862ba0ff592926f88518f1f66d0 /tests | |
| parent | c8e6a9e8b6251bbc8276cb78cabe1998deecbed7 (diff) | |
| download | rust-bed3bb53d207c1bf92c26833e8d3d4280550f83e.tar.gz rust-bed3bb53d207c1bf92c26833e8d3d4280550f83e.zip | |
Don't resolve type var roots in point_at_expr_source_of_inferred_type
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/typeck/bad-type-in-vec-push.rs | 14 | ||||
| -rw-r--r-- | tests/ui/typeck/bad-type-in-vec-push.stderr | 20 |
2 files changed, 34 insertions, 0 deletions
diff --git a/tests/ui/typeck/bad-type-in-vec-push.rs b/tests/ui/typeck/bad-type-in-vec-push.rs new file mode 100644 index 00000000000..397e07dc17b --- /dev/null +++ b/tests/ui/typeck/bad-type-in-vec-push.rs @@ -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. +} diff --git a/tests/ui/typeck/bad-type-in-vec-push.stderr b/tests/ui/typeck/bad-type-in-vec-push.stderr new file mode 100644 index 00000000000..a24c49f0e9a --- /dev/null +++ b/tests/ui/typeck/bad-type-in-vec-push.stderr @@ -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`. |
