64ea8eb1a9
The `Debug` impl for `Ty` just calls the `Display` impl for `Ty`. This is surprising and annoying. In particular, it means `Debug` doesn't show as much information as `Debug` for `TyKind` does. And `Debug` is used in some user-facing error messages, which seems bad. This commit changes the `Debug` impl for `Ty` to call the `Debug` impl for `TyKind`. It also does a number of follow-up changes to preserve existing output, many of which involve inserting `with_no_trimmed_paths!` calls. It also adds `Display` impls for `UserType` and `Canonical`. Some tests have changes to expected output: - Those that use the `rustc_abi(debug)` attribute. - Those that use the `EMIT_MIR` annotation. In each case the output is slightly uglier than before. This isn't ideal, but it's pretty weird (particularly for the attribute) that the output is using `Debug` in the first place. They're fairly obscure attributes (I hadn't heard of them) so I'm not worried by this. For `async-is-unwindsafe.stderr`, there is one line that now lacks a full path. This is a consistency improvement, because all the other mentions of `Context` in this test lack a path.
55 lines
1.9 KiB
Rust
55 lines
1.9 KiB
Rust
// normalize-stderr-test "(abi|pref|unadjusted_abi_align): Align\([1-8] bytes\)" -> "$1: $$SOME_ALIGN"
|
|
// normalize-stderr-test "(size): Size\([48] bytes\)" -> "$1: $$SOME_SIZE"
|
|
// normalize-stderr-test "(can_unwind): (true|false)" -> "$1: $$SOME_BOOL"
|
|
// normalize-stderr-test "(valid_range): 0\.\.=(4294967295|18446744073709551615)" -> "$1: $$FULL"
|
|
// This pattern is prepared for when we account for alignment in the niche.
|
|
// normalize-stderr-test "(valid_range): [1-9]\.\.=(429496729[0-9]|1844674407370955161[0-9])" -> "$1: $$NON_NULL"
|
|
// normalize-stderr-test "Leaf\(0x0*20\)" -> "Leaf(0x0...20)"
|
|
// Some attributes are only computed for release builds:
|
|
// compile-flags: -O
|
|
#![feature(rustc_attrs)]
|
|
#![crate_type = "lib"]
|
|
|
|
struct S(u16);
|
|
|
|
#[rustc_abi(debug)]
|
|
fn test(_x: u8) -> bool { true } //~ ERROR: fn_abi
|
|
|
|
#[rustc_abi(debug)]
|
|
type TestFnPtr = fn(bool) -> u8; //~ ERROR: fn_abi
|
|
|
|
#[rustc_abi(debug)]
|
|
fn test_generic<T>(_x: *const T) { } //~ ERROR: fn_abi
|
|
|
|
#[rustc_abi(debug)]
|
|
const C: () = (); //~ ERROR: can only be applied to
|
|
|
|
impl S {
|
|
#[rustc_abi(debug)]
|
|
const C: () = (); //~ ERROR: can only be applied to
|
|
}
|
|
|
|
impl S {
|
|
#[rustc_abi(debug)]
|
|
fn assoc_test(&self) { } //~ ERROR: fn_abi
|
|
}
|
|
|
|
#[rustc_abi(assert_eq)]
|
|
type TestAbiEq = (fn(bool), fn(bool));
|
|
|
|
#[rustc_abi(assert_eq)]
|
|
type TestAbiNe = (fn(u8), fn(u32)); //~ ERROR: ABIs are not compatible
|
|
|
|
#[rustc_abi(assert_eq)]
|
|
type TestAbiNeLarger = (fn([u8; 32]), fn([u32; 32])); //~ ERROR: ABIs are not compatible
|
|
|
|
#[rustc_abi(assert_eq)]
|
|
type TestAbiNeFloat = (fn(f32), fn(u32)); //~ ERROR: ABIs are not compatible
|
|
|
|
// Sign matters on some targets (such as s390x), so let's make sure we never accept this.
|
|
#[rustc_abi(assert_eq)]
|
|
type TestAbiNeSign = (fn(i32), fn(u32)); //~ ERROR: ABIs are not compatible
|
|
|
|
#[rustc_abi(assert_eq)]
|
|
type TestAbiEqNonsense = (fn((str, str)), fn((str, str))); //~ ERROR: cannot be known at compilation time
|