Skip to content

Commit ebd8e5c

Browse files
authored
Rollup merge of rust-lang#103383 - compiler-errors:tait-scope, r=oli-obk
Note scope of TAIT more accurately This maybe explains why the person was confused in rust-lang#101897, since we say "same module" but really should've said "same impl". r? ``@oli-obk``
2 parents a0a9ade + 4accf83 commit ebd8e5c

File tree

7 files changed

+12
-5
lines changed

7 files changed

+12
-5
lines changed

compiler/rustc_error_messages/locales/en-US/hir_analysis.ftl

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ hir_analysis_expected_default_return_type = expected `()` because of default ret
9393
hir_analysis_expected_return_type = expected `{$expected}` because of return type
9494
9595
hir_analysis_unconstrained_opaque_type = unconstrained opaque type
96-
.note = `{$name}` must be used in combination with a concrete type within the same module
96+
.note = `{$name}` must be used in combination with a concrete type within the same {$what}
9797
9898
hir_analysis_missing_type_params =
9999
the type {$parameterCount ->

compiler/rustc_hir_analysis/src/collect/type_of.rs

+6
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,12 @@ fn find_opaque_ty_constraints_for_tait(tcx: TyCtxt<'_>, def_id: LocalDefId) -> T
701701
tcx.sess.emit_err(UnconstrainedOpaqueType {
702702
span: tcx.def_span(def_id),
703703
name: tcx.item_name(tcx.local_parent(def_id).to_def_id()),
704+
what: match tcx.hir().get(scope) {
705+
_ if scope == hir::CRATE_HIR_ID => "module",
706+
Node::Item(hir::Item { kind: hir::ItemKind::Mod(_), .. }) => "module",
707+
Node::Item(hir::Item { kind: hir::ItemKind::Impl(_), .. }) => "impl",
708+
_ => "item",
709+
},
704710
});
705711
return tcx.ty_error();
706712
};

compiler/rustc_hir_analysis/src/errors.rs

+1
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ pub struct UnconstrainedOpaqueType {
143143
#[primary_span]
144144
pub span: Span,
145145
pub name: Symbol,
146+
pub what: &'static str,
146147
}
147148

148149
pub struct MissingTypeParams {

src/test/ui/generic-associated-types/issue-87258_a.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error: unconstrained opaque type
44
LL | type FooFuture<'a> = impl Trait1;
55
| ^^^^^^^^^^^
66
|
7-
= note: `FooFuture` must be used in combination with a concrete type within the same module
7+
= note: `FooFuture` must be used in combination with a concrete type within the same impl
88

99
error: aborting due to previous error
1010

src/test/ui/lint/inline-trait-and-foreign-items.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ error: unconstrained opaque type
6767
LL | type U = impl Trait;
6868
| ^^^^^^^^^^
6969
|
70-
= note: `U` must be used in combination with a concrete type within the same module
70+
= note: `U` must be used in combination with a concrete type within the same impl
7171

7272
error: aborting due to 6 previous errors; 2 warnings emitted
7373

src/test/ui/lint/no-coverage.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ error: unconstrained opaque type
9494
LL | type U = impl Trait;
9595
| ^^^^^^^^^^
9696
|
97-
= note: `U` must be used in combination with a concrete type within the same module
97+
= note: `U` must be used in combination with a concrete type within the same impl
9898

9999
error: aborting due to 7 previous errors; 6 warnings emitted
100100

src/test/ui/save-analysis/issue-68621.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error: unconstrained opaque type
44
LL | type Future = impl Trait;
55
| ^^^^^^^^^^
66
|
7-
= note: `Future` must be used in combination with a concrete type within the same module
7+
= note: `Future` must be used in combination with a concrete type within the same impl
88

99
error: aborting due to previous error
1010

0 commit comments

Comments
 (0)