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

invalid_reference_casting lint catches some patterns that aren't UB #116410

Open
LegionMammal978 opened this issue Oct 4, 2023 · 18 comments · Fixed by #116421
Open

invalid_reference_casting lint catches some patterns that aren't UB #116410

LegionMammal978 opened this issue Oct 4, 2023 · 18 comments · Fixed by #116421
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. L-invalid_reference_casting Lint: invalid_reference_casting T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-opsem Relevant to the opsem team

Comments

@LegionMammal978
Copy link
Contributor

LegionMammal978 commented Oct 4, 2023

When reading the 1.73.0 release notes, I noticed that the invalid_reference_casting lint was made deny-by-default in #112431, under the premise that casting &T to &mut T via raw pointers is always UB under Stacked Borrows. However, the lint appears a bit overly strict, since such a cast does not cause UB when T is a zero-sized type:

#![allow(invalid_reference_casting)]

fn main() {
    let r1: &() = &();
    let r2: &mut () = unsafe { &mut *(r1 as *const _ as *mut _) };
    *r2 = ();
}

Without #![allow(invalid_reference_casting)], this cast triggers the lint in 1.75.0-nightly (187b813 2023-10-03):

error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell`
 --> src/main.rs:5:32
  |
5 |     let r2: &mut () = unsafe { &mut *(r1 as *const _ as *mut _) };
  |                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>
  = note: `#[deny(invalid_reference_casting)]` on by default

However, when the lint is disabled, Miri runs the program successfully, under both Stacked Borrows and Tree Borrows. This makes sense looking at the rules: the reference doesn't point to any bytes, so it doesn't need to perform any access or be granted any permissions.

This pattern looks a bit dubious when expressed as a reference cast, but it is not UB. Therefore, I would suggest downgrading or turning off the lint when the destination type is a ZST.

Note: An earlier version of this issue also considered directly casting from &UnsafeCell<i32> to &mut i32, which is legal under Stacked Borrows and Tree Borrows, but explicitly called out as UB in the UnsafeCell documentation. It was decided that linting on this case, as well as the related case of casting from &UnsafeCell<i32> to &mut UnsafeCell<i32> which isn't explicitly mentioned, is permissible as an enforcement of library UB until the aliasing rules are ultimately finalized. This was clarified in the diagnostic by #116421.

@LegionMammal978 LegionMammal978 added the C-bug Category: This is a bug. label Oct 4, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Oct 4, 2023
@Urgau
Copy link
Member

Urgau commented Oct 4, 2023

There is a difference between library UB and language UB and this is an example of one.

The documentation of UnsafeCell specifically says:

Note that the only valid way to obtain a *mut T pointer to the contents of a shared UnsafeCell is through .get() or .raw_get().

And even calls out against what your describing:

Even though T and UnsafeCell<T> have the same memory layout, the following is not allowed and undefined behavior:

unsafe fn not_allowed<T>(ptr: &UnsafeCell<T>) -> &mut T {
   let t = ptr as *const UnsafeCell<T> as *mut T;
   // This is undefined behavior, because the `*mut T` pointer
   // was not obtained through `.get()` nor `.raw_get()`:
   unsafe { &mut *t }
}

@RalfJung said here that he felt that linting here was justified. That still the case?

To me the lint is working as intended, this isn't a bug.

@rustbot label -needs-triage +A-lint

@rustbot rustbot added A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Oct 4, 2023
@RalfJung
Copy link
Member

RalfJung commented Oct 4, 2023

Yes, that was deliberate. But of course if people find it confusing we can always reconsider.

@LegionMammal978
Copy link
Contributor Author

LegionMammal978 commented Oct 4, 2023

There is a difference between library UB and language UB and this is an example of one.

The documentation of UnsafeCell specifically says:

Note that the only valid way to obtain a *mut T pointer to the contents of a shared UnsafeCell is through .get() or .raw_get().

And even calls out against what your describing:

Even though T and UnsafeCell<T> have the same memory layout, the following is not allowed and undefined behavior:

unsafe fn not_allowed<T>(ptr: &UnsafeCell<T>) -> &mut T {
   let t = ptr as *const UnsafeCell<T> as *mut T;
   // This is undefined behavior, because the `*mut T` pointer
   // was not obtained through `.get()` nor `.raw_get()`:
   unsafe { &mut *t }
}

To me the lint is working as intended, this isn't a bug.

I see how the first cast causes library UB according to the UnsafeCell documentation. However, a modified version of the first cast is still forbidden by the lint, even though it correctly uses .get() to "obtain a *mut T pointer to the contents of a shared UnsafeCell<T>":

let r1: &UnsafeCell<i32> = &UnsafeCell::new(0);
let r2: &mut UnsafeCell<i32> = unsafe { &mut *(r1 as *const _ as *mut _) };
unsafe { *r2.get() = 42 };

Also, even without UnsafeCell, there's still the case where the destination type is a ZST and requires no permission, but the lint still catches it. It's generally permitted to create a &mut ZST reference from any (non-null aligned) address at all, except for those of dangling allocations and locals, and creating it from a shared reference seems like just another case of that. Unless we mean to have some secret unwritten language UB that prevents &ZST-to-&mut ZST casts in particular?

@Urgau
Copy link
Member

Urgau commented Oct 4, 2023

let r1: &UnsafeCell<i32> = &UnsafeCell::new(0);
let r2: &mut UnsafeCell<i32> = unsafe { &mut *(r1 as *const _ as *mut _) };
unsafe { *r2.get() = 42 };

r2 is doing exactly what the documentation is saying to be undefined behavior. You want the .get() to be done on the creation of r2, like this:

let r1: &UnsafeCell<i32> = &UnsafeCell::new(0);
let r2: &mut UnsafeCell<i32> = unsafe { &mut *(r1.get() as *mut _) };

Otherwise it's still undefined behaviour according to the documentation.

As for the ZST concern I will let someone more knowledgeable address it.

@LegionMammal978
Copy link
Contributor Author

LegionMammal978 commented Oct 4, 2023

let r1: &UnsafeCell<i32> = &UnsafeCell::new(0);
let r2: &mut UnsafeCell<i32> = unsafe { &mut *(r1 as *const _ as *mut _) };
unsafe { *r2.get() = 42 };

r2 is doing exactly what the documentation is saying to be undefined behavior. You want the .get() to be done on the creation of r2, like this:

let r1: &UnsafeCell<i32> = &UnsafeCell::new(0);
let r2: &mut UnsafeCell<i32> = unsafe { &mut *(r1.get() as *mut _) };

Otherwise it's still undefined behaviour according to the documentation.

Where in the documentation does it talk "exactly" about creating a &mut UnsafeCell<T> from an &UnsafeCell<T>? My point is that the quoted text is talking only about creating a pointer to the contents of the UnsafeCell<T>, and says nothing about creating one to the cell itself.


If we go through the literal text of the UnsafeCell documentation regarding &mut references, it says:

If you have a reference &T, then normally in Rust the compiler performs optimizations based on the knowledge that &T points to immutable data. Mutating that data, for example through an alias or by transmuting an &T into an &mut T, is considered undefined behavior.

This is specifically referring to the case where T does not have interior mutability, and &T is truly immutable. (However, it is still missing the caveat of ZST references, unless we stretch "normally" to exclude that.)

There is no legal way to obtain aliasing &mut, not even with UnsafeCell<T>.

r2 is not aliased with any other &mut references.

If you create a safe reference with lifetime 'a (either a &T or &mut T reference), then you must not access the data in any way that contradicts that reference for the remainder of 'a.

A write access doesn't contradict an &UnsafeCell<T> reference.

A &mut T reference may be released to safe code provided neither other &mut T nor &T co-exist with it. A &mut T must always be unique.

