diff options
Diffstat (limited to 'src/test/ui/inference')
19 files changed, 128 insertions, 22 deletions
diff --git a/src/test/ui/inference/char-as-str-single.fixed b/src/test/ui/inference/char-as-str-single.fixed index e401492a8..bab1854dc 100644 --- a/src/test/ui/inference/char-as-str-single.fixed +++ b/src/test/ui/inference/char-as-str-single.fixed @@ -8,4 +8,5 @@ fn main() { let _: char = 'a'; //~ ERROR mismatched types let _: char = '人'; //~ ERROR mismatched types + let _: char = '\''; //~ ERROR mismatched types } diff --git a/src/test/ui/inference/char-as-str-single.rs b/src/test/ui/inference/char-as-str-single.rs index 4f23cea53..736920643 100644 --- a/src/test/ui/inference/char-as-str-single.rs +++ b/src/test/ui/inference/char-as-str-single.rs @@ -8,4 +8,5 @@ fn main() { let _: char = "a"; //~ ERROR mismatched types let _: char = "人"; //~ ERROR mismatched types + let _: char = "'"; //~ ERROR mismatched types } diff --git a/src/test/ui/inference/char-as-str-single.stderr b/src/test/ui/inference/char-as-str-single.stderr index 29075c154..3375ec6ac 100644 --- a/src/test/ui/inference/char-as-str-single.stderr +++ b/src/test/ui/inference/char-as-str-single.stderr @@ -24,6 +24,19 @@ help: if you meant to write a `char` literal, use single quotes LL | let _: char = '人'; | ~~~~ -error: aborting due to 2 previous errors +error[E0308]: mismatched types + --> $DIR/char-as-str-single.rs:11:19 + | +LL | let _: char = "'"; + | ---- ^^^ expected `char`, found `&str` + | | + | expected due to this + | +help: if you meant to write a `char` literal, use single quotes + | +LL | let _: char = '\''; + | ~~~~ + +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/inference/inference-variable-behind-raw-pointer.stderr b/src/test/ui/inference/inference-variable-behind-raw-pointer.stderr index c38f57912..3dea09e7f 100644 --- a/src/test/ui/inference/inference-variable-behind-raw-pointer.stderr +++ b/src/test/ui/inference/inference-variable-behind-raw-pointer.stderr @@ -4,9 +4,9 @@ warning: type annotations needed LL | if data.is_null() {} | ^^^^^^^ | - = note: `#[warn(tyvar_behind_raw_pointer)]` on by default = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! = note: for more information, see issue #46906 <https://github.com/rust-lang/rust/issues/46906> + = note: `#[warn(tyvar_behind_raw_pointer)]` on by default warning: 1 warning emitted diff --git a/src/test/ui/inference/inference_unstable.stderr b/src/test/ui/inference/inference_unstable.stderr index df7a09686..ecbf2641b 100644 --- a/src/test/ui/inference/inference_unstable.stderr +++ b/src/test/ui/inference/inference_unstable.stderr @@ -4,11 +4,11 @@ warning: an associated function with this name may be added to the standard libr LL | assert_eq!('x'.ipu_flatten(), 1); | ^^^^^^^^^^^ | - = note: `#[warn(unstable_name_collisions)]` on by default = warning: once this associated item is added to the standard library, the ambiguity may cause an error or change in behavior! = note: for more information, see issue #48919 <https://github.com/rust-lang/rust/issues/48919> = help: call with fully qualified syntax `inference_unstable_itertools::IpuItertools::ipu_flatten(...)` to keep using the current method = help: add `#![feature(ipu_flatten)]` to the crate attributes to enable `inference_unstable_iterator::IpuIterator::ipu_flatten` + = note: `#[warn(unstable_name_collisions)]` on by default warning: an associated function with this name may be added to the standard library in the future --> $DIR/inference_unstable.rs:19:20 diff --git a/src/test/ui/inference/issue-36053.rs b/src/test/ui/inference/issue-36053.rs new file mode 100644 index 000000000..5c6d07804 --- /dev/null +++ b/src/test/ui/inference/issue-36053.rs @@ -0,0 +1,22 @@ +// run-pass +// Regression test for #36053. ICE was caused due to obligations being +// added to a special, dedicated fulfillment cx during a +// probe. Problem seems to be related to the particular definition of +// `FusedIterator` in std but I was not able to isolate that into an +// external crate. + +use std::iter::FusedIterator; + +struct Thing<'a>(#[allow(unused_tuple_struct_fields)] &'a str); +impl<'a> Iterator for Thing<'a> { + type Item = &'a str; + fn next(&mut self) -> Option<&'a str> { + None + } +} + +impl<'a> FusedIterator for Thing<'a> {} + +fn main() { + Thing("test").fuse().filter(|_| true).count(); +} diff --git a/src/test/ui/inference/issue-71732.stderr b/src/test/ui/inference/issue-71732.stderr index 04673a375..79bee3328 100644 --- a/src/test/ui/inference/issue-71732.stderr +++ b/src/test/ui/inference/issue-71732.stderr @@ -2,7 +2,9 @@ error[E0283]: type annotations needed --> $DIR/issue-71732.rs:18:10 | LL | .get(&"key".into()) - | ^^^ cannot infer type of the type parameter `Q` declared on the associated function `get` + | ^^^ ------------- type must be known at this point + | | + | cannot infer type of the type parameter `Q` declared on the associated function `get` | = note: multiple `impl`s satisfying `String: Borrow<_>` found in the following crates: `alloc`, `core`: - impl Borrow<str> for String; @@ -13,7 +15,7 @@ note: required by a bound in `HashMap::<K, V, S>::get` | LL | K: Borrow<Q>, | ^^^^^^^^^ required by this bound in `HashMap::<K, V, S>::get` -help: consider specifying the type argument in the function call +help: consider specifying the generic argument | LL | .get::<Q>(&"key".into()) | +++++ diff --git a/src/test/ui/inference/issue-86162-1.stderr b/src/test/ui/inference/issue-86162-1.stderr index e395e65fa..4f621b82d 100644 --- a/src/test/ui/inference/issue-86162-1.stderr +++ b/src/test/ui/inference/issue-86162-1.stderr @@ -4,7 +4,7 @@ error[E0283]: type annotations needed LL | foo(gen()); //<- Do not suggest `foo::<impl Clone>()`! | --- ^^^ cannot infer type of the type parameter `T` declared on the function `gen` | | - | type must be known at this point + | required by a bound introduced by this call | = note: cannot satisfy `_: Clone` note: required by a bound in `foo` diff --git a/src/test/ui/inference/issue-86162-2.stderr b/src/test/ui/inference/issue-86162-2.stderr index 30e6e10ea..9aff2cec1 100644 --- a/src/test/ui/inference/issue-86162-2.stderr +++ b/src/test/ui/inference/issue-86162-2.stderr @@ -4,7 +4,7 @@ error[E0283]: type annotations needed LL | Foo::bar(gen()); //<- Do not suggest `Foo::bar::<impl Clone>()`! | -------- ^^^ cannot infer type of the type parameter `T` declared on the function `gen` | | - | type must be known at this point + | required by a bound introduced by this call | = note: cannot satisfy `_: Clone` note: required by a bound in `Foo::bar` diff --git a/src/test/ui/inference/need_type_info/concrete-impl.stderr b/src/test/ui/inference/need_type_info/concrete-impl.stderr index b79d34aff..aa3296995 100644 --- a/src/test/ui/inference/need_type_info/concrete-impl.stderr +++ b/src/test/ui/inference/need_type_info/concrete-impl.stderr @@ -3,11 +3,6 @@ error[E0282]: type annotations needed | LL | <Struct as Ambiguous<_>>::method(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `Self` declared on the trait `Ambiguous` - | -help: consider specifying the generic argument - | -LL | <Struct as Ambiguous::<_>>::method(); - | ~~~~~ error[E0283]: type annotations needed --> $DIR/concrete-impl.rs:13:5 @@ -22,10 +17,6 @@ LL | impl Ambiguous<One> for Struct {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ LL | impl Ambiguous<Two> for Struct {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -help: consider specifying the generic argument - | -LL | <Struct as Ambiguous::<_>>::method(); - | ~~~~~ error: aborting due to 2 previous errors diff --git a/src/test/ui/inference/need_type_info/do-not-suggest-generic-arguments-for-turbofish.rs b/src/test/ui/inference/need_type_info/do-not-suggest-generic-arguments-for-turbofish.rs new file mode 100644 index 000000000..3084f6eac --- /dev/null +++ b/src/test/ui/inference/need_type_info/do-not-suggest-generic-arguments-for-turbofish.rs @@ -0,0 +1,11 @@ +enum OhNo<T, U> { + A(T), + B(U), + C, +} + +fn uwu() { + OhNo::C::<u32, _>; //~ ERROR type annotations needed +} + +fn main() {} diff --git a/src/test/ui/inference/need_type_info/do-not-suggest-generic-arguments-for-turbofish.stderr b/src/test/ui/inference/need_type_info/do-not-suggest-generic-arguments-for-turbofish.stderr new file mode 100644 index 000000000..2ad35ab03 --- /dev/null +++ b/src/test/ui/inference/need_type_info/do-not-suggest-generic-arguments-for-turbofish.stderr @@ -0,0 +1,9 @@ +error[E0282]: type annotations needed + --> $DIR/do-not-suggest-generic-arguments-for-turbofish.rs:8:5 + | +LL | OhNo::C::<u32, _>; + | ^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `U` declared on the enum `OhNo` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0282`. diff --git a/src/test/ui/inference/need_type_info/expr-struct-type-relative-gat.rs b/src/test/ui/inference/need_type_info/expr-struct-type-relative-gat.rs index bcd29bb4e..b0c0d3397 100644 --- a/src/test/ui/inference/need_type_info/expr-struct-type-relative-gat.rs +++ b/src/test/ui/inference/need_type_info/expr-struct-type-relative-gat.rs @@ -1,5 +1,3 @@ -#![feature(generic_associated_types)] - trait Foo { type Output<T>; diff --git a/src/test/ui/inference/need_type_info/expr-struct-type-relative-gat.stderr b/src/test/ui/inference/need_type_info/expr-struct-type-relative-gat.stderr index 65a75b68c..cbc2477de 100644 --- a/src/test/ui/inference/need_type_info/expr-struct-type-relative-gat.stderr +++ b/src/test/ui/inference/need_type_info/expr-struct-type-relative-gat.stderr @@ -1,5 +1,5 @@ error[E0282]: type annotations needed - --> $DIR/expr-struct-type-relative-gat.rs:17:9 + --> $DIR/expr-struct-type-relative-gat.rs:15:9 | LL | Self::Output::Simple {}; | ^^^^^^^^^^^^ cannot infer type for type parameter `T` declared on the associated type `Output` diff --git a/src/test/ui/inference/need_type_info/issue-103053.rs b/src/test/ui/inference/need_type_info/issue-103053.rs new file mode 100644 index 000000000..05169666f --- /dev/null +++ b/src/test/ui/inference/need_type_info/issue-103053.rs @@ -0,0 +1,18 @@ +trait TypeMapper { + type MapType; +} + +type Mapped<T> = <T as TypeMapper>::MapType; + +struct Test {} + +impl TypeMapper for () { + type MapType = Test; +} + +fn test() { + Mapped::<()> {}; + None; //~ ERROR type annotations needed +} + +fn main() {} diff --git a/src/test/ui/inference/need_type_info/issue-103053.stderr b/src/test/ui/inference/need_type_info/issue-103053.stderr new file mode 100644 index 000000000..84f0475d8 --- /dev/null +++ b/src/test/ui/inference/need_type_info/issue-103053.stderr @@ -0,0 +1,14 @@ +error[E0282]: type annotations needed + --> $DIR/issue-103053.rs:15:5 + | +LL | None; + | ^^^^ cannot infer type of the type parameter `T` declared on the enum `Option` + | +help: consider specifying the generic argument + | +LL | None::<T>; + | +++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0282`. diff --git a/src/test/ui/inference/str-as-char.fixed b/src/test/ui/inference/str-as-char.fixed index 09f3dec5a..6aea809cb 100644 --- a/src/test/ui/inference/str-as-char.fixed +++ b/src/test/ui/inference/str-as-char.fixed @@ -4,5 +4,7 @@ // run-rustfix fn main() { - let _: &str = "a"; //~ ERROR mismatched types + let _: &str = "a"; //~ ERROR mismatched types + let _: &str = "\"\"\""; //~ ERROR character literal may only contain one codepoint + let _: &str = "\"\"\""; //~ ERROR character literal may only contain one codepoint } diff --git a/src/test/ui/inference/str-as-char.rs b/src/test/ui/inference/str-as-char.rs index 7092a6124..eaa8d788c 100644 --- a/src/test/ui/inference/str-as-char.rs +++ b/src/test/ui/inference/str-as-char.rs @@ -4,5 +4,7 @@ // run-rustfix fn main() { - let _: &str = 'a'; //~ ERROR mismatched types + let _: &str = 'a'; //~ ERROR mismatched types + let _: &str = '"""'; //~ ERROR character literal may only contain one codepoint + let _: &str = '\"\"\"'; //~ ERROR character literal may only contain one codepoint } diff --git a/src/test/ui/inference/str-as-char.stderr b/src/test/ui/inference/str-as-char.stderr index ebbe7c80f..2c84dac8e 100644 --- a/src/test/ui/inference/str-as-char.stderr +++ b/src/test/ui/inference/str-as-char.stderr @@ -1,3 +1,25 @@ +error: character literal may only contain one codepoint + --> $DIR/str-as-char.rs:8:19 + | +LL | let _: &str = '"""'; + | ^^^^^ + | +help: if you meant to write a `str` literal, use double quotes + | +LL | let _: &str = "\"\"\""; + | ~~~~~~~~ + +error: character literal may only contain one codepoint + --> $DIR/str-as-char.rs:9:19 + | +LL | let _: &str = '\"\"\"'; + | ^^^^^^^^ + | +help: if you meant to write a `str` literal, use double quotes + | +LL | let _: &str = "\"\"\""; + | ~~~~~~~~ + error[E0308]: mismatched types --> $DIR/str-as-char.rs:7:19 | @@ -11,6 +33,6 @@ help: if you meant to write a `str` literal, use double quotes LL | let _: &str = "a"; | ~~~ -error: aborting due to previous error +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0308`. |