Skip to content

Commit

Permalink
i am free
Browse files Browse the repository at this point in the history
  • Loading branch information
BoxyUwU committed Jan 18, 2023
1 parent a2a50f9 commit 1171fe5
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 15 deletions.
19 changes: 11 additions & 8 deletions compiler/rustc_middle/src/ty/print/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1290,15 +1290,18 @@ pub trait PrettyPrinter<'tcx>:
p!(print_value_path(def.did, substs))
}
DefKind::AnonConst => {
if def.is_local() {
let span = self.tcx().def_span(def.did);
if let Ok(snip) = self.tcx().sess.source_map().span_to_snippet(span) {
p!(write("{}", snip))
} else {
p!(print_value_path(def.did, substs))
}
if def.is_local()
&& let span = self.tcx().def_span(def.did)
&& let Ok(snip) = self.tcx().sess.source_map().span_to_snippet(span)
{
p!(write("{}", snip))
} else {
p!(print_value_path(def.did, substs))
// Do not call `print_value_path` as if a parent of this anon const is an impl it will
// attempt to print out the impl trait ref i.e. `<T as Trait>::{constant#0}`. This would
// cause printing to enter an infinite recursion if the anon const is in the self type i.e.
// `impl<T: Default> Default for [T; 32 - 1 - 1 - 1] {`
// where we would try to print `<[T; /* print `constant#0` again */] as Default>::{constant#0}`
p!(write("{}::{}", self.tcx().crate_name(def.did.krate), self.tcx().def_path(def.did).to_string_no_crate_verbose()))
}
}
defkind => bug!("`{:?}` has unexpcted defkind {:?}", ct, defkind),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
|
fn main() -> () {
let mut _0: (); // return place in scope 0 at $DIR/region_subtyping_basic.rs:+0:11: +0:11
let mut _1: [usize; Const { ty: usize, kind: Value(Leaf(0x00000003)) }]; // in scope 0 at $DIR/region_subtyping_basic.rs:+1:9: +1:14
let mut _1: [usize; Const(Value(Leaf(0x00000003)): usize)]; // in scope 0 at $DIR/region_subtyping_basic.rs:+1:9: +1:14
let _3: usize; // in scope 0 at $DIR/region_subtyping_basic.rs:+2:16: +2:17
let mut _4: usize; // in scope 0 at $DIR/region_subtyping_basic.rs:+2:14: +2:18
let mut _5: bool; // in scope 0 at $DIR/region_subtyping_basic.rs:+2:14: +2:18
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
|
fn main() -> () {
let mut _0: (); // return place in scope 0 at $DIR/region_subtyping_basic.rs:+0:11: +0:11
let mut _1: [usize; Const { ty: usize, kind: Value(Leaf(0x0000000000000003)) }]; // in scope 0 at $DIR/region_subtyping_basic.rs:+1:9: +1:14
let mut _1: [usize; Const(Value(Leaf(0x0000000000000003)): usize)]; // in scope 0 at $DIR/region_subtyping_basic.rs:+1:9: +1:14
let _3: usize; // in scope 0 at $DIR/region_subtyping_basic.rs:+2:16: +2:17
let mut _4: usize; // in scope 0 at $DIR/region_subtyping_basic.rs:+2:14: +2:18
let mut _5: bool; // in scope 0 at $DIR/region_subtyping_basic.rs:+2:14: +2:18
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ error[E0308]: mismatched types
--> $DIR/non_local_anon_const_diagnostics.rs:12:43
|
LL | let _: anon_const_non_local::Foo<2> = anon_const_non_local::foo::<M>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `2`, found `foo::<M>::{constant#0}`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `2`, found `anon_const_non_local::::foo::{constant#0}`
|
= note: expected constant `2`
found constant `foo::<M>::{constant#0}`
found constant `anon_const_non_local::::foo::{constant#0}`

error: aborting due to previous error

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/limits/issue-15919-32.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error: values of the type `[usize; 4294967295]` are too big for the current architecture
error: values of the type `[usize; usize::MAX]` are too big for the current architecture
--> $DIR/issue-15919-32.rs:9:9
|
LL | let x = [0usize; 0xffff_ffff];
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/limits/issue-17913.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// build-fail
// normalize-stderr-test "\[&usize; \d+\]" -> "[&usize; N]"
// normalize-stderr-test "\[&usize; \d+\]" -> "[&usize; usize::MAX]"
// error-pattern: too big for the current architecture

// FIXME https://github.com/rust-lang/rust/issues/59774
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/limits/issue-17913.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error: values of the type `[&usize; N]` are too big for the current architecture
error: values of the type `[&usize; usize::MAX]` are too big for the current architecture

error: aborting due to previous error

0 comments on commit 1171fe5

Please sign in to comment.