about summary refs log tree commit diff
path: root/compiler/rustc_mir_transform/src
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2024-11-15 23:38:11 +0100
committerGitHub <noreply@github.com>2024-11-15 23:38:11 +0100
commitc3a632c28bc8d175d228f35aaa370dc50929e3da (patch)
tree2be5d27dd76355717a94a04dc6a3671bec92b78f /compiler/rustc_mir_transform/src
parentb3e2981ff75dc8d2135894d0d0975046367f3855 (diff)
parent7f0275636ebcd4808a4e1b2752b139c2e792e1f3 (diff)
downloadrust-c3a632c28bc8d175d228f35aaa370dc50929e3da.tar.gz
rust-c3a632c28bc8d175d228f35aaa370dc50929e3da.zip
Rollup merge of #133074 - ferrocene:ja-make-ui-test-os-agnostic, r=Noratrieb
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.
Diffstat (limited to 'compiler/rustc_mir_transform/src')
0 files changed, 0 insertions, 0 deletions