Auto merge of #87194 - eddyb:const-value-mangling, r=michaelwoerister,oli-obk
rustc_symbol_mangling: support structural constants and &str in v0. This PR should unblock #85530 (except for float `const` generics, which AFAIK should've never worked). (cc `@tmiasko` could the https://github.com/rust-lang/rust/pull/85530#issuecomment-857855379 failures be retried with a quick crater "subset" run of this PR + changing the default to `v0`? Just to make sure I didn't miss anything other than the floats) The encoding is the one suggested before in e.g. https://github.com/rust-lang/rust/issues/61486#issuecomment-878932102, tho this PR won't by itself finish #61486, before closing that we'd likely want to move to `@oli-obk's` "valtrees" (i.e. #83234 and other associated work). <hr> **EDITs**: 1. switched unit/tuple/braced-with-named-fields `<const-fields>` prefixes from `"u"`/`"T"`/`""` to `"U"`/`"T"`/`"S"` to avoid the ambiguity reported by `@tmiasko` in https://github.com/rust-lang/rust/pull/87194#issuecomment-884279921. 2. `rustc-demangle` PR: https://github.com/alexcrichton/rustc-demangle/pull/55 3. RFC amendment PR: https://github.com/rust-lang/rfcs/pull/3161 * also removed the grammar changes included in that PR, from this description 4. added tests (temporarily using my fork of `rustc-demangle`) <hr> r? `@michaelwoerister`
This commit is contained in:
commit
ad02dc46ba
21 changed files with 609 additions and 63 deletions
|
@ -1220,13 +1220,20 @@ pub trait PrettyPrinter<'tcx>:
|
|||
}
|
||||
p!(")");
|
||||
}
|
||||
ty::Adt(def, substs) if def.variants.is_empty() => {
|
||||
p!(print_value_path(def.did, substs));
|
||||
ty::Adt(def, _) if def.variants.is_empty() => {
|
||||
self = self.typed_value(
|
||||
|mut this| {
|
||||
write!(this, "unreachable()")?;
|
||||
Ok(this)
|
||||
},
|
||||
|this| this.print_type(ty),
|
||||
": ",
|
||||
)?;
|
||||
}
|
||||
ty::Adt(def, substs) => {
|
||||
let variant_id =
|
||||
contents.variant.expect("destructed const of adt without variant id");
|
||||
let variant_def = &def.variants[variant_id];
|
||||
let variant_idx =
|
||||
contents.variant.expect("destructed const of adt without variant idx");
|
||||
let variant_def = &def.variants[variant_idx];
|
||||
p!(print_value_path(variant_def.def_id, substs));
|
||||
|
||||
match variant_def.ctor_kind {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue