Skip to content

Commit

Permalink
Update tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
reitermarkus committed Jan 27, 2024
1 parent 117eb9f commit 021739c
Show file tree
Hide file tree
Showing 14 changed files with 62 additions and 93 deletions.
35 changes: 1 addition & 34 deletions src/etc/natvis/libcore.natvis
Original file line number Diff line number Diff line change
Expand Up @@ -41,40 +41,7 @@
</Expand>
</Type>

<Type Name="core::num::nonzero::NonZeroI8">
<DisplayString>{__0}</DisplayString>
</Type>
<Type Name="core::num::nonzero::NonZeroI16">
<DisplayString>{__0}</DisplayString>
</Type>
<Type Name="core::num::nonzero::NonZeroI32">
<DisplayString>{__0}</DisplayString>
</Type>
<Type Name="core::num::nonzero::NonZeroI64">
<DisplayString>{__0}</DisplayString>
</Type>
<Type Name="core::num::nonzero::NonZeroI128">
<DisplayString>{__0}</DisplayString>
</Type>
<Type Name="core::num::nonzero::NonZeroIsize">
<DisplayString>{__0}</DisplayString>
</Type>
<Type Name="core::num::nonzero::NonZeroU8">
<DisplayString>{__0}</DisplayString>
</Type>
<Type Name="core::num::nonzero::NonZeroU16">
<DisplayString>{__0}</DisplayString>
</Type>
<Type Name="core::num::nonzero::NonZeroU32">
<DisplayString>{__0}</DisplayString>
</Type>
<Type Name="core::num::nonzero::NonZeroU64">
<DisplayString>{__0}</DisplayString>
</Type>
<Type Name="core::num::nonzero::NonZeroU128">
<DisplayString>{__0}</DisplayString>
</Type>
<Type Name="core::num::nonzero::NonZeroUsize">
<Type Name="core::num::nonzero::NonZero&lt;*&gt;">
<DisplayString>{__0}</DisplayString>
</Type>

Expand Down
8 changes: 4 additions & 4 deletions tests/debuginfo/msvc-pretty-enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@
// cdb-check: [+0x000] __0 : 0x2a [Type: unsigned int]

// cdb-command: dx niche128_some
// cdb-check: niche128_some : Some [Type: enum2$<core::option::Option<core::num::nonzero::NonZeroI128> >]
// cdb-check: niche128_some : Some [Type: enum2$<core::option::Option<core::num::nonzero::NonZero<i128> > >]
// Note: we can't actually read the value of the field because CDB cannot handle 128 bit integers.
// cdb-check: [+0x000] __0 [...] [Type: core::num::nonzero::NonZeroI128]
// cdb-check: [+0x000] __0 [...] [Type: core::num::nonzero::NonZero<i128>]

// cdb-command: dx niche128_none
// cdb-check: niche128_none : None [Type: enum2$<core::option::Option<core::num::nonzero::NonZeroI128> >]
// cdb-check: niche128_none : None [Type: enum2$<core::option::Option<core::num::nonzero::NonZero<i128> > >]

// cdb-command: dx wrapping_niche128_untagged
// cdb-check: wrapping_niche128_untagged : X [Type: enum2$<msvc_pretty_enums::Wrapping128Niche>]
Expand Down Expand Up @@ -84,7 +84,7 @@

// cdb-command: dx niche_w_fields_2_some,d
// cdb-check: niche_w_fields_2_some,d : A [Type: enum2$<msvc_pretty_enums::NicheLayoutWithFields2>]
// cdb-check: [+0x[...]] __0 : 800 [Type: core::num::nonzero::NonZeroU32]
// cdb-check: [+0x[...]] __0 : 800 [Type: core::num::nonzero::NonZero<u32>]
// cdb-check: [+0x[...]] __1 : 900 [Type: unsigned __int64]

