Skip to content

Commit 0cf9613

Browse files
committed
Refactor away NestedMetaItemKind
Remove methods `Attribute::span` and `MetaItem::span` duplicating public fields
1 parent 63116d3 commit 0cf9613

File tree

26 files changed

+126
-145
lines changed

26 files changed

+126
-145
lines changed

src/librustc/hir/check_attr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ impl<'a, 'tcx> CheckAttrVisitor<'a, 'tcx> {
233233
_ => continue,
234234
};
235235
self.emit_repr_error(
236-
hint.span,
236+
hint.span(),
237237
item.span,
238238
&format!("attribute should be applied to {}", allowed_targets),
239239
&format!("not {} {}", article, allowed_targets),
@@ -242,7 +242,7 @@ impl<'a, 'tcx> CheckAttrVisitor<'a, 'tcx> {
242242

243243
// Just point at all repr hints if there are any incompatibilities.
244244
// This is not ideal, but tracking precisely which ones are at fault is a huge hassle.
245-
let hint_spans = hints.iter().map(|hint| hint.span);
245+
let hint_spans = hints.iter().map(|hint| hint.span());
246246

247247
// Error on repr(transparent, <anything else>).
248248
if is_transparent && hints.len() > 1 {

src/librustc/ich/impls_syntax.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -360,9 +360,7 @@ fn hash_token<'a, 'gcx, W: StableHasherResult>(
360360
}
361361
}
362362

363-
impl_stable_hash_for_spanned!(::syntax::ast::NestedMetaItemKind);
364-
365-
impl_stable_hash_for!(enum ::syntax::ast::NestedMetaItemKind {
363+
impl_stable_hash_for!(enum ::syntax::ast::NestedMetaItem {
366364
MetaItem(meta_item),
367365
Literal(lit)
368366
});

src/librustc/lint/levels.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ impl<'a> LintLevelsBuilder<'a> {
258258
let meta_item = match li.meta_item() {
259259
Some(meta_item) if meta_item.is_word() => meta_item,
260260
_ => {
261-
let mut err = bad_attr(li.span);
261+
let mut err = bad_attr(li.span());
262262
if let Some(item) = li.meta_item() {
263263
if let ast::MetaItemKind::NameValue(_) = item.node {
264264
if item.path == "reason" {
@@ -290,7 +290,7 @@ impl<'a> LintLevelsBuilder<'a> {
290290
let name = meta_item.path.segments.last().expect("empty lint name").ident.name;
291291
match store.check_lint_name(&name.as_str(), tool_name) {
292292
CheckLintNameResult::Ok(ids) => {
293-
let src = LintSource::Node(name, li.span, reason);
293+
let src = LintSource::Node(name, li.span(), reason);
294294
for id in ids {
295295
specs.insert(*id, (level, src));
296296
}
@@ -301,7 +301,7 @@ impl<'a> LintLevelsBuilder<'a> {
301301
Ok(ids) => {
302302
let complete_name = &format!("{}::{}", tool_name.unwrap(), name);
303303
let src = LintSource::Node(
304-
Symbol::intern(complete_name), li.span, reason
304+
Symbol::intern(complete_name), li.span(), reason
305305
);
306306
for id in ids {
307307
specs.insert(*id, (level, src));
@@ -323,18 +323,18 @@ impl<'a> LintLevelsBuilder<'a> {
323323
lint,
324324
lvl,
325325
src,
326-
Some(li.span.into()),
326+
Some(li.span().into()),
327327
&msg,
328328
);
329329
err.span_suggestion(
330-
li.span,
330+
li.span(),
331331
"change it to",
332332
new_lint_name.to_string(),
333333
Applicability::MachineApplicable,
334334
).emit();
335335

336336
let src = LintSource::Node(
337-
Symbol::intern(&new_lint_name), li.span, reason
337+
Symbol::intern(&new_lint_name), li.span(), reason
338338
);
339339
for id in ids {
340340
specs.insert(*id, (level, src));
@@ -361,11 +361,11 @@ impl<'a> LintLevelsBuilder<'a> {
361361
lint,
362362
level,
363363
src,
364-
Some(li.span.into()),
364+
Some(li.span().into()),
365365
&msg);
366366
if let Some(new_name) = renamed {
367367
err.span_suggestion(
368-
li.span,
368+
li.span(),
369369
"use the new name",
370370
new_name,
371371
Applicability::MachineApplicable
@@ -384,12 +384,12 @@ impl<'a> LintLevelsBuilder<'a> {
384384
lint,
385385
level,
386386
src,
387-
Some(li.span.into()),
387+
Some(li.span().into()),
388388
&msg);
389389

390390
if let Some(suggestion) = suggestion {
391391
db.span_suggestion(
392-
li.span,
392+
li.span(),
393393
"did you mean",
394394
suggestion.to_string(),
395395
Applicability::MachineApplicable,

src/librustc/traits/on_unimplemented.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ impl<'a, 'gcx, 'tcx> OnUnimplementedDirective {
107107
{
108108
if let Some(items) = item.meta_item_list() {
109109
if let Ok(subcommand) =
110-
Self::parse(tcx, trait_def_id, &items, item.span, false)
110+
Self::parse(tcx, trait_def_id, &items, item.span(), false)
111111
{
112112
subcommands.push(subcommand);
113113
} else {
@@ -118,7 +118,7 @@ impl<'a, 'gcx, 'tcx> OnUnimplementedDirective {
118118
}
119119

120120
// nothing found
121-
parse_error(tcx, item.span,
121+
parse_error(tcx, item.span(),
122122
"this attribute must have a valid value",
123123
"expected value here",
124124
Some(r#"eg `#[rustc_on_unimplemented(message="foo")]`"#));

src/librustc_incremental/assert_dep_graph.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ impl<'a, 'tcx> IfThisChanged<'a, 'tcx> {
104104
value = Some(ident.name),
105105
_ =>
106106
// FIXME better-encapsulate meta_item (don't directly access `node`)
107-
span_bug!(list_item.span(), "unexpected meta-item {:?}", list_item.node),
107+
span_bug!(list_item.span(), "unexpected meta-item {:?}", list_item),
108108
}
109109
}
110110
value

src/librustc_incremental/assert_module_sources.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ impl<'a, 'tcx> AssertModuleSource<'a, 'tcx> {
153153
return value;
154154
} else {
155155
self.tcx.sess.span_fatal(
156-
item.span,
156+
item.span(),
157157
&format!("associated value expected for `{}`", name));
158158
}
159159
}

src/librustc_incremental/persist/dirty_clean.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -430,13 +430,13 @@ impl<'a, 'tcx> DirtyCleanVisitor<'a, 'tcx> {
430430
if DepNode::has_label_string(label) {
431431
if out.contains(label) {
432432
self.tcx.sess.span_fatal(
433-
item.span,
433+
item.span(),
434434
&format!("dep-node label `{}` is repeated", label));
435435
}
436436
out.insert(label.to_string());
437437
} else {
438438
self.tcx.sess.span_fatal(
439-
item.span,
439+
item.span(),
440440
&format!("dep-node label `{}` not recognized", label));
441441
}
442442
}
@@ -582,7 +582,7 @@ fn expect_associated_value(tcx: TyCtxt<'_, '_, '_>, item: &NestedMetaItem) -> as
582582
"expected an associated value".to_string()
583583
};
584584

585-
tcx.sess.span_fatal(item.span, &msg);
585+
tcx.sess.span_fatal(item.span(), &msg);
586586
}
587587
}
588588

src/librustc_metadata/native_libs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ impl<'a, 'tcx> ItemLikeVisitor<'tcx> for Collector<'a, 'tcx> {
7676
k => {
7777
struct_span_err!(self.tcx.sess, m.span, E0458,
7878
"unknown kind: `{}`", k)
79-
.span_label(item.span, "unknown kind").emit();
79+
.span_label(item.span(), "unknown kind").emit();
8080
cstore::NativeUnknown
8181
}
8282
};

src/librustc_passes/layout_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl<'a, 'tcx> VarianceTest<'a, 'tcx> {
8686

8787
_ => {
8888
self.tcx.sess.span_err(
89-
meta_item.span,
89+
meta_item.span(),
9090
&format!("unrecognized field name `{}`", name),
9191
);
9292
}

src/librustc_plugin/load.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ pub fn load_plugins(sess: &Session,
5959
match plugin.ident_str() {
6060
Some(name) if !plugin.is_value_str() => {
6161
let args = plugin.meta_item_list().map(ToOwned::to_owned);
62-
loader.load_plugin(plugin.span, name, args.unwrap_or_default());
62+
loader.load_plugin(plugin.span(), name, args.unwrap_or_default());
6363
},
6464
_ => call_malformed_plugin_attribute(sess, attr.span),
6565
}

0 commit comments

Comments
 (0)