Move associated type bounds check to ast lowering

This makes the check for when associated type bounds more accurate
This commit is contained in:
Michael Goulet
2023-02-14 19:15:43 +00:00
parent b869e84e58
commit e7c490892f
12 changed files with 171 additions and 139 deletions

View File

@@ -1002,8 +1002,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
} else {
self.arena.alloc(hir::GenericArgs::none())
};
let itctx_tait = &ImplTraitContext::TypeAliasesOpaqueTy;
let kind = match &constraint.kind {
AssocConstraintKind::Equality { term } => {
let term = match term {
@@ -1040,7 +1038,13 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
// then to an opaque type).
//
// FIXME: this is only needed until `impl Trait` is allowed in type aliases.
ImplTraitContext::Disallowed(_) if self.is_in_dyn_type => (true, itctx_tait),
ImplTraitContext::Disallowed(position) if self.is_in_dyn_type => {
self.tcx.sess.emit_err(errors::MisplacedAssocTyBinding {
span: constraint.span,
position: DiagnosticArgFromDisplay(position),
});
(false, itctx)
}
// We are in the parameter position, but not within a dyn type:
//