Skip to content

Rollup of 7 pull requests - #95572

Closed
matthiaskrgr wants to merge 20 commits into
rust-lang:masterfrom
matthiaskrgr:rollup-g1qdasf
Closed

Rollup of 7 pull requests#95572
matthiaskrgr wants to merge 20 commits into
rust-lang:masterfrom
matthiaskrgr:rollup-g1qdasf

Conversation

@matthiaskrgr

Copy link
Copy Markdown
Member

Successful merges:

Failed merges:

r? @ghost
@rustbot modify labels: rollup

Create a similar rollup

dtolnayand others added 20 commits March 31, 2022 12:34
**Description**
Add the `addr`, `with_addr, `map_addr` methods to the `NonNull` type,
and map the address type to `NonZeroUsize`.
**Motiviation**
The `NonNull` type is useful for implementing pointer types which have
the 0-niche. It is currently possible to implement these provenance
preserving functions by calling `NonNull::as_ptr` and `new_unchecked`.
The addition of these methods simply make it more ergonomic to use.
**Testing**
Added a unit test of a nonnull tagged pointer type. This is based on
some real code I have elsewhere, that currently routes the pointer
through a `NonZeroUsize` and back out to produce a usable pointer.
…r-errors
Make GATs object safe under generic_associated_types_extended feature
Based on rust-lang#94869
Let's say we have
```rust
trait StreamingIterator {
type Item<'a> where Self: 'a;
}
```
And `dyn for<'a> StreamingIterator<Item<'a> = &'a i32>`.
If we ask `(dyn for<'a> StreamingIterator<Item<'a> = &'a i32>): StreamingIterator`, then we have to prove that `for<'x> (&'x i32): Sized`. So, we generate *new* bound vars to subst for the GAT generics.
Importantly, this doesn't fully verify that these are usable and sound.
r? `@nikomatsakis`
Handle rustc_const_stable attribute in library feature collector
The library feature collector in [compiler/rustc_passes/src/lib_features.rs](https://github.com/rust-lang/rust/blob/551b4fa395fa588d91cbecfb0cdfe1baa02670cf/compiler/rustc_passes/src/lib_features.rs) has only been looking at `#[stable(…)]`, `#[unstable(…)]`, and `#[rustc_const_unstable(…)]` attributes, while ignoring `#[rustc_const_stable(…)]`. The consequences of this were:
- When any const feature got stabilized (changing one or more `rustc_const_unstable` to `rustc_const_stable`), users who had previously enabled that unstable feature using `#![feature(…)]` would get told "unknown feature", rather than rustc's nicer "the feature … has been stable since … and no longer requires an attribute to enable".
This can be seen in the way that rust-lang#93957 (comment) failed after rebase:
```console
error[E0635]: unknown feature `const_ptr_offset`
--> $DIR/offset_from_ub.rs:1:35
|
LL | #![feature(const_ptr_offset_from, const_ptr_offset)]
| ^^^^^^^^^^^^^^^^
```
- We weren't enforcing that a particular feature is either stable everywhere or unstable everywhere, and that a feature that has been stabilized has the same stabilization version everywhere, both of which we enforce for the other stability attributes.
This PR updates the library feature collector to handle `rustc_const_stable`, and fixes places in the standard library and test suite where `rustc_const_stable` was being used in a way that does not meet the rules for a stability attribute.
invalid_value lint: detect invalid initialization of arrays
…iagnostic, r=tmiasko
Add error message suggestion for missing noreturn in naked function
I had to google the syntax for inline asm's `noreturn` option when I got this error earlier today, so I figured I'd save others the trouble and add the syntax/fix as a suggestion in the error.
Implement provenance preserving methods on NonNull
### Description
Add the `addr`, `with_addr`, `map_addr` methods to the `NonNull` type, and map the address type to `NonZeroUsize`.
### Motivation
The `NonNull` type is useful for implementing pointer types which have the 0-niche. It is currently possible to implement these provenance preserving functions by calling `NonNull::as_ptr` and `new_unchecked`. The adding these methods makes it more ergonomic.
### Testing
Added a unit test of a non-null tagged pointer type. This is based on some real code I have elsewhere, that currently routes the pointer through a `NonZeroUsize` and back out to produce a usable pointer. I wanted to produce an ideal version of the same tagged pointer struct that preserved pointer provenance.
### Related
Extension of APIs proposed in rust-lang#95228 . I can also split this out into a separate tracking issue if that is better (though I may need some pointers on how to do that).
Fix `thread_local!` macro to be compatible with `no_implicit_prelude`
Fixes issue rust-lang#95533.
@rustbotrustbot added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. rollup A PR which is a rollup labels Apr 1, 2022
@matthiaskrgr

Copy link
Copy Markdown
MemberAuthor

@bors r+ rollup=never p=7

@bors

bors commented Apr 1, 2022

Copy link
Copy Markdown
Collaborator

📌 Commit b0cc70b has been approved by matthiaskrgr

@borsbors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Apr 1, 2022
@bors

bors commented Apr 1, 2022

Copy link
Copy Markdown
Collaborator

⌛ Testing commit b0cc70b with merge ef72b1a83ab3d0c839ad57f4a69ae342c4c100f6...

@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job x86_64-gnu-nopt failed! Check out the build log: (web)(plain)

Click to see the possible cause of the failure (guessed by this bot)

---- [ui (nll)] ui/generic-associated-types/trait-objects.rs#extended stdout ----
diff of stderr:
- error[E0621]: explicit lifetime required in the type of `x`
- --> $DIR/trait-objects.rs:16:7
+ error[E0521]: borrowed data escapes outside of function
3 |
3 |
4 LL | fn min_size(x: &mut dyn for<'a> StreamingIterator<Item<'a> = &'a i32>) -> usize {
- | ------------------------------------------------------ help: add explicit lifetime `'a` to the type of `x`: `&'a mut (dyn StreamingIterator<for<'a> Item = &'a i32> + 'a)`
+ | - - let's call the lifetime of this reference `'1`
+ | |
+ | `x` is a reference that is only valid in the function body
7 LL | x.size_hint().0
7 LL | x.size_hint().0
- | ^^^^^^^^^ lifetime `'a` required
+ | |
+ | |
+ | `x` escapes the function body here
+ | argument requires that `'1` must outlive `'static`
10 error: aborting due to previous error
11 - For more information about this error, try `rustc --explain E0621`.
- For more information about this error, try `rustc --explain E0621`.
+ For more information about this error, try `rustc --explain E0521`.
13 The actual stderr differed from the expected stderr.
Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/generic-associated-types/trait-objects.extended.nll/trait-objects.extended.nll.stderr
To only update this specific test, also pass `--test-args generic-associated-types/trait-objects.rs`
Some tests failed in compiletest suite=ui compare_mode=Nll mode=ui host=x86_64-unknown-linux-gnu target=x86_64-unknown-linux-gnu
error in revision `extended`: 1 errors occurred comparing output.
status: exit status: 1
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/generic-associated-types/trait-objects.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--cfg" "extended" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/generic-associated-types/trait-objects.extended.nll" "-Zborrowck=mir" "-A" "unused" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/generic-associated-types/trait-objects.extended.nll/auxiliary"
stdout: none
--- stderr -------------------------------
error[E0521]: borrowed data escapes outside of function
|
|
LL | fn min_size(x: &mut dyn for<'a> StreamingIterator<Item<'a> = &'a i32>) -> usize {
| - - let's call the lifetime of this reference `'1`
| |
| `x` is a reference that is only valid in the function body
LL | //[base]~^ the trait `StreamingIterator` cannot be made into an object
LL | x.size_hint().0
| |
| |
| `x` escapes the function body here
| argument requires that `'1` must outlive `'static`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0521`.
------------------------------------------

@bors

bors commented Apr 2, 2022

Copy link
Copy Markdown
Collaborator

💔 Test failed - checks-actions

@borsbors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Apr 2, 2022
@matthiaskrgr
matthiaskrgr deleted the rollup-g1qdasf branch July 30, 2022 10:32
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rollupA PR which is a rollupS-waiting-on-reviewStatus: Awaiting review from the assignee but also interested parties.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

12 participants

@matthiaskrgr@bors@rust-log-analyzer@rustbot@Dylan-DPC@dtolnay@jam1garner@declanvk@niluxv@lcnr@RalfJung@jackh726