// cdb-command: dx niche_w_fields_2_none,d
Expand Down
46 changes: 23 additions & 23 deletions tests/debuginfo/numeric-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,59 +3,59 @@
// min-gdb-version: 8.1
// ignore-windows-gnu // emit_debug_gdb_scripts is disabled on Windows

// Tests the visualizations for `NonZero{I,U}{8,16,32,64,128,size}`, `Wrapping<T>` and
// Tests the visualizations for `NonZero<T>`, `Wrapping<T>` and
// `Atomic{Bool,I8,I16,I32,I64,Isize,U8,U16,U32,U64,Usize}` located in `libcore.natvis`.

// === CDB TESTS ==================================================================================
// cdb-command: g

// cdb-command: dx nz_i8
// cdb-check:nz_i8 : 11 [Type: core::num::nonzero::NonZeroI8]
// cdb-check: [<Raw View>] [Type: core::num::nonzero::NonZeroI8]
// cdb-check:nz_i8 : 11 [Type: core::num::nonzero::NonZero<i8>]
// cdb-check: [<Raw View>] [Type: core::num::nonzero::NonZero<i8>]

// cdb-command: dx nz_i16
// cdb-check:nz_i16 : 22 [Type: core::num::nonzero::NonZeroI16]
// cdb-check: [<Raw View>] [Type: core::num::nonzero::NonZeroI16]
// cdb-check:nz_i16 : 22 [Type: core::num::nonzero::NonZero<i16>]
// cdb-check: [<Raw View>] [Type: core::num::nonzero::NonZero<i16>]

// cdb-command: dx nz_i32
// cdb-check:nz_i32 : 33 [Type: core::num::nonzero::NonZeroI32]
// cdb-check: [<Raw View>] [Type: core::num::nonzero::NonZeroI32]
// cdb-check:nz_i32 : 33 [Type: core::num::nonzero::NonZero<i32>]
// cdb-check: [<Raw View>] [Type: core::num::nonzero::NonZero<i32>]

// cdb-command: dx nz_i64
// cdb-check:nz_i64 : 44 [Type: core::num::nonzero::NonZeroI64]
// cdb-check: [<Raw View>] [Type: core::num::nonzero::NonZeroI64]
// cdb-check:nz_i64 : 44 [Type: core::num::nonzero::NonZero<i64>]
// cdb-check: [<Raw View>] [Type: core::num::nonzero::NonZero<i64>]

// 128-bit integers don't seem to work in CDB
// cdb-command: dx nz_i128
// cdb-check: [<Raw View>] [Type: core::num::nonzero::NonZeroI128]
// cdb-check: [<Raw View>] [Type: core::num::nonzero::NonZero<i128>]

// cdb-command: dx nz_isize
// cdb-check:nz_isize : 66 [Type: core::num::nonzero::NonZeroIsize]
// cdb-check: [<Raw View>] [Type: core::num::nonzero::NonZeroIsize]
// cdb-check:nz_isize : 66 [Type: core::num::nonzero::NonZero<isize>]
// cdb-check: [<Raw View>] [Type: core::num::nonzero::NonZero<isize>]

// cdb-command: dx nz_u8
// cdb-check:nz_u8 : 0x4d [Type: core::num::nonzero::NonZeroU8]
// cdb-check: [<Raw View>] [Type: core::num::nonzero::NonZeroU8]
// cdb-check:nz_u8 : 0x4d [Type: core::num::nonzero::NonZero<u8>]
// cdb-check: [<Raw View>] [Type: core::num::nonzero::NonZero<u8>]

// cdb-command: dx nz_u16
// cdb-check:nz_u16 : 0x58 [Type: core::num::nonzero::NonZeroU16]
// cdb-check: [<Raw View>] [Type: core::num::nonzero::NonZeroU16]
// cdb-check:nz_u16 : 0x58 [Type: core::num::nonzero::NonZero<u16>]
// cdb-check: [<Raw View>] [Type: core::num::nonzero::NonZero<u16>]

