Commit Graph

260981 Commits

Author SHA1 Message Date
Nicholas Nethercote
487802d6c8 Remove TrailingToken.
It's used in `Parser::collect_tokens_trailing_token` to decide whether
to capture a trailing token. But the callers actually know whether to
capture a trailing token, so it's simpler for them to just pass in a
bool.

Also, the `TrailingToken::Gt` case was weird, because it didn't result
in a trailing token being captured. It could have been subsumed by the
`TrailingToken::MaybeComma` case, and it effectively is in the new code.
2024-07-18 17:28:49 +10:00
bors
4bb2f27861 Auto merge of #127892 - tgross35:rollup-7j9wkzc, r=tgross35
Rollup of 9 pull requests

Successful merges:

 - #127542 ([`macro_metavar_expr_concat`] Add support for literals)
 - #127652 (Unignore cg_gcc fmt)
 - #127664 (Fix precise capturing suggestion for hidden regions when we have APITs)
 - #127806 (Some parser improvements)
 - #127828 (Commonize `uname -m` results for `aarch64` in docker runner)
 - #127845 (unix: break `stack_overflow::install_main_guard` into smaller fn)
 - #127859 (ptr::metadata: avoid references to extern types)
 - #127861 (Document the column numbers for the dbg! macro)
 - #127875 (style-guide: Clarify version-sorting)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-07-18 03:43:44 +00:00
Trevor Gross
7c63526b70
Rollup merge of #127875 - joshtriplett:style-guide-clarify-sorting, r=compiler-errors
style-guide: Clarify version-sorting

Every time we apply version-sorting, we also say to sort non-lowercase before
lowercase. This seems likely to be what we'll want for future sorting,
as well. For simplicity, just incorporate that into the definition,
"unless otherwise specified".
2024-07-17 19:53:29 -05:00
Trevor Gross
8bb057874d
Rollup merge of #127861 - Kriskras99:patch-1, r=tgross35
Document the column numbers for the dbg! macro

The line numbers were also made consistent, some examples used the line numbers as shown on the playground while others used the line numbers that you would expect when just seeing the documentation.

The second option was chosen to make everything consistent.
2024-07-17 19:53:29 -05:00
Trevor Gross
c36a39cd1f
Rollup merge of #127859 - RalfJung:ptr-dyn-metadata, r=scottmcm
ptr::metadata: avoid references to extern types

References to `extern types` are somewhat dubious entities, since generally we say that references must be dereferenceable for their size as determined via `size_of_val`, but with `extern type` that is an ill-defined statement. I'd like to make Miri warn for such cases since it interacts poorly with Stacked Borrows. To avoid warnings people can't fix, this requires not using references to `extern type` in the standard library, and I think `DynMetadata` is the only currently remaining use. so this changes `DynMetadata` to use a NonNull raw pointer instead. Given that the alignment was 1, this shouldn't really change anything meaningful.

I also updated a comment added by `@scottmcm` in https://github.com/rust-lang/rust/pull/125479, since I think the old comment is wrong. The `DynMetadata` type itself is not special, it is a normal aggregate. But computing field types for wide pointers (including references) is special.
2024-07-17 19:53:28 -05:00
Trevor Gross
3c4f820c5b
Rollup merge of #127845 - workingjubilee:actually-break-up-big-ass-stack-overflow-fn, r=joboet
unix: break `stack_overflow::install_main_guard` into smaller fn

This was one big deeply-indented function for no reason. This made it hard to reason about the boundaries of its safety. Or just, y'know, read. Simplify it by splitting it into platform-specific functions, but which are still asked to keep compiling (a desirable property, since all of these OS use a similar API).

This is mostly a whitespace change, so I suggest reviewing it only after setting Files changed -> (the options gear) -> [x] Hide whitespace as that will make it easier to see how the code was actually broken up instead of raw line diffs.
2024-07-17 19:53:28 -05:00
Trevor Gross
d76ec075ab
Rollup merge of #127828 - tgross35:docker-aarch64-uname, r=onur-ozkan
Commonize `uname -m` results for `aarch64` in docker runner

`uname -m` on Linux reports `aarch64`, but on MacOS reports `arm64`. Commonize this to `aarch64`.

With this fix, it is now possible to run aarch64 CI docker images on Arm MacOS.
2024-07-17 19:53:27 -05:00
Trevor Gross
fa1303662a
Rollup merge of #127806 - nnethercote:parser-improvements, r=spastorino
Some parser improvements

I was looking closely at attribute handling in the parser while debugging some issues relating to #124141, and found a few small improvements.

``@spastorino``
2024-07-17 19:53:27 -05:00
Trevor Gross
b5771e7e0d
Rollup merge of #127664 - compiler-errors:precise-capturing-better-sugg-apit, r=oli-obk
Fix precise capturing suggestion for hidden regions when we have APITs

