Skip to content

Commit 9aeead4

Browse files
committed
add error message for unused duplicate
1 parent 49443bf commit 9aeead4

File tree

7 files changed

+21
-29
lines changed

7 files changed

+21
-29
lines changed

compiler/rustc_ast_lowering/src/expr.rs

+6-9
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
7474
// Merge attributes into the inner expression.
7575
if !e.attrs.is_empty() {
7676
let old_attrs = self.attrs.get(&ex.hir_id.local_id).copied().unwrap_or(&[]);
77-
let new_attrs = self.lower_attrs_vec(&e.attrs, e.span, ex.hir_id)
78-
.into_iter()
79-
.chain(old_attrs.iter().cloned());
80-
self.attrs.insert(
81-
ex.hir_id.local_id,
82-
&*self.arena.alloc_from_iter(
83-
new_attrs,
84-
),
85-
);
77+
let new_attrs = self
78+
.lower_attrs_vec(&e.attrs, e.span, ex.hir_id)
79+
.into_iter()
80+
.chain(old_attrs.iter().cloned());
81+
self.attrs
82+
.insert(ex.hir_id.local_id, &*self.arena.alloc_from_iter(new_attrs));
8683
}
8784
return ex;
8885
}

compiler/rustc_ast_lowering/src/item.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl<'a, 'hir> ItemLowerer<'a, 'hir> {
5858
&mut self,
5959
owner: NodeId,
6060
f: impl FnOnce(&mut LoweringContext<'_, 'hir>) -> hir::OwnerNode<'hir>,
61-
) {
61+
) {
6262
let mut lctx = LoweringContext::new(self.tcx, self.resolver);
6363
lctx.with_hir_id_owner(owner, |lctx| f(lctx));
6464

compiler/rustc_ast_lowering/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
5151
use rustc_data_structures::tagged_ptr::TaggedRef;
5252
use rustc_errors::{DiagArgFromDisplay, DiagCtxtHandle, StashKey};
5353
use rustc_hir::def::{DefKind, LifetimeRes, Namespace, PartialRes, PerNS, Res};
54-
use rustc_hir::def_id::{LocalDefId, CRATE_DEF_ID, LOCAL_CRATE};
54+
use rustc_hir::def_id::{CRATE_DEF_ID, LOCAL_CRATE, LocalDefId};
5555
use rustc_hir::{
5656
self as hir, ConstArg, GenericArg, HirId, ItemLocalMap, LangItem, ParamName, TraitCandidate,
5757
};

compiler/rustc_attr_parsing/messages.ftl

+1-3
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,7 @@ attr_parsing_unused_duplicate =
135135
unused attribute
136136
.suggestion = remove this attribute
137137
.note = attribute also specified here
138-
.warn = {-attr_parsing_previously_accepted}
139-
140-
138+
.warn = {-passes_previously_accepted}
141139
attr_parsing_unused_multiple =
142140
multiple `{$name}` attributes
143141
.suggestion = remove this attribute

compiler/rustc_attr_parsing/src/context.rs

+8-10
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,7 @@ impl Stage for Late {
195195
diag: impl DynSend + for<'x> LintDiagnostic<'x, ()> + 'static,
196196
) {
197197
println!("stashing lint");
198-
dcx.delay_lint_during_ast_lowering((lint, id, span, Box::new(|x| {
199-
diag.decorate_lint(x)
200-
})));
198+
dcx.delay_lint_during_ast_lowering((lint, id, span, Box::new(|x| diag.decorate_lint(x))));
201199
}
202200
}
203201

@@ -221,7 +219,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
221219
}
222220

223221
pub(crate) fn emit_lint(
224-
& self,
222+
&self,
225223
lint: &'static Lint,
226224
span: Span,
227225
diag: impl DynSend + for<'x> LintDiagnostic<'x, ()> + 'static,
@@ -316,12 +314,12 @@ impl<'sess> AttributeParser<'sess, Early> {
316314
) -> Option<Attribute> {
317315
let mut p = Self { features: None, tools: Vec::new(), parse_only: Some(sym), sess };
318316
let mut parsed = p.parse_attribute_list(
319-
attrs,
320-
target_span,
321-
target_node_id,
322-
OmitDoc::Skip,
323-
std::convert::identity,
324-
);
317+
attrs,
318+
target_span,
319+
target_node_id,
320+
OmitDoc::Skip,
321+
std::convert::identity,
322+
);
325323
assert!(parsed.len() <= 1);
326324

327325
parsed.pop()

compiler/rustc_attr_parsing/src/session_diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ pub(crate) struct UnusedMultiple {
452452
}
453453

454454
#[derive(LintDiagnostic)]
455-
#[diag(attr_parsing_unused_multiple)]
455+
#[diag(attr_parsing_unused_duplicate)]
456456
pub(crate) struct UnusedDuplicate {
457457
#[suggestion(code = "", applicability = "machine-applicable")]
458458
pub this: Span,

compiler/rustc_errors/src/lib.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ pub use diagnostic_impls::{
5353
DiagArgFromDisplay, DiagSymbolList, ElidedLifetimeInPathSubdiag, ExpectedLifetimeParameter,
5454
IndicateAnonymousLifetime, SingleLabelManySpans,
5555
};
56-
use rustc_lint_defs::Lint;
57-
use rustc_hir::HirId;
5856
pub use emitter::ColorConfig;
5957
use emitter::{DynEmitter, Emitter, is_case_difference, is_different};
6058
use rustc_data_structures::AtomicRef;
@@ -66,8 +64,9 @@ pub use rustc_error_messages::{
6664
SubdiagMessage, fallback_fluent_bundle, fluent_bundle,
6765
};
6866
use rustc_hashes::Hash128;
69-
use rustc_lint_defs::LintExpectationId;
67+
use rustc_hir::HirId;
7068
pub use rustc_lint_defs::{Applicability, listify, pluralize};
69+
use rustc_lint_defs::{Lint, LintExpectationId};
7170
use rustc_macros::{Decodable, Encodable};
7271
pub use rustc_span::ErrorGuaranteed;
7372
pub use rustc_span::fatal_error::{FatalError, FatalErrorMarker};
@@ -542,7 +541,7 @@ pub type HirDelayedLint = (
542541
&'static Lint,
543542
HirId,
544543
Span,
545-
Box<dyn DynSend + for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>) + 'static>
544+
Box<dyn DynSend + for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>) + 'static>,
546545
);
547546

548547
/// This inner struct exists to keep it all behind a single lock;

0 commit comments

Comments
 (0)