Skip to content

Commit b24126a

Browse files
committed
fix lifetimes as requested by rustc build
1 parent 2811a1a commit b24126a

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/legacy.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ pub struct Demangle<'a> {
4646
// Note that this demangler isn't quite as fancy as it could be. We have lots
4747
// of other information in our symbols like hashes, version, type information,
4848
// etc. Additionally, this doesn't handle glue symbols at all.
49-
pub fn demangle(s: &str) -> Result<(Demangle, &str), ()> {
49+
pub fn demangle(s: &str) -> Result<(Demangle<'_>, &str), ()> {
5050
// First validate the symbol. If it doesn't look like anything we're
5151
// expecting, we just print it literally. Note that we must handle non-Rust
5252
// symbols because we could have any function in the backtrace.
@@ -103,7 +103,7 @@ fn is_rust_hash(s: &str) -> bool {
103103
}
104104

105105
impl<'a> fmt::Display for Demangle<'a> {
106-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
106+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
107107
// Alright, let's do this.
108108
let mut inner = self.inner;
109109
for element in 0..self.elements {

src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ enum DemangleStyle<'a> {
8888
/// assert_eq!(demangle("_ZN3foo3barE").to_string(), "foo::bar");
8989
/// assert_eq!(demangle("foo").to_string(), "foo");
9090
/// ```
91-
pub fn demangle(mut s: &str) -> Demangle {
91+
pub fn demangle(mut s: &str) -> Demangle<'_> {
9292
// During ThinLTO LLVM may import and rename internal symbols, so strip out
9393
// those endings first as they're one of the last manglings applied to symbol
9494
// names.
@@ -164,7 +164,7 @@ pub struct TryDemangleError {
164164
/// // While `demangle` will just pass the non-symbol through as a no-op.
165165
/// assert_eq!(rustc_demangle::demangle(not_a_rust_symbol).as_str(), not_a_rust_symbol);
166166
/// ```
167-
pub fn try_demangle(s: &str) -> Result<Demangle, TryDemangleError> {
167+
pub fn try_demangle(s: &str) -> Result<Demangle<'_>, TryDemangleError> {
168168
let sym = demangle(s);
169169
if sym.style.is_some() {
170170
Ok(sym)
@@ -241,7 +241,7 @@ impl<F: fmt::Write> fmt::Write for SizeLimitedFmtAdapter<F> {
241241
}
242242

243243
impl<'a> fmt::Display for Demangle<'a> {
244-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
244+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
245245
match self.style {
246246
None => f.write_str(self.original)?,
247247
Some(ref d) => {
@@ -276,7 +276,7 @@ impl<'a> fmt::Display for Demangle<'a> {
276276
}
277277

278278
impl<'a> fmt::Debug for Demangle<'a> {
279-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
279+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
280280
fmt::Display::fmt(self, f)
281281
}
282282
}

src/v0.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ pub fn demangle(s: &str) -> Result<(Demangle, &str), ParseError> {
5353
}
5454

5555
// Paths always start with uppercase characters.
56-
match inner.as_bytes()[0] {
57-
b'A'..=b'Z' => {}
56+
match inner.bytes().next() {
57+
Some(b'A'..=b'Z') => {}
5858
_ => return Err(ParseError::Invalid),
5959
}
6060

0 commit comments

Comments
 (0)