r2 remains unique for its lifetime, and indeed it could be safely passed into a callback (as long as that callback can't cause a read access on r1).

Note that whilst mutating the contents of an &UnsafeCell<T> (even while other &UnsafeCell<T> references alias the cell) is ok (provided you enforce the above invariants some other way), it is still undefined behavior to have multiple &mut UnsafeCell<T> aliases. That is, UnsafeCell is a wrapper designed to have a special interaction with shared accesses (i.e., through an &UnsafeCell<_> reference); there is no magic whatsoever when dealing with exclusive accesses (e.g., through an &mut UnsafeCell<_>): neither the cell nor the wrapped value may be aliased for the duration of that &mut borrow.

Once again, r2 is not aliased with any other &mut UnsafeCell<i32> references. Perhaps this wording could be stretched as the cast "losing" the magic and making r2.get() no longer work, but that would be a very big stretch in the absence of explicit clarification.

Note that the only valid way to obtain a *mut T pointer to the contents of a shared UnsafeCell<T> is through .get() or .raw_get(). A &mut T reference can be obtained by either dereferencing this pointer or by calling .get_mut() on an exclusive UnsafeCell<T>.

This is the main relevant passage here. Again, this is very specifically talking about "obtain[ing] a *mut T pointer to the contents". When I convert r1 to r2, I am not obtaining a mutable reference to the i32 contained in the cell, but to the UnsafeCell<i32> itself. Then, I convert that to a shared reference and call .get() to validly obtain a *mut i32 pointer to the contents. At no point do I create a mutable pointer to the contents without calling .get() or .raw_get().

@fmease fmease added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Oct 4, 2023
@Urgau
Copy link
Member

Urgau commented Oct 4, 2023

Sorry, I didn't realise your point was about &UnsafeCell<T> -> &mut UnsafeCell<T> regardless of the inner T.

That's an interesting point.

The reference seems to agree with your interpretation:

Behavior considered undefined:
Mutating immutable data. All data inside a const item is immutable. Moreover, all data reached through a shared reference or data owned by an immutable binding is immutable, unless that data is contained within an UnsafeCell.

That would means that:

  • &UnsafeCell<T> -> &mut UnsafeCell<T> is fine
  • &T -> &mut T is only fine, if T has interior mutability
  • &UnsafeCell<T> -> &mut T is not fine and should use UnsafeCell::get or UnsafeCell::raw_get

Does this make sense?

EDIT: No, it doesn't.

This would means that for &A -> &mut B to be considered UB with casts:

  • A should not have interior mutability
  • OR if A has interior mutability then B should not have interior mutability (couldn't call UnsafeCell::{raw_,}get)

Another way to say it would be to say that for a given transformation &A -> &mut B only done with casts to not be consider lang and library UB A and B should have interior mutability.

@fmease fmease added the T-opsem Relevant to the opsem team label Oct 4, 2023
@RalfJung
Copy link
Member

RalfJung commented Oct 4, 2023

&UnsafeCell -> &mut UnsafeCell is fine

Eh what? &T -> &mut T is basically never fine, for any T. This has nothing to do with UnsafeCell.

@Urgau
Copy link
Member

Urgau commented Oct 4, 2023

&UnsafeCell -> &mut UnsafeCell is fine

Eh what? &T -> &mut T is basically never fine, for any T. This has nothing to do with UnsafeCell.

My bad, I mixed-up some things in my head, opsem is really not my strong suite. Sorry for the noise.

@LegionMammal978
Copy link
Contributor Author

LegionMammal978 commented Oct 4, 2023

&UnsafeCell -> &mut UnsafeCell is fine

Eh what? &T -> &mut T is basically never fine, for any T. This has nothing to do with UnsafeCell.

The thing is, we never actually say anywhere that &UnsafeCell<T>&mut UnsafeCell<T> is not fine. The documentation for UnsafeCell specifically says that &T&mut T is not fine when &T is a reference to immutable data, and that &UnsafeCell<T> is the exception to this rule, since it allows the data to be mutable.

Then, later, it expressly forbids converting &UnsafeCell<T> to &mut T directly, saying that the only valid way to mutably access the contents is through .get() or .raw_get(). However, the paragraph forbidding that says absolutely nothing about converting &UnsafeCell<T> to &mut UnsafeCell<T>. And nothing outside of that paragraph forbids that conversion either: the original &UnsafeCell<T> is valid for write accesses in general, and there's nothing violating the uniqueness of the &mut UnsafeCell<T> derived from it.

@RalfJung
Copy link
Member

RalfJung commented Oct 5, 2023

When it comes to library docs, everything that is not allowed is forbidden. You cannot make any assumptions about the internals of a library type except for those that are explicitly documented.

@RalfJung
Copy link
Member

RalfJung commented Oct 5, 2023

the original &UnsafeCell is valid for write accesses in general,

No, it isn't. At least we haven't documented that. The only thing we have documented is that you can call get on it and write to the pointer that it returns. For all you know, &UnsafeCell is a read-only pointer that only becomes read-write in get.

That's not how Stacked Borrows or Tree Borrows work, but it is possible (not likely, but possible) that we end up with an aliasing model that works like that.

@LegionMammal978
Copy link
Contributor Author

LegionMammal978 commented Oct 5, 2023

When it comes to library docs, everything that is not allowed is forbidden. You cannot make any assumptions about the internals of a library type except for those that are explicitly documented.

Isn't there general agreement that certain assumptions are allowed, even when the standard library docs don't explicitly permit them? In other words, the set of permitted unsafe operations on arbitrary types is strictly larger than "operations that can be performed with safe code and the standard library". The archetypical example here is take_mut, which you consider to be sound, and so do I, even though it has observable effects that cannot be generated safely. But meanwhile, the related operation of swapping equally-sized DSTs is not considered sound. Until we have a grand unified theory of safety invariants, there is a gray area wherever the docs don't explicitly permit nor forbid a particular operation.

@RalfJung
Copy link
Member

RalfJung commented Oct 6, 2023

We're grandfathering in patterns like take_mut, but this approach is in general not tenable -- it is not hard to end up in situations where two such extensions are mutually incompatible.

Also, this issue here is about an opsem (aliasing model) question more than it is about a safety invariant question.

@bors bors closed this as completed in 7d7004d Oct 6, 2023
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Oct 6, 2023
Rollup merge of rust-lang#116421 - Urgau:inter-mut-invalid_ref_casting, r=oli-obk

Clarify `invalid_reference_casting` lint around interior mutable types

This is PR intends to clarify the `invalid_reference_casting` lint around interior mutable types by adding a note for them saying that they should go through `UnsafeCell::get`.

So for this code:
```rust
let cell = &std::cell::UnsafeCell::new(0);
let _num = &mut *(cell as *const _ as *mut i32);
```

the following note will be added to the lint output:

```diff
 error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused,  consider instead using an `UnsafeCell`
   --> $DIR/reference_casting.rs:68:16
    |
 LL |     let _num = &mut *(cell as *const _ as *mut i32);
    |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>
+   = note: even for types with interior mutability, the only legal way to obtain a mutable pointer from a shared reference is through `UnsafeCell::get`
```

Suggestion are welcome around the note contents.

Fixes rust-lang#116410
cc `@RalfJung`
@LegionMammal978
Copy link
Contributor Author

LegionMammal978 commented Oct 6, 2023

Also, this issue here is about an opsem (aliasing model) question more than it is about a safety invariant question.

I'd say the UnsafeCell case is a safety invariant question in that it is not UB by the standards of our current aliasing models, but it is UB by virtue of its library docs explicitly saying that it is UB. (You were specifically saying above that this is about "the internals of a library type".) Right now, the current aliasing models are treated as a "source of truth" for the ultimate aliasing model, in that if a certain pattern gets through every configuration of Miri, and doesn't make assumptions about library types, it's generally considered acceptable; the alternative would be to ban all programs doing anything mildly peculiar with the aliasing rules until we finally decide on a model. UnsafeCell is only an exception here due to the additional rule in its documentation.

Also, how does #116421 solve the case of &ZST-to-&mut ZST casts, to which the current aliasing models also do not ascribe any language UB, and to which no library docs apply? This issue is not just about UnsafeCell. I am not aware of a precedent of preliminarily deciding that we have "secret unwritten language UB" that can be enforced by the compiler with a deny-by-default lint, even when the pattern is valid today.

@RalfJung
Copy link
Member

RalfJung commented Oct 6, 2023

For gray area we generally do reserve the right to deny, I think, in particular if there are good alternatives. (I don't know if there are good alternatives for this case.)

But yes for ZST the argument could be made that we're unlikely to make this actually UB in the future so maybe we shouldn't lint against this. I don't have a strong opinion either way, just a technical concern -- it can be hard to find out if the type is a ZST. We could possibly silence the lint if we're sure it's a ZST but still lint for generic types that might be ZST. The only concern with that is that the fact that the lint disappears on ZST could be interpreted as a promise that this is fine...

@LegionMammal978
Copy link
Contributor Author

LegionMammal978 commented Oct 6, 2023

But yes for ZST the argument could be made that we're unlikely to make this actually UB in the future so maybe we shouldn't lint against this. I don't have a strong opinion either way, just a technical concern -- it can be hard to find out if the type is a ZST. We could possibly silence the lint if we're sure it's a ZST but still lint for generic types that might be ZST. The only concern with that is that the fact that the lint disappears on ZST could be interpreted as a promise that this is fine...

Sure, I have no particular qualms with adding extra restrictions on "private ZST" types and whatnot, akin to the restrictions on ZST fields for repr(transparent). My main concern is that deny-by-default lints (except for future-incompat lints) should only be used for patterns that can't and won't ever do what they look like they're doing, and I don't think that performing odd but legal aliasing operations according to the current models meet this bar. (After all, what if we want to write programs specifically to demonstrate the minutiae of the aliasing models? It would be a pain to keep working around the compiler extraneously saying "no, this way is Wrong, you mustn't do it".)

If implicit promises are a real concern, then perhaps it might be useful to have something less forceful than a deny-by-default lint for patterns that could be dubious under alternative conceptions of the aliasing rules. But I personally don't see it as that big of an issue, given how compiler UB detection has always explicitly been on a "best-effort" basis rather than a hard guarantee.

Regardless, can this issue be re-opened until the ZST question is resolved?

@RalfJung
Copy link
Member

RalfJung commented Oct 7, 2023

odd but legal aliasing operations according according to the current models

We don't have a "current model", we just have a bunch of non-normative experiments.

But anyway, I reopened. Can you update the issue description to reflect that this is only about the ZST case now?

@RalfJung RalfJung reopened this Oct 7, 2023
@LegionMammal978
Copy link
Contributor Author

I have updated the issue description.

surechen added a commit to surechen/rust that referenced this issue Oct 10, 2023
commit 84d44dd1d8ec1e98fff94272ba4f96b2a1f044ca
Merge: fa6d1e75125 d23dc2093c2
Author: bors <[email protected]>
Date:   Tue Oct 10 06:04:08 2023 +0000

    Auto merge of #116366 - estebank:issue-103982, r=oli-obk

    Suggest labeling block if `break` is in bare block

    Fix #103982.

commit fa6d1e75125d9c94c21a58c2301492026031fcb8
Merge: 59edd670569 14d29be03c5
Author: bors <[email protected]>
Date:   Tue Oct 10 00:08:23 2023 +0000

    Auto merge of #109882 - ecnelises:aix_std, r=workingjubilee

    Support AIX in Rust standard library

    Also containing original contributions from `@bzEq` .

commit d23dc2093c2037a3f401d917ddb9e9c8507ef116
Author: Esteban Küber <[email protected]>
Date:   Mon Oct 9 22:48:10 2023 +0000

    Account for macros

commit 59edd67056919c83c59001a8b4f2d8749359377a
Merge: cdddcd3bea3 592163fb71a
Author: bors <[email protected]>
Date:   Mon Oct 9 21:03:41 2023 +0000

    Auto merge of #116497 - compiler-errors:impl-span, r=cjgillot

    Extend `impl`'s `def_span` to include its where clauses

    Typically, we highlight the def-span of an impl in a diagnostic due to either:
    1. coherence error
    2. trait evaluation cycle
    3. invalid implementation of built-in trait

    I find that an impl's where clauses are very often required to understanding why these errors come about, which is unfortunate since where clauses may be located on different lines and don't show up in the error. This PR expands the def-span of impls to include these where clauses.

    r? cjgillot since you've touched this code a while back to make some spans shorter, but you can also reassign to wg-diagnostics or compiler if you're busy or have no strong opinions.

commit c30d57bb77535f3923cbfa666e84d1916b6bce37
Author: Esteban Küber <[email protected]>
Date:   Wed Oct 4 01:29:45 2023 +0000

    fix

commit 5c17b8be61b69be6c38619f829ba81c64212110d
Author: Esteban Küber <[email protected]>
Date:   Tue Oct 3 21:34:52 2023 +0000

    Move some tests around

commit daac0114591777f29e2f6396e8c2bd5d2c506788
Author: Esteban Küber <[email protected]>
Date:   Tue Oct 3 00:20:59 2023 +0000

    Suggest labeling block if `break` is in bare block

    Fix #103982.

commit cdddcd3bea35049dab56888d4391cb9b5b1b4491
Merge: 317783ad2c1 89d610cd06f
Author: bors <[email protected]>
Date:   Mon Oct 9 17:14:17 2023 +0000

    Auto merge of #116532 - onur-ozkan:enable-rustflags-bootstrap-on-bootstrap, r=albertlarsan68

    Add RUSTFLAGS_BOOTSTRAP to RUSTFLAGS for bootstrap compilation

    Adds `RUSTFLAGS_BOOTSTRAP` to `RUSTFLAGS` for bootstrap compilation when `RUSTFLAGS_BOOTSTRAP` exists in the environment. With this PR, `RUSTFLAGS_BOOTSTRAP` will affect every build(as we already do for rustc and std) compiled with stage0 compiler.

    Resolves #94234

commit 317783ad2c128037ab1ab7722fa3fa61a9e481a5
Merge: be581d9f82a 27a5146e7cd
Author: bors <[email protected]>
Date:   Mon Oct 9 15:08:28 2023 +0000

    Auto merge of #116569 - matthiaskrgr:rollup-ni0jdd6, r=matthiaskrgr

    Rollup of 6 pull requests

    Successful merges:

     - #115882 (improve the suggestion of `generic_bound_failure`)
     - #116537 (Fix suggestion span involving wrongly placed generic arg on variant)
     - #116543 (In smir `find_crates` returns `Vec<Crate>` instead of `Option<Crate>`)
     - #116549 (Simplify some mir passes by using let chains)
     - #116556 (Sync rustc_codegen_cranelift)
     - #116561 (Add a test for fixed ICE)

    r? `@ghost`
    `@rustbot` modify labels: rollup

commit 27a5146e7cd669cd9979865c04929de10fd7b7b3
Merge: ea5cac02e89 2e000ebaa59
Author: Matthias Krüger <[email protected]>
Date:   Mon Oct 9 16:26:03 2023 +0200

    Rollup merge of #116561 - ouz-a:testfor_115517, r=compiler-errors

    Add a test for fixed ICE

    Addresses https://github.com/rust-lang/rust/issues/115517#issuecomment-1730164116

    Closes #115517

    r? ``@compiler-errors``

commit ea5cac02e8921e4e3aeb1830b68b88adc3898b27
Merge: 148f5c1bdf9 3ed37652593
Author: Matthias Krüger <[email protected]>
Date:   Mon Oct 9 16:26:02 2023 +0200

    Rollup merge of #116556 - bjorn3:sync_cg_clif-2023-10-09, r=bjorn3

    Sync rustc_codegen_cranelift

    The highlights this time are improved simd and inline asm support, `is_x86_feature_detected!()` returning the actual cpu features when inline asm support is enabled and a couple of bug fixes.

    r? ```@ghost```

    ```@rustbot``` label +A-codegen +A-cranelift +T-compiler +subtree-sync

commit 148f5c1bdf974e7fc9504aef156016a4852e2053
Merge: 2266e794212 47ebffabb81
Author: Matthias Krüger <[email protected]>
Date:   Mon Oct 9 16:26:02 2023 +0200

    Rollup merge of #116549 - DaniPopes:miropts-let-chains, r=oli-obk

    Simplify some mir passes by using let chains

commit 2266e79421279c63e7a6d5b92efe4800940012f9
Merge: 374c885f4a2 4ff6e87a8cb
Author: Matthias Krüger <[email protected]>
Date:   Mon Oct 9 16:26:01 2023 +0200

    Rollup merge of #116543 - ouz-a:crate_return_vec, r=oli-obk

    In smir `find_crates` returns `Vec<Crate>` instead of `Option<Crate>`

    Addresses https://github.com/rust-lang/project-stable-mir/issues/40

    r? `@oli-obk`

commit 374c885f4a29aaf391c5d5eaa1d4c01164725333
Merge: 389747c41dc 23a3b9e4492
Author: Matthias Krüger <[email protected]>
Date:   Mon Oct 9 16:26:01 2023 +0200

    Rollup merge of #116537 - gurry:116473-ice-sugg-overlap, r=compiler-errors

    Fix suggestion span involving wrongly placed generic arg on variant

    Fixes #116473

    The span computation was wrong. It went from the end of the variant to the end of the (wrongly placed) args. However, the variant lived in a different expansion and this resulted in a nonsensical span that overlaps with another and thereby leads to the ICE.

    In the fix I've changed span computation to not be based on the location of the variant, but purely on the location of the args. I simply extend the start of the args span 2 positions to the left and that includes the `::` and that's all we need apparently.

    This approach produces a correct span regardless of which macro/expansion the args reside in and where the variant is.

commit 389747c41dc81a23088d8aa27425923d7d81f70c
Merge: 7ed044c075f a8830631b94
Author: Matthias Krüger <[email protected]>
Date:   Mon Oct 9 16:26:00 2023 +0200

    Rollup merge of #115882 - aliemjay:diag-name-region-1, r=compiler-errors

    improve the suggestion of `generic_bound_failure`

    - Fixes #115375
    - suggest the bound in the correct scope: trait or impl header vs assoc item. See `tests/ui/suggestions/lifetimes/type-param-bound-scope.rs`
    - don't suggest a lifetime name that conflicts with the other late-bound regions of the function:
    ```rust
    type Inv<'a> = *mut &'a ();
    fn check_bound<'a, T: 'a>(_: T, _: Inv<'a>) {}
    fn test<'a, T>(_: &'a str, t: T, lt: Inv<'_>) { // suggests a new name `'a`
        check_bound(t, lt); //~ ERROR
    }
    ```

commit be581d9f82a1bcc547c685d7e1b411c246b0bb00
Merge: 7ed044c075f 1210aac1c00
Author: bors <[email protected]>
Date:   Mon Oct 9 13:18:47 2023 +0000

    Auto merge of #116142 - GuillaumeGomez:enum-variant-display, r=fmease

    [rustdoc] Show enum discrimant if it is a C-like variant

    Fixes https://github.com/rust-lang/rust/issues/101337.

    We currently display values for associated constant items in traits:

    ![image](https://github.com/rust-lang/rust/assets/3050060/03e566ec-c670-47b4-8ca2-b982baa7a0f4)

    And we also display constant values like [here](file:///home/imperio/rust/rust/build/x86_64-unknown-linux-gnu/doc/std/f32/consts/constant.E.html).

    I think that for coherency, we should display values of C-like enum variants.

    With this change, it looks like this:

    ![image](https://github.com/rust-lang/rust/assets/3050060/b53fbbe0-bdb1-4289-8537-f2dd4988e9ac)

    As for the display of the constant value itself, I used what we already have to keep coherency.

    We display the C-like variants value in the following scenario:
     1. It is a C-like variant with a value set => all the time
     2. It is a C-like variant without a value set: All other variants are C-like variants and at least one them has its value set.

    Here is the result in code:

    ```rust
    // Ax and Bx value will be displayed.
    enum A {
        Ax = 12,
        Bx,
    }

    // Ax and Bx value will not be displayed
    enum B {
        Ax,
        Bx,
    }

    // Bx value will not be displayed
    enum C {
        Ax(u32),
        Bx,
    }

    // Bx value will not be displayed, Cx value will be displayed.
    #[repr(u32)]
    enum D {
        Ax(u32),
        Bx,
        Cx = 12,
    }
    ```

    r? `@notriddle`

commit 1210aac1c00d9d3435ba801e0dee2d4ac502a738
Author: Guillaume Gomez <[email protected]>
Date:   Mon Oct 9 14:33:04 2023 +0200

    Add more complex test cases for enum discriminant display

commit 4b6fc8b70fd355614bad31d4268993dc7ef17431
Author: Guillaume Gomez <[email protected]>
Date:   Mon Oct 9 14:26:52 2023 +0200

    Improve code

commit 592163fb71a07383141a882d185d80b874490982
Author: Michael Goulet <[email protected]>
Date:   Fri Oct 6 20:35:52 2023 +0000

    Extend impl's def_span to include where clauses

commit 2e000ebaa59851b0be911f016375b20c3b5288c0
Author: Oğuz Ağcayazı <[email protected]>
Date:   Mon Oct 9 13:30:21 2023 +0300

    add test

commit 7ed044c075fc0e7ad2574d3144ca00ba14608d8f
Merge: 093b9d5b295 31cb61b3117
Author: bors <[email protected]>
Date:   Mon Oct 9 09:43:10 2023 +0000

    Auto merge of #115238 - workingjubilee:ich-entferne-welke-blumen, r=nikic

    Formally demote tier 2 MIPS targets to tier 3

    Per https://github.com/rust-lang/compiler-team/issues/648

    Fixes https://github.com/rust-lang/rust/issues/115218

commit 3ed37652593c188734b226dcecf920cee019961b
Author: bjorn3 <[email protected]>
Date:   Mon Oct 9 09:04:52 2023 +0000

    Remove no longer used dependency from the list of allowed dependencies

commit 169055f2ffef79b453e0d89599d0f0c5dabc0adb
Merge: 093b9d5b295 81dc066758e
Author: bjorn3 <[email protected]>
Date:   Mon Oct 9 08:52:46 2023 +0000

    Merge commit '81dc066758ec150b43822d4a0c84aae20fe10f40' into sync_cg_clif-2023-10-09

commit 81dc066758ec150b43822d4a0c84aae20fe10f40
Author: bjorn3 <[email protected]>
Date:   Mon Oct 9 08:33:47 2023 +0000

    Rustup to rustc 1.75.0-nightly (bf9a1c8a1 2023-10-08)

commit 88198c70e4f0eaf06231122a15d6c967ae0b6159
Merge: cc5db2c1c84 fea943debfa
Author: bjorn3 <[email protected]>
Date:   Mon Oct 9 08:26:09 2023 +0000

    Sync from rust bf9a1c8a193fc373897196321215794c8bebbeec

commit 4ff6e87a8cb0d5cba020917bc30ea0f7ef5d2a5b
Author: Oğuz Ağcayazı <[email protected]>
Date:   Sun Oct 8 22:55:16 2023 +0300

    return crates instead of a crate

commit 14d29be03c58587ef4bc7b3d2e1e1e29f2be5985
Author: Qiu Chaofan <[email protected]>
Date:   Mon Apr 3 12:33:51 2023 +0800

    Support AIX in Rust standard library

commit 093b9d5b295d85e144d0ee7da65ea03987214c06
Merge: 1f48cbc3f8d 005ec2e51ce
Author: bors <[email protected]>
Date:   Mon Oct 9 06:00:23 2023 +0000

    Auto merge of #116533 - cjgillot:skip-trivial-mir, r=oli-obk

    Do not run optimizations on trivial MIR.

    Fixes https://github.com/rust-lang/rust/issues/116513

    The bug was introduced in https://github.com/rust-lang/rust/pull/110728, which put the check too early in the query chain.

    cc `@oli-obk` `@ouz-a`

commit 47ebffabb81e80bb3ad3992af1fbb4035e362d77
Author: DaniPopes <[email protected]>
Date:   Mon Oct 9 05:22:31 2023 +0200

    Simplify some mir passes by using let chains

commit 23a3b9e44926aa0d4c49a722654ef59f010b55ba
Author: Gurinder Singh <[email protected]>
Date:   Mon Oct 9 08:04:00 2023 +0530

    Fix suggestion span involving wrongly placed generic arg on enum variants

    When the variant and the (wrongly placed) args are at separate
    source locations such as being in different macos or one in a macro and
    the other somwhere outside of it, the arg spans we computed spanned
    the entire distance between such locations and were hence invalid.
    .

commit 1f48cbc3f8dbd393a7e713a0f90d7c6ec72d58ee
Merge: 37fda989ea8 9d211b044d3
Author: bors <[email protected]>
Date:   Mon Oct 9 02:08:13 2023 +0000

    Auto merge of #116096 - cjgillot:debuginfo-fndef-size, r=nikic

    Make FnDef 1-ZST in LLVM debuginfo.

    Discussed in https://rust-lang.zulipchat.com/#narrow/stream/187780-t-compiler.2Fwg-llvm/topic/LLVM.20HEAD.20llvm.2Edbg.2Edeclare.2Falloca.20size.20mismatch

    r? `@nikic`

commit 37fda989ea8acb1db02748b8478c64e51a515bbd
Merge: bf9a1c8a193 ad8271dd56b
Author: bors <[email protected]>
Date:   Mon Oct 9 00:03:52 2023 +0000

    Auto merge of #116468 - nnethercote:rustc_serialize, r=Mark-Simulacrum

    Streamline `rustc_serialize`

    r? `@Mark-Simulacrum`

commit 31cb61b3117ca2a9957c19821e020d1d8c8534c7
Author: Jubilee Young <[email protected]>
Date:   Sun Oct 8 15:35:07 2023 -0700

    Drop all MIPS targets from CI

commit 14cdb3808dadcf9ee57f29d49a0d86c7bb545c91
Author: Jubilee Young <[email protected]>
Date:   Fri Aug 25 21:08:52 2023 -0700

    Drop mips*-unknown-linux-musl* to tier 3

    Also be more pedantic about spelling:
    - LE? Is it "less than or equal to"? Say "little endian".
    - We're Rust, not C, preserve the initial capital in "N64".
    - "MUSL" doesn't stand for anything; Rich Felker spells it "musl".

commit 03870154f4badc1939f718ac74c49438ce507241
Author: Jubilee Young <[email protected]>
Date:   Sun Jul 2 20:59:31 2023 -0700

    Drop mips*-unknown-linux-gnu* to tier 3

    In the process, be more pedantic about spelling:
    - LE? Do you mean "limited edition"? It's "little endian".
    - The name of the ABI is "N64" as in "Nintendo 64".

commit 9d211b044d3198f8e2c9a3e5678fafd2a61a5308
Author: Camille GILLOT <[email protected]>
Date:   Sun Oct 8 16:43:57 2023 +0000

    Ignore MSVC in test.

commit 098fc9715e0f0cc3aa5c6ff0512e389c24d09254
Author: Camille GILLOT <[email protected]>
Date:   Mon Sep 18 16:29:50 2023 +0000

    Make FnDef 1-ZST in LLVM debuginfo.

commit bf9a1c8a193fc373897196321215794c8bebbeec
Merge: 4f4a413fe69 7ecb09d05c0
Author: bors <[email protected]>
Date:   Sun Oct 8 15:18:22 2023 +0000

    Auto merge of #116515 - petrochenkov:nolegflavor, r=lqd

    linker: Remove unstable legacy CLI linker flavors

commit 4f4a413fe6931d0ad9d3ac6bd20ff36398961e64
Merge: 1e3c8f196b2 eaafb256f8e
Author: bors <[email protected]>
Date:   Sun Oct 8 12:38:14 2023 +0000

    Auto merge of #116454 - tmiasko:small-dominators, r=cjgillot

    Generalize small dominators optimization

    * Use small dominators optimization from 640ede7b0a1840415cb6ec881c2210302bfeba18 more generally.
    * Merge `DefLocation` and `LocationExtended` since they serve the same purpose.

commit 005ec2e51ce99c6dd5e88c273b3f9b273fdf3f41
Author: Camille GILLOT <[email protected]>
Date:   Sun Oct 8 12:08:09 2023 +0000

    Do not run optimizations on trivial MIR.

commit cc5db2c1c84169872f6278a3eb5f03c5abdef641
Merge: 81093441c16 2672876b63c
Author: bjorn3 <[email protected]>
Date:   Sun Oct 8 13:21:53 2023 +0200

    Merge pull request #1397 from bjorn3/inline_asm_tweaks

    Test inline asm support on CI

commit 1e3c8f196b2753b3e463bc6be2dc446f36653279
Merge: ab039f79b8a b704697fba5
Author: bors <[email protected]>
Date:   Sun Oct 8 10:50:33 2023 +0000

    Auto merge of #116183 - cjgillot:debug-dse-always, r=oli-obk

    Always preserve DebugInfo in DeadStoreElimination.

    This is a version of #106852 that does not check the current crate's debuginfo flag, and always attempts to preserve debuginfo.

    I haven't figured out how to handle mixing debuginfo levels for std, the one for the test, and the one for the CI target just right to merge #106852, so this can at least fix the debuginfo issue.

    Fixes https://github.com/rust-lang/rust/issues/103655

commit 89d610cd06f90cd6bd0bccdb395a3127290e1b45
Author: onur-ozkan <[email protected]>
Date:   Sun Oct 8 13:41:56 2023 +0300

    Add RUSTFLAGS_BOOTSTRAP to RUSTFLAGS for bootstrap compilation

    Note that RUSTFLAGS_BOOTSTRAP should always be added to the end of
    RUSTFLAGS to be actually effective (e.g., if we have `-Dwarnings` in
    RUSTFLAGS, passing `-Awarnings` from RUSTFLAGS_BOOTSTRAP should override it).

    Signed-off-by: onur-ozkan <[email protected]>

commit a8830631b9446c8b48cd4eba1ef448eb5a258cdc
Author: Ali MJ Al-Nasrawy <[email protected]>
Date:   Sun Oct 8 10:06:17 2023 +0000

    remove trailing dots

commit 996ffcb718941fc36ec5fdee38ed99ce20ec06d5
Author: Ali MJ Al-Nasrawy <[email protected]>
Date:   Sun Sep 17 14:32:02 2023 +0000

    always show and explain sub region

commit 5be0b2283aa26f0fee1e3d1161524a23d65484b7
Author: Ali MJ Al-Nasrawy <[email protected]>
Date:   Fri Sep 8 01:35:51 2023 +0000

    improve the suggestion of generic_bound_failure

commit 2672876b63c4e4a46071c4661cc06098ab746eac
Author: bjorn3 <[email protected]>
Date:   Sat Oct 7 11:14:24 2023 +0000

    Run inline asm rustc tests on CI

commit 91e5bd87e6ef2a3320bf610cb7cc2e2d64d7606f
Author: bjorn3 <[email protected]>
Date:   Sat Oct 7 11:14:10 2023 +0000

    Skip cpuid shim when inline asm support is enabled

    cg_clif should support enough simd intrinsics now to not need almost all
    cpu features to be force disabled. In addition they can't be disabled
    anyway when using a sysroot compiled by LLVM.

commit 07147f34d0691a0709b0e1f5ef62c8029d2da58d
Author: bjorn3 <[email protected]>
Date:   Sat Oct 7 11:12:46 2023 +0000

    Fix inline asm on macOS

commit 81093441c16dba56221bae016b394d0fb5dc57a2
Author: bjorn3 <[email protected]>
Date:   Sun Oct 8 09:30:32 2023 +0000

    Rustup to rustc 1.75.0-nightly (97c81e1b5 2023-10-07)

commit 1906ec56fce048588b319bfbc97126ba9d8c5de2
Merge: e759603da1d c9f6ac45d9a
Author: bjorn3 <[email protected]>
Date:   Sun Oct 8 09:22:39 2023 +0000

    Sync from rust 97c81e1b537088f1881c8894ee8579812ed9b6d1

commit ab039f79b8a0cfea01fb8aa10860560b9689e4c6
Merge: 6d271692b0c b563595c6e6
Author: bors <[email protected]>
Date:   Sun Oct 8 09:04:57 2023 +0000

    Auto merge of #116514 - petrochenkov:nogccld, r=lqd

    linker: Remove `-Zgcc-ld` option

    It is subsumed by `-Clinker-flavor=*-lld-cc -Clink-self-contained=+linker` options now.

    r? `@lqd`

commit 6d271692b0cc8ea1e91bbc8c090c88e7dbd5efe3
Merge: e08de860365 d9a7afec8b0
Author: bors <[email protected]>
Date:   Sun Oct 8 07:13:19 2023 +0000

    Auto merge of #116509 - Enselic:rustc-test-op, r=Mark-Simulacrum

    tests/run-make: Move RUSTC_TEST_OP to tools.mk and use in more places

commit b563595c6e6002ab582e2eb4ebd2a19baa8a1e34
Author: Vadim Petrochenkov <[email protected]>
Date:   Sat Oct 7 13:57:29 2023 +0300

    linker: Remove `-Zgcc-ld` option

    It is subsumed by `-Clinker-flavor=*-lld-cc -Clink-self-contained=+linker` options now

commit fea943debfab3859853ef623e06248ffbfd603ab
Merge: c9f6ac45d9a 2753052adf3
Author: bors <[email protected]>
Date:   Sun Oct 8 05:24:16 2023 +0000

    Auto merge of #116487 - tamird:avoid-unwrap-absolute, r=bjorn3

    compiler: env/path handling fixes

    Please see individual commits. r? `@bjorn3` cf. #116426

commit e08de860365aa73653dc5fc45b09f194785f3e57
Merge: 1516ca1bc01 3cac3de200a
Author: bors <[email protected]>
Date:   Sun Oct 8 05:24:16 2023 +0000

    Auto merge of #116487 - tamird:avoid-unwrap-absolute, r=bjorn3

    compiler: env/path handling fixes

    Please see individual commits. r? `@bjorn3` cf. #116426

commit 1516ca1bc01181af73c7b7760fb90137007da75f
Merge: fdf32ee9fcd 5048f813130
Author: bors <[email protected]>
Date:   Sun Oct 8 03:36:37 2023 +0000

    Auto merge of #116486 - van-ema:master, r=nikic

    Fix to register analysis passes with -Zllvm-plugins at link-time

    This PR fixes an unexpected behavior of the `-Zllvm-plugins` flag. It allows to run an out-of-tree pass as part of LTO.
    However, analysis passes are registered before the plugin is loaded. As a result an analysis pass, which is passed as a plugin, is not registered. This causes the LLVM PassManager to fail when the analysis pass is queried from a transformation pass  [(here)](https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/IR/PassManager.h#L776).

    This fix mimics the bahavior in [LLVM LTOBackend.cpp](https://github.com/llvm/llvm-project/blob/main/llvm/lib/LTO/LTOBackend.cpp#L273) by loading the plugin before the analysis passes are registered.

    Tested with rustc 1.60 and 1.65 and LLVM-13.0.1.

commit fdf32ee9fcd259913c7dece8f7b915b2d5560a49
Merge: e9addfdecf1 098dd979393
Author: bors <[email protected]>
Date:   Sun Oct 8 01:48:31 2023 +0000

    Auto merge of #116450 - Kobzol:automation-try-bors-ci, r=Mark-Simulacrum

    Enable new bors try branch to run on CI

    Needed to fix [this error](https://github.com/rust-lang/rust/actions/runs/6420044833/job/17431256956). Inspired by https://github.com/rust-lang/rust/pull/99988

    Also, removes `try-merge` from the workflow. It shouldn't have been added in https://github.com/rust-lang/rust/pull/116353.

    r? `@Mark-Simulacrum`

commit e9addfdecf14633324fc5c935f4f2983699bef7e
Merge: 97c81e1b537 209789ef4c2
Author: bors <[email protected]>
Date:   Sun Oct 8 00:04:17 2023 +0000

    Auto merge of #114623 - Kobzol:opt-dist-gha-summaries, r=Mark-Simulacrum

    Print some information from try builds to GitHub summary

    This PR adds some logs from `opt-dist` (the duration of the individual steps of the build pipeline, and the size of the resulting artifacts) to GitHub [job summaries](https://github.blog/2022-05-09-supercharging-github-actions-with-job-summaries/), in order to quickly show useful information right in the GHA CI job page, without needing to read the full log.

    [This](https://github.com/rust-lang-ci/rust/actions/runs/5810621086) is how the summary currently looks like.

    r? `@ghost`

commit 97c81e1b537088f1881c8894ee8579812ed9b6d1
Merge: cf21a0823b8 e53c7787772
Author: bors <[email protected]>
Date:   Sat Oct 7 20:59:32 2023 +0000

    Auto merge of #116416 - Kobzol:ci-host-llvm-17-0-2, r=Mark-Simulacrum

    Bump host compiler on x64 dist Linux to LLVM 17.0.2

    17.0.0-rc3 had a bunch of miscompilations, and it's probably better in general not to use a RC version of LLVM long term on CI.

commit cf21a0823b8a863fb3f1ed33d7d31bfd4881c2d3
Merge: 598e29bf700 81d1f7ea9d8
Author: bors <[email protected]>
Date:   Sat Oct 7 19:11:17 2023 +0000

    Auto merge of #116437 - nnethercote:rustc_features, r=Nilstrieb

    Clean up `rustc_features`

    Plenty more to be done, but this is a decent start.

    r? `@Nilstrieb`

commit 7ecb09d05c05daa437fba557b0f6733d6759c96c
Author: Vadim Petrochenkov <[email protected]>
Date:   Sat Oct 7 14:27:58 2023 +0300

    linker: Remove unstable legacy CLI linker flavors

commit 598e29bf70074de5ce2701a867450591083c4ff1
Merge: 935a091a783 258a65d4a20
Author: bors <[email protected]>
Date:   Sat Oct 7 17:10:02 2023 +0000

    Auto merge of #100806 - timvermeulen:split_inclusive_double_ended_bound, r=dtolnay

    Fix generic bound of `str::SplitInclusive`'s `DoubleEndedIterator` impl

    `str::SplitInclusive`'s `DoubleEndedIterator` implementation currently uses a `ReverseSearcher` bound for the corresponding searcher. A `DoubleEndedSearcher` bound should have been used instead.

    `DoubleEndedIterator` requires that repeated `next_back` calls produce the same items as repeated `next` calls, in opposite order. `ReverseSearcher` lets you search starting from the back of a string, but it makes no guarantees about how its matches correspond to the matches found by a forward search. `DoubleEndedSearcher` is a subtrait of `ReverseSearcher` and does require that the same matches are found in both directions.

    This bug fix is a breaking change. Calling `next_back` on `"a+++b".split_inclusive("++")` is currently accepted with repeated calls producing `"b"` and `"a+++"`, while forward iteration yields `"a++"` and `"+b"`. Also see https://github.com/rust-lang/rust/issues/100756#issuecomment-1221307166 for more details.

    I believe that this is the only iterator that uses this bound incorrectly — other related iterators such as `str::Split` do have a `DoubleEndedSearcher` bound for their `DoubleEndedIterator` implementation. And `slice::SplitInclusive` doesn't face this problem at all because it doesn't use patterns, only a predicate.

    cc `@SkiFire13`

commit 935a091a7834253a845a92629b8f1109b5befa5d
Merge: 91db3bdc8ce 8dc92a360c3
Author: bors <[email protected]>
Date:   Sat Oct 7 15:21:05 2023 +0000

    Auto merge of #116330 - RalfJung:dont-key-on-allocid, r=oli-obk

    remove Key impls for types that involve an AllocId

    I don't understand how but somehow that leads to issues like https://github.com/rust-lang/rust/issues/83085? Anyway removing unused impls doesn't seem like a bad idea. The concerning part is that of course nothing will stop us from having such impls again in the future, alongside re-introducing bugs like #83085.

    r? `@oli-obk`

commit 91db3bdc8cefa5a9bd58b8fbc3ce5ef1859b4b93
Merge: 48e24629e94 56e4715fc6e
Author: bors <[email protected]>
Date:   Sat Oct 7 13:33:19 2023 +0000

    Auto merge of #116310 - Enselic:check_fn_args_move_size, r=oli-obk

    rustc_monomorphize: Introduce check_fn_args_move_size()

    This is in preparation of improving diagnostics of "large moves into functions", a.k.a. passing args.

    Note: This PR consists of two self-contained commits that can be reviewed independently.

    For https://github.com/rust-lang/rust/issues/83518

    Also see https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/arg.20Spans.20for.20TerminatorKind.3A.3ACall.3F

    r? `@oli-obk` who is E-mentor

commit b0badc17cdc8d2f75061d2e4674a8adcfa8983d5
Author: Guillaume Gomez <[email protected]>
Date:   Sat Oct 7 14:37:47 2023 +0200

    Add cross-crate C-like variant test

commit de70a77be235f839dede3c06fdb70c5528f540e6
Author: Guillaume Gomez <[email protected]>
Date:   Sat Oct 7 14:37:30 2023 +0200

    Correctly handle cross-crate C-like variants

commit 1994d0b4a42b9b2d6e0c821f57d37a184f4df44a
Author: Guillaume Gomez <[email protected]>
Date:   Sat Oct 7 00:25:34 2023 +0200

    Update enum-variant-value test

commit 9e15f363be1f62cf81d4efb55d95a542663fe6da
Author: Guillaume Gomez <[email protected]>
Date:   Sat Oct 7 00:14:57 2023 +0200

    Only display enum variants integer values if one of them has a value set

commit e759603da1d281890cac241f244d2288c127b355
Author: bjorn3 <[email protected]>
Date:   Sat Oct 7 09:47:03 2023 +0000

    Consistently use eprintln inside the build system

commit 48e24629e946339943b194163a81374cf533ce5a
Merge: d087c6fae21 ad7045e160b
Author: bors <[email protected]>
Date:   Sat Oct 7 10:57:18 2023 +0000

    Auto merge of #115583 - RalfJung:packed-unsized, r=lcnr

    fix detecting references to packed unsized fields

    Fixes https://github.com/rust-lang/rust/issues/115396

    This is a breaking change, but permitted as a soundness fix.

commit d087c6fae215484bf47ba6dda1bc836ef4c07ac5
Merge: 0f3d72aa7a7 cbe892fd659
Author: bors <[email protected]>
Date:   Sat Oct 7 08:58:23 2023 +0000

    Auto merge of #116457 - RalfJung:try_eval_scalar_int, r=cjgillot

    fix fast-path for try_eval_scalar_int

    Cc https://github.com/rust-lang/rust/pull/116281 `@Nadrieril`

commit 56e4715fc6ef3cd8c008150ed0f1886a7696062f
Author: Martin Nordholts <[email protected]>
Date:   Sun Oct 1 09:03:41 2023 +0200

    rustc_monomorphize: Introduce check_fn_args_move_size()

    So that we later can improve the accuracy of diagnostics.

commit 41d24ccb49102bf6e2bfb5828f6d67abd8961e00
Author: Martin Nordholts <[email protected]>
Date:   Sun Oct 1 08:51:47 2023 +0200

    rustc_monomorphize: Move limit check into check_move_size()

    And rename to check_operand_move_size(). Later we will introduce
    check_fn_args_move_size().

commit 0f3d72aa7a71b58f487b7e4ed663cf5b23b746fd
Merge: fc01a7432be a04b7a37445
Author: bors <[email protected]>
Date:   Sat Oct 7 07:10:56 2023 +0000

    Auto merge of #116508 - RalfJung:miri, r=RalfJung

    Miri subtree update

    r? `@ghost`

commit d9a7afec8b079b16b6b6f2e23e1f375bc37b4abf
Author: Martin Nordholts <[email protected]>
Date:   Sat Oct 7 08:23:10 2023 +0200

    tests/run-make: Use RUSTC_TEST_OP in more places

commit 88966c477386db4ccabd18df3de52647d3540f96
Author: Martin Nordholts <[email protected]>
Date:   Sat Oct 7 08:14:38 2023 +0200

    tests/run-make: Move RUSTC_TEST_OP to tools.mk

    To reduce duplication. A follow-up commit will begin using it in even
    more places.

commit f96541e9a9be7a5b28191be9229d72c8bf47baa7
Author: Martin Nordholts <[email protected]>
Date:   Sat Oct 7 08:17:20 2023 +0200

    tests/run-make: Remove wrong blessing advice

    run-make tests are not special but can be blessed like other tests, like
    this:

        ./x.py test --bless tests/run-make/unknown-mod-stdin

commit a04b7a374458b640960798dffe83e614f7907562
Author: Ralf Jung <[email protected]>
Date:   Sat Oct 7 07:56:15 2023 +0200

    allow option-ext as a tool dependency (MPL licensed)

commit 5aecfe467b94c1d1a5124b119a8864d6dce8596f
Author: Ralf Jung <[email protected]>
Date:   Sat Oct 7 07:55:48 2023 +0200

    update lockfile

commit fc01a7432be662270467a4c3fa4a38811b621d9d
Merge: 4ea5190026d 6b98dcc743b
Author: bors <[email protected]>
Date:   Sat Oct 7 05:26:12 2023 +0000

    Auto merge of #109214 - tosti007:std_collection_hash_new_rework, r=workingjubilee

    Use `HashMap::with_capacity_and_hasher` instead of using base

    Cleans up the internal logic for `HashMap::with_capacity` slightly.

commit 1c42857135ca902122fdbe6e050ba1481431541b
Merge: 3b08930677e 722736ac4ab
Author: bors <[email protected]>
Date:   Sat Oct 7 05:18:45 2023 +0000

    Auto merge of #3113 - rust-lang:rustup-2023-10-07, r=saethlin

    Automatic sync from rustc

commit 722736ac4ab71b34645149b6994c0d56c6143832
Merge: d322243e388 4ea5190026d
Author: The Miri Conjob Bot <[email protected]>
Date:   Sat Oct 7 05:10:55 2023 +0000

    Merge from rustc

commit d322243e38808ab0078a8ecad32d31c8f5d8060e
Author: The Miri Conjob Bot <[email protected]>
Date:   Sat Oct 7 05:01:29 2023 +0000

    Preparing for merge from rustc

commit 4ea5190026dbc1302b644d938e68bc6843cb8b24
Merge: 93b6a365680 93677276bc4
Author: bors <[email protected]>
Date:   Sat Oct 7 02:20:50 2023 +0000

    Auto merge of #116318 - pitaj:android-backtrace-build, r=workingjubilee

    Invoke `backtrace-rs` buildscript in `std` buildscript

    Based on #99883 by `@Arc-blroth`
    Depends on rust-lang/backtrace-rs#556 and rust-lang/cc-rs#705

commit 93b6a36568027e44a7345ae8d577c0d13545c79f
Merge: 8fdb0a9b578 4b102b0d8d8
Author: bors <[email protected]>
Date:   Sat Oct 7 00:27:14 2023 +0000

    Auto merge of #116501 - workingjubilee:rollup-fpzov6m, r=workingjubilee

    Rollup of 4 pull requests

    Successful merges:

     - #116277 (dont call mir.post_mono_checks in codegen)
     - #116400 (Detect missing `=>` after match guard during parsing)
     - #116458 (Properly export function defined in test which uses global_asm!())
     - #116500 (Add tvOS to target_os for register_dtor)

    r? `@ghost`
    `@rustbot` modify labels: rollup

commit 4b102b0d8d8212bd2aca7ddd9ff8f699844e37c3
Merge: 5268120d4a1 3abef68e63e
Author: Jubilee <[email protected]>
Date:   Fri Oct 6 16:37:48 2023 -0700

    Rollup merge of #116500 - simlay:tvos-support-for-register_dtor, r=workingjubilee

    Add tvOS to target_os for register_dtor

    Closes #116491.

commit 5268120d4a10a879b0fe8aae0ffa9443b3e45266
Merge: 0d68e416a56 ecf271cfb62
Author: Jubilee <[email protected]>
Date:   Fri Oct 6 16:37:47 2023 -0700

    Rollup merge of #116458 - bjorn3:fix_global_asm_test, r=workingjubilee

    Properly export function defined in test which uses global_asm!()

    Currently the test passes with the LLVM backend as the codegen unit partitioning logic happens to place both the global_asm!() and the function which calls the function defined by the global_asm!() in the same CGU. With the Cranelift backend it breaks however as it will place all assembly in separate codegen units to be passed to an external linker.

commit 0d68e416a568ae0e206bcf65a2c5234565ba3bf5
Merge: 6d1c3a40cb4 8fd345dd4b8
Author: Jubilee <[email protected]>
Date:   Fri Oct 6 16:37:47 2023 -0700

    Rollup merge of #116400 - estebank:issue-78585, r=WaffleLapkin

    Detect missing `=>` after match guard during parsing

    ```
    error: expected one of `,`, `:`, or `}`, found `.`
      --> $DIR/missing-fat-arrow.rs:25:14
       |
    LL |         Some(a) if a.value == b {
       |                               - while parsing this struct
    LL |             a.value = 1;
       |             -^ expected one of `,`, `:`, or `}`
       |             |
       |             while parsing this struct field
       |
    help: try naming a field
       |
    LL |             a: a.value = 1;
       |             ++
    help: you might have meant to start a match arm after the match guard
       |
    LL |         Some(a) if a.value == b => {
       |                                 ++
    ```

    Fix #78585.

commit c9f6ac45d9a57e60ed4b2d63c96af49be2219ba1
Merge: ed900871cfc ffa2d3ab632
Author: Jubilee <[email protected]>
Date:   Fri Oct 6 16:37:46 2023 -0700

    Rollup merge of #116277 - RalfJung:post-mono, r=oli-obk

    dont call mir.post_mono_checks in codegen

    It seems like all tests are still passing when I remove this... let's see what CI says.

commit 6d1c3a40cb4ce7b455e44834f79c5ecf39cd5021
Merge: 960754090ac fa248cd9e69
Author: Jubilee <[email protected]>
Date:   Fri Oct 6 16:37:46 2023 -0700

    Rollup merge of #116277 - RalfJung:post-mono, r=oli-obk

    dont call mir.post_mono_checks in codegen

    It seems like all tests are still passing when I remove this... let's see what CI says.

commit 8fdb0a9b578ddbe7246d8088a93c09b7679c4616
Merge: 960754090ac 3706e6f61a9
Author: bors <[email protected]>
Date:   Fri Oct 6 22:39:41 2023 +0000

    Auto merge of #114709 - ShE3py:wasi-io-error-more, r=workingjubilee

    Use `io_error_more` on WASI

    #86442 added many variants to [`io::ErrorKind`](https://doc.rust-lang.org/stable/std/io/enum.ErrorKind.html), but `sys::wasi::decode_error_kind()` wasn't modified to use them.

    The preview1 `errno` list:
    https://github.com/WebAssembly/WASI/blob/4712d490fd7662f689af6faa5d718e042f014931/legacy/preview1/docs.md#-errno-variant

    Original implementation: #63814

    `@rustbot` label +A-error-handling +C-enhancement +O-wasi

commit 3abef68e63e12a1c6af2e09c2f020f778d2892ee
Author: Sebastian Imlay <[email protected]>
Date:   Fri Oct 6 18:11:49 2023 -0400

    Add tvOS to target_os for register_dtor

commit 91114d6616f58996b6009bcb23196e8dc253e8bf
Author: Guillaume Gomez <[email protected]>
Date:   Fri Oct 6 23:55:30 2023 +0200

    Show values of C-like variants even if not defined by the user

commit 960754090acc9cdd2a5a57586f244c0fc712d26c
Merge: 94bc9c737ea 7f0cf8c0e41
Author: bors <[email protected]>
Date:   Fri Oct 6 20:51:40 2023 +0000

    Auto merge of #116492 - matthiaskrgr:rollup-xzfhmq1, r=matthiaskrgr

    Rollup of 7 pull requests

    Successful merges:

     - #114564 (Attempt to describe the intent behind the `From` trait further)
     - #116297 (add some docs to hooks/mod.rs)
     - #116423 (Fix typo in attrs.rs)
     - #116466 (`rustc_transmute` cleanups)
     - #116474 (Assorted small cleanups)
     - #116481 (Reuse existing `Some`s in `Option::(x)or`)
     - #116484 (Minor doc clarification in Once::call_once)

    r? `@ghost`
    `@rustbot` modify labels: rollup

commit 7f0cf8c0e41dd5df27edfa57d42399dbab634320
Merge: f8dae0c20a0 c95015c2955
Author: Matthias Krüger <[email protected]>
Date:   Fri Oct 6 21:17:51 2023 +0200

    Rollup merge of #116484 - peterjoel:once-doc-clarify, r=cuviper

    Minor doc clarification in Once::call_once

commit f8dae0c20a03a584c12146c89253e2c2ef93d4b2
Merge: 9796dfdd563 5432d13bb04
Author: Matthias Krüger <[email protected]>
Date:   Fri Oct 6 21:17:50 2023 +0200

    Rollup merge of #116481 - scottmcm:tweak-combinators, r=cuviper

    Reuse existing `Some`s in `Option::(x)or`

    LLVM still has trouble re-using discriminants sometimes when rebuilding a two-variant enum, so when we have the correct variant already built, just use it.

    That's shorter in the Rust code, as well as simpler in MIR and the optimized LLVM, so might as well: <https://rust.godbolt.org/z/KhdE8eToW>

    Thanks to `@veber-alex` for pointing out this opportunity in https://github.com/rust-lang/rust/issues/101210#issuecomment-1732470941

commit 9796dfdd563d9b7d09088b94b8e3314c61a3786c
Merge: 25fbd133ea4 e7dabc9f877
Author: Matthias Krüger <[email protected]>
Date:   Fri Oct 6 21:17:50 2023 +0200

    Rollup merge of #116474 - nnethercote:rustc_assorted, r=spastorino

    Assorted small cleanups

    r? `@spastorino`

commit 25fbd133ea4a0cf3e76820fa09d4a7cdaeb62775
Merge: 81192f2fc46 29ed8e492ab
Author: Matthias Krüger <[email protected]>
Date:   Fri Oct 6 21:17:49 2023 +0200

    Rollup merge of #116466 - nnethercote:rustc_transmute, r=oli-obk

    `rustc_transmute` cleanups

    Just some things I found while poking around this code.

    r? `@oli-obk`

commit 81192f2fc46ee8483efc908314d8c5f5e314799d
Merge: fdb136a83f3 23efab4811c
Author: Matthias Krüger <[email protected]>
Date:   Fri Oct 6 21:17:49 2023 +0200

    Rollup merge of #116423 - eltociear:patch-22, r=flip1995

    Fix typo in attrs.rs

    documenation -> documentation

commit fdb136a83f32555c76911e9c77f62ad21cbfadd3
Merge: 4dfa5e5dec5 13e58755d7c
Author: Matthias Krüger <[email protected]>
Date:   Fri Oct 6 21:17:48 2023 +0200

    Rollup merge of #116297 - RalfJung:hooks, r=oli-obk

    add some docs to hooks/mod.rs

    r? `@oli-obk`

commit 4dfa5e5dec58f7c510b6e3722fa74b244d4ba887
Merge: 31be8cc4114 1651f1f4b8f
Author: Matthias Krüger <[email protected]>
Date:   Fri Oct 6 21:17:48 2023 +0200

    Rollup merge of #114564 - scottmcm:when-to-from, r=dtolnay

    Attempt to describe the intent behind the `From` trait further

    Inspired by the <https://internals.rust-lang.org/t/allow-use-as-and-try-as-for-from-and-tryfrom-traits/19240/26?u=scottmcm> thread.

    `@rustbot` label +T-libs-api

commit 94bc9c737ea97d56f9b4076553ac37c05c1e3931
Merge: 31be8cc4114 4483ac2206d
Author: bors <[email protected]>
Date:   Fri Oct 6 18:44:32 2023 +0000

    Auto merge of #114811 - estebank:impl-ambiguity, r=wesleywiser

    Show more information when multiple `impl`s apply

    - When there are `impl`s without type params, show only those (to avoid showing overly generic `impl`s).
    ```
    error[E0283]: type annotations needed
      --> $DIR/multiple-impl-apply.rs:34:9
       |
    LL |     let y = x.into();
       |         ^     ---- type must be known at this point
       |
    note: multiple `impl`s satisfying `_: From<Baz>` found
      --> $DIR/multiple-impl-apply.rs:14:1
       |
    LL | impl From<Baz> for Bar {
       | ^^^^^^^^^^^^^^^^^^^^^^
    ...
    LL | impl From<Baz> for Foo {
       | ^^^^^^^^^^^^^^^^^^^^^^
       = note: required for `Baz` to implement `Into<_>`
    help: consider giving `y` an explicit type
       |
    LL |     let y: /* Type */ = x.into();
       |          ++++++++++++
    ```

    - Lower the importance of `T: Sized`, `T: WellFormed` and coercion errors, to prioritize more relevant errors. The pre-existing deduplication logic deals with hiding redundant errors better that way, and we show errors with more metadata that is useful to the user.

    - Show `<SelfTy as Trait>::assoc_fn` suggestion in more cases.
    ```
    error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type
      --> $DIR/cross-return-site-inference.rs:38:16
       |
    LL |     return Err(From::from("foo"));
       |                ^^^^^^^^^^ cannot call associated function of trait
       |
    help: use a fully-qualified path to a specific available implementation
       |
    LL |     return Err(</* self type */ as From>::from("foo"));
       |                +++++++++++++++++++     +
    ```

    Fix #88284.

commit 3706e6f61a95225ce6cf3dca4c3d0b86545d9090
Author: ShE3py <[email protected]>
Date:   Fri Oct 6 19:05:45 2023 +0200

    Use `io_error_more` on WASI

commit 31be8cc41148983e742fea8f559aacca0f6647db
Merge: 64fa0c34d7c 6233d44815c
Author: bors <[email protected]>
Date:   Fri Oct 6 16:46:13 2023 +0000

    Auto merge of #116489 - flip1995:clippyup, r=Manishearth

    Clippy subtree sync

    r? `@Manishearth`

commit fa248cd9e6927dd6981078963aa47feb941a0d10
Author: Ralf Jung <[email protected]>
Date:   Fri Oct 6 18:25:23 2023 +0200

    add some comments explaining how the required_consts stuff fits together

commit 3b08930677e5f9b5999caa2e5960df8def1b1e73
Merge: 375ff3e5ce5 100ea2b4999
Author: bors <[email protected]>
Date:   Fri Oct 6 16:25:15 2023 +0000

    Auto merge of #3112 - RalfJung:rustup, r=RalfJung

    Rustup

    preparing for rustc-push

commit 100ea2b499955b2e0814719317c4092f95f988b1
Merge: ea56007362c 3706e6f61a9
Author: Ralf Jung <[email protected]>
Date:   Fri Oct 6 18:15:20 2023 +0200

    Merge from rustc

commit ea56007362cf04da6d776a89fa45f536c537c448
Author: Ralf Jung <[email protected]>
Date:   Fri Oct 6 18:15:12 2023 +0200

    Preparing for merge from rustc

commit 4483ac2206dd6ed1f80a9d1769a5635b1980d288
Author: Esteban Küber <[email protected]>
Date:   Thu Oct 5 03:57:10 2023 +0000

    Fix windows test that has different stderr output

commit 6233d44815ce681062fca851a254f2a37db7916e
Author: Philipp Krones <[email protected]>
Date:   Fri Oct 6 17:47:56 2023 +0200

    Update Cargo.lock

commit b704697fba5a1621000fbfbd53231cfa0b388878
Author: Camille GILLOT <[email protected]>
Date:   Tue Sep 26 21:13:31 2023 +0000

    Bless incremental tests.

commit 27d6a57e5821c8b7f5c8b049e36b856ed9440bfe
Author: Camille GILLOT <[email protected]>
Date:   Thu Jan 12 20:04:42 2023 +0000

    Preserve DebugInfo in DeadStoreElimination.

commit 375ff3e5ce54156db1443dca021e72a6ff8ec75c
Merge: 3c511bb4178 e1e880e9c6a
Author: bors <[email protected]>
Date:   Fri Oct 6 15:44:37 2023 +0000

    Auto merge of #3110 - eduardosm:rounding-without-host-floats, r=RalfJung

    Do not use host floats in `simd_{ceil,floor,round,trunc}`

commit 3c8c3ad6dfa95afcf4e70ccd692f976fc238e24c
Merge: 1bc0463b183 b105fb4c39b
Author: Philipp Krones <[email protected]>
Date:   Fri Oct 6 17:35:45 2023 +0200

    Merge commit 'b105fb4c39bc1a010807a6c076193cef8d93c109' into clippyup

commit b105fb4c39bc1a010807a6c076193cef8d93c109
Merge: 7217c0f3ac1 b8677e54d4e
Author: bors <[email protected]>
Date:   Fri Oct 6 15:34:34 2023 +0000

    Auto merge of #11629 - flip1995:rustup, r=flip1995

    Rustup

    r? `@ghost`

    changelog: none

commit b8677e54d4eb2181f539864d3594a0dd62f2f0d9
Author: Philipp Krones <[email protected]>
Date:   Fri Oct 6 17:32:44 2023 +0200

    Bump Clippy version -> 0.1.75

commit 50754da9fa2f956eed5af672ed3c7820d774ce91
Author: Philipp Krones <[email protected]>
Date:   Fri Oct 6 17:32:32 2023 +0200

    Bump nightly version -> 2023-10-06

commit 82c3064c47599978b4cbc11330a6c593219125ec
Merge: c5c6d703de7 7217c0f3ac1
Author: Philipp Krones <[email protected]>
Date:   Fri Oct 6 17:27:17 2023 +0200

    Merge remote-tracking branch 'upstream/master' into rustup

commit 7217c0f3ac15a20dd1cc1d5bc02f084f40db8029
Merge: 279127ce2e5 48d2770e527
Author: bors <[email protected]>
Date:   Fri Oct 6 15:06:00 2023 +0000

    Auto merge of #11628 - koka831:fix/11625, r=blyxyas

    Improve `redundant_locals` help message

    Fixes #11625

    AFAIK, `span_lint_and_help` points the beginning of spans when we pass multiple spans to the second argument, so This PR I also modified its help span and its message.

    lint result of the given example in the issue will be:

    ```console
    error: redundant redefinition of a binding `apple`
     --> src/main.rs:5:5
      |
    5 |     let apple = apple;
      |     ^^^^^^^^^^^^^^^^^^
      |
    help: `apple` is initially defined here
     --> src/main.rs:4:9
      |
    4 |     let apple = 42;
      |         ^^^^^
      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_locals
    ```

    I hope that this change might help reduce user confusion, but I'd appreciate alternative suggestions:)

    changelog: [`redundant_locals`]: Now points at the rebinding of the variable

commit 3c511bb41780f50cf7eef5a5e1e8a8804ae13ab9
Merge: 4587c7c1c04 bf1356efc3d
Author: bors <[email protected]>
Date:   Fri Oct 6 14:58:31 2023 +0000

    Auto merge of #3067 - Vanille-N:spurious-incremental, r=RalfJung

    Continuation of #3054: enable spurious reads in TB

    The last additions to the test suite of TB left some unresolved `#[should_panic]` that these new modifications solve.

    ## Problem

    Recall that the issues were arising from the interleavings that follow.

    ### A. `Reserved -> Frozen` has visible effects after function exit

    The transition `Reserved -> Frozen` irreversibly blocks write accesses to the tag, so in the interleaving below `y` initially `Reserved` becomes `Frozen` only in the target where a spurious read through `x` is inserted. This makes the later write through `y` UB only in the target and not in the source.
    ```
    1: retag x (&, protect)
    2: retag y (&mut, protect)
    1: spurious read x
    1: ret x
    2: ret y
    2: write y
    ```

    ### B. Protectors only announce their presence on retag

    There is a read-on-reborrow for protected locations, but if the retag of `x` occurs before that of `y` and there is no explicit access through `x`, then `y` is unaware of the existence of `x`. This is problematic because a spurious read inserted through `x` between the retag of `y` and the return of the function protecting `x` is a noalias violation in the target without UB in the source.
    ```
    1: retag x (&, protect)
    2: retag y (&mut, protect)
    1: spurious read x
    1: ret x
    2: write y
    2: ret y
    ```

    ## Step 1: Finer behavior for `Reserved`

    Since one problem is that `Reserved -> Frozen` has consequences beyond function exit, we decide to remove this transition entirely. To replace it we introduce a new subtype of `Reserved` with the extra boolean `aliased` set.
    `Reserved { aliased: true }` forbids child accesses, but only temporarily: it has no effect on activation once the tag is no longer protected.
    This makes the semantics of Tree Borrows slightly weaker in favor of being more similar to noalias.

    This solves interleaving **A.**, but **B.** is still a problem and the exhaustive tests do not pass yet.

    ## Step 2: Read on function exit

    Protected tags issue a "reminder" that they are protected until this instant inclusive, in the form of an implicit read (symmetrically to the implicit read on retag). This ensures that if the periods on which two tags `x` and `y` are protected overlap then no matter the interleaving of retags and returns, there is either a protector currently active or a read that has been emitted, both of which temporarily block activation.

    This makes the exhaustive test designed previously pass, but it has an effect on the ability to return an activated pointer that I had not foreseen before implementing it.

    ## Step 2': Do not propagate to children

    A naive implementation of **Step 2** makes the following code UB:
    ```rs
    fn reborrow(x: &mut u8) -> &mut u8 {
        let y = &mut *x;
        *y = *y;
        y // callee returns `y: Active`...
    }

    let x = &mut 0u8;
    let y = reborrow(x); // ... and caller receives `y: Frozen`
    *y = 1; // UB
    ```
    This is unacceptable, and a simple fix is to make this implicit read visible only to foreign tags.

    We still lack hindsight on the ramifications of this decision, and the fact that the problematic pattern was only discovered because it occured in one completely unrelated test (with a cryptic error message) is worrying. We should be vigilant as to how this interacts with the rest of the model.

    ## TODO

    As of commit #281c30, the data race model has not been fully updated.
    We have removed the reborrow of mutable references counting as a write access, but we still need the implicit read of function exit to count as a read.

commit 64fa0c34d7cb1a2d522414ab2c87024e465bd613
Merge: 1bc0463b183 8a1be9942d6
Author: bors <[email protected]>
Date:   Fri Oct 6 14:57:09 2023 +0000

    Auto merge of #115304 - Enselic:trailing-gt, r=cjgillot

    Allow file names to end with '>'

    The [`rustc_span::FileName`](https://doc.rust-lang.org/stable/nightly-rustc/rustc_span/enum.FileName.html) enum already differentiates between real files and "fake" files such as `<anon>`. We do not need to artificially forbid real file names from ending in `>`.

    Closes #73419

commit 279127ce2e5db187501e24631b49d635bae04865
Merge: 9554e477c29 dcc400191e4
Author: bors <[email protected]>
Date:   Fri Oct 6 14:19:45 2023 +0000

    Auto merge of #11611 - Alexendoo:items-after-test-module-check-crate, r=blyxyas

    Fix `items_after_test_module` for non root modules, add applicable suggestion

    Fixes #11050
    Fixes #11153

    changelog: [`items_after_test_module`]: Now suggests a machine-applicable suggestion.
    changelog: [`items:after_test_module`]: Also lints for non root modules

commit 3cac3de200a99ed29583ce95705696e4b4782c76
Author: Tamir Duberstein <[email protected]>
Date:   Fri Oct 6 08:35:45 2023 -0400

    rustc_metadata: use try_canonicalize

    This is simpler and avoids unnecessary calls to `env::current_dir`.

    rustc_plugin is left unchanged to avoid conflicts with #116412.

    Updates #116426.

commit 5aeb6a326f2fa941061b60c9286665847fe0401e
Author: Tamir Duberstein <[email protected]>
Date:   Fri Oct 6 08:32:00 2023 -0400

    rustc_codegen_ssa: use try_canonicalize in rpath

    This is simpler and avoids unnecessary calls to `env::current_dir`.

commit 48d2770e527dd21fd8ae71178d360abd005b6ddc
Author: koka <[email protected]>
Date:   Fri Oct 6 22:18:11 2023 +0900

    Improve `redundant_locals` help message

commit e1e880e9c6a8c756195720a51c0c0b5b1819d959
Author: Eduardo Sánchez Muñoz <[email protected]>
Date:   Fri Oct 6 15:12:36 2023 +0200

    Do not use host floats in `simd_{ceil,floor,round,trunc}`

commit 1bc0463b183392ad4e0ae9c5f7a76630d487230d
Merge: 6683f13fa1b 5674092e76f
Author: bors <[email protected]>
Date:   Fri Oct 6 13:07:15 2023 +0000

    Auto merge of #116483 - GuillaumeGomez:rollup-z65pno1, r=GuillaumeGomez

    Rollup of 6 pull requests

    Successful merges:

     - #115454 (Clarify example in docs of str::char_slice)
     - #115522 (Clarify ManuallyDrop bit validity)
     - #115588 (Fix a comment in std::iter::successors)
     - #116198 (Add more diagnostic items for clippy)
     - #116329 (update some comments around swap())
     - #116475 (rustdoc-search: fix bug with multi-item impl trait)

    r? `@ghost`
    `@rustbot` modify labels: rollup

commit a081007265044a7baa0f23c286b6380be35c8bb0
Author: Tamir Duberstein <[email protected]>
Date:   Fri Oct 6 08:22:35 2023 -0400

    rustc_driver: avoid fallible conversions

    Use `std::path::PathBuf` rather than `String`; use `std::env::var_os`
    rather than `std::env::var`. These changes avoid a number of error paths
    which can arise in the presence of non-UTF-8 paths.

commit 2753052adf3b21f7af1218b6a325484a5481658e
Author: Tamir Duberstein <[email protected]>
Date:   Fri Oct 6 08:51:30 2023 -0400

    compiler: always use var_os("RUST_BACKTRACE")

    There are 3 instances of var(...) and 3 instances of var_os(...); the
    latter avoids an appearance of unhandled error, so use it everywhere.

commit 7654d4b39833bc6fc0b0bcd184a616ff6ac7d9bd
Author: Tamir Duberstein <[email protected]>
Date:   Fri Oct 6 08:51:30 2023 -0400

    compiler: always use var_os("RUST_BACKTRACE")

    There are 3 instances of var(...) and 3 instances of var_os(...); the
    latter avoids an appearance of unhandled error, so use it everywhere.

commit dcc400191e444c8a57869f5004fdcbab807f7f09
Author: Alex Macleod <[email protected]>
Date:   Wed Oct 4 20:24:16 2023 +0000

    Fix `items_after_test_module` for non root modules, add applicable suggestion

commit bf1356efc3d3d2c6b5c3fb3157d234f7a0901bc8
Author: Neven Villani <[email protected]>
Date:   Wed Sep 20 14:27:20 2023 +0200

    Fix problems of Reserved -> Frozen

    Reserved loses permissions too quickly.
    Adding more fine-grained behavior of Reserved lets it lose
    write permissions only temporarily.
    Protected tags receive a read access on initialized locations.

commit 5048f813130f5c50fb95b784ad14ff40477c500b
Author: Emanuele Vannacci <[email protected]>
Date:   Fri Oct 6 12:04:28 2023 +0000

    fix to register analysis pass from llvm plugin

commit c95015c2955e8507f93a1106fa3f7eaafc25308b
Author: Peter Hall <[email protected]>
Date:   Fri Oct 6 12:20:39 2023 +0100

    Minor doc clarification in Once::call_once

commit 5674092e76f3736239910c892bf459ac686f47d1
Merge: 9e28a9349ce 1eb2a766417
Author: Guillaume Gomez <[email protected]>
Date:   Fri Oct 6 13:18:35 2023 +0200

    Rollup merge of #116475 - notriddle:notriddle/impl-trait-null, r=GuillaumeGomez

    rustdoc-search: fix bug with multi-item impl trait

    Preview searches:

    - https://notriddle.com/rustdoc-html-demo-5/compiler-doc-impl-trait-bugfix/index.html?search=-%3E%20globalctxt

    - https://notriddle.com/rustdoc-html-demo-5/compiler-doc-impl-trait-bugfix/index.html?search=globalctxt

commit 9e28a9349ce31ce0a246c4f76ae44c6efbf53545
Merge: 3785fed021d bfc0f23acb4
Author: Guillaume Gomez <[email protected]>
Date:   Fri Oct 6 13:18:35 2023 +0200

    Rollup merge of #116329 - RalfJung:swap-comments, r=scottmcm

    update some comments around swap()

    Based on ``@eddyb's`` comment [here](https://github.com/rust-lang/unsafe-code-guidelines/issues/461#issuecomment-1742156410).

    And then I noticed the wrong capitalization for Miri and fixed it in some other places as well.

commit 3785fed021dd834ebe40812c0e0f896cbcc5dce5
Merge: 382701e6b6c d464b72970f
Author: Guillaume Gomez <[email protected]>
Date:   Fri Oct 6 13:18:34 2023 +0200

    Rollup merge of #116198 - Jarcho:diag_items, r=WaffleLapkin

    Add more diagnostic items for clippy

commit 382701e6b6c4b65b5f4a00d6092cf8cef91f1181
Merge: 525c661842b 71429f5fd23
Author: Guillaume Gomez <[email protected]>
Date:   Fri Oct 6 13:18:34 2023 +0200

    Rollup merge of #115588 - tifv:fix-comment-successors, r=scottmcm

    Fix a comment in std::iter::successors

    The `unfold` function have since #58062 been renamed to `from_fn`.
    (I'm not sure if this whole comment is still useful—it's not like there are many iterators that *can't* be based on `from_fn`. Anyway, in its current form this comment is not correct, and it sent me into a half-hour research of what happened to `unfold` function, so I want to do *something* with it :upside_down_face: deleting these three lines is a perfectly fine alternative, in my opinion.)

commit 525c661842b5fd6be5b191a4f6baa2c79d722e36
Merge: 4e818f6b723 a16622f62f1
Author: Guillaume Gomez <[email protected]>
Date:   Fri Oct 6 13:18:33 2023 +0200

    Rollup merge of #115522 - joshlf:patch-8, r=scottmcm

    Clarify ManuallyDrop bit validity

    Clarify that `ManuallyDrop<T>` has the same bit validity as `T`.

commit 4e818f6b72398ff1693b7372b24af0e24a1bc07e
Merge: d4ba2b4c7c9 dfdab8fc629
Author: Guillaume Gomez <[email protected]>
Date:   Fri Oct 6 13:18:33 2023 +0200

    Rollup merge of #115454 - vwkd:patch-1, r=scottmcm

    Clarify example in docs of str::char_slice

    Just a one word improvement.

    “Last” can be misread as meaning the last (third) instead of the previous (first).

commit 6683f13fa1ba91ab84dd5bc5bc21965a1b0530e1
Merge: d4ba2b4c7c9 9baab45e2f2
Author: bors <[email protected]>
Date:   Fri Oct 6 11:12:13 2023 +0000

    Auto merge of #111595 - fortanix:raoul/waitqueue_clarifications, r=workingjubilee

    `waitqueue` clarifications for SGX platform

    The documentation of `waitqueue` functions on the `x86_64-fortanix-unknown-sgx` platform is incorrect at some places and on others missing. This PR improves upon this.

    cc: `@jethrogb`

commit ecf271cfb6224fae07a2b096bfbae22c6112b011
Author: bjorn3 <[email protected]>
Date:   Fri Oct 6 11:02:11 2023 +0000

    Use pushsection/popsection

commit 4587c7c1c044652a89104b8dccfd8e025aea177f
Merge: 413540837b9 03a03e2ef66
Author: bors <[email protected]>
Date:   Fri Oct 6 09:11:14 2023 +0000

    Auto merge of #3109 - RalfJung:dlsym, r=RalfJung

    add a direct dlsym test

commit 03a03e2ef66f80548681b8dbbf387b55e7b8a3cb
Author: Ralf Jung <[email protected]>
Date:   Fri Oct 6 11:06:16 2023 +0200

    add a direct dlsym test

commit 5432d13bb04cecf213c2753b25cfb1e366cb8026
Author: Scott McMurray <[email protected]>
Date:   Fri Oct 6 01:41:48 2023 -0700

    Reuse existing `Some`s in `Option::(x)or`

    LLVM still has trouble re-using discriminants sometimes when rebuilding a two-variant enum, so when we have the correct variant already built, just use it.

    That's simpler in LLVM *and* in MIR, so might as well: <https://rust.godbolt.org/z/KhdE8eToW>

commit d4ba2b4c7c938cf90c03a265cb31356537f608ad
Merge: ff057893b8a e300847864f
Author: bors <[email protected]>
Date:   Fri Oct 6 08:04:53 2023 +0000

    Auto merge of #116018 - DianQK:simd-wide-sum-test, r=scottmcm

    Increasing the SIMD size improves the vectorization possibilities

    Change the `simd-wide-sum.rs` to pass tests based on the LLVM main branch.

    For smaller lengths, we cannot expect to always get vectorized.

    A related discussion at https://rust-lang.zulipchat.com/#narrow/stream/187780-t-compiler.2Fwg-llvm/topic/LLVM.20HEAD.3A.20codegen.2Fsimd.2Fsimd-wide-sum.2Ers.20newly.20failing.

    r? scottmcm

commit 413540837b904e7cdf5d2b5ff137867268868095
Merge: f9003c08ab2 16cde069fc7
Author: bors <[email protected]>
Date:   Fri Oct 6 07:40:47 2023 +0000

    Auto merge of #3108 - RalfJung:dlsym, r=RalfJung

    refactor dlsym: dispatch symbols via the normal shim mechanism

    This avoids having to adjust Miri when switching between invoking the function via a linked symbol vs via dlsym.

commit 16cde069fc7e727dca3c6d8ec5077f0d2f6f928b
Author: Ralf Jung <[email protected]>
Date:   Fri Oct 6 09:38:50 2023 +0200

    allow dyn_sym in the files where they are defined; remove unreachable android code

commit 099311ba5a15162d73afe9ebe62bdc463ebd76c0
Author: Ralf Jung <[email protected]>
Date:   Fri Oct 6 09:20:51 2023 +0200

    make some things on foreign_items private

commit bc8d4dfa95ae10c3f7229c01710a9e8f838baaec
Author: Ralf Jung <[email protected]>
Date:   Fri Oct 6 09:15:48 2023 +0200

    refactor dlsym: dispatch symbols via the normal shim mechanism

commit e300847864faf93538354b418da0a1612efd36f4
Author: scottmcm <[email protected]>
Date:   Fri Oct 6 07:05:09 2023 +0000

    Add a wishlist FIXME

commit 1651f1f4b8f97a51f1699101cfe03ea129ec7a07
Author: Scott McMurray <[email protected]>
Date:   Thu Oct 5 23:03:02 2023 -0700

    Elaborate some caveats to lossless

commit f9003c08ab2e5d331ebd9285cc3a205d0b4c956c
Merge: 1a6ab015d00 dff7d5aa2f0
Author: bors <[email protected]>
Date:   Fri Oct 6 05:52:07 2023 +0000

    Auto merge of #3098 - BlackHoleFox:apple-entropy, r=RalfJung

    Support getentropy on macOS as a foreign item

    Prior this was always assumed to be accessed via `dlsym` shim, but in `std` I'm attempting to start [unconditionally linking](https://github.com/rust-lang/rust/pull/116319) to `getentropy` on macOS now that Rust's platform version support allows it.

    This just moves the main logic of the previous `dlsym` handler into an eval context extension so it can be used via both call paths. The `dlsym` handler is still needed as `getrandom` uses it.

commit dff7d5aa2f041f833901318ab8d301aeeb8ef06c
Author: BlackHoleFox <[email protected]>
Date:   Sun Oct 1 12:19:41 2023 -0500

    Move getentropy handling to a shared location for foreign item implementation

commit ff057893b8a2f20de2ff258ed8690f5a42fed78a
Merge: fd80c02c168 b29777a1862
Author: bors <[email protected]>
Date:   Fri Oct 6 05:34:36 2023 +0000

    Auto merge of #116472 - matthiaskrgr:rollup-1mz0qrp, r=matthiaskrgr

    Rollup of 2 pull requests

    Successful merges:

     - #116421 (Clarify `invalid_reference_casting` lint around interior mutable types)
     - #116469 (Fix typo in README.md)

    r? `@ghost`
    `@rustbot` modify labels: rollup

commit 1eb2a766417c755f6787358bfc36385a26c4ed31
Author: Michael Howell <[email protected]>
Date:   Thu Oct 5 22:32:37 2023 -0700

    rustdoc-search: fix bug with multi-item impl trait

commit 44f92c1f805434866b9744a6c8953ecdd8cc36f9
Author: scottmcm <[email protected]>
Date:   Fri Oct 6 05:31:54 2023 +0000

    Don't mention "recover the original" in `From` docs

    Co-authored-by: Josh Triplett <[email protected]>

commit b80e653ca1278a2c4fa411b938be1ccc7ed204fb
Author: Scott McMurray <[email protected]>
Date:   Sun Aug 6 14:54:55 2023 -0700

    Attempt to describe the intent behind the `From` trait further

commit b29777a18627464864611cb595677f21623e1be8
Merge: 7d7004d3e64 6ff3c3a421c
Author: Matthias Krüger <[email protected]>
Date:   Fri Oct 6 06:23:48 2023 +0200

    Rollup merge of #116469 - prakashAditya639:master, r=workingjubilee

    Fix typo in README.md

     the word "programatically" should be corrected to "programmatically."

commit 7d7004d3e64c27cdc71b06c177506edc11040410
Merge: 579be69de9f e46236cceb0
Author: Matthias Krüger <[email protected]>
Date:   Fri Oct 6 06:23:48 2023 +0200

    Rollup merge of #116421 - Urgau:inter-mut-invalid_ref_casting, r=oli-obk

    Clarify `invalid_reference_casting` lint around interior mutable types

    This is PR intends to clarify the `invalid_reference_casting` lint around interior mutable types by adding a note for them saying that they should go through `UnsafeCell::get`.

    So for this code:
    ```rust
    let cell = &std::cell::UnsafeCell::new(0);
    let _num = &mut *(cell as *const _ as *mut i32);
    ```

    the following note will be added to the lint output:

    ```diff
     error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused,  consider instead using an `UnsafeCell`
       --> $DIR/reference_casting.rs:68:16
        |
     LL |     let _num = &mut *(cell as *const _ as *mut i32);
        |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>
    +   = note: even for types with interior mutability, the only legal way to obtain a mutable pointer from a shared reference is through `UnsafeCell::get`
    ```

    Suggestion are welcome around the note contents.

    Fixes https://github.com/rust-lang/rust/issues/116410
    cc `@RalfJung`

commit e7dabc9f877d76e0a3432100d83b14b97978533d
Author: Nicholas Nethercote <[email protected]>
Date:   Fri Oct 6 14:59:11 2023 +1100

    Remove unnecessary `pub`.

commit 093b435b786dfd816aba790f0097943258a1b366
Author: Nicholas Nethercote <[email protected]>
Date:   Fri Oct 6 14:58:01 2023 +1100

    Remove unneeded features.

commit 4b51a3eb52c5ae292ba54c2044be695630fccc3e
Author: Nicholas Nethercote <[email protected]>
Date:   Fri Oct 6 14:57:25 2023 +1100

    Remove unneeded dependency.

    Also sort them.

commit e49a1470baee89823a49aa6ec7baa19aa033b88b
Author: Nicholas Nethercote <[email protected]>
Date:   Wed Oct 4 18:27:18 2023 +1100

    Factor out `insert_or_error`.

    It appears identically as a closure in two functions.

    Also change its return type from `bool` to `Option<()>` so it can be
    used with `?`.

commit 108e541cc2d73fc4548847a2cfddca5c3b3499e6
Author: Nicholas Nethercote <[email protected]>
Date:   Wed Oct 4 15:37:44 2023 +1100

    Remove unused `FileName::CfgSpec`.

commit 442a66d385bc2cdaf53b042437b9997d7b163d6d
Author: Nicholas Nethercote <[email protected]>
Date:   Tue Oct 3 17:03:58 2023 +1100

    Remove unneeded dependency.

commit fd80c02c168c2dfbb82c29d2617f524d2723205b
Merge: 5…
JanekGraff added a commit to JanekGraff/stm32f0xx-hal that referenced this issue Nov 24, 2023
NOTE: I have not tested this on hardware, just added the allow attribute.

Also see [this](rust-lang/rust#116410) issue
@jieyouxu jieyouxu added the L-invalid_reference_casting Lint: invalid_reference_casting label May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. L-invalid_reference_casting Lint: invalid_reference_casting T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-opsem Relevant to the opsem team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants