summaryrefslogtreecommitdiffstats
path: root/tests/ui/self
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
commitef24de24a82fe681581cc130f342363c47c0969a (patch)
tree0d494f7e1a38b95c92426f58fe6eaa877303a86c /tests/ui/self
parentReleasing progress-linux version 1.74.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-ef24de24a82fe681581cc130f342363c47c0969a.tar.xz
rustc-ef24de24a82fe681581cc130f342363c47c0969a.zip
Merging upstream version 1.75.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/self')
-rw-r--r--tests/ui/self/arbitrary-self-from-method-substs.default.stderr13
-rw-r--r--tests/ui/self/arbitrary-self-from-method-substs.feature.stderr (renamed from tests/ui/self/arbitrary-self-from-method-substs.stderr)2
-rw-r--r--tests/ui/self/arbitrary-self-from-method-substs.rs8
-rw-r--r--tests/ui/self/arbitrary-self-types-not-object-safe.curr.stderr2
-rw-r--r--tests/ui/self/arbitrary-self-types-not-object-safe.object_safe_for_dispatch.stderr1
-rw-r--r--tests/ui/self/arbitrary_self_types_needing_mut_pin.fixed3
-rw-r--r--tests/ui/self/arbitrary_self_types_needing_mut_pin.stderr10
-rw-r--r--tests/ui/self/self-impl.stderr4
-rw-r--r--tests/ui/self/self_type_keyword.rs2
-rw-r--r--tests/ui/self/self_type_keyword.stderr27
10 files changed, 53 insertions, 19 deletions
diff --git a/tests/ui/self/arbitrary-self-from-method-substs.default.stderr b/tests/ui/self/arbitrary-self-from-method-substs.default.stderr
new file mode 100644
index 000000000..cbf5e6c54
--- /dev/null
+++ b/tests/ui/self/arbitrary-self-from-method-substs.default.stderr
@@ -0,0 +1,13 @@
+error[E0658]: `R` cannot be used as the type of `self` without the `arbitrary_self_types` feature
+ --> $DIR/arbitrary-self-from-method-substs.rs:8:43
+ |
+LL | fn get<R: Deref<Target = Self>>(self: R) -> u32 {
+ | ^
+ |
+ = note: see issue #44874 <https://github.com/rust-lang/rust/issues/44874> for more information
+ = help: add `#![feature(arbitrary_self_types)]` to the crate attributes to enable
+ = help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0658`.
diff --git a/tests/ui/self/arbitrary-self-from-method-substs.stderr b/tests/ui/self/arbitrary-self-from-method-substs.feature.stderr
index 6c252fadf..7378d53c3 100644
--- a/tests/ui/self/arbitrary-self-from-method-substs.stderr
+++ b/tests/ui/self/arbitrary-self-from-method-substs.feature.stderr
@@ -1,5 +1,5 @@
error[E0308]: mismatched types
- --> $DIR/arbitrary-self-from-method-substs.rs:14:5
+ --> $DIR/arbitrary-self-from-method-substs.rs:16:5
|
LL | foo.get::<&Foo>();
| ^^^ expected `&Foo`, found `Foo`
diff --git a/tests/ui/self/arbitrary-self-from-method-substs.rs b/tests/ui/self/arbitrary-self-from-method-substs.rs
index 0f911a208..004445dc3 100644
--- a/tests/ui/self/arbitrary-self-from-method-substs.rs
+++ b/tests/ui/self/arbitrary-self-from-method-substs.rs
@@ -1,10 +1,12 @@
-#![feature(arbitrary_self_types)]
+// revisions: default feature
+#![cfg_attr(feature, feature(arbitrary_self_types))]
use std::ops::Deref;
struct Foo(u32);
impl Foo {
- fn get<R: Deref<Target=Self>>(self: R) -> u32 {
+ fn get<R: Deref<Target = Self>>(self: R) -> u32 {
+ //[default]~^ ERROR: `R` cannot be used as the type of `self`
self.0
}
}
@@ -12,5 +14,5 @@ impl Foo {
fn main() {
let mut foo = Foo(1);
foo.get::<&Foo>();
- //~^ ERROR mismatched types
+ //[feature]~^ ERROR mismatched types
}
diff --git a/tests/ui/self/arbitrary-self-types-not-object-safe.curr.stderr b/tests/ui/self/arbitrary-self-types-not-object-safe.curr.stderr
index 13591f5b6..fdd18c6b3 100644
--- a/tests/ui/self/arbitrary-self-types-not-object-safe.curr.stderr
+++ b/tests/ui/self/arbitrary-self-types-not-object-safe.curr.stderr
@@ -14,6 +14,7 @@ LL | trait Foo {
| --- this trait cannot be made into an object...
LL | fn foo(self: &Rc<Self>) -> usize;
| ^^^^^^^^^ ...because method `foo`'s `self` parameter cannot be dispatched on
+ = help: only type `usize` implements the trait, consider using it directly instead
error[E0038]: the trait `Foo` cannot be made into an object
--> $DIR/arbitrary-self-types-not-object-safe.rs:33:13
@@ -31,6 +32,7 @@ LL | trait Foo {
| --- this trait cannot be made into an object...
LL | fn foo(self: &Rc<Self>) -> usize;
| ^^^^^^^^^ ...because method `foo`'s `self` parameter cannot be dispatched on
+ = help: only type `usize` implements the trait, consider using it directly instead
= note: required for the cast from `Rc<usize>` to `Rc<dyn Foo>`
error: aborting due to 2 previous errors
diff --git a/tests/ui/self/arbitrary-self-types-not-object-safe.object_safe_for_dispatch.stderr b/tests/ui/self/arbitrary-self-types-not-object-safe.object_safe_for_dispatch.stderr
index 593f70535..0a567ddcc 100644
--- a/tests/ui/self/arbitrary-self-types-not-object-safe.object_safe_for_dispatch.stderr
+++ b/tests/ui/self/arbitrary-self-types-not-object-safe.object_safe_for_dispatch.stderr
@@ -14,6 +14,7 @@ LL | trait Foo {
| --- this trait cannot be made into an object...
LL | fn foo(self: &Rc<Self>) -> usize;
| ^^^^^^^^^ ...because method `foo`'s `self` parameter cannot be dispatched on
+ = help: only type `usize` implements the trait, consider using it directly instead
= note: required for the cast from `Rc<usize>` to `Rc<dyn Foo>`
error: aborting due to previous error
diff --git a/tests/ui/self/arbitrary_self_types_needing_mut_pin.fixed b/tests/ui/self/arbitrary_self_types_needing_mut_pin.fixed
index ccd65ff40..a400a1672 100644
--- a/tests/ui/self/arbitrary_self_types_needing_mut_pin.fixed
+++ b/tests/ui/self/arbitrary_self_types_needing_mut_pin.fixed
@@ -8,5 +8,6 @@ impl S {
}
fn main() {
- Pin::new(&mut S).x(); //~ ERROR no method named `x` found
+ let mut pinned = std::pin::pin!(S);
+ pinned.as_mut().x(); //~ ERROR no method named `x` found
}
diff --git a/tests/ui/self/arbitrary_self_types_needing_mut_pin.stderr b/tests/ui/self/arbitrary_self_types_needing_mut_pin.stderr
index f34ce4dce..5dcb58611 100644
--- a/tests/ui/self/arbitrary_self_types_needing_mut_pin.stderr
+++ b/tests/ui/self/arbitrary_self_types_needing_mut_pin.stderr
@@ -4,16 +4,14 @@ error[E0599]: no method named `x` found for struct `S` in the current scope
LL | struct S;
| -------- method `x` not found for this struct
...
-LL | fn x(self: Pin<&mut Self>) {
- | - the method is available for `Pin<&mut S>` here
-...
LL | S.x();
| ^ method not found in `S`
|
-help: consider wrapping the receiver expression with the appropriate type
+help: consider pinning the expression
+ |
+LL ~ let mut pinned = std::pin::pin!(S);
+LL ~ pinned.as_mut().x();
|
-LL | Pin::new(&mut S).x();
- | +++++++++++++ +
error: aborting due to previous error
diff --git a/tests/ui/self/self-impl.stderr b/tests/ui/self/self-impl.stderr
index 36372b644..18ffd1542 100644
--- a/tests/ui/self/self-impl.stderr
+++ b/tests/ui/self/self-impl.stderr
@@ -2,13 +2,13 @@ error[E0223]: ambiguous associated type
--> $DIR/self-impl.rs:23:16
|
LL | let _: <Self>::Baz = true;
- | ^^^^^^^^^^^ help: use the fully-qualified path: `<Bar as Foo>::Baz`
+ | ^^^^^^^^^^^ help: use fully-qualified syntax: `<Bar as Foo>::Baz`
error[E0223]: ambiguous associated type
--> $DIR/self-impl.rs:25:16
|
LL | let _: Self::Baz = true;
- | ^^^^^^^^^ help: use the fully-qualified path: `<Bar as Foo>::Baz`
+ | ^^^^^^^^^ help: use fully-qualified syntax: `<Bar as Foo>::Baz`
error: aborting due to 2 previous errors
diff --git a/tests/ui/self/self_type_keyword.rs b/tests/ui/self/self_type_keyword.rs
index b42bf8eea..96d24715e 100644
--- a/tests/ui/self/self_type_keyword.rs
+++ b/tests/ui/self/self_type_keyword.rs
@@ -22,6 +22,8 @@ pub fn main() {
//~^ ERROR cannot find macro `Self` in this scope
Foo { Self } => (),
//~^ ERROR expected identifier, found keyword `Self`
+ //~| ERROR mismatched types
+ //~| ERROR `Foo` does not have a field named `Self`
}
}
diff --git a/tests/ui/self/self_type_keyword.stderr b/tests/ui/self/self_type_keyword.stderr
index aca08d811..6e65fae80 100644
--- a/tests/ui/self/self_type_keyword.stderr
+++ b/tests/ui/self/self_type_keyword.stderr
@@ -31,19 +31,19 @@ LL | Foo { Self } => (),
| ^^^^ expected identifier, found keyword
error: expected identifier, found keyword `Self`
- --> $DIR/self_type_keyword.rs:29:26
+ --> $DIR/self_type_keyword.rs:31:26
|
LL | extern crate core as Self;
| ^^^^ expected identifier, found keyword
error: expected identifier, found keyword `Self`
- --> $DIR/self_type_keyword.rs:34:32
+ --> $DIR/self_type_keyword.rs:36:32
|
LL | use std::option::Option as Self;
| ^^^^ expected identifier, found keyword
error: expected identifier, found keyword `Self`
- --> $DIR/self_type_keyword.rs:39:11
+ --> $DIR/self_type_keyword.rs:41:11
|
LL | trait Self {}
| ^^^^ expected identifier, found keyword
@@ -80,7 +80,22 @@ LL | struct Bar<'Self>;
|
= help: consider removing `'Self`, referring to it in a field, or using a marker such as `PhantomData`
-error: aborting due to 12 previous errors
+error[E0308]: mismatched types
+ --> $DIR/self_type_keyword.rs:23:9
+ |
+LL | match 15 {
+ | -- this expression has type `{integer}`
+...
+LL | Foo { Self } => (),
+ | ^^^^^^^^^^^^ expected integer, found `Foo`
+
+error[E0026]: struct `Foo` does not have a field named `Self`
+ --> $DIR/self_type_keyword.rs:23:15
+ |
+LL | Foo { Self } => (),
+ | ^^^^ struct `Foo` does not have this field
+
+error: aborting due to 14 previous errors
-Some errors have detailed explanations: E0392, E0531.
-For more information about an error, try `rustc --explain E0392`.
+Some errors have detailed explanations: E0026, E0308, E0392, E0531.
+For more information about an error, try `rustc --explain E0026`.