Auto merge of #143779 - JonathanBrouwer:automatically_derived_parser, r=oli-obk
Port `#[automatically_derived]` to the new attribute parsing infrastructure Ports `#[automatically_derived]` to the new attribute parsing infrastructure for https://github.com/rust-lang/rust/issues/131229#issuecomment-2971351163 r? `@oli-obk` cc `@jdonszelmann`
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
use rustc_attr_data_structures::{AttributeKind, find_attr};
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_errors::{Applicability, Diag};
|
||||
use rustc_hir as hir;
|
||||
@@ -62,7 +63,7 @@ impl<'tcx> LateLintPass<'tcx> for DefaultCouldBeDerived {
|
||||
let hir::ImplItemKind::Fn(_sig, body_id) = impl_item.kind else { return };
|
||||
let assoc = cx.tcx.associated_item(impl_item.owner_id);
|
||||
let parent = assoc.container_id(cx.tcx);
|
||||
if cx.tcx.has_attr(parent, sym::automatically_derived) {
|
||||
if find_attr!(cx.tcx.get_all_attrs(parent), AttributeKind::AutomaticallyDerived(..)) {
|
||||
// We don't care about what `#[derive(Default)]` produces in this lint.
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -644,7 +644,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
|
||||
) {
|
||||
let sess = self.sess;
|
||||
for (attr_index, attr) in attrs.iter().enumerate() {
|
||||
if attr.has_name(sym::automatically_derived) {
|
||||
if attr.is_automatically_derived_attr() {
|
||||
self.insert(
|
||||
LintId::of(SINGLE_USE_LIFETIMES),
|
||||
LevelAndSource {
|
||||
|
||||
Reference in New Issue
Block a user