diff options
| author | Mahdi Dibaiee <mdibaiee@pm.me> | 2022-01-10 08:54:42 +0000 |
|---|---|---|
| committer | Mahdi Dibaiee <mdibaiee@pm.me> | 2022-01-10 17:42:20 +0000 |
| commit | 91ed6892f7ec60fb76eeaaa024919f293a58d733 (patch) | |
| tree | 220e24d714a7892d27f15869ac42728c1a6bd9f0 /compiler | |
| parent | 4c3e330a8c023af20beb23a3a46b5d6d77a62839 (diff) | |
| download | rust-91ed6892f7ec60fb76eeaaa024919f293a58d733.tar.gz rust-91ed6892f7ec60fb76eeaaa024919f293a58d733.zip | |
rustc_pass_by_value lint: add test on custom types
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_lint/src/pass_by_value.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_passes/src/check_attr.rs | 11 |
2 files changed, 4 insertions, 8 deletions
diff --git a/compiler/rustc_lint/src/pass_by_value.rs b/compiler/rustc_lint/src/pass_by_value.rs index 0bfa2a673c2..0847f600f9d 100644 --- a/compiler/rustc_lint/src/pass_by_value.rs +++ b/compiler/rustc_lint/src/pass_by_value.rs @@ -11,6 +11,7 @@ declare_tool_lint! { /// The `rustc_pass_by_value` lint marks a type with `#[rustc_pass_by_value]` requiring it to always be passed by value. /// This is usually used for types that are thin wrappers around references, so there is no benefit to an extra /// layer of indirection. (Example: `Ty` which is a reference to a `TyS`) + /// This lint relies on `#[rustc_diagnostic_item]` being available for the target. pub rustc::PASS_BY_VALUE, Warn, "pass by reference of a type flagged as `#[rustc_pass_by_value]`", diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index 2febb2e56ec..e700a61ce48 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -1070,20 +1070,15 @@ impl CheckAttrVisitor<'_> { /// Warns against some misuses of `#[pass_by_value]` fn check_pass_by_value(&self, attr: &Attribute, span: &Span, target: Target) -> bool { match target { - Target::Struct - | Target::Enum - | Target::Union - | Target::Trait - | Target::TraitAlias - | Target::TyAlias => true, + Target::Struct | Target::Enum | Target::TyAlias => true, _ => { self.tcx .sess .struct_span_err( attr.span, - "`pass_by_value` attribute should be applied to a struct, enum, trait or type alias.", + "`pass_by_value` attribute should be applied to a struct, enum or type alias.", ) - .span_label(*span, "is not a struct, enum, trait or type alias") + .span_label(*span, "is not a struct, enum or type alias") .emit(); false } |
