Skip to content

Commit f0c4da4

Browse files
committedMar 1, 2022
Auto merge of rust-lang#94477 - matthiaskrgr:rollup-8h29qek, r=matthiaskrgr
Rollup of 3 pull requests Successful merges: - rust-lang#94359 (Fix inconsistent symbol mangling of integers constants with -Zverbose) - rust-lang#94465 (6 - Make more use of `let_chains`) - rust-lang#94470 (:arrow_up: rust-analyzer) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 4a56cbe + 2091f2a commit f0c4da4

17 files changed

+1435
-220
lines changed
 

‎compiler/rustc_mir_build/src/build/expr/stmt.rs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -116,22 +116,20 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
116116
// it is usually better to focus on `the_value` rather
117117
// than the entirety of block(s) surrounding it.
118118
let adjusted_span = (|| {
119-
if let ExprKind::Block { body } = &expr.kind {
120-
if let Some(tail_expr) = body.expr {
121-
let mut expr = &this.thir[tail_expr];
122-
while let ExprKind::Block {
123-
body: Block { expr: Some(nested_expr), .. },
124-
}
125-
| ExprKind::Scope { value: nested_expr, .. } = expr.kind
126-
{
127-
expr = &this.thir[nested_expr];
128-
}
129-
this.block_context.push(BlockFrame::TailExpr {
130-
tail_result_is_ignored: true,
131-
span: expr.span,
132-
});
133-
return Some(expr.span);
119+
if let ExprKind::Block { body } = &expr.kind && let Some(tail_ex) = body.expr {
120+
let mut expr = &this.thir[tail_ex];
121+
while let ExprKind::Block {
122+
body: Block { expr: Some(nested_expr), .. },
134123
}
124+
| ExprKind::Scope { value: nested_expr, .. } = expr.kind
125+
{
126+
expr = &this.thir[nested_expr];
127+
}
128+
this.block_context.push(BlockFrame::TailExpr {
129+
tail_result_is_ignored: true,
130+
span: expr.span,
131+
});
132+
return Some(expr.span);
135133
}
136134
None
137135
})();

‎compiler/rustc_mir_build/src/build/matches/mod.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1597,13 +1597,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
15971597
}
15981598

15991599
// Insert a Shallow borrow of any places that is switched on.
1600-
if let Some(fb) = fake_borrows {
1601-
if let Ok(match_place_resolved) =
1602-
match_place.clone().try_upvars_resolved(self.tcx, self.typeck_results)
1603-
{
1604-
let resolved_place = match_place_resolved.into_place(self.tcx, self.typeck_results);
1605-
fb.insert(resolved_place);
1606-
}
1600+
if let Some(fb) = fake_borrows && let Ok(match_place_resolved) =
1601+
match_place.clone().try_upvars_resolved(self.tcx, self.typeck_results)
1602+
{
1603+
let resolved_place = match_place_resolved.into_place(self.tcx, self.typeck_results);
1604+
fb.insert(resolved_place);
16071605
}
16081606

16091607
// perform the test, branching to one of N blocks. For each of

‎compiler/rustc_mir_build/src/build/mod.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -877,14 +877,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
877877
let arg_local = self.local_decls.push(LocalDecl::with_source_info(ty, source_info));
878878

879879
// If this is a simple binding pattern, give debuginfo a nice name.
880-
if let Some(arg) = arg_opt {
881-
if let Some(ident) = arg.pat.simple_ident() {
882-
self.var_debug_info.push(VarDebugInfo {
883-
name: ident.name,
884-
source_info,
885-
value: VarDebugInfoContents::Place(arg_local.into()),
886-
});
887-
}
880+
if let Some(arg) = arg_opt && let Some(ident) = arg.pat.simple_ident() {
881+
self.var_debug_info.push(VarDebugInfo {
882+
name: ident.name,
883+
source_info,
884+
value: VarDebugInfoContents::Place(arg_local.into()),
885+
});
888886
}
889887
}
890888

‎compiler/rustc_mir_build/src/check_unsafety.rs

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -416,23 +416,21 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> {
416416
}
417417
ExprKind::Field { lhs, .. } => {
418418
let lhs = &self.thir[lhs];
419-
if let ty::Adt(adt_def, _) = lhs.ty.kind() {
420-
if adt_def.is_union() {
421-
if let Some((assigned_ty, assignment_span)) = self.assignment_info {
422-
// To avoid semver hazard, we only consider `Copy` and `ManuallyDrop` non-dropping.
423-
if !(assigned_ty
424-
.ty_adt_def()
425-
.map_or(false, |adt| adt.is_manually_drop())
426-
|| assigned_ty
427-
.is_copy_modulo_regions(self.tcx.at(expr.span), self.param_env))
428-
{
429-
self.requires_unsafe(assignment_span, AssignToDroppingUnionField);
430-
} else {
431-
// write to non-drop union field, safe
432-
}
419+
if let ty::Adt(adt_def, _) = lhs.ty.kind() && adt_def.is_union() {
420+
if let Some((assigned_ty, assignment_span)) = self.assignment_info {
421+
// To avoid semver hazard, we only consider `Copy` and `ManuallyDrop` non-dropping.
422+
if !(assigned_ty
423+
.ty_adt_def()
424+
.map_or(false, |adt| adt.is_manually_drop())
425+
|| assigned_ty
426+
.is_copy_modulo_regions(self.tcx.at(expr.span), self.param_env))
427+
{
428+
self.requires_unsafe(assignment_span, AssignToDroppingUnionField);
433429
} else {
434-
self.requires_unsafe(expr.span, AccessToUnionField);
430+
// write to non-drop union field, safe
435431
}
432+
} else {
433+
self.requires_unsafe(expr.span, AccessToUnionField);
436434
}
437435
}
438436
}
@@ -476,10 +474,8 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> {
476474
}
477475
ExprKind::Let { expr: expr_id, .. } => {
478476
let let_expr = &self.thir[expr_id];
479-
if let ty::Adt(adt_def, _) = let_expr.ty.kind() {
480-
if adt_def.is_union() {
481-
self.requires_unsafe(expr.span, AccessToUnionField);
482-
}
477+
if let ty::Adt(adt_def, _) = let_expr.ty.kind() && adt_def.is_union() {
478+
self.requires_unsafe(expr.span, AccessToUnionField);
483479
}
484480
}
485481
_ => {}

‎compiler/rustc_mir_build/src/lib.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
//! Construction of MIR from HIR.
22
//!
33
//! This crate also contains the match exhaustiveness and usefulness checking.
4+
#![allow(rustc::potential_query_instability)]
5+
#![feature(bool_to_option)]
46
#![feature(box_patterns)]
57
#![feature(control_flow_enum)]
68
#![feature(crate_visibility_modifier)]
7-
#![feature(bool_to_option)]
9+
#![feature(let_chains)]
810
#![feature(let_else)]
9-
#![feature(once_cell)]
1011
#![feature(min_specialization)]
12+
#![feature(once_cell)]
1113
#![recursion_limit = "256"]
12-
#![allow(rustc::potential_query_instability)]
1314

1415
#[macro_use]
1516
extern crate tracing;

‎compiler/rustc_mir_build/src/thir/pattern/check_match.rs

Lines changed: 36 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -315,47 +315,43 @@ fn check_for_bindings_named_same_as_variants(
315315
rf: RefutableFlag,
316316
) {
317317
pat.walk_always(|p| {
318-
if let hir::PatKind::Binding(_, _, ident, None) = p.kind {
319-
if let Some(ty::BindByValue(hir::Mutability::Not)) =
318+
if let hir::PatKind::Binding(_, _, ident, None) = p.kind
319+
&& let Some(ty::BindByValue(hir::Mutability::Not)) =
320320
cx.typeck_results.extract_binding_mode(cx.tcx.sess, p.hir_id, p.span)
321-
{
322-
let pat_ty = cx.typeck_results.pat_ty(p).peel_refs();
323-
if let ty::Adt(edef, _) = pat_ty.kind() {
324-
if edef.is_enum()
325-
&& edef.variants.iter().any(|variant| {
326-
variant.ident(cx.tcx) == ident && variant.ctor_kind == CtorKind::Const
327-
})
328-
{
329-
let variant_count = edef.variants.len();
330-
cx.tcx.struct_span_lint_hir(
331-
BINDINGS_WITH_VARIANT_NAME,
332-
p.hir_id,
321+
&& let pat_ty = cx.typeck_results.pat_ty(p).peel_refs()
322+
&& let ty::Adt(edef, _) = pat_ty.kind()
323+
&& edef.is_enum()
324+
&& edef.variants.iter().any(|variant| {
325+
variant.ident(cx.tcx) == ident && variant.ctor_kind == CtorKind::Const
326+
})
327+
{
328+
let variant_count = edef.variants.len();
329+
cx.tcx.struct_span_lint_hir(
330+
BINDINGS_WITH_VARIANT_NAME,
331+
p.hir_id,
332+
p.span,
333+
|lint| {
334+
let ty_path = cx.tcx.def_path_str(edef.did);
335+
let mut err = lint.build(&format!(
336+
"pattern binding `{}` is named the same as one \
337+
of the variants of the type `{}`",
338+
ident, ty_path
339+
));
340+
err.code(error_code!(E0170));
341+
// If this is an irrefutable pattern, and there's > 1 variant,
342+
// then we can't actually match on this. Applying the below
343+
// suggestion would produce code that breaks on `check_irrefutable`.
344+
if rf == Refutable || variant_count == 1 {
345+
err.span_suggestion(
333346
p.span,
334-
|lint| {
335-
let ty_path = cx.tcx.def_path_str(edef.did);
336-
let mut err = lint.build(&format!(
337-
"pattern binding `{}` is named the same as one \
338-
of the variants of the type `{}`",
339-
ident, ty_path
340-
));
341-
err.code(error_code!(E0170));
342-
// If this is an irrefutable pattern, and there's > 1 variant,
343-
// then we can't actually match on this. Applying the below
344-
// suggestion would produce code that breaks on `check_irrefutable`.
345-
if rf == Refutable || variant_count == 1 {
346-
err.span_suggestion(
347-
p.span,
348-
"to match on the variant, qualify the path",
349-
format!("{}::{}", ty_path, ident),
350-
Applicability::MachineApplicable,
351-
);
352-
}
353-
err.emit();
354-
},
355-
)
347+
"to match on the variant, qualify the path",
348+
format!("{}::{}", ty_path, ident),
349+
Applicability::MachineApplicable,
350+
);
356351
}
357-
}
358-
}
352+
err.emit();
353+
},
354+
)
359355
}
360356
});
361357
}
@@ -622,10 +618,8 @@ fn maybe_point_at_variant<'a, 'p: 'a, 'tcx: 'a>(
622618
let mut covered = vec![];
623619
for pattern in patterns {
624620
if let Variant(variant_index) = pattern.ctor() {
625-
if let ty::Adt(this_def, _) = pattern.ty().kind() {
626-
if this_def.did != def.did {
627-
continue;
628-
}
621+
if let ty::Adt(this_def, _) = pattern.ty().kind() && this_def.did != def.did {
622+
continue;
629623
}
630624
let sp = def.variants[*variant_index].ident(cx.tcx).span;
631625
if covered.contains(&sp) {

‎compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -680,27 +680,23 @@ impl<'tcx> Constructor<'tcx> {
680680
///
681681
/// This means that the variant has a stdlib unstable feature marking it.
682682
pub(super) fn is_unstable_variant(&self, pcx: PatCtxt<'_, '_, 'tcx>) -> bool {
683-
if let Constructor::Variant(idx) = self {
684-
if let ty::Adt(adt, _) = pcx.ty.kind() {
685-
let variant_def_id = adt.variants[*idx].def_id;
686-
// Filter variants that depend on a disabled unstable feature.
687-
return matches!(
688-
pcx.cx.tcx.eval_stability(variant_def_id, None, DUMMY_SP, None),
689-
EvalResult::Deny { .. }
690-
);
691-
}
683+
if let Constructor::Variant(idx) = self && let ty::Adt(adt, _) = pcx.ty.kind() {
684+
let variant_def_id = adt.variants[*idx].def_id;
685+
// Filter variants that depend on a disabled unstable feature.
686+
return matches!(
687+
pcx.cx.tcx.eval_stability(variant_def_id, None, DUMMY_SP, None),
688+
EvalResult::Deny { .. }
689+
);
692690
}
693691
false
694692
}
695693

696694
/// Checks if the `Constructor` is a `Constructor::Variant` with a `#[doc(hidden)]`
697695
/// attribute.
698696
pub(super) fn is_doc_hidden_variant(&self, pcx: PatCtxt<'_, '_, 'tcx>) -> bool {
699-
if let Constructor::Variant(idx) = self {
700-
if let ty::Adt(adt, _) = pcx.ty.kind() {
701-
let variant_def_id = adt.variants[*idx].def_id;
702-
return pcx.cx.tcx.is_doc_hidden(variant_def_id);
703-
}
697+
if let Constructor::Variant(idx) = self && let ty::Adt(adt, _) = pcx.ty.kind() {
698+
let variant_def_id = adt.variants[*idx].def_id;
699+
return pcx.cx.tcx.is_doc_hidden(variant_def_id);
704700
}
705701
false
706702
}

‎compiler/rustc_mir_build/src/thir/pattern/mod.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -790,16 +790,14 @@ crate fn compare_const_vals<'tcx>(
790790
};
791791
}
792792

793-
if let ty::Str = ty.kind() {
794-
if let (
795-
ty::ConstKind::Value(a_val @ ConstValue::Slice { .. }),
796-
ty::ConstKind::Value(b_val @ ConstValue::Slice { .. }),
797-
) = (a.val(), b.val())
798-
{
799-
let a_bytes = get_slice_bytes(&tcx, a_val);
800-
let b_bytes = get_slice_bytes(&tcx, b_val);
801-
return from_bool(a_bytes == b_bytes);
802-
}
793+
if let ty::Str = ty.kind() && let (
794+
ty::ConstKind::Value(a_val @ ConstValue::Slice { .. }),
795+
ty::ConstKind::Value(b_val @ ConstValue::Slice { .. }),
796+
) = (a.val(), b.val())
797+
{
798+
let a_bytes = get_slice_bytes(&tcx, a_val);
799+
let b_bytes = get_slice_bytes(&tcx, b_val);
800+
return from_bool(a_bytes == b_bytes);
803801
}
804802
fallback()
805803
}

‎compiler/rustc_symbol_mangling/src/legacy.rs

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,14 +216,32 @@ impl<'tcx> Printer<'tcx> for &mut SymbolPrinter<'tcx> {
216216
Ok(self)
217217
}
218218

219-
fn print_type(self, ty: Ty<'tcx>) -> Result<Self::Type, Self::Error> {
219+
fn print_type(mut self, ty: Ty<'tcx>) -> Result<Self::Type, Self::Error> {
220220
match *ty.kind() {
221221
// Print all nominal types as paths (unlike `pretty_print_type`).
222222
ty::FnDef(def_id, substs)
223223
| ty::Opaque(def_id, substs)
224224
| ty::Projection(ty::ProjectionTy { item_def_id: def_id, substs })
225225
| ty::Closure(def_id, substs)
226226
| ty::Generator(def_id, substs, _) => self.print_def_path(def_id, substs),
227+
228+
// The `pretty_print_type` formatting of array size depends on
229+
// -Zverbose flag, so we cannot reuse it here.
230+
ty::Array(ty, size) => {
231+
self.write_str("[")?;
232+
self = self.print_type(ty)?;
233+
self.write_str("; ")?;
234+
if let Some(size) = size.val().try_to_bits(self.tcx().data_layout.pointer_size) {
235+
write!(self, "{}", size)?
236+
} else if let ty::ConstKind::Param(param) = size.val() {
237+
self = param.print(self)?
238+
} else {
239+
self.write_str("_")?
240+
}
241+
self.write_str("]")?;
242+
Ok(self)
243+
}
244+
227245
_ => self.pretty_print_type(ty),
228246
}
229247
}
@@ -245,12 +263,22 @@ impl<'tcx> Printer<'tcx> for &mut SymbolPrinter<'tcx> {
245263

246264
fn print_const(self, ct: ty::Const<'tcx>) -> Result<Self::Const, Self::Error> {
247265
// only print integers
248-
if let ty::ConstKind::Value(ConstValue::Scalar(Scalar::Int { .. })) = ct.val() {
249-
if ct.ty().is_integral() {
250-
return self.pretty_print_const(ct, true);
266+
match (ct.val(), ct.ty().kind()) {
267+
(
268+
ty::ConstKind::Value(ConstValue::Scalar(Scalar::Int(scalar))),
269+
ty::Int(_) | ty::Uint(_),
270+
) => {
271+
// The `pretty_print_const` formatting depends on -Zverbose
272+
// flag, so we cannot reuse it here.
273+
let signed = matches!(ct.ty().kind(), ty::Int(_));
274+
write!(
275+
self,
276+
"{:#?}",
277+
ty::ConstInt::new(scalar, signed, ct.ty().is_ptr_sized_integral())
278+
)?;
251279
}
280+
_ => self.write_str("_")?,
252281
}
253-
self.write_str("_")?;
254282
Ok(self)
255283
}
256284

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
error: symbol-name(_ZN1c21Unsigned$LT$11_u8$GT$1f17h[HASH]E)
2+
--> $DIR/const-generics-demangling.rs:13:5
3+
|
4+
LL | #[rustc_symbol_name]
5+
| ^^^^^^^^^^^^^^^^^^^^
6+
7+
error: demangling(c::Unsigned<11_u8>::f::h[HASH])
8+
--> $DIR/const-generics-demangling.rs:13:5
9+
|
10+
LL | #[rustc_symbol_name]
11+
| ^^^^^^^^^^^^^^^^^^^^
12+
13+
error: demangling-alt(c::Unsigned<11_u8>::f)
14+
--> $DIR/const-generics-demangling.rs:13:5
15+
|
16+
LL | #[rustc_symbol_name]
17+
| ^^^^^^^^^^^^^^^^^^^^
18+
19+
error: symbol-name(_ZN1c22Signed$LT$.152_i16$GT$1f17h[HASH]E)
20+
--> $DIR/const-generics-demangling.rs:26:5
21+
|
22+
LL | #[rustc_symbol_name]
23+
| ^^^^^^^^^^^^^^^^^^^^
24+
25+
error: demangling(c::Signed<.152_i16>::f::h[HASH])
26+
--> $DIR/const-generics-demangling.rs:26:5
27+
|
28+
LL | #[rustc_symbol_name]
29+
| ^^^^^^^^^^^^^^^^^^^^
30+
31+
error: demangling-alt(c::Signed<.152_i16>::f)
32+
--> $DIR/const-generics-demangling.rs:26:5
33+
|
34+
LL | #[rustc_symbol_name]
35+
| ^^^^^^^^^^^^^^^^^^^^
36+
37+
error: symbol-name(_ZN1c13Bool$LT$_$GT$1f17h[HASH]E)
38+
--> $DIR/const-generics-demangling.rs:39:5
39+
|
40+
LL | #[rustc_symbol_name]
41+
| ^^^^^^^^^^^^^^^^^^^^
42+
43+
error: demangling(c::Bool<_>::f::h[HASH])
44+
--> $DIR/const-generics-demangling.rs:39:5
45+
|
46+
LL | #[rustc_symbol_name]
47+
| ^^^^^^^^^^^^^^^^^^^^
48+
49+
error: demangling-alt(c::Bool<_>::f)
50+
--> $DIR/const-generics-demangling.rs:39:5
51+
|
52+
LL | #[rustc_symbol_name]
53+
| ^^^^^^^^^^^^^^^^^^^^
54+
55+
error: symbol-name(_ZN1c13Char$LT$_$GT$1f17h[HASH]E)
56+
--> $DIR/const-generics-demangling.rs:52:5
57+
|
58+
LL | #[rustc_symbol_name]
59+
| ^^^^^^^^^^^^^^^^^^^^
60+
61+
error: demangling(c::Char<_>::f::h[HASH])
62+
--> $DIR/const-generics-demangling.rs:52:5
63+
|
64+
LL | #[rustc_symbol_name]
65+
| ^^^^^^^^^^^^^^^^^^^^
66+
67+
error: demangling-alt(c::Char<_>::f)
68+
--> $DIR/const-generics-demangling.rs:52:5
69+
|
70+
LL | #[rustc_symbol_name]
71+
| ^^^^^^^^^^^^^^^^^^^^
72+
73+
error: aborting due to 12 previous errors
74+
Lines changed: 46 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,62 @@
11
// build-fail
2-
// compile-flags: -C symbol-mangling-version=v0 --crate-name=c
3-
// normalize-stderr-test: "c\[.*?\]" -> "c[HASH]"
2+
// revisions: legacy v0
3+
// compile-flags: --crate-name=c
4+
//[legacy]compile-flags: -C symbol-mangling-version=legacy -Z unstable-options
5+
// [v0]compile-flags: -C symbol-mangling-version=v0
6+
//[legacy]normalize-stderr-test: "h[[:xdigit:]]{16}" -> "h[HASH]"
7+
// [v0]normalize-stderr-test: "c\[.*?\]" -> "c[HASH]"
48
#![feature(rustc_attrs)]
59

610
pub struct Unsigned<const F: u8>;
711

8-
#[rustc_symbol_name]
9-
//~^ ERROR symbol-name(_RMCs
10-
//~| ERROR demangling(<c[
11-
//~| ERROR demangling-alt(<c::Unsigned<11>>)
12-
impl Unsigned<11> {}
12+
impl Unsigned<11> {
13+
#[rustc_symbol_name]
14+
//[v0]~^ ERROR symbol-name(_RNvMCs
15+
//[v0]~| ERROR demangling(<c[
16+
//[v0]~| ERROR demangling-alt(<c::Unsigned<11>>::f)
17+
//[legacy]~^^^^ ERROR symbol-name(_ZN1c21Unsigned$LT$11_u8$GT$
18+
//[legacy]~| ERROR demangling(c::Unsigned<11_u8>::f::
19+
//[legacy]~| ERROR demangling-alt(c::Unsigned<11_u8>::f)
20+
fn f() {}
21+
}
1322

1423
pub struct Signed<const F: i16>;
1524

16-
#[rustc_symbol_name]
17-
//~^ ERROR symbol-name(_RMs_Cs
18-
//~| ERROR demangling(<c[
19-
//~| ERROR demangling-alt(<c::Signed<-152>>)
20-
impl Signed<-152> {}
25+
impl Signed<-152> {
26+
#[rustc_symbol_name]
27+
//[v0]~^ ERROR symbol-name(_RNvMs_Cs
28+
//[v0]~| ERROR demangling(<c[
29+
//[v0]~| ERROR demangling-alt(<c::Signed<-152>>::f)
30+
//[legacy]~^^^^ ERROR symbol-name(_ZN1c22Signed$LT$.152_i16$GT$
31+
//[legacy]~| ERROR demangling(c::Signed<.152_i16>::f::
32+
//[legacy]~| ERROR demangling-alt(c::Signed<.152_i16>::f)
33+
fn f() {}
34+
}
2135

2236
pub struct Bool<const F: bool>;
2337

24-
#[rustc_symbol_name]
25-
//~^ ERROR symbol-name(_RMs0_Cs
26-
//~| ERROR demangling(<c[
27-
//~| ERROR demangling-alt(<c::Bool<true>>)
28-
impl Bool<true> {}
38+
impl Bool<true> {
39+
#[rustc_symbol_name]
40+
//[v0]~^ ERROR symbol-name(_RNvMs0_Cs
41+
//[v0]~| ERROR demangling(<c[
42+
//[v0]~| ERROR demangling-alt(<c::Bool<true>>::f)
43+
//[legacy]~^^^^ ERROR symbol-name(_ZN1c13Bool$LT$_$GT$
44+
//[legacy]~| ERROR demangling(c::Bool<_>::f::
45+
//[legacy]~| ERROR demangling-alt(c::Bool<_>::f)
46+
fn f() {}
47+
}
2948

3049
pub struct Char<const F: char>;
3150

32-
#[rustc_symbol_name]
33-
//~^ ERROR symbol-name(_RMs1_Cs
34-
//~| ERROR demangling(<c[
35-
//~| ERROR demangling-alt(<c::Char<'∂'>>)
36-
impl Char<'∂'> {}
51+
impl Char<'∂'> {
52+
#[rustc_symbol_name]
53+
//[v0]~^ ERROR symbol-name(_RNvMs1_Cs
54+
//[v0]~| ERROR demangling(<c[
55+
//[v0]~| ERROR demangling-alt(<c::Char<'∂'>>::f)
56+
//[legacy]~^^^^ ERROR symbol-name(_ZN1c13Char$LT$_$GT$
57+
//[legacy]~| ERROR demangling(c::Char<_>::f::
58+
//[legacy]~| ERROR demangling-alt(c::Char<_>::f)
59+
fn f() {}
60+
}
3761

3862
fn main() {}

‎src/test/ui/symbol-names/const-generics-demangling.stderr

Lines changed: 0 additions & 74 deletions
This file was deleted.
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
error: symbol-name(_RNvMCsCRATE_HASH_1cINtB<REF>_8UnsignedKhb_E1f)
2+
--> $DIR/const-generics-demangling.rs:13:5
3+
|
4+
LL | #[rustc_symbol_name]
5+
| ^^^^^^^^^^^^^^^^^^^^
6+
7+
error: demangling(<c[HASH]::Unsigned<11u8>>::f)
8+
--> $DIR/const-generics-demangling.rs:13:5
9+
|
10+
LL | #[rustc_symbol_name]
11+
| ^^^^^^^^^^^^^^^^^^^^
12+
13+
error: demangling-alt(<c::Unsigned<11>>::f)
14+
--> $DIR/const-generics-demangling.rs:13:5
15+
|
16+
LL | #[rustc_symbol_name]
17+
| ^^^^^^^^^^^^^^^^^^^^
18+
19+
error: symbol-name(_RNvMs_CsCRATE_HASH_1cINtB<REF>_6SignedKsn98_E1f)
20+
--> $DIR/const-generics-demangling.rs:26:5
21+
|
22+
LL | #[rustc_symbol_name]
23+
| ^^^^^^^^^^^^^^^^^^^^
24+
25+
error: demangling(<c[HASH]::Signed<-152i16>>::f)
26+
--> $DIR/const-generics-demangling.rs:26:5
27+
|
28+
LL | #[rustc_symbol_name]
29+
| ^^^^^^^^^^^^^^^^^^^^
30+
31+
error: demangling-alt(<c::Signed<-152>>::f)
32+
--> $DIR/const-generics-demangling.rs:26:5
33+
|
34+
LL | #[rustc_symbol_name]
35+
| ^^^^^^^^^^^^^^^^^^^^
36+
37+
error: symbol-name(_RNvMs0_CsCRATE_HASH_1cINtB<REF>_4BoolKb1_E1f)
38+
--> $DIR/const-generics-demangling.rs:39:5
39+
|
40+
LL | #[rustc_symbol_name]
41+
| ^^^^^^^^^^^^^^^^^^^^
42+
43+
error: demangling(<c[HASH]::Bool<true>>::f)
44+
--> $DIR/const-generics-demangling.rs:39:5
45+
|
46+
LL | #[rustc_symbol_name]
47+
| ^^^^^^^^^^^^^^^^^^^^
48+
49+
error: demangling-alt(<c::Bool<true>>::f)
50+
--> $DIR/const-generics-demangling.rs:39:5
51+
|
52+
LL | #[rustc_symbol_name]
53+
| ^^^^^^^^^^^^^^^^^^^^
54+
55+
error: symbol-name(_RNvMs1_CsCRATE_HASH_1cINtB<REF>_4CharKc2202_E1f)
56+
--> $DIR/const-generics-demangling.rs:52:5
57+
|
58+
LL | #[rustc_symbol_name]
59+
| ^^^^^^^^^^^^^^^^^^^^
60+
61+
error: demangling(<c[HASH]::Char<'∂'>>::f)
62+
--> $DIR/const-generics-demangling.rs:52:5
63+
|
64+
LL | #[rustc_symbol_name]
65+
| ^^^^^^^^^^^^^^^^^^^^
66+
67+
error: demangling-alt(<c::Char<'∂'>>::f)
68+
--> $DIR/const-generics-demangling.rs:52:5
69+
|
70+
LL | #[rustc_symbol_name]
71+
| ^^^^^^^^^^^^^^^^^^^^
72+
73+
error: aborting due to 12 previous errors
74+

‎src/test/ui/symbol-names/types.legacy.stderr

Lines changed: 470 additions & 0 deletions
Large diffs are not rendered by default.

‎src/test/ui/symbol-names/types.rs

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
// build-fail
2+
// revisions: legacy verbose-legacy
3+
// compile-flags: --crate-name=a -C symbol-mangling-version=legacy -Z unstable-options
4+
//[verbose-legacy]compile-flags: -Zverbose
5+
// normalize-stderr-test: "h[[:xdigit:]]{16}" -> "h[HASH]"
6+
7+
#![feature(never_type)]
8+
#![feature(rustc_attrs)]
9+
10+
pub fn b() {
11+
struct Type<T: ?Sized>(T);
12+
13+
#[rustc_symbol_name]
14+
//~^ ERROR symbol-name(_ZN1a1b16Type$LT$bool$GT$
15+
//~| ERROR demangling(a::b::Type<bool>::
16+
//~| ERROR demangling-alt(a::b::Type<bool>)
17+
impl Type<bool> {}
18+
19+
#[rustc_symbol_name]
20+
//~^ ERROR symbol-name(_ZN1a1b16Type$LT$char$GT$
21+
//~| ERROR demangling(a::b::Type<char>::
22+
//~| ERROR demangling-alt(a::b::Type<char>)
23+
impl Type<char> {}
24+
25+
#[rustc_symbol_name]
26+
//~^ ERROR symbol-name(_ZN1a1b14Type$LT$i8$GT$
27+
//~| ERROR demangling(a::b::Type<i8>::
28+
//~| ERROR demangling-alt(a::b::Type<i8>)
29+
impl Type<i8> {}
30+
31+
#[rustc_symbol_name]
32+
//~^ ERROR symbol-name(_ZN1a1b15Type$LT$i16$GT$
33+
//~| ERROR demangling(a::b::Type<i16>::
34+
//~| ERROR demangling-alt(a::b::Type<i16>)
35+
impl Type<i16> {}
36+
37+
#[rustc_symbol_name]
38+
//~^ ERROR symbol-name(_ZN1a1b15Type$LT$i32$GT$
39+
//~| ERROR demangling(a::b::Type<i32>::
40+
//~| ERROR demangling-alt(a::b::Type<i32>)
41+
impl Type<i32> {}
42+
43+
#[rustc_symbol_name]
44+
//~^ ERROR symbol-name(_ZN1a1b15Type$LT$i64$GT$
45+
//~| ERROR demangling(a::b::Type<i64>::
46+
//~| ERROR demangling-alt(a::b::Type<i64>)
47+
impl Type<i64> {}
48+
49+
#[rustc_symbol_name]
50+
//~^ ERROR symbol-name(_ZN1a1b14Type$LT$u8$GT$
51+
//~| ERROR demangling(a::b::Type<u8>::
52+
//~| ERROR demangling-alt(a::b::Type<u8>)
53+
impl Type<u8> {}
54+
55+
#[rustc_symbol_name]
56+
//~^ ERROR symbol-name(_ZN1a1b15Type$LT$u16$GT$
57+
//~| ERROR demangling(a::b::Type<u16>::
58+
//~| ERROR demangling-alt(a::b::Type<u16>)
59+
impl Type<u16> {}
60+
61+
#[rustc_symbol_name]
62+
//~^ ERROR symbol-name(_ZN1a1b15Type$LT$u32$GT$
63+
//~| ERROR demangling(a::b::Type<u32>::
64+
//~| ERROR demangling-alt(a::b::Type<u32>)
65+
impl Type<u32> {}
66+
67+
#[rustc_symbol_name]
68+
//~^ ERROR symbol-name(_ZN1a1b15Type$LT$u64$GT$
69+
//~| ERROR demangling(a::b::Type<u64>::
70+
//~| ERROR demangling-alt(a::b::Type<u64>)
71+
impl Type<u64> {}
72+
73+
#[rustc_symbol_name]
74+
//~^ ERROR symbol-name(_ZN1a1b15Type$LT$f32$GT$
75+
//~| ERROR demangling(a::b::Type<f32>::
76+
//~| ERROR demangling-alt(a::b::Type<f32>)
77+
impl Type<f32> {}
78+
79+
#[rustc_symbol_name]
80+
//~^ ERROR symbol-name(_ZN1a1b15Type$LT$f64$GT$
81+
//~| ERROR demangling(a::b::Type<f64>::
82+
//~| ERROR demangling-alt(a::b::Type<f64>)
83+
impl Type<f64> {}
84+
85+
#[rustc_symbol_name]
86+
//~^ ERROR symbol-name(_ZN1a1b15Type$LT$str$GT$
87+
//~| ERROR demangling(a::b::Type<str>::
88+
//~| ERROR demangling-alt(a::b::Type<str>)
89+
impl Type<str> {}
90+
91+
#[rustc_symbol_name]
92+
//~^ ERROR symbol-name(_ZN1a1b17Type$LT$$u21$$GT$
93+
//~| ERROR demangling(a::b::Type<!>::
94+
//~| ERROR demangling-alt(a::b::Type<!>)
95+
impl Type<!> {}
96+
97+
#[rustc_symbol_name]
98+
//~^ ERROR symbol-name(_ZN1a1b20Type$LT$$LP$$RP$$GT
99+
//~| ERROR demangling(a::b::Type<()>::
100+
//~| ERROR demangling-alt(a::b::Type<()>)
101+
impl Type<()> {}
102+
103+
#[rustc_symbol_name]
104+
//~^ ERROR symbol-name(_ZN1a1b25Type$LT$$LP$u8$C$$RP$$GT$
105+
//~| ERROR demangling(a::b::Type<(u8,)>::
106+
//~| ERROR demangling-alt(a::b::Type<(u8,)>)
107+
impl Type<(u8,)> {}
108+
109+
#[rustc_symbol_name]
110+
//~^ ERROR symbol-name(_ZN1a1b28Type$LT$$LP$u8$C$u16$RP$$GT$
111+
//~| ERROR demangling(a::b::Type<(u8,u16)>::
112+
//~| ERROR demangling-alt(a::b::Type<(u8,u16)>)
113+
impl Type<(u8,u16)> {}
114+
115+
#[rustc_symbol_name]
116+
//~^ ERROR symbol-name(_ZN1a1b34Type$LT$$LP$u8$C$u16$C$u32$RP$$GT$
117+
//~| ERROR demangling(a::b::Type<(u8,u16,u32)>::
118+
//~| ERROR demangling-alt(a::b::Type<(u8,u16,u32)>)
119+
impl Type<(u8,u16,u32)> {}
120+
121+
#[rustc_symbol_name]
122+
//~^ ERROR symbol-name(_ZN1a1b28Type$LT$$BP$const$u20$u8$GT$
123+
//~| ERROR demangling(a::b::Type<*const u8>::
124+
//~| ERROR demangling-alt(a::b::Type<*const u8>)
125+
impl Type<*const u8> {}
126+
127+
#[rustc_symbol_name]
128+
//~^ ERROR symbol-name(_ZN1a1b26Type$LT$$BP$mut$u20$u8$GT$
129+
//~| ERROR demangling(a::b::Type<*mut u8>::
130+
//~| ERROR demangling-alt(a::b::Type<*mut u8>)
131+
impl Type<*mut u8> {}
132+
133+
#[rustc_symbol_name]
134+
//~^ ERROR symbol-name(_ZN1a1b19Type$LT$$RF$str$GT$
135+
//~| ERROR demangling(a::b::Type<&str>::
136+
//~| ERROR demangling-alt(a::b::Type<&str>)
137+
impl Type<&str> {}
138+
139+
#[rustc_symbol_name]
140+
//~^ ERROR symbol-name(_ZN1a1b27Type$LT$$RF$mut$u20$str$GT$
141+
//~| ERROR demangling(a::b::Type<&mut str>::
142+
//~| ERROR demangling-alt(a::b::Type<&mut str>)
143+
impl Type<&mut str> {}
144+
145+
#[rustc_symbol_name]
146+
//~^ ERROR symbol-name(_ZN1a1b35Type$LT$$u5b$u8$u3b$$u20$0$u5d$$GT$
147+
//~| ERROR demangling(a::b::Type<[u8; 0]>::
148+
//~| ERROR demangling-alt(a::b::Type<[u8; 0]>)
149+
impl Type<[u8; 0]> {}
150+
151+
#[rustc_symbol_name]
152+
//~^ ERROR symbol-name(_ZN1a1b22Type$LT$fn$LP$$RP$$GT$
153+
//~| ERROR demangling(a::b::Type<fn()>::
154+
//~| ERROR demangling-alt(a::b::Type<fn()>)
155+
impl Type<fn()> {}
156+
157+
#[rustc_symbol_name]
158+
//~^ ERROR symbol-name(_ZN1a1b60Type$LT$unsafe$u20$extern$u20$$u22$C$u22$$u20$fn$LP$$RP$$GT$
159+
//~| ERROR demangling(a::b::Type<unsafe extern "C" fn()>::
160+
//~| ERROR demangling-alt(a::b::Type<unsafe extern "C" fn()>)
161+
impl Type<unsafe extern "C" fn()> {}
162+
163+
#[rustc_symbol_name]
164+
//~^ ERROR symbol-name(_ZN1a1b34Type$LT$$u5b$T$u3b$$u20$N$u5d$$GT$
165+
//~| ERROR demangling(a::b::Type<[T; N]>::
166+
//~| ERROR demangling-alt(a::b::Type<[T; N]>)
167+
impl<const N: usize, T> Type<[T; N]> {}
168+
}
169+
170+
fn main() {}

‎src/test/ui/symbol-names/types.verbose-legacy.stderr

Lines changed: 470 additions & 0 deletions
Large diffs are not rendered by default.

‎src/tools/rust-analyzer

0 commit comments

Comments
 (0)
Please sign in to comment.