From 20431706a863f92cb37dc512fef6e48d192aaf2c Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:11:38 +0200 Subject: Merging upstream version 1.66.0+dfsg1. Signed-off-by: Daniel Baumann --- .../closure-arg-type-mismatch.stderr | 2 +- .../ui/mismatched_types/closure-mismatch.stderr | 2 +- src/test/ui/mismatched_types/fn-variance-1.stderr | 4 ++-- src/test/ui/mismatched_types/issue-36053-2.stderr | 4 ++-- src/test/ui/mismatched_types/show_module.rs | 18 ++++++++++++++++ src/test/ui/mismatched_types/show_module.stderr | 23 +++++++++++++++++++++ src/test/ui/mismatched_types/similar_paths.rs | 11 ++++++++++ src/test/ui/mismatched_types/similar_paths.stderr | 23 +++++++++++++++++++++ .../ui/mismatched_types/similar_paths_primitive.rs | 10 +++++++++ .../similar_paths_primitive.stderr | 24 ++++++++++++++++++++++ 10 files changed, 115 insertions(+), 6 deletions(-) create mode 100644 src/test/ui/mismatched_types/show_module.rs create mode 100644 src/test/ui/mismatched_types/show_module.stderr create mode 100644 src/test/ui/mismatched_types/similar_paths.rs create mode 100644 src/test/ui/mismatched_types/similar_paths.stderr create mode 100644 src/test/ui/mismatched_types/similar_paths_primitive.rs create mode 100644 src/test/ui/mismatched_types/similar_paths_primitive.stderr (limited to 'src/test/ui/mismatched_types') diff --git a/src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr b/src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr index 71469bfec..92d545b73 100644 --- a/src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr +++ b/src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr @@ -23,7 +23,7 @@ LL | a.iter().map(|_: &(u16, u16)| 45); | expected due to this | = note: expected closure signature `fn(&(u32, u32)) -> _` - found closure signature `for<'r> fn(&'r (u16, u16)) -> _` + found closure signature `for<'a> fn(&'a (u16, u16)) -> _` note: required by a bound in `map` --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL | diff --git a/src/test/ui/mismatched_types/closure-mismatch.stderr b/src/test/ui/mismatched_types/closure-mismatch.stderr index ef76ec63f..a7ef8fa08 100644 --- a/src/test/ui/mismatched_types/closure-mismatch.stderr +++ b/src/test/ui/mismatched_types/closure-mismatch.stderr @@ -13,7 +13,7 @@ error[E0308]: mismatched types LL | baz(|_| ()); | ^^^^^^^^^^^ one type is more general than the other | - = note: expected trait `for<'r> Fn<(&'r (),)>` + = note: expected trait `for<'a> Fn<(&'a (),)>` found trait `Fn<(&(),)>` note: this closure does not fulfill the lifetime requirements --> $DIR/closure-mismatch.rs:8:9 diff --git a/src/test/ui/mismatched_types/fn-variance-1.stderr b/src/test/ui/mismatched_types/fn-variance-1.stderr index eec6d83fe..5794e606e 100644 --- a/src/test/ui/mismatched_types/fn-variance-1.stderr +++ b/src/test/ui/mismatched_types/fn-variance-1.stderr @@ -10,7 +10,7 @@ LL | apply(&3, takes_mut); | required by a bound introduced by this call | = note: expected function signature `fn(&{integer}) -> _` - found function signature `for<'r> fn(&'r mut isize) -> _` + found function signature `for<'a> fn(&'a mut isize) -> _` note: required by a bound in `apply` --> $DIR/fn-variance-1.rs:5:37 | @@ -29,7 +29,7 @@ LL | apply(&mut 3, takes_imm); | required by a bound introduced by this call | = note: expected function signature `fn(&mut {integer}) -> _` - found function signature `for<'r> fn(&'r isize) -> _` + found function signature `for<'a> fn(&'a isize) -> _` note: required by a bound in `apply` --> $DIR/fn-variance-1.rs:5:37 | diff --git a/src/test/ui/mismatched_types/issue-36053-2.stderr b/src/test/ui/mismatched_types/issue-36053-2.stderr index b11ea97d1..906001ca1 100644 --- a/src/test/ui/mismatched_types/issue-36053-2.stderr +++ b/src/test/ui/mismatched_types/issue-36053-2.stderr @@ -6,8 +6,8 @@ LL | once::<&str>("str").fuse().filter(|a: &str| true).count(); | | | expected due to this | - = note: expected closure signature `for<'r> fn(&'r &str) -> _` - found closure signature `for<'r> fn(&'r str) -> _` + = note: expected closure signature `for<'a> fn(&'a &str) -> _` + found closure signature `for<'a> fn(&'a str) -> _` note: required by a bound in `filter` --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL | diff --git a/src/test/ui/mismatched_types/show_module.rs b/src/test/ui/mismatched_types/show_module.rs new file mode 100644 index 000000000..61550b887 --- /dev/null +++ b/src/test/ui/mismatched_types/show_module.rs @@ -0,0 +1,18 @@ +pub mod blah { + pub mod baz { + pub struct Foo; + } +} + +pub mod meh { + pub struct Foo; +} + +pub type Foo = blah::baz::Foo; + +fn foo() -> Foo { + meh::Foo + //~^ ERROR mismatched types [E0308] +} + +fn main() {} diff --git a/src/test/ui/mismatched_types/show_module.stderr b/src/test/ui/mismatched_types/show_module.stderr new file mode 100644 index 000000000..5e48e0955 --- /dev/null +++ b/src/test/ui/mismatched_types/show_module.stderr @@ -0,0 +1,23 @@ +error[E0308]: mismatched types + --> $DIR/show_module.rs:14:5 + | +LL | fn foo() -> Foo { + | --- expected `baz::Foo` because of return type +LL | meh::Foo + | ^^^^^^^^ expected struct `baz::Foo`, found struct `meh::Foo` + | + = note: struct `meh::Foo` and struct `baz::Foo` have similar names, but are actually distinct types +note: struct `meh::Foo` is defined in module `crate::meh` of the current crate + --> $DIR/show_module.rs:8:5 + | +LL | pub struct Foo; + | ^^^^^^^^^^^^^^ +note: struct `baz::Foo` is defined in module `crate::blah::baz` of the current crate + --> $DIR/show_module.rs:3:9 + | +LL | pub struct Foo; + | ^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/mismatched_types/similar_paths.rs b/src/test/ui/mismatched_types/similar_paths.rs new file mode 100644 index 000000000..4b9157f39 --- /dev/null +++ b/src/test/ui/mismatched_types/similar_paths.rs @@ -0,0 +1,11 @@ +enum Option { + Some(T), + None, +} + +pub fn foo() -> Option { + Some(42_u8) + //~^ ERROR mismatched types [E0308] +} + +fn main() {} diff --git a/src/test/ui/mismatched_types/similar_paths.stderr b/src/test/ui/mismatched_types/similar_paths.stderr new file mode 100644 index 000000000..e65ae58d4 --- /dev/null +++ b/src/test/ui/mismatched_types/similar_paths.stderr @@ -0,0 +1,23 @@ +error[E0308]: mismatched types + --> $DIR/similar_paths.rs:7:5 + | +LL | pub fn foo() -> Option { + | ---------- expected `Option` because of return type +LL | Some(42_u8) + | ^^^^^^^^^^^ expected enum `Option`, found enum `std::option::Option` + | + = note: enum `std::option::Option` and enum `Option` have similar names, but are actually distinct types +note: enum `std::option::Option` is defined in crate `core` + --> $SRC_DIR/core/src/option.rs:LL:COL + | +LL | pub enum Option { + | ^^^^^^^^^^^^^^^^^^ +note: enum `Option` is defined in the current crate + --> $DIR/similar_paths.rs:1:1 + | +LL | enum Option { + | ^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/mismatched_types/similar_paths_primitive.rs b/src/test/ui/mismatched_types/similar_paths_primitive.rs new file mode 100644 index 000000000..8f5b7cce4 --- /dev/null +++ b/src/test/ui/mismatched_types/similar_paths_primitive.rs @@ -0,0 +1,10 @@ +#![allow(non_camel_case_types)] + +struct bool; + +fn foo(_: bool) {} + +fn main() { + foo(true); + //~^ ERROR mismatched types [E0308] +} diff --git a/src/test/ui/mismatched_types/similar_paths_primitive.stderr b/src/test/ui/mismatched_types/similar_paths_primitive.stderr new file mode 100644 index 000000000..8a2f73945 --- /dev/null +++ b/src/test/ui/mismatched_types/similar_paths_primitive.stderr @@ -0,0 +1,24 @@ +error[E0308]: mismatched types + --> $DIR/similar_paths_primitive.rs:8:9 + | +LL | foo(true); + | --- ^^^^ expected struct `bool`, found `bool` + | | + | arguments to this function are incorrect + | + = note: bool and struct `bool` have similar names, but are actually distinct types + = note: bool is a primitive defined by the language +note: struct `bool` is defined in the current crate + --> $DIR/similar_paths_primitive.rs:3:1 + | +LL | struct bool; + | ^^^^^^^^^^^ +note: function defined here + --> $DIR/similar_paths_primitive.rs:5:4 + | +LL | fn foo(_: bool) {} + | ^^^ ------- + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. -- cgit v1.2.3