mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
Account for self ty alias
This commit is contained in:
parent
3716a3fd31
commit
a0a251a688
@ -384,7 +384,7 @@ hir_analysis_precise_capture_self_alias = `Self` can't be captured in `use<...>`
|
||||
|
||||
hir_analysis_recursive_generic_parameter = {$param_def_kind} `{$param_name}` is only used recursively
|
||||
.label = {$param_def_kind} must be used non-recursively in the definition
|
||||
.note = all type parameters must be used in a non-recursive way in order to constrain its variance
|
||||
.note = all type parameters must be used in a non-recursive way in order to constrain their variance
|
||||
|
||||
hir_analysis_redundant_lifetime_args = unnecessary lifetime parameter `{$victim}`
|
||||
.note = you can use the `{$candidate}` lifetime directly, in place of `{$victim}`
|
||||
|
@ -1961,11 +1961,16 @@ impl<'tcx> Visitor<'tcx> for CollectUsageSpans<'_> {
|
||||
}
|
||||
|
||||
fn visit_ty(&mut self, t: &'tcx hir::Ty<'tcx>) -> Self::Result {
|
||||
if let hir::TyKind::Path(hir::QPath::Resolved(None, qpath)) = t.kind
|
||||
&& let Res::Def(DefKind::TyParam, def_id) = qpath.res
|
||||
if let hir::TyKind::Path(hir::QPath::Resolved(None, qpath)) = t.kind {
|
||||
if let Res::Def(DefKind::TyParam, def_id) = qpath.res
|
||||
&& def_id == self.param_def_id
|
||||
{
|
||||
self.spans.push(t.span);
|
||||
return;
|
||||
} else if let Res::SelfTyAlias { .. } = qpath.res {
|
||||
self.spans.push(t.span);
|
||||
return;
|
||||
}
|
||||
}
|
||||
intravisit::walk_ty(self, t);
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ LL | type Poly0<T> = Poly1<(T,)>;
|
||||
| type parameter must be used non-recursively in the definition
|
||||
|
|
||||
= help: consider removing `T` or referring to it in the body of the type alias
|
||||
= note: all type parameters must be used in a non-recursive way in order to constrain its variance
|
||||
= note: all type parameters must be used in a non-recursive way in order to constrain their variance
|
||||
|
||||
error: type parameter `T` is only used recursively
|
||||
--> $DIR/inherent-impls-overflow.rs:17:24
|
||||
@ -24,7 +24,7 @@ LL | type Poly1<T> = Poly0<(T,)>;
|
||||
| type parameter must be used non-recursively in the definition
|
||||
|
|
||||
= help: consider removing `T` or referring to it in the body of the type alias
|
||||
= note: all type parameters must be used in a non-recursive way in order to constrain its variance
|
||||
= note: all type parameters must be used in a non-recursive way in order to constrain their variance
|
||||
|
||||
error[E0275]: overflow evaluating the requirement `Poly0<()> == _`
|
||||
--> $DIR/inherent-impls-overflow.rs:21:6
|
||||
|
@ -24,7 +24,7 @@ LL | struct A<T>(B<T>);
|
||||
| type parameter must be used non-recursively in the definition
|
||||
|
|
||||
= help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
|
||||
= note: all type parameters must be used in a non-recursive way in order to constrain its variance
|
||||
= note: all type parameters must be used in a non-recursive way in order to constrain their variance
|
||||
|
||||
error: type parameter `T` is only used recursively
|
||||
--> $DIR/issue-105231.rs:5:17
|
||||
@ -35,7 +35,7 @@ LL | struct B<T>(A<A<T>>);
|
||||
| type parameter must be used non-recursively in the definition
|
||||
|
|
||||
= help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
|
||||
= note: all type parameters must be used in a non-recursive way in order to constrain its variance
|
||||
= note: all type parameters must be used in a non-recursive way in order to constrain their variance
|
||||
|
||||
error[E0275]: overflow evaluating the requirement `A<A<A<A<A<A<A<...>>>>>>>: Send`
|
||||
|
|
||||
|
@ -16,6 +16,9 @@ enum ListCell<T> {
|
||||
Nil
|
||||
}
|
||||
|
||||
struct SelfTyAlias<T>(Box<Self>);
|
||||
//~^ ERROR parameter `T` is only used recursively
|
||||
|
||||
struct WithBounds<T: Sized> {}
|
||||
//~^ ERROR parameter `T` is never used
|
||||
|
||||
|
@ -25,10 +25,21 @@ LL | Cons(Box<ListCell<T>>),
|
||||
| ^
|
||||
|
|
||||
= help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
|
||||
= note: all type parameters must be used in a non-recursive way in order to constrain its variance
|
||||
= note: all type parameters must be used in a non-recursive way in order to constrain their variance
|
||||
|
||||
error: type parameter `T` is only used recursively
|
||||
--> $DIR/variance-unused-type-param.rs:19:27
|
||||
|
|
||||
LL | struct SelfTyAlias<T>(Box<Self>);
|
||||
| - ^^^^
|
||||
| |
|
||||
| type parameter must be used non-recursively in the definition
|
||||
|
|
||||
= help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
|
||||
= note: all type parameters must be used in a non-recursive way in order to constrain their variance
|
||||
|
||||
error[E0392]: type parameter `T` is never used
|
||||
--> $DIR/variance-unused-type-param.rs:19:19
|
||||
--> $DIR/variance-unused-type-param.rs:22:19
|
||||
|
|
||||
LL | struct WithBounds<T: Sized> {}
|
||||
| ^ unused type parameter
|
||||
@ -36,7 +47,7 @@ LL | struct WithBounds<T: Sized> {}
|
||||
= help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
|
||||
|
||||
error[E0392]: type parameter `T` is never used
|
||||
--> $DIR/variance-unused-type-param.rs:22:24
|
||||
--> $DIR/variance-unused-type-param.rs:25:24
|
||||
|
|
||||
LL | struct WithWhereBounds<T> where T: Sized {}
|
||||
| ^ unused type parameter
|
||||
@ -44,13 +55,13 @@ LL | struct WithWhereBounds<T> where T: Sized {}
|
||||
= help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
|
||||
|
||||
error[E0392]: type parameter `T` is never used
|
||||
--> $DIR/variance-unused-type-param.rs:25:27
|
||||
--> $DIR/variance-unused-type-param.rs:28:27
|
||||
|
|
||||
LL | struct WithOutlivesBounds<T: 'static> {}
|
||||
| ^ unused type parameter
|
||||
|
|
||||
= help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
error: aborting due to 7 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0392`.
|
||||
|
Loading…
Reference in New Issue
Block a user