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/inference | |
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/inference')
-rw-r--r-- | tests/ui/inference/char-as-str-single.fixed | 9 | ||||
-rw-r--r-- | tests/ui/inference/char-as-str-single.rs | 9 | ||||
-rw-r--r-- | tests/ui/inference/char-as-str-single.stderr | 15 | ||||
-rw-r--r-- | tests/ui/inference/issue-80409.rs | 36 | ||||
-rw-r--r-- | tests/ui/inference/issue-83606.stderr | 2 | ||||
-rw-r--r-- | tests/ui/inference/need_type_info/concrete-impl.rs | 3 | ||||
-rw-r--r-- | tests/ui/inference/need_type_info/concrete-impl.stderr | 9 | ||||
-rw-r--r-- | tests/ui/inference/need_type_info/issue-109905.rs | 25 | ||||
-rw-r--r-- | tests/ui/inference/need_type_info/issue-109905.stderr | 15 |
9 files changed, 117 insertions, 6 deletions
diff --git a/tests/ui/inference/char-as-str-single.fixed b/tests/ui/inference/char-as-str-single.fixed index bab1854dc..1621a279f 100644 --- a/tests/ui/inference/char-as-str-single.fixed +++ b/tests/ui/inference/char-as-str-single.fixed @@ -10,3 +10,12 @@ fn main() { let _: char = '人'; //~ ERROR mismatched types let _: char = '\''; //~ ERROR mismatched types } + +// regression test for https://github.com/rust-lang/rust/issues/109586 +#[allow(dead_code)] +fn convert_c_to_str(c: char) { + match c { + 'A' => {} //~ ERROR mismatched types + _ => {} + } +} diff --git a/tests/ui/inference/char-as-str-single.rs b/tests/ui/inference/char-as-str-single.rs index 736920643..2903142f1 100644 --- a/tests/ui/inference/char-as-str-single.rs +++ b/tests/ui/inference/char-as-str-single.rs @@ -10,3 +10,12 @@ fn main() { let _: char = "人"; //~ ERROR mismatched types let _: char = "'"; //~ ERROR mismatched types } + +// regression test for https://github.com/rust-lang/rust/issues/109586 +#[allow(dead_code)] +fn convert_c_to_str(c: char) { + match c { + "A" => {} //~ ERROR mismatched types + _ => {} + } +} diff --git a/tests/ui/inference/char-as-str-single.stderr b/tests/ui/inference/char-as-str-single.stderr index 3375ec6ac..9149efe32 100644 --- a/tests/ui/inference/char-as-str-single.stderr +++ b/tests/ui/inference/char-as-str-single.stderr @@ -37,6 +37,19 @@ help: if you meant to write a `char` literal, use single quotes LL | let _: char = '\''; | ~~~~ -error: aborting due to 3 previous errors +error[E0308]: mismatched types + --> $DIR/char-as-str-single.rs:18:9 + | +LL | match c { + | - this expression has type `char` +LL | "A" => {} + | ^^^ expected `char`, found `&str` + | +help: if you meant to write a `char` literal, use single quotes + | +LL | 'A' => {} + | ~~~ + +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/inference/issue-80409.rs b/tests/ui/inference/issue-80409.rs new file mode 100644 index 000000000..80cad6dfc --- /dev/null +++ b/tests/ui/inference/issue-80409.rs @@ -0,0 +1,36 @@ +// check-pass + +#![allow(unreachable_code, unused)] + +use std::marker::PhantomData; + +struct FsmBuilder<TFsm> { + _fsm: PhantomData<TFsm>, +} + +impl<TFsm> FsmBuilder<TFsm> { + fn state(&mut self) -> FsmStateBuilder<TFsm> { + todo!() + } +} + +struct FsmStateBuilder<TFsm> { + _state: PhantomData<TFsm>, +} + +impl<TFsm> FsmStateBuilder<TFsm> { + fn on_entry<TAction: Fn(&mut StateContext<'_, TFsm>)>(&self, _action: TAction) {} +} + +trait Fsm { + type Context; +} + +struct StateContext<'a, TFsm: Fsm> { + context: &'a mut TFsm::Context, +} + +fn main() { + let mut builder: FsmBuilder<usize> = todo!(); + builder.state().on_entry(|_| {}); +} diff --git a/tests/ui/inference/issue-83606.stderr b/tests/ui/inference/issue-83606.stderr index f2ee8692e..97ed53fb3 100644 --- a/tests/ui/inference/issue-83606.stderr +++ b/tests/ui/inference/issue-83606.stderr @@ -4,7 +4,7 @@ error[E0282]: type annotations needed for `[usize; N]` LL | let _ = foo("foo"); | ^ | -help: consider giving this pattern a type, where the the value of const parameter `N` is specified +help: consider giving this pattern a type, where the value of const parameter `N` is specified | LL | let _: [usize; N] = foo("foo"); | ++++++++++++ diff --git a/tests/ui/inference/need_type_info/concrete-impl.rs b/tests/ui/inference/need_type_info/concrete-impl.rs index 72e0e74f3..fc79e6201 100644 --- a/tests/ui/inference/need_type_info/concrete-impl.rs +++ b/tests/ui/inference/need_type_info/concrete-impl.rs @@ -7,10 +7,13 @@ struct Two; struct Struct; impl Ambiguous<One> for Struct {} +//~^ NOTE multiple `impl`s satisfying `Struct: Ambiguous<_>` found impl Ambiguous<Two> for Struct {} fn main() { <Struct as Ambiguous<_>>::method(); //~^ ERROR type annotations needed + //~| NOTE cannot infer type of the type parameter `A` //~| ERROR type annotations needed + //~| NOTE infer type of the type parameter `A` } diff --git a/tests/ui/inference/need_type_info/concrete-impl.stderr b/tests/ui/inference/need_type_info/concrete-impl.stderr index aa3296995..74c3f6cd5 100644 --- a/tests/ui/inference/need_type_info/concrete-impl.stderr +++ b/tests/ui/inference/need_type_info/concrete-impl.stderr @@ -1,20 +1,21 @@ error[E0282]: type annotations needed - --> $DIR/concrete-impl.rs:13:5 + --> $DIR/concrete-impl.rs:14:5 | LL | <Struct as Ambiguous<_>>::method(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `Self` declared on the trait `Ambiguous` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `A` declared on the trait `Ambiguous` error[E0283]: type annotations needed - --> $DIR/concrete-impl.rs:13:5 + --> $DIR/concrete-impl.rs:14:5 | LL | <Struct as Ambiguous<_>>::method(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `Self` declared on the trait `Ambiguous` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `A` declared on the trait `Ambiguous` | note: multiple `impl`s satisfying `Struct: Ambiguous<_>` found --> $DIR/concrete-impl.rs:9:1 | LL | impl Ambiguous<One> for Struct {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | LL | impl Ambiguous<Two> for Struct {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/inference/need_type_info/issue-109905.rs b/tests/ui/inference/need_type_info/issue-109905.rs new file mode 100644 index 000000000..99d10a5ea --- /dev/null +++ b/tests/ui/inference/need_type_info/issue-109905.rs @@ -0,0 +1,25 @@ +// Test that we show the correct type parameter that couldn't be inferred and that we don't +// end up stating nonsense like "type parameter `'a`" which we used to do. + +trait Trait<'a, T> { + fn m(self); +} + +impl<'a, A> Trait<'a, A> for () { + fn m(self) {} +} + +fn qualified() { + <() as Trait<'static, _>>::m(()); + //~^ ERROR type annotations needed + //~| NOTE cannot infer type of the type parameter `T` + +} + +fn unqualified() { + Trait::<'static, _>::m(()); + //~^ ERROR type annotations needed + //~| NOTE cannot infer type of the type parameter `T` +} + +fn main() {} diff --git a/tests/ui/inference/need_type_info/issue-109905.stderr b/tests/ui/inference/need_type_info/issue-109905.stderr new file mode 100644 index 000000000..fcdd50f14 --- /dev/null +++ b/tests/ui/inference/need_type_info/issue-109905.stderr @@ -0,0 +1,15 @@ +error[E0282]: type annotations needed + --> $DIR/issue-109905.rs:13:5 + | +LL | <() as Trait<'static, _>>::m(()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the trait `Trait` + +error[E0282]: type annotations needed + --> $DIR/issue-109905.rs:20:5 + | +LL | Trait::<'static, _>::m(()); + | ^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the trait `Trait` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0282`. |