summaryrefslogtreecommitdiffstats
path: root/tests/ui/functions-closures
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
commit218caa410aa38c29984be31a5229b9fa717560ee (patch)
treec54bd55eeb6e4c508940a30e94c0032fbd45d677 /tests/ui/functions-closures
parentReleasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz
rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--tests/ui/functions-closures/auxiliary/fn-abi.rs (renamed from src/test/ui/functions-closures/auxiliary/fn-abi.rs)0
-rw-r--r--tests/ui/functions-closures/call-closure-from-overloaded-op.rs (renamed from src/test/ui/functions-closures/call-closure-from-overloaded-op.rs)0
-rw-r--r--tests/ui/functions-closures/capture-clauses-boxed-closures.rs (renamed from src/test/ui/functions-closures/capture-clauses-boxed-closures.rs)0
-rw-r--r--tests/ui/functions-closures/capture-clauses-unboxed-closures.rs (renamed from src/test/ui/functions-closures/capture-clauses-unboxed-closures.rs)0
-rw-r--r--tests/ui/functions-closures/clone-closure.rs (renamed from src/test/ui/functions-closures/clone-closure.rs)0
-rw-r--r--tests/ui/functions-closures/closure-bounds-can-capture-chan.rs (renamed from src/test/ui/functions-closures/closure-bounds-can-capture-chan.rs)0
-rw-r--r--tests/ui/functions-closures/closure-expected-type/README.md8
-rw-r--r--tests/ui/functions-closures/closure-expected-type/expect-infer-supply-two-infers.rs (renamed from src/test/ui/functions-closures/closure-expected-type/expect-infer-supply-two-infers.rs)0
-rw-r--r--tests/ui/functions-closures/closure-expected-type/issue-38714.rs (renamed from src/test/ui/functions-closures/closure-expected-type/issue-38714.rs)0
-rw-r--r--tests/ui/functions-closures/closure-expected-type/supply-just-return-type.rs (renamed from src/test/ui/functions-closures/closure-expected-type/supply-just-return-type.rs)0
-rw-r--r--tests/ui/functions-closures/closure-expected-type/supply-nothing.rs (renamed from src/test/ui/functions-closures/closure-expected-type/supply-nothing.rs)0
-rw-r--r--tests/ui/functions-closures/closure-immediate.rs (renamed from src/test/ui/functions-closures/closure-immediate.rs)0
-rw-r--r--tests/ui/functions-closures/closure-inference.rs (renamed from src/test/ui/functions-closures/closure-inference.rs)0
-rw-r--r--tests/ui/functions-closures/closure-inference2.rs (renamed from src/test/ui/functions-closures/closure-inference2.rs)0
-rw-r--r--tests/ui/functions-closures/closure-reform.rs (renamed from src/test/ui/functions-closures/closure-reform.rs)0
-rw-r--r--tests/ui/functions-closures/closure-returning-closure.rs (renamed from src/test/ui/functions-closures/closure-returning-closure.rs)0
-rw-r--r--tests/ui/functions-closures/closure-to-fn-coercion.rs (renamed from src/test/ui/functions-closures/closure-to-fn-coercion.rs)0
-rw-r--r--tests/ui/functions-closures/closure_to_fn_coercion-expected-types.rs (renamed from src/test/ui/functions-closures/closure_to_fn_coercion-expected-types.rs)0
-rw-r--r--tests/ui/functions-closures/copy-closure.rs (renamed from src/test/ui/functions-closures/copy-closure.rs)0
-rw-r--r--tests/ui/functions-closures/fn-abi.rs (renamed from src/test/ui/functions-closures/fn-abi.rs)0
-rw-r--r--tests/ui/functions-closures/fn-bare-assign.rs (renamed from src/test/ui/functions-closures/fn-bare-assign.rs)0
-rw-r--r--tests/ui/functions-closures/fn-bare-coerce-to-block.rs (renamed from src/test/ui/functions-closures/fn-bare-coerce-to-block.rs)0
-rw-r--r--tests/ui/functions-closures/fn-bare-item.rs (renamed from src/test/ui/functions-closures/fn-bare-item.rs)0
-rw-r--r--tests/ui/functions-closures/fn-bare-size.rs (renamed from src/test/ui/functions-closures/fn-bare-size.rs)0
-rw-r--r--tests/ui/functions-closures/fn-bare-spawn.rs (renamed from src/test/ui/functions-closures/fn-bare-spawn.rs)0
-rw-r--r--tests/ui/functions-closures/fn-coerce-field.rs (renamed from src/test/ui/functions-closures/fn-coerce-field.rs)0
-rw-r--r--tests/ui/functions-closures/fn-help-with-err-generic-is-not-function.rs (renamed from src/test/ui/functions-closures/fn-help-with-err-generic-is-not-function.rs)0
-rw-r--r--tests/ui/functions-closures/fn-help-with-err-generic-is-not-function.stderr (renamed from src/test/ui/functions-closures/fn-help-with-err-generic-is-not-function.stderr)9
-rw-r--r--tests/ui/functions-closures/fn-help-with-err.rs24
-rw-r--r--tests/ui/functions-closures/fn-help-with-err.stderr27
-rw-r--r--tests/ui/functions-closures/fn-item-type-cast.rs (renamed from src/test/ui/functions-closures/fn-item-type-cast.rs)0
-rw-r--r--tests/ui/functions-closures/fn-item-type-coerce.rs (renamed from src/test/ui/functions-closures/fn-item-type-coerce.rs)0
-rw-r--r--tests/ui/functions-closures/fn-item-type-zero-sized.rs (renamed from src/test/ui/functions-closures/fn-item-type-zero-sized.rs)0
-rw-r--r--tests/ui/functions-closures/fn-lval.rs (renamed from src/test/ui/functions-closures/fn-lval.rs)0
-rw-r--r--tests/ui/functions-closures/fn-type-infer.rs (renamed from src/test/ui/functions-closures/fn-type-infer.rs)0
-rw-r--r--tests/ui/functions-closures/implied-bounds-closure-arg-outlives.rs (renamed from src/test/ui/functions-closures/implied-bounds-closure-arg-outlives.rs)0
-rw-r--r--tests/ui/functions-closures/nullable-pointer-opt-closures.rs (renamed from src/test/ui/functions-closures/nullable-pointer-opt-closures.rs)0
-rw-r--r--tests/ui/functions-closures/parallel-codegen-closures.rs (renamed from src/test/ui/functions-closures/parallel-codegen-closures.rs)0
-rw-r--r--tests/ui/functions-closures/return-from-closure.rs (renamed from src/test/ui/functions-closures/return-from-closure.rs)0
39 files changed, 65 insertions, 3 deletions
diff --git a/src/test/ui/functions-closures/auxiliary/fn-abi.rs b/tests/ui/functions-closures/auxiliary/fn-abi.rs
index ace9fbdfd..ace9fbdfd 100644
--- a/src/test/ui/functions-closures/auxiliary/fn-abi.rs
+++ b/tests/ui/functions-closures/auxiliary/fn-abi.rs
diff --git a/src/test/ui/functions-closures/call-closure-from-overloaded-op.rs b/tests/ui/functions-closures/call-closure-from-overloaded-op.rs
index 8e1c68fd7..8e1c68fd7 100644
--- a/src/test/ui/functions-closures/call-closure-from-overloaded-op.rs
+++ b/tests/ui/functions-closures/call-closure-from-overloaded-op.rs
diff --git a/src/test/ui/functions-closures/capture-clauses-boxed-closures.rs b/tests/ui/functions-closures/capture-clauses-boxed-closures.rs
index bcde50463..bcde50463 100644
--- a/src/test/ui/functions-closures/capture-clauses-boxed-closures.rs
+++ b/tests/ui/functions-closures/capture-clauses-boxed-closures.rs
diff --git a/src/test/ui/functions-closures/capture-clauses-unboxed-closures.rs b/tests/ui/functions-closures/capture-clauses-unboxed-closures.rs
index 206b3d7b6..206b3d7b6 100644
--- a/src/test/ui/functions-closures/capture-clauses-unboxed-closures.rs
+++ b/tests/ui/functions-closures/capture-clauses-unboxed-closures.rs
diff --git a/src/test/ui/functions-closures/clone-closure.rs b/tests/ui/functions-closures/clone-closure.rs
index 1e725d805..1e725d805 100644
--- a/src/test/ui/functions-closures/clone-closure.rs
+++ b/tests/ui/functions-closures/clone-closure.rs
diff --git a/src/test/ui/functions-closures/closure-bounds-can-capture-chan.rs b/tests/ui/functions-closures/closure-bounds-can-capture-chan.rs
index ccb2e201d..ccb2e201d 100644
--- a/src/test/ui/functions-closures/closure-bounds-can-capture-chan.rs
+++ b/tests/ui/functions-closures/closure-bounds-can-capture-chan.rs
diff --git a/tests/ui/functions-closures/closure-expected-type/README.md b/tests/ui/functions-closures/closure-expected-type/README.md
new file mode 100644
index 000000000..0b749040a
--- /dev/null
+++ b/tests/ui/functions-closures/closure-expected-type/README.md
@@ -0,0 +1,8 @@
+Some tests targeted at how we deduce the types of closure arguments.
+This process is a result of some heuristics aimed at combining the
+*expected type* we have with the *actual types* that we get from
+inputs. This investigation was kicked off by #38714, which revealed
+some pretty deep flaws in the ad-hoc way that we were doing things
+before.
+
+See also `tests/ui/closure-expected-type`.
diff --git a/src/test/ui/functions-closures/closure-expected-type/expect-infer-supply-two-infers.rs b/tests/ui/functions-closures/closure-expected-type/expect-infer-supply-two-infers.rs
index 6d5a9876c..6d5a9876c 100644
--- a/src/test/ui/functions-closures/closure-expected-type/expect-infer-supply-two-infers.rs
+++ b/tests/ui/functions-closures/closure-expected-type/expect-infer-supply-two-infers.rs
diff --git a/src/test/ui/functions-closures/closure-expected-type/issue-38714.rs b/tests/ui/functions-closures/closure-expected-type/issue-38714.rs
index e97785b5c..e97785b5c 100644
--- a/src/test/ui/functions-closures/closure-expected-type/issue-38714.rs
+++ b/tests/ui/functions-closures/closure-expected-type/issue-38714.rs
diff --git a/src/test/ui/functions-closures/closure-expected-type/supply-just-return-type.rs b/tests/ui/functions-closures/closure-expected-type/supply-just-return-type.rs
index e9964531c..e9964531c 100644
--- a/src/test/ui/functions-closures/closure-expected-type/supply-just-return-type.rs
+++ b/tests/ui/functions-closures/closure-expected-type/supply-just-return-type.rs
diff --git a/src/test/ui/functions-closures/closure-expected-type/supply-nothing.rs b/tests/ui/functions-closures/closure-expected-type/supply-nothing.rs
index 8665cfc21..8665cfc21 100644
--- a/src/test/ui/functions-closures/closure-expected-type/supply-nothing.rs
+++ b/tests/ui/functions-closures/closure-expected-type/supply-nothing.rs
diff --git a/src/test/ui/functions-closures/closure-immediate.rs b/tests/ui/functions-closures/closure-immediate.rs
index 428fc6bde..428fc6bde 100644
--- a/src/test/ui/functions-closures/closure-immediate.rs
+++ b/tests/ui/functions-closures/closure-immediate.rs
diff --git a/src/test/ui/functions-closures/closure-inference.rs b/tests/ui/functions-closures/closure-inference.rs
index 1877414f0..1877414f0 100644
--- a/src/test/ui/functions-closures/closure-inference.rs
+++ b/tests/ui/functions-closures/closure-inference.rs
diff --git a/src/test/ui/functions-closures/closure-inference2.rs b/tests/ui/functions-closures/closure-inference2.rs
index 4ce132e86..4ce132e86 100644
--- a/src/test/ui/functions-closures/closure-inference2.rs
+++ b/tests/ui/functions-closures/closure-inference2.rs
diff --git a/src/test/ui/functions-closures/closure-reform.rs b/tests/ui/functions-closures/closure-reform.rs
index 0bb6159ff..0bb6159ff 100644
--- a/src/test/ui/functions-closures/closure-reform.rs
+++ b/tests/ui/functions-closures/closure-reform.rs
diff --git a/src/test/ui/functions-closures/closure-returning-closure.rs b/tests/ui/functions-closures/closure-returning-closure.rs
index 17db81687..17db81687 100644
--- a/src/test/ui/functions-closures/closure-returning-closure.rs
+++ b/tests/ui/functions-closures/closure-returning-closure.rs
diff --git a/src/test/ui/functions-closures/closure-to-fn-coercion.rs b/tests/ui/functions-closures/closure-to-fn-coercion.rs
index 87ba488b5..87ba488b5 100644
--- a/src/test/ui/functions-closures/closure-to-fn-coercion.rs
+++ b/tests/ui/functions-closures/closure-to-fn-coercion.rs
diff --git a/src/test/ui/functions-closures/closure_to_fn_coercion-expected-types.rs b/tests/ui/functions-closures/closure_to_fn_coercion-expected-types.rs
index e7a938395..e7a938395 100644
--- a/src/test/ui/functions-closures/closure_to_fn_coercion-expected-types.rs
+++ b/tests/ui/functions-closures/closure_to_fn_coercion-expected-types.rs
diff --git a/src/test/ui/functions-closures/copy-closure.rs b/tests/ui/functions-closures/copy-closure.rs
index 72da02421..72da02421 100644
--- a/src/test/ui/functions-closures/copy-closure.rs
+++ b/tests/ui/functions-closures/copy-closure.rs
diff --git a/src/test/ui/functions-closures/fn-abi.rs b/tests/ui/functions-closures/fn-abi.rs
index ac3a4be33..ac3a4be33 100644
--- a/src/test/ui/functions-closures/fn-abi.rs
+++ b/tests/ui/functions-closures/fn-abi.rs
diff --git a/src/test/ui/functions-closures/fn-bare-assign.rs b/tests/ui/functions-closures/fn-bare-assign.rs
index f5dab3c84..f5dab3c84 100644
--- a/src/test/ui/functions-closures/fn-bare-assign.rs
+++ b/tests/ui/functions-closures/fn-bare-assign.rs
diff --git a/src/test/ui/functions-closures/fn-bare-coerce-to-block.rs b/tests/ui/functions-closures/fn-bare-coerce-to-block.rs
index 922e016dd..922e016dd 100644
--- a/src/test/ui/functions-closures/fn-bare-coerce-to-block.rs
+++ b/tests/ui/functions-closures/fn-bare-coerce-to-block.rs
diff --git a/src/test/ui/functions-closures/fn-bare-item.rs b/tests/ui/functions-closures/fn-bare-item.rs
index a6e6495a4..a6e6495a4 100644
--- a/src/test/ui/functions-closures/fn-bare-item.rs
+++ b/tests/ui/functions-closures/fn-bare-item.rs
diff --git a/src/test/ui/functions-closures/fn-bare-size.rs b/tests/ui/functions-closures/fn-bare-size.rs
index 2ba56eaae..2ba56eaae 100644
--- a/src/test/ui/functions-closures/fn-bare-size.rs
+++ b/tests/ui/functions-closures/fn-bare-size.rs
diff --git a/src/test/ui/functions-closures/fn-bare-spawn.rs b/tests/ui/functions-closures/fn-bare-spawn.rs
index 0d46fe220..0d46fe220 100644
--- a/src/test/ui/functions-closures/fn-bare-spawn.rs
+++ b/tests/ui/functions-closures/fn-bare-spawn.rs
diff --git a/src/test/ui/functions-closures/fn-coerce-field.rs b/tests/ui/functions-closures/fn-coerce-field.rs
index 38bde7b9e..38bde7b9e 100644
--- a/src/test/ui/functions-closures/fn-coerce-field.rs
+++ b/tests/ui/functions-closures/fn-coerce-field.rs
diff --git a/src/test/ui/functions-closures/fn-help-with-err-generic-is-not-function.rs b/tests/ui/functions-closures/fn-help-with-err-generic-is-not-function.rs
index e48ab4aa9..e48ab4aa9 100644
--- a/src/test/ui/functions-closures/fn-help-with-err-generic-is-not-function.rs
+++ b/tests/ui/functions-closures/fn-help-with-err-generic-is-not-function.rs
diff --git a/src/test/ui/functions-closures/fn-help-with-err-generic-is-not-function.stderr b/tests/ui/functions-closures/fn-help-with-err-generic-is-not-function.stderr
index 26bdf460f..9d4ea0115 100644
--- a/src/test/ui/functions-closures/fn-help-with-err-generic-is-not-function.stderr
+++ b/tests/ui/functions-closures/fn-help-with-err-generic-is-not-function.stderr
@@ -2,9 +2,12 @@ error[E0412]: cannot find type `T` in this scope
--> $DIR/fn-help-with-err-generic-is-not-function.rs:2:13
|
LL | impl Struct<T>
- | - ^ not found in this scope
- | |
- | help: you might be missing a type parameter: `<T>`
+ | ^ not found in this scope
+ |
+help: you might be missing a type parameter
+ |
+LL | impl<T> Struct<T>
+ | +++
error[E0412]: cannot find type `T` in this scope
--> $DIR/fn-help-with-err-generic-is-not-function.rs:7:5
diff --git a/tests/ui/functions-closures/fn-help-with-err.rs b/tests/ui/functions-closures/fn-help-with-err.rs
new file mode 100644
index 000000000..612fe1b84
--- /dev/null
+++ b/tests/ui/functions-closures/fn-help-with-err.rs
@@ -0,0 +1,24 @@
+// This test case checks the behavior of typeck::check::method::suggest::is_fn on Ty::Error.
+
+struct Foo;
+
+trait Bar {
+ //~^ NOTE `Bar` defines an item `bar`, perhaps you need to implement it
+ fn bar(&self) {}
+}
+
+impl Bar for Foo {}
+
+fn main() {
+ let arc = std::sync::Arc::new(oops);
+ //~^ ERROR cannot find value `oops` in this scope
+ //~| NOTE not found
+ arc.bar();
+
+ let arc2 = std::sync::Arc::new(|| Foo);
+ arc2.bar();
+ //~^ ERROR no method named `bar`
+ //~| NOTE method not found
+ //~| HELP items from traits can only be used if the trait is implemented and in scope
+ //~| HELP use parentheses to call this closure
+}
diff --git a/tests/ui/functions-closures/fn-help-with-err.stderr b/tests/ui/functions-closures/fn-help-with-err.stderr
new file mode 100644
index 000000000..83a2b1f58
--- /dev/null
+++ b/tests/ui/functions-closures/fn-help-with-err.stderr
@@ -0,0 +1,27 @@
+error[E0425]: cannot find value `oops` in this scope
+ --> $DIR/fn-help-with-err.rs:13:35
+ |
+LL | let arc = std::sync::Arc::new(oops);
+ | ^^^^ not found in this scope
+
+error[E0599]: no method named `bar` found for struct `Arc<[closure@fn-help-with-err.rs:18:36]>` in the current scope
+ --> $DIR/fn-help-with-err.rs:19:10
+ |
+LL | arc2.bar();
+ | ^^^ method not found in `Arc<[closure@fn-help-with-err.rs:18:36]>`
+ |
+ = help: items from traits can only be used if the trait is implemented and in scope
+note: `Bar` defines an item `bar`, perhaps you need to implement it
+ --> $DIR/fn-help-with-err.rs:5:1
+ |
+LL | trait Bar {
+ | ^^^^^^^^^
+help: use parentheses to call this closure
+ |
+LL | arc2().bar();
+ | ++
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0425, E0599.
+For more information about an error, try `rustc --explain E0425`.
diff --git a/src/test/ui/functions-closures/fn-item-type-cast.rs b/tests/ui/functions-closures/fn-item-type-cast.rs
index 4d50ea97b..4d50ea97b 100644
--- a/src/test/ui/functions-closures/fn-item-type-cast.rs
+++ b/tests/ui/functions-closures/fn-item-type-cast.rs
diff --git a/src/test/ui/functions-closures/fn-item-type-coerce.rs b/tests/ui/functions-closures/fn-item-type-coerce.rs
index 7a096764e..7a096764e 100644
--- a/src/test/ui/functions-closures/fn-item-type-coerce.rs
+++ b/tests/ui/functions-closures/fn-item-type-coerce.rs
diff --git a/src/test/ui/functions-closures/fn-item-type-zero-sized.rs b/tests/ui/functions-closures/fn-item-type-zero-sized.rs
index bd9f1ed66..bd9f1ed66 100644
--- a/src/test/ui/functions-closures/fn-item-type-zero-sized.rs
+++ b/tests/ui/functions-closures/fn-item-type-zero-sized.rs
diff --git a/src/test/ui/functions-closures/fn-lval.rs b/tests/ui/functions-closures/fn-lval.rs
index 01079eea4..01079eea4 100644
--- a/src/test/ui/functions-closures/fn-lval.rs
+++ b/tests/ui/functions-closures/fn-lval.rs
diff --git a/src/test/ui/functions-closures/fn-type-infer.rs b/tests/ui/functions-closures/fn-type-infer.rs
index fe6567f22..fe6567f22 100644
--- a/src/test/ui/functions-closures/fn-type-infer.rs
+++ b/tests/ui/functions-closures/fn-type-infer.rs
diff --git a/src/test/ui/functions-closures/implied-bounds-closure-arg-outlives.rs b/tests/ui/functions-closures/implied-bounds-closure-arg-outlives.rs
index 4ac07123d..4ac07123d 100644
--- a/src/test/ui/functions-closures/implied-bounds-closure-arg-outlives.rs
+++ b/tests/ui/functions-closures/implied-bounds-closure-arg-outlives.rs
diff --git a/src/test/ui/functions-closures/nullable-pointer-opt-closures.rs b/tests/ui/functions-closures/nullable-pointer-opt-closures.rs
index 87dacfba2..87dacfba2 100644
--- a/src/test/ui/functions-closures/nullable-pointer-opt-closures.rs
+++ b/tests/ui/functions-closures/nullable-pointer-opt-closures.rs
diff --git a/src/test/ui/functions-closures/parallel-codegen-closures.rs b/tests/ui/functions-closures/parallel-codegen-closures.rs
index 79759daba..79759daba 100644
--- a/src/test/ui/functions-closures/parallel-codegen-closures.rs
+++ b/tests/ui/functions-closures/parallel-codegen-closures.rs
diff --git a/src/test/ui/functions-closures/return-from-closure.rs b/tests/ui/functions-closures/return-from-closure.rs
index 656a95f12..656a95f12 100644
--- a/src/test/ui/functions-closures/return-from-closure.rs
+++ b/tests/ui/functions-closures/return-from-closure.rs