X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Flibsyntax_pos%2Fsymbol.rs;h=0eecdbfa9763442d176552f62686c1065b07235a;hb=6413480adf6bc788e515a9746cf382e1ceb153fe;hp=7097f332b8b8f5cbdd210714b58e7d425215148a;hpb=fc6e9a2845e8bb4560811ed21136483a596505bb;p=rust.git diff --git a/src/libsyntax_pos/symbol.rs b/src/libsyntax_pos/symbol.rs index 7097f332b8b..0eecdbfa976 100644 --- a/src/libsyntax_pos/symbol.rs +++ b/src/libsyntax_pos/symbol.rs @@ -5,6 +5,7 @@ use arena::DroplessArena; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::indexed_vec::Idx; +use rustc_data_structures::newtype_index; use serialize::{Decodable, Decoder, Encodable, Encoder}; use std::fmt; @@ -12,8 +13,8 @@ use std::cmp::{PartialEq, Ordering, PartialOrd, Ord}; use std::hash::{Hash, Hasher}; -use hygiene::SyntaxContext; -use {Span, DUMMY_SP, GLOBALS}; +use crate::hygiene::SyntaxContext; +use crate::{Span, DUMMY_SP, GLOBALS}; #[derive(Copy, Clone, Eq)] pub struct Ident { @@ -100,13 +101,13 @@ fn hash(&self, state: &mut H) { } impl fmt::Debug for Ident { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}{:?}", self.name, self.span.ctxt()) } } impl fmt::Display for Ident { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt(&self.name, f) } } @@ -181,7 +182,7 @@ pub fn gensymed(self) -> Self { pub fn as_str(self) -> LocalInternedString { with_interner(|interner| unsafe { LocalInternedString { - string: ::std::mem::transmute::<&str, &str>(interner.get(self)) + string: std::mem::transmute::<&str, &str>(interner.get(self)) } }) } @@ -198,7 +199,7 @@ pub fn as_u32(self) -> u32 { } impl fmt::Debug for Symbol { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let is_gensymed = with_interner(|interner| interner.is_gensymed(*self)); if is_gensymed { write!(f, "{}({:?})", self, self.0) @@ -209,7 +210,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { } impl fmt::Display for Symbol { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt(&self.as_str(), f) } } @@ -226,7 +227,7 @@ fn decode(d: &mut D) -> Result { } } -impl> PartialEq for Symbol { +impl> PartialEq for Symbol { fn eq(&self, other: &T) -> bool { self.as_str() == other.deref() } @@ -335,7 +336,7 @@ impl Keyword { }; )* - impl ::std::str::FromStr for Keyword { + impl std::str::FromStr for Keyword { type Err = (); fn from_str(s: &str) -> Result { @@ -519,40 +520,40 @@ pub fn get(&self) -> &'static str { } } -impl ::std::convert::AsRef for LocalInternedString +impl std::convert::AsRef for LocalInternedString where - str: ::std::convert::AsRef + str: std::convert::AsRef { fn as_ref(&self) -> &U { self.string.as_ref() } } -impl> ::std::cmp::PartialEq for LocalInternedString { +impl> std::cmp::PartialEq for LocalInternedString { fn eq(&self, other: &T) -> bool { self.string == other.deref() } } -impl ::std::cmp::PartialEq for str { +impl std::cmp::PartialEq for str { fn eq(&self, other: &LocalInternedString) -> bool { self == other.string } } -impl<'a> ::std::cmp::PartialEq for &'a str { +impl<'a> std::cmp::PartialEq for &'a str { fn eq(&self, other: &LocalInternedString) -> bool { *self == other.string } } -impl ::std::cmp::PartialEq for String { +impl std::cmp::PartialEq for String { fn eq(&self, other: &LocalInternedString) -> bool { self == other.string } } -impl<'a> ::std::cmp::PartialEq for &'a String { +impl<'a> std::cmp::PartialEq for &'a String { fn eq(&self, other: &LocalInternedString) -> bool { *self == other.string } @@ -561,19 +562,19 @@ fn eq(&self, other: &LocalInternedString) -> bool { impl !Send for LocalInternedString {} impl !Sync for LocalInternedString {} -impl ::std::ops::Deref for LocalInternedString { +impl std::ops::Deref for LocalInternedString { type Target = str; fn deref(&self) -> &str { self.string } } impl fmt::Debug for LocalInternedString { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(self.string, f) } } impl fmt::Display for LocalInternedString { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt(self.string, f) } } @@ -640,7 +641,7 @@ fn cmp(&self, other: &InternedString) -> Ordering { } } -impl> PartialEq for InternedString { +impl> PartialEq for InternedString { fn eq(&self, other: &T) -> bool { self.with(|string| string == other.deref()) } @@ -676,20 +677,20 @@ fn eq(&self, other: &InternedString) -> bool { } } -impl ::std::convert::From for String { +impl std::convert::From for String { fn from(val: InternedString) -> String { val.as_symbol().to_string() } } impl fmt::Debug for InternedString { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.with(|str| fmt::Debug::fmt(&str, f)) } } impl fmt::Display for InternedString { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.with(|str| fmt::Display::fmt(&str, f)) } } @@ -709,7 +710,7 @@ fn encode(&self, s: &mut S) -> Result<(), S::Error> { #[cfg(test)] mod tests { use super::*; - use Globals; + use crate::Globals; #[test] fn interner_tests() {