Auto merge of #98284 - JohnTitor:rollup-7lbs143, r=JohnTitor

Rollup of 5 pull requests

Successful merges:

 - #98183 (Fix pretty printing of empty bound lists in where-clause)
 - #98268 (Improve `lifetime arguments are not allowed on` error message)
 - #98273 (Fix minor documentation typo)
 - #98274 (Minor improvements on error for `Self` type in items that don't allow it)
 - #98281 (Fix typo in `HashMap::drain` docs)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2022-06-20 08:18:07 +00:00
commit 4104596251
35 changed files with 265 additions and 140 deletions

View File

@ -814,7 +814,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
}
fn bounds_to_string(&self, bounds: &[ast::GenericBound]) -> String {
Self::to_string(|s| s.print_type_bounds("", bounds))
Self::to_string(|s| s.print_type_bounds(bounds))
}
fn pat_to_string(&self, pat: &ast::Pat) -> String {
@ -991,7 +991,12 @@ impl<'a> State<'a> {
Term::Const(c) => self.print_expr_anon_const(c, &[]),
}
}
ast::AssocConstraintKind::Bound { bounds } => self.print_type_bounds(":", &*bounds),
ast::AssocConstraintKind::Bound { bounds } => {
if !bounds.is_empty() {
self.word_nbsp(":");
self.print_type_bounds(&bounds);
}
}
}
}
@ -1045,11 +1050,14 @@ impl<'a> State<'a> {
}
ast::TyKind::Path(Some(ref qself), ref path) => self.print_qpath(path, qself, false),
ast::TyKind::TraitObject(ref bounds, syntax) => {
let prefix = if syntax == ast::TraitObjectSyntax::Dyn { "dyn" } else { "" };
self.print_type_bounds(prefix, &bounds);
if syntax == ast::TraitObjectSyntax::Dyn {
self.word_nbsp("dyn");
}
self.print_type_bounds(bounds);
}
ast::TyKind::ImplTrait(_, ref bounds) => {
self.print_type_bounds("impl", &bounds);
self.word_nbsp("impl");
self.print_type_bounds(bounds);
}
ast::TyKind::Array(ref ty, ref length) => {
self.word("[");
@ -1549,29 +1557,24 @@ impl<'a> State<'a> {
}
}
pub fn print_type_bounds(&mut self, prefix: &'static str, bounds: &[ast::GenericBound]) {
if !bounds.is_empty() {
self.word(prefix);
let mut first = true;
for bound in bounds {
if !(first && prefix.is_empty()) {
self.nbsp();
}
if first {
first = false;
} else {
self.word_space("+");
}
pub fn print_type_bounds(&mut self, bounds: &[ast::GenericBound]) {
let mut first = true;
for bound in bounds {
if first {
first = false;
} else {
self.nbsp();
self.word_space("+");
}
match bound {
GenericBound::Trait(tref, modifier) => {
if modifier == &TraitBoundModifier::Maybe {
self.word("?");
}
self.print_poly_trait_ref(tref);
match bound {
GenericBound::Trait(tref, modifier) => {
if modifier == &TraitBoundModifier::Maybe {
self.word("?");
}
GenericBound::Outlives(lt) => self.print_lifetime(*lt),
self.print_poly_trait_ref(tref);
}
GenericBound::Outlives(lt) => self.print_lifetime(*lt),
}
}
}
@ -1580,22 +1583,14 @@ impl<'a> State<'a> {
self.print_name(lifetime.ident.name)
}
pub(crate) fn print_lifetime_bounds(
&mut self,
lifetime: ast::Lifetime,
bounds: &ast::GenericBounds,
) {
self.print_lifetime(lifetime);
if !bounds.is_empty() {
self.word(": ");
for (i, bound) in bounds.iter().enumerate() {
if i != 0 {
self.word(" + ");
}
match bound {
ast::GenericBound::Outlives(lt) => self.print_lifetime(*lt),
_ => panic!(),
}
pub(crate) fn print_lifetime_bounds(&mut self, bounds: &ast::GenericBounds) {
for (i, bound) in bounds.iter().enumerate() {
if i != 0 {
self.word(" + ");
}
match bound {
ast::GenericBound::Outlives(lt) => self.print_lifetime(*lt),
_ => panic!(),
}
}
}
@ -1613,11 +1608,18 @@ impl<'a> State<'a> {
match param.kind {
ast::GenericParamKind::Lifetime => {
let lt = ast::Lifetime { id: param.id, ident: param.ident };
s.print_lifetime_bounds(lt, &param.bounds)
s.print_lifetime(lt);
if !param.bounds.is_empty() {
s.word_nbsp(":");
s.print_lifetime_bounds(&param.bounds)
}
}
ast::GenericParamKind::Type { ref default } => {
s.print_ident(param.ident);
s.print_type_bounds(":", &param.bounds);
if !param.bounds.is_empty() {
s.word_nbsp(":");
s.print_type_bounds(&param.bounds);
}
if let Some(ref default) = default {
s.space();
s.word_space("=");
@ -1630,7 +1632,10 @@ impl<'a> State<'a> {
s.space();
s.word_space(":");
s.print_type(ty);
s.print_type_bounds(":", &param.bounds);
if !param.bounds.is_empty() {
s.word_nbsp(":");
s.print_type_bounds(&param.bounds);
}
if let Some(ref default) = default {
s.space();
s.word_space("=");

View File

@ -114,7 +114,10 @@ impl<'a> State<'a> {
self.word_space("type");
self.print_ident(ident);
self.print_generic_params(&generics.params);
self.print_type_bounds(":", bounds);
if !bounds.is_empty() {
self.word_nbsp(":");
self.print_type_bounds(bounds);
}
self.print_where_clause_parts(where_clauses.0.0, before_predicates);
if let Some(ty) = ty {
self.space();
@ -320,7 +323,10 @@ impl<'a> State<'a> {
real_bounds.push(b.clone());
}
}
self.print_type_bounds(":", &real_bounds);
if !real_bounds.is_empty() {
self.word_nbsp(":");
self.print_type_bounds(&real_bounds);
}
self.print_where_clause(&generics.where_clause);
self.word(" ");
self.bopen();
@ -347,7 +353,10 @@ impl<'a> State<'a> {
}
}
self.nbsp();
self.print_type_bounds("=", &real_bounds);
if !real_bounds.is_empty() {
self.word_nbsp("=");
self.print_type_bounds(&real_bounds);
}
self.print_where_clause(&generics.where_clause);
self.word(";");
self.end(); // end inner head-block
@ -618,14 +627,23 @@ impl<'a> State<'a> {
}) => {
self.print_formal_generic_params(bound_generic_params);
self.print_type(bounded_ty);
self.print_type_bounds(":", bounds);
self.word(":");
if !bounds.is_empty() {
self.nbsp();
self.print_type_bounds(bounds);
}
}
ast::WherePredicate::RegionPredicate(ast::WhereRegionPredicate {
lifetime,
bounds,
..
}) => {
self.print_lifetime_bounds(*lifetime, bounds);
self.print_lifetime(*lifetime);
self.word(":");
if !bounds.is_empty() {
self.nbsp();
self.print_lifetime_bounds(bounds);
}
}
ast::WherePredicate::EqPredicate(ast::WhereEqPredicate { lhs_ty, rhs_ty, .. }) => {
self.print_type(lhs_ty);

View File

@ -1355,7 +1355,10 @@ impl<'a> Parser<'a> {
s.print_mutability(mut_ty.mutbl, false);
s.popen();
s.print_type(&mut_ty.ty);
s.print_type_bounds(" +", &bounds);
if !bounds.is_empty() {
s.word(" + ");
s.print_type_bounds(&bounds);
}
s.pclose()
});

View File

@ -1914,6 +1914,8 @@ impl<'a> Resolver<'a> {
};
}
(msg, None)
} else if ident.name == kw::SelfUpper {
("`Self` is only available in impls, traits, and type definitions".to_string(), None)
} else if ident.name.as_str().chars().next().map_or(false, |c| c.is_ascii_uppercase()) {
// Check whether the name refers to an item in the value namespace.
let binding = if let Some(ribs) = ribs {

View File

@ -332,6 +332,16 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
span,
"`Self` is only available in impls, traits, and type definitions".to_string(),
);
if let Some(item_kind) = self.diagnostic_metadata.current_item {
err.span_label(
item_kind.ident.span,
format!(
"`Self` not allowed in {} {}",
item_kind.kind.article(),
item_kind.kind.descr()
),
);
}
return (err, Vec::new());
}
if is_self_value(path, ns) {
@ -389,6 +399,15 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
);
}
}
} else if let Some(item_kind) = self.diagnostic_metadata.current_item {
err.span_label(
item_kind.ident.span,
format!(
"`self` not allowed in {} {}",
item_kind.kind.article(),
item_kind.kind.descr()
),
);
}
return (err, Vec::new());
}
@ -1788,7 +1807,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
path: &[Segment],
) -> Option<(Span, &'static str, String, Applicability)> {
let (ident, span) = match path {
[segment] if !segment.has_generic_args => {
[segment] if !segment.has_generic_args && segment.ident.name != kw::SelfUpper => {
(segment.ident.to_string(), segment.ident.span)
}
_ => return None,

View File

@ -1,4 +1,4 @@
//! This crates defines the trait resolution method.
//! This crate defines the trait resolution method.
//!
//! - **Traits.** Trait resolution is implemented in the `traits` module.
//!

View File

@ -2195,8 +2195,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
"{kind} arguments are not allowed on {this_type}",
);
err.span_label(last_span, format!("{kind} argument{s} not allowed"));
for (_, span) in types_and_spans {
err.span_label(span, "not allowed on this");
for (what, span) in types_and_spans {
err.span_label(span, format!("not allowed on {what}"));
}
extend(&mut err);
err.emit();

View File

@ -588,7 +588,7 @@ impl<K, V, S> HashMap<K, V, S> {
///
/// If the returned iterator is dropped before being fully consumed, it
/// drops the remaining key-value pairs. The returned iterator keeps a
/// mutable borrow on the vector to optimize its implementation.
/// mutable borrow on the map to optimize its implementation.
///
/// # Examples
///

View File

@ -2,4 +2,7 @@
fn f<'a, 'b, T>(t: T) -> isize where T: 'a, 'a: 'b, T: Eq { 0 }
// This is legal syntax, sometimes generated by macros. `where T: $($bound+)*`
fn zero_bounds<'a, T>() where 'a:, T: {}
fn main() {}

View File

@ -4,7 +4,7 @@ error[E0109]: type arguments are not allowed on type parameter `Irrelevant`
LL | #[derive(Debug)]
| -----
| |
| not allowed on this
| not allowed on type parameter `Irrelevant`
| in this derive macro expansion
LL | pub struct Irrelevant<Irrelevant> {
| ^^^^^^^^^^ type argument not allowed

View File

@ -4,7 +4,7 @@ error[E0109]: type arguments are not allowed on this type
LL | type X = u32<i32>;
| --- ^^^ type argument not allowed
| |
| not allowed on this
| not allowed on this type
|
help: primitive type `u32` doesn't have generic parameters
|

View File

@ -4,7 +4,7 @@ error[E0109]: lifetime arguments are not allowed on this type
LL | type X = u32<'static>;
| --- ^^^^^^^ lifetime argument not allowed
| |
| not allowed on this
| not allowed on this type
|
help: primitive type `u32` doesn't have generic parameters
|

View File

@ -1,6 +1,8 @@
error[E0411]: cannot find type `Self` in this scope
--> $DIR/E0411.rs:2:6
|
LL | fn main() {
| ---- `Self` not allowed in a function
LL | <Self>::foo;
| ^^^^ `Self` is only available in impls, traits, and type definitions

View File

@ -4,7 +4,7 @@ error[E0109]: type arguments are not allowed on module `marker`
LL | fn is_copy<T: ::std::marker<i32>::Copy>() {}
| ------ ^^^ type argument not allowed
| |
| not allowed on this
| not allowed on module `marker`
error: aborting due to previous error

View File

@ -4,7 +4,7 @@ error[E0109]: type arguments are not allowed on self constructor
LL | Self::<E>(e)
| ---- ^ type argument not allowed
| |
| not allowed on this
| not allowed on self constructor
error: aborting due to previous error

View File

@ -4,7 +4,7 @@ error[E0109]: type arguments are not allowed on local variable
LL | c1::<()>;
| -- ^^ type argument not allowed
| |
| not allowed on this
| not allowed on local variable
error[E0109]: type arguments are not allowed on local variable
--> $DIR/issue-60989.rs:16:10
@ -12,7 +12,7 @@ error[E0109]: type arguments are not allowed on local variable
LL | c1::<dyn Into<B>>;
| -- ^^^^^^^^^^^ type argument not allowed
| |
| not allowed on this
| not allowed on local variable
error: aborting due to 2 previous errors

View File

@ -2,7 +2,7 @@ extern "C" {
fn bget(&self, index: [usize; Self::DIM]) -> bool {
//~^ ERROR incorrect function inside `extern` block
//~| ERROR `self` parameter is only allowed in associated functions
//~| ERROR use of undeclared type `Self`
//~| ERROR failed to resolve: `Self`
type T<'a> = &'a str;
}
}

View File

@ -25,11 +25,11 @@ LL | fn bget(&self, index: [usize; Self::DIM]) -> bool {
|
= note: associated functions are those in `impl` or `trait` definitions
error[E0433]: failed to resolve: use of undeclared type `Self`
error[E0433]: failed to resolve: `Self` is only available in impls, traits, and type definitions
--> $DIR/issue-97194.rs:2:35
|
LL | fn bget(&self, index: [usize; Self::DIM]) -> bool {
| ^^^^ use of undeclared type `Self`
| ^^^^ `Self` is only available in impls, traits, and type definitions
error: aborting due to 3 previous errors

View File

@ -4,7 +4,7 @@ error[E0109]: type arguments are not allowed on module `Mod`
LL | Mod::<i32>::FakeVariant(0);
| --- ^^^ type argument not allowed
| |
| not allowed on this
| not allowed on module `Mod`
error: aborting due to previous error

View File

@ -1,5 +1,30 @@
// Also includes more Self usages per #93796
fn foo(_: Self) {
//~^ ERROR cannot find type `Self`
}
fn foo2() {
let x: Self;
//~^ ERROR cannot find type `Self`
}
type Foo<T>
where
Self: Clone,
//~^ ERROR cannot find type `Self`
= Vec<T>;
const FOO: Self = 0;
//~^ ERROR cannot find type `Self`
const FOO2: u32 = Self::bar();
//~^ ERROR failed to resolve: `Self`
static FOO_S: Self = 0;
//~^ ERROR cannot find type `Self`
static FOO_S2: u32 = Self::bar();
//~^ ERROR failed to resolve: `Self`
fn main() {}

View File

@ -1,9 +1,57 @@
error[E0433]: failed to resolve: `Self` is only available in impls, traits, and type definitions
--> $DIR/issue-24968.rs:21:19
|
LL | const FOO2: u32 = Self::bar();
| ^^^^ `Self` is only available in impls, traits, and type definitions
error[E0433]: failed to resolve: `Self` is only available in impls, traits, and type definitions
--> $DIR/issue-24968.rs:27:22
|
LL | static FOO_S2: u32 = Self::bar();
| ^^^^ `Self` is only available in impls, traits, and type definitions
error[E0411]: cannot find type `Self` in this scope
--> $DIR/issue-24968.rs:1:11
--> $DIR/issue-24968.rs:3:11
|
LL | fn foo(_: Self) {
| ^^^^ `Self` is only available in impls, traits, and type definitions
| --- ^^^^ `Self` is only available in impls, traits, and type definitions
| |
| `Self` not allowed in a function
error: aborting due to previous error
error[E0411]: cannot find type `Self` in this scope
--> $DIR/issue-24968.rs:8:12
|
LL | fn foo2() {
| ---- `Self` not allowed in a function
LL | let x: Self;
| ^^^^ `Self` is only available in impls, traits, and type definitions
For more information about this error, try `rustc --explain E0411`.
error[E0411]: cannot find type `Self` in this scope
--> $DIR/issue-24968.rs:14:5
|
LL | type Foo<T>
| --- `Self` not allowed in a type alias
LL | where
LL | Self: Clone,
| ^^^^ `Self` is only available in impls, traits, and type definitions
error[E0411]: cannot find type `Self` in this scope
--> $DIR/issue-24968.rs:18:12
|
LL | const FOO: Self = 0;
| --- ^^^^ `Self` is only available in impls, traits, and type definitions
| |
| `Self` not allowed in a constant item
error[E0411]: cannot find type `Self` in this scope
--> $DIR/issue-24968.rs:24:15
|
LL | static FOO_S: Self = 0;
| ----- ^^^^ `Self` is only available in impls, traits, and type definitions
| |
| `Self` not allowed in a static item
error: aborting due to 7 previous errors
Some errors have detailed explanations: E0411, E0433.
For more information about an error, try `rustc --explain E0411`.

View File

@ -10,7 +10,7 @@ error[E0109]: type arguments are not allowed on this type
LL | let z = T::A::<u8> {};
| - ^^ type argument not allowed
| |
| not allowed on this
| not allowed on this type
error[E0071]: expected struct, variant or union type, found associated type
--> $DIR/struct-path-associated-type.rs:14:13
@ -30,7 +30,7 @@ error[E0109]: type arguments are not allowed on this type
LL | let z = T::A::<u8> {};
| - ^^ type argument not allowed
| |
| not allowed on this
| not allowed on this type
error[E0223]: ambiguous associated type
--> $DIR/struct-path-associated-type.rs:32:13

View File

@ -10,7 +10,7 @@ error[E0109]: type arguments are not allowed on self type
LL | let z = Self::<u8> {};
| ---- ^^ type argument not allowed
| |
| not allowed on this
| not allowed on self type
|
help: the `Self` type doesn't accept type parameters
|
@ -36,7 +36,7 @@ error[E0109]: type arguments are not allowed on self type
LL | let z = Self::<u8> {};
| ---- ^^ type argument not allowed
| |
| not allowed on this
| not allowed on self type
|
note: `Self` is of type `S`
--> $DIR/struct-path-self.rs:1:8
@ -58,7 +58,7 @@ error[E0109]: type arguments are not allowed on self type
LL | let z = Self::<u8> {};
| ---- ^^ type argument not allowed
| |
| not allowed on this
| not allowed on self type
|
note: `Self` is of type `S`
--> $DIR/struct-path-self.rs:1:8

View File

@ -23,7 +23,7 @@ error[E0109]: type arguments are not allowed on this type
LL | Self::TSVariant::<()>(());
| --------- ^^ type argument not allowed
| |
| not allowed on this
| not allowed on this type
error[E0109]: type arguments are not allowed on self type
--> $DIR/enum-variant-generic-args.rs:17:16
@ -31,7 +31,7 @@ error[E0109]: type arguments are not allowed on self type
LL | Self::<()>::TSVariant(());
| ---- ^^ type argument not allowed
| |
| not allowed on this
| not allowed on self type
|
note: `Self` is of type `Enum<T>`
--> $DIR/enum-variant-generic-args.rs:7:6
@ -71,7 +71,7 @@ error[E0109]: type arguments are not allowed on self type
LL | Self::<()>::TSVariant::<()>(());
| ---- ^^ type argument not allowed
| |
| not allowed on this
| not allowed on self type
|
note: `Self` is of type `Enum<T>`
--> $DIR/enum-variant-generic-args.rs:7:6
@ -92,7 +92,7 @@ error[E0109]: type arguments are not allowed on this type
LL | Self::<()>::TSVariant::<()>(());
| --------- ^^ type argument not allowed
| |
| not allowed on this
| not allowed on this type
error[E0308]: mismatched types
--> $DIR/enum-variant-generic-args.rs:26:29
@ -112,7 +112,7 @@ error[E0109]: type arguments are not allowed on this type
LL | Self::SVariant::<()> { v: () };
| -------- ^^ type argument not allowed
| |
| not allowed on this
| not allowed on this type
|
= note: enum variants can't have type parameters
help: you might have meant to specity type parameters on enum `Enum`
@ -139,7 +139,7 @@ error[E0109]: type arguments are not allowed on self type
LL | Self::<()>::SVariant { v: () };
| ---- ^^ type argument not allowed
| |
| not allowed on this
| not allowed on self type
|
note: `Self` is of type `Enum<T>`
--> $DIR/enum-variant-generic-args.rs:7:6
@ -172,7 +172,7 @@ error[E0109]: type arguments are not allowed on self type
LL | Self::<()>::SVariant::<()> { v: () };
| ---- ^^ type argument not allowed
| |
| not allowed on this
| not allowed on self type
|
note: `Self` is of type `Enum<T>`
--> $DIR/enum-variant-generic-args.rs:7:6
@ -193,7 +193,7 @@ error[E0109]: type arguments are not allowed on this type
LL | Self::<()>::SVariant::<()> { v: () };
| -------- ^^ type argument not allowed
| |
| not allowed on this
| not allowed on this type
|
= note: enum variants can't have type parameters
help: you might have meant to specity type parameters on enum `Enum`
@ -220,7 +220,7 @@ error[E0109]: type arguments are not allowed on this type
LL | Self::UVariant::<()>;
| -------- ^^ type argument not allowed
| |
| not allowed on this
| not allowed on this type
error[E0109]: type arguments are not allowed on self type
--> $DIR/enum-variant-generic-args.rs:43:16
@ -228,7 +228,7 @@ error[E0109]: type arguments are not allowed on self type
LL | Self::<()>::UVariant;
| ---- ^^ type argument not allowed
| |
| not allowed on this
| not allowed on self type
|
note: `Self` is of type `Enum<T>`
--> $DIR/enum-variant-generic-args.rs:7:6
@ -249,7 +249,7 @@ error[E0109]: type arguments are not allowed on self type
LL | Self::<()>::UVariant::<()>;
| ---- ^^ type argument not allowed
| |
| not allowed on this
| not allowed on self type
|
note: `Self` is of type `Enum<T>`
--> $DIR/enum-variant-generic-args.rs:7:6
@ -270,7 +270,7 @@ error[E0109]: type arguments are not allowed on this type
LL | Self::<()>::UVariant::<()>;
| -------- ^^ type argument not allowed
| |
| not allowed on this
| not allowed on this type
error[E0109]: type arguments are not allowed on this type
--> $DIR/enum-variant-generic-args.rs:54:29
@ -278,7 +278,7 @@ error[E0109]: type arguments are not allowed on this type
LL | Enum::<()>::TSVariant::<()>(());
| --------- ^^ type argument not allowed
| |
| not allowed on this
| not allowed on this type
error[E0109]: type arguments are not allowed on this type
--> $DIR/enum-variant-generic-args.rs:57:24
@ -286,7 +286,7 @@ error[E0109]: type arguments are not allowed on this type
LL | Alias::TSVariant::<()>(());
| --------- ^^ type argument not allowed
| |
| not allowed on this
| not allowed on this type
error[E0109]: type arguments are not allowed on this type
--> $DIR/enum-variant-generic-args.rs:59:30
@ -294,7 +294,7 @@ error[E0109]: type arguments are not allowed on this type
LL | Alias::<()>::TSVariant::<()>(());
| --------- ^^ type argument not allowed
| |
| not allowed on this
| not allowed on this type
error[E0109]: type arguments are not allowed on this type
--> $DIR/enum-variant-generic-args.rs:62:29
@ -302,7 +302,7 @@ error[E0109]: type arguments are not allowed on this type
LL | AliasFixed::TSVariant::<()>(());
| --------- ^^ type argument not allowed
| |
| not allowed on this
| not allowed on this type
error[E0107]: this type alias takes 0 generic arguments but 1 generic argument was supplied
--> $DIR/enum-variant-generic-args.rs:64:5
@ -338,7 +338,7 @@ error[E0109]: type arguments are not allowed on this type
LL | AliasFixed::<()>::TSVariant::<()>(());
| --------- ^^ type argument not allowed
| |
| not allowed on this
| not allowed on this type
error[E0109]: type arguments are not allowed on this type
--> $DIR/enum-variant-generic-args.rs:72:28
@ -346,7 +346,7 @@ error[E0109]: type arguments are not allowed on this type
LL | Enum::<()>::SVariant::<()> { v: () };
| -------- ^^ type argument not allowed
| |
| not allowed on this
| not allowed on this type
|
= note: enum variants can't have type parameters
@ -356,7 +356,7 @@ error[E0109]: type arguments are not allowed on this type
LL | Alias::SVariant::<()> { v: () };
| -------- ^^ type argument not allowed
| |
| not allowed on this
| not allowed on this type
|
= note: enum variants can't have type parameters
help: you might have meant to specity type parameters on enum `Enum`
@ -371,7 +371,7 @@ error[E0109]: type arguments are not allowed on this type
LL | Alias::<()>::SVariant::<()> { v: () };
| -------- ^^ type argument not allowed
| |
| not allowed on this
| not allowed on this type
|
= note: enum variants can't have type parameters
help: you might have meant to specity type parameters on enum `Enum`
@ -386,7 +386,7 @@ error[E0109]: type arguments are not allowed on this type
LL | AliasFixed::SVariant::<()> { v: () };
| -------- ^^ type argument not allowed
| |
| not allowed on this
| not allowed on this type
|
= note: enum variants can't have type parameters
help: you might have meant to specity type parameters on enum `Enum`
@ -429,7 +429,7 @@ error[E0109]: type arguments are not allowed on this type
LL | AliasFixed::<()>::SVariant::<()> { v: () };
| -------- ^^ type argument not allowed
| |
| not allowed on this
| not allowed on this type
|
= note: enum variants can't have type parameters
help: you might have meant to specity type parameters on enum `Enum`
@ -444,7 +444,7 @@ error[E0109]: type arguments are not allowed on this type
LL | Enum::<()>::UVariant::<()>;
| -------- ^^ type argument not allowed
| |
| not allowed on this
| not allowed on this type
error[E0109]: type arguments are not allowed on this type
--> $DIR/enum-variant-generic-args.rs:93:23
@ -452,7 +452,7 @@ error[E0109]: type arguments are not allowed on this type
LL | Alias::UVariant::<()>;
| -------- ^^ type argument not allowed
| |
| not allowed on this
| not allowed on this type
error[E0109]: type arguments are not allowed on this type
--> $DIR/enum-variant-generic-args.rs:95:29
@ -460,7 +460,7 @@ error[E0109]: type arguments are not allowed on this type
LL | Alias::<()>::UVariant::<()>;
| -------- ^^ type argument not allowed
| |
| not allowed on this
| not allowed on this type
error[E0109]: type arguments are not allowed on this type
--> $DIR/enum-variant-generic-args.rs:98:28
@ -468,7 +468,7 @@ error[E0109]: type arguments are not allowed on this type
LL | AliasFixed::UVariant::<()>;
| -------- ^^ type argument not allowed
| |
| not allowed on this
| not allowed on this type
error[E0107]: this type alias takes 0 generic arguments but 1 generic argument was supplied
--> $DIR/enum-variant-generic-args.rs:100:5
@ -504,7 +504,7 @@ error[E0109]: type arguments are not allowed on this type
LL | AliasFixed::<()>::UVariant::<()>;
| -------- ^^ type argument not allowed
| |
| not allowed on this
| not allowed on this type
error: aborting due to 39 previous errors

View File

@ -4,7 +4,7 @@ error[E0109]: type arguments are not allowed on this type
LL | let _ = Alias::None::<u8>;
| ---- ^^ type argument not allowed
| |
| not allowed on this
| not allowed on this type
error: aborting due to previous error

View File

@ -3,6 +3,6 @@ pub trait Trait {
}
pub type Alias = dyn Trait<A = Self::A>;
//~^ ERROR failed to resolve: use of undeclared type `Self` [E0433]
//~^ ERROR failed to resolve: `Self`
fn main() {}

View File

@ -1,8 +1,8 @@
error[E0433]: failed to resolve: use of undeclared type `Self`
error[E0433]: failed to resolve: `Self` is only available in impls, traits, and type definitions
--> $DIR/issue-62263-self-in-atb.rs:5:32
|
LL | pub type Alias = dyn Trait<A = Self::A>;
| ^^^^ use of undeclared type `Self`
| ^^^^ `Self` is only available in impls, traits, and type definitions
error: aborting due to previous error

View File

@ -1,4 +1,4 @@
type Alias = Self::Target;
//~^ ERROR failed to resolve: use of undeclared type `Self` [E0433]
//~^ ERROR failed to resolve: `Self`
fn main() {}

View File

@ -1,8 +1,8 @@
error[E0433]: failed to resolve: use of undeclared type `Self`
error[E0433]: failed to resolve: `Self` is only available in impls, traits, and type definitions
--> $DIR/issue-62305-self-assoc-ty.rs:1:14
|
LL | type Alias = Self::Target;
| ^^^^ use of undeclared type `Self`
| ^^^^ `Self` is only available in impls, traits, and type definitions
error: aborting due to previous error

View File

@ -2,9 +2,9 @@ error[E0411]: cannot find type `Self` in this scope
--> $DIR/issue-62364-self-ty-arg.rs:5:29
|
LL | type Alias<'a> = Struct<&'a Self>;
| - ^^^^ `Self` is only available in impls, traits, and type definitions
| |
| help: you might be missing a type parameter: `, Self`
| ----- ^^^^ `Self` is only available in impls, traits, and type definitions
| |
| `Self` not allowed in a type alias
error: aborting due to previous error

View File

@ -41,7 +41,7 @@ error[E0109]: type arguments are not allowed on this type
LL | 0: u8(ţ
| -- ^ type argument not allowed
| |
| not allowed on this
| not allowed on this type
|
help: primitive type `u8` doesn't have generic parameters
|

View File

@ -4,7 +4,7 @@ error[E0109]: type arguments are not allowed on this type
LL | let _x: isize<isize>;
| ----- ^^^^^ type argument not allowed
| |
| not allowed on this
| not allowed on this type
|
help: primitive type `isize` doesn't have generic parameters
|
@ -18,7 +18,7 @@ error[E0109]: type arguments are not allowed on this type
LL | let _x: i8<isize>;
| -- ^^^^^ type argument not allowed
| |
| not allowed on this
| not allowed on this type
|
help: primitive type `i8` doesn't have generic parameters
|
@ -32,7 +32,7 @@ error[E0109]: type arguments are not allowed on this type
LL | let _x: i16<isize>;
| --- ^^^^^ type argument not allowed
| |
| not allowed on this
| not allowed on this type
|
help: primitive type `i16` doesn't have generic parameters
|
@ -46,7 +46,7 @@ error[E0109]: type arguments are not allowed on this type
LL | let _x: i32<isize>;
| --- ^^^^^ type argument not allowed
| |
| not allowed on this
| not allowed on this type
|
help: primitive type `i32` doesn't have generic parameters
|
@ -60,7 +60,7 @@ error[E0109]: type arguments are not allowed on this type
LL | let _x: i64<isize>;
| --- ^^^^^ type argument not allowed
| |
| not allowed on this
| not allowed on this type
|
help: primitive type `i64` doesn't have generic parameters
|
@ -74,7 +74,7 @@ error[E0109]: type arguments are not allowed on this type
LL | let _x: usize<isize>;
| ----- ^^^^^ type argument not allowed
| |
| not allowed on this
| not allowed on this type
|
help: primitive type `usize` doesn't have generic parameters
|
@ -88,7 +88,7 @@ error[E0109]: type arguments are not allowed on this type
LL | let _x: u8<isize>;
| -- ^^^^^ type argument not allowed
| |
| not allowed on this
| not allowed on this type
|
help: primitive type `u8` doesn't have generic parameters
|
@ -102,7 +102,7 @@ error[E0109]: type arguments are not allowed on this type
LL | let _x: u16<isize>;
| --- ^^^^^ type argument not allowed
| |
| not allowed on this
| not allowed on this type
|
help: primitive type `u16` doesn't have generic parameters
|
@ -116,7 +116,7 @@ error[E0109]: type arguments are not allowed on this type
LL | let _x: u32<isize>;
| --- ^^^^^ type argument not allowed
| |
| not allowed on this
| not allowed on this type
|
help: primitive type `u32` doesn't have generic parameters
|
@ -130,7 +130,7 @@ error[E0109]: type arguments are not allowed on this type
LL | let _x: u64<isize>;
| --- ^^^^^ type argument not allowed
| |
| not allowed on this
| not allowed on this type
|
help: primitive type `u64` doesn't have generic parameters
|
@ -144,7 +144,7 @@ error[E0109]: type arguments are not allowed on this type
LL | let _x: char<isize>;
| ---- ^^^^^ type argument not allowed
| |
| not allowed on this
| not allowed on this type
|
help: primitive type `char` doesn't have generic parameters
|
@ -158,7 +158,7 @@ error[E0109]: lifetime arguments are not allowed on this type
LL | let _x: isize<'static>;
| ----- ^^^^^^^ lifetime argument not allowed
| |
| not allowed on this
| not allowed on this type
|
help: primitive type `isize` doesn't have generic parameters
|
@ -172,7 +172,7 @@ error[E0109]: lifetime arguments are not allowed on this type
LL | let _x: i8<'static>;
| -- ^^^^^^^ lifetime argument not allowed
| |
| not allowed on this
| not allowed on this type
|
help: primitive type `i8` doesn't have generic parameters
|
@ -186,7 +186,7 @@ error[E0109]: lifetime arguments are not allowed on this type
LL | let _x: i16<'static>;
| --- ^^^^^^^ lifetime argument not allowed
| |
| not allowed on this
| not allowed on this type
|
help: primitive type `i16` doesn't have generic parameters
|
@ -200,7 +200,7 @@ error[E0109]: lifetime arguments are not allowed on this type
LL | let _x: i32<'static>;
| --- ^^^^^^^ lifetime argument not allowed
| |
| not allowed on this
| not allowed on this type
|
help: primitive type `i32` doesn't have generic parameters
|
@ -214,7 +214,7 @@ error[E0109]: lifetime arguments are not allowed on this type
LL | let _x: i64<'static>;
| --- ^^^^^^^ lifetime argument not allowed
| |
| not allowed on this
| not allowed on this type
|
help: primitive type `i64` doesn't have generic parameters
|
@ -228,7 +228,7 @@ error[E0109]: lifetime arguments are not allowed on this type
LL | let _x: usize<'static>;
| ----- ^^^^^^^ lifetime argument not allowed
| |
| not allowed on this
| not allowed on this type
|
help: primitive type `usize` doesn't have generic parameters
|
@ -242,7 +242,7 @@ error[E0109]: lifetime arguments are not allowed on this type
LL | let _x: u8<'static>;
| -- ^^^^^^^ lifetime argument not allowed
| |
| not allowed on this
| not allowed on this type
|
help: primitive type `u8` doesn't have generic parameters
|
@ -256,7 +256,7 @@ error[E0109]: lifetime arguments are not allowed on this type
LL | let _x: u16<'static>;
| --- ^^^^^^^ lifetime argument not allowed
| |
| not allowed on this
| not allowed on this type
|
help: primitive type `u16` doesn't have generic parameters
|
@ -270,7 +270,7 @@ error[E0109]: lifetime arguments are not allowed on this type
LL | let _x: u32<'static>;
| --- ^^^^^^^ lifetime argument not allowed
| |
| not allowed on this
| not allowed on this type
|
help: primitive type `u32` doesn't have generic parameters
|
@ -284,7 +284,7 @@ error[E0109]: lifetime arguments are not allowed on this type
LL | let _x: u64<'static>;
| --- ^^^^^^^ lifetime argument not allowed
| |
| not allowed on this
| not allowed on this type
|
help: primitive type `u64` doesn't have generic parameters
|
@ -298,7 +298,7 @@ error[E0109]: lifetime arguments are not allowed on this type
LL | let _x: char<'static>;
| ---- ^^^^^^^ lifetime argument not allowed
| |
| not allowed on this
| not allowed on this type
|
help: primitive type `char` doesn't have generic parameters
|

View File

@ -4,7 +4,7 @@ impl S {
fn f() {}
fn g() {
use Self::f; //~ ERROR unresolved import
pub(in Self::f) struct Z; //~ ERROR use of undeclared type `Self`
pub(in Self::f) struct Z; //~ ERROR failed to resolve: `Self`
}
}

View File

@ -1,14 +1,14 @@
error[E0433]: failed to resolve: use of undeclared type `Self`
error[E0433]: failed to resolve: `Self` is only available in impls, traits, and type definitions
--> $DIR/use-self-type.rs:7:16
|
LL | pub(in Self::f) struct Z;
| ^^^^ use of undeclared type `Self`
| ^^^^ `Self` is only available in impls, traits, and type definitions
error[E0432]: unresolved import `Self`
--> $DIR/use-self-type.rs:6:13
|
LL | use Self::f;
| ^^^^ use of undeclared type `Self`
| ^^^^ `Self` is only available in impls, traits, and type definitions
error: aborting due to 2 previous errors

View File

@ -4,7 +4,7 @@ error[E0109]: const arguments are not allowed on this type
LL | let x: usize<foo>;
| ----- ^^^ const argument not allowed
| |
| not allowed on this
| not allowed on this type
|
help: primitive type `usize` doesn't have generic parameters
|