summaryrefslogtreecommitdiffstats
path: root/tests/ui/inference
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:59:35 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:59:35 +0000
commitd1b2d29528b7794b41e66fc2136e395a02f8529b (patch)
treea4a17504b260206dec3cf55b2dca82929a348ac2 /tests/ui/inference
parentReleasing progress-linux version 1.72.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.tar.xz
rustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.zip
Merging upstream version 1.73.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/inference')
-rw-r--r--tests/ui/inference/issue-113354.fixed4
-rw-r--r--tests/ui/inference/issue-113354.rs4
-rw-r--r--tests/ui/inference/issue-113354.stderr14
-rw-r--r--tests/ui/inference/need_type_info/infer-var-for-self-param.rs7
-rw-r--r--tests/ui/inference/need_type_info/infer-var-for-self-param.stderr14
-rw-r--r--tests/ui/inference/need_type_info/issue-113264-incorrect-impl-trait-in-path-suggestion.rs12
-rw-r--r--tests/ui/inference/need_type_info/issue-113264-incorrect-impl-trait-in-path-suggestion.stderr14
-rw-r--r--tests/ui/inference/str-as-char.fixed1
-rw-r--r--tests/ui/inference/str-as-char.rs1
-rw-r--r--tests/ui/inference/str-as-char.stderr13
-rw-r--r--tests/ui/inference/type-infer-generalize-ty-var.rs4
11 files changed, 86 insertions, 2 deletions
diff --git a/tests/ui/inference/issue-113354.fixed b/tests/ui/inference/issue-113354.fixed
new file mode 100644
index 000000000..804db985a
--- /dev/null
+++ b/tests/ui/inference/issue-113354.fixed
@@ -0,0 +1,4 @@
+//run-rustfix
+fn main() {
+ let _ = || { while let Some(_) = Some(1) { } }; //~ ERROR mismatched types
+}
diff --git a/tests/ui/inference/issue-113354.rs b/tests/ui/inference/issue-113354.rs
new file mode 100644
index 000000000..ec33d1f8b
--- /dev/null
+++ b/tests/ui/inference/issue-113354.rs
@@ -0,0 +1,4 @@
+//run-rustfix
+fn main() {
+ let _ = || { while Some(_) = Some(1) { } }; //~ ERROR mismatched types
+}
diff --git a/tests/ui/inference/issue-113354.stderr b/tests/ui/inference/issue-113354.stderr
new file mode 100644
index 000000000..045a5aa7b
--- /dev/null
+++ b/tests/ui/inference/issue-113354.stderr
@@ -0,0 +1,14 @@
+error[E0308]: mismatched types
+ --> $DIR/issue-113354.rs:3:24
+ |
+LL | let _ = || { while Some(_) = Some(1) { } };
+ | ^^^^^^^^^^^^^^^^^ expected `bool`, found `()`
+ |
+help: consider adding `let`
+ |
+LL | let _ = || { while let Some(_) = Some(1) { } };
+ | +++
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/inference/need_type_info/infer-var-for-self-param.rs b/tests/ui/inference/need_type_info/infer-var-for-self-param.rs
new file mode 100644
index 000000000..51ac7943f
--- /dev/null
+++ b/tests/ui/inference/need_type_info/infer-var-for-self-param.rs
@@ -0,0 +1,7 @@
+// Regression test for #113610 where we ICEd when trying to print
+// inference variables created by instantiating the self type parameter.
+
+fn main() {
+ let _ = (Default::default(),);
+ //~^ ERROR cannot call associated function on trait
+}
diff --git a/tests/ui/inference/need_type_info/infer-var-for-self-param.stderr b/tests/ui/inference/need_type_info/infer-var-for-self-param.stderr
new file mode 100644
index 000000000..36d754693
--- /dev/null
+++ b/tests/ui/inference/need_type_info/infer-var-for-self-param.stderr
@@ -0,0 +1,14 @@
+error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type
+ --> $DIR/infer-var-for-self-param.rs:5:14
+ |
+LL | let _ = (Default::default(),);
+ | ^^^^^^^^^^^^^^^^ cannot call associated function of trait
+ |
+help: use a fully-qualified path to a specific available implementation
+ |
+LL | let _ = (</* self type */ as Default>::default(),);
+ | +++++++++++++++++++ +
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0790`.
diff --git a/tests/ui/inference/need_type_info/issue-113264-incorrect-impl-trait-in-path-suggestion.rs b/tests/ui/inference/need_type_info/issue-113264-incorrect-impl-trait-in-path-suggestion.rs
new file mode 100644
index 000000000..5a893f2d8
--- /dev/null
+++ b/tests/ui/inference/need_type_info/issue-113264-incorrect-impl-trait-in-path-suggestion.rs
@@ -0,0 +1,12 @@
+trait T {}
+
+struct S {}
+
+impl S {
+ fn owo(&self, _: Option<&impl T>) {}
+}
+
+fn main() {
+ (S {}).owo(None)
+ //~^ ERROR type annotations needed
+}
diff --git a/tests/ui/inference/need_type_info/issue-113264-incorrect-impl-trait-in-path-suggestion.stderr b/tests/ui/inference/need_type_info/issue-113264-incorrect-impl-trait-in-path-suggestion.stderr
new file mode 100644
index 000000000..0ec219415
--- /dev/null
+++ b/tests/ui/inference/need_type_info/issue-113264-incorrect-impl-trait-in-path-suggestion.stderr
@@ -0,0 +1,14 @@
+error[E0282]: type annotations needed
+ --> $DIR/issue-113264-incorrect-impl-trait-in-path-suggestion.rs:10:16
+ |
+LL | (S {}).owo(None)
+ | ^^^^ cannot infer type of the type parameter `T` declared on the enum `Option`
+ |
+help: consider specifying the generic argument
+ |
+LL | (S {}).owo(None::<&_>)
+ | ++++++
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0282`.
diff --git a/tests/ui/inference/str-as-char.fixed b/tests/ui/inference/str-as-char.fixed
index 6aea809cb..911b067c4 100644
--- a/tests/ui/inference/str-as-char.fixed
+++ b/tests/ui/inference/str-as-char.fixed
@@ -7,4 +7,5 @@ fn main() {
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
+ let _: &str = "\"\"\\\"\\\"\\\\\""; //~ ERROR character literal may only contain one codepoint
}
diff --git a/tests/ui/inference/str-as-char.rs b/tests/ui/inference/str-as-char.rs
index eaa8d788c..832bc871a 100644
--- a/tests/ui/inference/str-as-char.rs
+++ b/tests/ui/inference/str-as-char.rs
@@ -7,4 +7,5 @@ fn main() {
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
+ let _: &str = '"\"\\"\\\"\\\\"'; //~ ERROR character literal may only contain one codepoint
}
diff --git a/tests/ui/inference/str-as-char.stderr b/tests/ui/inference/str-as-char.stderr
index 2c84dac8e..216f4cda6 100644
--- a/tests/ui/inference/str-as-char.stderr
+++ b/tests/ui/inference/str-as-char.stderr
@@ -20,6 +20,17 @@ 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:10: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
|
@@ -33,6 +44,6 @@ help: if you meant to write a `str` literal, use double quotes
LL | let _: &str = "a";
| ~~~
-error: aborting due to 3 previous errors
+error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/inference/type-infer-generalize-ty-var.rs b/tests/ui/inference/type-infer-generalize-ty-var.rs
index a3d6916cb..8b4a8c32b 100644
--- a/tests/ui/inference/type-infer-generalize-ty-var.rs
+++ b/tests/ui/inference/type-infer-generalize-ty-var.rs
@@ -1,4 +1,6 @@
-// run-pass
+// check-pass
+// revisions: current next
+//[next] compile-flags: -Ztrait-solver=next
#![allow(non_upper_case_globals)]
#![allow(dead_code)]