Skip to content

Commit

Permalink
Rollup merge of #103383 - compiler-errors:tait-scope, r=oli-obk
Browse files Browse the repository at this point in the history
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``
  • Loading branch information
matthiaskrgr authored Oct 29, 2022
2 parents 67c469f + 4accf83 commit 790a716
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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_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 =
the type {$parameterCount ->
Expand Down
6 changes: 6 additions & 0 deletions compiler/rustc_hir_analysis/src/collect/type_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,12 @@ fn find_opaque_ty_constraints_for_tait(tcx: TyCtxt<'_>, def_id: LocalDefId) -> T
tcx.sess.emit_err(UnconstrainedOpaqueType {
span: tcx.def_span(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();
};
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_hir_analysis/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ pub struct UnconstrainedOpaqueType {
#[primary_span]
pub span: Span,
pub name: Symbol,
pub what: &'static str,
}

pub struct MissingTypeParams {
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/generic-associated-types/issue-87258_a.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error: unconstrained opaque type
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

2 changes: 1 addition & 1 deletion src/test/ui/lint/inline-trait-and-foreign-items.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ error: unconstrained opaque type
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

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/lint/no-coverage.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ error: unconstrained opaque type
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

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/save-analysis/issue-68621.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error: unconstrained opaque type
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

0 comments on commit 790a716

Please sign in to comment.