// cdb-command: dx nz_u32
// cdb-check:nz_u32 : 0x63 [Type: core::num::nonzero::NonZeroU32]
// cdb-check: [<Raw View>] [Type: core::num::nonzero::NonZeroU32]
// cdb-check:nz_u32 : 0x63 [Type: core::num::nonzero::NonZero<u32>]
// cdb-check: [<Raw View>] [Type: core::num::nonzero::NonZero<u32>]

// cdb-command: dx nz_u64
// cdb-check:nz_u64 : 0x64 [Type: core::num::nonzero::NonZeroU64]
// cdb-check: [<Raw View>] [Type: core::num::nonzero::NonZeroU64]
// cdb-check:nz_u64 : 0x64 [Type: core::num::nonzero::NonZero<u64>]
// cdb-check: [<Raw View>] [Type: core::num::nonzero::NonZero<u64>]

// 128-bit integers don't seem to work in CDB
// cdb-command: dx nz_u128
// cdb-check: [<Raw View>] [Type: core::num::nonzero::NonZeroU128]
// cdb-check: [<Raw View>] [Type: core::num::nonzero::NonZero<u128>]

// cdb-command: dx nz_usize
// cdb-check:nz_usize : 0x7a [Type: core::num::nonzero::NonZeroUsize]
// cdb-check: [<Raw View>] [Type: core::num::nonzero::NonZeroUsize]
// cdb-check:nz_usize : 0x7a [Type: core::num::nonzero::NonZero<usize>]
// cdb-check: [<Raw View>] [Type: core::num::nonzero::NonZero<usize>]

