summaryrefslogtreecommitdiffstats
path: root/src/test/ui/mismatched_types
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:11:38 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:13:23 +0000
commit20431706a863f92cb37dc512fef6e48d192aaf2c (patch)
tree2867f13f5fd5437ba628c67d7f87309ccadcd286 /src/test/ui/mismatched_types
parentReleasing progress-linux version 1.65.0+dfsg1-2~progress7.99u1. (diff)
downloadrustc-20431706a863f92cb37dc512fef6e48d192aaf2c.tar.xz
rustc-20431706a863f92cb37dc512fef6e48d192aaf2c.zip
Merging upstream version 1.66.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/mismatched_types')
-rw-r--r--src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr2
-rw-r--r--src/test/ui/mismatched_types/closure-mismatch.stderr2
-rw-r--r--src/test/ui/mismatched_types/fn-variance-1.stderr4
-rw-r--r--src/test/ui/mismatched_types/issue-36053-2.stderr4
-rw-r--r--src/test/ui/mismatched_types/show_module.rs18
-rw-r--r--src/test/ui/mismatched_types/show_module.stderr23
-rw-r--r--src/test/ui/mismatched_types/similar_paths.rs11
-rw-r--r--src/test/ui/mismatched_types/similar_paths.stderr23
-rw-r--r--src/test/ui/mismatched_types/similar_paths_primitive.rs10
-rw-r--r--src/test/ui/mismatched_types/similar_paths_primitive.stderr24
10 files changed, 115 insertions, 6 deletions
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<T> {
+ Some(T),
+ None,
+}
+
+pub fn foo() -> Option<u8> {
+ 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<u8> {
+ | ---------- expected `Option<u8>` 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<T> {
+ | ^^^^^^^^^^^^^^^^^^
+note: enum `Option` is defined in the current crate
+ --> $DIR/similar_paths.rs:1:1
+ |
+LL | enum Option<T> {
+ | ^^^^^^^^^^^^^^
+
+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`.