diff --git a/Cargo.lock b/Cargo.lock
index 833356011964..7db952ef55d0 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -3356,9 +3356,9 @@ dependencies = [
[[package]]
name = "rustc-demangle"
-version = "0.1.26"
+version = "0.1.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "56f7d92ca342cea22a06f2121d944b4fd82af56988c270852495420f961d4ace"
+checksum = "b50b8869d9fc858ce7266cce0194bd74df58b9d0e3f6df3a9fc8eb470d95c09d"
[[package]]
name = "rustc-hash"
diff --git a/compiler/rustc_symbol_mangling/Cargo.toml b/compiler/rustc_symbol_mangling/Cargo.toml
index 0df9c7682bf8..d28eb3f04706 100644
--- a/compiler/rustc_symbol_mangling/Cargo.toml
+++ b/compiler/rustc_symbol_mangling/Cargo.toml
@@ -6,7 +6,7 @@ edition = "2024"
[dependencies]
# tidy-alphabetical-start
punycode = "0.4.0"
-rustc-demangle = "0.1.21"
+rustc-demangle = "0.1.27"
rustc_abi = { path = "../rustc_abi" }
rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" }
diff --git a/compiler/rustc_symbol_mangling/src/v0.rs b/compiler/rustc_symbol_mangling/src/v0.rs
index 755b4923e9cd..95cbb9e07ebb 100644
--- a/compiler/rustc_symbol_mangling/src/v0.rs
+++ b/compiler/rustc_symbol_mangling/src/v0.rs
@@ -648,7 +648,10 @@ impl<'tcx> Printer<'tcx> for V0SymbolMangler<'tcx> {
p.push_ident(name.as_str());
match projection.term.kind() {
ty::TermKind::Ty(ty) => ty.print(p),
- ty::TermKind::Const(c) => c.print(p),
+ ty::TermKind::Const(c) => {
+ p.push("K");
+ c.print(p)
+ }
}?;
}
ty::ExistentialPredicate::AutoTrait(def_id) => {
diff --git a/src/doc/rustc/src/symbol-mangling/v0.md b/src/doc/rustc/src/symbol-mangling/v0.md
index 2bcc453a5326..89d10658bb7e 100644
--- a/src/doc/rustc/src/symbol-mangling/v0.md
+++ b/src/doc/rustc/src/symbol-mangling/v0.md
@@ -857,7 +857,11 @@ Remaining primitives are encoded as a crate production, e.g. `C4f128`.
>
> dyn-trait → *[path]* {*[dyn-trait-assoc-binding]*}
>
- > dyn-trait-assoc-binding → `p` *[undisambiguated-identifier]* *[type]*
+ > dyn-trait-assoc-binding → `p` *[undisambiguated-identifier]* *[type-or-const]*
+ >
+ > type-or-const → \
+ > *[type]* \
+ > | `K` *[const]*
The tag `D` is followed by a *[dyn-bounds]* which encodes the trait bounds,
followed by a *[lifetime]* of the trait object lifetime bound.
@@ -867,11 +871,12 @@ Remaining primitives are encoded as a crate production, e.g. `C4f128`.
Each *[dyn-trait]* represents a trait bound, which consists of a *[path]* to the trait followed by zero or more *[dyn-trait-assoc-binding]* which list the associated types.
- Each *[dyn-trait-assoc-binding]* consists of a character `p` followed a *[undisambiguated-identifier]* representing the associated binding name, and finally a *[type]*.
+ Each *[dyn-trait-assoc-binding]* consists of a character `p` followed a *[undisambiguated-identifier]* representing the associated binding name, and finally a *[type-or-const]*.
[dyn-bounds]: #dyn-bounds
[dyn-trait]: #dyn-trait
[dyn-trait-assoc-binding]: #dyn-trait-assoc-binding
+[type-or-const]: #type-or-const
* A *[path]* to a named type.
diff --git a/tests/ui/const-generics/associated-const-bindings/dyn-compat-symbol-mangling.rs b/tests/ui/const-generics/associated-const-bindings/dyn-compat-symbol-mangling.rs
new file mode 100644
index 000000000000..18be0fccc051
--- /dev/null
+++ b/tests/ui/const-generics/associated-const-bindings/dyn-compat-symbol-mangling.rs
@@ -0,0 +1,28 @@
+// Ensure that we can successfully mangle & demangle trait object types w/ assoc const bindings.
+
+// FIXME(mgca): Legacy mangling still crashes:
+// "finding type for [impl], encountered [crate root] with no parent"
+
+//@ build-fail
+//@ revisions: v0
+//\@[legacy] compile-flags: -C symbol-mangling-version=legacy -Z unstable-options
+//@ [v0] compile-flags: -C symbol-mangling-version=v0
+//\@[legacy] normalize-stderr: "h[[:xdigit:]]{16}" -> "h[HASH]"
+//@ [v0] normalize-stderr: "sym\[.*?\]" -> "sym[HASH]"
+
+#![feature(min_generic_const_args, rustc_attrs)]
+#![expect(incomplete_features)]
+#![crate_name = "sym"]
+
+trait Trait {
+ #[type_const]
+ const N: usize;
+}
+
+#[rustc_symbol_name]
+//~^ ERROR symbol-name(_RMCs
+//~| ERROR demangling(>)
+impl dyn Trait {}
+
+fn main() {}
diff --git a/tests/ui/const-generics/associated-const-bindings/dyn-compat-symbol-mangling.v0.stderr b/tests/ui/const-generics/associated-const-bindings/dyn-compat-symbol-mangling.v0.stderr
new file mode 100644
index 000000000000..424251acc3e9
--- /dev/null
+++ b/tests/ui/const-generics/associated-const-bindings/dyn-compat-symbol-mangling.v0.stderr
@@ -0,0 +1,20 @@
+error: symbol-name(_RMCsCRATE_HASH_3symDNtB[_5Traitp1NKj0_EL_)
+ --> $DIR/dyn-compat-symbol-mangling.rs:22:1
+ |
+LL | #[rustc_symbol_name]
+ | ^^^^^^^^^^^^^^^^^^^^
+
+error: demangling(>)
+ --> $DIR/dyn-compat-symbol-mangling.rs:22:1
+ |
+LL | #[rustc_symbol_name]
+ | ^^^^^^^^^^^^^^^^^^^^
+
+error: demangling-alt(>)
+ --> $DIR/dyn-compat-symbol-mangling.rs:22:1
+ |
+LL | #[rustc_symbol_name]
+ | ^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 3 previous errors
+
]