Point to the empty trait alias.
This commit is contained in:
parent
1d43b4d59c
commit
e947fad68c
@ -45,6 +45,7 @@ typeck-copy-impl-on-non-adt =
|
|||||||
|
|
||||||
typeck-trait-object-declared-with-no-traits =
|
typeck-trait-object-declared-with-no-traits =
|
||||||
at least one trait is required for an object type
|
at least one trait is required for an object type
|
||||||
|
.alias-span = this alias does not contain a trait
|
||||||
|
|
||||||
typeck-ambiguous-lifetime-bound =
|
typeck-ambiguous-lifetime-bound =
|
||||||
ambiguous lifetime bound, explicit lifetime bound required
|
ambiguous lifetime bound, explicit lifetime bound required
|
||||||
|
@ -1370,7 +1370,13 @@ trait here instead: `trait NewTrait: {} {{}}`",
|
|||||||
}
|
}
|
||||||
|
|
||||||
if regular_traits.is_empty() && auto_traits.is_empty() {
|
if regular_traits.is_empty() && auto_traits.is_empty() {
|
||||||
tcx.sess.emit_err(TraitObjectDeclaredWithNoTraits { span });
|
let trait_alias_span = bounds
|
||||||
|
.trait_bounds
|
||||||
|
.iter()
|
||||||
|
.map(|&(trait_ref, _, _)| trait_ref.def_id())
|
||||||
|
.find(|&trait_ref| tcx.is_trait_alias(trait_ref))
|
||||||
|
.map(|trait_ref| tcx.def_span(trait_ref));
|
||||||
|
tcx.sess.emit_err(TraitObjectDeclaredWithNoTraits { span, trait_alias_span });
|
||||||
return tcx.ty_error();
|
return tcx.ty_error();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,6 +103,8 @@ pub struct CopyImplOnNonAdt {
|
|||||||
pub struct TraitObjectDeclaredWithNoTraits {
|
pub struct TraitObjectDeclaredWithNoTraits {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
|
#[label = "alias-span"]
|
||||||
|
pub trait_alias_span: Option<Span>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(SessionDiagnostic)]
|
||||||
|
@ -1,12 +1,18 @@
|
|||||||
error[E0224]: at least one trait is required for an object type
|
error[E0224]: at least one trait is required for an object type
|
||||||
--> $DIR/only-maybe-bound.rs:13:12
|
--> $DIR/only-maybe-bound.rs:13:12
|
||||||
|
|
|
|
||||||
|
LL | trait _1 = _0;
|
||||||
|
| -------------- this alias does not contain a trait
|
||||||
|
...
|
||||||
LL | type _T0 = dyn _1;
|
LL | type _T0 = dyn _1;
|
||||||
| ^^^^^^
|
| ^^^^^^
|
||||||
|
|
||||||
error[E0224]: at least one trait is required for an object type
|
error[E0224]: at least one trait is required for an object type
|
||||||
--> $DIR/only-maybe-bound.rs:19:12
|
--> $DIR/only-maybe-bound.rs:19:12
|
||||||
|
|
|
|
||||||
|
LL | trait _2 = _1 + _1;
|
||||||
|
| ------------------- this alias does not contain a trait
|
||||||
|
LL |
|
||||||
LL | type _T1 = dyn _2;
|
LL | type _T1 = dyn _2;
|
||||||
| ^^^^^^
|
| ^^^^^^
|
||||||
|
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
error[E0224]: at least one trait is required for an object type
|
error[E0224]: at least one trait is required for an object type
|
||||||
--> $DIR/issue-65673.rs:9:16
|
--> $DIR/issue-65673.rs:9:16
|
||||||
|
|
|
|
||||||
|
LL | trait Alias<T> = where T: Trait;
|
||||||
|
| -------------------------------- this alias does not contain a trait
|
||||||
|
...
|
||||||
LL | type Ctx = dyn Alias<T>;
|
LL | type Ctx = dyn Alias<T>;
|
||||||
| ^^^^^^^^^^^^
|
| ^^^^^^^^^^^^
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user