summaryrefslogtreecommitdiffstats
path: root/tests/ui/methods
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:43 +0000
commit3e3e70d529d8c7d7c4d7bc4fefc9f109393b9245 (patch)
treedaf049b282ab10e8c3d03e409b3cd84ff3f7690c /tests/ui/methods
parentAdding debian version 1.68.2+dfsg1-1. (diff)
downloadrustc-3e3e70d529d8c7d7c4d7bc4fefc9f109393b9245.tar.xz
rustc-3e3e70d529d8c7d7c4d7bc4fefc9f109393b9245.zip
Merging upstream version 1.69.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/methods')
-rw-r--r--tests/ui/methods/assign-to-method.rs3
-rw-r--r--tests/ui/methods/assign-to-method.stderr4
-rw-r--r--tests/ui/methods/issues/issue-105732.stderr2
-rw-r--r--tests/ui/methods/issues/issue-61525.stderr4
-rw-r--r--tests/ui/methods/issues/issue-90315.stderr10
-rw-r--r--tests/ui/methods/method-ambig-two-traits-cross-crate.stderr4
-rw-r--r--tests/ui/methods/method-ambig-two-traits-from-bounds.stderr4
-rw-r--r--tests/ui/methods/method-ambig-two-traits-from-impls.stderr4
-rw-r--r--tests/ui/methods/method-ambig-two-traits-with-default-method.stderr4
-rw-r--r--tests/ui/methods/method-call-err-msg.stderr34
-rw-r--r--tests/ui/methods/method-call-lifetime-args-fail.rs8
-rw-r--r--tests/ui/methods/method-call-lifetime-args-fail.stderr16
-rw-r--r--tests/ui/methods/method-deref-to-same-trait-object-with-separate-params.stderr6
-rw-r--r--tests/ui/methods/method-not-found-but-doc-alias.rs11
-rw-r--r--tests/ui/methods/method-not-found-but-doc-alias.stderr12
-rw-r--r--tests/ui/methods/method-self-arg-1.rs4
-rw-r--r--tests/ui/methods/method-self-arg-1.stderr8
17 files changed, 81 insertions, 57 deletions
diff --git a/tests/ui/methods/assign-to-method.rs b/tests/ui/methods/assign-to-method.rs
index 85beaee8d..71e40759c 100644
--- a/tests/ui/methods/assign-to-method.rs
+++ b/tests/ui/methods/assign-to-method.rs
@@ -1,5 +1,4 @@
-// compile-flags: -Zsave-analysis
-// Also regression test for #69409
+// Regression test for #69409
struct Cat {
meows : usize,
diff --git a/tests/ui/methods/assign-to-method.stderr b/tests/ui/methods/assign-to-method.stderr
index cafe9abae..a1fc57cae 100644
--- a/tests/ui/methods/assign-to-method.stderr
+++ b/tests/ui/methods/assign-to-method.stderr
@@ -1,5 +1,5 @@
error[E0615]: attempted to take value of method `speak` on type `Cat`
- --> $DIR/assign-to-method.rs:22:10
+ --> $DIR/assign-to-method.rs:21:10
|
LL | nyan.speak = || println!("meow");
| ^^^^^ method, not a field
@@ -7,7 +7,7 @@ LL | nyan.speak = || println!("meow");
= help: methods are immutable and cannot be assigned to
error[E0615]: attempted to take value of method `speak` on type `Cat`
- --> $DIR/assign-to-method.rs:23:10
+ --> $DIR/assign-to-method.rs:22:10
|
LL | nyan.speak += || println!("meow");
| ^^^^^ method, not a field
diff --git a/tests/ui/methods/issues/issue-105732.stderr b/tests/ui/methods/issues/issue-105732.stderr
index 769664254..19ccd2de6 100644
--- a/tests/ui/methods/issues/issue-105732.stderr
+++ b/tests/ui/methods/issues/issue-105732.stderr
@@ -2,7 +2,7 @@ error[E0380]: auto traits cannot have associated items
--> $DIR/issue-105732.rs:4:8
|
LL | auto trait Foo {
- | --- auto trait cannot have associated items
+ | --- auto traits cannot have associated items
LL | fn g(&self);
| ---^-------- help: remove these associated items
diff --git a/tests/ui/methods/issues/issue-61525.stderr b/tests/ui/methods/issues/issue-61525.stderr
index 3e73b950a..a8afdeb84 100644
--- a/tests/ui/methods/issues/issue-61525.stderr
+++ b/tests/ui/methods/issues/issue-61525.stderr
@@ -21,13 +21,13 @@ error[E0308]: mismatched types
--> $DIR/issue-61525.rs:14:33
|
LL | 1.query::<dyn ToString>("")
- | --------------------- ^^ expected trait object `dyn ToString`, found `&str`
+ | --------------------- ^^ expected `dyn ToString`, found `&str`
| |
| arguments to this method are incorrect
|
= note: expected trait object `dyn ToString`
found reference `&'static str`
-note: associated function defined here
+note: method defined here
--> $DIR/issue-61525.rs:2:8
|
LL | fn query<Q>(self, q: Q);
diff --git a/tests/ui/methods/issues/issue-90315.stderr b/tests/ui/methods/issues/issue-90315.stderr
index 4d3c086ff..0466bb0a0 100644
--- a/tests/ui/methods/issues/issue-90315.stderr
+++ b/tests/ui/methods/issues/issue-90315.stderr
@@ -57,7 +57,7 @@ error[E0308]: mismatched types
--> $DIR/issue-90315.rs:28:8
|
LL | if 1..(end + 1).is_empty() {
- | ^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found struct `Range`
+ | ^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `Range<{integer}>`
|
= note: expected type `bool`
found struct `std::ops::Range<{integer}>`
@@ -77,7 +77,7 @@ error[E0308]: mismatched types
--> $DIR/issue-90315.rs:34:8
|
LL | if 1..(end + 1).is_sorted() {
- | ^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found struct `Range`
+ | ^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `Range<{integer}>`
|
= note: expected type `bool`
found struct `std::ops::Range<{integer}>`
@@ -97,7 +97,7 @@ error[E0308]: mismatched types
--> $DIR/issue-90315.rs:40:21
|
LL | let _res: i32 = 3..6.take(2).sum();
- | --- ^^^^^^^^^^^^^^^^^^ expected `i32`, found struct `Range`
+ | --- ^^^^^^^^^^^^^^^^^^ expected `i32`, found `Range<{integer}>`
| |
| expected due to this
|
@@ -119,7 +119,7 @@ error[E0308]: mismatched types
--> $DIR/issue-90315.rs:45:21
|
LL | let _sum: i32 = 3..6.sum();
- | --- ^^^^^^^^^^ expected `i32`, found struct `Range`
+ | --- ^^^^^^^^^^ expected `i32`, found `Range<{integer}>`
| |
| expected due to this
|
@@ -158,7 +158,7 @@ error[E0308]: mismatched types
--> $DIR/issue-90315.rs:62:8
|
LL | if 1..end.error_method() {
- | ^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found struct `Range`
+ | ^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `Range<{integer}>`
|
= note: expected type `bool`
found struct `std::ops::Range<{integer}>`
diff --git a/tests/ui/methods/method-ambig-two-traits-cross-crate.stderr b/tests/ui/methods/method-ambig-two-traits-cross-crate.stderr
index 4b2597eed..5132d9277 100644
--- a/tests/ui/methods/method-ambig-two-traits-cross-crate.stderr
+++ b/tests/ui/methods/method-ambig-two-traits-cross-crate.stderr
@@ -10,11 +10,11 @@ note: candidate #2 is defined in an impl of the trait `Me2` for the type `usize`
|
LL | impl Me2 for usize { fn me(&self) -> usize { *self } }
| ^^^^^^^^^^^^^^^^^^^^^
-help: disambiguate the associated function for candidate #1
+help: disambiguate the method for candidate #1
|
LL | fn main() { Me::me(&1_usize); }
| ~~~~~~~~~~~~~~~~
-help: disambiguate the associated function for candidate #2
+help: disambiguate the method for candidate #2
|
LL | fn main() { Me2::me(&1_usize); }
| ~~~~~~~~~~~~~~~~~
diff --git a/tests/ui/methods/method-ambig-two-traits-from-bounds.stderr b/tests/ui/methods/method-ambig-two-traits-from-bounds.stderr
index 1feaa2c73..601e6bbb0 100644
--- a/tests/ui/methods/method-ambig-two-traits-from-bounds.stderr
+++ b/tests/ui/methods/method-ambig-two-traits-from-bounds.stderr
@@ -14,11 +14,11 @@ note: candidate #2 is defined in the trait `B`
|
LL | trait B { fn foo(&self); }
| ^^^^^^^^^^^^^^
-help: disambiguate the associated function for candidate #1
+help: disambiguate the method for candidate #1
|
LL | A::foo(t);
| ~~~~~~~~~
-help: disambiguate the associated function for candidate #2
+help: disambiguate the method for candidate #2
|
LL | B::foo(t);
| ~~~~~~~~~
diff --git a/tests/ui/methods/method-ambig-two-traits-from-impls.stderr b/tests/ui/methods/method-ambig-two-traits-from-impls.stderr
index f69b56892..313591433 100644
--- a/tests/ui/methods/method-ambig-two-traits-from-impls.stderr
+++ b/tests/ui/methods/method-ambig-two-traits-from-impls.stderr
@@ -14,11 +14,11 @@ note: candidate #2 is defined in an impl of the trait `B` for the type `AB`
|
LL | fn foo(self) {}
| ^^^^^^^^^^^^
-help: disambiguate the associated function for candidate #1
+help: disambiguate the method for candidate #1
|
LL | A::foo(AB {});
| ~~~~~~~~~~~~~
-help: disambiguate the associated function for candidate #2
+help: disambiguate the method for candidate #2
|
LL | B::foo(AB {});
| ~~~~~~~~~~~~~
diff --git a/tests/ui/methods/method-ambig-two-traits-with-default-method.stderr b/tests/ui/methods/method-ambig-two-traits-with-default-method.stderr
index e84dff8ba..df01966b3 100644
--- a/tests/ui/methods/method-ambig-two-traits-with-default-method.stderr
+++ b/tests/ui/methods/method-ambig-two-traits-with-default-method.stderr
@@ -14,11 +14,11 @@ note: candidate #2 is defined in an impl of the trait `Bar` for the type `usize`
|
LL | trait Bar { fn method(&self) {} }
| ^^^^^^^^^^^^^^^^
-help: disambiguate the associated function for candidate #1
+help: disambiguate the method for candidate #1
|
LL | Foo::method(&1_usize);
| ~~~~~~~~~~~~~~~~~~~~~
-help: disambiguate the associated function for candidate #2
+help: disambiguate the method for candidate #2
|
LL | Bar::method(&1_usize);
| ~~~~~~~~~~~~~~~~~~~~~
diff --git a/tests/ui/methods/method-call-err-msg.stderr b/tests/ui/methods/method-call-err-msg.stderr
index 81269b73b..bd51378cf 100644
--- a/tests/ui/methods/method-call-err-msg.stderr
+++ b/tests/ui/methods/method-call-err-msg.stderr
@@ -2,17 +2,16 @@ error[E0061]: this method takes 0 arguments but 1 argument was supplied
--> $DIR/method-call-err-msg.rs:13:7
|
LL | x.zero(0)
- | ^^^^ - argument of type `{integer}` unexpected
+ | ^^^^ -
+ | |
+ | unexpected argument of type `{integer}`
+ | help: remove the extra argument
|
-note: associated function defined here
+note: method defined here
--> $DIR/method-call-err-msg.rs:5:8
|
LL | fn zero(self) -> Foo { self }
| ^^^^
-help: remove the extra argument
- |
-LL | x.zero()
- | ~~
error[E0061]: this method takes 1 argument but 0 arguments were supplied
--> $DIR/method-call-err-msg.rs:14:7
@@ -20,7 +19,7 @@ error[E0061]: this method takes 1 argument but 0 arguments were supplied
LL | .one()
| ^^^-- an argument of type `isize` is missing
|
-note: associated function defined here
+note: method defined here
--> $DIR/method-call-err-msg.rs:6:8
|
LL | fn one(self, _: isize) -> Foo { self }
@@ -36,7 +35,7 @@ error[E0061]: this method takes 2 arguments but 1 argument was supplied
LL | .two(0);
| ^^^--- an argument of type `isize` is missing
|
-note: associated function defined here
+note: method defined here
--> $DIR/method-call-err-msg.rs:7:8
|
LL | fn two(self, _: isize, _: isize) -> Foo { self }
@@ -49,14 +48,17 @@ LL | .two(0, /* isize */);
error[E0599]: `Foo` is not an iterator
--> $DIR/method-call-err-msg.rs:19:7
|
-LL | pub struct Foo;
- | --------------
- | |
- | method `take` not found for this struct
- | doesn't satisfy `Foo: Iterator`
+LL | pub struct Foo;
+ | --------------
+ | |
+ | method `take` not found for this struct
+ | doesn't satisfy `Foo: Iterator`
...
-LL | .take()
- | ^^^^ `Foo` is not an iterator
+LL | / y.zero()
+LL | | .take()
+ | | -^^^^ `Foo` is not an iterator
+ | |______|
+ |
|
= note: the following trait bounds were not satisfied:
`Foo: Iterator`
@@ -73,7 +75,7 @@ error[E0061]: this method takes 3 arguments but 0 arguments were supplied
LL | y.three::<usize>();
| ^^^^^^^^^^^^^^-- three arguments of type `usize`, `usize`, and `usize` are missing
|
-note: associated function defined here
+note: method defined here
--> $DIR/method-call-err-msg.rs:8:8
|
LL | fn three<T>(self, _: T, _: T, _: T) -> Foo { self }
diff --git a/tests/ui/methods/method-call-lifetime-args-fail.rs b/tests/ui/methods/method-call-lifetime-args-fail.rs
index 6bf55844d..1f13de094 100644
--- a/tests/ui/methods/method-call-lifetime-args-fail.rs
+++ b/tests/ui/methods/method-call-lifetime-args-fail.rs
@@ -14,9 +14,9 @@ impl S {
fn method_call() {
S.early(); // OK
S.early::<'static>();
- //~^ ERROR this associated function takes 2 lifetime arguments but 1 lifetime argument
+ //~^ ERROR method takes 2 lifetime arguments but 1 lifetime argument
S.early::<'static, 'static, 'static>();
- //~^ ERROR this associated function takes 2 lifetime arguments but 3 lifetime arguments were supplied
+ //~^ ERROR method takes 2 lifetime arguments but 3 lifetime arguments were supplied
let _: &u8 = S.life_and_type::<'static>();
S.life_and_type::<u8>();
S.life_and_type::<'static, u8>();
@@ -61,9 +61,9 @@ fn ufcs() {
S::early(S); // OK
S::early::<'static>(S);
- //~^ ERROR this associated function takes 2 lifetime arguments but 1 lifetime argument
+ //~^ ERROR method takes 2 lifetime arguments but 1 lifetime argument
S::early::<'static, 'static, 'static>(S);
- //~^ ERROR this associated function takes 2 lifetime arguments but 3 lifetime arguments were supplied
+ //~^ ERROR method takes 2 lifetime arguments but 3 lifetime arguments were supplied
let _: &u8 = S::life_and_type::<'static>(S);
S::life_and_type::<u8>(S);
S::life_and_type::<'static, u8>(S);
diff --git a/tests/ui/methods/method-call-lifetime-args-fail.stderr b/tests/ui/methods/method-call-lifetime-args-fail.stderr
index 249b48ab1..34526256f 100644
--- a/tests/ui/methods/method-call-lifetime-args-fail.stderr
+++ b/tests/ui/methods/method-call-lifetime-args-fail.stderr
@@ -1,4 +1,4 @@
-error[E0107]: this associated function takes 2 lifetime arguments but 1 lifetime argument was supplied
+error[E0107]: method takes 2 lifetime arguments but 1 lifetime argument was supplied
--> $DIR/method-call-lifetime-args-fail.rs:16:7
|
LL | S.early::<'static>();
@@ -6,7 +6,7 @@ LL | S.early::<'static>();
| |
| expected 2 lifetime arguments
|
-note: associated function defined here, with 2 lifetime parameters: `'a`, `'b`
+note: method defined here, with 2 lifetime parameters: `'a`, `'b`
--> $DIR/method-call-lifetime-args-fail.rs:6:8
|
LL | fn early<'a, 'b>(self) -> (&'a u8, &'b u8) { loop {} }
@@ -16,7 +16,7 @@ help: add missing lifetime argument
LL | S.early::<'static, 'static>();
| +++++++++
-error[E0107]: this associated function takes 2 lifetime arguments but 3 lifetime arguments were supplied
+error[E0107]: method takes 2 lifetime arguments but 3 lifetime arguments were supplied
--> $DIR/method-call-lifetime-args-fail.rs:18:7
|
LL | S.early::<'static, 'static, 'static>();
@@ -24,7 +24,7 @@ LL | S.early::<'static, 'static, 'static>();
| |
| expected 2 lifetime arguments
|
-note: associated function defined here, with 2 lifetime parameters: `'a`, `'b`
+note: method defined here, with 2 lifetime parameters: `'a`, `'b`
--> $DIR/method-call-lifetime-args-fail.rs:6:8
|
LL | fn early<'a, 'b>(self) -> (&'a u8, &'b u8) { loop {} }
@@ -198,7 +198,7 @@ note: the late bound lifetime parameter is introduced here
LL | fn late_unused_early<'a, 'b>(self) -> &'b u8 { loop {} }
| ^^
-error[E0107]: this associated function takes 2 lifetime arguments but 1 lifetime argument was supplied
+error[E0107]: method takes 2 lifetime arguments but 1 lifetime argument was supplied
--> $DIR/method-call-lifetime-args-fail.rs:63:8
|
LL | S::early::<'static>(S);
@@ -206,7 +206,7 @@ LL | S::early::<'static>(S);
| |
| expected 2 lifetime arguments
|
-note: associated function defined here, with 2 lifetime parameters: `'a`, `'b`
+note: method defined here, with 2 lifetime parameters: `'a`, `'b`
--> $DIR/method-call-lifetime-args-fail.rs:6:8
|
LL | fn early<'a, 'b>(self) -> (&'a u8, &'b u8) { loop {} }
@@ -216,7 +216,7 @@ help: add missing lifetime argument
LL | S::early::<'static, 'static>(S);
| +++++++++
-error[E0107]: this associated function takes 2 lifetime arguments but 3 lifetime arguments were supplied
+error[E0107]: method takes 2 lifetime arguments but 3 lifetime arguments were supplied
--> $DIR/method-call-lifetime-args-fail.rs:65:8
|
LL | S::early::<'static, 'static, 'static>(S);
@@ -224,7 +224,7 @@ LL | S::early::<'static, 'static, 'static>(S);
| |
| expected 2 lifetime arguments
|
-note: associated function defined here, with 2 lifetime parameters: `'a`, `'b`
+note: method defined here, with 2 lifetime parameters: `'a`, `'b`
--> $DIR/method-call-lifetime-args-fail.rs:6:8
|
LL | fn early<'a, 'b>(self) -> (&'a u8, &'b u8) { loop {} }
diff --git a/tests/ui/methods/method-deref-to-same-trait-object-with-separate-params.stderr b/tests/ui/methods/method-deref-to-same-trait-object-with-separate-params.stderr
index 82addab94..4e83e4b77 100644
--- a/tests/ui/methods/method-deref-to-same-trait-object-with-separate-params.stderr
+++ b/tests/ui/methods/method-deref-to-same-trait-object-with-separate-params.stderr
@@ -44,15 +44,15 @@ note: candidate #3 is defined in the trait `FinalFoo`
|
LL | fn foo(&self) -> u8;
| ^^^^^^^^^^^^^^^^^^^^
-help: disambiguate the associated function for candidate #1
+help: disambiguate the method for candidate #1
|
LL | let z = X::foo(x);
| ~~~~~~~~~
-help: disambiguate the associated function for candidate #2
+help: disambiguate the method for candidate #2
|
LL | let z = NuisanceFoo::foo(x);
| ~~~~~~~~~~~~~~~~~~~
-help: disambiguate the associated function for candidate #3
+help: disambiguate the method for candidate #3
|
LL | let z = FinalFoo::foo(x);
| ~~~~~~~~~~~~~~~~
diff --git a/tests/ui/methods/method-not-found-but-doc-alias.rs b/tests/ui/methods/method-not-found-but-doc-alias.rs
new file mode 100644
index 000000000..9c6d10029
--- /dev/null
+++ b/tests/ui/methods/method-not-found-but-doc-alias.rs
@@ -0,0 +1,11 @@
+struct Foo;
+
+impl Foo {
+ #[doc(alias = "quux")]
+ fn bar(&self) {}
+}
+
+fn main() {
+ Foo.quux();
+ //~^ ERROR no method named `quux` found for struct `Foo` in the current scope
+}
diff --git a/tests/ui/methods/method-not-found-but-doc-alias.stderr b/tests/ui/methods/method-not-found-but-doc-alias.stderr
new file mode 100644
index 000000000..5102a452f
--- /dev/null
+++ b/tests/ui/methods/method-not-found-but-doc-alias.stderr
@@ -0,0 +1,12 @@
+error[E0599]: no method named `quux` found for struct `Foo` in the current scope
+ --> $DIR/method-not-found-but-doc-alias.rs:9:9
+ |
+LL | struct Foo;
+ | ---------- method `quux` not found for this struct
+...
+LL | Foo.quux();
+ | ^^^^ help: there is a method with a similar name: `bar`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0599`.
diff --git a/tests/ui/methods/method-self-arg-1.rs b/tests/ui/methods/method-self-arg-1.rs
index f589f20d8..5912b4ec2 100644
--- a/tests/ui/methods/method-self-arg-1.rs
+++ b/tests/ui/methods/method-self-arg-1.rs
@@ -9,9 +9,9 @@ impl Foo {
fn main() {
let x = Foo;
Foo::bar(x); //~ ERROR mismatched types
- //~| expected `&Foo`, found struct `Foo`
+ //~| expected `&Foo`, found `Foo`
Foo::bar(&42); //~ ERROR mismatched types
- //~| expected struct `Foo`, found integer
+ //~| expected `&Foo`, found `&{integer}`
//~| expected reference `&Foo`
//~| found reference `&{integer}`
}
diff --git a/tests/ui/methods/method-self-arg-1.stderr b/tests/ui/methods/method-self-arg-1.stderr
index 01fec6fca..9241a8be5 100644
--- a/tests/ui/methods/method-self-arg-1.stderr
+++ b/tests/ui/methods/method-self-arg-1.stderr
@@ -4,11 +4,11 @@ error[E0308]: mismatched types
LL | Foo::bar(x);
| -------- ^
| | |
- | | expected `&Foo`, found struct `Foo`
+ | | expected `&Foo`, found `Foo`
| | help: consider borrowing here: `&x`
| arguments to this function are incorrect
|
-note: associated function defined here
+note: method defined here
--> $DIR/method-self-arg-1.rs:6:8
|
LL | fn bar(&self) {}
@@ -18,13 +18,13 @@ error[E0308]: mismatched types
--> $DIR/method-self-arg-1.rs:13:14
|
LL | Foo::bar(&42);
- | -------- ^^^ expected struct `Foo`, found integer
+ | -------- ^^^ expected `&Foo`, found `&{integer}`
| |
| arguments to this function are incorrect
|
= note: expected reference `&Foo`
found reference `&{integer}`
-note: associated function defined here
+note: method defined here
--> $DIR/method-self-arg-1.rs:6:8
|
LL | fn bar(&self) {}