Skip to content

Commit a8e86f0

Browse files
committed
Fix fallout in rustdoc and tests.
1 parent c9935e4 commit a8e86f0

30 files changed

+120
-130
lines changed

src/librustc/session/config.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -1764,9 +1764,7 @@ mod tests {
17641764
use std::rc::Rc;
17651765
use super::{OutputType, OutputTypes, Externs};
17661766
use rustc_back::PanicStrategy;
1767-
use syntax::{ast, attr};
1768-
use syntax::parse::token::InternedString;
1769-
use syntax::codemap::dummy_spanned;
1767+
use syntax::symbol::Symbol;
17701768

17711769
fn optgroups() -> Vec<OptGroup> {
17721770
super::rustc_optgroups().into_iter()
@@ -1795,9 +1793,7 @@ mod tests {
17951793
let (sessopts, cfg) = build_session_options_and_crate_config(matches);
17961794
let sess = build_session(sessopts, &dep_graph, None, registry, Rc::new(DummyCrateStore));
17971795
let cfg = build_configuration(&sess, cfg);
1798-
assert!(attr::contains(&cfg, &dummy_spanned(ast::MetaItemKind::Word({
1799-
InternedString::new("test")
1800-
}))));
1796+
assert!(cfg.contains(&(Symbol::intern("test"), None)));
18011797
}
18021798

18031799
// When the user supplies --test and --cfg test, don't implicitly add
@@ -1818,7 +1814,7 @@ mod tests {
18181814
let sess = build_session(sessopts, &dep_graph, None, registry,
18191815
Rc::new(DummyCrateStore));
18201816
let cfg = build_configuration(&sess, cfg);
1821-
let mut test_items = cfg.iter().filter(|m| m.name() == "test");
1817+
let mut test_items = cfg.iter().filter(|&&(name, _)| name == "test");
18221818
assert!(test_items.next().is_some());
18231819
assert!(test_items.next().is_none());
18241820
}

src/librustc_driver/driver.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ use syntax::{ast, diagnostics, visit};
5454
use syntax::attr;
5555
use syntax::ext::base::ExtCtxt;
5656
use syntax::parse::{self, PResult};
57-
use syntax::symbol::{self, Symbol};
57+
use syntax::symbol::Symbol;
5858
use syntax::util::node_count::NodeCounter;
5959
use syntax;
6060
use syntax_ext;

src/librustc_driver/test.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ use syntax::codemap::CodeMap;
3434
use errors;
3535
use errors::emitter::Emitter;
3636
use errors::{Level, DiagnosticBuilder};
37-
use syntax::parse::token;
3837
use syntax::feature_gate::UnstableFeatures;
38+
use syntax::symbol::Symbol;
3939

4040
use rustc::hir;
4141

@@ -288,11 +288,11 @@ impl<'a, 'gcx, 'tcx> Env<'a, 'gcx, 'tcx> {
288288

289289
pub fn t_param(&self, index: u32) -> Ty<'tcx> {
290290
let name = format!("T{}", index);
291-
self.infcx.tcx.mk_param(index, token::intern(&name[..]))
291+
self.infcx.tcx.mk_param(index, Symbol::intern(&name[..]))
292292
}
293293

294294
pub fn re_early_bound(&self, index: u32, name: &'static str) -> &'tcx ty::Region {
295-
let name = token::intern(name);
295+
let name = Symbol::intern(name);
296296
self.infcx.tcx.mk_region(ty::ReEarlyBound(ty::EarlyBoundRegion {
297297
index: index,
298298
name: name,

src/librustdoc/clean/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ use syntax::abi::Abi;
2424
use syntax::ast;
2525
use syntax::attr;
2626
use syntax::codemap::Spanned;
27-
use syntax::parse::token::keywords;
2827
use syntax::ptr::P;
2928
use syntax::print::pprust as syntax_pprust;
29+
use syntax::symbol::keywords;
3030
use syntax_pos::{self, DUMMY_SP, Pos};
3131

3232
use rustc_trans::back::link;
@@ -242,7 +242,7 @@ impl Clean<ExternalCrate> for CrateNum {
242242
}
243243
});
244244
ExternalCrate {
245-
name: (&cx.sess().cstore.crate_name(self.0)[..]).to_owned(),
245+
name: cx.sess().cstore.crate_name(self.0).to_string(),
246246
attrs: cx.sess().cstore.item_attrs(root).clean(cx),
247247
primitives: primitives,
248248
}
@@ -2577,7 +2577,7 @@ impl Clean<Vec<Item>> for doctree::Import {
25772577
// #[doc(no_inline)] attribute is present.
25782578
// Don't inline doc(hidden) imports so they can be stripped at a later stage.
25792579
let denied = self.vis != hir::Public || self.attrs.iter().any(|a| {
2580-
&a.name()[..] == "doc" && match a.meta_item_list() {
2580+
a.name() == "doc" && match a.meta_item_list() {
25812581
Some(l) => attr::list_contains_name(l, "no_inline") ||
25822582
attr::list_contains_name(l, "hidden"),
25832583
None => false,

src/libsyntax/codemap.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,7 @@ impl CodeMapper for CodeMap {
871871
#[cfg(test)]
872872
mod tests {
873873
use super::*;
874+
use symbol::keywords;
874875
use std::rc::Rc;
875876

876877
#[test]
@@ -1097,10 +1098,9 @@ mod tests {
10971098
#[test]
10981099
fn t11() {
10991100
// Test span_to_expanded_string works with expansion
1100-
use ast::Name;
11011101
let cm = init_code_map();
11021102
let root = Span { lo: BytePos(0), hi: BytePos(11), expn_id: NO_EXPANSION };
1103-
let format = ExpnFormat::MacroBang(Name(0u32));
1103+
let format = ExpnFormat::MacroBang(keywords::Invalid.name());
11041104
let callee = NameAndSpan { format: format,
11051105
allow_internal_unstable: false,
11061106
span: None };
@@ -1197,11 +1197,9 @@ mod tests {
11971197
fn init_expansion_chain(cm: &CodeMap) -> Span {
11981198
// Creates an expansion chain containing two recursive calls
11991199
// root -> expA -> expA -> expB -> expB -> end
1200-
use ast::Name;
1201-
12021200
let root = Span { lo: BytePos(0), hi: BytePos(11), expn_id: NO_EXPANSION };
12031201

1204-
let format_root = ExpnFormat::MacroBang(Name(0u32));
1202+
let format_root = ExpnFormat::MacroBang(keywords::Invalid.name());
12051203
let callee_root = NameAndSpan { format: format_root,
12061204
allow_internal_unstable: false,
12071205
span: Some(root) };
@@ -1210,7 +1208,7 @@ mod tests {
12101208
let id_a1 = cm.record_expansion(info_a1);
12111209
let span_a1 = Span { lo: BytePos(12), hi: BytePos(23), expn_id: id_a1 };
12121210

1213-
let format_a = ExpnFormat::MacroBang(Name(1u32));
1211+
let format_a = ExpnFormat::MacroBang(keywords::As.name());
12141212
let callee_a = NameAndSpan { format: format_a,
12151213
allow_internal_unstable: false,
12161214
span: Some(span_a1) };
@@ -1223,7 +1221,7 @@ mod tests {
12231221
let id_b1 = cm.record_expansion(info_b1);
12241222
let span_b1 = Span { lo: BytePos(25), hi: BytePos(36), expn_id: id_b1 };
12251223

1226-
let format_b = ExpnFormat::MacroBang(Name(2u32));
1224+
let format_b = ExpnFormat::MacroBang(keywords::Box.name());
12271225
let callee_b = NameAndSpan { format: format_b,
12281226
allow_internal_unstable: false,
12291227
span: None };

src/libsyntax/fold.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1332,9 +1332,8 @@ pub fn noop_fold_vis<T: Folder>(vis: Visibility, folder: &mut T) -> Visibility {
13321332
#[cfg(test)]
13331333
mod tests {
13341334
use std::io;
1335-
use ast;
1335+
use ast::{self, Ident};
13361336
use util::parser_testing::{string_to_crate, matches_codepattern};
1337-
use parse::token;
13381337
use print::pprust;
13391338
use fold;
13401339
use super::*;
@@ -1350,7 +1349,7 @@ mod tests {
13501349

13511350
impl Folder for ToZzIdentFolder {
13521351
fn fold_ident(&mut self, _: ast::Ident) -> ast::Ident {
1353-
token::str_to_ident("zz")
1352+
Ident::from_str("zz")
13541353
}
13551354
fn fold_mac(&mut self, mac: ast::Mac) -> ast::Mac {
13561355
fold::noop_fold_mac(mac, self)

src/libsyntax/parse/lexer/mod.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -1702,6 +1702,7 @@ mod tests {
17021702
use super::*;
17031703

17041704
use ast::Ident;
1705+
use symbol::Symbol;
17051706
use syntax_pos::{BytePos, Span, NO_EXPANSION};
17061707
use codemap::CodeMap;
17071708
use errors;
@@ -1752,7 +1753,7 @@ mod tests {
17521753
// read another token:
17531754
let tok3 = string_reader.next_token();
17541755
let tok4 = TokenAndSpan {
1755-
tok: token::Ident(str_to_ident("main")),
1756+
tok: token::Ident(Ident::from_str("main")),
17561757
sp: Span {
17571758
lo: BytePos(24),
17581759
hi: BytePos(28),
@@ -1774,7 +1775,7 @@ mod tests {
17741775

17751776
// make the identifier by looking up the string in the interner
17761777
fn mk_ident(id: &str) -> token::Token {
1777-
token::Ident(str_to_ident(id))
1778+
token::Ident(Ident::from_str(id))
17781779
}
17791780

17801781
#[test]
@@ -1838,7 +1839,7 @@ mod tests {
18381839
let cm = Rc::new(CodeMap::new());
18391840
let sh = mk_sh(cm.clone());
18401841
assert_eq!(setup(&cm, &sh, "'abc".to_string()).next_token().tok,
1841-
token::Lifetime(token::str_to_ident("'abc")));
1842+
token::Lifetime(Ident::from_str("'abc")));
18421843
}
18431844

18441845
#[test]
@@ -1848,7 +1849,7 @@ mod tests {
18481849
assert_eq!(setup(&cm, &sh, "r###\"\"#a\\b\x00c\"\"###".to_string())
18491850
.next_token()
18501851
.tok,
1851-
token::Literal(token::StrRaw(Symol::intern("\"#a\\b\x00c\""), 3), None));
1852+
token::Literal(token::StrRaw(Symbol::intern("\"#a\\b\x00c\""), 3), None));
18521853
}
18531854

18541855
#[test]

src/libsyntax/parse/mod.rs

+23-28
Original file line numberDiff line numberDiff line change
@@ -597,12 +597,11 @@ mod tests {
597597
use std::rc::Rc;
598598
use syntax_pos::{self, Span, BytePos, Pos, NO_EXPANSION};
599599
use codemap::Spanned;
600-
use ast::{self, PatKind};
600+
use ast::{self, Ident, PatKind};
601601
use abi::Abi;
602602
use attr::first_attr_value_str_by_name;
603603
use parse;
604604
use parse::parser::Parser;
605-
use parse::token::{str_to_ident};
606605
use print::pprust::item_to_string;
607606
use ptr::P;
608607
use tokenstream::{self, TokenTree};
@@ -624,7 +623,7 @@ mod tests {
624623
global: false,
625624
segments: vec![
626625
ast::PathSegment {
627-
identifier: str_to_ident("a"),
626+
identifier: Ident::from_str("a"),
628627
parameters: ast::PathParameters::none(),
629628
}
630629
],
@@ -643,11 +642,11 @@ mod tests {
643642
global: true,
644643
segments: vec![
645644
ast::PathSegment {
646-
identifier: str_to_ident("a"),
645+
identifier: Ident::from_str("a"),
647646
parameters: ast::PathParameters::none(),
648647
},
649648
ast::PathSegment {
650-
identifier: str_to_ident("b"),
649+
identifier: Ident::from_str("b"),
651650
parameters: ast::PathParameters::none(),
652651
}
653652
]
@@ -676,8 +675,8 @@ mod tests {
676675
Some(&TokenTree::Token(_, token::Ident(name_zip))),
677676
Some(&TokenTree::Delimited(_, ref macro_delimed)),
678677
)
679-
if name_macro_rules.name.as_str() == "macro_rules"
680-
&& name_zip.name.as_str() == "zip" => {
678+
if name_macro_rules.name == "macro_rules"
679+
&& name_zip.name == "zip" => {
681680
let tts = &macro_delimed.tts[..];
682681
match (tts.len(), tts.get(0), tts.get(1), tts.get(2)) {
683682
(
@@ -694,8 +693,7 @@ mod tests {
694693
Some(&TokenTree::Token(_, token::Dollar)),
695694
Some(&TokenTree::Token(_, token::Ident(ident))),
696695
)
697-
if first_delimed.delim == token::Paren
698-
&& ident.name.as_str() == "a" => {},
696+
if first_delimed.delim == token::Paren && ident.name == "a" => {},
699697
_ => panic!("value 3: {:?}", **first_delimed),
700698
}
701699
let tts = &second_delimed.tts[..];
@@ -706,7 +704,7 @@ mod tests {
706704
Some(&TokenTree::Token(_, token::Ident(ident))),
707705
)
708706
if second_delimed.delim == token::Paren
709-
&& ident.name.as_str() == "a" => {},
707+
&& ident.name == "a" => {},
710708
_ => panic!("value 4: {:?}", **second_delimed),
711709
}
712710
},
@@ -722,17 +720,17 @@ mod tests {
722720
let tts = string_to_tts("fn a (b : i32) { b; }".to_string());
723721

724722
let expected = vec![
725-
TokenTree::Token(sp(0, 2), token::Ident(str_to_ident("fn"))),
726-
TokenTree::Token(sp(3, 4), token::Ident(str_to_ident("a"))),
723+
TokenTree::Token(sp(0, 2), token::Ident(Ident::from_str("fn"))),
724+
TokenTree::Token(sp(3, 4), token::Ident(Ident::from_str("a"))),
727725
TokenTree::Delimited(
728726
sp(5, 14),
729727
Rc::new(tokenstream::Delimited {
730728
delim: token::DelimToken::Paren,
731729
open_span: sp(5, 6),
732730
tts: vec![
733-
TokenTree::Token(sp(6, 7), token::Ident(str_to_ident("b"))),
731+
TokenTree::Token(sp(6, 7), token::Ident(Ident::from_str("b"))),
734732
TokenTree::Token(sp(8, 9), token::Colon),
735-
TokenTree::Token(sp(10, 13), token::Ident(str_to_ident("i32"))),
733+
TokenTree::Token(sp(10, 13), token::Ident(Ident::from_str("i32"))),
736734
],
737735
close_span: sp(13, 14),
738736
})),
@@ -742,7 +740,7 @@ mod tests {
742740
delim: token::DelimToken::Brace,
743741
open_span: sp(15, 16),
744742
tts: vec![
745-
TokenTree::Token(sp(17, 18), token::Ident(str_to_ident("b"))),
743+
TokenTree::Token(sp(17, 18), token::Ident(Ident::from_str("b"))),
746744
TokenTree::Token(sp(18, 19), token::Semi),
747745
],
748746
close_span: sp(20, 21),
@@ -763,7 +761,7 @@ mod tests {
763761
global: false,
764762
segments: vec![
765763
ast::PathSegment {
766-
identifier: str_to_ident("d"),
764+
identifier: Ident::from_str("d"),
767765
parameters: ast::PathParameters::none(),
768766
}
769767
],
@@ -786,7 +784,7 @@ mod tests {
786784
global:false,
787785
segments: vec![
788786
ast::PathSegment {
789-
identifier: str_to_ident("b"),
787+
identifier: Ident::from_str("b"),
790788
parameters: ast::PathParameters::none(),
791789
}
792790
],
@@ -810,7 +808,7 @@ mod tests {
810808
id: ast::DUMMY_NODE_ID,
811809
node: PatKind::Ident(ast::BindingMode::ByValue(ast::Mutability::Immutable),
812810
Spanned{ span:sp(0, 1),
813-
node: str_to_ident("b")
811+
node: Ident::from_str("b")
814812
},
815813
None),
816814
span: sp(0,1)}));
@@ -822,7 +820,7 @@ mod tests {
822820
// this test depends on the intern order of "fn" and "i32"
823821
assert_eq!(string_to_item("fn a (b : i32) { b; }".to_string()),
824822
Some(
825-
P(ast::Item{ident:str_to_ident("a"),
823+
P(ast::Item{ident:Ident::from_str("a"),
826824
attrs:Vec::new(),
827825
id: ast::DUMMY_NODE_ID,
828826
node: ast::ItemKind::Fn(P(ast::FnDecl {
@@ -833,8 +831,7 @@ mod tests {
833831
global:false,
834832
segments: vec![
835833
ast::PathSegment {
836-
identifier:
837-
str_to_ident("i32"),
834+
identifier: Ident::from_str("i32"),
838835
parameters: ast::PathParameters::none(),
839836
}
840837
],
@@ -847,7 +844,7 @@ mod tests {
847844
ast::BindingMode::ByValue(ast::Mutability::Immutable),
848845
Spanned{
849846
span: sp(6,7),
850-
node: str_to_ident("b")},
847+
node: Ident::from_str("b")},
851848
None
852849
),
853850
span: sp(6,7)
@@ -882,9 +879,7 @@ mod tests {
882879
global:false,
883880
segments: vec![
884881
ast::PathSegment {
885-
identifier:
886-
str_to_ident(
887-
"b"),
882+
identifier: Ident::from_str("b"),
888883
parameters:
889884
ast::PathParameters::none(),
890885
}
@@ -996,20 +991,20 @@ mod tests {
996991
let item = parse_item_from_source_str(name.clone(), source, &sess)
997992
.unwrap().unwrap();
998993
let doc = first_attr_value_str_by_name(&item.attrs, "doc").unwrap();
999-
assert_eq!(&doc[..], "/// doc comment");
994+
assert_eq!(doc, "/// doc comment");
1000995

1001996
let source = "/// doc comment\r\n/// line 2\r\nfn foo() {}".to_string();
1002997
let item = parse_item_from_source_str(name.clone(), source, &sess)
1003998
.unwrap().unwrap();
1004-
let docs = item.attrs.iter().filter(|a| &*a.name() == "doc")
999+
let docs = item.attrs.iter().filter(|a| a.name() == "doc")
10051000
.map(|a| a.value_str().unwrap().to_string()).collect::<Vec<_>>();
10061001
let b: &[_] = &["/// doc comment".to_string(), "/// line 2".to_string()];
10071002
assert_eq!(&docs[..], b);
10081003

10091004
let source = "/** doc comment\r\n * with CRLF */\r\nfn foo() {}".to_string();
10101005
let item = parse_item_from_source_str(name, source, &sess).unwrap().unwrap();
10111006
let doc = first_attr_value_str_by_name(&item.attrs, "doc").unwrap();
1012-
assert_eq!(&doc[..], "/** doc comment\n * with CRLF */");
1007+
assert_eq!(doc, "/** doc comment\n * with CRLF */");
10131008
}
10141009

10151010
#[test]

0 commit comments

Comments
 (0)