Cleanup InternedString
.
This commit is contained in:
parent
e85a0d70b8
commit
36c8f6b0d3
@ -343,7 +343,7 @@ impl DefPathData {
|
||||
|
||||
pub fn as_interned_str(&self) -> InternedString {
|
||||
use self::DefPathData::*;
|
||||
match *self {
|
||||
let s = match *self {
|
||||
TypeNs(ref name) |
|
||||
ValueNs(ref name) |
|
||||
Module(ref name) |
|
||||
@ -353,43 +353,24 @@ impl DefPathData {
|
||||
EnumVariant(ref name) |
|
||||
Binding(ref name) |
|
||||
Field(ref name) => {
|
||||
name.clone()
|
||||
}
|
||||
|
||||
Impl => {
|
||||
InternedString::new("{{impl}}")
|
||||
return name.clone();
|
||||
}
|
||||
|
||||
// note that this does not show up in user printouts
|
||||
CrateRoot => {
|
||||
InternedString::new("{{root}}")
|
||||
}
|
||||
CrateRoot => "{{root}}",
|
||||
|
||||
// note that this does not show up in user printouts
|
||||
InlinedRoot(_) => {
|
||||
InternedString::new("{{inlined-root}}")
|
||||
}
|
||||
InlinedRoot(_) => "{{inlined-root}}",
|
||||
|
||||
Misc => {
|
||||
InternedString::new("{{?}}")
|
||||
}
|
||||
Impl => "{{impl}}",
|
||||
Misc => "{{?}}",
|
||||
ClosureExpr => "{{closure}}",
|
||||
StructCtor => "{{constructor}}",
|
||||
Initializer => "{{initializer}}",
|
||||
ImplTrait => "{{impl-Trait}}",
|
||||
};
|
||||
|
||||
ClosureExpr => {
|
||||
InternedString::new("{{closure}}")
|
||||
}
|
||||
|
||||
StructCtor => {
|
||||
InternedString::new("{{constructor}}")
|
||||
}
|
||||
|
||||
Initializer => {
|
||||
InternedString::new("{{initializer}}")
|
||||
}
|
||||
|
||||
ImplTrait => {
|
||||
InternedString::new("{{impl-Trait}}")
|
||||
}
|
||||
}
|
||||
Symbol::intern(s).as_str()
|
||||
}
|
||||
|
||||
pub fn to_string(&self) -> String {
|
||||
|
@ -765,7 +765,7 @@ impl<'a, 'ast> NodesMatchingSuffix<'a, 'ast> {
|
||||
None => return false,
|
||||
Some((node_id, name)) => (node_id, name),
|
||||
};
|
||||
if &part[..] != mod_name.as_str() {
|
||||
if mod_name != &**part {
|
||||
return false;
|
||||
}
|
||||
cursor = self.map.get_parent(mod_id);
|
||||
@ -803,8 +803,7 @@ impl<'a, 'ast> NodesMatchingSuffix<'a, 'ast> {
|
||||
// We are looking at some node `n` with a given name and parent
|
||||
// id; do their names match what I am seeking?
|
||||
fn matches_names(&self, parent_of_n: NodeId, name: Name) -> bool {
|
||||
name.as_str() == &self.item_name[..] &&
|
||||
self.suffix_matches(parent_of_n)
|
||||
name == &**self.item_name && self.suffix_matches(parent_of_n)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -498,8 +498,7 @@ impl<'a, 'tcx> DeadVisitor<'a, 'tcx> {
|
||||
span: syntax_pos::Span,
|
||||
name: ast::Name,
|
||||
node_type: &str) {
|
||||
let name = name.as_str();
|
||||
if !name.starts_with("_") {
|
||||
if !name.as_str().starts_with("_") {
|
||||
self.tcx
|
||||
.sess
|
||||
.add_lint(lint::builtin::DEAD_CODE,
|
||||
|
@ -92,7 +92,7 @@ fn entry_point_type(item: &Item, at_root: bool) -> EntryPointType {
|
||||
EntryPointType::Start
|
||||
} else if attr::contains_name(&item.attrs, "main") {
|
||||
EntryPointType::MainAttr
|
||||
} else if item.name.as_str() == "main" {
|
||||
} else if item.name == "main" {
|
||||
if at_root {
|
||||
// This is a top-level function so can be 'main'
|
||||
EntryPointType::MainNamed
|
||||
|
@ -55,7 +55,7 @@ impl<'a, 'gcx, 'tcx> ExprVisitor<'a, 'gcx, 'tcx> {
|
||||
ty::TyFnDef(.., ref bfty) => bfty.abi == RustIntrinsic,
|
||||
_ => return false
|
||||
};
|
||||
intrinsic && self.infcx.tcx.item_name(def_id).as_str() == "transmute"
|
||||
intrinsic && self.infcx.tcx.item_name(def_id) == "transmute"
|
||||
}
|
||||
|
||||
fn check_transmute(&self, span: Span, from: Ty<'gcx>, to: Ty<'gcx>, id: ast::NodeId) {
|
||||
|
@ -455,7 +455,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> {
|
||||
// When compiling with --test we don't enforce stability on the
|
||||
// compiler-generated test module, demarcated with `DUMMY_SP` plus the
|
||||
// name `__test`
|
||||
if item.span == DUMMY_SP && item.name.as_str() == "__test" { return }
|
||||
if item.span == DUMMY_SP && item.name == "__test" { return }
|
||||
|
||||
check_item(self.tcx, item, true,
|
||||
&mut |id, sp, stab, depr| self.check(id, sp, stab, depr));
|
||||
|
@ -169,7 +169,7 @@ fn is_rustc_peek<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
{
|
||||
let name = tcx.item_name(def_id);
|
||||
if abi == Abi::RustIntrinsic || abi == Abi::PlatformIntrinsic {
|
||||
if name.as_str() == "rustc_peek" {
|
||||
if name == "rustc_peek" {
|
||||
return Some((args, source_info.span));
|
||||
}
|
||||
}
|
||||
|
@ -81,19 +81,12 @@ impl NonCamelCaseTypes {
|
||||
.concat()
|
||||
}
|
||||
|
||||
let s = name.as_str();
|
||||
|
||||
if !is_camel_case(name) {
|
||||
let c = to_camel_case(&s);
|
||||
let c = to_camel_case(&name.as_str());
|
||||
let m = if c.is_empty() {
|
||||
format!("{} `{}` should have a camel case name such as `CamelCase`",
|
||||
sort,
|
||||
s)
|
||||
format!("{} `{}` should have a camel case name such as `CamelCase`", sort, name)
|
||||
} else {
|
||||
format!("{} `{}` should have a camel case name such as `{}`",
|
||||
sort,
|
||||
s,
|
||||
c)
|
||||
format!("{} `{}` should have a camel case name such as `{}`", sort, name, c)
|
||||
};
|
||||
cx.span_lint(NON_CAMEL_CASE_TYPES, span, &m[..]);
|
||||
}
|
||||
@ -326,21 +319,19 @@ pub struct NonUpperCaseGlobals;
|
||||
|
||||
impl NonUpperCaseGlobals {
|
||||
fn check_upper_case(cx: &LateContext, sort: &str, name: ast::Name, span: Span) {
|
||||
let s = name.as_str();
|
||||
|
||||
if s.chars().any(|c| c.is_lowercase()) {
|
||||
let uc = NonSnakeCase::to_snake_case(&s).to_uppercase();
|
||||
if uc != &s[..] {
|
||||
if name.as_str().chars().any(|c| c.is_lowercase()) {
|
||||
let uc = NonSnakeCase::to_snake_case(&name.as_str()).to_uppercase();
|
||||
if name != &*uc {
|
||||
cx.span_lint(NON_UPPER_CASE_GLOBALS,
|
||||
span,
|
||||
&format!("{} `{}` should have an upper case name such as `{}`",
|
||||
sort,
|
||||
s,
|
||||
name,
|
||||
uc));
|
||||
} else {
|
||||
cx.span_lint(NON_UPPER_CASE_GLOBALS,
|
||||
span,
|
||||
&format!("{} `{}` should have an upper case name", sort, s));
|
||||
&format!("{} `{}` should have an upper case name", sort, name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1229,7 +1229,7 @@ impl LateLintPass for MutableTransmutes {
|
||||
ty::TyFnDef(.., ref bfty) if bfty.abi == RustIntrinsic => (),
|
||||
_ => return false,
|
||||
}
|
||||
cx.tcx.item_name(def_id).as_str() == "transmute"
|
||||
cx.tcx.item_name(def_id) == "transmute"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ impl<'a> AstValidator<'a> {
|
||||
if label.name == keywords::StaticLifetime.name() {
|
||||
self.err_handler().span_err(span, &format!("invalid label name `{}`", label.name));
|
||||
}
|
||||
if label.name.as_str() == "'_" {
|
||||
if label.name == "'_" {
|
||||
self.session.add_lint(lint::builtin::LIFETIME_UNDERSCORE,
|
||||
id,
|
||||
span,
|
||||
@ -90,7 +90,7 @@ impl<'a> AstValidator<'a> {
|
||||
|
||||
impl<'a> Visitor for AstValidator<'a> {
|
||||
fn visit_lifetime(&mut self, lt: &Lifetime) {
|
||||
if lt.name.as_str() == "'_" {
|
||||
if lt.name == "'_" {
|
||||
self.session.add_lint(lint::builtin::LIFETIME_UNDERSCORE,
|
||||
lt.id,
|
||||
lt.span,
|
||||
|
@ -101,7 +101,7 @@ impl<'a> Registry<'a> {
|
||||
///
|
||||
/// This is the most general hook into `libsyntax`'s expansion behavior.
|
||||
pub fn register_syntax_extension(&mut self, name: ast::Name, extension: SyntaxExtension) {
|
||||
if name.as_str() == "macro_rules" {
|
||||
if name == "macro_rules" {
|
||||
panic!("user-defined macros may not be named `macro_rules`");
|
||||
}
|
||||
self.syntax_exts.push((name, match extension {
|
||||
|
@ -138,7 +138,7 @@ impl<'b> Resolver<'b> {
|
||||
match view_path.node {
|
||||
ViewPathSimple(binding, ref full_path) => {
|
||||
let mut source = full_path.segments.last().unwrap().identifier;
|
||||
let source_name = source.name.as_str();
|
||||
let source_name = source.name;
|
||||
if source_name == "mod" || source_name == "self" {
|
||||
resolve_error(self,
|
||||
view_path.span,
|
||||
|
@ -1462,7 +1462,6 @@ impl<'a> Resolver<'a> {
|
||||
let name = module_path[index].name;
|
||||
match self.resolve_name_in_module(search_module, name, TypeNS, false, false, span) {
|
||||
Failed(_) => {
|
||||
let segment_name = name.as_str();
|
||||
let module_name = module_to_string(search_module);
|
||||
let msg = if "???" == &module_name {
|
||||
let current_module = self.current_module;
|
||||
@ -1480,10 +1479,10 @@ impl<'a> Resolver<'a> {
|
||||
|
||||
format!("Did you mean `{}{}`?", prefix, path_str)
|
||||
}
|
||||
None => format!("Maybe a missing `extern crate {};`?", segment_name),
|
||||
None => format!("Maybe a missing `extern crate {};`?", name),
|
||||
}
|
||||
} else {
|
||||
format!("Could not find `{}` in `{}`", segment_name, module_name)
|
||||
format!("Could not find `{}` in `{}`", name, module_name)
|
||||
};
|
||||
|
||||
return Failed(span.map(|span| (span, msg)));
|
||||
@ -1651,7 +1650,7 @@ impl<'a> Resolver<'a> {
|
||||
/// grammar: (SELF MOD_SEP ) ? (SUPER MOD_SEP) *
|
||||
fn resolve_module_prefix(&mut self, module_path: &[Ident], span: Option<Span>)
|
||||
-> ResolveResult<ModulePrefixResult<'a>> {
|
||||
if &*module_path[0].name.as_str() == "$crate" {
|
||||
if module_path[0].name == "$crate" {
|
||||
return Success(PrefixFound(self.resolve_crate_var(module_path[0].ctxt), 1));
|
||||
}
|
||||
|
||||
@ -1667,7 +1666,7 @@ impl<'a> Resolver<'a> {
|
||||
self.module_map[&self.current_module.normal_ancestor_id.unwrap()];
|
||||
|
||||
// Now loop through all the `super`s we find.
|
||||
while i < module_path.len() && "super" == module_path[i].name.as_str() {
|
||||
while i < module_path.len() && module_path[i].name == "super" {
|
||||
debug!("(resolving module prefix) resolving `super` at {}",
|
||||
module_to_string(&containing_module));
|
||||
if let Some(parent) = containing_module.parent {
|
||||
@ -2635,7 +2634,7 @@ impl<'a> Resolver<'a> {
|
||||
let qualified_binding = self.resolve_module_relative_path(span, segments, namespace);
|
||||
match (qualified_binding, unqualified_def) {
|
||||
(Ok(binding), Some(ref ud)) if binding.def() == ud.def &&
|
||||
segments[0].identifier.name.as_str() != "$crate" => {
|
||||
segments[0].identifier.name != "$crate" => {
|
||||
self.session
|
||||
.add_lint(lint::builtin::UNUSED_QUALIFICATIONS,
|
||||
id,
|
||||
@ -2881,7 +2880,7 @@ impl<'a> Resolver<'a> {
|
||||
}
|
||||
|
||||
fn find_best_match(&mut self, name: &str) -> SuggestionType {
|
||||
if let Some(macro_name) = self.macro_names.iter().find(|n| n.as_str() == name) {
|
||||
if let Some(macro_name) = self.macro_names.iter().find(|&n| n == &name) {
|
||||
return SuggestionType::Macro(format!("{}!", macro_name));
|
||||
}
|
||||
|
||||
@ -3000,8 +2999,7 @@ impl<'a> Resolver<'a> {
|
||||
false // Stop advancing
|
||||
});
|
||||
|
||||
if method_scope &&
|
||||
&path_name[..] == keywords::SelfValue.name().as_str() {
|
||||
if method_scope && keywords::SelfValue.name() == &*path_name {
|
||||
resolve_error(self,
|
||||
expr.span,
|
||||
ResolutionError::SelfNotAvailableInStaticMethod);
|
||||
|
@ -115,7 +115,7 @@ impl<'a> base::Resolver for Resolver<'a> {
|
||||
impl<'a, 'b> Folder for EliminateCrateVar<'a, 'b> {
|
||||
fn fold_path(&mut self, mut path: ast::Path) -> ast::Path {
|
||||
let ident = path.segments[0].identifier;
|
||||
if &ident.name.as_str() == "$crate" {
|
||||
if ident.name == "$crate" {
|
||||
path.global = true;
|
||||
let module = self.0.resolve_crate_var(ident.ctxt);
|
||||
if module.is_local() {
|
||||
@ -151,7 +151,7 @@ impl<'a> base::Resolver for Resolver<'a> {
|
||||
}
|
||||
|
||||
fn add_macro(&mut self, scope: Mark, mut def: ast::MacroDef, export: bool) {
|
||||
if &def.ident.name.as_str() == "macro_rules" {
|
||||
if def.ident.name == "macro_rules" {
|
||||
self.session.span_err(def.span, "user-defined macros may not be named `macro_rules`");
|
||||
}
|
||||
|
||||
|
@ -663,7 +663,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
|
||||
-> bool {
|
||||
(bare_fn_ty.abi == Abi::RustIntrinsic ||
|
||||
bare_fn_ty.abi == Abi::PlatformIntrinsic) &&
|
||||
tcx.item_name(def_id).as_str() == "drop_in_place"
|
||||
tcx.item_name(def_id) == "drop_in_place"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
||||
let sig = tcx.erase_late_bound_regions_and_normalize(&fty.sig);
|
||||
let arg_tys = sig.inputs;
|
||||
let ret_ty = sig.output;
|
||||
let name = tcx.item_name(def_id).as_str();
|
||||
let name = &*tcx.item_name(def_id).as_str();
|
||||
|
||||
let span = match call_debug_location {
|
||||
DebugLoc::ScopeAt(_, span) => span,
|
||||
@ -123,15 +123,15 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
||||
Call(bcx, llfn, &[], call_debug_location);
|
||||
Unreachable(bcx);
|
||||
return Result::new(bcx, C_undef(Type::nil(ccx).ptr_to()));
|
||||
} else if &name[..] == "unreachable" {
|
||||
} else if name == "unreachable" {
|
||||
Unreachable(bcx);
|
||||
return Result::new(bcx, C_nil(ccx));
|
||||
}
|
||||
|
||||
let llret_ty = type_of::type_of(ccx, ret_ty);
|
||||
|
||||
let simple = get_simple_intrinsic(ccx, &name);
|
||||
let llval = match (simple, &name[..]) {
|
||||
let simple = get_simple_intrinsic(ccx, name);
|
||||
let llval = match (simple, name) {
|
||||
(Some(llfn), _) => {
|
||||
Call(bcx, llfn, &llargs, call_debug_location)
|
||||
}
|
||||
@ -340,7 +340,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
||||
let sty = &arg_tys[0].sty;
|
||||
match int_type_width_signed(sty, ccx) {
|
||||
Some((width, signed)) =>
|
||||
match &*name {
|
||||
match name {
|
||||
"ctlz" => count_zeros_intrinsic(bcx, &format!("llvm.ctlz.i{}", width),
|
||||
llargs[0], call_debug_location),
|
||||
"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>,
|
||||
let sty = &arg_tys[0].sty;
|
||||
match float_type_width(sty) {
|
||||
Some(_width) =>
|
||||
match &*name {
|
||||
match name {
|
||||
"fadd_fast" => FAddFast(bcx, llargs[0], llargs[1], call_debug_location),
|
||||
"fsub_fast" => FSubFast(bcx, llargs[0], llargs[1], call_debug_location),
|
||||
"fmul_fast" => FMulFast(bcx, llargs[0], llargs[1], call_debug_location),
|
||||
|
@ -320,7 +320,7 @@ fn place_root_translation_items<'a, 'tcx, I>(scx: &SharedCrateContext<'a, 'tcx>,
|
||||
|
||||
let codegen_unit_name = match characteristic_def_id {
|
||||
Some(def_id) => compute_codegen_unit_name(tcx, def_id, is_volatile),
|
||||
None => InternedString::new(FALLBACK_CODEGEN_UNIT),
|
||||
None => Symbol::intern(FALLBACK_CODEGEN_UNIT).as_str(),
|
||||
};
|
||||
|
||||
let make_codegen_unit = || {
|
||||
@ -365,7 +365,7 @@ fn place_root_translation_items<'a, 'tcx, I>(scx: &SharedCrateContext<'a, 'tcx>,
|
||||
// always ensure we have at least one CGU; otherwise, if we have a
|
||||
// crate with just types (for example), we could wind up with no CGU
|
||||
if codegen_units.is_empty() {
|
||||
let codegen_unit_name = InternedString::new(FALLBACK_CODEGEN_UNIT);
|
||||
let codegen_unit_name = Symbol::intern(FALLBACK_CODEGEN_UNIT).as_str();
|
||||
codegen_units.entry(codegen_unit_name.clone())
|
||||
.or_insert_with(|| CodegenUnit::empty(codegen_unit_name.clone()));
|
||||
}
|
||||
|
@ -1252,7 +1252,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
|
||||
if bounds.len() > 1 {
|
||||
let spans = bounds.iter().map(|b| {
|
||||
self.tcx().associated_items(b.def_id()).find(|item| {
|
||||
item.kind == ty::AssociatedKind::Type && item.name.as_str() == assoc_name
|
||||
item.kind == ty::AssociatedKind::Type && item.name == assoc_name
|
||||
})
|
||||
.and_then(|item| self.tcx().map.as_local_node_id(item.def_id))
|
||||
.and_then(|node_id| self.tcx().map.opt_span(node_id))
|
||||
|
@ -342,7 +342,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
let def = pick.item.def();
|
||||
if let probe::InherentImplPick = pick.kind {
|
||||
if !pick.item.vis.is_accessible_from(self.body_id, &self.tcx.map) {
|
||||
let msg = format!("{} `{}` is private", def.kind_name(), &method_name.as_str());
|
||||
let msg = format!("{} `{}` is private", def.kind_name(), method_name);
|
||||
self.tcx.sess.span_err(span, &msg);
|
||||
}
|
||||
}
|
||||
|
@ -943,7 +943,7 @@ fn check_on_unimplemented<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
Position::ArgumentNamed(s) if s == "Self" => (),
|
||||
// So is `{A}` if A is a type parameter
|
||||
Position::ArgumentNamed(s) => match types.iter().find(|t| {
|
||||
t.name.as_str() == s
|
||||
t.name == s
|
||||
}) {
|
||||
Some(_) => (),
|
||||
None => {
|
||||
@ -3127,7 +3127,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
ty::TyAdt(adt, ..) if adt.is_enum() => {
|
||||
struct_span_err!(self.tcx.sess, field.name.span, E0559,
|
||||
"{} `{}::{}` has no field named `{}`",
|
||||
kind_name, actual, variant.name.as_str(), field.name.node)
|
||||
kind_name, actual, variant.name, field.name.node)
|
||||
}
|
||||
_ => {
|
||||
struct_span_err!(self.tcx.sess, field.name.span, E0560,
|
||||
@ -3147,7 +3147,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
match ty.sty {
|
||||
ty::TyAdt(adt, ..) if adt.is_enum() => {
|
||||
err.span_label(field.name.span, &format!("`{}::{}` does not have this field",
|
||||
ty, variant.name.as_str()));
|
||||
ty, variant.name));
|
||||
}
|
||||
_ => {
|
||||
err.span_label(field.name.span, &format!("`{}` does not have this field", ty));
|
||||
|
@ -373,7 +373,7 @@ impl Generics {
|
||||
}
|
||||
pub fn span_for_name(&self, name: &str) -> Option<Span> {
|
||||
for t in &self.ty_params {
|
||||
if t.ident.name.as_str() == name {
|
||||
if t.ident.name == name {
|
||||
return Some(t.span);
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ pub fn entry_point_type(item: &Item, depth: usize) -> EntryPointType {
|
||||
EntryPointType::Start
|
||||
} else if attr::contains_name(&item.attrs, "main") {
|
||||
EntryPointType::MainAttr
|
||||
} else if item.ident.name.as_str() == "main" {
|
||||
} else if item.ident.name == "main" {
|
||||
if depth == 1 {
|
||||
// This is a top-level function so can be 'main'
|
||||
EntryPointType::MainNamed
|
||||
|
@ -643,7 +643,7 @@ impl<'a> ExtCtxt<'a> {
|
||||
loop {
|
||||
if self.codemap().with_expn_info(expn_id, |info| {
|
||||
info.map_or(None, |i| {
|
||||
if i.callee.name().as_str() == "include" {
|
||||
if i.callee.name() == "include" {
|
||||
// Stop going up the backtrace once include! is encountered
|
||||
return None;
|
||||
}
|
||||
|
@ -791,8 +791,7 @@ fn is_in_follow(tok: &Token, frag: &str) -> Result<bool, (String, &'static str)>
|
||||
"pat" => {
|
||||
match *tok {
|
||||
FatArrow | Comma | Eq | BinOp(token::Or) => Ok(true),
|
||||
Ident(i) if (i.name.as_str() == "if" ||
|
||||
i.name.as_str() == "in") => Ok(true),
|
||||
Ident(i) if i.name == "if" || i.name == "in" => Ok(true),
|
||||
_ => Ok(false)
|
||||
}
|
||||
},
|
||||
@ -800,8 +799,8 @@ fn is_in_follow(tok: &Token, frag: &str) -> Result<bool, (String, &'static str)>
|
||||
match *tok {
|
||||
OpenDelim(token::DelimToken::Brace) | OpenDelim(token::DelimToken::Bracket) |
|
||||
Comma | FatArrow | Colon | Eq | Gt | Semi | BinOp(token::Or) => Ok(true),
|
||||
MatchNt(_, ref frag) if frag.name.as_str() == "block" => Ok(true),
|
||||
Ident(i) if i.name.as_str() == "as" || i.name.as_str() == "where" => Ok(true),
|
||||
MatchNt(_, ref frag) if frag.name == "block" => Ok(true),
|
||||
Ident(i) if i.name == "as" || i.name == "where" => Ok(true),
|
||||
_ => Ok(false)
|
||||
}
|
||||
},
|
||||
|
@ -2535,7 +2535,7 @@ impl<'a> Parser<'a> {
|
||||
let prev_span = self.prev_span;
|
||||
let fstr = n.as_str();
|
||||
let mut err = self.diagnostic().struct_span_err(prev_span,
|
||||
&format!("unexpected token: `{}`", n.as_str()));
|
||||
&format!("unexpected token: `{}`", n));
|
||||
if fstr.chars().all(|x| "0123456789.".contains(x)) {
|
||||
let float = match fstr.parse::<f64>().ok() {
|
||||
Some(f) => f,
|
||||
|
@ -244,14 +244,6 @@ pub struct InternedString {
|
||||
string: Rc<str>,
|
||||
}
|
||||
|
||||
impl InternedString {
|
||||
pub fn new(string: &'static str) -> InternedString {
|
||||
InternedString {
|
||||
string: Rc::__from_str(string),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ::std::ops::Deref for InternedString {
|
||||
type Target = str;
|
||||
fn deref(&self) -> &str { &self.string }
|
||||
@ -269,30 +261,6 @@ impl fmt::Display for InternedString {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> PartialEq<&'a str> for InternedString {
|
||||
fn eq(&self, other: & &'a str) -> bool {
|
||||
PartialEq::eq(&self.string[..], *other)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> PartialEq<InternedString> for &'a str {
|
||||
fn eq(&self, other: &InternedString) -> bool {
|
||||
PartialEq::eq(*self, &other.string[..])
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq<str> for InternedString {
|
||||
fn eq(&self, other: &str) -> bool {
|
||||
PartialEq::eq(&self.string[..], other)
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq<InternedString> for str {
|
||||
fn eq(&self, other: &InternedString) -> bool {
|
||||
PartialEq::eq(self, &other.string[..])
|
||||
}
|
||||
}
|
||||
|
||||
impl Decodable for InternedString {
|
||||
fn decode<D: Decoder>(d: &mut D) -> Result<InternedString, D::Error> {
|
||||
Ok(Symbol::intern(&d.read_str()?).as_str())
|
||||
|
Loading…
x
Reference in New Issue
Block a user