diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:20:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:20:29 +0000 |
commit | 631cd5845e8de329d0e227aaa707d7ea228b8f8f (patch) | |
tree | a1b87c8f8cad01cf18f7c5f57a08f102771ed303 /tests/ui/typeck | |
parent | Adding debian version 1.69.0+dfsg1-1. (diff) | |
download | rustc-631cd5845e8de329d0e227aaa707d7ea228b8f8f.tar.xz rustc-631cd5845e8de329d0e227aaa707d7ea228b8f8f.zip |
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/typeck')
30 files changed, 213 insertions, 114 deletions
diff --git a/tests/ui/typeck/bad-type-in-vec-contains.stderr b/tests/ui/typeck/bad-type-in-vec-contains.stderr index 0e03388d2..72533ab1f 100644 --- a/tests/ui/typeck/bad-type-in-vec-contains.stderr +++ b/tests/ui/typeck/bad-type-in-vec-contains.stderr @@ -7,7 +7,6 @@ LL | primes.contains(3); | | expected `&_`, found integer | | help: consider borrowing here: `&3` | arguments to this method are incorrect - | here the type of `primes` is inferred to be `[_]` | = note: expected reference `&_` found type `{integer}` diff --git a/tests/ui/typeck/bad-type-in-vec-push.stderr b/tests/ui/typeck/bad-type-in-vec-push.stderr index ae46050c9..1d5337260 100644 --- a/tests/ui/typeck/bad-type-in-vec-push.stderr +++ b/tests/ui/typeck/bad-type-in-vec-push.stderr @@ -1,8 +1,6 @@ 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 `Vec<_>` | | diff --git a/tests/ui/typeck/explain_clone_autoref.stderr b/tests/ui/typeck/explain_clone_autoref.stderr index 4539da438..38cb7fe55 100644 --- a/tests/ui/typeck/explain_clone_autoref.stderr +++ b/tests/ui/typeck/explain_clone_autoref.stderr @@ -14,7 +14,8 @@ LL | nc.clone() | ^^ help: consider annotating `NotClone` with `#[derive(Clone)]` | -LL | #[derive(Clone)] +LL + #[derive(Clone)] +LL | struct NotClone; | error: aborting due to previous error diff --git a/tests/ui/typeck/issue-105946.rs b/tests/ui/typeck/issue-105946.rs index bf01751d5..f53f31138 100644 --- a/tests/ui/typeck/issue-105946.rs +++ b/tests/ui/typeck/issue-105946.rs @@ -1,12 +1,10 @@ fn digit() -> str { - return {}; - //~^ ERROR: mismatched types [E0308] + return {}; + //~^ ERROR: mismatched types [E0308] } fn main() { - let [_y..] = [box 1, box 2]; + let [_y..] = [Box::new(1), Box::new(2)]; //~^ ERROR: cannot find value `_y` in this scope [E0425] //~| ERROR: `X..` patterns in slices are experimental [E0658] - //~| ERROR: box expression syntax is experimental; you can call `Box::new` instead [E0658] - //~| ERROR: box expression syntax is experimental; you can call `Box::new` instead [E0658] //~| ERROR: pattern requires 1 element but array has 2 [E0527] } diff --git a/tests/ui/typeck/issue-105946.stderr b/tests/ui/typeck/issue-105946.stderr index d803de4df..26c3b7fbc 100644 --- a/tests/ui/typeck/issue-105946.stderr +++ b/tests/ui/typeck/issue-105946.stderr @@ -1,49 +1,31 @@ error[E0425]: cannot find value `_y` in this scope --> $DIR/issue-105946.rs:6:10 | -LL | let [_y..] = [box 1, box 2]; +LL | let [_y..] = [Box::new(1), Box::new(2)]; | ^^ not found in this scope error[E0658]: `X..` patterns in slices are experimental --> $DIR/issue-105946.rs:6:10 | -LL | let [_y..] = [box 1, box 2]; +LL | let [_y..] = [Box::new(1), Box::new(2)]; | ^^^^ | = note: see issue #67264 <https://github.com/rust-lang/rust/issues/67264> for more information = help: add `#![feature(half_open_range_patterns_in_slices)]` to the crate attributes to enable -error[E0658]: box expression syntax is experimental; you can call `Box::new` instead - --> $DIR/issue-105946.rs:6:19 - | -LL | let [_y..] = [box 1, box 2]; - | ^^^^^ - | - = note: see issue #49733 <https://github.com/rust-lang/rust/issues/49733> for more information - = help: add `#![feature(box_syntax)]` to the crate attributes to enable - -error[E0658]: box expression syntax is experimental; you can call `Box::new` instead - --> $DIR/issue-105946.rs:6:26 - | -LL | let [_y..] = [box 1, box 2]; - | ^^^^^ - | - = note: see issue #49733 <https://github.com/rust-lang/rust/issues/49733> for more information - = help: add `#![feature(box_syntax)]` to the crate attributes to enable - error[E0308]: mismatched types - --> $DIR/issue-105946.rs:2:10 + --> $DIR/issue-105946.rs:2:12 | -LL | return {}; - | ^^ expected `str`, found `()` +LL | return {}; + | ^^ expected `str`, found `()` error[E0527]: pattern requires 1 element but array has 2 --> $DIR/issue-105946.rs:6:9 | -LL | let [_y..] = [box 1, box 2]; +LL | let [_y..] = [Box::new(1), Box::new(2)]; | ^^^^^^ expected 2 elements -error: aborting due to 6 previous errors +error: aborting due to 4 previous errors Some errors have detailed explanations: E0308, E0425, E0527, E0658. For more information about an error, try `rustc --explain E0308`. diff --git a/tests/ui/typeck/issue-107775.stderr b/tests/ui/typeck/issue-107775.stderr index 9ee9c022c..b97e74b7e 100644 --- a/tests/ui/typeck/issue-107775.stderr +++ b/tests/ui/typeck/issue-107775.stderr @@ -2,9 +2,9 @@ error[E0308]: mismatched types --> $DIR/issue-107775.rs:35:16 | LL | map.insert(1, Struct::do_something); - | - -------------------- this is of type `fn(u8) -> Pin<Box<dyn Future<Output = ()> + Send>> {<Struct as Trait>::do_something::<'_>}`, which causes `map` to be inferred as `HashMap<{integer}, fn(u8) -> Pin<Box<dyn Future<Output = ()> + Send>> {<Struct as Trait>::do_something::<'_>}>` - | | - | this is of type `{integer}`, which causes `map` to be inferred as `HashMap<{integer}, fn(u8) -> Pin<Box<dyn Future<Output = ()> + Send>> {<Struct as Trait>::do_something::<'_>}>` + | --- -------------------- this argument has type `fn(u8) -> Pin<Box<dyn Future<Output = ()> + Send>> {<Struct as Trait>::do_something::<'_>}`... + | | + | ... which causes `map` to have type `HashMap<{integer}, fn(u8) -> Pin<Box<dyn Future<Output = ()> + Send>> {<Struct as Trait>::do_something::<'_>}>` LL | Self { map } | ^^^ expected `HashMap<u16, fn(u8) -> Pin<...>>`, found `HashMap<{integer}, ...>` | diff --git a/tests/ui/typeck/issue-110052.rs b/tests/ui/typeck/issue-110052.rs new file mode 100644 index 000000000..f124b58b5 --- /dev/null +++ b/tests/ui/typeck/issue-110052.rs @@ -0,0 +1,12 @@ +// Makes sure we deal with escaping lifetimes *above* INNERMOST when +// suggesting trait for ambiguous associated type. + +impl<I, V> Validator<I> for () +where + for<'iter> dyn Validator<<&'iter I>::Item>:, + //~^ ERROR ambiguous associated type +{} + +pub trait Validator<T> {} + +fn main() {} diff --git a/tests/ui/typeck/issue-110052.stderr b/tests/ui/typeck/issue-110052.stderr new file mode 100644 index 000000000..0c15c03a7 --- /dev/null +++ b/tests/ui/typeck/issue-110052.stderr @@ -0,0 +1,9 @@ +error[E0223]: ambiguous associated type + --> $DIR/issue-110052.rs:6:30 + | +LL | for<'iter> dyn Validator<<&'iter I>::Item>:, + | ^^^^^^^^^^^^^^^^ help: use the fully-qualified path: `<&'iter I as IntoIterator>::Item` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0223`. diff --git a/tests/ui/typeck/issue-43189.stderr b/tests/ui/typeck/issue-43189.stderr index caf7530b8..c072e6a08 100644 --- a/tests/ui/typeck/issue-43189.stderr +++ b/tests/ui/typeck/issue-43189.stderr @@ -12,7 +12,7 @@ LL | fn a(&self) {} = help: items from traits can only be used if the trait is in scope help: the following trait is implemented but not in scope; perhaps add a `use` for it: | -LL | use xcrate_issue_43189_b::xcrate_issue_43189_a::A; +LL + use xcrate_issue_43189_b::xcrate_issue_43189_a::A; | error: aborting due to previous error diff --git a/tests/ui/typeck/issue-87935-unsized-box-expr.rs b/tests/ui/typeck/issue-87935-unsized-box-expr.rs deleted file mode 100644 index cd2a82074..000000000 --- a/tests/ui/typeck/issue-87935-unsized-box-expr.rs +++ /dev/null @@ -1,10 +0,0 @@ -#![feature(box_syntax)] -// Box expression needs to be movable, and hence has to be of a Sized type. -fn main() { - let _x: Box<[u32]> = box { loop {} }; - //~^ ERROR: the size for values of type `[u32]` cannot be known at compilation time - - // Check that a deduced size does not cause issues. - let _y: Box<[u32]> = box []; - let _z: Box<[u32; 0]> = box { loop {} }; -} diff --git a/tests/ui/typeck/issue-87935-unsized-box-expr.stderr b/tests/ui/typeck/issue-87935-unsized-box-expr.stderr deleted file mode 100644 index 9ff822352..000000000 --- a/tests/ui/typeck/issue-87935-unsized-box-expr.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0277]: the size for values of type `[u32]` cannot be known at compilation time - --> $DIR/issue-87935-unsized-box-expr.rs:4:30 - | -LL | let _x: Box<[u32]> = box { loop {} }; - | ^^^^^^^^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `[u32]` - = note: the type of a box expression must have a statically known size - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/typeck/issue-90164.stderr b/tests/ui/typeck/issue-90164.stderr index 1e2f1bae3..8586f5222 100644 --- a/tests/ui/typeck/issue-90164.stderr +++ b/tests/ui/typeck/issue-90164.stderr @@ -6,7 +6,8 @@ LL | copy(r, w); | | | required by a bound introduced by this call | - = note: consider using `Box::pin` + = note: consider using the `pin!` macro + consider using `Box::pin` if you need to access the pinned value outside of the current scope note: required by a bound in `copy` --> $DIR/issue-90164.rs:1:12 | diff --git a/tests/ui/typeck/lazy-norm/cast-checks-handling-projections.rs b/tests/ui/typeck/lazy-norm/cast-checks-handling-projections.rs deleted file mode 100644 index 5ff567cd0..000000000 --- a/tests/ui/typeck/lazy-norm/cast-checks-handling-projections.rs +++ /dev/null @@ -1,6 +0,0 @@ -// compile-flags: -Ztrait-solver=next -// known-bug: unknown - -fn main() { - (0u8 + 0u8) as char; -} diff --git a/tests/ui/typeck/lazy-norm/cast-checks-handling-projections.stderr b/tests/ui/typeck/lazy-norm/cast-checks-handling-projections.stderr deleted file mode 100644 index 6b09ccd52..000000000 --- a/tests/ui/typeck/lazy-norm/cast-checks-handling-projections.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0271]: type mismatch resolving `char == <u8 as Add>::Output` - --> $DIR/cast-checks-handling-projections.rs:5:5 - | -LL | (0u8 + 0u8) as char; - | ^^^^^^^^^^^ types differ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0271`. diff --git a/tests/ui/typeck/lazy-norm/equating-projection-cyclically.rs b/tests/ui/typeck/lazy-norm/equating-projection-cyclically.rs deleted file mode 100644 index 019c6e81c..000000000 --- a/tests/ui/typeck/lazy-norm/equating-projection-cyclically.rs +++ /dev/null @@ -1,24 +0,0 @@ -// compile-flags: -Ztrait-solver=next -// known-bug: unknown - -trait Test { - type Assoc; -} - -fn transform<T: Test>(x: T) -> T::Assoc { - todo!() -} - -impl Test for i32 { - type Assoc = i32; -} - -impl Test for String { - type Assoc = String; -} - -fn main() { - let mut x = Default::default(); - x = transform(x); - x = 1i32; -} diff --git a/tests/ui/typeck/lazy-norm/equating-projection-cyclically.stderr b/tests/ui/typeck/lazy-norm/equating-projection-cyclically.stderr deleted file mode 100644 index 57cbc65a1..000000000 --- a/tests/ui/typeck/lazy-norm/equating-projection-cyclically.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/equating-projection-cyclically.rs:22:19 - | -LL | x = transform(x); - | ^ expected inferred type, found associated type - | - = note: expected type `_` - found associated type `<_ as Test>::Assoc` - = help: consider constraining the associated type `<_ as Test>::Assoc` to `_` - = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/typeck/output-type-mismatch.rs b/tests/ui/typeck/output-type-mismatch.rs new file mode 100644 index 000000000..35097aa9e --- /dev/null +++ b/tests/ui/typeck/output-type-mismatch.rs @@ -0,0 +1,5 @@ +// error-pattern: mismatched types + +fn f() { } + +fn main() { let i: isize; i = f(); } diff --git a/tests/ui/typeck/output-type-mismatch.stderr b/tests/ui/typeck/output-type-mismatch.stderr new file mode 100644 index 000000000..4507a4df6 --- /dev/null +++ b/tests/ui/typeck/output-type-mismatch.stderr @@ -0,0 +1,11 @@ +error[E0308]: mismatched types + --> $DIR/output-type-mismatch.rs:5:31 + | +LL | fn main() { let i: isize; i = f(); } + | ----- ^^^ expected `isize`, found `()` + | | + | expected due to this type + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/typeck/suppressed-error.rs b/tests/ui/typeck/suppressed-error.rs new file mode 100644 index 000000000..1e39be460 --- /dev/null +++ b/tests/ui/typeck/suppressed-error.rs @@ -0,0 +1,8 @@ +fn main() { + let (x, y) = (); +//~^ ERROR mismatched types +//~| expected unit type `()` +//~| found tuple `(_, _)` +//~| expected `()`, found + return x; +} diff --git a/tests/ui/typeck/suppressed-error.stderr b/tests/ui/typeck/suppressed-error.stderr new file mode 100644 index 000000000..11d70f8a4 --- /dev/null +++ b/tests/ui/typeck/suppressed-error.stderr @@ -0,0 +1,14 @@ +error[E0308]: mismatched types + --> $DIR/suppressed-error.rs:2:9 + | +LL | let (x, y) = (); + | ^^^^^^ -- this expression has type `()` + | | + | expected `()`, found `(_, _)` + | + = note: expected unit type `()` + found tuple `(_, _)` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/typeck/tag-that-dare-not-speak-its-name.rs b/tests/ui/typeck/tag-that-dare-not-speak-its-name.rs new file mode 100644 index 000000000..0e76ec246 --- /dev/null +++ b/tests/ui/typeck/tag-that-dare-not-speak-its-name.rs @@ -0,0 +1,16 @@ +// Issue #876 + +use std::vec::Vec; + +fn last<T>(v: Vec<&T> ) -> std::option::Option<T> { + ::std::panic!(); +} + +fn main() { + let y; + let x : char = last(y); + //~^ ERROR mismatched types + //~| expected type `char` + //~| found enum `Option<_>` + //~| expected `char`, found `Option<_>` +} diff --git a/tests/ui/typeck/tag-that-dare-not-speak-its-name.stderr b/tests/ui/typeck/tag-that-dare-not-speak-its-name.stderr new file mode 100644 index 000000000..f53abe53b --- /dev/null +++ b/tests/ui/typeck/tag-that-dare-not-speak-its-name.stderr @@ -0,0 +1,14 @@ +error[E0308]: mismatched types + --> $DIR/tag-that-dare-not-speak-its-name.rs:11:20 + | +LL | let x : char = last(y); + | ---- ^^^^^^^ expected `char`, found `Option<_>` + | | + | expected due to this + | + = note: expected type `char` + found enum `Option<_>` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/typeck/terr-in-field.rs b/tests/ui/typeck/terr-in-field.rs new file mode 100644 index 000000000..cfe350ef8 --- /dev/null +++ b/tests/ui/typeck/terr-in-field.rs @@ -0,0 +1,17 @@ +struct Foo { + a: isize, + b: isize, +} + +struct Bar { + a: isize, + b: usize, +} + +fn want_foo(f: Foo) {} +fn have_bar(b: Bar) { + want_foo(b); //~ ERROR mismatched types + //~| expected `Foo`, found `Bar` +} + +fn main() {} diff --git a/tests/ui/typeck/terr-in-field.stderr b/tests/ui/typeck/terr-in-field.stderr new file mode 100644 index 000000000..09df4b34b --- /dev/null +++ b/tests/ui/typeck/terr-in-field.stderr @@ -0,0 +1,17 @@ +error[E0308]: mismatched types + --> $DIR/terr-in-field.rs:13:14 + | +LL | want_foo(b); + | -------- ^ expected `Foo`, found `Bar` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/terr-in-field.rs:11:4 + | +LL | fn want_foo(f: Foo) {} + | ^^^^^^^^ ------ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/typeck/terr-sorts.rs b/tests/ui/typeck/terr-sorts.rs new file mode 100644 index 000000000..c1e2f7dae --- /dev/null +++ b/tests/ui/typeck/terr-sorts.rs @@ -0,0 +1,15 @@ +struct Foo { + a: isize, + b: isize, +} + +type Bar = Box<Foo>; + +fn want_foo(f: Foo) {} +fn have_bar(b: Bar) { + want_foo(b); //~ ERROR mismatched types + //~| expected struct `Foo` + //~| found struct `Box<Foo>` +} + +fn main() {} diff --git a/tests/ui/typeck/terr-sorts.stderr b/tests/ui/typeck/terr-sorts.stderr new file mode 100644 index 000000000..8f1975374 --- /dev/null +++ b/tests/ui/typeck/terr-sorts.stderr @@ -0,0 +1,23 @@ +error[E0308]: mismatched types + --> $DIR/terr-sorts.rs:10:14 + | +LL | want_foo(b); + | -------- ^ expected `Foo`, found `Box<Foo>` + | | + | arguments to this function are incorrect + | + = note: expected struct `Foo` + found struct `Box<Foo>` +note: function defined here + --> $DIR/terr-sorts.rs:8:4 + | +LL | fn want_foo(f: Foo) {} + | ^^^^^^^^ ------ +help: consider unboxing the value + | +LL | want_foo(*b); + | + + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/typeck/while-type-error.rs b/tests/ui/typeck/while-type-error.rs new file mode 100644 index 000000000..8098bfcd8 --- /dev/null +++ b/tests/ui/typeck/while-type-error.rs @@ -0,0 +1,3 @@ +// error-pattern: mismatched types + +fn main() { while main { } } diff --git a/tests/ui/typeck/while-type-error.stderr b/tests/ui/typeck/while-type-error.stderr new file mode 100644 index 000000000..529cbff05 --- /dev/null +++ b/tests/ui/typeck/while-type-error.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/while-type-error.rs:3:19 + | +LL | fn main() { while main { } } + | ^^^^ expected `bool`, found fn item + | + = note: expected type `bool` + found fn item `fn() {main}` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/typeck/wrong-ret-type.rs b/tests/ui/typeck/wrong-ret-type.rs new file mode 100644 index 000000000..cbff8dbae --- /dev/null +++ b/tests/ui/typeck/wrong-ret-type.rs @@ -0,0 +1,3 @@ +// error-pattern: mismatched types +fn mk_int() -> usize { let i: isize = 3; return i; } +fn main() { } diff --git a/tests/ui/typeck/wrong-ret-type.stderr b/tests/ui/typeck/wrong-ret-type.stderr new file mode 100644 index 000000000..c686a0b2f --- /dev/null +++ b/tests/ui/typeck/wrong-ret-type.stderr @@ -0,0 +1,16 @@ +error[E0308]: mismatched types + --> $DIR/wrong-ret-type.rs:2:49 + | +LL | fn mk_int() -> usize { let i: isize = 3; return i; } + | ----- ^ expected `usize`, found `isize` + | | + | expected `usize` because of return type + | +help: you can convert an `isize` to a `usize` and panic if the converted value doesn't fit + | +LL | fn mk_int() -> usize { let i: isize = 3; return i.try_into().unwrap(); } + | ++++++++++++++++++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. |