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 4 pull requests #71853

Merged
merged 33 commits into from
May 3, 2020
Merged

Rollup of 4 pull requests #71853

merged 33 commits into from
May 3, 2020

Conversation

Dylan-DPC-zz
Copy link

Successful merges:

Failed merges:

r? @ghost

ThinkChaos and others added 30 commits April 26, 2020 11:43
In the same vein as `Cell::take` and `Option::take`.
This partially reverts commit 4b5b6cb,
reversing some changes made to 62b3624.
Co-Authored-By: Ralf Jung <[email protected]>
Co-Authored-By: Oliver Scherer <[email protected]>
Avoids having to repeat InterpErrorInfo { .. }
…asKalbertodt

Add `RefCell::take`

Add `RefCell::take` to match `Cell` and `Option`.
I also changed a couple of calls to `.replace` to `.take`.

Tracking issue is rust-lang#71395.

This is my first contribution, please tell me if there's anything I could improve, thanks!
Dylan-DPC added 3 commits May 3, 2020 18:34
…rror, r=RalfJung

Fix exceeding bitshifts not emitting for assoc. consts (properly this time, I swear!)

Fixes rust-lang#69021 and fixes rust-lang#71353.

As described in rust-lang#71353 (comment), this PR:

- adds a variant of `try_validation!` called `try_validation_pat!` that allows specific failures to be turned into validation failures (but returns the rest, unchanged), and
- allows `InvalidProgram` to be returned out of validation

r? @RalfJung
Suggest deref when coercing `ty::Ref` to `ty::RawPtr` with arbitrary mutability

Fixes rust-lang#71676
1. Implement dereference suggestion when coercing `ty::Ref` to `ty::RawPtr` with arbitrary mutability.
2. Extract the dereference steps into `deref_steps()`, which removes all the `use` and `pub` noise introduced by last PR rust-lang#71540, and makes the code more readable.
3. Use the `remove_prefix()` closure which makes the prefix removal more readable.
4. Introduce `Applicability` as a return value of `check_ref` to suggest `Applicability::Unspecified` suggestion.

**Special**: I found it is not possible to genereate `Applicability::MachineApplicable` suggestion for situation like this:
```rust
use std::ops::Deref;
use std::ops::DerefMut;
struct Bar(u8);
struct Foo(Bar);
struct Emm(Foo);
impl Deref for Bar{
    type Target = u8;
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
impl Deref for Foo {
    type Target = Bar;
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
impl Deref for Emm {
    type Target = Foo;
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
impl DerefMut for Bar{
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}
impl DerefMut for Foo {
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}
impl DerefMut for Emm {
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}
fn main() {
    let a = Emm(Foo(Bar(0)));
    let _: *mut u8 = &a; //~ ERROR mismatched types
}
```
We may suggest `&mut ***a` here, but the `a` is not declared as mutable variable. And also when processing HIR, it's not possible to check if `a` is declared as a mutable variable (currently we do borrow checking with MIR). So we cannot ensure that suggestion when coercing immutable reference to mutable pointer is always machine applicable. Therefore I added a `Applicability` return value in `check_ref()`. And move the `immutable reference -> mutable pointer` situation into a sperate test file without `run-rustfix`. (It seems that `run-rustfix` will also adopt `Applicability::Unspecified` suggestion, which is strange)
…uillaumeGomez

Add long error explanation for E0539

since this error is similar to [E0551](https://github.com/rust-lang/rust/blob/master/src/librustc_error_codes/error_codes/E0551.md) most of the content was copied from it. part of rust-lang#61137.
@Dylan-DPC-zz
Copy link
Author

@bors r+ rollup=never p=4

@bors
Copy link
Contributor

bors commented May 3, 2020

📌 Commit ce1dba9 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 May 3, 2020
@bors
Copy link
Contributor

bors commented May 3, 2020

⌛ Testing commit ce1dba9 with merge ea733c3...

@bors
Copy link
Contributor

bors commented May 3, 2020

☀️ Test successful - checks-azure
Approved by: Dylan-DPC
Pushing ea733c3 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label May 3, 2020
@bors bors merged commit ea733c3 into rust-lang:master May 3, 2020
@bors bors mentioned this pull request May 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants