Rollup merge of #103383 - compiler-errors:tait-scope, r=oli-obk

Note scope of TAIT more accurately

This maybe explains why the person was confused in #101897, since we say "same module" but really should've said "same impl".

r? ``@oli-obk``
This commit is contained in:
Matthias Krüger 2022-10-29 08:57:35 +02:00 committed by GitHub
commit 790a716420
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 12 additions and 5 deletions

View File

@ -93,7 +93,7 @@ hir_analysis_expected_default_return_type = expected `()` because of default ret
hir_analysis_expected_return_type = expected `{$expected}` because of return type hir_analysis_expected_return_type = expected `{$expected}` because of return type
hir_analysis_unconstrained_opaque_type = unconstrained opaque type hir_analysis_unconstrained_opaque_type = unconstrained opaque type
.note = `{$name}` must be used in combination with a concrete type within the same module .note = `{$name}` must be used in combination with a concrete type within the same {$what}
hir_analysis_missing_type_params = hir_analysis_missing_type_params =
the type {$parameterCount -> the type {$parameterCount ->

View File

@ -701,6 +701,12 @@ fn visit_trait_item(&mut self, it: &'tcx TraitItem<'tcx>) {
tcx.sess.emit_err(UnconstrainedOpaqueType { tcx.sess.emit_err(UnconstrainedOpaqueType {
span: tcx.def_span(def_id), span: tcx.def_span(def_id),
name: tcx.item_name(tcx.local_parent(def_id).to_def_id()), name: tcx.item_name(tcx.local_parent(def_id).to_def_id()),
what: match tcx.hir().get(scope) {
_ if scope == hir::CRATE_HIR_ID => "module",
Node::Item(hir::Item { kind: hir::ItemKind::Mod(_), .. }) => "module",
Node::Item(hir::Item { kind: hir::ItemKind::Impl(_), .. }) => "impl",
_ => "item",
},
}); });
return tcx.ty_error(); return tcx.ty_error();
}; };

View File

@ -143,6 +143,7 @@ pub struct UnconstrainedOpaqueType {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
pub name: Symbol, pub name: Symbol,
pub what: &'static str,
} }
pub struct MissingTypeParams { pub struct MissingTypeParams {

View File

@ -4,7 +4,7 @@ error: unconstrained opaque type
LL | type FooFuture<'a> = impl Trait1; LL | type FooFuture<'a> = impl Trait1;
| ^^^^^^^^^^^ | ^^^^^^^^^^^
| |
= note: `FooFuture` must be used in combination with a concrete type within the same module = note: `FooFuture` must be used in combination with a concrete type within the same impl
error: aborting due to previous error error: aborting due to previous error

View File

@ -67,7 +67,7 @@ error: unconstrained opaque type
LL | type U = impl Trait; LL | type U = impl Trait;
| ^^^^^^^^^^ | ^^^^^^^^^^
| |
= note: `U` must be used in combination with a concrete type within the same module = note: `U` must be used in combination with a concrete type within the same impl
error: aborting due to 6 previous errors; 2 warnings emitted error: aborting due to 6 previous errors; 2 warnings emitted

View File

@ -94,7 +94,7 @@ error: unconstrained opaque type
LL | type U = impl Trait; LL | type U = impl Trait;
| ^^^^^^^^^^ | ^^^^^^^^^^
| |
= note: `U` must be used in combination with a concrete type within the same module = note: `U` must be used in combination with a concrete type within the same impl
error: aborting due to 7 previous errors; 6 warnings emitted error: aborting due to 7 previous errors; 6 warnings emitted

View File

@ -4,7 +4,7 @@ error: unconstrained opaque type
LL | type Future = impl Trait; LL | type Future = impl Trait;
| ^^^^^^^^^^ | ^^^^^^^^^^
| |
= note: `Future` must be used in combination with a concrete type within the same module = note: `Future` must be used in combination with a concrete type within the same impl
error: aborting due to previous error error: aborting due to previous error