Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 7 pull requests #98667

Closed
wants to merge 28 commits into from
Closed

Conversation

Dylan-DPC
Copy link
Member

Successful merges:

Failed merges:

r? @ghost
@rustbot modify labels: rollup

Create a similar rollup

nbdd0121 and others added 28 commits June 8, 2022 21:32
you should always run x.py check before pushing
Fix FFI-unwind unsoundness with mixed panic mode

UB maybe introduced when an FFI exception happens in a `C-unwind` foreign function and it propagates through a crate compiled with `-C panic=unwind` into a crate compiled with `-C panic=abort` (rust-lang#96926).

To prevent this unsoundness from happening, we will disallow a crate compiled with `-C panic=unwind` to be linked into `panic-abort` *if* it contains a call to `C-unwind` foreign function or function pointer. If no such call exists, then we continue to allow such mixed panic mode linking because it's sound (and stable). In fact we still need the ability to do mixed panic mode linking for std, because we only compile std once with `-C panic=unwind` and link it regardless panic strategy.

For libraries that wish to remain compile-once-and-linkable-to-both-panic-runtimes, a `ffi_unwind_calls` lint is added (gated under `c_unwind` feature gate) to flag any FFI unwind calls that will cause the linkable panic runtime be restricted.

In summary:
```rust
#![warn(ffi_unwind_calls)]

mod foo {
    #[no_mangle]
    pub extern "C-unwind" fn foo() {}
}

extern "C-unwind" {
    fn foo();
}

fn main() {
    // Call to Rust function is fine regardless ABI.
    foo::foo();
    // Call to foreign function, will cause the crate to be unlinkable to panic-abort if compiled with `-Cpanic=unwind`.
    unsafe { foo(); }
    //~^ WARNING call to foreign function with FFI-unwind ABI
    let ptr: extern "C-unwind" fn() = foo::foo;
    // Call to function pointer, will cause the crate to be unlinkable to panic-abort if compiled with `-Cpanic=unwind`.
    ptr();
    //~^ WARNING call to function pointer with FFI-unwind ABI
}
```

Fix rust-lang#96926

``@rustbot`` label: T-compiler F-c_unwind
…ion-diagnostic-1, r=davidtwco

Migrate some `rustc_borrowck` diagnostics to `SessionDiagnostic`

Self-explanatory

r? ``@davidtwco``
…htriplett

Add `fetch_not` method on `AtomicBool`

This PR adds a `fetch_not` method on `AtomicBool` performs the NOT operation on the inner value.
Internally, this just calls the `fetch_xor` method with the value `true`.

[See this IRLO discussion](https://internals.rust-lang.org/t/could-we-have-fetch-not-for-atomicbool-s/16881)
Erase regions in New Abstract Consts

When an abstract const is constructed, we previously included lifetimes in the set of substitutes, so it was not able to unify two abstract consts if their lifetimes did not match but the values did, despite the values not depending on the lifetimes. This caused code that should have compiled to not compile.

Fixes rust-lang#98452

r? ``@lcnr``
…ial, r=RalfJung

Fix box with custom allocator in miri

This should fix the failures in rust-lang/miri#2072 and rust-lang#98510.

cc ``@RalfJung``
…on, r=oli-obk

Clean up arg mismatch diagnostic, generalize tuple wrap suggestion

This is based on top of rust-lang#97542, so just look at the last commit which contains the relevant changes.

1. Remove `final_arg_types` which was one of the last places we were using raw (`usize`) indices instead of typed indices in the arg mismatch suggestion code.
2. Improve the tuple wrap suggestion, now we suggest things like `call(a, b, c, d)` -> `call(a, (b, c), d)` 😺
3. Folded in fix rust-lang#98645
emit Retag for compound types with reference fields

I want to add an option to Miri to do retagging inside reference fields. But that means we first have to even emit `Retag` for types that *contain* references (rather than being of reference types). :)

Stacked Borrows originally did that, but we stopped doing it when hitting bunch of issues in the standard library. However I have since realized that we actually do emit `noalias` for newtypes references, which means for soundness we should recurse into fields. Also it'd probably be bad news if newtypes lose out on optimizations (and they don't, for anything else). I want to add an option for that to Miri so that we can start experimenting with those semantics.

r? `@oli-obk`
@rustbot rustbot added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jun 29, 2022
@rustbot rustbot added the rollup A PR which is a rollup label Jun 29, 2022
@Dylan-DPC
Copy link
Member Author

@bors r+ rollup=never p=5

@bors
Copy link
Contributor

bors commented Jun 29, 2022

📌 Commit 92d372a has been approved by Dylan-DPC

@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Jun 29, 2022
@bors
Copy link
Contributor

bors commented Jun 29, 2022

⌛ Testing commit 92d372a with merge deb787c514f7ca6254a85e78a5245bbfa689fb16...

@bors
Copy link
Contributor

bors commented Jun 29, 2022

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jun 29, 2022
@Dylan-DPC Dylan-DPC closed this Jun 29, 2022
@Dylan-DPC Dylan-DPC deleted the rollup-symzzsl branch June 29, 2022 12:28
@rust-log-analyzer
Copy link
Collaborator

The job test-various failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
test [ui] src/test/ui/wrong-hashset-issue-42918.rs ... ok

failures:

---- [ui] src/test/ui/unwind-abis/ffi-unwind-calls-lint.rs stdout ----

- warning: call to foreign function with FFI-unwind ABI
-   --> $DIR/ffi-unwind-calls-lint.rs:19:14
-    |
-    |
- LL |     unsafe { foo(); }
-    |              ^^^^^ call to foreign function with FFI-unwind ABI
- note: the lint level is defined here
-   --> $DIR/ffi-unwind-calls-lint.rs:4:9
-    |
-    |
- LL | #![warn(ffi_unwind_calls)]
- 
- warning: call to function pointer with FFI-unwind ABI
-   --> $DIR/ffi-unwind-calls-lint.rs:23:5
-    |
-    |
- LL |     ptr();
-    |     ^^^^^ call to function pointer with FFI-unwind ABI
- warning: 2 warnings emitted
- 
- 



The actual stderr differed from the expected stderr.
Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/unwind-abis/ffi-unwind-calls-lint/ffi-unwind-calls-lint.stderr
To only update this specific test, also pass `--test-args unwind-abis/ffi-unwind-calls-lint.rs`

error: 1 errors occurred comparing output.
status: exit status: 0
status: exit status: 0
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/unwind-abis/ffi-unwind-calls-lint.rs" "-Zthreads=1" "--target=wasm32-unknown-unknown" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Cstrip=debuginfo" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/unwind-abis/ffi-unwind-calls-lint" "-A" "unused" "-Crpath" "-O" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/wasm32-unknown-unknown/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/unwind-abis/ffi-unwind-calls-lint/auxiliary"
stdout: none
stderr: none


failures:
    [ui] src/test/ui/unwind-abis/ffi-unwind-calls-lint.rs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rollup A PR which is a rollup S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants