Skip to content

Commit d04391c

Browse files
committed
Removes unchecked_error_guaranteed call.
If we abort immediately after complaining about the obsolete `impl Trait for ..` syntax, then we avoid reaching HIR lowering. This means we can use `TyKind::Dummy` instead of `TyKind::Err`.
1 parent bb59453 commit d04391c

File tree

2 files changed

+8
-19
lines changed

2 files changed

+8
-19
lines changed

compiler/rustc_ast_passes/src/ast_validation.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -881,9 +881,10 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
881881
&item.vis,
882882
errors::VisibilityNotPermittedNote::TraitImpl,
883883
);
884-
// njn: use Dummy here
885-
if let TyKind::Err(_) = self_ty.kind {
886-
this.dcx().emit_err(errors::ObsoleteAuto { span: item.span });
884+
if let TyKind::Dummy = self_ty.kind {
885+
// Abort immediately otherwise the `TyKind::Dummy` will reach HIR lowering,
886+
// which isn't allowed. Not a problem for this obscure, obsolete syntax.
887+
this.dcx().emit_fatal(errors::ObsoleteAuto { span: item.span });
887888
}
888889
if let (&Unsafe::Yes(span), &ImplPolarity::Negative(sp)) = (unsafety, polarity)
889890
{

compiler/rustc_parse/src/parser/item.rs

+4-16
Original file line numberDiff line numberDiff line change
@@ -592,22 +592,10 @@ impl<'a> Parser<'a> {
592592
// We need to report this error after `cfg` expansion for compatibility reasons
593593
self.bump(); // `..`, do not add it to expected tokens
594594

595-
// FIXME(nnethercote): AST validation later detects this
596-
// `TyKind::Err` and emits an errors. So why the unchecked
597-
// ErrorGuaranteed?
598-
// - A `span_delayed_bug` doesn't work here, because rustfmt can
599-
// hit this path but then not hit the follow-up path in the AST
600-
// validator that issues the error, which results in ICEs.
601-
// - `TyKind::Dummy` doesn't work, because it ends up reaching HIR
602-
// lowering, which results in ICEs. Changing `TyKind::Dummy` to
603-
// `TyKind::Err` during AST validation might fix that, but that's
604-
// not possible because AST validation doesn't allow mutability.
605-
//
606-
// #121072 will hopefully remove all this special handling of the
607-
// obsolete `impl Trait for ..` and then this can go away.
608-
#[allow(deprecated)]
609-
let guar = rustc_errors::ErrorGuaranteed::unchecked_error_guaranteed();
610-
Some(self.mk_ty(self.prev_token.span, TyKind::Err(guar)))
595+
// AST validation later detects this `TyKind::Dummy` and emits an
596+
// error. (#121072 will hopefully remove all this special handling
597+
// of the obsolete `impl Trait for ..` and then this can go away.)
598+
Some(self.mk_ty(self.prev_token.span, TyKind::Dummy))
611599
} else if has_for || self.token.can_begin_type() {
612600
Some(self.parse_ty()?)
613601
} else {

0 commit comments

Comments
 (0)