0
0
mirror of https://github.com/rust-lang/rust.git synced 2024-12-01 04:21:19 +01:00
rust/tests/ui/structs-enums
Jorge Aparicio 7f0275636e make UI test OS-agnostic
the internal representation of `std::sync::Mutex` depends on the compilation target. due to this,
the compiler produces different number of errors for UI test
`issue-17431-6.rs` depending on the compilation target.

for example, when compiling the UI test to an `*-apple-*` or `*-qnx7*` target, the "cycle detected"
error is not reported

``` console
$ cat src/lib.rs
use std::sync::Mutex;

enum Foo {
    X(Mutex<Option<Foo>>),
}

impl Foo {
    fn bar(self) {}
}

fn main() {}

$ cargo check --target x86_64-apple-ios 2>&1 | rg '^error\['
error[E0072]: recursive type `Foo` has infinite size
```

whereas rustc produces two errors for other OSes, like Linux, which is what the UI test expects

``` console
$ cargo check --target x86_64-unknown-linux-gnu 2>&1 | rg '^error\['
error[E0072]: recursive type `Foo` has infinite size
error[E0391]: cycle detected when computing when `Foo` needs drop
```

this commit replaces the problematic `Mutex` with `UnsafeCell`, which has the same internal
representation regardless of the compilation target. with that change, rustc reports two errors for
all compilation targets.

``` console
$ cat src/lib.rs
use std::cell::UnsafeCell;

enum Foo {
    X(UnsafeCell<Option<Foo>>),
}

impl Foo {
    fn bar(self) {}
}

fn main() {}

$ cargo check --target x86_64-apple-ios 2>&1 | rg '^error\['
error[E0072]: recursive type `Foo` has infinite size
error[E0391]: cycle detected when computing when `Foo` needs drop
```

with this change, we can remove the `ignore-apple` directive as the UI test now also passes on apple
targets.
2024-11-15 16:37:18 +01:00
..
auxiliary
enum-rec make UI test OS-agnostic 2024-11-15 16:37:18 +01:00
struct-rec
align-enum.rs
align-struct.rs
borrow-tuple-fields.rs
class-cast-to-trait-cross-crate-2.rs
class-cast-to-trait-multiple-types.rs
class-cast-to-trait.rs
class-dtor.rs
class-exports.rs
class-impl-very-parameterized-trait.rs
class-implement-trait-cross-crate.rs
class-implement-traits.rs
class-method-cross-crate.rs
class-methods-cross-crate.rs
class-methods.rs
class-poly-methods-cross-crate.rs
class-poly-methods.rs
class-separate-impl.rs
class-str-field.rs
class-typarams.rs
classes-cross-crate.rs
classes-self-referential.rs
classes-simple-cross-crate.rs
classes-simple-method.rs
classes-simple.rs
classes.rs
codegen-tag-static-padding.rs
compare-generic-enums.rs
cross-crate-newtype-struct-pat.rs
discrim-explicit-23030.rs
empty-struct-braces.rs
empty-tag.rs
enum-alignment.rs
enum-clike-ffi-as-int.rs
enum-discr.rs
enum-discrim-autosizing.rs
enum-discrim-manual-sizing.rs
enum-discrim-range-overflow.rs
enum-discrim-width-stuff.rs
enum-disr-val-pretty.rs
enum-export-inheritance.rs
enum-layout-optimization.rs
enum-non-c-like-repr-c-and-int.rs
enum-non-c-like-repr-c.rs
enum-non-c-like-repr-int.rs
enum-null-pointer-opt.rs
enum-null-pointer-opt.stderr
enum-nullable-const-null-with-fields.rs
enum-nullable-simplifycfg-misopt.rs
enum-univariant-repr.rs
enum-variants.rs
enum-vec-initializer.rs
export-abstract-tag.rs
export-tag-variant.rs
expr-if-struct.rs
expr-match-struct.rs
field-destruction-order.rs
foreign-struct.rs
functional-struct-upd.rs
issue-1701.rs
issue-2718-a.rs
issue-2718-a.stderr
issue-3008-1.rs
issue-3008-1.stderr
issue-3008-2.rs
issue-3008-2.stderr
issue-3008-3.rs
issue-3008-3.stderr
issue-38002.rs
issue-50731.rs
issue-103869.fixed
issue-103869.rs
issue-103869.stderr
ivec-tag.rs
module-qualified-struct-destructure.rs
multiple-reprs.rs
namespaced-enum-emulate-flat-xc.rs
namespaced-enum-emulate-flat.rs
namespaced-enum-glob-import-xcrate.rs
namespaced-enum-glob-import.rs
namespaced-enums-xcrate.rs
namespaced-enums.rs
nested-enum-same-names.rs
newtype-struct-drop-run.rs
newtype-struct-with-dtor.rs
newtype-struct-xc-2.rs
newtype-struct-xc.rs
nonzero-enum.rs
numeric-fields.rs
rec-align-u32.rs remove support for rustc_safe_intrinsic attribute; use rustc_intrinsic functions instead 2024-11-08 09:16:00 +01:00
rec-align-u64.rs remove support for rustc_safe_intrinsic attribute; use rustc_intrinsic functions instead 2024-11-08 09:16:00 +01:00
rec-auto.rs
rec-extend.rs
rec-tup.rs
rec.rs
record-pat.rs
resource-in-struct.rs
simple-generic-tag.rs
simple-match-generic-tag.rs
small-enum-range-edge.rs
small-enums-with-fields.rs
struct_variant_xc_match.rs
struct_variant_xc.rs
struct-aliases-xcrate.rs
struct-aliases.rs
struct-destructuring-cross-crate.rs
struct-enum-ignoring-field-with-underscore.rs
struct-enum-ignoring-field-with-underscore.stderr
struct-field-shorthand.rs
struct-like-variant-construct.rs
struct-like-variant-match.rs
struct-lit-functional-no-fields.rs
struct-literal-dtor.rs
struct-new-as-field-name.rs
struct-order-of-eval-1.rs
struct-order-of-eval-2.rs
struct-order-of-eval-3.rs
struct-order-of-eval-4.rs
struct-partial-move-1.rs
struct-partial-move-2.rs
struct-path-associated-type.rs
struct-path-self.rs
struct-pattern-matching.rs
struct-variant-field-visibility.rs
tag-align-dyn-u64.rs
tag-align-dyn-variants.rs
tag-align-shape.rs
tag-align-u64.rs
tag-disr-val-shape.rs
tag-exports.rs
tag-in-block.rs
tag-variant-disr-type-mismatch.rs
tag-variant-disr-val.rs
tag.rs
tuple-struct-construct.rs
tuple-struct-constructor-pointer.rs
tuple-struct-destructuring.rs
tuple-struct-matching.rs
tuple-struct-trivial.rs
type-sizes.rs move strict provenance lints to new feature gate, remove old feature gates 2024-10-21 15:22:17 +01:00
uninstantiable-struct.rs
unit-like-struct-drop-run.rs
unit-like-struct.rs
variant-structs-trivial.rs