Commit Graph

261215 Commits

Author SHA1 Message Date
许杰友 Jieyou Xu (Joe) 288c572745 run_make_support: move external deps to `external_deps` module 2024-07-17 12:48:21 +00:00
许杰友 Jieyou Xu (Joe) a02008edac run_make_support: move `env_var{,_os}` into `env_checked` module 2024-07-17 12:48:21 +00:00
许杰友 Jieyou Xu (Joe) 544dda3828 run_make_support: move target checks into `targets` module 2024-07-17 12:48:21 +00:00
许杰友 Jieyou Xu (Joe) 427cf94106 run_make_support: move `impl_common_helpers` into own `macros` module 2024-07-17 12:48:21 +00:00
Tobias Bucher 2162f3f34b Mention how you can go from `BorrowedFd` to `OwnedFd` and back 2024-07-17 14:34:00 +02:00
Tobias Bucher 538b31e977 Make language around `ToOwned` for `BorrowedFd` more precise 2024-07-17 14:33:39 +02:00
Kriskras99 99f879c32f
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 14:10:41 +02:00
Ralf Jung f9c0d3370f ptr::metadata: update comment on vtable_ptr work-around 2024-07-17 13:56:25 +02:00
Zalathar 411fcb6b2d Rename `test` to `pick_test_for_match_pair` 2024-07-17 21:50:12 +10:00
Zalathar 03bfa3690e Rename `MatchPair` to `MatchPairTree`
In #120904, `MatchPair` became able to store other match pairs as children,
forming a tree. That has made the old name confusing, so this patch renames the
type to `MatchPairTree`.
2024-07-17 21:50:07 +10:00
Ralf Jung 21dc49c587 ptr::metadata: avoid references to extern types 2024-07-17 13:50:01 +02:00
yukang 2c2ef6ce9d add chenyukang to review rotation 2024-07-17 19:12:05 +08:00
yukang 40e07a3ab1 Remove invalid further restricting for type bound 2024-07-17 19:08:37 +08:00
bors 3de0a7c716 Auto merge of #127602 - onur-ozkan:calling-order, r=Kobzol
maintain the given order on step execution

Previously step execution disregarded the CLI order and this change executes the given steps in the order specified on CLI.

For example, running `x $kind a b c` will execute `$kind` step for `a`, then `b`, then `c` crates in the specified order.

Fixes #126165
cc `@matthiaskrgr`
2024-07-17 10:57:17 +00:00
Jerry Wang eea6502dcb
Use `llvm-readobj` for `run-make/crate-hash-rustc-version` 2024-07-17 06:49:23 -04:00
Jerry Wang ec6e07b09d
Migrate `crate-hash-rustc-version` to `rmake` 2024-07-17 06:49:23 -04:00
onur-ozkan 4ad753af91 maintain the given order on step execution
Previously step execution disregarded the CLI order and this change executes the given
steps in the order specified on CLI.

For example, running `x $kind a b c` will execute `$kind` step for `a`, then `b`, then `c` crates
in the specified order.

Signed-off-by: onur-ozkan <work@onurozkan.dev>
2024-07-17 12:37:36 +03:00
Trevor Gross f99f61b272
Rollup merge of #127850 - jieyouxu:bootstrap-llvm-config, r=onur-ozkan
bootstrap: open `llvm-config` as r+w

This previously failed on Windows and prevented building on Windows for compiler stuff because the `llvm-config` file was open as read-only.

Tested locally on a Windows machine.

Fixes #127849.
2024-07-17 04:06:01 -05:00
Trevor Gross 5d7466efb8
Rollup merge of #127847 - ChrisDenton:vacation, r=jhpratt
Reviewer on vacation

``@jhpratt`` asked to be set as on vacation
2024-07-17 04:06:00 -05:00
Trevor Gross 599d32414b
Rollup merge of #127813 - ChrisDenton:win-futex, r=joboet
Prevent double reference in generic futex

In the Windows futex implementation we were a little lax at allowing references to references (i.e. `&&`) which can lead to deadlocks due to reading the wrong memory address. This uses a trait to tighten the constraints and ensure this doesn't happen.

r? libs
2024-07-17 04:05:59 -05:00
Trevor Gross 56f95559da
Rollup merge of #127763 - ChrisDenton:safe-unsafe-unsafe, r=tgross35
Make more Windows functions `#![deny(unsafe_op_in_unsafe_fn)]`

As part of #127747, I've evaluated some more Windows functions and added `unsafe` blocks where necessary. Some are just trivial wrappers that "inherit" the full unsafety of their function, but for others I've added some safety comments. A few functions weren't actually unsafe at all. I think they were just using `unsafe fn` to avoid an `unsafe {}` block.

I'm not touching `c.rs` yet because that is partially being addressed by another PR and also I have plans to further reduce the number of wrapper functions we have in there.

r? libs
2024-07-17 04:05:59 -05:00
许杰友 Jieyou Xu (Joe) 3bee50736d bootstrap: open llvm_config as r+w
This previously failed on Windows because the `llvm_config` file was
open as read-only.
2024-07-17 17:00:06 +08:00
Chris Denton a216a34ef3
jhpratt on vacation 2024-07-17 07:53:02 +00:00
Jubilee Young d47cb26ddd unix: unsafe-wrap install_main_guard_default 2024-07-17 00:08:05 -07:00
Jubilee Young 6ed563d491 unix: clean up install_main_guard_freebsd
This just was a mess.
2024-07-17 00:06:27 -07:00
Jubilee Young e285c95cee unix: stack_start_aligned is a safe fn
This function is purely informative, answering where a stack starts.
This is a safe operation, even if an answer requires unsafe code,
and even if the result is some unsafe code decides to trust the answer.
It also doesn't need to fetch the PAGE_SIZE when its caller just did so!
Let's complicate its signature and in doing so simplify its operation.

This allows sprinkling around #[forbid(unsafe_op_in_unsafe_fn)]
2024-07-16 23:46:03 -07:00
Jubilee Young 17c70a9aac unix: split stack_overflow::install_main_guard by os 2024-07-16 23:32:02 -07:00
Chris Denton 0585c4a23e
Prevent double reference in generic futex 2024-07-17 05:57:39 +00:00
bors cb12b52f16 Auto merge of #127838 - weihanglo:update-cargo, r=weihanglo
Update cargo