Suggests to turn APITs into type parameters so they can be named in precise capturing syntax for hidden type lifetime errors. We also note that it may change the API.

This is currently done via a note *and* a suggestion, which feels a bit redundant, but I wasn't totally sure of a better alternative for the presentation.

Code is kind of a mess but there's a lot of cases to consider. Happy to iterate on this if you think the approach is too messy.

Based on #127619, only the last commit is relevant.
r? oli-obk

Tracking:

- https://github.com/rust-lang/rust/issues/123432
2024-07-17 19:53:26 -05:00
Trevor Gross
973d92c3cc
Rollup merge of #127652 - GuillaumeGomez:cg-gcc-fmt, r=Urgau
Unignore cg_gcc fmt

`rustc_codegen_gcc` uses `rustfmt` now so it can be unignored.

r? ``@Urgau``
2024-07-17 19:53:26 -05:00
Trevor Gross
e6f0caf197
Rollup merge of #127542 - c410-f3r:concat-again, r=petrochenkov
[`macro_metavar_expr_concat`] Add support for literals

Adds support for literals in macro parameters.

```rust
macro_rules! with_literal {
    ($literal:literal) => {
        const ${concat(FOO, $literal)}: i32 = 1;
    }
}

fn main() {
    with_literal!("_BAR");
    assert_eq!(FOO_BAR, 1);
}
```

cc #124225

r? ``@petrochenkov``
2024-07-17 19:53:25 -05:00
bors
e35364a521 Auto merge of #127865 - matthiaskrgr:rollup-8m49dlg, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #125042 (Use ordinal number in argument error)
 - #127229 (rustdoc: click target for sidebar items flush left)
 - #127337 (Move a few intrinsics to Rust abi)
 - #127472 (MIR building: Stop using `unpack!` for `BlockAnd<()>`)
 - #127579 (Solve a error `.clone()` suggestion when moving a mutable reference)
 - #127769 (Don't use implicit features in `Cargo.toml` in `compiler/`)
 - #127844 (Remove invalid further restricting suggestion for type bound)
 - #127855 (Add myself to review rotation)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-07-17 21:52:29 +00:00
Josh Triplett
37257b45e9 style-guide: Clarify version-sorting
Every time we apply version-sorting, we also say to sort non-lowercase before
lowercase. This seems likely to be what we'll want for future sorting,
as well. For simplicity, just incorporate that into the definition,
"unless otherwise specified".
2024-07-17 13:24:32 -07:00
Caio
553279b152 Add support for literals 2024-07-17 17:00:48 -03:00
bors
fcc325f1bc Auto merge of #125942 - timokroeger:windows-once-futex, r=ChrisDenton
Windows: Use futex implementation for `Once`

Keep the queue implementation for win7.
Inspired by PR #121956

<!--
If this PR is related to an unstable feature or an otherwise tracked effort,
please link to the relevant tracking issue here. If you don't know of a related
tracking issue or there are none, feel free to ignore this.

This PR will get automatically assigned to a reviewer. In case you would like
a specific user to review your work, you can assign it to them by using

    r​? <reviewer name>
-->
2024-07-17 19:28:24 +00:00
Guillaume Gomez
213782dd71 Format cg_gcc with same formatting parameters 2024-07-17 20:22:07 +02:00
Guillaume Gomez
12bedc3e2b Ignore files in cg_gcc example folder 2024-07-17 20:21:52 +02:00
Guillaume Gomez
261d92c07d Align cg_gcc rustfmt.toml with rust's 2024-07-17 20:17:44 +02:00
Guillaume Gomez
e1852d0a3c Unignore cg_gcc fmt 2024-07-17 20:15:03 +02:00
Trevor Gross
f3f0b57264 Commonize uname -m results for aarch64 in docker runner
`uname -m` on Linux reports `aarch64`, but on MacOS reports `arm64`.
Commonize this to `aarch64`.

With this fix, it is now possible to run aarch64 CI docker images on Arm
MacOS.
2024-07-17 12:04:59 -05:00
bors
f00f850919 Auto merge of #127760 - jieyouxu:rmake-support-reorganize, r=Kobzol
Reorganize the `run-make-support` library

The `run_make_support` library has a kitchen sink `lib.rs` that make discovery/learning very difficult. Let's try to improve that by breaking up `lib.rs` into smaller more organized modules. This is a precursor to improving the documentation and learnability of the `run_make_support` library.

### Changes

- Breakup `lib.rs` into smaller modules according to functionality
- Rename `recursive_diff` -> `assert_dirs_are_equal`
- Rename one of the `read_dir` with callback interface as `read_dir_entries`
- Coalesced fs-related stuff onto a `fs` module, re-exported to tests as `rfs`
- Minor doc improvements / fixes in a few places (I have a follow-up documentation PR planned)

