summaryrefslogtreecommitdiffstats
path: root/vendor/rustc-demangle
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/rustc-demangle')
-rw-r--r--vendor/rustc-demangle/.cargo-checksum.json2
-rw-r--r--vendor/rustc-demangle/Cargo.toml30
-rw-r--r--vendor/rustc-demangle/src/lib.rs97
3 files changed, 119 insertions, 10 deletions
diff --git a/vendor/rustc-demangle/.cargo-checksum.json b/vendor/rustc-demangle/.cargo-checksum.json
index ccb0200bf..9ddcdb2d5 100644
--- a/vendor/rustc-demangle/.cargo-checksum.json
+++ b/vendor/rustc-demangle/.cargo-checksum.json
@@ -1 +1 @@
-{"files":{"Cargo.toml":"574e364beff42bec64bc576759ff927d1d2ba3fb52c595dd8bc02864778f8406","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"3bb7af78423e95b207beebd452cdd973d65663cf25a0fc9358c588f53783293c","src/legacy.rs":"b4d5a140ed0bf2d792431961d6fd44a21c99235489a2c9f6717d1577a42c09ce","src/lib.rs":"a6aef558ecbdcad7ed63d4590863a29233264396b6b21745b498df1602776457","src/v0-large-test-symbols/early-recursion-limit":"96861a7042db35ee0bd04802820d0f2d6a3b534ce13547912b6364001ffd1494","src/v0.rs":"4e5bd069aa61def3dc732b3a285861914895272668ddfcb6b9eef46dd5713041"},"package":"7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342"} \ No newline at end of file
+{"files":{"Cargo.toml":"f4132bc65d5e58e2f27b9f9ef197b1c286582137b65285292b75a5a230fc81c8","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"3bb7af78423e95b207beebd452cdd973d65663cf25a0fc9358c588f53783293c","src/legacy.rs":"b4d5a140ed0bf2d792431961d6fd44a21c99235489a2c9f6717d1577a42c09ce","src/lib.rs":"607fe60c1e65da3f86a0b4b8fececb7db79049a0cd4cb316492e8e6593bf39c6","src/v0-large-test-symbols/early-recursion-limit":"96861a7042db35ee0bd04802820d0f2d6a3b534ce13547912b6364001ffd1494","src/v0.rs":"4e5bd069aa61def3dc732b3a285861914895272668ddfcb6b9eef46dd5713041"},"package":"d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76"} \ No newline at end of file
diff --git a/vendor/rustc-demangle/Cargo.toml b/vendor/rustc-demangle/Cargo.toml
index 2253b63b1..61238e3f0 100644
--- a/vendor/rustc-demangle/Cargo.toml
+++ b/vendor/rustc-demangle/Cargo.toml
@@ -3,25 +3,35 @@
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
-# to registry (e.g., crates.io) dependencies
+# to registry (e.g., crates.io) dependencies.
#
-# If you believe there's an error in this file please file an
-# issue against the rust-lang/cargo repository. If you're
-# editing this file be aware that the upstream Cargo.toml
-# will likely look very different (and much more reasonable)
+# If you are reading this file be aware that the original Cargo.toml
+# will likely look very different (and much more reasonable).
+# See Cargo.toml.orig for the original contents.
[package]
name = "rustc-demangle"
-version = "0.1.21"
+version = "0.1.23"
authors = ["Alex Crichton <alex@alexcrichton.com>"]
-description = "Rust compiler symbol demangling.\n"
+description = """
+Rust compiler symbol demangling.
+"""
homepage = "https://github.com/alexcrichton/rustc-demangle"
documentation = "https://docs.rs/rustc-demangle"
readme = "README.md"
license = "MIT/Apache-2.0"
repository = "https://github.com/alexcrichton/rustc-demangle"
+
+[package.metadata.docs.rs]
+features = ["std"]
+rustdoc-args = [
+ "--cfg",
+ "docsrs",
+]
+
[profile.release]
lto = true
+
[dependencies.compiler_builtins]
version = "0.1.2"
optional = true
@@ -32,4 +42,8 @@ optional = true
package = "rustc-std-workspace-core"
[features]
-rustc-dep-of-std = ["core", "compiler_builtins"]
+rustc-dep-of-std = [
+ "core",
+ "compiler_builtins",
+]
+std = []
diff --git a/vendor/rustc-demangle/src/lib.rs b/vendor/rustc-demangle/src/lib.rs
index 1ecb13fee..cafec2f92 100644
--- a/vendor/rustc-demangle/src/lib.rs
+++ b/vendor/rustc-demangle/src/lib.rs
@@ -25,8 +25,9 @@
#![no_std]
#![deny(missing_docs)]
+#![cfg_attr(docsrs, feature(doc_cfg))]
-#[cfg(test)]
+#[cfg(any(test, feature = "std"))]
#[macro_use]
extern crate std;
@@ -144,6 +145,75 @@ pub fn demangle(mut s: &str) -> Demangle {
}
}
+#[cfg(feature = "std")]
+fn demangle_line(
+ line: &str,
+ output: &mut impl std::io::Write,
+ include_hash: bool,
+) -> std::io::Result<()> {
+ let mut head = 0;
+ while head < line.len() {
+ // Move to the next potential match
+ let next_head = match (line[head..].find("_ZN"), line[head..].find("_R")) {
+ (Some(idx), None) | (None, Some(idx)) => head + idx,
+ (Some(idx1), Some(idx2)) => head + idx1.min(idx2),
+ (None, None) => {
+ // No more matches...
+ line.len()
+ }
+ };
+ output.write_all(line[head..next_head].as_bytes())?;
+ head = next_head;
+ // Find the non-matching character.
+ //
+ // If we do not find a character, then until the end of the line is the
+ // thing to demangle.
+ let match_end = line[head..]
+ .find(|ch: char| !(ch == '$' || ch == '.' || ch == '_' || ch.is_ascii_alphanumeric()))
+ .map(|idx| head + idx)
+ .unwrap_or(line.len());
+
+ let mangled = &line[head..match_end];
+ head = head + mangled.len();
+ if let Ok(demangled) = try_demangle(mangled) {
+ if include_hash {
+ write!(output, "{}", demangled)?;
+ } else {
+ write!(output, "{:#}", demangled)?;
+ }
+ } else {
+ output.write_all(mangled.as_bytes())?;
+ }
+ }
+ Ok(())
+}
+
+/// Process a stream of data from `input` into the provided `output`, demangling any symbols found
+/// within.
+///
+/// Note that the underlying implementation will perform many relatively small writes to the
+/// output. If the output is expensive to write to (e.g., requires syscalls), consider using
+/// `std::io::BufWriter`.
+#[cfg(feature = "std")]
+#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
+pub fn demangle_stream<R: std::io::BufRead, W: std::io::Write>(
+ input: &mut R,
+ output: &mut W,
+ include_hash: bool,
+) -> std::io::Result<()> {
+ let mut buf = std::string::String::new();
+ // We read in lines to reduce the memory usage at any time.
+ //
+ // demangle_line is also more efficient with relatively small buffers as it will copy around
+ // trailing data during demangling. In the future we might directly stream to the output but at
+ // least right now that seems to be less efficient.
+ while input.read_line(&mut buf)? > 0 {
+ demangle_line(&buf, output, include_hash)?;
+ buf.clear();
+ }
+ Ok(())
+}
+
/// Error returned from the `try_demangle` function below when demangling fails.
#[derive(Debug, Clone)]
pub struct TryDemangleError {
@@ -490,4 +560,29 @@ mod tests {
"{size limit reached}"
);
}
+
+ #[cfg(feature = "std")]
+ fn demangle_str(input: &str) -> String {
+ let mut output = Vec::new();
+ super::demangle_line(input, &mut output, false);
+ String::from_utf8(output).unwrap()
+ }
+
+ #[test]
+ #[cfg(feature = "std")]
+ fn find_multiple() {
+ assert_eq!(
+ demangle_str("_ZN3fooE.llvm moocow _ZN3fooE.llvm"),
+ "foo.llvm moocow foo.llvm"
+ );
+ }
+
+ #[test]
+ #[cfg(feature = "std")]
+ fn interleaved_new_legacy() {
+ assert_eq!(
+ demangle_str("_ZN3fooE.llvm moocow _RNvMNtNtNtNtCs8a2262Dv4r_3mio3sys4unix8selector5epollNtB2_8Selector6select _ZN3fooE.llvm"),
+ "foo.llvm moocow <mio::sys::unix::selector::epoll::Selector>::select foo.llvm"
+ );
+ }
}