@@ -284,6 +284,9 @@ impl<'sess, S: Stage> AttributeParser<'sess, S> {
284284 mut emit_lint : impl FnMut ( LintId , Span , AttributeLintKind ) ,
285285 ) -> Vec < Attribute > {
286286 let mut attributes = Vec :: new ( ) ;
287+ // Attributes that are still in the AST at this step but that we will not care about during
288+ // the next steps.
289+ let mut dropped_attributes = Vec :: new ( ) ;
287290 let mut attr_paths: Vec < RefPathParser < ' _ > > = Vec :: new ( ) ;
288291 let mut early_parsed_state = EarlyParsedState :: default ( ) ;
289292
@@ -413,21 +416,6 @@ impl<'sess, S: Stage> AttributeParser<'sess, S> {
413416 ) ;
414417 }
415418 } else {
416- // If we're here, we must be compiling a tool attribute... Or someone
417- // forgot to parse their fancy new attribute. Let's warn them in any case.
418- // If you are that person, and you really think your attribute should
419- // remain unparsed, carefully read the documentation in this module and if
420- // you still think so you can add an exception to this assertion.
421-
422- // FIXME(jdonszelmann): convert other attributes, and check with this that
423- // we caught em all
424- // const FIXME_TEMPORARY_ATTR_ALLOWLIST: &[Symbol] = &[sym::cfg];
425- // assert!(
426- // self.tools.contains(&parts[0]) || true,
427- // // || FIXME_TEMPORARY_ATTR_ALLOWLIST.contains(&parts[0]),
428- // "attribute {path} wasn't parsed and isn't a know tool attribute",
429- // );
430-
431419 let attr = AttrItem {
432420 path : attr_path. clone ( ) ,
433421 args : self
@@ -443,8 +431,19 @@ impl<'sess, S: Stage> AttributeParser<'sess, S> {
443431 self . check_invalid_crate_level_attr_item ( & attr) ;
444432 }
445433
446- attributes. push ( Attribute :: Unparsed ( Box :: new ( attr) ) ) ;
447- } ;
434+ let attr = Attribute :: Unparsed ( Box :: new ( attr) ) ;
435+
436+ if self . tools . contains ( & parts[ 0 ] )
437+ // FIXME: this can be removed once #152369 has been merged.
438+ // https://github.com/rust-lang/rust/pull/152369
439+ || [ sym:: allow, sym:: deny, sym:: expect, sym:: forbid, sym:: warn]
440+ . contains ( & parts[ 0 ] )
441+ {
442+ attributes. push ( attr) ;
443+ } else {
444+ dropped_attributes. push ( attr) ;
445+ }
446+ }
448447 }
449448 }
450449 }
@@ -460,7 +459,9 @@ impl<'sess, S: Stage> AttributeParser<'sess, S> {
460459 }
461460
462461 if self . stage . should_emit ( ) != ShouldEmit :: Nothing && target == Target :: WherePredicate {
463- self . check_invalid_where_predicate_attrs ( & attributes) ;
462+ self . check_invalid_where_predicate_attrs (
463+ attributes. iter ( ) . chain ( dropped_attributes. iter ( ) ) ,
464+ ) ;
464465 }
465466
466467 attributes
0 commit comments