Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions compiler/rustc_builtin_macros/src/deriving/generic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@ impl<'a> TraitDef<'a> {
.filter(|a| {
a.has_any_name(&[
sym::allow,
sym::expect,
sym::warn,
sym::deny,
sym::forbid,
Expand Down
14 changes: 14 additions & 0 deletions tests/ui/lint/rfc-2383-lint-reason/derive-expect-issue-150553-2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Make sure that the copied `#[expect]` attr in the derived code does not trigger an unfulfilled
// expectation as it's linked to the original one which is fulfilled.
//
// See <https://github.com/rust-lang/rust/issues/150553#issuecomment-3780810363> for rational.

//@ check-pass

#[expect(non_camel_case_types)]
#[derive(Debug)]
pub struct SCREAMING_CASE {
pub t_ref: i64,
}

fn main() {}
14 changes: 14 additions & 0 deletions tests/ui/lint/rfc-2383-lint-reason/derive-expect-issue-150553-3.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Make sure we produce the unfulfilled expectation lint if neither the struct or the
// derived code fulfilled it.

//@ check-pass

#[expect(unexpected_cfgs)]
//~^ WARN this lint expectation is unfulfilled
//~^^ WARN this lint expectation is unfulfilled
#[derive(Debug)]
pub struct MyStruct {
pub t_ref: i64,
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
warning: this lint expectation is unfulfilled
--> $DIR/derive-expect-issue-150553-3.rs:6:10
|
LL | #[expect(unexpected_cfgs)]
| ^^^^^^^^^^^^^^^
|
= note: `#[warn(unfulfilled_lint_expectations)]` on by default

warning: this lint expectation is unfulfilled
--> $DIR/derive-expect-issue-150553-3.rs:6:10
|
LL | #[expect(unexpected_cfgs)]
| ^^^^^^^^^^^^^^^
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

warning: 2 warnings emitted

22 changes: 22 additions & 0 deletions tests/ui/lint/rfc-2383-lint-reason/derive-expect-issue-150553.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Make sure we properly copy the `#[expect]` attr to the derived code and that no
// unfulfilled expectations are trigerred.
//
// See <https://github.com/rust-lang/rust/issues/150553> for rational.

//@ check-pass

#![deny(redundant_lifetimes)]

use std::fmt::Debug;

#[derive(Debug)]
#[expect(redundant_lifetimes)]
pub struct RefWrapper<'a, T>
where
'a: 'static,
T: Debug,
{
pub t_ref: &'a T,
}

fn main() {}
Loading