Skip to content

Commit 29731ca

Browse files
Rollup merge of rust-lang#153055 - Urgau:revert-152289, r=jdonszelmann
Revert "Also duplicate `#[expect]` attribute in `#[derive]`-ed code" Turns out rust-lang#152289 doesn't work, not because cloning an attribute doesn't keep the same attribute id, but because `#[cfg]` and `#[cfg_attr]` [re-parse items from scratch](https://github.com/rust-lang/rust/blob/859951e3c7c9d0322c39bad49221937455bdffcd/compiler/rustc_builtin_macros/src/cfg_eval.rs#L100-L109) bypassing any cloning on AST and forcing the creation of new attribute IDs. 😕 Fixes rust-lang#153036 Fixes rust-lang#152401 Reopens rust-lang#150553
2 parents 69b7853 + 8fefa65 commit 29731ca

File tree

6 files changed

+39
-13
lines changed

6 files changed

+39
-13
lines changed

compiler/rustc_builtin_macros/src/deriving/generic/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,6 @@ impl<'a> TraitDef<'a> {
540540
.filter(|a| {
541541
a.has_any_name(&[
542542
sym::allow,
543-
sym::expect,
544543
sym::warn,
545544
sym::deny,
546545
sym::forbid,

tests/ui/lint/rfc-2383-lint-reason/derive-expect-issue-150553-3.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
// FIXME: Bring back duplication of the `#[expect]` attribute when deriving.
2+
//
13
// Make sure we produce the unfulfilled expectation lint if neither the struct or the
24
// derived code fulfilled it.
35

46
//@ check-pass
57

68
#[expect(unexpected_cfgs)]
79
//~^ WARN this lint expectation is unfulfilled
8-
//~^^ WARN this lint expectation is unfulfilled
10+
//FIXME ~^^ WARN this lint expectation is unfulfilled
911
#[derive(Debug)]
1012
pub struct MyStruct {
1113
pub t_ref: i64,
Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,10 @@
11
warning: this lint expectation is unfulfilled
2-
--> $DIR/derive-expect-issue-150553-3.rs:6:10
2+
--> $DIR/derive-expect-issue-150553-3.rs:8:10
33
|
44
LL | #[expect(unexpected_cfgs)]
55
| ^^^^^^^^^^^^^^^
66
|
77
= note: `#[warn(unfulfilled_lint_expectations)]` on by default
88

9-
warning: this lint expectation is unfulfilled
10-
--> $DIR/derive-expect-issue-150553-3.rs:6:10
11-
|
12-
LL | #[expect(unexpected_cfgs)]
13-
| ^^^^^^^^^^^^^^^
14-
|
15-
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
16-
17-
warning: 2 warnings emitted
9+
warning: 1 warning emitted
1810

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// This test makes sure that expended items with derives don't interfear with lint expectations.
2+
//
3+
// See <https://github.com/rust-lang/rust/issues/153036> for some context.
4+
5+
//@ check-pass
6+
7+
#[derive(Clone, Debug)]
8+
#[expect(unused)]
9+
pub struct LoggingArgs {
10+
#[cfg(false)]
11+
x: i32,
12+
y: i32,
13+
}
14+
15+
fn main() {}

tests/ui/lint/rfc-2383-lint-reason/derive-expect-issue-150553.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
// FIXME: Bring back duplication of the `#[expect]` attribute when deriving.
2+
//
13
// Make sure we properly copy the `#[expect]` attr to the derived code and that no
24
// unfulfilled expectations are trigerred.
35
//
46
// See <https://github.com/rust-lang/rust/issues/150553> for rational.
57

6-
//@ check-pass
8+
//@ check-fail
79

810
#![deny(redundant_lifetimes)]
911

@@ -12,6 +14,7 @@ use std::fmt::Debug;
1214
#[derive(Debug)]
1315
#[expect(redundant_lifetimes)]
1416
pub struct RefWrapper<'a, T>
17+
//~^ ERROR redundant_lifetimes
1518
where
1619
'a: 'static,
1720
T: Debug,
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error: unnecessary lifetime parameter `'a`
2+
--> $DIR/derive-expect-issue-150553.rs:16:23
3+
|
4+
LL | pub struct RefWrapper<'a, T>
5+
| ^^
6+
|
7+
= note: you can use the `'static` lifetime directly, in place of `'a`
8+
note: the lint level is defined here
9+
--> $DIR/derive-expect-issue-150553.rs:10:9
10+
|
11+
LL | #![deny(redundant_lifetimes)]
12+
| ^^^^^^^^^^^^^^^^^^^
13+
14+
error: aborting due to 1 previous error
15+

0 commit comments

Comments
 (0)