Skip to content

Commit 1171fe5

Browse files
committed
i am free
1 parent a2a50f9 commit 1171fe5

File tree

7 files changed

+18
-15
lines changed

7 files changed

+18
-15
lines changed

compiler/rustc_middle/src/ty/print/pretty.rs

+11-8
Original file line numberDiff line numberDiff line change
@@ -1290,15 +1290,18 @@ pub trait PrettyPrinter<'tcx>:
12901290
p!(print_value_path(def.did, substs))
12911291
}
12921292
DefKind::AnonConst => {
1293-
if def.is_local() {
1294-
let span = self.tcx().def_span(def.did);
1295-
if let Ok(snip) = self.tcx().sess.source_map().span_to_snippet(span) {
1296-
p!(write("{}", snip))
1297-
} else {
1298-
p!(print_value_path(def.did, substs))
1299-
}
1293+
if def.is_local()
1294+
&& let span = self.tcx().def_span(def.did)
1295+
&& let Ok(snip) = self.tcx().sess.source_map().span_to_snippet(span)
1296+
{
1297+
p!(write("{}", snip))
13001298
} else {
1301-
p!(print_value_path(def.did, substs))
1299+
// Do not call `print_value_path` as if a parent of this anon const is an impl it will
1300+
// attempt to print out the impl trait ref i.e. `<T as Trait>::{constant#0}`. This would
1301+
// cause printing to enter an infinite recursion if the anon const is in the self type i.e.
1302+
// `impl<T: Default> Default for [T; 32 - 1 - 1 - 1] {`
1303+
// where we would try to print `<[T; /* print `constant#0` again */] as Default>::{constant#0}`
1304+
p!(write("{}::{}", self.tcx().crate_name(def.did.krate), self.tcx().def_path(def.did).to_string_no_crate_verbose()))
13021305
}
13031306
}
13041307
defkind => bug!("`{:?}` has unexpcted defkind {:?}", ct, defkind),

tests/mir-opt/nll/region_subtyping_basic.main.nll.0.32bit.mir

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
|
2323
fn main() -> () {
2424
let mut _0: (); // return place in scope 0 at $DIR/region_subtyping_basic.rs:+0:11: +0:11
25-
let mut _1: [usize; Const { ty: usize, kind: Value(Leaf(0x00000003)) }]; // in scope 0 at $DIR/region_subtyping_basic.rs:+1:9: +1:14
25+
let mut _1: [usize; Const(Value(Leaf(0x00000003)): usize)]; // in scope 0 at $DIR/region_subtyping_basic.rs:+1:9: +1:14
2626
let _3: usize; // in scope 0 at $DIR/region_subtyping_basic.rs:+2:16: +2:17
2727
let mut _4: usize; // in scope 0 at $DIR/region_subtyping_basic.rs:+2:14: +2:18
2828
let mut _5: bool; // in scope 0 at $DIR/region_subtyping_basic.rs:+2:14: +2:18

tests/mir-opt/nll/region_subtyping_basic.main.nll.0.64bit.mir

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
|
2323
fn main() -> () {
2424
let mut _0: (); // return place in scope 0 at $DIR/region_subtyping_basic.rs:+0:11: +0:11
25-
let mut _1: [usize; Const { ty: usize, kind: Value(Leaf(0x0000000000000003)) }]; // in scope 0 at $DIR/region_subtyping_basic.rs:+1:9: +1:14
25+
let mut _1: [usize; Const(Value(Leaf(0x0000000000000003)): usize)]; // in scope 0 at $DIR/region_subtyping_basic.rs:+1:9: +1:14
2626
let _3: usize; // in scope 0 at $DIR/region_subtyping_basic.rs:+2:16: +2:17
2727
let mut _4: usize; // in scope 0 at $DIR/region_subtyping_basic.rs:+2:14: +2:18
2828
let mut _5: bool; // in scope 0 at $DIR/region_subtyping_basic.rs:+2:14: +2:18

tests/ui/const-generics/generic_const_exprs/non_local_anon_const_diagnostics.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ error[E0308]: mismatched types
22
--> $DIR/non_local_anon_const_diagnostics.rs:12:43
33
|
44
LL | let _: anon_const_non_local::Foo<2> = anon_const_non_local::foo::<M>();
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `2`, found `foo::<M>::{constant#0}`
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `2`, found `anon_const_non_local::::foo::{constant#0}`
66
|
77
= note: expected constant `2`
8-
found constant `foo::<M>::{constant#0}`
8+
found constant `anon_const_non_local::::foo::{constant#0}`
99

1010
error: aborting due to previous error
1111

tests/ui/limits/issue-15919-32.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: values of the type `[usize; 4294967295]` are too big for the current architecture
1+
error: values of the type `[usize; usize::MAX]` are too big for the current architecture
22
--> $DIR/issue-15919-32.rs:9:9
33
|
44
LL | let x = [0usize; 0xffff_ffff];

tests/ui/limits/issue-17913.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// build-fail
2-
// normalize-stderr-test "\[&usize; \d+\]" -> "[&usize; N]"
2+
// normalize-stderr-test "\[&usize; \d+\]" -> "[&usize; usize::MAX]"
33
// error-pattern: too big for the current architecture
44

55
// FIXME https://github.com/rust-lang/rust/issues/59774

tests/ui/limits/issue-17913.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: values of the type `[&usize; N]` are too big for the current architecture
1+
error: values of the type `[&usize; usize::MAX]` are too big for the current architecture
22

33
error: aborting due to previous error
44

0 commit comments

Comments
 (0)