Rollup merge of #80411 - petrochenkov:nosymwith, r=matthewjasper
rustc_span: Remove `Symbol::with` A subset of https://github.com/rust-lang/rust/pull/79425 that is a pure refactoring.
This commit is contained in:
commit
80934aba15
2 changed files with 7 additions and 10 deletions
|
@ -2416,7 +2416,10 @@ impl<'a> Resolver<'a> {
|
||||||
} else if i == 0 {
|
} else if i == 0 {
|
||||||
if ident
|
if ident
|
||||||
.name
|
.name
|
||||||
.with(|n| n.chars().next().map_or(false, |c| c.is_ascii_uppercase()))
|
.as_str()
|
||||||
|
.chars()
|
||||||
|
.next()
|
||||||
|
.map_or(false, |c| c.is_ascii_uppercase())
|
||||||
{
|
{
|
||||||
(format!("use of undeclared type `{}`", ident), None)
|
(format!("use of undeclared type `{}`", ident), None)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1451,12 +1451,6 @@ impl Symbol {
|
||||||
with_interner(|interner| interner.intern(string))
|
with_interner(|interner| interner.intern(string))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Access the symbol's chars. This is a slowish operation because it
|
|
||||||
/// requires locking the symbol interner.
|
|
||||||
pub fn with<F: FnOnce(&str) -> R, R>(self, f: F) -> R {
|
|
||||||
with_interner(|interner| f(interner.get(self)))
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Convert to a `SymbolStr`. This is a slowish operation because it
|
/// Convert to a `SymbolStr`. This is a slowish operation because it
|
||||||
/// requires locking the symbol interner.
|
/// requires locking the symbol interner.
|
||||||
pub fn as_str(self) -> SymbolStr {
|
pub fn as_str(self) -> SymbolStr {
|
||||||
|
@ -1484,19 +1478,19 @@ impl Symbol {
|
||||||
|
|
||||||
impl fmt::Debug for Symbol {
|
impl fmt::Debug for Symbol {
|
||||||
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))
|
fmt::Debug::fmt(&self.as_str(), f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for Symbol {
|
impl fmt::Display for Symbol {
|
||||||
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))
|
fmt::Display::fmt(&self.as_str(), f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: Encoder> Encodable<S> for Symbol {
|
impl<S: Encoder> Encodable<S> for Symbol {
|
||||||
fn encode(&self, s: &mut S) -> Result<(), S::Error> {
|
fn encode(&self, s: &mut S) -> Result<(), S::Error> {
|
||||||
self.with(|string| s.emit_str(string))
|
s.emit_str(&self.as_str())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue