Auto merge of #67133 - oli-obk:it_must_be_a_sign, r=eddyb

Deduplicate pretty printing of constants

r? @eddyb for the pretty printing logic
cc @RalfJung
This commit is contained in:
bors 2020-03-16 16:31:23 +00:00
commit dd67187965
15 changed files with 396 additions and 206 deletions

View file

@ -10,7 +10,7 @@ error[E0282]: type annotations needed
--> $DIR/cannot-infer-const-args.rs:9:5
|
LL | foo();
| ^^^ cannot infer type for fn item `fn() -> usize {foo::<_: usize>}`
| ^^^ cannot infer type for fn item `fn() -> usize {foo::<{_: usize}>}`
error: aborting due to previous error

View file

@ -7,5 +7,5 @@
struct S<const N: usize>;
fn main() {
assert_eq!(std::any::type_name::<S<3>>(), "const_generic_type_name::S<3usize>");
assert_eq!(std::any::type_name::<S<3>>(), "const_generic_type_name::S<3>");
}

View file

@ -10,12 +10,12 @@ error[E0308]: mismatched types
--> $DIR/fn-const-param-infer.rs:16:31
|
LL | let _: Checked<not_one> = Checked::<not_two>;
| ---------------- ^^^^^^^^^^^^^^^^^^ expected `not_one`, found `not_two`
| ---------------- ^^^^^^^^^^^^^^^^^^ expected `{not_one as fn(usize) -> bool}`, found `{not_two as fn(usize) -> bool}`
| |
| expected due to this
|
= note: expected struct `Checked<not_one>`
found struct `Checked<not_two>`
= note: expected struct `Checked<{not_one as fn(usize) -> bool}>`
found struct `Checked<{not_two as fn(usize) -> bool}>`
error[E0308]: mismatched types
--> $DIR/fn-const-param-infer.rs:20:24
@ -36,12 +36,12 @@ error[E0308]: mismatched types
--> $DIR/fn-const-param-infer.rs:25:40
|
LL | let _: Checked<{generic::<u32>}> = Checked::<{generic::<u16>}>;
| ------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `generic::<u32>`, found `generic::<u16>`
| ------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `{generic::<u32> as fn(usize) -> bool}`, found `{generic::<u16> as fn(usize) -> bool}`
| |
| expected due to this
|
= note: expected struct `Checked<generic::<u32>>`
found struct `Checked<generic::<u16>>`
= note: expected struct `Checked<{generic::<u32> as fn(usize) -> bool}>`
found struct `Checked<{generic::<u16> as fn(usize) -> bool}>`
error: aborting due to 4 previous errors

View file

@ -4,6 +4,6 @@
struct Const<const P: *const u32>;
fn main() {
let _: Const<{15 as *const _}> = Const::<{10 as *const _}>; //~ mismatched types
let _: Const<{10 as *const _}> = Const::<{10 as *const _}>;
let _: Const<{ 15 as *const _ }> = Const::<{ 10 as *const _ }>; //~ mismatched types
let _: Const<{ 10 as *const _ }> = Const::<{ 10 as *const _ }>;
}

View file

@ -7,15 +7,15 @@ LL | #![feature(const_generics, const_compare_raw_pointers)]
= note: `#[warn(incomplete_features)]` on by default
error[E0308]: mismatched types
--> $DIR/raw-ptr-const-param.rs:7:38
--> $DIR/raw-ptr-const-param.rs:7:40
|
LL | let _: Const<{15 as *const _}> = Const::<{10 as *const _}>;
| ----------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `{pointer}`, found `{pointer}`
LL | let _: Const<{ 15 as *const _ }> = Const::<{ 10 as *const _ }>;
| ------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `{0xf as *const u32}`, found `{0xa as *const u32}`
| |
| expected due to this
|
= note: expected struct `Const<{pointer}>`
found struct `Const<{pointer}>`
= note: expected struct `Const<{0xf as *const u32}>`
found struct `Const<{0xa as *const u32}>`
error: aborting due to previous error

View file

@ -43,7 +43,7 @@ error: any use of this value will cause an error
LL | intrinsics::ptr_offset_from(self, origin)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| exact_div: 1 cannot be divided by 2 without remainder
| exact_div: 1isize cannot be divided by 2isize without remainder
| inside call to `std::ptr::const_ptr::<impl *const u16>::offset_from` at $DIR/offset_from_ub.rs:36:14
|
::: $DIR/offset_from_ub.rs:31:1