31 commits in 154fdac39ae9629954e19e9986fd2cf2cdd8d964..a2b58c3dad4d554ba01ed6c45c41ff85390560f2
2024-07-07 01:28:23 +0000 to 2024-07-16 00:52:02 +0000
- chore(ci): bump CI tools (rust-lang/cargo#14257)
- test: migrate fetch and list_availables to snapbox (rust-lang/cargo#14214)
- chore: downgrade to jobserver@0.1.28 (rust-lang/cargo#14254)
- perf(source): Don't `du` on every git source load (rust-lang/cargo#14252)
- fix(source): Don't warn about unreferenced duplicate packages (rust-lang/cargo#14239)
- feat(test): Add cargo_test to test-support prelude (rust-lang/cargo#14243)
- Add workflow to publish Cargo automatically (rust-lang/cargo#14202)
- test: migrate implicit_features to snapbox (rust-lang/cargo#14245)
- test: migrate build-std/main to snapbox (rust-lang/cargo#14241)
- test: migrate check_cfg to snapbox (rust-lang/cargo#14235)
- refactor(source): More RecursivePathSource clean up (rust-lang/cargo#14231)
- Add more profiling traces (rust-lang/cargo#14238)
- fix(overrides): Don't warn on duplicate packages from using '..' (rust-lang/cargo#14234)
- fix(test): Redact elapsed time in the minutes time frame (rust-lang/cargo#14233)
- test: Migrate lto tests to snapbox (rust-lang/cargo#14209)
- fix: Ensure dep/feature activates the dependency on 2024 (rust-lang/cargo#14221)
- chore(docs): update index of reference (rust-lang/cargo#14228)
- test: migrate test to snapbox (rust-lang/cargo#14226)
- chore: remove duplicate words (rust-lang/cargo#14229)
- docs(contrib): Document things I look for in RFCs (rust-lang/cargo#14222)
- docs(ref): Note MSRV for features in the docs (rust-lang/cargo#14224)
- test(progress): Resolve flakiness (rust-lang/cargo#14223)
- fix(test): Reduce over-prescription to the caller (rust-lang/cargo#14217)
- refactor: move get_source_id out of registry (rust-lang/cargo#14218)
- fix: rename to `rustdoc::broken_intra_doc_links` (rust-lang/cargo#14215)
- test: migrate member_errors, multitarget and new to snapbox (rust-lang/cargo#14210)
- test: migrate generate_lockfile and glob_targets to snapbox (rust-lang/cargo#14200)
- test: Ensure --list test works with cargo-bloat (rust-lang/cargo#14213)
- dont make new constant InternedString in hot path (rust-lang/cargo#14211)
- Fix compatible_with_older_cargo test. (rust-lang/cargo#14212)
- test: migrate metabuild, metadata and net_config to snapbox (rust-lang/cargo#14162)
2024-07-17 05:55:06 +00:00
Chris Denton 2043de12a3
Narrow the scope of the ReadFile unsafe block 2024-07-17 05:53:20 +00:00
Chris Denton a33abbba98
forbid(unsafe_op_in_unsafe_fn) in sys/os_str 2024-07-17 05:52:38 +00:00
bors a28b35eb35 Auto merge of #127840 - tgross35:rollup-jfkg1dq, r=tgross35
Rollup of 9 pull requests

Successful merges:

 - #125206 (Simplify environment variable examples)
 - #126271 (Skip fast path for dec2flt when optimize_for_size)
 - #126776 (Clean up more comments near use declarations)
 - #127444 (`impl Send + Sync` and override `count` for the `CStr::bytes` iterator)
 - #127512 (Terminate `--print link-args` output with newline)
 - #127792 (std: Use `read_unaligned` for reads from DWARF)
 - #127807 (Use futex.rs for Windows thread parking)
 - #127833 (zkvm: add `#[forbid(unsafe_op_in_unsafe_fn)]` in `stdlib`)
 - #127836 (std: Forbid unwrapped unsafe ops in xous and uefi modules)

Failed merges:

 - #127813 (Prevent double reference in generic futex)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-07-17 03:31:18 +00:00
Noah Lev 37ed7a4438 Add `ConstArgKind::Path` and make `ConstArg` its own HIR node
This is a very large commit since a lot needs to be changed in order to
make the tests pass. The salient changes are:

- `ConstArgKind` gets a new `Path` variant, and all const params are now
  represented using it. Non-param paths still use `ConstArgKind::Anon`
  to prevent this change from getting too large, but they will soon use
  the `Path` variant too.

- `ConstArg` gets a distinct `hir_id` field and its own variant in
  `hir::Node`. This affected many parts of the compiler that expected
  the parent of an `AnonConst` to be the containing context (e.g., an
  array repeat expression). They have been changed to check the
  "grandparent" where necessary.

- Some `ast::AnonConst`s now have their `DefId`s created in
  rustc_ast_lowering rather than `DefCollector`. This is because in some
  cases they will end up becoming a `ConstArgKind::Path` instead, which
  has no `DefId`. We have to solve this in a hacky way where we guess
  whether the `AnonConst` could end up as a path const since we can't
  know for sure until after name resolution (`N` could refer to a free
  const or a nullary struct). If it has no chance as being a const
  param, then we create a `DefId` in `DefCollector` -- otherwise we
  decide during ast_lowering. This will have to be updated once all path
  consts use `ConstArgKind::Path`.

- We explicitly use `ConstArgHasType` for array lengths, rather than
  implicitly relying on anon const type feeding -- this is due to the
  addition of `ConstArgKind::Path`.

- Some tests have their outputs changed, but the changes are for the
  most part minor (including removing duplicate or almost-duplicate
  errors). One test now ICEs, but it is for an incomplete, unstable
  feature and is now tracked at #127009.
2024-07-16 19:27:28 -07:00
Noah Lev 1c49d406b6 Use `ConstArg` for const param defaults
Now everything that actually affects the type system (i.e., excluding
const blocks, enum variant discriminants, etc.) *should* be using
`ConstArg`.
2024-07-16 19:27:28 -07:00
Noah Lev 67fccb7045 Use `ConstArg` for array lengths 2024-07-16 19:27:28 -07:00
Noah Lev 8818708a31 Use `ConstArg` for assoc item constraints 2024-07-16 19:27:28 -07:00
Noah Lev e7c85cb1e0 Setup ty::Const functions for `ConstArg` 2024-07-16 19:27:28 -07:00
Noah Lev 7d7be2f0f6 Setup ast_lowering functions for `ConstArg` 2024-07-16 19:27:28 -07:00
Noah Lev 11b144aa98 hir: Create `hir::ConstArgKind` enum
This will allow lowering const params to a dedicated enum variant, rather
than to an `AnonConst` that is later examined during `ty` lowering.
2024-07-16 19:27:28 -07:00
Noah Lev 71f8aed510 Add `current_def_id_parent` to `LoweringContext`
This is needed to track anon const parents properly once we implement
`ConstArgKind::Path` (which requires moving anon const def-creation
outside of `DefCollector`):

    Why do we need this in addition to [`Self::current_hir_id_owner`]?

    Currently (as of June 2024), anonymous constants are not HIR owners;
    however, they do get their own DefIds. Some of these DefIds have to be
    created during AST lowering, rather than def collection, because we
    can't tell until after name resolution whether an anonymous constant
    will end up instead being a [`rustc_hir::ConstArgKind::Path`]. However,
    to compute which generics are available to an anonymous constant nested
    inside another, we need to make sure that the parent is recorded as the
    parent anon const, not the enclosing item. So we need to track parent
    defs differently from HIR owners, since they will be finer-grained in
    the case of anon consts.
2024-07-16 19:27:28 -07:00
surechen 4821b84b92 If the moved value is a mut reference, it is used in a generic function and it's type is a generic param, 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 10:07:02 +08:00
Trevor Gross 1a1b44fcae
Rollup merge of #127836 - workingjubilee:forbid-unsafe-ops-in-xous-uefi, r=tgross35
std: Forbid unwrapped unsafe ops in xous and uefi modules
2024-07-16 20:10:14 -05:00
Trevor Gross dd80a728cc
Rollup merge of #127833 - risc0:erik/zkvm-deny-unsafe, r=workingjubilee
zkvm: add `#[forbid(unsafe_op_in_unsafe_fn)]` in `stdlib`

This also adds an additional `unsafe` block to address compiler errors.
This PR is intended to address https://github.com/rust-lang/rust/issues/127747 for the zkvm target.
2024-07-16 20:10:13 -05:00
Trevor Gross 446e0177ec
Rollup merge of #127807 - ChrisDenton:win-parking, r=joboet
Use futex.rs for Windows thread parking

If I'm not overlooking anything then the Windows 10+ thread parking implementation is practically the same as the futex.rs implementation. So we may as well use the same implementation for both. The old version is still kept around for Windows 7 support.

r? ````@joboet```` if you wouldn't mind double checking I've not missed something
2024-07-16 20:10:12 -05:00
Trevor Gross 045b8107f2
Rollup merge of #127792 - workingjubilee:read-unaligned-is-dwarfier, r=joboet
std: Use `read_unaligned` for reads from DWARF

There's a lot of... *stuff* going on here. Meanwhile, `read_unaligned` has been available since 1.17.0, so let's just use that.
2024-07-16 20:10:12 -05:00
Trevor Gross 8840d302e5
Rollup merge of #127512 - eggyal:newline-terminate-print-linkargs, r=compiler-errors
Terminate `--print link-args` output with newline

Fixes #127507
2024-07-16 20:10:11 -05:00
Trevor Gross 4013acdda2
Rollup merge of #127444 - Sky9x:cstr-bytes-iter, r=dtolnay
`impl Send + Sync` and override `count` for the `CStr::bytes` iterator

cc tracking issue #112115
2024-07-16 20:10:11 -05:00
Trevor Gross 606d8cf9e8
Rollup merge of #126776 - nnethercote:rustfmt-use-pre-cleanups-2, r=cuviper
Clean up more comments near use declarations

#125443 will reformat all use declarations in the repository. There are a few edge cases involving comments on use declarations that require care. This PR fixes them up so #125443 can go ahead with a simple `x fmt --all`. A follow-up to #126717.

r? ``@cuviper``
2024-07-16 20:10:10 -05:00
Trevor Gross fe1dc02163
Rollup merge of #126271 - diondokter:dec2flt-skip-fast-path, r=tgross35
Skip fast path for dec2flt when optimize_for_size

Tracking issue: https://github.com/rust-lang/rust/issues/125612

Skip the fast algorithm when optimizing for size.
When compiling for https://github.com/quartiq/stabilizer I get these numbers:

Before
```
   text    data     bss     dec     hex filename
 192192       8   49424  241624   3afd8 dual-iir
```

After
```
   text    data     bss     dec     hex filename
 191632       8   49424  241064   3ada8 dual-iir
```

This saves 560 bytes.
2024-07-16 20:10:09 -05:00
Trevor Gross 689d27293a
Rollup merge of #125206 - mgeisler:simplify-std-env-vars, r=jhpratt,tgross35
Simplify environment variable examples

I’ve found myself visiting the documentation for `std::env::vars` every few months, and every time I do, it is because I want to quickly get a snippet to print out all environment variables :-)

So I think it could be nice to simplify the examples a little to make them self-contained. It is of course a style question if one should import a module a not, but I personally don’t import modules used just once in a code snippet.
2024-07-16 20:10:09 -05:00