|
1 | 1 | use rustc_ast::visit::{self, AssocCtxt, FnCtxt, FnKind, Visitor}; |
2 | | -use rustc_ast::{self as ast, AttrVec, NodeId, PatKind, attr, token}; |
| 2 | +use rustc_ast::{self as ast, AttrVec, GenericBound, NodeId, PatKind, attr, token}; |
3 | 3 | use rustc_errors::inline_fluent; |
4 | 4 | use rustc_feature::{AttributeGate, BUILTIN_ATTRIBUTE_MAP, BuiltinAttribute, Features}; |
5 | 5 | use rustc_session::Session; |
@@ -147,7 +147,17 @@ impl<'a> PostExpansionVisitor<'a> { |
147 | 147 | for param in params { |
148 | 148 | if !param.bounds.is_empty() { |
149 | 149 | let spans: Vec<_> = param.bounds.iter().map(|b| b.span()).collect(); |
150 | | - self.sess.dcx().emit_err(errors::ForbiddenBound { spans }); |
| 150 | + if param.bounds.iter().any(|bound| matches!(bound, GenericBound::Trait(_))) { |
| 151 | + // Issue #149695 |
| 152 | + // Abort immediately otherwise items defined in complex bounds will be lowered into HIR, |
| 153 | + // which will cause ICEs when errors of the items visit unlowered parents. |
| 154 | + // |
| 155 | + // FIXME: Once we find a way to filter hirless items without causing perf regression, |
| 156 | + // we should still emit an error instead of fatal here. |
| 157 | + self.sess.dcx().emit_fatal(errors::ForbiddenBound { spans }); |
| 158 | + } else { |
| 159 | + self.sess.dcx().emit_err(errors::ForbiddenBound { spans }); |
| 160 | + } |
151 | 161 | } |
152 | 162 | } |
153 | 163 | } |
|
0 commit comments