summaryrefslogtreecommitdiffstats
path: root/src/test/ui/methods
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/methods')
-rw-r--r--src/test/ui/methods/issues/issue-90315.rs79
-rw-r--r--src/test/ui/methods/issues/issue-90315.stderr198
-rw-r--r--src/test/ui/methods/method-call-lifetime-args-lint-fail.stderr4
-rw-r--r--src/test/ui/methods/method-call-lifetime-args-lint.stderr4
-rw-r--r--src/test/ui/methods/method-call-lifetime-args-unresolved.stderr2
-rw-r--r--src/test/ui/methods/method-deref-to-same-trait-object-with-separate-params.stderr2
-rw-r--r--src/test/ui/methods/method-macro-backtrace.stderr8
7 files changed, 277 insertions, 20 deletions
diff --git a/src/test/ui/methods/issues/issue-90315.rs b/src/test/ui/methods/issues/issue-90315.rs
index 01bf9f484..79cdc4195 100644
--- a/src/test/ui/methods/issues/issue-90315.rs
+++ b/src/test/ui/methods/issues/issue-90315.rs
@@ -1,7 +1,76 @@
+#![allow(unused)]
fn main() {
- let arr = &[0,1,2,3];
- for _i in 0..arr.len().rev() { //~ERROR not an iterator
- // The above error used to say “the method `rev` exists for type `usize`”.
- // This regression test ensures it doesn't say that any more.
- }
+ let arr = &[0, 1, 2, 3];
+ for _i in 0..arr.len().rev() {
+ //~^ ERROR can't call method
+ //~| surround the range in parentheses
+ // The above error used to say “the method `rev` exists for type `usize`”.
+ // This regression test ensures it doesn't say that any more.
+ }
+
+ // Test for #102396
+ for i in 1..11.rev() {
+ //~^ ERROR can't call method
+ //~| HELP surround the range in parentheses
+ }
+
+ let end: usize = 10;
+ for i in 1..end.rev() {
+ //~^ ERROR can't call method
+ //~| HELP surround the range in parentheses
+ }
+
+ for i in 1..(end + 1).rev() {
+ //~^ ERROR can't call method
+ //~| HELP surround the range in parentheses
+ }
+
+ if 1..(end + 1).is_empty() {
+ //~^ ERROR can't call method
+ //~| ERROR mismatched types [E0308]
+ //~| HELP surround the range in parentheses
+ }
+
+ if 1..(end + 1).is_sorted() {
+ //~^ ERROR mismatched types [E0308]
+ //~| ERROR can't call method
+ //~| HELP surround the range in parentheses
+ }
+
+ let _res: i32 = 3..6.take(2).sum();
+ //~^ ERROR can't call method
+ //~| ERROR mismatched types [E0308]
+ //~| HELP surround the range in parentheses
+
+ let _sum: i32 = 3..6.sum();
+ //~^ ERROR can't call method
+ //~| ERROR mismatched types [E0308]
+ //~| HELP surround the range in parentheses
+
+ let a = 1 as usize;
+ let b = 10 as usize;
+
+ for _a in a..=b.rev() {
+ //~^ ERROR can't call method
+ //~| HELP surround the range in parentheses
+ }
+
+ let _res = ..10.contains(3);
+ //~^ ERROR can't call method
+ //~| HELP surround the range in parentheses
+
+ if 1..end.error_method() {
+ //~^ ERROR no method named `error_method`
+ //~| ERROR mismatched types [E0308]
+ // Won't suggest
+ }
+
+ let _res = b.take(1)..a;
+ //~^ ERROR `usize` is not an iterator
+
+ let _res: i32 = ..6.take(2).sum();
+ //~^ can't call method `take` on ambiguous numeric type
+ //~| ERROR mismatched types [E0308]
+ //~| HELP you must specify a concrete type for this numeric value
+ // Won't suggest because `RangeTo` dest not implemented `take`
}
diff --git a/src/test/ui/methods/issues/issue-90315.stderr b/src/test/ui/methods/issues/issue-90315.stderr
index c6a76c9e7..070cd3054 100644
--- a/src/test/ui/methods/issues/issue-90315.stderr
+++ b/src/test/ui/methods/issues/issue-90315.stderr
@@ -1,13 +1,201 @@
+error[E0689]: can't call method `rev` on type `usize`
+ --> $DIR/issue-90315.rs:4:28
+ |
+LL | for _i in 0..arr.len().rev() {
+ | ^^^ can't call method `rev` on type `usize`
+ |
+help: you must surround the range in parentheses to call its `rev` function
+ |
+LL | for _i in (0..arr.len()).rev() {
+ | + +
+
+error[E0689]: can't call method `rev` on type `{integer}`
+ --> $DIR/issue-90315.rs:12:20
+ |
+LL | for i in 1..11.rev() {
+ | ^^^ can't call method `rev` on type `{integer}`
+ |
+help: you must surround the range in parentheses to call its `rev` function
+ |
+LL | for i in (1..11).rev() {
+ | + +
+
+error[E0689]: can't call method `rev` on type `usize`
+ --> $DIR/issue-90315.rs:18:21
+ |
+LL | for i in 1..end.rev() {
+ | ^^^ can't call method `rev` on type `usize`
+ |
+help: you must surround the range in parentheses to call its `rev` function
+ |
+LL | for i in (1..end).rev() {
+ | + +
+
+error[E0689]: can't call method `rev` on type `usize`
+ --> $DIR/issue-90315.rs:23:27
+ |
+LL | for i in 1..(end + 1).rev() {
+ | ^^^ can't call method `rev` on type `usize`
+ |
+help: you must surround the range in parentheses to call its `rev` function
+ |
+LL | for i in (1..(end + 1)).rev() {
+ | + +
+
+error[E0689]: can't call method `is_empty` on type `usize`
+ --> $DIR/issue-90315.rs:28:21
+ |
+LL | if 1..(end + 1).is_empty() {
+ | ^^^^^^^^ can't call method `is_empty` on type `usize`
+ |
+help: you must surround the range in parentheses to call its `is_empty` function
+ |
+LL | if (1..(end + 1)).is_empty() {
+ | + +
+
+error[E0308]: mismatched types
+ --> $DIR/issue-90315.rs:28:8
+ |
+LL | if 1..(end + 1).is_empty() {
+ | ^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found struct `std::ops::Range`
+ |
+ = note: expected type `bool`
+ found struct `std::ops::Range<{integer}>`
+
+error[E0689]: can't call method `is_sorted` on type `usize`
+ --> $DIR/issue-90315.rs:34:21
+ |
+LL | if 1..(end + 1).is_sorted() {
+ | ^^^^^^^^^ can't call method `is_sorted` on type `usize`
+ |
+help: you must surround the range in parentheses to call its `is_sorted` function
+ |
+LL | if (1..(end + 1)).is_sorted() {
+ | + +
+
+error[E0308]: mismatched types
+ --> $DIR/issue-90315.rs:34:8
+ |
+LL | if 1..(end + 1).is_sorted() {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found struct `std::ops::Range`
+ |
+ = note: expected type `bool`
+ found struct `std::ops::Range<{integer}>`
+
+error[E0689]: can't call method `take` on type `{integer}`
+ --> $DIR/issue-90315.rs:40:26
+ |
+LL | let _res: i32 = 3..6.take(2).sum();
+ | ^^^^ can't call method `take` on type `{integer}`
+ |
+help: you must surround the range in parentheses to call its `take` function
+ |
+LL | let _res: i32 = (3..6).take(2).sum();
+ | + +
+
+error[E0308]: mismatched types
+ --> $DIR/issue-90315.rs:40:21
+ |
+LL | let _res: i32 = 3..6.take(2).sum();
+ | --- ^^^^^^^^^^^^^^^^^^ expected `i32`, found struct `std::ops::Range`
+ | |
+ | expected due to this
+ |
+ = note: expected type `i32`
+ found struct `std::ops::Range<{integer}>`
+
+error[E0689]: can't call method `sum` on type `{integer}`
+ --> $DIR/issue-90315.rs:45:26
+ |
+LL | let _sum: i32 = 3..6.sum();
+ | ^^^ can't call method `sum` on type `{integer}`
+ |
+help: you must surround the range in parentheses to call its `sum` function
+ |
+LL | let _sum: i32 = (3..6).sum();
+ | + +
+
+error[E0308]: mismatched types
+ --> $DIR/issue-90315.rs:45:21
+ |
+LL | let _sum: i32 = 3..6.sum();
+ | --- ^^^^^^^^^^ expected `i32`, found struct `std::ops::Range`
+ | |
+ | expected due to this
+ |
+ = note: expected type `i32`
+ found struct `std::ops::Range<{integer}>`
+
+error[E0689]: can't call method `rev` on type `usize`
+ --> $DIR/issue-90315.rs:53:21
+ |
+LL | for _a in a..=b.rev() {
+ | ^^^ can't call method `rev` on type `usize`
+ |
+help: you must surround the range in parentheses to call its `rev` function
+ |
+LL | for _a in (a..=b).rev() {
+ | + +
+
+error[E0689]: can't call method `contains` on type `{integer}`
+ --> $DIR/issue-90315.rs:58:21
+ |
+LL | let _res = ..10.contains(3);
+ | ^^^^^^^^ can't call method `contains` on type `{integer}`
+ |
+help: you must surround the range in parentheses to call its `contains` function
+ |
+LL | let _res = (..10).contains(3);
+ | + +
+
+error[E0599]: no method named `error_method` found for type `usize` in the current scope
+ --> $DIR/issue-90315.rs:62:15
+ |
+LL | if 1..end.error_method() {
+ | ^^^^^^^^^^^^ method not found in `usize`
+
+error[E0308]: mismatched types
+ --> $DIR/issue-90315.rs:62:8
+ |
+LL | if 1..end.error_method() {
+ | ^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found struct `std::ops::Range`
+ |
+ = note: expected type `bool`
+ found struct `std::ops::Range<{integer}>`
+
error[E0599]: `usize` is not an iterator
- --> $DIR/issue-90315.rs:3:26
+ --> $DIR/issue-90315.rs:68:18
|
-LL | for _i in 0..arr.len().rev() {
- | ^^^ `usize` is not an iterator
+LL | let _res = b.take(1)..a;
+ | ^^^^ `usize` is not an iterator
|
= note: the following trait bounds were not satisfied:
`usize: Iterator`
which is required by `&mut usize: Iterator`
-error: aborting due to previous error
+error[E0689]: can't call method `take` on ambiguous numeric type `{integer}`
+ --> $DIR/issue-90315.rs:71:25
+ |
+LL | let _res: i32 = ..6.take(2).sum();
+ | ^^^^
+ |
+help: you must specify a concrete type for this numeric value, like `i32`
+ |
+LL | let _res: i32 = ..6_i32.take(2).sum();
+ | ~~~~~
+
+error[E0308]: mismatched types
+ --> $DIR/issue-90315.rs:71:21
+ |
+LL | let _res: i32 = ..6.take(2).sum();
+ | --- ^^^^^^^^^^^^^^^^^ expected `i32`, found struct `RangeTo`
+ | |
+ | expected due to this
+ |
+ = note: expected type `i32`
+ found struct `RangeTo<_>`
+
+error: aborting due to 19 previous errors
-For more information about this error, try `rustc --explain E0599`.
+Some errors have detailed explanations: E0308, E0599, E0689.
+For more information about an error, try `rustc --explain E0308`.
diff --git a/src/test/ui/methods/method-call-lifetime-args-lint-fail.stderr b/src/test/ui/methods/method-call-lifetime-args-lint-fail.stderr
index 9e07d5ea3..394c1ac3c 100644
--- a/src/test/ui/methods/method-call-lifetime-args-lint-fail.stderr
+++ b/src/test/ui/methods/method-call-lifetime-args-lint-fail.stderr
@@ -7,13 +7,13 @@ LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {}
LL | S.late::<'static>(&0, &0);
| ^^^^^^^
|
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #42868 <https://github.com/rust-lang/rust/issues/42868>
note: the lint level is defined here
--> $DIR/method-call-lifetime-args-lint-fail.rs:1:9
|
LL | #![deny(late_bound_lifetime_arguments)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #42868 <https://github.com/rust-lang/rust/issues/42868>
error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
--> $DIR/method-call-lifetime-args-lint-fail.rs:26:14
diff --git a/src/test/ui/methods/method-call-lifetime-args-lint.stderr b/src/test/ui/methods/method-call-lifetime-args-lint.stderr
index f31f510a3..b4fc2d717 100644
--- a/src/test/ui/methods/method-call-lifetime-args-lint.stderr
+++ b/src/test/ui/methods/method-call-lifetime-args-lint.stderr
@@ -7,13 +7,13 @@ LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {}
LL | S.late::<'static>(&0, &0);
| ^^^^^^^
|
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #42868 <https://github.com/rust-lang/rust/issues/42868>
note: the lint level is defined here
--> $DIR/method-call-lifetime-args-lint.rs:1:9
|
LL | #![deny(late_bound_lifetime_arguments)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #42868 <https://github.com/rust-lang/rust/issues/42868>
error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
--> $DIR/method-call-lifetime-args-lint.rs:16:23
diff --git a/src/test/ui/methods/method-call-lifetime-args-unresolved.stderr b/src/test/ui/methods/method-call-lifetime-args-unresolved.stderr
index 78af19586..62f20d6d5 100644
--- a/src/test/ui/methods/method-call-lifetime-args-unresolved.stderr
+++ b/src/test/ui/methods/method-call-lifetime-args-unresolved.stderr
@@ -17,9 +17,9 @@ LL | 0.clone::<'a>();
LL | fn clone(&self) -> Self;
| - the late bound lifetime parameter is introduced here
|
- = note: `#[warn(late_bound_lifetime_arguments)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #42868 <https://github.com/rust-lang/rust/issues/42868>
+ = note: `#[warn(late_bound_lifetime_arguments)]` on by default
error: aborting due to previous error; 1 warning emitted
diff --git a/src/test/ui/methods/method-deref-to-same-trait-object-with-separate-params.stderr b/src/test/ui/methods/method-deref-to-same-trait-object-with-separate-params.stderr
index 59075397e..82addab94 100644
--- a/src/test/ui/methods/method-deref-to-same-trait-object-with-separate-params.stderr
+++ b/src/test/ui/methods/method-deref-to-same-trait-object-with-separate-params.stderr
@@ -4,8 +4,8 @@ warning: the feature `unsized_locals` is incomplete and may not be safe to use a
LL | #![feature(unsized_locals, unsized_fn_params)]
| ^^^^^^^^^^^^^^
|
- = note: `#[warn(incomplete_features)]` on by default
= note: see issue #48055 <https://github.com/rust-lang/rust/issues/48055> for more information
+ = note: `#[warn(incomplete_features)]` on by default
error[E0308]: mismatched types
--> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:87:24
diff --git a/src/test/ui/methods/method-macro-backtrace.stderr b/src/test/ui/methods/method-macro-backtrace.stderr
index 7ae00835c..dd616c4a5 100644
--- a/src/test/ui/methods/method-macro-backtrace.stderr
+++ b/src/test/ui/methods/method-macro-backtrace.stderr
@@ -1,11 +1,11 @@
-error[E0201]: duplicate definitions with name `bar`:
+error[E0592]: duplicate definitions with name `bar`
--> $DIR/method-macro-backtrace.rs:22:5
|
LL | fn bar(&self) { }
- | ------------- previous definition of `bar` here
+ | ------------- other definition for `bar`
LL | fn bar(&self) { }
- | ^^^^^^^^^^^^^ duplicate definition
+ | ^^^^^^^^^^^^^ duplicate definitions for `bar`
error: aborting due to previous error
-For more information about this error, try `rustc --explain E0201`.
+For more information about this error, try `rustc --explain E0592`.