Skip to content

Commit 36c8f6b

Browse files
committedNov 21, 2016
Cleanup InternedString.
1 parent e85a0d7 commit 36c8f6b

File tree

26 files changed

+63
-128
lines changed

26 files changed

+63
-128
lines changed
 

‎src/librustc/hir/map/definitions.rs

+13-32
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ impl DefPathData {
343343

344344
pub fn as_interned_str(&self) -> InternedString {
345345
use self::DefPathData::*;
346-
match *self {
346+
let s = match *self {
347347
TypeNs(ref name) |
348348
ValueNs(ref name) |
349349
Module(ref name) |
@@ -353,43 +353,24 @@ impl DefPathData {
353353
EnumVariant(ref name) |
354354
Binding(ref name) |
355355
Field(ref name) => {
356-
name.clone()
357-
}
358-
359-
Impl => {
360-
InternedString::new("{{impl}}")
356+
return name.clone();
361357
}
362358

363359
// note that this does not show up in user printouts
364-
CrateRoot => {
365-
InternedString::new("{{root}}")
366-
}
360+
CrateRoot => "{{root}}",
367361

368362
// note that this does not show up in user printouts
369-
InlinedRoot(_) => {
370-
InternedString::new("{{inlined-root}}")
371-
}
372-
373-
Misc => {
374-
InternedString::new("{{?}}")
375-
}
376-
377-
ClosureExpr => {
378-
InternedString::new("{{closure}}")
379-
}
380-
381-
StructCtor => {
382-
InternedString::new("{{constructor}}")
383-
}
384-
385-
Initializer => {
386-
InternedString::new("{{initializer}}")
387-
}
363+
InlinedRoot(_) => "{{inlined-root}}",
364+
365+
Impl => "{{impl}}",
366+
Misc => "{{?}}",
367+
ClosureExpr => "{{closure}}",
368+
StructCtor => "{{constructor}}",
369+
Initializer => "{{initializer}}",
370+
ImplTrait => "{{impl-Trait}}",
371+
};
388372

389-
ImplTrait => {
390-
InternedString::new("{{impl-Trait}}")
391-
}
392-
}
373+
Symbol::intern(s).as_str()
393374
}
394375

395376
pub fn to_string(&self) -> String {

‎src/librustc/hir/map/mod.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ impl<'a, 'ast> NodesMatchingSuffix<'a, 'ast> {
765765
None => return false,
766766
Some((node_id, name)) => (node_id, name),
767767
};
768-
if &part[..] != mod_name.as_str() {
768+
if mod_name != &**part {
769769
return false;
770770
}
771771
cursor = self.map.get_parent(mod_id);
@@ -803,8 +803,7 @@ impl<'a, 'ast> NodesMatchingSuffix<'a, 'ast> {
803803
// We are looking at some node `n` with a given name and parent
804804
// id; do their names match what I am seeking?
805805
fn matches_names(&self, parent_of_n: NodeId, name: Name) -> bool {
806-
name.as_str() == &self.item_name[..] &&
807-
self.suffix_matches(parent_of_n)
806+
name == &**self.item_name && self.suffix_matches(parent_of_n)
808807
}
809808
}
810809

‎src/librustc/middle/dead.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -498,8 +498,7 @@ impl<'a, 'tcx> DeadVisitor<'a, 'tcx> {
498498
span: syntax_pos::Span,
499499
name: ast::Name,
500500
node_type: &str) {
501-
let name = name.as_str();
502-
if !name.starts_with("_") {
501+
if !name.as_str().starts_with("_") {
503502
self.tcx
504503
.sess
505504
.add_lint(lint::builtin::DEAD_CODE,

‎src/librustc/middle/entry.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ fn entry_point_type(item: &Item, at_root: bool) -> EntryPointType {
9292
EntryPointType::Start
9393
} else if attr::contains_name(&item.attrs, "main") {
9494
EntryPointType::MainAttr
95-
} else if item.name.as_str() == "main" {
95+
} else if item.name == "main" {
9696
if at_root {
9797
// This is a top-level function so can be 'main'
9898
EntryPointType::MainNamed

‎src/librustc/middle/intrinsicck.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl<'a, 'gcx, 'tcx> ExprVisitor<'a, 'gcx, 'tcx> {
5555
ty::TyFnDef(.., ref bfty) => bfty.abi == RustIntrinsic,
5656
_ => return false
5757
};
58-
intrinsic && self.infcx.tcx.item_name(def_id).as_str() == "transmute"
58+
intrinsic && self.infcx.tcx.item_name(def_id) == "transmute"
5959
}
6060

6161
fn check_transmute(&self, span: Span, from: Ty<'gcx>, to: Ty<'gcx>, id: ast::NodeId) {

‎src/librustc/middle/stability.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> {
455455
// When compiling with --test we don't enforce stability on the
456456
// compiler-generated test module, demarcated with `DUMMY_SP` plus the
457457
// name `__test`
458-
if item.span == DUMMY_SP && item.name.as_str() == "__test" { return }
458+
if item.span == DUMMY_SP && item.name == "__test" { return }
459459

460460
check_item(self.tcx, item, true,
461461
&mut |id, sp, stab, depr| self.check(id, sp, stab, depr));

‎src/librustc_borrowck/borrowck/mir/dataflow/sanity_check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ fn is_rustc_peek<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
169169
{
170170
let name = tcx.item_name(def_id);
171171
if abi == Abi::RustIntrinsic || abi == Abi::PlatformIntrinsic {
172-
if name.as_str() == "rustc_peek" {
172+
if name == "rustc_peek" {
173173
return Some((args, source_info.span));
174174
}
175175
}

‎src/librustc_lint/bad_style.rs

+8-17
Original file line numberDiff line numberDiff line change
@@ -81,19 +81,12 @@ impl NonCamelCaseTypes {
8181
.concat()
8282
}
8383

84-
let s = name.as_str();
85-
8684
if !is_camel_case(name) {
87-
let c = to_camel_case(&s);
85+
let c = to_camel_case(&name.as_str());
8886
let m = if c.is_empty() {
89-
format!("{} `{}` should have a camel case name such as `CamelCase`",
90-
sort,
91-
s)
87+
format!("{} `{}` should have a camel case name such as `CamelCase`", sort, name)
9288
} else {
93-
format!("{} `{}` should have a camel case name such as `{}`",
94-
sort,
95-
s,
96-
c)
89+
format!("{} `{}` should have a camel case name such as `{}`", sort, name, c)
9790
};
9891
cx.span_lint(NON_CAMEL_CASE_TYPES, span, &m[..]);
9992
}
@@ -326,21 +319,19 @@ pub struct NonUpperCaseGlobals;
326319

327320
impl NonUpperCaseGlobals {
328321
fn check_upper_case(cx: &LateContext, sort: &str, name: ast::Name, span: Span) {
329-
let s = name.as_str();
330-
331-
if s.chars().any(|c| c.is_lowercase()) {
332-
let uc = NonSnakeCase::to_snake_case(&s).to_uppercase();
333-
if uc != &s[..] {
322+
if name.as_str().chars().any(|c| c.is_lowercase()) {
323+
let uc = NonSnakeCase::to_snake_case(&name.as_str()).to_uppercase();
324+
if name != &*uc {
334325
cx.span_lint(NON_UPPER_CASE_GLOBALS,
335326
span,
336327
&format!("{} `{}` should have an upper case name such as `{}`",
337328
sort,
338-
s,
329+
name,
339330
uc));
340331
} else {
341332
cx.span_lint(NON_UPPER_CASE_GLOBALS,
342333
span,
343-
&format!("{} `{}` should have an upper case name", sort, s));
334+
&format!("{} `{}` should have an upper case name", sort, name));
344335
}
345336
}
346337
}

‎src/librustc_lint/builtin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1229,7 +1229,7 @@ impl LateLintPass for MutableTransmutes {
12291229
ty::TyFnDef(.., ref bfty) if bfty.abi == RustIntrinsic => (),
12301230
_ => return false,
12311231
}
1232-
cx.tcx.item_name(def_id).as_str() == "transmute"
1232+
cx.tcx.item_name(def_id) == "transmute"
12331233
}
12341234
}
12351235
}

‎src/librustc_passes/ast_validation.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl<'a> AstValidator<'a> {
4040
if label.name == keywords::StaticLifetime.name() {
4141
self.err_handler().span_err(span, &format!("invalid label name `{}`", label.name));
4242
}
43-
if label.name.as_str() == "'_" {
43+
if label.name == "'_" {
4444
self.session.add_lint(lint::builtin::LIFETIME_UNDERSCORE,
4545
id,
4646
span,
@@ -90,7 +90,7 @@ impl<'a> AstValidator<'a> {
9090

9191
impl<'a> Visitor for AstValidator<'a> {
9292
fn visit_lifetime(&mut self, lt: &Lifetime) {
93-
if lt.name.as_str() == "'_" {
93+
if lt.name == "'_" {
9494
self.session.add_lint(lint::builtin::LIFETIME_UNDERSCORE,
9595
lt.id,
9696
lt.span,

‎src/librustc_plugin/registry.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl<'a> Registry<'a> {
101101
///
102102
/// This is the most general hook into `libsyntax`'s expansion behavior.
103103
pub fn register_syntax_extension(&mut self, name: ast::Name, extension: SyntaxExtension) {
104-
if name.as_str() == "macro_rules" {
104+
if name == "macro_rules" {
105105
panic!("user-defined macros may not be named `macro_rules`");
106106
}
107107
self.syntax_exts.push((name, match extension {

‎src/librustc_resolve/build_reduced_graph.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ impl<'b> Resolver<'b> {
138138
match view_path.node {
139139
ViewPathSimple(binding, ref full_path) => {
140140
let mut source = full_path.segments.last().unwrap().identifier;
141-
let source_name = source.name.as_str();
141+
let source_name = source.name;
142142
if source_name == "mod" || source_name == "self" {
143143
resolve_error(self,
144144
view_path.span,

‎src/librustc_resolve/lib.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -1462,7 +1462,6 @@ impl<'a> Resolver<'a> {
14621462
let name = module_path[index].name;
14631463
match self.resolve_name_in_module(search_module, name, TypeNS, false, false, span) {
14641464
Failed(_) => {
1465-
let segment_name = name.as_str();
14661465
let module_name = module_to_string(search_module);
14671466
let msg = if "???" == &module_name {
14681467
let current_module = self.current_module;
@@ -1480,10 +1479,10 @@ impl<'a> Resolver<'a> {
14801479

14811480
format!("Did you mean `{}{}`?", prefix, path_str)
14821481
}
1483-
None => format!("Maybe a missing `extern crate {};`?", segment_name),
1482+
None => format!("Maybe a missing `extern crate {};`?", name),
14841483
}
14851484
} else {
1486-
format!("Could not find `{}` in `{}`", segment_name, module_name)
1485+
format!("Could not find `{}` in `{}`", name, module_name)
14871486
};
14881487

14891488
return Failed(span.map(|span| (span, msg)));
@@ -1651,7 +1650,7 @@ impl<'a> Resolver<'a> {
16511650
/// grammar: (SELF MOD_SEP ) ? (SUPER MOD_SEP) *
16521651
fn resolve_module_prefix(&mut self, module_path: &[Ident], span: Option<Span>)
16531652
-> ResolveResult<ModulePrefixResult<'a>> {
1654-
if &*module_path[0].name.as_str() == "$crate" {
1653+
if module_path[0].name == "$crate" {
16551654
return Success(PrefixFound(self.resolve_crate_var(module_path[0].ctxt), 1));
16561655
}
16571656

@@ -1667,7 +1666,7 @@ impl<'a> Resolver<'a> {
16671666
self.module_map[&self.current_module.normal_ancestor_id.unwrap()];
16681667

16691668
// Now loop through all the `super`s we find.
1670-
while i < module_path.len() && "super" == module_path[i].name.as_str() {
1669+
while i < module_path.len() && module_path[i].name == "super" {
16711670
debug!("(resolving module prefix) resolving `super` at {}",
16721671
module_to_string(&containing_module));
16731672
if let Some(parent) = containing_module.parent {
@@ -2635,7 +2634,7 @@ impl<'a> Resolver<'a> {
26352634
let qualified_binding = self.resolve_module_relative_path(span, segments, namespace);
26362635
match (qualified_binding, unqualified_def) {
26372636
(Ok(binding), Some(ref ud)) if binding.def() == ud.def &&
2638-
segments[0].identifier.name.as_str() != "$crate" => {
2637+
segments[0].identifier.name != "$crate" => {
26392638
self.session
26402639
.add_lint(lint::builtin::UNUSED_QUALIFICATIONS,
26412640
id,
@@ -2881,7 +2880,7 @@ impl<'a> Resolver<'a> {
28812880
}
28822881

28832882
fn find_best_match(&mut self, name: &str) -> SuggestionType {
2884-
if let Some(macro_name) = self.macro_names.iter().find(|n| n.as_str() == name) {
2883+
if let Some(macro_name) = self.macro_names.iter().find(|&n| n == &name) {
28852884
return SuggestionType::Macro(format!("{}!", macro_name));
28862885
}
28872886

@@ -3000,8 +2999,7 @@ impl<'a> Resolver<'a> {
30002999
false // Stop advancing
30013000
});
30023001

3003-
if method_scope &&
3004-
&path_name[..] == keywords::SelfValue.name().as_str() {
3002+
if method_scope && keywords::SelfValue.name() == &*path_name {
30053003
resolve_error(self,
30063004
expr.span,
30073005
ResolutionError::SelfNotAvailableInStaticMethod);

‎src/librustc_resolve/macros.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ impl<'a> base::Resolver for Resolver<'a> {
115115
impl<'a, 'b> Folder for EliminateCrateVar<'a, 'b> {
116116
fn fold_path(&mut self, mut path: ast::Path) -> ast::Path {
117117
let ident = path.segments[0].identifier;
118-
if &ident.name.as_str() == "$crate" {
118+
if ident.name == "$crate" {
119119
path.global = true;
120120
let module = self.0.resolve_crate_var(ident.ctxt);
121121
if module.is_local() {
@@ -151,7 +151,7 @@ impl<'a> base::Resolver for Resolver<'a> {
151151
}
152152

153153
fn add_macro(&mut self, scope: Mark, mut def: ast::MacroDef, export: bool) {
154-
if &def.ident.name.as_str() == "macro_rules" {
154+
if def.ident.name == "macro_rules" {
155155
self.session.span_err(def.span, "user-defined macros may not be named `macro_rules`");
156156
}
157157

‎src/librustc_trans/collector.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
663663
-> bool {
664664
(bare_fn_ty.abi == Abi::RustIntrinsic ||
665665
bare_fn_ty.abi == Abi::PlatformIntrinsic) &&
666-
tcx.item_name(def_id).as_str() == "drop_in_place"
666+
tcx.item_name(def_id) == "drop_in_place"
667667
}
668668
}
669669
}

‎src/librustc_trans/intrinsic.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
107107
let sig = tcx.erase_late_bound_regions_and_normalize(&fty.sig);
108108
let arg_tys = sig.inputs;
109109
let ret_ty = sig.output;
110-
let name = tcx.item_name(def_id).as_str();
110+
let name = &*tcx.item_name(def_id).as_str();
111111

112112
let span = match call_debug_location {
113113
DebugLoc::ScopeAt(_, span) => span,
@@ -123,15 +123,15 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
123123
Call(bcx, llfn, &[], call_debug_location);
124124
Unreachable(bcx);
125125
return Result::new(bcx, C_undef(Type::nil(ccx).ptr_to()));
126-
} else if &name[..] == "unreachable" {
126+
} else if name == "unreachable" {
127127
Unreachable(bcx);
128128
return Result::new(bcx, C_nil(ccx));
129129
}
130130

131131
let llret_ty = type_of::type_of(ccx, ret_ty);
132132

133-
let simple = get_simple_intrinsic(ccx, &name);
134-
let llval = match (simple, &name[..]) {
133+
let simple = get_simple_intrinsic(ccx, name);
134+
let llval = match (simple, name) {
135135
(Some(llfn), _) => {
136136
Call(bcx, llfn, &llargs, call_debug_location)
137137
}
@@ -340,7 +340,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
340340
let sty = &arg_tys[0].sty;
341341
match int_type_width_signed(sty, ccx) {
342342
Some((width, signed)) =>
343-
match &*name {
343+
match name {
344344
"ctlz" => count_zeros_intrinsic(bcx, &format!("llvm.ctlz.i{}", width),
345345
llargs[0], call_debug_location),
346346
"cttz" => count_zeros_intrinsic(bcx, &format!("llvm.cttz.i{}", width),
@@ -394,7 +394,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
394394
let sty = &arg_tys[0].sty;
395395
match float_type_width(sty) {
396396
Some(_width) =>
397-
match &*name {
397+
match name {
398398
"fadd_fast" => FAddFast(bcx, llargs[0], llargs[1], call_debug_location),
399399
"fsub_fast" => FSubFast(bcx, llargs[0], llargs[1], call_debug_location),
400400
"fmul_fast" => FMulFast(bcx, llargs[0], llargs[1], call_debug_location),

‎src/librustc_trans/partitioning.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ fn place_root_translation_items<'a, 'tcx, I>(scx: &SharedCrateContext<'a, 'tcx>,
320320

321321
let codegen_unit_name = match characteristic_def_id {
322322
Some(def_id) => compute_codegen_unit_name(tcx, def_id, is_volatile),
323-
None => InternedString::new(FALLBACK_CODEGEN_UNIT),
323+
None => Symbol::intern(FALLBACK_CODEGEN_UNIT).as_str(),
324324
};
325325

326326
let make_codegen_unit = || {
@@ -365,7 +365,7 @@ fn place_root_translation_items<'a, 'tcx, I>(scx: &SharedCrateContext<'a, 'tcx>,
365365
// always ensure we have at least one CGU; otherwise, if we have a
366366
// crate with just types (for example), we could wind up with no CGU
367367
if codegen_units.is_empty() {
368-
let codegen_unit_name = InternedString::new(FALLBACK_CODEGEN_UNIT);
368+
let codegen_unit_name = Symbol::intern(FALLBACK_CODEGEN_UNIT).as_str();
369369
codegen_units.entry(codegen_unit_name.clone())
370370
.or_insert_with(|| CodegenUnit::empty(codegen_unit_name.clone()));
371371
}

‎src/librustc_typeck/astconv.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1252,7 +1252,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
12521252
if bounds.len() > 1 {
12531253
let spans = bounds.iter().map(|b| {
12541254
self.tcx().associated_items(b.def_id()).find(|item| {
1255-
item.kind == ty::AssociatedKind::Type && item.name.as_str() == assoc_name
1255+
item.kind == ty::AssociatedKind::Type && item.name == assoc_name
12561256
})
12571257
.and_then(|item| self.tcx().map.as_local_node_id(item.def_id))
12581258
.and_then(|node_id| self.tcx().map.opt_span(node_id))

‎src/librustc_typeck/check/method/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
342342
let def = pick.item.def();
343343
if let probe::InherentImplPick = pick.kind {
344344
if !pick.item.vis.is_accessible_from(self.body_id, &self.tcx.map) {
345-
let msg = format!("{} `{}` is private", def.kind_name(), &method_name.as_str());
345+
let msg = format!("{} `{}` is private", def.kind_name(), method_name);
346346
self.tcx.sess.span_err(span, &msg);
347347
}
348348
}

‎src/librustc_typeck/check/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,7 @@ fn check_on_unimplemented<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
943943
Position::ArgumentNamed(s) if s == "Self" => (),
944944
// So is `{A}` if A is a type parameter
945945
Position::ArgumentNamed(s) => match types.iter().find(|t| {
946-
t.name.as_str() == s
946+
t.name == s
947947
}) {
948948
Some(_) => (),
949949
None => {
@@ -3127,7 +3127,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
31273127
ty::TyAdt(adt, ..) if adt.is_enum() => {
31283128
struct_span_err!(self.tcx.sess, field.name.span, E0559,
31293129
"{} `{}::{}` has no field named `{}`",
3130-
kind_name, actual, variant.name.as_str(), field.name.node)
3130+
kind_name, actual, variant.name, field.name.node)
31313131
}
31323132
_ => {
31333133
struct_span_err!(self.tcx.sess, field.name.span, E0560,
@@ -3147,7 +3147,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
31473147
match ty.sty {
31483148
ty::TyAdt(adt, ..) if adt.is_enum() => {
31493149
err.span_label(field.name.span, &format!("`{}::{}` does not have this field",
3150-
ty, variant.name.as_str()));
3150+
ty, variant.name));
31513151
}
31523152
_ => {
31533153
err.span_label(field.name.span, &format!("`{}` does not have this field", ty));

‎src/libsyntax/ast.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ impl Generics {
373373
}
374374
pub fn span_for_name(&self, name: &str) -> Option<Span> {
375375
for t in &self.ty_params {
376-
if t.ident.name.as_str() == name {
376+
if t.ident.name == name {
377377
return Some(t.span);
378378
}
379379
}

‎src/libsyntax/entry.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub fn entry_point_type(item: &Item, depth: usize) -> EntryPointType {
2828
EntryPointType::Start
2929
} else if attr::contains_name(&item.attrs, "main") {
3030
EntryPointType::MainAttr
31-
} else if item.ident.name.as_str() == "main" {
31+
} else if item.ident.name == "main" {
3232
if depth == 1 {
3333
// This is a top-level function so can be 'main'
3434
EntryPointType::MainNamed

‎src/libsyntax/ext/base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ impl<'a> ExtCtxt<'a> {
643643
loop {
644644
if self.codemap().with_expn_info(expn_id, |info| {
645645
info.map_or(None, |i| {
646-
if i.callee.name().as_str() == "include" {
646+
if i.callee.name() == "include" {
647647
// Stop going up the backtrace once include! is encountered
648648
return None;
649649
}

‎src/libsyntax/ext/tt/macro_rules.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -791,17 +791,16 @@ fn is_in_follow(tok: &Token, frag: &str) -> Result<bool, (String, &'static str)>
791791
"pat" => {
792792
match *tok {
793793
FatArrow | Comma | Eq | BinOp(token::Or) => Ok(true),
794-
Ident(i) if (i.name.as_str() == "if" ||
795-
i.name.as_str() == "in") => Ok(true),
794+
Ident(i) if i.name == "if" || i.name == "in" => Ok(true),
796795
_ => Ok(false)
797796
}
798797
},
799798
"path" | "ty" => {
800799
match *tok {
801800
OpenDelim(token::DelimToken::Brace) | OpenDelim(token::DelimToken::Bracket) |
802801
Comma | FatArrow | Colon | Eq | Gt | Semi | BinOp(token::Or) => Ok(true),
803-
MatchNt(_, ref frag) if frag.name.as_str() == "block" => Ok(true),
804-
Ident(i) if i.name.as_str() == "as" || i.name.as_str() == "where" => Ok(true),
802+
MatchNt(_, ref frag) if frag.name == "block" => Ok(true),
803+
Ident(i) if i.name == "as" || i.name == "where" => Ok(true),
805804
_ => Ok(false)
806805
}
807806
},

‎src/libsyntax/parse/parser.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2535,7 +2535,7 @@ impl<'a> Parser<'a> {
25352535
let prev_span = self.prev_span;
25362536
let fstr = n.as_str();
25372537
let mut err = self.diagnostic().struct_span_err(prev_span,
2538-
&format!("unexpected token: `{}`", n.as_str()));
2538+
&format!("unexpected token: `{}`", n));
25392539
if fstr.chars().all(|x| "0123456789.".contains(x)) {
25402540
let float = match fstr.parse::<f64>().ok() {
25412541
Some(f) => f,

‎src/libsyntax/symbol.rs

-32
Original file line numberDiff line numberDiff line change
@@ -244,14 +244,6 @@ pub struct InternedString {
244244
string: Rc<str>,
245245
}
246246

247-
impl InternedString {
248-
pub fn new(string: &'static str) -> InternedString {
249-
InternedString {
250-
string: Rc::__from_str(string),
251-
}
252-
}
253-
}
254-
255247
impl ::std::ops::Deref for InternedString {
256248
type Target = str;
257249
fn deref(&self) -> &str { &self.string }
@@ -269,30 +261,6 @@ impl fmt::Display for InternedString {
269261
}
270262
}
271263

272-
impl<'a> PartialEq<&'a str> for InternedString {
273-
fn eq(&self, other: & &'a str) -> bool {
274-
PartialEq::eq(&self.string[..], *other)
275-
}
276-
}
277-
278-
impl<'a> PartialEq<InternedString> for &'a str {
279-
fn eq(&self, other: &InternedString) -> bool {
280-
PartialEq::eq(*self, &other.string[..])
281-
}
282-
}
283-
284-
impl PartialEq<str> for InternedString {
285-
fn eq(&self, other: &str) -> bool {
286-
PartialEq::eq(&self.string[..], other)
287-
}
288-
}
289-
290-
impl PartialEq<InternedString> for str {
291-
fn eq(&self, other: &InternedString) -> bool {
292-
PartialEq::eq(self, &other.string[..])
293-
}
294-
}
295-
296264
impl Decodable for InternedString {
297265
fn decode<D: Decoder>(d: &mut D) -> Result<InternedString, D::Error> {
298266
Ok(Symbol::intern(&d.read_str()?).as_str())

0 commit comments

Comments
 (0)
Please sign in to comment.