Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Rollup of 9 pull requests #128248

Closed
wants to merge 36 commits into from
Closed

Conversation

tgross35
Copy link
Contributor

Successful merges:

r? @ghost
@rustbot modify labels: rollup

Create a similar rollup

Skgland and others added 30 commits July 4, 2024 21:27
the current title is too similar to that of the page for
std::result::Result, which is a problem both for
navigating to the Result docs via browser autocomplete, and for
being able to tell which tab is which when the width of tabs is
small.
This has been bugging me for a while. I find complex "if any of these
are true" conditions easier to think about than complex "if all of these
are true" conditions, because you can stop as soon as one is true.
It has a single call site. This change makes the two `needs_collect`
conditions more similar to each other, and therefore easier to
understand.
I have always found `is_complete` an unhelpful name. The new name (and
inverted sense) fits in better with the conditions at its call sites.
The current code is this:
```
self.capture_state.replace_ranges.push((start_pos..end_pos, Some(target)));
self.capture_state.replace_ranges.extend(inner_attr_replace_ranges);
```
What's not obvious is that every range in `inner_attr_replace_ranges`
must be a strict sub-range of `start_pos..end_pos`. Which means, in
`LazyAttrTokenStreamImpl::to_attr_token_stream`, they will be done
first, and then the `start_pos..end_pos` replacement will just overwrite
them. So they aren't needed.
Imagine you have replace ranges (2..20,X) and (5..15,Y), and these tokens:
```
a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x
```
If we replace (5..15,Y) first, then (2..20,X) we get this sequence
```
a,b,c,d,e,Y,_,_,_,_,_,_,_,_,_,p,q,r,s,t,u,v,w,x
a,b,X,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,u,v,w,x
```
which is what we want.

If we do it in the other order, we get this:
```
a,b,X,_,_,_,_,_,_,_,_,_,_,_,_,p,q,r,s,t,u,v,w,x
a,b,X,_,_,Y,_,_,_,_,_,_,_,_,_,_,_,_,_,_,u,v,w,x
```
which is wrong. So it's true that we need the `.rev()` but the comment
is wrong about why.
A fully imperative style is easier to read than a half-iterator,
half-imperative style. Also, rename `inner_attr` as `attr` because it
might be an outer attribute.
This was handled correctly already for `extern unsafe fn()`.

Co-authored-by: Folkert <folkert@folkertdev.nl>
…tr, r=dtolnay

Stabilize const `{integer}::from_str_radix` i.e. `const_int_from_str`

This PR stabilizes the feature `const_int_from_str`.

- ACP Issue: rust-lang/libs-team#74
- Implementation PR: rust-lang#99322
- Part of Tracking Issue: rust-lang#59133

API Change Diff:

```diff
impl {integer} {
- pub       fn from_str_radix(src: &str, radix: u32) -> Result<Self, ParseIntError>;
+ pub const fn from_str_radix(src: &str, radix: u32) -> Result<Self, ParseIntError>;
}

impl ParseIntError {
- pub       fn kind(&self) -> &IntErrorKind;
+ pub const fn kind(&self) -> &IntErrorKind;
}
```
This makes it easier to parse integers at compile-time, e.g.
the example from the Tracking Issue:

```rust
env!("SOMETHING").parse::<usize>().unwrap()
```

could now be achived  with

```rust
match usize::from_str_radix(env!("SOMETHING"), 10) {
  Ok(val) => val,
  Err(err) => panic!("Invalid value for SOMETHING environment variable."),
}
```

rather than having to depend on a library that implements or manually implement the parsing at compile-time.

---

Checklist based on [Libs Stabilization Guide - When there's const involved](https://std-dev-guide.rust-lang.org/development/stabilization.html#when-theres-const-involved)

I am treating this as a [partial stabilization](https://std-dev-guide.rust-lang.org/development/stabilization.html#partial-stabilizations) as it shares a tracking issue (and is rather small), so directly opening the partial stabilization PR for the subset (feature `const_int_from_str`) being stabilized.

- [x] ping Constant Evaluation WG
- [x] no unsafe involved
- [x] no `#[allow_internal_unstable]`
- [ ] usage of `intrinsic::const_eval_select` rust-lang#124625 in `from_str_radix_assert` to change the error message between compile-time and run-time
- [ ] [rust-labg/libs-api FCP](rust-lang#124941 (comment))
…ssages, r=bjorn3

`#[naked]`: report incompatible attributes

tracking issue: rust-lang#90957

this is a re-implementation of rust-lang#93809 by `@bstrie` which was closed 2 years ago due to inactivity.

This PR takes some of the final comments into account, specifically providing a little more context in error messages, and using an allow list to determine which attributes are compatible with `#[naked]`.

Notable attributes that are incompatible with `#[naked]` are:

  * `#[inline]`
  * `#[track_caller]`
  * ~~`#[target_feature]`~~ (this is now allowed, see discussion below)
  * `#[test]`, `#[ignore]`, `#[should_panic]`

There may be valid use cases for `#[target_feature]` but for now it is disallowed. The others just directly conflict with what `#[naked]` should do.

Naked functions are still important for systems programming, embedded and operating systems, so I'd like to move them forward.
… r=notriddle,GuillaumeGomez

rustdoc: change title of search results

the current title is too similar to that of the page for std::result::Result, which is a problem both for
navigating to the Result docs via browser autocomplete, and for being able to tell which tab is which when the width of tabs is small.
…s, r=petrochenkov

Refactor complex conditions in `collect_tokens_trailing_token`

More readability improvements for this complicated function.

r? ```@petrochenkov```
…r=petrochenkov

Remove unnecessary range replacements

This PR removes an unnecessary range replacement in `collect_tokens_trailing_token`, and does a couple of other small cleanups.

r? ```@petrochenkov```
…etrochenkov

Remove redundant option that was just encoding that a slice was empty

There is already a sanity check ensuring we don't put empty attribute lists into the HIR:

https://github.com/rust-lang/rust/blob/6ef11b81c2c02c3c4b7556d1991a98572fe9af87/compiler/rustc_ast_lowering/src/lib.rs#L661-L667
…ix, r=tgross35

CI: do not respect custom try jobs for unrolled perf builds

Before this PR, if a pull request merged in a rollup had some `try-job` annotations, the unrolled perf builds were running the custom try jobs instead of the default job, which was wrong.

Found out [here](https://rust-lang.zulipchat.com/#narrow/stream/242791-t-infra/topic/try-perf.20jobs.20respect.20try-job.20annotations).
…compiler-errors

Improve `extern "<abi>" unsafe fn()` error message

These errors were already reported in rust-lang#87217, and fixed by rust-lang#87235 but missed the case of an explicit ABI.

This PR does not cover multiple keywords like `extern "C" pub const unsafe fn()`, but I don't know what a good way to cover this  would be. It also seems rarer than `extern "C" unsafe` which I saw happen a few times in workshops.
…ocs, r=tgross35

Fix `Iterator::filter` docs

Small fix to add code formatting around `Iterator::filter` `true` return type
@rustbot rustbot added A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. rollup A PR which is a rollup labels Jul 26, 2024
@tgross35
Copy link
Contributor Author

@bors r+ rollup=never p=5

@bors
Copy link
Contributor

bors commented Jul 26, 2024

📌 Commit 2157c39 has been approved by tgross35

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 26, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 26, 2024
Rollup of 9 pull requests

Successful merges:

 - rust-lang#124941 (Stabilize const `{integer}::from_str_radix` i.e. `const_int_from_str`)
 - rust-lang#127853 (`#[naked]`: report incompatible attributes)
 - rust-lang#128210 (rustdoc: change title of search results)
 - rust-lang#128223 (Refactor complex conditions in `collect_tokens_trailing_token`)
 - rust-lang#128224 (Remove unnecessary range replacements)
 - rust-lang#128226 (Remove redundant option that was just encoding that a slice was empty)
 - rust-lang#128227 (CI: do not respect custom try jobs for unrolled perf builds)
 - rust-lang#128229 (Improve `extern "<abi>" unsafe fn()` error message)
 - rust-lang#128235 (Fix `Iterator::filter` docs)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors
Copy link
Contributor

bors commented Jul 26, 2024

⌛ Testing commit 2157c39 with merge cd16d1e...

@rust-log-analyzer
Copy link
Collaborator

The job dist-arm-linux failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
warning: profiler_builtins@0.0.0:  static void llvm_writeout_and_clear(void) {
warning: profiler_builtins@0.0.0:  ^~~~~~
   Compiling rustc-std-workspace-core v1.99.0 (/checkout/library/rustc-std-workspace-core)
[RUSTC-TIMING] rustc_std_workspace_core test:false 0.022
error[E0736]: attribute incompatible with `#[naked]`
    |
71  |    /   macro_rules! intrinsics {
72  |    |       () => ();
73  |    |
73  |    |
74  |    |       // Support cfg_attr:
...      |
112 |    | /         intrinsics! {
113 |    | |             #[$($attr)*]
114 |    | |             $(#[$($attrs)*])*
115 |    | |             pub unsafe extern $abi fn $name($($argname: $ty),*) $(-> $ret)? {
116 |    | |                 $($body)*
118 |    | |         }
    |    | |_________- in this macro invocation (#2)
...      |
181 |    | /         intrinsics! {
181 |    | /         intrinsics! {
182 |    | |             $(#[$($attr)*])*
183 |    | |             #[linkage = "weak"]
184 |    | |             pub unsafe extern $abi fn $name( $($argname: $ty),* ) $(-> $ret)? {
185 |    | |                 $($body)*
187 |    | |         }
    |    | |_________- in this macro invocation (#3)
...      |
429 |    |               #[naked]
429 |    |               #[naked]
    |    |               -------- function marked with `#[naked]` here
430 |    |               $(#[$($attr)*])*
    |    |                 ^^^^^^^^^^^^ the `linkage` attribute is incompatible with `#[naked]`
531 |    |       );
532 |    |   }
    |    |   -
    |    |   |
    |    |   |
    |    |   in this expansion of `intrinsics!` (#1)
    |    |___in this expansion of `intrinsics!` (#2)
    |        in this expansion of `intrinsics!` (#3)
   ::: /rust/deps/compiler_builtins-0.1.109/src/arm.rs:20:1
    |
20  | /      intrinsics! {
21  | |          // NOTE This function and the ones below are implemented using assembly because they are using a
21  | |          // NOTE This function and the ones below are implemented using assembly because they are using a
22  | |          // custom calling convention which can't be implemented using a normal Rust function.
23  | |          #[cfg_attr(all(not(windows), not(target_vendor="apple")), weak)]
186 | |          }
187 | |      }
    | |______- in this macro invocation (#1)


error[E0736]: attribute incompatible with `#[naked]`
    |
71  |     /   macro_rules! intrinsics {
72  |     |       () => ();
73  |     |
73  |     |
74  |     |       // Support cfg_attr:
...       |
112 |     | /         intrinsics! {
113 |     | |             #[$($attr)*]
114 |     | |             $(#[$($attrs)*])*
115 |     | |             pub unsafe extern $abi fn $name($($argname: $ty),*) $(-> $ret)? {
116 |     | |                 $($body)*
118 |     | |         }
    |     | |_________- in this macro invocation (#3)
...       |
...       |
128 |     |           intrinsics!($($rest)*);
...       |
181 |     | /         intrinsics! {
181 |     | /         intrinsics! {
182 |     | |             $(#[$($attr)*])*
183 |     | |             #[linkage = "weak"]
184 |     | |             pub unsafe extern $abi fn $name( $($argname: $ty),* ) $(-> $ret)? {
185 |     | |                 $($body)*
187 |     | |         }
    |     | |_________- in this macro invocation (#4)
...       |
429 |     |               #[naked]
429 |     |               #[naked]
    |     |               -------- function marked with `#[naked]` here
430 |     |               $(#[$($attr)*])*
    |     |                 ^^^^^^^^^^^^ the `linkage` attribute is incompatible with `#[naked]`
531 |     |       );
532 |     |   }
    |     |   -
    |     |   |
    |     |   |
    |     |   in this expansion of `intrinsics!` (#1)
    |     |   in this expansion of `intrinsics!` (#2)
    |     |___in this expansion of `intrinsics!` (#3)
    |         in this expansion of `intrinsics!` (#4)
   ::: /rust/deps/compiler_builtins-0.1.109/src/arm.rs:20:1
    |
20  | /       intrinsics! {
21  | |           // NOTE This function and the ones below are implemented using assembly because they are using a
21  | |           // NOTE This function and the ones below are implemented using assembly because they are using a
22  | |           // custom calling convention which can't be implemented using a normal Rust function.
23  | |           #[cfg_attr(all(not(windows), not(target_vendor="apple")), weak)]
186 | |           }
187 | |       }
    | |_______- in this macro invocation (#1)


error[E0736]: attribute incompatible with `#[naked]`
    |
71  |      /   macro_rules! intrinsics {
72  |      |       () => ();
73  |      |
73  |      |
74  |      |       // Support cfg_attr:
...        |
112 |      | /         intrinsics! {
113 |      | |             #[$($attr)*]
114 |      | |             $(#[$($attrs)*])*
115 |      | |             pub unsafe extern $abi fn $name($($argname: $ty),*) $(-> $ret)? {
116 |      | |                 $($body)*
118 |      | |         }
    |      | |_________- in this macro invocation (#4)
...        |
...        |
128 |      |           intrinsics!($($rest)*);
    |      |           |
    |      |           in this macro invocation (#2)
    |      |           in this macro invocation (#3)
...        |
...        |
181 |      | /         intrinsics! {
182 |      | |             $(#[$($attr)*])*
183 |      | |             #[linkage = "weak"]
184 |      | |             pub unsafe extern $abi fn $name( $($argname: $ty),* ) $(-> $ret)? {
185 |      | |                 $($body)*
187 |      | |         }
    |      | |_________- in this macro invocation (#5)
...        |
429 |      |               #[naked]
429 |      |               #[naked]
    |      |               -------- function marked with `#[naked]` here
430 |      |               $(#[$($attr)*])*
    |      |                 ^^^^^^^^^^^^ the `linkage` attribute is incompatible with `#[naked]`
531 |      |       );
532 |      |   }
    |      |   -
    |      |   |
    |      |   |
    |      |   in this expansion of `intrinsics!` (#1)
    |      |   in this expansion of `intrinsics!` (#2)
    |      |   in this expansion of `intrinsics!` (#3)
    |      |___in this expansion of `intrinsics!` (#4)
    |          in this expansion of `intrinsics!` (#5)
   ::: /rust/deps/compiler_builtins-0.1.109/src/arm.rs:20:1
    |
20  | /        intrinsics! {
21  | |            // NOTE This function and the ones below are implemented using assembly because they are using a
21  | |            // NOTE This function and the ones below are implemented using assembly because they are using a
22  | |            // custom calling convention which can't be implemented using a normal Rust function.
23  | |            #[cfg_attr(all(not(windows), not(target_vendor="apple")), weak)]
186 | |            }
187 | |        }
    | |________- in this macro invocation (#1)

@bors
Copy link
Contributor

bors commented Jul 26, 2024

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 26, 2024
@tgross35 tgross35 closed this Jul 26, 2024
@tgross35 tgross35 deleted the rollup-o7u1j6v branch July 26, 2024 22:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc rollup A PR which is a rollup S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rustdoc Relevant 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.