Skip to content

Commit

Permalink
Update UI tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
reitermarkus committed Jan 20, 2024
1 parent 22a1992 commit 88b1f00
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 30 deletions.
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<core::num::nonzero::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 `(core::num::nonzero::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: `core::num::nonzero::NonZero<u32>` must be non-null

error: the type `(NonZeroU32, i32)` does not permit being left uninitialized
error: the type `(core::num::nonzero::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: `core::num::nonzero::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 `core::num::nonzero::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 `core::num::nonzero::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 `core::num::nonzero::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: `core::num::nonzero::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<core::num::nonzero::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<core::num::nonzero::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<(), core::num::nonzero::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 `core::num::nonzero::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<core::num::nonzero::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<core::num::nonzero::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<core::num::nonzero::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<core::num::nonzero::NonZero<u32>, core::num::nonzero::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<core::num::nonzero::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<core::num::nonzero::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<core::num::nonzero::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<core::num::nonzero::NonZero<u32>, core::num::nonzero::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<core::num::nonzero::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: `core::num::nonzero::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
2 changes: 1 addition & 1 deletion tests/ui/traits/issue-77982.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ LL | let ips: Vec<_> = (0..100_000).map(|_| u32::from(0u32.into())).collect(
|
= note: multiple `impl`s satisfying `u32: From<_>` found in the `core` crate:
- impl From<Ipv4Addr> for u32;
- impl From<NonZeroU32> for u32;
- impl From<bool> for u32;
- impl From<char> for u32;
- impl From<core::num::nonzero::NonZero<u32>> for u32;
- impl From<u16> for u32;
- impl From<u8> for u32;
help: try using a fully qualified path to specify the expected types
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/try-trait/bad-interconversion.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ LL | Ok(Err(123_i32)?)
= note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
= help: the following other types implement trait `From<T>`:
<u8 as From<bool>>
<u8 as From<NonZeroU8>>
<u8 as From<core::num::nonzero::NonZero<u8>>>
= note: required for `Result<u64, u8>` to implement `FromResidual<Result<Infallible, i32>>`

error[E0277]: the `?` operator can only be used on `Result`s, not `Option`s, in a function that returns `Result`
Expand Down

0 comments on commit 88b1f00

Please sign in to comment.