This PR is best reviewed commit-by-commit.

r? `@Kobzol` (or Mark, or T-compiler or T-bootstrap)

try-job: x86_64-msvc
try-job: aarch64-apple
try-job: test-various
try-job: armhf-gnu
try-job: dist-x86_64-linux
2024-07-17 15:52:03 +00:00
Michael Goulet
1d40d4c4f4 Fix precise capturing suggestion for hidden type when APITs are involved 2024-07-17 10:52:13 -04:00
Matthias Krüger
2ea21cfd42
Rollup merge of #127855 - chenyukang:yukang-add-triagebot, r=jieyouxu
Add myself to review rotation

r? `@wesleywiser`
2024-07-17 16:22:33 +02:00
Matthias Krüger
1e1e64f10f
Rollup merge of #127844 - chenyukang:yukang-fix-type-bound-127555, r=jieyouxu
Remove invalid further restricting suggestion for type bound

This PR partially addresses #127555, it will remove the obvious error suggestion:

```console
   |                      ^^^^ required by this bound in `<Baz as Foo>::bar`
help: consider further restricting this bound
   |
12 |         F: FnMut() + Send + std::marker::Send,
   |                           +++++++++++++++++++
```

I may create another PR to get a better diagnostic for `impl has stricter requirements than trait` scenario.
2024-07-17 16:22:32 +02:00
Matthias Krüger
9db57bf0c9
Rollup merge of #127769 - compiler-errors:ed-2024-dep, r=oli-obk
Don't use implicit features in `Cargo.toml` in `compiler/`

