about summary refs log tree commit diff
path: root/compiler/rustc_passes
diff options
context:
space:
mode:
authorCamelid <camelidcamel@gmail.com>2021-03-11 15:41:51 -0800
committerCamelid <camelidcamel@gmail.com>2021-03-13 13:55:15 -0800
commit7e972a39b8e9c7228ce230206326e3e4c4e81e2c (patch)
treed60ac857a407f4e661d253a379d9568f8c2e7725 /compiler/rustc_passes
parent7189c05bf8fe5b9d21815c44540d76301c90a8aa (diff)
downloadrust-7e972a39b8e9c7228ce230206326e3e4c4e81e2c.tar.gz
rust-7e972a39b8e9c7228ce230206326e3e4c4e81e2c.zip
Report error for each invalid nested attribute
Diffstat (limited to 'compiler/rustc_passes')
-rw-r--r--compiler/rustc_passes/src/check_attr.rs15
1 files changed, 9 insertions, 6 deletions
diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs
index 5120edb2e35..a1871e796d8 100644
--- a/compiler/rustc_passes/src/check_attr.rs
+++ b/compiler/rustc_passes/src/check_attr.rs
@@ -531,6 +531,8 @@ impl CheckAttrVisitor<'tcx> {
     }
 
     fn check_doc_attrs(&self, attr: &Attribute, hir_id: HirId, target: Target) -> bool {
+        let mut is_valid = true;
+
         if let Some(list) = attr.meta().and_then(|mi| mi.meta_item_list().map(|l| l.to_vec())) {
             for meta in list {
                 if let Some(i_meta) = meta.meta_item() {
@@ -539,14 +541,14 @@ impl CheckAttrVisitor<'tcx> {
                             if !self.check_attr_crate_level(&meta, hir_id, "alias")
                                 || !self.check_doc_alias(&meta, hir_id, target) =>
                         {
-                            return false;
+                            is_valid = false
                         }
 
                         sym::keyword
                             if !self.check_attr_crate_level(&meta, hir_id, "keyword")
                                 || !self.check_doc_keyword(&meta, hir_id) =>
                         {
-                            return false;
+                            is_valid = false
                         }
 
                         sym::test if CRATE_HIR_ID != hir_id => {
@@ -562,7 +564,7 @@ impl CheckAttrVisitor<'tcx> {
                                     .emit();
                                 },
                             );
-                            return false;
+                            is_valid = false;
                         }
 
                         // no_default_passes: deprecated
@@ -602,7 +604,7 @@ impl CheckAttrVisitor<'tcx> {
                                     .emit();
                                 },
                             );
-                            return false;
+                            is_valid = false;
                         }
                     }
                 } else {
@@ -614,11 +616,12 @@ impl CheckAttrVisitor<'tcx> {
                             lint.build(&format!("unknown `doc` attribute")).emit();
                         },
                     );
-                    return false;
+                    is_valid = false;
                 }
             }
         }
-        true
+
+        is_valid
     }
 
     /// Checks if `#[cold]` is applied to a non-function. Returns `true` if valid.