Skip to content

Commit 80934ab

Browse files
authored
Rollup merge of rust-lang#80411 - petrochenkov:nosymwith, r=matthewjasper
rustc_span: Remove `Symbol::with` A subset of rust-lang#79425 that is a pure refactoring.
2 parents 55b52ee + 0ae998e commit 80934ab

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

compiler/rustc_resolve/src/lib.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -2416,7 +2416,10 @@ impl<'a> Resolver<'a> {
24162416
} else if i == 0 {
24172417
if ident
24182418
.name
2419-
.with(|n| n.chars().next().map_or(false, |c| c.is_ascii_uppercase()))
2419+
.as_str()
2420+
.chars()
2421+
.next()
2422+
.map_or(false, |c| c.is_ascii_uppercase())
24202423
{
24212424
(format!("use of undeclared type `{}`", ident), None)
24222425
} else {

compiler/rustc_span/src/symbol.rs

+3-9
Original file line numberDiff line numberDiff line change
@@ -1451,12 +1451,6 @@ impl Symbol {
14511451
with_interner(|interner| interner.intern(string))
14521452
}
14531453

1454-
/// Access the symbol's chars. This is a slowish operation because it
1455-
/// requires locking the symbol interner.
1456-
pub fn with<F: FnOnce(&str) -> R, R>(self, f: F) -> R {
1457-
with_interner(|interner| f(interner.get(self)))
1458-
}
1459-
14601454
/// Convert to a `SymbolStr`. This is a slowish operation because it
14611455
/// requires locking the symbol interner.
14621456
pub fn as_str(self) -> SymbolStr {
@@ -1484,19 +1478,19 @@ impl Symbol {
14841478

14851479
impl fmt::Debug for Symbol {
14861480
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1487-
self.with(|str| fmt::Debug::fmt(&str, f))
1481+
fmt::Debug::fmt(&self.as_str(), f)
14881482
}
14891483
}
14901484

14911485
impl fmt::Display for Symbol {
14921486
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1493-
self.with(|str| fmt::Display::fmt(&str, f))
1487+
fmt::Display::fmt(&self.as_str(), f)
14941488
}
14951489
}
14961490

14971491
impl<S: Encoder> Encodable<S> for Symbol {
14981492
fn encode(&self, s: &mut S) -> Result<(), S::Error> {
1499-
self.with(|string| s.emit_str(string))
1493+
s.emit_str(&self.as_str())
15001494
}
15011495
}
15021496

0 commit comments

Comments
 (0)