Fixes compiler crates to stop using implicit features (https://github.com/rust-lang/cargo/issues/12826) which are denied in in edition 2024.
2024-07-17 16:22:31 +02:00
Matthias Krüger
23dd3a099c
Rollup merge of #127579 - surechen:fix_127285, r=lcnr
Solve a error `.clone()` suggestion when moving a mutable reference

If the moved value is a mut reference, it is used in a generic function and it's type is a generic param, suggest it can be reborrowed to avoid moving.

for example:

```rust
struct Y(u32);
// x's type is '& mut Y' and it is used in `fn generic<T>(x: T) {}`.
fn generic<T>(x: T) {}
```

fixes #127285
2024-07-17 16:22:29 +02:00
Matthias Krüger
c98487e3be
Rollup merge of #127472 - Zalathar:block-and-unit, r=fmease
MIR building: Stop using `unpack!` for `BlockAnd<()>`

This is a subset of #127416, containing only the parts related to `BlockAnd<()>`.

The first patch removes the non-assigning form of the `unpack!` macro, because it is frustratingly inconsistent with the main form. We can replace it with an ordinary method that discards the `()` and returns the block.

The second patch then finds all of the remaining code that was using `unpack!` with `BlockAnd<()>`, and updates it to use that new method instead.

---

Changes since original review of #127416:
- Renamed `fn unpack_block` → `fn into_block`
- Removed `fn unpack_discard`, replacing it with `let _: BlockAnd<()> = ...` (2 occurrences)
- Tweaked `arm_end_blocks` to unpack earlier and build `Vec<BasicBlock>` instead of `Vec<BlockAnd<()>>`
2024-07-17 16:22:28 +02:00
Matthias Krüger
3ddfd97198
Rollup merge of #127337 - celinval:intrinsics-fallback, r=oli-obk
Move a few intrinsics to Rust abi

Move a few more intrinsic functions to the convention added in #121192. In the second commit, I added documentation about their safety requirements. Let me know if you would like me to move the second commit to a different PR.

Note: I kept the same signature of `pref_align_of`, but I was wondering why this function is considered unsafe?
2024-07-17 16:22:28 +02:00
Matthias Krüger
0472b2a09f
Rollup merge of #127229 - notriddle:notriddle/mile-wide-bar, r=GuillaumeGomez
rustdoc: click target for sidebar items flush left

This change adjusts the clickable area of sidebar links to touch the leftmost edge of the canvas, making them [much easier](https://www.nngroup.com/articles/fitts-law/) to click (when the browser window is maximized or tiled left, but those cases are common enough to matter).

[Screencast from 2024-07-15 15-31-07.webm](https://github.com/user-attachments/assets/1e952d3a-e9e7-476b-b211-44a17c190b38)

<details><summary>old screencast</summary>

[Screencast from 2024-07-01 17-23-34.webm](https://github.com/rust-lang/rust/assets/1593513/dc6f9c2e-5904-403d-b353-d233e6e1afbc)

</details>
2024-07-17 16:22:26 +02:00
Matthias Krüger
2b34490da6
Rollup merge of #125042 - long-long-float:suggest-move-arg-outside, r=fmease
Use ordinal number in argument error

Add an ordinal number to two argument errors ("unexpected" and "missing") for ease of understanding error.

```
error[E0061]: this function takes 3 arguments but 2 arguments were supplied
  --> test.rs:11:5
   |
11 |     f(42, 'a');
   |     ^     --- 2nd argument of type `f32` is missing
   |
(snip)

error[E0061]: this function takes 3 arguments but 4 arguments were supplied
  --> test.rs:12:5
   |
12 |     f(42, 42, 1.0, 'a');
   |     ^   ----
   |         | |
   |         | unexpected 2nd argument of type `{integer}`
   |         help: remove the extra argument
```

To get an ordinal number, I copied `ordinalize` from other crate `rustc_resolve` because I think it is too much to link `rustc_resolve` for this small function. Please let me know if there is a better way.
2024-07-17 16:22:26 +02:00
许杰友 Jieyou Xu (Joe)
d69cc1ccbf tests: update for rfs rename 2024-07-17 13:34:18 +00:00
许杰友 Jieyou Xu (Joe)
1f1bf4c71b run_make_support: use fs internally, but rfs to tests 2024-07-17 13:32:29 +00:00
许杰友 Jieyou Xu (Joe)
a00b860bfc tests: update rustdoc test for renamed assert_dirs_are_equal 2024-07-17 13:32:29 +00:00
许杰友 Jieyou Xu (Joe)
30bdc4a309 run_make_support: rename assert_recursive_eq to assert_dirs_are_equal 2024-07-17 13:32:29 +00:00
许杰友 Jieyou Xu (Joe)
57a2f76557 run_make_support: moved some helpers into string module 2024-07-17 13:32:29 +00:00
许杰友 Jieyou Xu (Joe)
0dfecb3855 run_make_support: move some helpers from assertion to path 2024-07-17 13:32:29 +00:00
许杰友 Jieyou Xu (Joe)
636be91cc0 tests: update for renamed fs module in run_make_support 2024-07-17 13:32:29 +00:00
许杰友 Jieyou Xu (Joe)
e1569fde3e run_make_support: coalesce fs helpers into single fs module
There were *two* `read_dir` helpers, one being a simple
`std::fs::read_dir` wrapper, the other has a different callback-based
signature. We also rename the callback-based `read_dir` as
`read_dir_entries`.

Also don't top-level re-export most `fs::*` helpers.
2024-07-17 13:32:28 +00:00
bors
08cdc2fa1a Auto merge of #127851 - tgross35:rollup-i39um74, r=tgross35
Rollup of 4 pull requests

Successful merges:

 - #127763 (Make more Windows functions `#![deny(unsafe_op_in_unsafe_fn)]`)
 - #127813 (Prevent double reference in generic futex)
 - #127847 (Reviewer on vacation)
 - #127850 (bootstrap: open `llvm-config` as r+w)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-07-17 13:20:54 +00:00
许杰友 Jieyou Xu (Joe)
13a1751061 run_make_support: rename cygpath_windows to get_windows_path and move under external_deps as private 2024-07-17 12:48:23 +00:00
许杰友 Jieyou Xu (Joe)
a443dc4ecd run_make_support: rename env_checked -> env 2024-07-17 12:48:22 +00:00
许杰友 Jieyou Xu (Joe)
b7f7205212 run_make_support: move build_native_static_lib under external_deps
And fix some `ar`-related rebase mishaps.
2024-07-17 12:48:22 +00:00
许杰友 Jieyou Xu (Joe)
aadd08576d run_make_support: make set_host_rpath private and move into util 2024-07-17 12:48:22 +00:00
许杰友 Jieyou Xu (Joe)
e956808c6c run_make_support: move handle_failed_output into util module 2024-07-17 12:48:22 +00:00
许杰友 Jieyou Xu (Joe)
88fd1df017 run_make_support: move assert_recursive_eq into assertion_helpers 2024-07-17 12:48:22 +00:00
许杰友 Jieyou Xu (Joe)
56cbfa8749 tests: update rustdoc test for renamed assert_recursive_eq 2024-07-17 12:48:22 +00:00
许杰友 Jieyou Xu (Joe)
230804dc3a run_make_support: rename recursive_diff to assert_recursive_eq 2024-07-17 12:48:22 +00:00
许杰友 Jieyou Xu (Joe)
f66d3d33e4 run_make_support: move assertions and helpers into own module 2024-07-17 12:48:22 +00:00
许杰友 Jieyou Xu (Joe)
66cef19d11 run_make_support: move run_in_tmpdir and test_while_readonly to scoped_run module 2024-07-17 12:48:22 +00:00
许杰友 Jieyou Xu (Joe)
17212abd1a run_make_support: move fs helpers to own module 2024-07-17 12:48:22 +00:00