diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-06-12 17:44:38 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-06-12 17:44:38 +0200 |
| commit | 8475a88d67db7b341fd26ac5d9210988c659a37d (patch) | |
| tree | 36e506e1741770a9bb55e49d45c1729b46a123e3 /compiler | |
| parent | a5245b5894883d6a7803da96ed0899d2066177d4 (diff) | |
| parent | 72421bfb0c2a2a0209fbc96bb9a7d332589661d9 (diff) | |
Rollup merge of #112416 - jieyouxu:issue-112363, r=wesleywiser
Fix debug ICE for extern type with where clauses Fixes #112363.
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_ast_passes/src/ast_validation.rs | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/compiler/rustc_ast_passes/src/ast_validation.rs b/compiler/rustc_ast_passes/src/ast_validation.rs index 04ed2767876..a0979bbda54 100644 --- a/compiler/rustc_ast_passes/src/ast_validation.rs +++ b/compiler/rustc_ast_passes/src/ast_validation.rs @@ -364,7 +364,12 @@ impl<'a> AstValidator<'a> { self.err_handler().emit_err(errors::BoundInContext { span, ctx }); } - fn check_foreign_ty_genericless(&self, generics: &Generics, where_span: Span) { + fn check_foreign_ty_genericless( + &self, + generics: &Generics, + before_where_clause: &TyAliasWhereClause, + after_where_clause: &TyAliasWhereClause, + ) { let cannot_have = |span, descr, remove_descr| { self.err_handler().emit_err(errors::ExternTypesCannotHave { span, @@ -378,9 +383,14 @@ impl<'a> AstValidator<'a> { cannot_have(generics.span, "generic parameters", "generic parameters"); } - if !generics.where_clause.predicates.is_empty() { - cannot_have(where_span, "`where` clauses", "`where` clause"); - } + let check_where_clause = |where_clause: &TyAliasWhereClause| { + if let TyAliasWhereClause(true, where_clause_span) = where_clause { + cannot_have(*where_clause_span, "`where` clauses", "`where` clause"); + } + }; + + check_where_clause(before_where_clause); + check_where_clause(after_where_clause); } fn check_foreign_kind_bodyless(&self, ident: Ident, kind: &str, body: Option<Span>) { @@ -1039,7 +1049,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> { self.check_defaultness(fi.span, *defaultness); self.check_foreign_kind_bodyless(fi.ident, "type", ty.as_ref().map(|b| b.span)); self.check_type_no_bounds(bounds, "`extern` blocks"); - self.check_foreign_ty_genericless(generics, where_clauses.0.1); + self.check_foreign_ty_genericless(generics, &where_clauses.0, &where_clauses.1); self.check_foreign_item_ascii_only(fi.ident); } ForeignItemKind::Static(_, _, body) => { |
