Skip to content

Commit 0503fca

Browse files
Give all arguments a Span as argument
Signed-off-by: Jonathan Brouwer <[email protected]>
1 parent 855e0fe commit 0503fca

File tree

12 files changed

+25
-25
lines changed

12 files changed

+25
-25
lines changed

compiler/rustc_attr_data_structures/src/attributes.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ pub enum AttributeKind {
232232
},
233233

234234
/// Represents `#[rustc_const_stable_indirect]`.
235-
ConstStabilityIndirect,
235+
ConstStabilityIndirect(Span),
236236

237237
/// Represents [`#[deprecated]`](https://doc.rust-lang.org/stable/reference/attributes/diagnostics.html#the-deprecated-attribute).
238238
Deprecation { deprecation: Deprecation, span: Span },
@@ -241,7 +241,7 @@ pub enum AttributeKind {
241241
DocComment { style: AttrStyle, kind: CommentKind, span: Span, comment: Symbol },
242242

243243
/// Represents `#[rustc_dummy]`.
244-
Dummy,
244+
Dummy(Span),
245245

246246
/// Represents [`#[export_name]`](https://doc.rust-lang.org/reference/abi.html#the-export_name-attribute).
247247
ExportName {
@@ -252,7 +252,7 @@ pub enum AttributeKind {
252252
},
253253

254254
/// Represents `#[export_stable]`.
255-
ExportStable,
255+
ExportStable(Span),
256256

257257
/// Represents `#[ffi_const]`.
258258
FfiConst(Span),
@@ -280,7 +280,7 @@ pub enum AttributeKind {
280280
LoopMatch(Span),
281281

282282
/// Represents `#[rustc_macro_transparency]`.
283-
MacroTransparency(Transparency),
283+
MacroTransparency(Transparency, Span),
284284

285285
/// Represents [`#[may_dangle]`](https://std-dev-guide.rust-lang.org/tricky/may-dangle.html).
286286
MayDangle(Span),
@@ -326,7 +326,7 @@ pub enum AttributeKind {
326326
RustcLayoutScalarValidRangeStart(Box<u128>, Span),
327327

328328
/// Represents `#[rustc_object_lifetime_default]`.
329-
RustcObjectLifetimeDefault,
329+
RustcObjectLifetimeDefault(Span),
330330

331331
/// Represents `#[rustc_skip_during_method_dispatch]`.
332332
SkipDuringMethodDispatch { array: bool, boxed_slice: bool, span: Span },

compiler/rustc_attr_data_structures/src/encode_cross_crate.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ impl AttributeKind {
2222
Confusables { .. } => Yes,
2323
ConstContinue(..) => No,
2424
ConstStability { .. } => Yes,
25-
ConstStabilityIndirect => No,
25+
ConstStabilityIndirect(..) => No,
2626
Deprecation { .. } => Yes,
2727
DocComment { .. } => Yes,
28-
Dummy => No,
28+
Dummy(..) => No,
2929
ExportName { .. } => Yes,
30-
ExportStable => No,
30+
ExportStable(..) => No,
3131
FfiConst(..) => No,
3232
FfiPure(..) => No,
3333
Ignore { .. } => No,
@@ -49,7 +49,7 @@ impl AttributeKind {
4949
Repr { .. } => No,
5050
RustcLayoutScalarValidRangeEnd(..) => Yes,
5151
RustcLayoutScalarValidRangeStart(..) => Yes,
52-
RustcObjectLifetimeDefault => No,
52+
RustcObjectLifetimeDefault(..) => No,
5353
SkipDuringMethodDispatch { .. } => No,
5454
Stability { .. } => Yes,
5555
StdInternalSymbol(..) => No,

compiler/rustc_attr_parsing/src/attributes/dummy.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ impl<S: Stage> SingleAttributeParser<S> for DummyParser {
1313
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Ignore;
1414
const TEMPLATE: AttributeTemplate = template!(Word); // Anything, really
1515

16-
fn convert(_: &mut AcceptContext<'_, '_, S>, _: &ArgParser<'_>) -> Option<AttributeKind> {
17-
Some(AttributeKind::Dummy)
16+
fn convert(cx: &mut AcceptContext<'_, '_, S>, _: &ArgParser<'_>) -> Option<AttributeKind> {
17+
Some(AttributeKind::Dummy(cx.attr_span))
1818
}
1919
}

compiler/rustc_attr_parsing/src/attributes/link_attrs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ pub(crate) struct ExportStableParser;
6464
impl<S: Stage> NoArgsAttributeParser<S> for ExportStableParser {
6565
const PATH: &[Symbol] = &[sym::export_stable];
6666
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
67-
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::ExportStable;
67+
const CREATE: fn(Span) -> AttributeKind = AttributeKind::ExportStable;
6868
}
6969

7070
pub(crate) struct FfiConstParser;

compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,6 @@ impl<S: Stage> SingleAttributeParser<S> for RustcObjectLifetimeDefaultParser {
7272
return None;
7373
}
7474

75-
Some(AttributeKind::RustcObjectLifetimeDefault)
75+
Some(AttributeKind::RustcObjectLifetimeDefault(cx.attr_span))
7676
}
7777
}

compiler/rustc_attr_parsing/src/attributes/stability.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ pub(crate) struct ConstStabilityIndirectParser;
136136
impl<S: Stage> NoArgsAttributeParser<S> for ConstStabilityIndirectParser {
137137
const PATH: &[Symbol] = &[sym::rustc_const_stable_indirect];
138138
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Ignore;
139-
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::ConstStabilityIndirect;
139+
const CREATE: fn(Span) -> AttributeKind = AttributeKind::ConstStabilityIndirect;
140140
}
141141

142142
#[derive(Default)]

compiler/rustc_attr_parsing/src/attributes/transparency.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ impl<S: Stage> SingleAttributeParser<S> for TransparencyParser {
3939
}
4040
None => None,
4141
}
42-
.map(AttributeKind::MacroTransparency)
42+
.map(|t| AttributeKind::MacroTransparency(t, cx.attr_span))
4343
}
4444
}

compiler/rustc_expand/src/mbe/macro_rules.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ pub fn compile_declarative_macro(
429429
return dummy_syn_ext(guar);
430430
}
431431

432-
let transparency = find_attr!(attrs, AttributeKind::MacroTransparency(x) => *x)
432+
let transparency = find_attr!(attrs, AttributeKind::MacroTransparency(x, _) => *x)
433433
.unwrap_or(Transparency::fallback(macro_rules));
434434

435435
if let Some(guar) = guar {

compiler/rustc_passes/src/check_attr.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
162162
}
163163
Attribute::Parsed(AttributeKind::Repr { .. }) => { /* handled below this loop and elsewhere */
164164
}
165-
Attribute::Parsed(AttributeKind::RustcObjectLifetimeDefault) => {
165+
Attribute::Parsed(AttributeKind::RustcObjectLifetimeDefault(..)) => {
166166
self.check_object_lifetime_default(hir_id);
167167
}
168168
&Attribute::Parsed(AttributeKind::PubTransparent(attr_span)) => {
@@ -204,7 +204,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
204204
AttributeKind::RustcLayoutScalarValidRangeStart(_num, attr_span)
205205
| AttributeKind::RustcLayoutScalarValidRangeEnd(_num, attr_span),
206206
) => self.check_rustc_layout_scalar_valid_range(*attr_span, span, target),
207-
Attribute::Parsed(AttributeKind::ExportStable) => {
207+
Attribute::Parsed(AttributeKind::ExportStable(..)) => {
208208
// handled in `check_export`
209209
}
210210
&Attribute::Parsed(AttributeKind::FfiConst(attr_span)) => {
@@ -215,9 +215,9 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
215215
}
216216
Attribute::Parsed(
217217
AttributeKind::BodyStability { .. }
218-
| AttributeKind::ConstStabilityIndirect
219-
| AttributeKind::MacroTransparency(_)
220-
| AttributeKind::Dummy,
218+
| AttributeKind::ConstStabilityIndirect(..)
219+
| AttributeKind::MacroTransparency(..)
220+
| AttributeKind::Dummy(..),
221221
) => { /* do nothing */ }
222222
Attribute::Parsed(AttributeKind::AsPtr(attr_span)) => {
223223
self.check_applied_to_fn_or_method(hir_id, *attr_span, span, target)

compiler/rustc_passes/src/check_export.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl<'tcx> ExportableItemCollector<'tcx> {
4545
}
4646

4747
fn item_is_exportable(&self, def_id: LocalDefId) -> bool {
48-
let has_attr = find_attr!(self.tcx.get_all_attrs(def_id), AttributeKind::ExportStable);
48+
let has_attr = find_attr!(self.tcx.get_all_attrs(def_id), AttributeKind::ExportStable(..));
4949
if !self.in_exportable_mod && !has_attr {
5050
return false;
5151
}
@@ -81,7 +81,7 @@ impl<'tcx> ExportableItemCollector<'tcx> {
8181
fn walk_item_with_mod(&mut self, item: &'tcx hir::Item<'tcx>) {
8282
let def_id = item.hir_id().owner.def_id;
8383
let old_exportable_mod = self.in_exportable_mod;
84-
if find_attr!(self.tcx.get_all_attrs(def_id), AttributeKind::ExportStable) {
84+
if find_attr!(self.tcx.get_all_attrs(def_id), AttributeKind::ExportStable(..)) {
8585
self.in_exportable_mod = true;
8686
}
8787
let old_seen_exportable_in_mod = std::mem::replace(&mut self.seen_exportable_in_mod, false);

0 commit comments

Comments
 (0)