Skip to content

Commit 0453cda

Browse files
committed
Don't bail out early when checking invalid repr attr
1 parent 4b87ed9 commit 0453cda

File tree

3 files changed

+25
-8
lines changed

3 files changed

+25
-8
lines changed

compiler/rustc_passes/src/check_attr.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,11 @@ impl CheckAttrVisitor<'_> {
101101
item: Option<ItemLike<'_>>,
102102
) {
103103
let mut doc_aliases = FxHashMap::default();
104-
let mut is_valid = true;
105104
let mut specified_inline = None;
106105
let mut seen = FxHashMap::default();
107106
let attrs = self.tcx.hir().attrs(hir_id);
108107
for attr in attrs {
109-
let attr_is_valid = match attr.name_or_empty() {
108+
match attr.name_or_empty() {
110109
sym::do_not_recommend => self.check_do_not_recommend(attr.span, target),
111110
sym::inline => self.check_inline(hir_id, attr, span, target),
112111
sym::no_coverage => self.check_no_coverage(hir_id, attr, span, target),
@@ -188,7 +187,6 @@ impl CheckAttrVisitor<'_> {
188187
sym::link_ordinal => self.check_link_ordinal(&attr, span, target),
189188
_ => true,
190189
};
191-
is_valid &= attr_is_valid;
192190

193191
// lint-only checks
194192
match attr.name_or_empty() {
@@ -255,10 +253,6 @@ impl CheckAttrVisitor<'_> {
255253
self.check_unused_attribute(hir_id, attr)
256254
}
257255

258-
if !is_valid {
259-
return;
260-
}
261-
262256
self.check_repr(attrs, span, target, item, hir_id);
263257
self.check_used(attrs, target);
264258
}

tests/ui/repr/invalid_repr_list_help.rs

+5
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,8 @@ pub struct OwO3 {
1515
pub enum OwO4 {
1616
UwU = 1,
1717
}
18+
19+
#[repr(uwu)] //~ERROR: unrecognized representation hint
20+
#[doc(owo)] //~WARN: unknown `doc` attribute
21+
//~^ WARN: this was previously
22+
pub struct Owo5;

tests/ui/repr/invalid_repr_list_help.stderr

+19-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,24 @@ LL | #[repr(uwu, u8)]
3030
|
3131
= help: valid reprs are `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize`
3232

33-
error: aborting due to 4 previous errors
33+
warning: unknown `doc` attribute `owo`
34+
--> $DIR/invalid_repr_list_help.rs:20:7
35+
|
36+
LL | #[doc(owo)]
37+
| ^^^
38+
|
39+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
40+
= note: for more information, see issue #82730 <https://github.com/rust-lang/rust/issues/82730>
41+
= note: `#[warn(invalid_doc_attributes)]` on by default
42+
43+
error[E0552]: unrecognized representation hint
44+
--> $DIR/invalid_repr_list_help.rs:19:8
45+
|
46+
LL | #[repr(uwu)]
47+
| ^^^
48+
|
49+
= help: valid reprs are `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize`
50+
51+
error: aborting due to 5 previous errors; 1 warning emitted
3452

3553
For more information about this error, try `rustc --explain E0552`.

0 commit comments

Comments
 (0)