`, or `self: Pin` (where P is one \
+ of the previous types except `Self`)";
+
fn check_method_receiver<'fcx, 'tcx>(
fcx: &FnCtxt<'fcx, 'tcx>,
method_sig: &hir::MethodSig,
method: &ty::AssocItem,
self_ty: Ty<'tcx>,
) {
- const HELP_FOR_SELF_TYPE: &str =
- "consider changing to `self`, `&self`, `&mut self`, `self: Box`, \
- `self: Rc`, `self: Arc`, or `self: Pin` (where P is one \
- of the previous types except `Self`)";
// Check that the method has a valid receiver type, given the type `Self`.
- debug!("check_method_receiver({:?}, self_ty={:?})",
- method, self_ty);
+ debug!("check_method_receiver({:?}, self_ty={:?})", method, self_ty);
if !method.method_has_self_argument {
return;
@@ -805,12 +805,7 @@ fn check_method_receiver<'fcx, 'tcx>(
if fcx.tcx.features().arbitrary_self_types {
if !receiver_is_valid(fcx, span, receiver_ty, self_ty, true) {
// Report error; `arbitrary_self_types` was enabled.
- fcx.tcx.sess.diagnostic().mut_span_err(
- span, &format!("invalid method receiver type: {:?}", receiver_ty)
- ).note("type of `self` must be `Self` or a type that dereferences to it")
- .help(HELP_FOR_SELF_TYPE)
- .code(DiagnosticId::Error("E0307".into()))
- .emit();
+ e0307(fcx, span, receiver_ty);
}
} else {
if !receiver_is_valid(fcx, span, receiver_ty, self_ty, false) {
@@ -830,17 +825,22 @@ fn check_method_receiver<'fcx, 'tcx>(
.emit();
} else {
// Report error; would not have worked with `arbitrary_self_types`.
- fcx.tcx.sess.diagnostic().mut_span_err(
- span, &format!("invalid method receiver type: {:?}", receiver_ty)
- ).note("type must be `Self` or a type that dereferences to it")
- .help(HELP_FOR_SELF_TYPE)
- .code(DiagnosticId::Error("E0307".into()))
- .emit();
+ e0307(fcx, span, receiver_ty);
}
}
}
}
+fn e0307(fcx: &FnCtxt<'fcx, 'tcx>, span: Span, receiver_ty: Ty<'_>) {
+ fcx.tcx.sess.diagnostic().mut_span_err(
+ span,
+ &format!("invalid `self` parameter type: {:?}", receiver_ty)
+ ).note("type of `self` must be `Self` or a type that dereferences to it")
+ .help(HELP_FOR_SELF_TYPE)
+ .code(DiagnosticId::Error("E0307".into()))
+ .emit();
+}
+
/// Returns whether `receiver_ty` would be considered a valid receiver type for `self_ty`. If
/// `arbitrary_self_types` is enabled, `receiver_ty` must transitively deref to `self_ty`, possibly
/// through a `*const/mut T` raw pointer. If the feature is not enabled, the requirements are more
diff --git a/src/librustc_typeck/error_codes.rs b/src/librustc_typeck/error_codes.rs
index b52183d4b1b56..093446d28533e 100644
--- a/src/librustc_typeck/error_codes.rs
+++ b/src/librustc_typeck/error_codes.rs
@@ -212,7 +212,7 @@ match string {
E0033: r##"
This error indicates that a pointer to a trait type cannot be implicitly
dereferenced by a pattern. Every trait defines a type, but because the
-size of trait implementors isn't fixed, this type has no compile-time size.
+size of trait implementers isn't fixed, this type has no compile-time size.
Therefore, all accesses to trait types must be through pointers. If you
encounter this error you should try to avoid dereferencing the pointer.
@@ -2425,6 +2425,87 @@ struct Bar { x: Foo }
```
"##,
+E0307: r##"
+This error indicates that the `self` parameter in a method has an invalid
+"reciever type".
+
+Methods take a special first parameter, of which there are three variants:
+`self`, `&self`, and `&mut self`. These are syntactic sugar for
+`self: Self`, `self: &Self`, and `self: &mut Self` respectively.
+
+```
+# struct Foo;
+trait Trait {
+ fn foo(&self);
+// ^^^^^ `self` here is a reference to the receiver object
+}
+
+impl Trait for Foo {
+ fn foo(&self) {}
+// ^^^^^ the receiver type is `&Foo`
+}
+```
+
+The type `Self` acts as an alias to the type of the current trait
+implementer, or "receiver type". Besides the already mentioned `Self`,
+`&Self` and `&mut Self` valid receiver types, the following are also valid:
+`self: Box`, `self: Rc`, `self: Arc`, and `self: Pin`
+(where P is one of the previous types except `Self`). Note that `Self` can
+also be the underlying implementing type, like `Foo` in the following
+example:
+
+```
+# struct Foo;
+# trait Trait {
+# fn foo(&self);
+# }
+impl Trait for Foo {
+ fn foo(self: &Foo) {}
+}
+```
+
+E0307 will be emitted by the compiler when using an invalid reciver type,
+like in the following example:
+
+```compile_fail,E0307
+# struct Foo;
+# struct Bar;
+# trait Trait {
+# fn foo(&self);
+# }
+impl Trait for Foo {
+ fn foo(self: &Bar) {}
+}
+```
+
+The nightly feature [Arbintrary self types][AST] extends the accepted
+set of receiver types to also include any type that can dereference to
+`Self`:
+
+```
+#![feature(arbitrary_self_types)]
+
+struct Foo;
+struct Bar;
+
+// Because you can dereference `Bar` into `Foo`...
+impl std::ops::Deref for Bar {
+ type Target = Foo;
+
+ fn deref(&self) -> &Foo {
+ &Foo
+ }
+}
+
+impl Foo {
+ fn foo(self: Bar) {}
+// ^^^^^^^^^ ...it can be used as the receiver type
+}
+```
+
+[AST]: https://doc.rust-lang.org/unstable-book/language-features/arbitrary-self-types.html
+"##,
+
E0321: r##"
A cross-crate opt-out trait was implemented on something which wasn't a struct
or enum type. Erroneous code example:
@@ -4851,7 +4932,6 @@ register_diagnostics! {
// E0247,
// E0248, // value used as a type, now reported earlier during resolution as E0412
// E0249,
- E0307, // invalid method `self` type
// E0319, // trait impls for defaulted traits allowed just for structs/enums
// E0372, // coherence not object safe
E0377, // the trait `CoerceUnsized` may only be implemented for a coercion
diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs
index 5060f368229bb..0386dbd490d03 100644
--- a/src/libstd/io/mod.rs
+++ b/src/libstd/io/mod.rs
@@ -371,6 +371,14 @@ where
loop {
if g.len == g.buf.len() {
unsafe {
+ // FIXME(danielhenrymantilla): #42788
+ //
+ // - This creates a (mut) reference to a slice of
+ // _uninitialized_ integers, which is **undefined behavior**
+ //
+ // - Only the standard library gets to soundly "ignore" this,
+ // based on its privileged knowledge of unstable rustc
+ // internals;
g.buf.reserve(reservation_size(r));
let capacity = g.buf.capacity();
g.buf.set_len(capacity);
diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs
index c3882bacf87eb..71050b0dcd1f5 100644
--- a/src/libstd/lib.rs
+++ b/src/libstd/lib.rs
@@ -244,7 +244,6 @@
#![feature(cfg_target_has_atomic)]
#![feature(cfg_target_thread_local)]
#![feature(char_error_internals)]
-#![feature(checked_duration_since)]
#![feature(clamp)]
#![feature(compiler_builtins_lib)]
#![feature(concat_idents)]
diff --git a/src/libstd/time.rs b/src/libstd/time.rs
index 98371b9ba3d7e..d59085cd44a6f 100644
--- a/src/libstd/time.rs
+++ b/src/libstd/time.rs
@@ -221,7 +221,6 @@ impl Instant {
/// # Examples
///
/// ```no_run
- /// #![feature(checked_duration_since)]
/// use std::time::{Duration, Instant};
/// use std::thread::sleep;
///
@@ -231,7 +230,7 @@ impl Instant {
/// println!("{:?}", new_now.checked_duration_since(now));
/// println!("{:?}", now.checked_duration_since(new_now)); // None
/// ```
- #[unstable(feature = "checked_duration_since", issue = "58402")]
+ #[stable(feature = "checked_duration_since", since = "1.39.0")]
pub fn checked_duration_since(&self, earlier: Instant) -> Option {
self.0.checked_sub_instant(&earlier.0)
}
@@ -242,7 +241,6 @@ impl Instant {
/// # Examples
///
/// ```no_run
- /// #![feature(checked_duration_since)]
/// use std::time::{Duration, Instant};
/// use std::thread::sleep;
///
@@ -252,7 +250,7 @@ impl Instant {
/// println!("{:?}", new_now.saturating_duration_since(now));
/// println!("{:?}", now.saturating_duration_since(new_now)); // 0ns
/// ```
- #[unstable(feature = "checked_duration_since", issue = "58402")]
+ #[stable(feature = "checked_duration_since", since = "1.39.0")]
pub fn saturating_duration_since(&self, earlier: Instant) -> Duration {
self.checked_duration_since(earlier).unwrap_or(Duration::new(0, 0))
}
diff --git a/src/libsyntax/parse/parser/expr.rs b/src/libsyntax/parse/parser/expr.rs
index 5b9f0f1df6718..e502a08f4b253 100644
--- a/src/libsyntax/parse/parser/expr.rs
+++ b/src/libsyntax/parse/parser/expr.rs
@@ -889,6 +889,36 @@ impl<'a> Parser<'a> {
hi = path.span;
return Ok(self.mk_expr(lo.to(hi), ExprKind::Path(Some(qself), path), attrs));
}
+ if self.token.is_path_start() {
+ let path = self.parse_path(PathStyle::Expr)?;
+
+ // `!`, as an operator, is prefix, so we know this isn't that
+ if self.eat(&token::Not) {
+ // MACRO INVOCATION expression
+ let (delim, tts) = self.expect_delimited_token_tree()?;
+ hi = self.prev_span;
+ ex = ExprKind::Mac(Mac {
+ path,
+ tts,
+ delim,
+ span: lo.to(hi),
+ prior_type_ascription: self.last_type_ascription,
+ });
+ } else if self.check(&token::OpenDelim(token::Brace)) {
+ if let Some(expr) = self.maybe_parse_struct_expr(lo, &path, &attrs) {
+ return expr;
+ } else {
+ hi = path.span;
+ ex = ExprKind::Path(None, path);
+ }
+ } else {
+ hi = path.span;
+ ex = ExprKind::Path(None, path);
+ }
+
+ let expr = self.mk_expr(lo.to(hi), ex, attrs);
+ return self.maybe_recover_from_bad_qpath(expr, true);
+ }
if self.check_keyword(kw::Move) || self.check_keyword(kw::Static) {
return self.parse_lambda_expr(attrs);
}
@@ -1007,32 +1037,6 @@ impl<'a> Parser<'a> {
let (await_hi, e_kind) = self.parse_incorrect_await_syntax(lo, self.prev_span)?;
hi = await_hi;
ex = e_kind;
- } else if self.token.is_path_start() {
- let path = self.parse_path(PathStyle::Expr)?;
-
- // `!`, as an operator, is prefix, so we know this isn't that
- if self.eat(&token::Not) {
- // MACRO INVOCATION expression
- let (delim, tts) = self.expect_delimited_token_tree()?;
- hi = self.prev_span;
- ex = ExprKind::Mac(Mac {
- path,
- tts,
- delim,
- span: lo.to(hi),
- prior_type_ascription: self.last_type_ascription,
- });
- } else if self.check(&token::OpenDelim(token::Brace)) {
- if let Some(expr) = self.maybe_parse_struct_expr(lo, &path, &attrs) {
- return expr;
- } else {
- hi = path.span;
- ex = ExprKind::Path(None, path);
- }
- } else {
- hi = path.span;
- ex = ExprKind::Path(None, path);
- }
} else {
if !self.unclosed_delims.is_empty() && self.check(&token::Semi) {
// Don't complain about bare semicolons after unclosed braces
diff --git a/src/libsyntax_pos/symbol.rs b/src/libsyntax_pos/symbol.rs
index f44716e013ec8..3a4dc1f5a096b 100644
--- a/src/libsyntax_pos/symbol.rs
+++ b/src/libsyntax_pos/symbol.rs
@@ -818,10 +818,14 @@ impl Ident {
with_interner(|interner| interner.is_gensymed(self.name))
}
+ /// Convert the name to a `LocalInternedString`. This is a slowish
+ /// operation because it requires locking the symbol interner.
pub fn as_str(self) -> LocalInternedString {
self.name.as_str()
}
+ /// Convert the name to an `InternedString`. This is a slowish operation
+ /// because it requires locking the symbol interner.
pub fn as_interned_str(self) -> InternedString {
self.name.as_interned_str()
}
@@ -916,6 +920,25 @@ impl Symbol {
with_interner(|interner| interner.intern(string))
}
+ /// Access the symbol's chars. This is a slowish operation because it
+ /// requires locking the symbol interner.
+ pub fn with R, R>(self, f: F) -> R {
+ with_interner(|interner| {
+ f(interner.get(self))
+ })
+ }
+
+ /// Access two symbols' chars. This is a slowish operation because it
+ /// requires locking the symbol interner, but it is faster than calling
+ /// `with()` twice.
+ fn with2 R, R>(self, other: Symbol, f: F) -> R {
+ with_interner(|interner| {
+ f(interner.get(self), interner.get(other))
+ })
+ }
+
+ /// Convert to a `LocalInternedString`. This is a slowish operation because
+ /// it requires locking the symbol interner.
pub fn as_str(self) -> LocalInternedString {
with_interner(|interner| unsafe {
LocalInternedString {
@@ -924,6 +947,8 @@ impl Symbol {
})
}
+ /// Convert to an `InternedString`. This is a slowish operation because it
+ /// requires locking the symbol interner.
pub fn as_interned_str(self) -> InternedString {
with_interner(|interner| InternedString {
symbol: interner.interned(self)
@@ -1152,39 +1177,11 @@ fn with_interner T>(f: F) -> T {
// FIXME: ensure that the interner outlives any thread which uses
// `LocalInternedString`, by creating a new thread right after constructing the
// interner.
-#[derive(Clone, Copy, Hash, PartialOrd, Eq, Ord)]
+#[derive(Clone, Copy, Eq, PartialOrd, Ord)]
pub struct LocalInternedString {
string: &'static str,
}
-impl LocalInternedString {
- /// Maps a string to its interned representation.
- pub fn intern(string: &str) -> Self {
- let string = with_interner(|interner| {
- let symbol = interner.intern(string);
- interner.strings[symbol.0.as_usize()]
- });
- LocalInternedString {
- string: unsafe { std::mem::transmute::<&str, &str>(string) }
- }
- }
-
- pub fn as_interned_str(self) -> InternedString {
- InternedString {
- symbol: Symbol::intern(self.string)
- }
- }
-
- #[inline]
- pub fn get(&self) -> &str {
- // This returns a valid string since we ensure that `self` outlives the interner
- // by creating the interner on a thread which outlives threads which can access it.
- // This type cannot move to a thread which outlives the interner since it does
- // not implement Send.
- self.string
- }
-}
-
impl std::convert::AsRef for LocalInternedString
where
str: std::convert::AsRef
@@ -1246,18 +1243,6 @@ impl fmt::Display for LocalInternedString {
}
}
-impl Decodable for LocalInternedString {
- fn decode(d: &mut D) -> Result {
- Ok(LocalInternedString::intern(&d.read_str()?))
- }
-}
-
-impl Encodable for LocalInternedString {
- fn encode(&self, s: &mut S) -> Result<(), S::Error> {
- s.emit_str(self.string)
- }
-}
-
/// An alternative to `Symbol` that is focused on string contents. It has two
/// main differences to `Symbol`.
///
@@ -1285,28 +1270,19 @@ impl InternedString {
}
pub fn with R, R>(self, f: F) -> R {
- let str = with_interner(|interner| {
- interner.get(self.symbol) as *const str
- });
- // This is safe because the interner keeps string alive until it is dropped.
- // We can access it because we know the interner is still alive since we use a
- // scoped thread local to access it, and it was alive at the beginning of this scope
- unsafe { f(&*str) }
+ self.symbol.with(f)
}
fn with2 R, R>(self, other: &InternedString, f: F) -> R {
- let (self_str, other_str) = with_interner(|interner| {
- (interner.get(self.symbol) as *const str,
- interner.get(other.symbol) as *const str)
- });
- // This is safe for the same reason that `with` is safe.
- unsafe { f(&*self_str, &*other_str) }
+ self.symbol.with2(other.symbol, f)
}
pub fn as_symbol(self) -> Symbol {
self.symbol
}
+ /// Convert to a `LocalInternedString`. This is a slowish operation because it
+ /// requires locking the symbol interner.
pub fn as_str(self) -> LocalInternedString {
self.symbol.as_str()
}
diff --git a/src/test/ui/associated-const/associated-const-in-trait.stderr b/src/test/ui/associated-const/associated-const-in-trait.stderr
index dff268a55c909..a5d7fc5b70246 100644
--- a/src/test/ui/associated-const/associated-const-in-trait.stderr
+++ b/src/test/ui/associated-const/associated-const-in-trait.stderr
@@ -1,10 +1,11 @@
error[E0038]: the trait `Trait` cannot be made into an object
--> $DIR/associated-const-in-trait.rs:9:6
|
+LL | const N: usize;
+ | - the trait cannot contain associated consts like `N`
+...
LL | impl dyn Trait {
| ^^^^^^^^^ the trait `Trait` cannot be made into an object
- |
- = note: the trait cannot contain associated consts like `N`
error: aborting due to previous error
diff --git a/src/test/ui/async-await/mutually-recursive-async-impl-trait-type.rs b/src/test/ui/async-await/mutually-recursive-async-impl-trait-type.rs
new file mode 100644
index 0000000000000..bb2a61f03ce1f
--- /dev/null
+++ b/src/test/ui/async-await/mutually-recursive-async-impl-trait-type.rs
@@ -0,0 +1,13 @@
+// edition:2018
+// Test that impl trait does not allow creating recursive types that are
+// otherwise forbidden when using `async` and `await`.
+
+async fn rec_1() { //~ ERROR recursion in an `async fn`
+ rec_2().await;
+}
+
+async fn rec_2() { //~ ERROR recursion in an `async fn`
+ rec_1().await;
+}
+
+fn main() {}
diff --git a/src/test/ui/async-await/mutually-recursive-async-impl-trait-type.stderr b/src/test/ui/async-await/mutually-recursive-async-impl-trait-type.stderr
new file mode 100644
index 0000000000000..9249308936e54
--- /dev/null
+++ b/src/test/ui/async-await/mutually-recursive-async-impl-trait-type.stderr
@@ -0,0 +1,19 @@
+error[E0733]: recursion in an `async fn` requires boxing
+ --> $DIR/mutually-recursive-async-impl-trait-type.rs:5:18
+ |
+LL | async fn rec_1() {
+ | ^ recursive `async fn`
+ |
+ = note: a recursive `async fn` must be rewritten to return a boxed `dyn Future`.
+
+error[E0733]: recursion in an `async fn` requires boxing
+ --> $DIR/mutually-recursive-async-impl-trait-type.rs:9:18
+ |
+LL | async fn rec_2() {
+ | ^ recursive `async fn`
+ |
+ = note: a recursive `async fn` must be rewritten to return a boxed `dyn Future`.
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0733`.
diff --git a/src/test/ui/async-await/recursive-async-impl-trait-type.stderr b/src/test/ui/async-await/recursive-async-impl-trait-type.stderr
index 8781a9c444d0a..9ee014021804e 100644
--- a/src/test/ui/async-await/recursive-async-impl-trait-type.stderr
+++ b/src/test/ui/async-await/recursive-async-impl-trait-type.stderr
@@ -2,9 +2,9 @@ error[E0733]: recursion in an `async fn` requires boxing
--> $DIR/recursive-async-impl-trait-type.rs:5:40
|
LL | async fn recursive_async_function() -> () {
- | ^^ an `async fn` cannot invoke itself directly
+ | ^^ recursive `async fn`
|
- = note: a recursive `async fn` must be rewritten to return a boxed future.
+ = note: a recursive `async fn` must be rewritten to return a boxed `dyn Future`.
error: aborting due to previous error
diff --git a/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.old.stderr b/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.old.stderr
index c38d7456a9952..18a7cea95bdb9 100644
--- a/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.old.stderr
+++ b/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.old.stderr
@@ -1,10 +1,10 @@
error[E0038]: the trait `NotObjectSafe` cannot be made into an object
--> $DIR/coherence-impl-trait-for-trait-object-safe.rs:11:6
|
+LL | trait NotObjectSafe { fn eq(&self, other: Self); }
+ | -- method `eq` references the `Self` type in its parameters or return type
LL | impl NotObjectSafe for dyn NotObjectSafe { }
| ^^^^^^^^^^^^^ the trait `NotObjectSafe` cannot be made into an object
- |
- = note: method `eq` references the `Self` type in its arguments or return type
error: aborting due to previous error
diff --git a/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.re.stderr b/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.re.stderr
index c38d7456a9952..18a7cea95bdb9 100644
--- a/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.re.stderr
+++ b/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.re.stderr
@@ -1,10 +1,10 @@
error[E0038]: the trait `NotObjectSafe` cannot be made into an object
--> $DIR/coherence-impl-trait-for-trait-object-safe.rs:11:6
|
+LL | trait NotObjectSafe { fn eq(&self, other: Self); }
+ | -- method `eq` references the `Self` type in its parameters or return type
LL | impl NotObjectSafe for dyn NotObjectSafe { }
| ^^^^^^^^^^^^^ the trait `NotObjectSafe` cannot be made into an object
- |
- = note: method `eq` references the `Self` type in its arguments or return type
error: aborting due to previous error
diff --git a/src/test/ui/did_you_mean/issue-40006.stderr b/src/test/ui/did_you_mean/issue-40006.stderr
index 87e48cd1e1cd9..5b384045a486a 100644
--- a/src/test/ui/did_you_mean/issue-40006.stderr
+++ b/src/test/ui/did_you_mean/issue-40006.stderr
@@ -61,8 +61,9 @@ error[E0038]: the trait `X` cannot be made into an object
|
LL | impl dyn X {
| ^^^^^ the trait `X` cannot be made into an object
- |
- = note: method `xxx` has no receiver
+...
+LL | fn xxx() { ### }
+ | --- associated function `xxx` has no `self` parameter
error: aborting due to 9 previous errors
diff --git a/src/test/ui/error-codes/E0033-teach.rs b/src/test/ui/error-codes/E0033-teach.rs
index 6a27b07fa8b77..1943965139423 100644
--- a/src/test/ui/error-codes/E0033-teach.rs
+++ b/src/test/ui/error-codes/E0033-teach.rs
@@ -1,14 +1,13 @@
// compile-flags: -Z teach
trait SomeTrait {
- fn foo();
+ fn foo(); //~ associated function `foo` has no `self` parameter
}
fn main() {
let trait_obj: &dyn SomeTrait = SomeTrait;
//~^ ERROR expected value, found trait `SomeTrait`
//~| ERROR E0038
- //~| method `foo` has no receiver
let &invalid = trait_obj;
//~^ ERROR E0033
diff --git a/src/test/ui/error-codes/E0033-teach.stderr b/src/test/ui/error-codes/E0033-teach.stderr
index fb630de7fc147..80f3d4441bd9f 100644
--- a/src/test/ui/error-codes/E0033-teach.stderr
+++ b/src/test/ui/error-codes/E0033-teach.stderr
@@ -7,13 +7,14 @@ LL | let trait_obj: &dyn SomeTrait = SomeTrait;
error[E0038]: the trait `SomeTrait` cannot be made into an object
--> $DIR/E0033-teach.rs:8:20
|
+LL | fn foo();
+ | --- associated function `foo` has no `self` parameter
+...
LL | let trait_obj: &dyn SomeTrait = SomeTrait;
| ^^^^^^^^^^^^^^ the trait `SomeTrait` cannot be made into an object
- |
- = note: method `foo` has no receiver
error[E0033]: type `&dyn SomeTrait` cannot be dereferenced
- --> $DIR/E0033-teach.rs:13:9
+ --> $DIR/E0033-teach.rs:12:9
|
LL | let &invalid = trait_obj;
| ^^^^^^^^ type `&dyn SomeTrait` cannot be dereferenced
diff --git a/src/test/ui/error-codes/E0033.rs b/src/test/ui/error-codes/E0033.rs
index 582600e110ba0..e5f0530f45ff8 100644
--- a/src/test/ui/error-codes/E0033.rs
+++ b/src/test/ui/error-codes/E0033.rs
@@ -1,12 +1,11 @@
trait SomeTrait {
- fn foo();
+ fn foo(); //~ associated function `foo` has no `self` parameter
}
fn main() {
let trait_obj: &dyn SomeTrait = SomeTrait;
//~^ ERROR expected value, found trait `SomeTrait`
//~| ERROR E0038
- //~| method `foo` has no receiver
let &invalid = trait_obj;
//~^ ERROR E0033
diff --git a/src/test/ui/error-codes/E0033.stderr b/src/test/ui/error-codes/E0033.stderr
index fe9f45d86a6a0..c2843796cc851 100644
--- a/src/test/ui/error-codes/E0033.stderr
+++ b/src/test/ui/error-codes/E0033.stderr
@@ -7,13 +7,14 @@ LL | let trait_obj: &dyn SomeTrait = SomeTrait;
error[E0038]: the trait `SomeTrait` cannot be made into an object
--> $DIR/E0033.rs:6:20
|
+LL | fn foo();
+ | --- associated function `foo` has no `self` parameter
+...
LL | let trait_obj: &dyn SomeTrait = SomeTrait;
| ^^^^^^^^^^^^^^ the trait `SomeTrait` cannot be made into an object
- |
- = note: method `foo` has no receiver
error[E0033]: type `&dyn SomeTrait` cannot be dereferenced
- --> $DIR/E0033.rs:11:9
+ --> $DIR/E0033.rs:10:9
|
LL | let &invalid = trait_obj;
| ^^^^^^^^ type `&dyn SomeTrait` cannot be dereferenced
diff --git a/src/test/ui/error-codes/E0038.stderr b/src/test/ui/error-codes/E0038.stderr
index e3d7593e42a71..5c4d6d53c4626 100644
--- a/src/test/ui/error-codes/E0038.stderr
+++ b/src/test/ui/error-codes/E0038.stderr
@@ -1,10 +1,11 @@
error[E0038]: the trait `Trait` cannot be made into an object
--> $DIR/E0038.rs:5:1
|
+LL | fn foo(&self) -> Self;
+ | --- method `foo` references the `Self` type in its parameters or return type
+...
LL | fn call_foo(x: Box) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` cannot be made into an object
- |
- = note: method `foo` references the `Self` type in its arguments or return type
error: aborting due to previous error
diff --git a/src/test/ui/explicit/explicit-self-lifetime-mismatch.rs b/src/test/ui/explicit/explicit-self-lifetime-mismatch.rs
index 82c64bcf6a767..9ab8e13893bc7 100644
--- a/src/test/ui/explicit/explicit-self-lifetime-mismatch.rs
+++ b/src/test/ui/explicit/explicit-self-lifetime-mismatch.rs
@@ -6,11 +6,11 @@ struct Foo<'a,'b> {
impl<'a,'b> Foo<'a,'b> {
fn bar(self:
Foo<'b,'a>
- //~^ ERROR mismatched method receiver
+ //~^ ERROR mismatched `self` parameter type
//~| expected type `Foo<'a, 'b>`
//~| found type `Foo<'b, 'a>`
//~| lifetime mismatch
- //~| ERROR mismatched method receiver
+ //~| ERROR mismatched `self` parameter type
//~| expected type `Foo<'a, 'b>`
//~| found type `Foo<'b, 'a>`
//~| lifetime mismatch
diff --git a/src/test/ui/explicit/explicit-self-lifetime-mismatch.stderr b/src/test/ui/explicit/explicit-self-lifetime-mismatch.stderr
index e6f9eded9a4f3..4bf2d573d4f96 100644
--- a/src/test/ui/explicit/explicit-self-lifetime-mismatch.stderr
+++ b/src/test/ui/explicit/explicit-self-lifetime-mismatch.stderr
@@ -1,4 +1,4 @@
-error[E0308]: mismatched method receiver
+error[E0308]: mismatched `self` parameter type
--> $DIR/explicit-self-lifetime-mismatch.rs:8:12
|
LL | Foo<'b,'a>
@@ -17,7 +17,7 @@ note: ...does not necessarily outlive the lifetime 'a as defined on the impl at
LL | impl<'a,'b> Foo<'a,'b> {
| ^^
-error[E0308]: mismatched method receiver
+error[E0308]: mismatched `self` parameter type
--> $DIR/explicit-self-lifetime-mismatch.rs:8:12
|
LL | Foo<'b,'a>
diff --git a/src/test/ui/impl-trait/recursive-impl-trait-type--through-non-recursize.rs b/src/test/ui/impl-trait/recursive-impl-trait-type--through-non-recursize.rs
new file mode 100644
index 0000000000000..cfd9c0ec5b45b
--- /dev/null
+++ b/src/test/ui/impl-trait/recursive-impl-trait-type--through-non-recursize.rs
@@ -0,0 +1,25 @@
+// Test that impl trait does not allow creating recursive types that are
+// otherwise forbidden. Even when there's an opaque type in another crate
+// hiding this.
+
+fn id(t: T) -> impl Sized { t }
+
+fn recursive_id() -> impl Sized { //~ ERROR opaque type expands to a recursive type
+ id(recursive_id2())
+}
+
+fn recursive_id2() -> impl Sized { //~ ERROR opaque type expands to a recursive type
+ id(recursive_id())
+}
+
+fn wrap(t: T) -> impl Sized { (t,) }
+
+fn recursive_wrap() -> impl Sized { //~ ERROR opaque type expands to a recursive type
+ wrap(recursive_wrap2())
+}
+
+fn recursive_wrap2() -> impl Sized { //~ ERROR opaque type expands to a recursive type
+ wrap(recursive_wrap())
+}
+
+fn main() {}
diff --git a/src/test/ui/impl-trait/recursive-impl-trait-type--through-non-recursize.stderr b/src/test/ui/impl-trait/recursive-impl-trait-type--through-non-recursize.stderr
new file mode 100644
index 0000000000000..7572c6c1bf057
--- /dev/null
+++ b/src/test/ui/impl-trait/recursive-impl-trait-type--through-non-recursize.stderr
@@ -0,0 +1,35 @@
+error[E0720]: opaque type expands to a recursive type
+ --> $DIR/recursive-impl-trait-type--through-non-recursize.rs:7:22
+ |
+LL | fn recursive_id() -> impl Sized {
+ | ^^^^^^^^^^ expands to a recursive type
+ |
+ = note: type resolves to itself
+
+error[E0720]: opaque type expands to a recursive type
+ --> $DIR/recursive-impl-trait-type--through-non-recursize.rs:11:23
+ |
+LL | fn recursive_id2() -> impl Sized {
+ | ^^^^^^^^^^ expands to a recursive type
+ |
+ = note: type resolves to itself
+
+error[E0720]: opaque type expands to a recursive type
+ --> $DIR/recursive-impl-trait-type--through-non-recursize.rs:17:24
+ |
+LL | fn recursive_wrap() -> impl Sized {
+ | ^^^^^^^^^^ expands to a recursive type
+ |
+ = note: expanded type is `((impl Sized,),)`
+
+error[E0720]: opaque type expands to a recursive type
+ --> $DIR/recursive-impl-trait-type--through-non-recursize.rs:21:25
+ |
+LL | fn recursive_wrap2() -> impl Sized {
+ | ^^^^^^^^^^ expands to a recursive type
+ |
+ = note: expanded type is `((impl Sized,),)`
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0720`.
diff --git a/src/test/ui/issues/issue-17740.rs b/src/test/ui/issues/issue-17740.rs
index c131b895849ae..b47568400c3b7 100644
--- a/src/test/ui/issues/issue-17740.rs
+++ b/src/test/ui/issues/issue-17740.rs
@@ -4,11 +4,11 @@ struct Foo<'a> {
impl <'a> Foo<'a>{
fn bar(self: &mut Foo) {
- //~^ mismatched method receiver
+ //~^ mismatched `self` parameter type
//~| expected type `Foo<'a>`
//~| found type `Foo<'_>`
//~| lifetime mismatch
- //~| mismatched method receiver
+ //~| mismatched `self` parameter type
//~| expected type `Foo<'a>`
//~| found type `Foo<'_>`
//~| lifetime mismatch
diff --git a/src/test/ui/issues/issue-17740.stderr b/src/test/ui/issues/issue-17740.stderr
index 7ab0fa4d818b0..b8a0a0676319a 100644
--- a/src/test/ui/issues/issue-17740.stderr
+++ b/src/test/ui/issues/issue-17740.stderr
@@ -1,4 +1,4 @@
-error[E0308]: mismatched method receiver
+error[E0308]: mismatched `self` parameter type
--> $DIR/issue-17740.rs:6:18
|
LL | fn bar(self: &mut Foo) {
@@ -23,7 +23,7 @@ note: ...does not necessarily outlive the lifetime 'a as defined on the impl at
LL | impl <'a> Foo<'a>{
| ^^
-error[E0308]: mismatched method receiver
+error[E0308]: mismatched `self` parameter type
--> $DIR/issue-17740.rs:6:18
|
LL | fn bar(self: &mut Foo) {
diff --git a/src/test/ui/issues/issue-17905-2.rs b/src/test/ui/issues/issue-17905-2.rs
index 259d945018938..44279cc867b46 100644
--- a/src/test/ui/issues/issue-17905-2.rs
+++ b/src/test/ui/issues/issue-17905-2.rs
@@ -6,8 +6,8 @@ impl Pair<
isize
> {
fn say(self: &Pair<&str, isize>) {
-//~^ ERROR mismatched method receiver
-//~| ERROR mismatched method receiver
+//~^ ERROR mismatched `self` parameter type
+//~| ERROR mismatched `self` parameter type
println!("{:?}", self);
}
}
diff --git a/src/test/ui/issues/issue-17905-2.stderr b/src/test/ui/issues/issue-17905-2.stderr
index e3909e0c1253f..585bc9c14883b 100644
--- a/src/test/ui/issues/issue-17905-2.stderr
+++ b/src/test/ui/issues/issue-17905-2.stderr
@@ -1,4 +1,4 @@
-error[E0308]: mismatched method receiver
+error[E0308]: mismatched `self` parameter type
--> $DIR/issue-17905-2.rs:8:18
|
LL | fn say(self: &Pair<&str, isize>) {
@@ -21,7 +21,7 @@ note: ...does not necessarily outlive the lifetime '_ as defined on the impl at
LL | &str,
| ^
-error[E0308]: mismatched method receiver
+error[E0308]: mismatched `self` parameter type
--> $DIR/issue-17905-2.rs:8:18
|
LL | fn say(self: &Pair<&str, isize>) {
diff --git a/src/test/ui/issues/issue-18959.stderr b/src/test/ui/issues/issue-18959.stderr
index 63c33b7f4472d..d5e7092801ecd 100644
--- a/src/test/ui/issues/issue-18959.stderr
+++ b/src/test/ui/issues/issue-18959.stderr
@@ -1,10 +1,11 @@
error[E0038]: the trait `Bar` cannot be made into an object
--> $DIR/issue-18959.rs:11:1
|
+LL | pub trait Foo { fn foo(&self, ext_thing: &T); }
+ | --- method `foo` has generic type parameters
+...
LL | fn foo(b: &dyn Bar) {
| ^^^^^^^^^^^^^^^^^^^ the trait `Bar` cannot be made into an object
- |
- = note: method `foo` has generic type parameters
error: aborting due to previous error
diff --git a/src/test/ui/issues/issue-19380.stderr b/src/test/ui/issues/issue-19380.stderr
index 27e3ff57bf9ab..92bfdf1f26e93 100644
--- a/src/test/ui/issues/issue-19380.stderr
+++ b/src/test/ui/issues/issue-19380.stderr
@@ -1,10 +1,11 @@
error[E0038]: the trait `Qiz` cannot be made into an object
--> $DIR/issue-19380.rs:11:3
|
+LL | fn qiz();
+ | --- associated function `qiz` has no `self` parameter
+...
LL | foos: &'static [&'static (dyn Qiz + 'static)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Qiz` cannot be made into an object
- |
- = note: method `qiz` has no receiver
error: aborting due to previous error
diff --git a/src/test/ui/issues/issue-19538.stderr b/src/test/ui/issues/issue-19538.stderr
index e5da0a9b0dac3..5415a45f7d621 100644
--- a/src/test/ui/issues/issue-19538.stderr
+++ b/src/test/ui/issues/issue-19538.stderr
@@ -1,18 +1,21 @@
error[E0038]: the trait `Bar` cannot be made into an object
--> $DIR/issue-19538.rs:17:15
|
+LL | fn foo(&self, val: T);
+ | --- method `foo` has generic type parameters
+...
LL | let test: &mut dyn Bar = &mut thing;
| ^^^^^^^^^^^^ the trait `Bar` cannot be made into an object
- |
- = note: method `foo` has generic type parameters
error[E0038]: the trait `Bar` cannot be made into an object
--> $DIR/issue-19538.rs:17:30
|
+LL | fn foo(&self, val: T);
+ | --- method `foo` has generic type parameters
+...
LL | let test: &mut dyn Bar = &mut thing;
| ^^^^^^^^^^ the trait `Bar` cannot be made into an object
|
- = note: method `foo` has generic type parameters
= note: required because of the requirements on the impl of `std::ops::CoerceUnsized<&mut dyn Bar>` for `&mut Thing`
error: aborting due to 2 previous errors
diff --git a/src/test/ui/issues/issue-50781.stderr b/src/test/ui/issues/issue-50781.stderr
index c98f78c51ee5f..02475ea97e3d1 100644
--- a/src/test/ui/issues/issue-50781.stderr
+++ b/src/test/ui/issues/issue-50781.stderr
@@ -1,8 +1,8 @@
error: the trait `X` cannot be made into an object
- --> $DIR/issue-50781.rs:6:5
+ --> $DIR/issue-50781.rs:6:8
|
LL | fn foo(&self) where Self: Trait;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^
|
note: lint level defined here
--> $DIR/issue-50781.rs:1:9
diff --git a/src/test/ui/issues/issue-56806.rs b/src/test/ui/issues/issue-56806.rs
index b6454e578e6af..b1dac26d65a15 100644
--- a/src/test/ui/issues/issue-56806.rs
+++ b/src/test/ui/issues/issue-56806.rs
@@ -1,7 +1,6 @@
pub trait Trait {
fn dyn_instead_of_self(self: Box);
- //~^ ERROR invalid method receiver type: std::boxed::Box<(dyn Trait + 'static)>
+ //~^ ERROR invalid `self` parameter type
}
-pub fn main() {
-}
+pub fn main() {}
diff --git a/src/test/ui/issues/issue-56806.stderr b/src/test/ui/issues/issue-56806.stderr
index fae6a26720f36..a4f9aadcfef3e 100644
--- a/src/test/ui/issues/issue-56806.stderr
+++ b/src/test/ui/issues/issue-56806.stderr
@@ -1,11 +1,12 @@
-error[E0307]: invalid method receiver type: std::boxed::Box<(dyn Trait + 'static)>
+error[E0307]: invalid `self` parameter type: std::boxed::Box<(dyn Trait + 'static)>
--> $DIR/issue-56806.rs:2:34
|
LL | fn dyn_instead_of_self(self: Box);
| ^^^^^^^^^^^^^^
|
- = note: type must be `Self` or a type that dereferences to it
+ = note: type of `self` must be `Self` or a type that dereferences to it
= help: consider changing to `self`, `&self`, `&mut self`, `self: Box`, `self: Rc`, `self: Arc`, or `self: Pin` (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 E0307`.
diff --git a/src/test/ui/lint/issue-54538-unused-parens-lint.rs b/src/test/ui/lint/issue-54538-unused-parens-lint.rs
index eda9e2cdfaa2f..c442c39fe010e 100644
--- a/src/test/ui/lint/issue-54538-unused-parens-lint.rs
+++ b/src/test/ui/lint/issue-54538-unused-parens-lint.rs
@@ -1,25 +1,75 @@
-// build-pass (FIXME(62277): could be check-pass?)
+#![feature(box_patterns)]
+
+#![feature(or_patterns)]
+//~^ WARN the feature `or_patterns` is incomplete
#![allow(ellipsis_inclusive_range_patterns)]
#![allow(unreachable_patterns)]
#![allow(unused_variables)]
-#![warn(unused_parens)]
+#![deny(unused_parens)]
+
+fn lint_on_top_level() {
+ let (a) = 0; //~ ERROR unnecessary parentheses around pattern
+ for (a) in 0..1 {} //~ ERROR unnecessary parentheses around pattern
+ if let (a) = 0 {} //~ ERROR unnecessary parentheses around pattern
+ while let (a) = 0 {} //~ ERROR unnecessary parentheses around pattern
+ fn foo((a): u8) {} //~ ERROR unnecessary parentheses around pattern
+ let _ = |(a): u8| 0; //~ ERROR unnecessary parentheses around pattern
+}
+
+// Don't lint in these cases (#64106).
+fn or_patterns_no_lint() {
+ match Box::new(0) {
+ box (0 | 1) => {} // Should not lint as `box 0 | 1` binds as `(box 0) | 1`.
+ _ => {}
+ }
+
+ match 0 {
+ x @ (0 | 1) => {} // Should not lint as `x @ 0 | 1` binds as `(x @ 0) | 1`.
+ _ => {}
+ }
+
+ if let &(0 | 1) = &0 {} // Should also not lint.
+ if let &mut (0 | 1) = &mut 0 {} // Same.
+
+ fn foo((Ok(a) | Err(a)): Result) {} // Doesn't parse if we remove parens for now.
+ //~^ ERROR identifier `a` is bound more than once
+
+ let _ = |(Ok(a) | Err(a)): Result| 1; // `|Ok(a) | Err(a)| 1` parses as bit-or.
+ //~^ ERROR identifier `a` is bound more than once
+}
+
+fn or_patterns_will_lint() {
+ if let (0 | 1) = 0 {} //~ ERROR unnecessary parentheses around pattern
+ if let ((0 | 1),) = (0,) {} //~ ERROR unnecessary parentheses around pattern
+ if let [(0 | 1)] = [0] {} //~ ERROR unnecessary parentheses around pattern
+ if let 0 | (1 | 2) = 0 {} //~ ERROR unnecessary parentheses around pattern
+ struct TS(u8);
+ if let TS((0 | 1)) = TS(0) {} //~ ERROR unnecessary parentheses around pattern
+ struct NS { f: u8 }
+ if let NS { f: (0 | 1) } = (NS { f: 0 }) {} //~ ERROR unnecessary parentheses around pattern
+}
+
+// Don't lint on `&(mut x)` because `&mut x` means something else (#55342).
+fn deref_mut_binding_no_lint() {
+ let &(mut x) = &0;
+}
fn main() {
match 1 {
- (_) => {} //~ WARNING: unnecessary parentheses around pattern
- (y) => {} //~ WARNING: unnecessary parentheses around pattern
- (ref r) => {} //~ WARNING: unnecessary parentheses around pattern
- (e @ 1...2) => {} //~ WARNING: unnecessary parentheses around outer pattern
- (1...2) => {} // Non ambiguous range pattern should not warn
+ (_) => {} //~ ERROR unnecessary parentheses around pattern
+ (y) => {} //~ ERROR unnecessary parentheses around pattern
+ (ref r) => {} //~ ERROR unnecessary parentheses around pattern
+ (e @ 1...2) => {} //~ ERROR unnecessary parentheses around pattern
+ (1...2) => {} // Non ambiguous range pattern should not warn
e @ (3...4) => {} // Non ambiguous range pattern should not warn
}
match &1 {
- (e @ &(1...2)) => {} //~ WARNING: unnecessary parentheses around outer pattern
- &(_) => {} //~ WARNING: unnecessary parentheses around pattern
- e @ &(1...2) => {} // Ambiguous range pattern should not warn
- &(1...2) => {} // Ambiguous range pattern should not warn
+ (e @ &(1...2)) => {} //~ ERROR unnecessary parentheses around pattern
+ &(_) => {} //~ ERROR unnecessary parentheses around pattern
+ e @ &(1...2) => {} // Ambiguous range pattern should not warn
+ &(1...2) => {} // Ambiguous range pattern should not warn
}
match &1 {
@@ -28,19 +78,19 @@ fn main() {
}
match 1 {
- (_) => {} //~ WARNING: unnecessary parentheses around pattern
- (y) => {} //~ WARNING: unnecessary parentheses around pattern
- (ref r) => {} //~ WARNING: unnecessary parentheses around pattern
- (e @ 1..=2) => {} //~ WARNING: unnecessary parentheses around outer pattern
- (1..=2) => {} // Non ambiguous range pattern should not warn
+ (_) => {} //~ ERROR unnecessary parentheses around pattern
+ (y) => {} //~ ERROR unnecessary parentheses around pattern
+ (ref r) => {} //~ ERROR unnecessary parentheses around pattern
+ (e @ 1..=2) => {} //~ ERROR unnecessary parentheses around pattern
+ (1..=2) => {} // Non ambiguous range pattern should not warn
e @ (3..=4) => {} // Non ambiguous range pattern should not warn
}
match &1 {
- (e @ &(1..=2)) => {} //~ WARNING: unnecessary parentheses around outer pattern
- &(_) => {} //~ WARNING: unnecessary parentheses around pattern
- e @ &(1..=2) => {} // Ambiguous range pattern should not warn
- &(1..=2) => {} // Ambiguous range pattern should not warn
+ (e @ &(1..=2)) => {} //~ ERROR unnecessary parentheses around pattern
+ &(_) => {} //~ ERROR unnecessary parentheses around pattern
+ e @ &(1..=2) => {} // Ambiguous range pattern should not warn
+ &(1..=2) => {} // Ambiguous range pattern should not warn
}
match &1 {
diff --git a/src/test/ui/lint/issue-54538-unused-parens-lint.stderr b/src/test/ui/lint/issue-54538-unused-parens-lint.stderr
index 3b312198952a5..a3e0fb938b3c6 100644
--- a/src/test/ui/lint/issue-54538-unused-parens-lint.stderr
+++ b/src/test/ui/lint/issue-54538-unused-parens-lint.stderr
@@ -1,78 +1,173 @@
-warning: unnecessary parentheses around pattern
- --> $DIR/issue-54538-unused-parens-lint.rs:10:9
+error[E0416]: identifier `a` is bound more than once in the same pattern
+ --> $DIR/issue-54538-unused-parens-lint.rs:35:25
|
-LL | (_) => {}
+LL | fn foo((Ok(a) | Err(a)): Result) {} // Doesn't parse if we remove parens for now.
+ | ^ used in a pattern more than once
+
+error[E0416]: identifier `a` is bound more than once in the same pattern
+ --> $DIR/issue-54538-unused-parens-lint.rs:38:27
+ |
+LL | let _ = |(Ok(a) | Err(a)): Result| 1; // `|Ok(a) | Err(a)| 1` parses as bit-or.
+ | ^ used in a pattern more than once
+
+warning: the feature `or_patterns` is incomplete and may cause the compiler to crash
+ --> $DIR/issue-54538-unused-parens-lint.rs:3:12
+ |
+LL | #![feature(or_patterns)]
+ | ^^^^^^^^^^^
+ |
+ = note: `#[warn(incomplete_features)]` on by default
+
+error: unnecessary parentheses around pattern
+ --> $DIR/issue-54538-unused-parens-lint.rs:12:9
+ |
+LL | let (a) = 0;
| ^^^ help: remove these parentheses
|
note: lint level defined here
- --> $DIR/issue-54538-unused-parens-lint.rs:6:9
+ --> $DIR/issue-54538-unused-parens-lint.rs:9:9
|
-LL | #![warn(unused_parens)]
+LL | #![deny(unused_parens)]
| ^^^^^^^^^^^^^
-warning: unnecessary parentheses around pattern
- --> $DIR/issue-54538-unused-parens-lint.rs:11:9
+error: unnecessary parentheses around pattern
+ --> $DIR/issue-54538-unused-parens-lint.rs:13:9
+ |
+LL | for (a) in 0..1 {}
+ | ^^^ help: remove these parentheses
+
+error: unnecessary parentheses around pattern
+ --> $DIR/issue-54538-unused-parens-lint.rs:14:12
+ |
+LL | if let (a) = 0 {}
+ | ^^^ help: remove these parentheses
+
+error: unnecessary parentheses around pattern
+ --> $DIR/issue-54538-unused-parens-lint.rs:15:15
+ |
+LL | while let (a) = 0 {}
+ | ^^^ help: remove these parentheses
+
+error: unnecessary parentheses around pattern
+ --> $DIR/issue-54538-unused-parens-lint.rs:16:12
+ |
+LL | fn foo((a): u8) {}
+ | ^^^ help: remove these parentheses
+
+error: unnecessary parentheses around pattern
+ --> $DIR/issue-54538-unused-parens-lint.rs:17:14
+ |
+LL | let _ = |(a): u8| 0;
+ | ^^^ help: remove these parentheses
+
+error: unnecessary parentheses around pattern
+ --> $DIR/issue-54538-unused-parens-lint.rs:43:12
+ |
+LL | if let (0 | 1) = 0 {}
+ | ^^^^^^^ help: remove these parentheses
+
+error: unnecessary parentheses around pattern
+ --> $DIR/issue-54538-unused-parens-lint.rs:44:13
+ |
+LL | if let ((0 | 1),) = (0,) {}
+ | ^^^^^^^ help: remove these parentheses
+
+error: unnecessary parentheses around pattern
+ --> $DIR/issue-54538-unused-parens-lint.rs:45:13
+ |
+LL | if let [(0 | 1)] = [0] {}
+ | ^^^^^^^ help: remove these parentheses
+
+error: unnecessary parentheses around pattern
+ --> $DIR/issue-54538-unused-parens-lint.rs:46:16
+ |
+LL | if let 0 | (1 | 2) = 0 {}
+ | ^^^^^^^ help: remove these parentheses
+
+error: unnecessary parentheses around pattern
+ --> $DIR/issue-54538-unused-parens-lint.rs:48:15
+ |
+LL | if let TS((0 | 1)) = TS(0) {}
+ | ^^^^^^^ help: remove these parentheses
+
+error: unnecessary parentheses around pattern
+ --> $DIR/issue-54538-unused-parens-lint.rs:50:20
+ |
+LL | if let NS { f: (0 | 1) } = (NS { f: 0 }) {}
+ | ^^^^^^^ help: remove these parentheses
+
+error: unnecessary parentheses around pattern
+ --> $DIR/issue-54538-unused-parens-lint.rs:60:9
+ |
+LL | (_) => {}
+ | ^^^ help: remove these parentheses
+
+error: unnecessary parentheses around pattern
+ --> $DIR/issue-54538-unused-parens-lint.rs:61:9
|
LL | (y) => {}
| ^^^ help: remove these parentheses
-warning: unnecessary parentheses around pattern
- --> $DIR/issue-54538-unused-parens-lint.rs:12:9
+error: unnecessary parentheses around pattern
+ --> $DIR/issue-54538-unused-parens-lint.rs:62:9
|
LL | (ref r) => {}
| ^^^^^^^ help: remove these parentheses
-warning: unnecessary parentheses around pattern
- --> $DIR/issue-54538-unused-parens-lint.rs:13:9
+error: unnecessary parentheses around pattern
+ --> $DIR/issue-54538-unused-parens-lint.rs:63:9
|
LL | (e @ 1...2) => {}
| ^^^^^^^^^^^ help: remove these parentheses
-warning: unnecessary parentheses around pattern
- --> $DIR/issue-54538-unused-parens-lint.rs:19:9
+error: unnecessary parentheses around pattern
+ --> $DIR/issue-54538-unused-parens-lint.rs:69:9
|
LL | (e @ &(1...2)) => {}
| ^^^^^^^^^^^^^^ help: remove these parentheses
-warning: unnecessary parentheses around pattern
- --> $DIR/issue-54538-unused-parens-lint.rs:20:10
+error: unnecessary parentheses around pattern
+ --> $DIR/issue-54538-unused-parens-lint.rs:70:10
|
LL | &(_) => {}
| ^^^ help: remove these parentheses
-warning: unnecessary parentheses around pattern
- --> $DIR/issue-54538-unused-parens-lint.rs:31:9
+error: unnecessary parentheses around pattern
+ --> $DIR/issue-54538-unused-parens-lint.rs:81:9
|
LL | (_) => {}
| ^^^ help: remove these parentheses
-warning: unnecessary parentheses around pattern
- --> $DIR/issue-54538-unused-parens-lint.rs:32:9
+error: unnecessary parentheses around pattern
+ --> $DIR/issue-54538-unused-parens-lint.rs:82:9
|
LL | (y) => {}
| ^^^ help: remove these parentheses
-warning: unnecessary parentheses around pattern
- --> $DIR/issue-54538-unused-parens-lint.rs:33:9
+error: unnecessary parentheses around pattern
+ --> $DIR/issue-54538-unused-parens-lint.rs:83:9
|
LL | (ref r) => {}
| ^^^^^^^ help: remove these parentheses
-warning: unnecessary parentheses around pattern
- --> $DIR/issue-54538-unused-parens-lint.rs:34:9
+error: unnecessary parentheses around pattern
+ --> $DIR/issue-54538-unused-parens-lint.rs:84:9
|
LL | (e @ 1..=2) => {}
| ^^^^^^^^^^^ help: remove these parentheses
-warning: unnecessary parentheses around pattern
- --> $DIR/issue-54538-unused-parens-lint.rs:40:9
+error: unnecessary parentheses around pattern
+ --> $DIR/issue-54538-unused-parens-lint.rs:90:9
|
LL | (e @ &(1..=2)) => {}
| ^^^^^^^^^^^^^^ help: remove these parentheses
-warning: unnecessary parentheses around pattern
- --> $DIR/issue-54538-unused-parens-lint.rs:41:10
+error: unnecessary parentheses around pattern
+ --> $DIR/issue-54538-unused-parens-lint.rs:91:10
|
LL | &(_) => {}
| ^^^ help: remove these parentheses
+error: aborting due to 26 previous errors
+
+For more information about this error, try `rustc --explain E0416`.
diff --git a/src/test/ui/object-safety/object-safety-associated-consts.stderr b/src/test/ui/object-safety/object-safety-associated-consts.stderr
index 55f9e3f9f138b..7d5aa00356e0b 100644
--- a/src/test/ui/object-safety/object-safety-associated-consts.stderr
+++ b/src/test/ui/object-safety/object-safety-associated-consts.stderr
@@ -1,10 +1,11 @@
error[E0038]: the trait `Bar` cannot be made into an object
--> $DIR/object-safety-associated-consts.rs:9:1
|
+LL | const X: usize;
+ | - the trait cannot contain associated consts like `X`
+...
LL | fn make_bar(t: &T) -> &dyn Bar {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` cannot be made into an object
- |
- = note: the trait cannot contain associated consts like `X`
error: aborting due to previous error
diff --git a/src/test/ui/object-safety/object-safety-generics.stderr b/src/test/ui/object-safety/object-safety-generics.stderr
index d66cdb98448d4..b25e0052e4163 100644
--- a/src/test/ui/object-safety/object-safety-generics.stderr
+++ b/src/test/ui/object-safety/object-safety-generics.stderr
@@ -1,18 +1,20 @@
error[E0038]: the trait `Bar` cannot be made into an object
--> $DIR/object-safety-generics.rs:14:1
|
+LL | fn bar(&self, t: T);
+ | --- method `bar` has generic type parameters
+...
LL | fn make_bar(t: &T) -> &dyn Bar {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` cannot be made into an object
- |
- = note: method `bar` has generic type parameters
error[E0038]: the trait `Bar` cannot be made into an object
--> $DIR/object-safety-generics.rs:19:1
|
+LL | fn bar(&self, t: T);
+ | --- method `bar` has generic type parameters
+...
LL | fn make_bar_explicit(t: &T) -> &dyn Bar {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` cannot be made into an object
- |
- = note: method `bar` has generic type parameters
error: aborting due to 2 previous errors
diff --git a/src/test/ui/object-safety/object-safety-mentions-Self.stderr b/src/test/ui/object-safety/object-safety-mentions-Self.stderr
index c0c471c2b1e72..971e79cb0210f 100644
--- a/src/test/ui/object-safety/object-safety-mentions-Self.stderr
+++ b/src/test/ui/object-safety/object-safety-mentions-Self.stderr
@@ -1,18 +1,20 @@
error[E0038]: the trait `Bar` cannot be made into an object
--> $DIR/object-safety-mentions-Self.rs:17:1
|
+LL | fn bar(&self, x: &Self);
+ | --- method `bar` references the `Self` type in its parameters or return type
+...
LL | fn make_bar(t: &T) -> &dyn Bar {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` cannot be made into an object
- |
- = note: method `bar` references the `Self` type in its arguments or return type
error[E0038]: the trait `Baz` cannot be made into an object
--> $DIR/object-safety-mentions-Self.rs:22:1
|
+LL | fn bar(&self) -> Self;
+ | --- method `bar` references the `Self` type in its parameters or return type
+...
LL | fn make_baz(t: &T) -> &dyn Baz {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Baz` cannot be made into an object
- |
- = note: method `bar` references the `Self` type in its arguments or return type
error: aborting due to 2 previous errors
diff --git a/src/test/ui/object-safety/object-safety-no-static.stderr b/src/test/ui/object-safety/object-safety-no-static.stderr
index da8dd657c2a9d..0de783f60ea47 100644
--- a/src/test/ui/object-safety/object-safety-no-static.stderr
+++ b/src/test/ui/object-safety/object-safety-no-static.stderr
@@ -1,10 +1,11 @@
error[E0038]: the trait `Foo` cannot be made into an object
--> $DIR/object-safety-no-static.rs:8:1
|
+LL | fn foo();
+ | --- associated function `foo` has no `self` parameter
+...
LL | fn foo_implicit(b: Box) -> Box {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` cannot be made into an object
- |
- = note: method `foo` has no receiver
error: aborting due to previous error
diff --git a/src/test/ui/resolve/issue-3907-2.stderr b/src/test/ui/resolve/issue-3907-2.stderr
index 968c1f3e463d0..63ac11dc8ae01 100644
--- a/src/test/ui/resolve/issue-3907-2.stderr
+++ b/src/test/ui/resolve/issue-3907-2.stderr
@@ -4,7 +4,7 @@ error[E0038]: the trait `issue_3907::Foo` cannot be made into an object
LL | fn bar(_x: Foo) {}
| ^^^^^^^^^^^^^^^ the trait `issue_3907::Foo` cannot be made into an object
|
- = note: method `bar` has no receiver
+ = note: associated function `bar` has no `self` parameter
error: aborting due to previous error
diff --git a/src/test/ui/rfc-2565-param-attrs/auxiliary/ident-mac.rs b/src/test/ui/rfc-2565-param-attrs/auxiliary/ident-mac.rs
new file mode 100644
index 0000000000000..b62cf31205fd3
--- /dev/null
+++ b/src/test/ui/rfc-2565-param-attrs/auxiliary/ident-mac.rs
@@ -0,0 +1,11 @@
+// force-host
+// no-prefer-dynamic
+
+#![crate_type = "proc-macro"]
+
+extern crate proc_macro;
+
+use proc_macro::TokenStream;
+
+#[proc_macro_attribute]
+pub fn id(_: TokenStream, input: TokenStream) -> TokenStream { input }
diff --git a/src/test/ui/rfc-2565-param-attrs/proc-macro-cannot-be-used.rs b/src/test/ui/rfc-2565-param-attrs/proc-macro-cannot-be-used.rs
new file mode 100644
index 0000000000000..8defa26e48d8d
--- /dev/null
+++ b/src/test/ui/rfc-2565-param-attrs/proc-macro-cannot-be-used.rs
@@ -0,0 +1,60 @@
+// aux-build:ident-mac.rs
+
+#![feature(param_attrs)]
+#![feature(c_variadic)]
+
+extern crate ident_mac;
+use ident_mac::id;
+
+struct W(u8);
+
+extern "C" { fn ffi(#[id] arg1: i32, #[id] ...); }
+//~^ ERROR the attribute `id` is currently unknown to the compiler
+//~| ERROR the attribute `id` is currently unknown to the compiler
+
+unsafe extern "C" fn cvar(arg1: i32, #[id] mut args: ...) {}
+//~^ ERROR the attribute `id` is currently unknown to the compiler
+
+type Alias = extern "C" fn(#[id] u8, #[id] ...);
+ //~^ ERROR the attribute `id` is currently unknown to the compiler
+ //~| ERROR the attribute `id` is currently unknown to the compiler
+
+fn free(#[id] arg1: u8) {
+ //~^ ERROR the attribute `id` is currently unknown to the compiler
+ let lam = |#[id] W(x), #[id] y| ();
+ //~^ ERROR the attribute `id` is currently unknown to the compiler
+ //~| ERROR the attribute `id` is currently unknown to the compiler
+}
+
+impl W {
+ fn inherent1(#[id] self, #[id] arg1: u8) {}
+ //~^ ERROR the attribute `id` is currently unknown to the compiler
+ //~| ERROR the attribute `id` is currently unknown to the compiler
+ fn inherent2(#[id] &self, #[id] arg1: u8) {}
+ //~^ ERROR the attribute `id` is currently unknown to the compiler
+ //~| ERROR the attribute `id` is currently unknown to the compiler
+ fn inherent3<'a>(#[id] &'a mut self, #[id] arg1: u8) {}
+ //~^ ERROR the attribute `id` is currently unknown to the compiler
+ //~| ERROR the attribute `id` is currently unknown to the compiler
+ fn inherent4<'a>(#[id] self: Box, #[id] arg1: u8) {}
+ //~^ ERROR the attribute `id` is currently unknown to the compiler
+ //~| ERROR the attribute `id` is currently unknown to the compiler
+}
+
+trait A {
+ fn trait1(#[id] self, #[id] arg1: u8);
+ //~^ ERROR the attribute `id` is currently unknown to the compiler
+ //~| ERROR the attribute `id` is currently unknown to the compiler
+ fn trait2(#[id] &self, #[id] arg1: u8);
+ //~^ ERROR the attribute `id` is currently unknown to the compiler
+ //~| ERROR the attribute `id` is currently unknown to the compiler
+ fn trait3<'a>(#[id] &'a mut self, #[id] arg1: u8);
+ //~^ ERROR the attribute `id` is currently unknown to the compiler
+ //~| ERROR the attribute `id` is currently unknown to the compiler
+ fn trait4<'a>(#[id] self: Box, #[id] arg1: u8, #[id] Vec);
+ //~^ ERROR the attribute `id` is currently unknown to the compiler
+ //~| ERROR the attribute `id` is currently unknown to the compiler
+ //~| ERROR the attribute `id` is currently unknown to the compiler
+}
+
+fn main() {}
diff --git a/src/test/ui/rfc-2565-param-attrs/proc-macro-cannot-be-used.stderr b/src/test/ui/rfc-2565-param-attrs/proc-macro-cannot-be-used.stderr
new file mode 100644
index 0000000000000..69b9a46b3d502
--- /dev/null
+++ b/src/test/ui/rfc-2565-param-attrs/proc-macro-cannot-be-used.stderr
@@ -0,0 +1,228 @@
+error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future
+ --> $DIR/proc-macro-cannot-be-used.rs:11:21
+ |
+LL | extern "C" { fn ffi(#[id] arg1: i32, #[id] ...); }
+ | ^^^^^
+ |
+ = note: for more information, see https://github.com/rust-lang/rust/issues/29642
+ = help: add `#![feature(custom_attribute)]` to the crate attributes to enable
+
+error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future
+ --> $DIR/proc-macro-cannot-be-used.rs:11:38
+ |
+LL | extern "C" { fn ffi(#[id] arg1: i32, #[id] ...); }
+ | ^^^^^
+ |
+ = note: for more information, see https://github.com/rust-lang/rust/issues/29642
+ = help: add `#![feature(custom_attribute)]` to the crate attributes to enable
+
+error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future
+ --> $DIR/proc-macro-cannot-be-used.rs:15:38
+ |
+LL | unsafe extern "C" fn cvar(arg1: i32, #[id] mut args: ...) {}
+ | ^^^^^
+ |
+ = note: for more information, see https://github.com/rust-lang/rust/issues/29642
+ = help: add `#![feature(custom_attribute)]` to the crate attributes to enable
+
+error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future
+ --> $DIR/proc-macro-cannot-be-used.rs:18:28
+ |
+LL | type Alias = extern "C" fn(#[id] u8, #[id] ...);
+ | ^^^^^
+ |
+ = note: for more information, see https://github.com/rust-lang/rust/issues/29642
+ = help: add `#![feature(custom_attribute)]` to the crate attributes to enable
+
+error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future
+ --> $DIR/proc-macro-cannot-be-used.rs:18:38
+ |
+LL | type Alias = extern "C" fn(#[id] u8, #[id] ...);
+ | ^^^^^
+ |
+ = note: for more information, see https://github.com/rust-lang/rust/issues/29642
+ = help: add `#![feature(custom_attribute)]` to the crate attributes to enable
+
+error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future
+ --> $DIR/proc-macro-cannot-be-used.rs:22:9
+ |
+LL | fn free(#[id] arg1: u8) {
+ | ^^^^^
+ |
+ = note: for more information, see https://github.com/rust-lang/rust/issues/29642
+ = help: add `#![feature(custom_attribute)]` to the crate attributes to enable
+
+error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future
+ --> $DIR/proc-macro-cannot-be-used.rs:24:16
+ |
+LL | let lam = |#[id] W(x), #[id] y| ();
+ | ^^^^^
+ |
+ = note: for more information, see https://github.com/rust-lang/rust/issues/29642
+ = help: add `#![feature(custom_attribute)]` to the crate attributes to enable
+
+error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future
+ --> $DIR/proc-macro-cannot-be-used.rs:24:28
+ |
+LL | let lam = |#[id] W(x), #[id] y| ();
+ | ^^^^^
+ |
+ = note: for more information, see https://github.com/rust-lang/rust/issues/29642
+ = help: add `#![feature(custom_attribute)]` to the crate attributes to enable
+
+error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future
+ --> $DIR/proc-macro-cannot-be-used.rs:30:18
+ |
+LL | fn inherent1(#[id] self, #[id] arg1: u8) {}
+ | ^^^^^
+ |
+ = note: for more information, see https://github.com/rust-lang/rust/issues/29642
+ = help: add `#![feature(custom_attribute)]` to the crate attributes to enable
+
+error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future
+ --> $DIR/proc-macro-cannot-be-used.rs:30:30
+ |
+LL | fn inherent1(#[id] self, #[id] arg1: u8) {}
+ | ^^^^^
+ |
+ = note: for more information, see https://github.com/rust-lang/rust/issues/29642
+ = help: add `#![feature(custom_attribute)]` to the crate attributes to enable
+
+error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future
+ --> $DIR/proc-macro-cannot-be-used.rs:33:18
+ |
+LL | fn inherent2(#[id] &self, #[id] arg1: u8) {}
+ | ^^^^^
+ |
+ = note: for more information, see https://github.com/rust-lang/rust/issues/29642
+ = help: add `#![feature(custom_attribute)]` to the crate attributes to enable
+
+error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future
+ --> $DIR/proc-macro-cannot-be-used.rs:33:31
+ |
+LL | fn inherent2(#[id] &self, #[id] arg1: u8) {}
+ | ^^^^^
+ |
+ = note: for more information, see https://github.com/rust-lang/rust/issues/29642
+ = help: add `#![feature(custom_attribute)]` to the crate attributes to enable
+
+error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future
+ --> $DIR/proc-macro-cannot-be-used.rs:36:22
+ |
+LL | fn inherent3<'a>(#[id] &'a mut self, #[id] arg1: u8) {}
+ | ^^^^^
+ |
+ = note: for more information, see https://github.com/rust-lang/rust/issues/29642
+ = help: add `#![feature(custom_attribute)]` to the crate attributes to enable
+
+error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future
+ --> $DIR/proc-macro-cannot-be-used.rs:36:42
+ |
+LL | fn inherent3<'a>(#[id] &'a mut self, #[id] arg1: u8) {}
+ | ^^^^^
+ |
+ = note: for more information, see https://github.com/rust-lang/rust/issues/29642
+ = help: add `#![feature(custom_attribute)]` to the crate attributes to enable
+
+error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future
+ --> $DIR/proc-macro-cannot-be-used.rs:39:22
+ |
+LL | fn inherent4<'a>(#[id] self: Box, #[id] arg1: u8) {}
+ | ^^^^^
+ |
+ = note: for more information, see https://github.com/rust-lang/rust/issues/29642
+ = help: add `#![feature(custom_attribute)]` to the crate attributes to enable
+
+error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future
+ --> $DIR/proc-macro-cannot-be-used.rs:39:45
+ |
+LL | fn inherent4<'a>(#[id] self: Box, #[id] arg1: u8) {}
+ | ^^^^^
+ |
+ = note: for more information, see https://github.com/rust-lang/rust/issues/29642
+ = help: add `#![feature(custom_attribute)]` to the crate attributes to enable
+
+error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future
+ --> $DIR/proc-macro-cannot-be-used.rs:45:15
+ |
+LL | fn trait1(#[id] self, #[id] arg1: u8);
+ | ^^^^^
+ |
+ = note: for more information, see https://github.com/rust-lang/rust/issues/29642
+ = help: add `#![feature(custom_attribute)]` to the crate attributes to enable
+
+error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future
+ --> $DIR/proc-macro-cannot-be-used.rs:45:27
+ |
+LL | fn trait1(#[id] self, #[id] arg1: u8);
+ | ^^^^^
+ |
+ = note: for more information, see https://github.com/rust-lang/rust/issues/29642
+ = help: add `#![feature(custom_attribute)]` to the crate attributes to enable
+
+error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future
+ --> $DIR/proc-macro-cannot-be-used.rs:48:15
+ |
+LL | fn trait2(#[id] &self, #[id] arg1: u8);
+ | ^^^^^
+ |
+ = note: for more information, see https://github.com/rust-lang/rust/issues/29642
+ = help: add `#![feature(custom_attribute)]` to the crate attributes to enable
+
+error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future
+ --> $DIR/proc-macro-cannot-be-used.rs:48:28
+ |
+LL | fn trait2(#[id] &self, #[id] arg1: u8);
+ | ^^^^^
+ |
+ = note: for more information, see https://github.com/rust-lang/rust/issues/29642
+ = help: add `#![feature(custom_attribute)]` to the crate attributes to enable
+
+error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future
+ --> $DIR/proc-macro-cannot-be-used.rs:51:19
+ |
+LL | fn trait3<'a>(#[id] &'a mut self, #[id] arg1: u8);
+ | ^^^^^
+ |
+ = note: for more information, see https://github.com/rust-lang/rust/issues/29642
+ = help: add `#![feature(custom_attribute)]` to the crate attributes to enable
+
+error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future
+ --> $DIR/proc-macro-cannot-be-used.rs:51:39
+ |
+LL | fn trait3<'a>(#[id] &'a mut self, #[id] arg1: u8);
+ | ^^^^^
+ |
+ = note: for more information, see https://github.com/rust-lang/rust/issues/29642
+ = help: add `#![feature(custom_attribute)]` to the crate attributes to enable
+
+error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future
+ --> $DIR/proc-macro-cannot-be-used.rs:54:19
+ |
+LL | fn trait4<'a>(#[id] self: Box, #[id] arg1: u8, #[id] Vec);
+ | ^^^^^
+ |
+ = note: for more information, see https://github.com/rust-lang/rust/issues/29642
+ = help: add `#![feature(custom_attribute)]` to the crate attributes to enable
+
+error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future
+ --> $DIR/proc-macro-cannot-be-used.rs:54:42
+ |
+LL | fn trait4<'a>(#[id] self: Box, #[id] arg1: u8, #[id] Vec);
+ | ^^^^^
+ |
+ = note: for more information, see https://github.com/rust-lang/rust/issues/29642
+ = help: add `#![feature(custom_attribute)]` to the crate attributes to enable
+
+error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future
+ --> $DIR/proc-macro-cannot-be-used.rs:54:58
+ |
+LL | fn trait4<'a>(#[id] self: Box, #[id] arg1: u8, #[id] Vec);
+ | ^^^^^
+ |
+ = note: for more information, see https://github.com/rust-lang/rust/issues/29642
+ = help: add `#![feature(custom_attribute)]` to the crate attributes to enable
+
+error: aborting due to 25 previous errors
+
+For more information about this error, try `rustc --explain E0658`.
diff --git a/src/test/ui/self/arbitrary-self-types-not-object-safe.stderr b/src/test/ui/self/arbitrary-self-types-not-object-safe.stderr
index e45bc2657f1ea..e6eba377a9578 100644
--- a/src/test/ui/self/arbitrary-self-types-not-object-safe.stderr
+++ b/src/test/ui/self/arbitrary-self-types-not-object-safe.stderr
@@ -1,18 +1,21 @@
error[E0038]: the trait `Foo` cannot be made into an object
--> $DIR/arbitrary-self-types-not-object-safe.rs:31:32
|
+LL | fn foo(self: &Rc) -> usize;
+ | --- method `foo`'s `self` parameter cannot be dispatched on
+...
LL | let x = Rc::new(5usize) as Rc;
| ^^^^^^^^^^^ the trait `Foo` cannot be made into an object
- |
- = note: method `foo`'s receiver cannot be dispatched on
error[E0038]: the trait `Foo` cannot be made into an object
--> $DIR/arbitrary-self-types-not-object-safe.rs:31:13
|
+LL | fn foo(self: &Rc) -> usize;
+ | --- method `foo`'s `self` parameter cannot be dispatched on
+...
LL | let x = Rc::new(5usize) as Rc;
| ^^^^^^^^^^^^^^^ the trait `Foo` cannot be made into an object
|
- = note: method `foo`'s receiver cannot be dispatched on
= note: required because of the requirements on the impl of `std::ops::CoerceUnsized>` for `std::rc::Rc`
error: aborting due to 2 previous errors
diff --git a/src/test/ui/span/issue-27522.rs b/src/test/ui/span/issue-27522.rs
index 5c9893f64a6ee..7a0cfb679ed67 100644
--- a/src/test/ui/span/issue-27522.rs
+++ b/src/test/ui/span/issue-27522.rs
@@ -3,7 +3,7 @@
struct SomeType {}
trait Foo {
- fn handler(self: &SomeType); //~ ERROR invalid method receiver type
+ fn handler(self: &SomeType); //~ ERROR invalid `self` parameter type
}
fn main() {}
diff --git a/src/test/ui/span/issue-27522.stderr b/src/test/ui/span/issue-27522.stderr
index 88dfee1cada3f..8a254a9685543 100644
--- a/src/test/ui/span/issue-27522.stderr
+++ b/src/test/ui/span/issue-27522.stderr
@@ -1,11 +1,12 @@
-error[E0307]: invalid method receiver type: &SomeType
+error[E0307]: invalid `self` parameter type: &SomeType
--> $DIR/issue-27522.rs:6:22
|
LL | fn handler(self: &SomeType);
| ^^^^^^^^^
|
- = note: type must be `Self` or a type that dereferences to it
+ = note: type of `self` must be `Self` or a type that dereferences to it
= help: consider changing to `self`, `&self`, `&mut self`, `self: Box`, `self: Rc`, `self: Arc`, or `self: Pin` (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 E0307`.
diff --git a/src/test/ui/traits/trait-item-privacy.stderr b/src/test/ui/traits/trait-item-privacy.stderr
index ce2919c8e7741..16ea7bdb0807d 100644
--- a/src/test/ui/traits/trait-item-privacy.stderr
+++ b/src/test/ui/traits/trait-item-privacy.stderr
@@ -110,12 +110,17 @@ LL | C::A;
error[E0038]: the trait `assoc_const::C` cannot be made into an object
--> $DIR/trait-item-privacy.rs:101:5
|
+LL | const A: u8 = 0;
+ | - the trait cannot contain associated consts like `A`
+...
+LL | const B: u8 = 0;
+ | - the trait cannot contain associated consts like `B`
+...
+LL | const C: u8 = 0;
+ | - the trait cannot contain associated consts like `C`
+...
LL | C::A;
| ^^^^ the trait `assoc_const::C` cannot be made into an object
- |
- = note: the trait cannot contain associated consts like `C`
- = note: the trait cannot contain associated consts like `B`
- = note: the trait cannot contain associated consts like `A`
error[E0223]: ambiguous associated type
--> $DIR/trait-item-privacy.rs:115:12
diff --git a/src/test/ui/traits/trait-object-safety.stderr b/src/test/ui/traits/trait-object-safety.stderr
index 68edc17870534..3ac1e96b30c95 100644
--- a/src/test/ui/traits/trait-object-safety.stderr
+++ b/src/test/ui/traits/trait-object-safety.stderr
@@ -1,19 +1,22 @@
error[E0038]: the trait `Tr` cannot be made into an object
--> $DIR/trait-object-safety.rs:15:22
|
+LL | fn foo();
+ | --- associated function `foo` has no `self` parameter
+...
LL | let _: &dyn Tr = &St;
| ^^^ the trait `Tr` cannot be made into an object
|
- = note: method `foo` has no receiver
= note: required because of the requirements on the impl of `std::ops::CoerceUnsized<&dyn Tr>` for `&St`
error[E0038]: the trait `Tr` cannot be made into an object
--> $DIR/trait-object-safety.rs:15:12
|
+LL | fn foo();
+ | --- associated function `foo` has no `self` parameter
+...
LL | let _: &dyn Tr = &St;
| ^^^^^^^ the trait `Tr` cannot be made into an object
- |
- = note: method `foo` has no receiver
error: aborting due to 2 previous errors
diff --git a/src/test/ui/traits/trait-test-2.stderr b/src/test/ui/traits/trait-test-2.stderr
index 5d5251925a1ae..83c2c06527493 100644
--- a/src/test/ui/traits/trait-test-2.stderr
+++ b/src/test/ui/traits/trait-test-2.stderr
@@ -13,20 +13,25 @@ LL | 10.blah::();
error[E0038]: the trait `bar` cannot be made into an object
--> $DIR/trait-test-2.rs:11:16
|
+LL | trait bar { fn dup(&self) -> Self; fn blah(&self); }
+ | --- ---- method `blah` has generic type parameters
+ | |
+ | method `dup` references the `Self` type in its parameters or return type
+...
LL | (box 10 as Box).dup();
| ^^^^^^^^^^^^ the trait `bar` cannot be made into an object
- |
- = note: method `dup` references the `Self` type in its arguments or return type
- = note: method `blah` has generic type parameters
error[E0038]: the trait `bar` cannot be made into an object
--> $DIR/trait-test-2.rs:11:6
|
+LL | trait bar { fn dup(&self) -> Self; fn blah(&self); }
+ | --- ---- method `blah` has generic type parameters
+ | |
+ | method `dup` references the `Self` type in its parameters or return type
+...
LL | (box 10 as Box).dup();
| ^^^^^^ the trait `bar` cannot be made into an object
|
- = note: method `dup` references the `Self` type in its arguments or return type
- = note: method `blah` has generic type parameters
= note: required because of the requirements on the impl of `std::ops::CoerceUnsized>` for `std::boxed::Box<{integer}>`
error: aborting due to 4 previous errors
diff --git a/src/test/ui/type/type-parameter-defaults-referencing-Self-ppaux.stderr b/src/test/ui/type/type-parameter-defaults-referencing-Self-ppaux.stderr
index 58727ea0fef99..b315fe9df8afd 100644
--- a/src/test/ui/type/type-parameter-defaults-referencing-Self-ppaux.stderr
+++ b/src/test/ui/type/type-parameter-defaults-referencing-Self-ppaux.stderr
@@ -13,10 +13,11 @@ LL | let y = x as dyn MyAdd;
error[E0038]: the trait `MyAdd` cannot be made into an object
--> $DIR/type-parameter-defaults-referencing-Self-ppaux.rs:14:18
|
+LL | trait MyAdd { fn add(&self, other: &Rhs) -> Self; }
+ | --- method `add` references the `Self` type in its parameters or return type
+...
LL | let y = x as dyn MyAdd;
| ^^^^^^^^^^^^^^ the trait `MyAdd` cannot be made into an object
- |
- = note: method `add` references the `Self` type in its arguments or return type
error: aborting due to 2 previous errors
diff --git a/src/test/ui/ufcs/ufcs-explicit-self-bad.rs b/src/test/ui/ufcs/ufcs-explicit-self-bad.rs
index c6ff94a5e7606..bdb8e197fbe49 100644
--- a/src/test/ui/ufcs/ufcs-explicit-self-bad.rs
+++ b/src/test/ui/ufcs/ufcs-explicit-self-bad.rs
@@ -6,7 +6,7 @@ struct Foo {
impl Foo {
fn foo(self: isize, x: isize) -> isize {
- //~^ ERROR invalid method receiver type
+ //~^ ERROR invalid `self` parameter type
self.f + x
}
}
@@ -17,11 +17,11 @@ struct Bar {
impl Bar {
fn foo(self: Bar, x: isize) -> isize {
- //~^ ERROR invalid method receiver type
+ //~^ ERROR invalid `self` parameter type
x
}
fn bar(self: &Bar, x: isize) -> isize {
- //~^ ERROR invalid method receiver type
+ //~^ ERROR invalid `self` parameter type
x
}
}
@@ -34,14 +34,14 @@ trait SomeTrait {
impl<'a, T> SomeTrait for &'a Bar {
fn dummy1(self: &&'a Bar) { }
- fn dummy2(self: &Bar) {} //~ ERROR mismatched method receiver
- //~^ ERROR mismatched method receiver
+ fn dummy2(self: &Bar) {} //~ ERROR mismatched `self` parameter type
+ //~^ ERROR mismatched `self` parameter type
fn dummy3(self: &&Bar) {}
- //~^ ERROR mismatched method receiver
+ //~^ ERROR mismatched `self` parameter type
//~| expected type `&'a Bar`
//~| found type `&Bar`
//~| lifetime mismatch
- //~| ERROR mismatched method receiver
+ //~| ERROR mismatched `self` parameter type
//~| expected type `&'a Bar`
//~| found type `&Bar`
//~| lifetime mismatch
diff --git a/src/test/ui/ufcs/ufcs-explicit-self-bad.stderr b/src/test/ui/ufcs/ufcs-explicit-self-bad.stderr
index 6da20e37577b0..b2fe1b281fc99 100644
--- a/src/test/ui/ufcs/ufcs-explicit-self-bad.stderr
+++ b/src/test/ui/ufcs/ufcs-explicit-self-bad.stderr
@@ -1,31 +1,31 @@
-error[E0307]: invalid method receiver type: isize
+error[E0307]: invalid `self` parameter type: isize
--> $DIR/ufcs-explicit-self-bad.rs:8:18
|
LL | fn foo(self: isize, x: isize) -> isize {
| ^^^^^
|
- = note: type must be `Self` or a type that dereferences to it
+ = note: type of `self` must be `Self` or a type that dereferences to it
= help: consider changing to `self`, `&self`, `&mut self`, `self: Box`, `self: Rc`, `self: Arc`, or `self: Pin` (where P is one of the previous types except `Self`)
-error[E0307]: invalid method receiver type: Bar
+error[E0307]: invalid `self` parameter type: Bar
--> $DIR/ufcs-explicit-self-bad.rs:19:18
|
LL | fn foo(self: Bar, x: isize) -> isize {
| ^^^^^^^^^^
|
- = note: type must be `Self` or a type that dereferences to it
+ = note: type of `self` must be `Self` or a type that dereferences to it
= help: consider changing to `self`, `&self`, `&mut self`, `self: Box`, `self: Rc`, `self: Arc`, or `self: Pin` (where P is one of the previous types except `Self`)
-error[E0307]: invalid method receiver type: &Bar
+error[E0307]: invalid `self` parameter type: &Bar
--> $DIR/ufcs-explicit-self-bad.rs:23:18
|
LL | fn bar(self: &Bar, x: isize) -> isize {
| ^^^^^^^^^^^
|
- = note: type must be `Self` or a type that dereferences to it
+ = note: type of `self` must be `Self` or a type that dereferences to it
= help: consider changing to `self`, `&self`, `&mut self`, `self: Box`, `self: Rc`, `self: Arc`, or `self: Pin` (where P is one of the previous types except `Self`)
-error[E0308]: mismatched method receiver
+error[E0308]: mismatched `self` parameter type
--> $DIR/ufcs-explicit-self-bad.rs:37:21
|
LL | fn dummy2(self: &Bar) {}
@@ -44,7 +44,7 @@ note: ...does not necessarily outlive the lifetime 'a as defined on the impl at
LL | impl<'a, T> SomeTrait for &'a Bar {
| ^^
-error[E0308]: mismatched method receiver
+error[E0308]: mismatched `self` parameter type
--> $DIR/ufcs-explicit-self-bad.rs:37:21
|
LL | fn dummy2(self: &Bar) {}
@@ -63,7 +63,7 @@ note: ...does not necessarily outlive the anonymous lifetime #1 defined on the m
LL | fn dummy2(self: &Bar) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
-error[E0308]: mismatched method receiver
+error[E0308]: mismatched `self` parameter type
--> $DIR/ufcs-explicit-self-bad.rs:39:21
|
LL | fn dummy3(self: &&Bar) {}
@@ -82,7 +82,7 @@ note: ...does not necessarily outlive the lifetime 'a as defined on the impl at
LL | impl<'a, T> SomeTrait for &'a Bar {
| ^^
-error[E0308]: mismatched method receiver
+error[E0308]: mismatched `self` parameter type
--> $DIR/ufcs-explicit-self-bad.rs:39:21
|
LL | fn dummy3(self: &&Bar) {}
@@ -103,4 +103,5 @@ LL | fn dummy3(self: &&Bar) {}
error: aborting due to 7 previous errors
-For more information about this error, try `rustc --explain E0308`.
+Some errors have detailed explanations: E0307, E0308.
+For more information about an error, try `rustc --explain E0307`.
diff --git a/src/test/ui/rfc-2166-underscore-imports/auxiliary/duplicate.rs b/src/test/ui/underscore-imports/auxiliary/duplicate.rs
similarity index 100%
rename from src/test/ui/rfc-2166-underscore-imports/auxiliary/duplicate.rs
rename to src/test/ui/underscore-imports/auxiliary/duplicate.rs
diff --git a/src/test/ui/rfc-2166-underscore-imports/auxiliary/underscore-imports.rs b/src/test/ui/underscore-imports/auxiliary/underscore-imports.rs
similarity index 100%
rename from src/test/ui/rfc-2166-underscore-imports/auxiliary/underscore-imports.rs
rename to src/test/ui/underscore-imports/auxiliary/underscore-imports.rs
diff --git a/src/test/ui/rfc-2166-underscore-imports/basic.rs b/src/test/ui/underscore-imports/basic.rs
similarity index 100%
rename from src/test/ui/rfc-2166-underscore-imports/basic.rs
rename to src/test/ui/underscore-imports/basic.rs
diff --git a/src/test/ui/rfc-2166-underscore-imports/basic.stderr b/src/test/ui/underscore-imports/basic.stderr
similarity index 100%
rename from src/test/ui/rfc-2166-underscore-imports/basic.stderr
rename to src/test/ui/underscore-imports/basic.stderr
diff --git a/src/test/ui/underscore-imports/cycle.rs b/src/test/ui/underscore-imports/cycle.rs
new file mode 100644
index 0000000000000..bacf9b2d5a96a
--- /dev/null
+++ b/src/test/ui/underscore-imports/cycle.rs
@@ -0,0 +1,18 @@
+// Check that cyclic glob imports are allowed with underscore imports
+
+// check-pass
+
+mod x {
+ pub use crate::y::*;
+ pub use std::ops::Deref as _;
+}
+
+mod y {
+ pub use crate::x::*;
+ pub use std::ops::Deref as _;
+}
+
+pub fn main() {
+ use x::*;
+ (&0).deref();
+}
diff --git a/src/test/ui/rfc-2166-underscore-imports/duplicate.rs b/src/test/ui/underscore-imports/duplicate.rs
similarity index 100%
rename from src/test/ui/rfc-2166-underscore-imports/duplicate.rs
rename to src/test/ui/underscore-imports/duplicate.rs
diff --git a/src/test/ui/rfc-2166-underscore-imports/intercrate.rs b/src/test/ui/underscore-imports/intercrate.rs
similarity index 100%
rename from src/test/ui/rfc-2166-underscore-imports/intercrate.rs
rename to src/test/ui/underscore-imports/intercrate.rs
diff --git a/src/test/ui/underscore-imports/shadow.rs b/src/test/ui/underscore-imports/shadow.rs
new file mode 100644
index 0000000000000..325f2001b9ede
--- /dev/null
+++ b/src/test/ui/underscore-imports/shadow.rs
@@ -0,0 +1,23 @@
+// Check that underscore imports don't cause glob imports to be unshadowed
+
+mod a {
+ pub use std::ops::Deref as Shadow;
+}
+
+mod b {
+ pub use crate::a::*;
+ macro_rules! m {
+ ($i:ident) => { pub struct $i; }
+ }
+ m!(Shadow);
+}
+
+mod c {
+ use crate::b::Shadow as _; // Only imports the struct
+
+ fn f(x: &()) {
+ x.deref(); //~ ERROR no method named `deref` found
+ }
+}
+
+fn main() {}
diff --git a/src/test/ui/underscore-imports/shadow.stderr b/src/test/ui/underscore-imports/shadow.stderr
new file mode 100644
index 0000000000000..92adca2c70490
--- /dev/null
+++ b/src/test/ui/underscore-imports/shadow.stderr
@@ -0,0 +1,13 @@
+error[E0599]: no method named `deref` found for type `&()` in the current scope
+ --> $DIR/shadow.rs:19:11
+ |
+LL | x.deref();
+ | ^^^^^
+ |
+ = help: items from traits can only be used if the trait is in scope
+ = note: the following trait is implemented but not in scope, perhaps add a `use` for it:
+ `use std::ops::Deref;`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0599`.
diff --git a/src/test/ui/rfc-2166-underscore-imports/unused-2018.rs b/src/test/ui/underscore-imports/unused-2018.rs
similarity index 100%
rename from src/test/ui/rfc-2166-underscore-imports/unused-2018.rs
rename to src/test/ui/underscore-imports/unused-2018.rs
diff --git a/src/test/ui/rfc-2166-underscore-imports/unused-2018.stderr b/src/test/ui/underscore-imports/unused-2018.stderr
similarity index 100%
rename from src/test/ui/rfc-2166-underscore-imports/unused-2018.stderr
rename to src/test/ui/underscore-imports/unused-2018.stderr
diff --git a/src/test/ui/wf/wf-object-safe.stderr b/src/test/ui/wf/wf-object-safe.stderr
index 3b264ecd580ec..0d8441f87e7e7 100644
--- a/src/test/ui/wf/wf-object-safe.stderr
+++ b/src/test/ui/wf/wf-object-safe.stderr
@@ -1,10 +1,11 @@
error[E0038]: the trait `A` cannot be made into an object
--> $DIR/wf-object-safe.rs:9:13
|
+LL | fn foo(&self, _x: &Self);
+ | --- method `foo` references the `Self` type in its parameters or return type
+...
LL | let _x: &dyn A;
| ^^^^^^ the trait `A` cannot be made into an object
- |
- = note: method `foo` references the `Self` type in its arguments or return type
error: aborting due to previous error
diff --git a/src/tools/tidy/src/features/tests.rs b/src/tools/tidy/src/features/tests.rs
index fa7a931ec865c..994523ac1abce 100644
--- a/src/tools/tidy/src/features/tests.rs
+++ b/src/tools/tidy/src/features/tests.rs
@@ -2,8 +2,8 @@ use super::*;
#[test]
fn test_find_attr_val() {
- let s = r#"#[unstable(feature = "checked_duration_since", issue = "58402")]"#;
- assert_eq!(find_attr_val(s, "feature"), Some("checked_duration_since"));
+ let s = r#"#[unstable(feature = "tidy_test_never_used_anywhere_else", issue = "58402")]"#;
+ assert_eq!(find_attr_val(s, "feature"), Some("tidy_test_never_used_anywhere_else"));
assert_eq!(find_attr_val(s, "issue"), Some("58402"));
assert_eq!(find_attr_val(s, "since"), None);
}