Skip to content

Commit 3a30bad

Browse files
committed
Use Ident instead of Name in MetaItem
1 parent 303298b commit 3a30bad

File tree

27 files changed

+138
-164
lines changed

27 files changed

+138
-164
lines changed

src/librustc/hir/lowering.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3503,12 +3503,10 @@ impl<'a> LoweringContext<'a> {
35033503
let attr = {
35043504
// allow(unreachable_code)
35053505
let allow = {
3506-
let allow_ident = self.str_to_ident("allow");
3507-
let uc_ident = self.str_to_ident("unreachable_code");
3508-
let uc_meta_item = attr::mk_spanned_word_item(e.span, uc_ident);
3509-
let uc_nested = NestedMetaItemKind::MetaItem(uc_meta_item);
3510-
let uc_spanned = respan(e.span, uc_nested);
3511-
attr::mk_spanned_list_item(e.span, allow_ident, vec![uc_spanned])
3506+
let allow_ident = Ident::from_str("allow").with_span_pos(e.span);
3507+
let uc_ident = Ident::from_str("unreachable_code").with_span_pos(e.span);
3508+
let uc_nested = attr::mk_nested_word_item(uc_ident);
3509+
attr::mk_list_item(e.span, allow_ident, vec![uc_nested])
35123510
};
35133511
attr::mk_spanned_attr_outer(e.span, attr::mk_attr_id(), allow)
35143512
};

src/librustc/ich/impls_syntax.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ impl_stable_hash_for!(enum ::syntax::ast::NestedMetaItemKind {
341341
});
342342

343343
impl_stable_hash_for!(struct ::syntax::ast::MetaItem {
344-
name,
344+
ident,
345345
node,
346346
span
347347
});

src/librustc/lint/levels.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ impl<'a> LintLevelsBuilder<'a> {
221221
continue
222222
}
223223
};
224-
let name = word.name();
224+
let name = word.ident.name;
225225
match store.check_lint_name(&name.as_str()) {
226226
CheckLintNameResult::Ok(ids) => {
227227
let src = LintSource::Node(name, li.span);

src/librustc/session/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1683,12 +1683,12 @@ pub fn parse_cfgspecs(cfgspecs: Vec<String>) -> ast::CrateConfig {
16831683
} else if meta_item.is_meta_item_list() {
16841684
let msg = format!(
16851685
"invalid predicate in --cfg command line argument: `{}`",
1686-
meta_item.name()
1686+
meta_item.ident
16871687
);
16881688
early_error(ErrorOutputType::default(), &msg)
16891689
}
16901690

1691-
(meta_item.name(), meta_item.value_str())
1691+
(meta_item.ident.name, meta_item.value_str())
16921692
})
16931693
.collect::<ast::CrateConfig>()
16941694
}

src/librustc/traits/on_unimplemented.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ impl<'a, 'gcx, 'tcx> OnUnimplementedDirective {
190190
for command in self.subcommands.iter().chain(Some(self)).rev() {
191191
if let Some(ref condition) = command.condition {
192192
if !attr::eval_condition(condition, &tcx.sess.parse_sess, &mut |c| {
193-
options.contains(&(c.name().as_str().to_string(),
193+
options.contains(&(c.ident.name.as_str().to_string(),
194194
match c.value_str().map(|s| s.as_str().to_string()) {
195195
Some(s) => Some(s),
196196
None => None

src/librustc_driver/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1045,7 +1045,7 @@ impl RustcDefaultCalls {
10451045
let mut cfgs = Vec::new();
10461046
for &(name, ref value) in sess.parse_sess.config.iter() {
10471047
let gated_cfg = GatedCfg::gate(&ast::MetaItem {
1048-
name,
1048+
ident: ast::Ident::with_empty_ctxt(name),
10491049
node: ast::MetaItemKind::Word,
10501050
span: DUMMY_SP,
10511051
});

src/librustc_incremental/assert_dep_graph.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ impl<'a, 'tcx> IfThisChanged<'a, 'tcx> {
110110
for list_item in attr.meta_item_list().unwrap_or_default() {
111111
match list_item.word() {
112112
Some(word) if value.is_none() =>
113-
value = Some(word.name().clone()),
113+
value = Some(word.ident.name),
114114
_ =>
115115
// FIXME better-encapsulate meta_item (don't directly access `node`)
116116
span_bug!(list_item.span(), "unexpected meta-item {:?}", list_item.node),

src/librustc_mir/dataflow/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ impl<'a, 'gcx: 'tcx, 'tcx: 'a, BD> DataflowAnalysis<'a, 'tcx, BD> where BD: BitD
152152
} else {
153153
sess.span_err(
154154
item.span,
155-
&format!("{} attribute requires a path", item.name()));
155+
&format!("{} attribute requires a path", item.ident));
156156
return None;
157157
}
158158
}

src/librustc_resolve/build_reduced_graph.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ impl<'a> Resolver<'a> {
717717
match attr.meta_item_list() {
718718
Some(names) => for attr in names {
719719
if let Some(word) = attr.word() {
720-
imports.imports.push((word.name(), attr.span()));
720+
imports.imports.push((word.ident.name, attr.span()));
721721
} else {
722722
span_err!(self.session, attr.span(), E0466, "bad macro import");
723723
}
@@ -731,7 +731,7 @@ impl<'a> Resolver<'a> {
731731
if let Some(names) = attr.meta_item_list() {
732732
for attr in names {
733733
if let Some(word) = attr.word() {
734-
imports.reexports.push((word.name(), attr.span()));
734+
imports.reexports.push((word.ident.name, attr.span()));
735735
} else {
736736
bad_macro_reexport(self, attr.span());
737737
}

src/librustdoc/clean/auto_trait.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> {
171171
let mut segments = path.segments.into_vec();
172172
let last = segments.pop().unwrap();
173173

174-
let real_name = name.as_ref().map(|n| Symbol::from(n.as_str()));
174+
let real_name = name.map(|name| Symbol::intern(&name));
175175

176176
segments.push(hir::PathSegment::new(
177177
real_name.unwrap_or(last.name),

0 commit comments

Comments
 (0)