// cdb-command: dx w_i8
// cdb-check:w_i8 : 10 [Type: core::num::wrapping::Wrapping<i8>]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
fn adt_transmutes() -> () {
let mut _0: ();
let _1: u8;
let mut _2: std::option::Option<std::num::NonZeroU8>;
let mut _2: std::option::Option<std::num::NonZero<u8>>;
let mut _4: std::num::Wrapping<i16>;
let mut _6: std::num::Wrapping<i16>;
let mut _8: Union32;
Expand Down Expand Up @@ -37,7 +37,7 @@
bb0: {
StorageLive(_1);
StorageLive(_2);
_2 = Option::<NonZeroU8>::Some(const _);
_2 = Option::<NonZero<u8>>::Some(const _);
_1 = move _2 as u8 (Transmute);
StorageDead(_2);
StorageLive(_3);
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/layout/zero-sized-array-enum-niche.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ error: layout_of(MultipleAlignments) = Layout {
LL | enum MultipleAlignments {
| ^^^^^^^^^^^^^^^^^^^^^^^

error: layout_of(Result<[u32; 0], Packed<NonZeroU16>>) = Layout {
error: layout_of(Result<[u32; 0], Packed<NonZero<u16>>>) = Layout {
size: Size(4 bytes),
align: AbiAndPrefAlign {
abi: Align(4 bytes),
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/lint/clashing-extern-fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ mod hidden_niche {

fn hidden_niche_unsafe_cell() -> Option<UnsafeCell<NonZeroUsize>>;
//~^ WARN redeclared with a different signature
//~| WARN block uses type `Option<UnsafeCell<NonZeroUsize>>`, which is not FFI-safe
//~| WARN block uses type `Option<UnsafeCell<NonZero<usize>>>`, which is not FFI-safe
}
}
}
6 changes: 3 additions & 3 deletions tests/ui/lint/clashing-extern-fn.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ LL | fn hidden_niche_transparent_no_niche() -> Option<TransparentNoN
= note: enum has no representation hint
= note: `#[warn(improper_ctypes)]` on by default

warning: `extern` block uses type `Option<UnsafeCell<NonZeroUsize>>`, which is not FFI-safe
warning: `extern` block uses type `Option<UnsafeCell<NonZero<usize>>>`, which is not FFI-safe
--> $DIR/clashing-extern-fn.rs:437:46
|
LL | fn hidden_niche_unsafe_cell() -> Option<UnsafeCell<NonZeroUsize>>;
Expand Down Expand Up @@ -163,7 +163,7 @@ LL | fn non_zero_usize() -> core::num::NonZeroUsize;
LL | fn non_zero_usize() -> usize;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration
|
= note: expected `unsafe extern "C" fn() -> NonZeroUsize`
= note: expected `unsafe extern "C" fn() -> NonZero<usize>`
found `unsafe extern "C" fn() -> usize`

warning: `non_null_ptr` redeclared with a different signature
Expand Down Expand Up @@ -224,7 +224,7 @@ LL | fn hidden_niche_unsafe_cell() -> Option<UnsafeCell<NonZeroUsize
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration
|
= note: expected `unsafe extern "C" fn() -> usize`
found `unsafe extern "C" fn() -> Option<UnsafeCell<NonZeroUsize>>`
found `unsafe extern "C" fn() -> Option<UnsafeCell<NonZero<usize>>>`

warning: 19 warnings emitted

16 changes: 8 additions & 8 deletions tests/ui/lint/invalid_value.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ LL | let _val: NonNull<i32> = mem::uninitialized();
= note: `std::ptr::NonNull<i32>` must be non-null
= note: raw pointers must be initialized

error: the type `(NonZeroU32, i32)` does not permit zero-initialization
error: the type `(NonZero<u32>, i32)` does not permit zero-initialization
--> $DIR/invalid_value.rs:95:39
|
LL | let _val: (NonZeroU32, i32) = mem::zeroed();
Expand All @@ -325,9 +325,9 @@ LL | let _val: (NonZeroU32, i32) = mem::zeroed();
| this code causes undefined behavior when executed
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
|
= note: `std::num::NonZeroU32` must be non-null
= note: `std::num::NonZero<u32>` must be non-null

error: the type `(NonZeroU32, i32)` does not permit being left uninitialized
error: the type `(NonZero<u32>, i32)` does not permit being left uninitialized
--> $DIR/invalid_value.rs:96:39
|
LL | let _val: (NonZeroU32, i32) = mem::uninitialized();
Expand All @@ -336,7 +336,7 @@ LL | let _val: (NonZeroU32, i32) = mem::uninitialized();
| this code causes undefined behavior when executed
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
|
= note: `std::num::NonZeroU32` must be non-null
= note: `std::num::NonZero<u32>` must be non-null
= note: integers must be initialized

error: the type `*const dyn Send` does not permit zero-initialization
Expand Down Expand Up @@ -417,7 +417,7 @@ LL | let _val: OneFruitNonZero = mem::zeroed();
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
|
= note: `OneFruitNonZero` must be non-null
note: because `std::num::NonZeroU32` must be non-null (in this field of the only potentially inhabited enum variant)
note: because `std::num::NonZero<u32>` must be non-null (in this field of the only potentially inhabited enum variant)
--> $DIR/invalid_value.rs:39:12
|
LL | Banana(NonZeroU32),
Expand All @@ -433,7 +433,7 @@ LL | let _val: OneFruitNonZero = mem::uninitialized();
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
|
= note: `OneFruitNonZero` must be non-null
note: because `std::num::NonZeroU32` must be non-null (in this field of the only potentially inhabited enum variant)
note: because `std::num::NonZero<u32>` must be non-null (in this field of the only potentially inhabited enum variant)
--> $DIR/invalid_value.rs:39:12
|
LL | Banana(NonZeroU32),
Expand Down Expand Up @@ -603,7 +603,7 @@ LL | let _val: &'static [i32] = mem::transmute((0usize, 0usize));
|
= note: references must be non-null

error: the type `NonZeroU32` does not permit zero-initialization
error: the type `NonZero<u32>` does not permit zero-initialization
--> $DIR/invalid_value.rs:154:32
|
LL | let _val: NonZeroU32 = mem::transmute(0);
Expand All @@ -612,7 +612,7 @@ LL | let _val: NonZeroU32 = mem::transmute(0);
| this code causes undefined behavior when executed
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
|
= note: `std::num::NonZeroU32` must be non-null
= note: `std::num::NonZero<u32>` must be non-null

error: the type `NonNull<i32>` does not permit zero-initialization
--> $DIR/invalid_value.rs:157:34
Expand Down
6 changes: 3 additions & 3 deletions tests/ui/lint/lint-ctypes-enum.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ LL | fn nonzero_i128(x: Option<num::NonZeroI128>);
|
= note: 128-bit integers don't currently have a known stable ABI

error: `extern` block uses type `Option<TransparentUnion<NonZeroU8>>`, which is not FFI-safe
error: `extern` block uses type `Option<TransparentUnion<NonZero<u8>>>`, which is not FFI-safe
--> $DIR/lint-ctypes-enum.rs:86:28
|
LL | fn transparent_union(x: Option<TransparentUnion<num::NonZeroU8>>);
Expand All @@ -70,7 +70,7 @@ LL | fn transparent_union(x: Option<TransparentUnion<num::NonZeroU8>>);
= help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum
= note: enum has no representation hint

error: `extern` block uses type `Option<Rust<NonZeroU8>>`, which is not FFI-safe
error: `extern` block uses type `Option<Rust<NonZero<u8>>>`, which is not FFI-safe
--> $DIR/lint-ctypes-enum.rs:88:20
|
LL | fn repr_rust(x: Option<Rust<num::NonZeroU8>>);
Expand All @@ -79,7 +79,7 @@ LL | fn repr_rust(x: Option<Rust<num::NonZeroU8>>);
= help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum
= note: enum has no representation hint

error: `extern` block uses type `Result<(), NonZeroI32>`, which is not FFI-safe
error: `extern` block uses type `Result<(), NonZero<i32>>`, which is not FFI-safe
--> $DIR/lint-ctypes-enum.rs:89:20
|
LL | fn no_result(x: Result<(), num::NonZeroI32>);
Expand Down
8 changes: 5 additions & 3 deletions tests/ui/mismatched_types/non_zero_assigned_something.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ error[E0308]: mismatched types
--> $DIR/non_zero_assigned_something.rs:2:35
|
LL | let _: std::num::NonZeroU64 = 1;
| -------------------- ^ expected `NonZeroU64`, found integer
| -------------------- ^ expected `NonZero<u64>`, found integer
| |
| expected due to this
|
= note: expected struct `NonZero<u64>`
found type `{integer}`
help: consider calling `NonZeroU64::new`
|
LL | let _: std::num::NonZeroU64 = NonZeroU64::new(1).unwrap();
Expand All @@ -15,11 +17,11 @@ error[E0308]: mismatched types
--> $DIR/non_zero_assigned_something.rs:6:43
|
LL | let _: Option<std::num::NonZeroU64> = 1;
| ---------------------------- ^ expected `Option<NonZeroU64>`, found integer
| ---------------------------- ^ expected `Option<NonZero<u64>>`, found integer
| |
| expected due to this
|
= note: expected enum `Option<NonZeroU64>`
= note: expected enum `Option<NonZero<u64>>`
found type `{integer}`
help: consider calling `NonZeroU64::new`
|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ LL | x / 100.0
= help: the trait `Div<{float}>` is not implemented for `u8`
= help: the following other types implement trait `Div<Rhs>`:
<u8 as Div>
<u8 as Div<NonZeroU8>>
<u8 as Div<NonZero<u8>>>
<u8 as Div<&u8>>
<&'a u8 as Div<u8>>
<&u8 as Div<&u8>>
Expand Down
16 changes: 8 additions & 8 deletions tests/ui/print_type_sizes/niche-filling.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ print-type-size field `.pre`: 1 bytes
print-type-size field `.post`: 2 bytes
print-type-size field `.val`: 4 bytes
print-type-size variant `None`: 0 bytes
print-type-size type: `MyOption<Union1<std::num::NonZeroU32>>`: 8 bytes, alignment: 4 bytes
print-type-size type: `MyOption<Union1<std::num::NonZero<u32>>>`: 8 bytes, alignment: 4 bytes
print-type-size discriminant: 4 bytes
print-type-size variant `Some`: 4 bytes
print-type-size field `.0`: 4 bytes
print-type-size variant `None`: 0 bytes
print-type-size type: `MyOption<Union2<std::num::NonZeroU32, std::num::NonZeroU32>>`: 8 bytes, alignment: 4 bytes
print-type-size type: `MyOption<Union2<std::num::NonZero<u32>, std::num::NonZero<u32>>>`: 8 bytes, alignment: 4 bytes
print-type-size discriminant: 4 bytes
print-type-size variant `Some`: 4 bytes
print-type-size field `.0`: 4 bytes
print-type-size variant `None`: 0 bytes
print-type-size type: `MyOption<Union2<std::num::NonZeroU32, u32>>`: 8 bytes, alignment: 4 bytes
print-type-size type: `MyOption<Union2<std::num::NonZero<u32>, u32>>`: 8 bytes, alignment: 4 bytes
print-type-size discriminant: 4 bytes
print-type-size variant `Some`: 4 bytes
print-type-size field `.0`: 4 bytes
Expand Down Expand Up @@ -53,22 +53,22 @@ print-type-size type: `MyOption<char>`: 4 bytes, alignment: 4 bytes
print-type-size variant `Some`: 4 bytes
print-type-size field `.0`: 4 bytes
print-type-size variant `None`: 0 bytes
print-type-size type: `MyOption<std::num::NonZeroU32>`: 4 bytes, alignment: 4 bytes
print-type-size type: `MyOption<std::num::NonZero<u32>>`: 4 bytes, alignment: 4 bytes
print-type-size variant `Some`: 4 bytes
print-type-size field `.0`: 4 bytes
print-type-size variant `None`: 0 bytes
print-type-size type: `Union1<std::num::NonZeroU32>`: 4 bytes, alignment: 4 bytes
print-type-size type: `Union1<std::num::NonZero<u32>>`: 4 bytes, alignment: 4 bytes
print-type-size variant `Union1`: 4 bytes
print-type-size field `.a`: 4 bytes
print-type-size type: `Union2<std::num::NonZeroU32, std::num::NonZeroU32>`: 4 bytes, alignment: 4 bytes
print-type-size type: `Union2<std::num::NonZero<u32>, std::num::NonZero<u32>>`: 4 bytes, alignment: 4 bytes
print-type-size variant `Union2`: 4 bytes
print-type-size field `.a`: 4 bytes
print-type-size field `.b`: 4 bytes, offset: 0 bytes, alignment: 4 bytes
print-type-size type: `Union2<std::num::NonZeroU32, u32>`: 4 bytes, alignment: 4 bytes
print-type-size type: `Union2<std::num::NonZero<u32>, u32>`: 4 bytes, alignment: 4 bytes
print-type-size variant `Union2`: 4 bytes
print-type-size field `.a`: 4 bytes
print-type-size field `.b`: 4 bytes, offset: 0 bytes, alignment: 4 bytes
print-type-size type: `std::num::NonZeroU32`: 4 bytes, alignment: 4 bytes
print-type-size type: `std::num::NonZero<u32>`: 4 bytes, alignment: 4 bytes
print-type-size field `.0`: 4 bytes
print-type-size type: `Enum4<(), (), (), MyOption<u8>>`: 2 bytes, alignment: 1 bytes
print-type-size variant `Four`: 2 bytes
Expand Down
Loading

0 comments on commit 021739c

Please sign in to comment.