Skip to content

Commit 84f4508

Browse files
committed
fix tests
1 parent 121abd0 commit 84f4508

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

src/libsyntax/attr.rs

+15-15
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub use self::ReprAttr::*;
1515
pub use self::IntType::*;
1616

1717
use ast;
18-
use ast::{AttrId, Attribute, Name, Ident};
18+
use ast::{AttrId, Attribute, Name, Ident, Path, PathSegment};
1919
use ast::{MetaItem, MetaItemKind, NestedMetaItem, NestedMetaItemKind};
2020
use ast::{Lit, LitKind, Expr, ExprKind, Item, Local, Stmt, StmtKind};
2121
use codemap::{BytePos, Spanned, respan, dummy_spanned};
@@ -212,7 +212,7 @@ impl NestedMetaItem {
212212
}
213213
}
214214

215-
fn name_from_path(path: &ast::Path) -> Name {
215+
fn name_from_path(path: &Path) -> Name {
216216
path.segments.last().expect("empty path in attribute").ident.name
217217
}
218218

@@ -399,15 +399,15 @@ pub fn mk_name_value_item_str(ident: Ident, value: Spanned<Symbol>) -> MetaItem
399399
}
400400

401401
pub fn mk_name_value_item(span: Span, ident: Ident, value: ast::Lit) -> MetaItem {
402-
MetaItem { ident: ast::Path::from_ident(ident), span, node: MetaItemKind::NameValue(value) }
402+
MetaItem { ident: Path::from_ident(ident), span, node: MetaItemKind::NameValue(value) }
403403
}
404404

405405
pub fn mk_list_item(span: Span, ident: Ident, items: Vec<NestedMetaItem>) -> MetaItem {
406-
MetaItem { ident: ast::Path::from_ident(ident), span, node: MetaItemKind::List(items) }
406+
MetaItem { ident: Path::from_ident(ident), span, node: MetaItemKind::List(items) }
407407
}
408408

409409
pub fn mk_word_item(ident: Ident) -> MetaItem {
410-
MetaItem { ident: ast::Path::from_ident(ident), span: ident.span, node: MetaItemKind::Word }
410+
MetaItem { ident: Path::from_ident(ident), span: ident.span, node: MetaItemKind::Word }
411411
}
412412

413413
pub fn mk_nested_word_item(ident: Ident) -> NestedMetaItem {
@@ -466,7 +466,7 @@ pub fn mk_sugared_doc_attr(id: AttrId, text: Symbol, span: Span) -> Attribute {
466466
Attribute {
467467
id,
468468
style,
469-
path: ast::Path::from_ident(Ident::from_str("doc").with_span_pos(span)),
469+
path: Path::from_ident(Ident::from_str("doc").with_span_pos(span)),
470470
tokens: MetaItemKind::NameValue(lit).tokens(span),
471471
is_sugared_doc: true,
472472
span,
@@ -1142,7 +1142,6 @@ impl MetaItem {
11421142
fn tokens(&self) -> TokenStream {
11431143
let mut idents = vec![];
11441144
let mut last_pos = BytePos(0 as u32);
1145-
// FIXME: Share code with `parse_path`.
11461145
for (i, segment) in self.ident.segments.iter().enumerate() {
11471146
let is_first = i == 0;
11481147
if !is_first {
@@ -1162,14 +1161,16 @@ impl MetaItem {
11621161
fn from_tokens<I>(tokens: &mut iter::Peekable<I>) -> Option<MetaItem>
11631162
where I: Iterator<Item = TokenTree>,
11641163
{
1164+
// FIXME: Share code with `parse_path`.
11651165
let ident = match tokens.next() {
11661166
Some(TokenTree::Token(span, Token::Ident(ident, _))) => {
11671167
if let Some(TokenTree::Token(_, Token::ModSep)) = tokens.peek() {
1168+
let mut segments = vec![PathSegment::from_ident(ident.with_span_pos(span))];
11681169
tokens.next();
1169-
let mut segments = vec![];
11701170
loop {
1171-
if let Some(TokenTree::Token(_, Token::Ident(ident, _))) = tokens.next() {
1172-
segments.push(ast::PathSegment::from_ident(ident));
1171+
if let Some(TokenTree::Token(span,
1172+
Token::Ident(ident, _))) = tokens.next() {
1173+
segments.push(PathSegment::from_ident(ident.with_span_pos(span)));
11731174
} else {
11741175
return None;
11751176
}
@@ -1179,15 +1180,14 @@ impl MetaItem {
11791180
break;
11801181
}
11811182
}
1182-
ast::Path { span, segments }
1183+
let span = span.with_hi(segments.last().unwrap().ident.span.hi());
1184+
Path { span, segments }
11831185
} else {
1184-
ast::Path::from_ident(ident)
1186+
Path::from_ident(ident.with_span_pos(span))
11851187
}
11861188
}
11871189
Some(TokenTree::Token(_, Token::Interpolated(ref nt))) => match nt.0 {
1188-
token::Nonterminal::NtIdent(ident, _) => {
1189-
ast::Path::from_ident(ident)
1190-
}
1190+
token::Nonterminal::NtIdent(ident, _) => Path::from_ident(ident),
11911191
token::Nonterminal::NtMeta(ref meta) => return Some(meta.clone()),
11921192
token::Nonterminal::NtPath(ref path) => path.clone(),
11931193
_ => return None,

src/libsyntax/feature_gate.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ declare_features! (
460460

461461
// Access to crate names passed via `--extern` through prelude
462462
(active, extern_prelude, "1.27.0", Some(44660), Some(Edition::Edition2018)),
463-
463+
464464
// Scoped attributes
465465
(active, tool_attributes, "1.25.0", Some(44690), None),
466466
);
@@ -1191,7 +1191,7 @@ impl<'a> Context<'a> {
11911191
}
11921192
} else {
11931193
gate_feature!(self, custom_attribute, attr.span,
1194-
&format!("the attribute `{}` is currently \
1194+
&format!("The attribute `{}` is currently \
11951195
unknown to the compiler and \
11961196
may have meaning \
11971197
added to it in the future",

src/test/compile-fail-fulldeps/auxiliary/macro_crate_test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ fn expand_duplicate(cx: &mut ExtCtxt,
117117
let copy_name = match mi.node {
118118
ast::MetaItemKind::List(ref xs) => {
119119
if let Some(word) = xs[0].word() {
120-
word.ident
120+
word.ident.segments.last().unwrap().ident
121121
} else {
122122
cx.span_err(mi.span, "Expected word");
123123
return;

src/test/run-pass-fulldeps/auxiliary/macro_crate_test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ fn expand_duplicate(cx: &mut ExtCtxt,
112112
let copy_name = match mi.node {
113113
ast::MetaItemKind::List(ref xs) => {
114114
if let Some(word) = xs[0].word() {
115-
word.ident
115+
word.ident.segments.last().unwrap().ident
116116
} else {
117117
cx.span_err(mi.span, "Expected word");
118118
return;

0 commit comments

Comments
 (0)