Commit Graph

268985 Commits

Author SHA1 Message Date
Matthias Krüger
20b1dadf92
Rollup merge of #130350 - RalfJung:strict-provenance, r=dtolnay
stabilize Strict Provenance and Exposed Provenance APIs

Given that [RFC 3559](https://rust-lang.github.io/rfcs/3559-rust-has-provenance.html) has been accepted, t-lang has approved the concept of provenance to exist in the language. So I think it's time that we stabilize the strict provenance and exposed provenance APIs, and discuss provenance explicitly in the docs:
```rust
// core::ptr
pub const fn without_provenance<T>(addr: usize) -> *const T;
pub const fn dangling<T>() -> *const T;
pub const fn without_provenance_mut<T>(addr: usize) -> *mut T;
pub const fn dangling_mut<T>() -> *mut T;
pub fn with_exposed_provenance<T>(addr: usize) -> *const T;
pub fn with_exposed_provenance_mut<T>(addr: usize) -> *mut T;

impl<T: ?Sized> *const T {
    pub fn addr(self) -> usize;
    pub fn expose_provenance(self) -> usize;
    pub fn with_addr(self, addr: usize) -> Self;
    pub fn map_addr(self, f: impl FnOnce(usize) -> usize) -> Self;
}

impl<T: ?Sized> *mut T {
    pub fn addr(self) -> usize;
    pub fn expose_provenance(self) -> usize;
    pub fn with_addr(self, addr: usize) -> Self;
    pub fn map_addr(self, f: impl FnOnce(usize) -> usize) -> Self;
}

impl<T: ?Sized> NonNull<T> {
    pub fn addr(self) -> NonZero<usize>;
    pub fn with_addr(self, addr: NonZero<usize>) -> Self;
    pub fn map_addr(self, f: impl FnOnce(NonZero<usize>) -> NonZero<usize>) -> Self;
}
```

I also did a pass over the docs to adjust them, because this is no longer an "experiment". The `ptr` docs now discuss the concept of provenance in general, and then they go into the two families of APIs for dealing with provenance: Strict Provenance and Exposed Provenance. I removed the discussion of how pointers also have an associated "address space" -- that is not actually tracked in the pointer value, it is tracked in the type, so IMO it just distracts from the core point of provenance. I also adjusted the docs for `with_exposed_provenance` to make it clear that we cannot guarantee much about this function, it's all best-effort.

There are two unstable lints associated with the strict_provenance feature gate; I moved them to a new [strict_provenance_lints](https://github.com/rust-lang/rust/issues/130351) feature since I didn't want this PR to have an even bigger FCP. ;)

`@rust-lang/opsem` Would be great to get some feedback on the docs here. :)
Nominating for `@rust-lang/libs-api.`

Part of https://github.com/rust-lang/rust/issues/95228.

[FCP comment](https://github.com/rust-lang/rust/pull/130350#issuecomment-2395114536)
2024-10-21 18:11:19 +02:00
Ralf Jung
56ee492a6e move strict provenance lints to new feature gate, remove old feature gates 2024-10-21 15:22:17 +01:00
Ralf Jung
c3e928d8dd stabilize Strict Provenance and Exposed Provenance
This comes with a big docs rewrite.
2024-10-21 15:05:35 +01:00
bors
3ec4308f6c Auto merge of #131972 - klensy:FindFirstFileExW, r=ChrisDenton
speedup directory traversal on windows

Optimizes walking over dirs on windows by replacing `FindFirstFileW` with `FindFirstFileExW` with `FindExInfoBasic` option, that allows skipping filling unused struct field which should be faster.

Also adds the same change for fallback call of `FindFirstFileExW` in metadata call.

Locally shows small speedup, but bench results from other users are welcome.
2024-10-21 11:10:24 +00:00
bors
3e33bda032 Auto merge of #130628 - workingjubilee:clean-up-result-ffi-guarantees, r=RalfJung
Finish stabilization of `result_ffi_guarantees`

The internal linting has been changed, so all that is left is making sure we stabilize what we want to stabilize.
2024-10-21 08:38:45 +00:00
Jubilee Young
7baf06680c lang: Strengthen RFC 3391 guarantees to match T-lang consensus 2024-10-21 00:43:36 -07:00
bors
93742bd782 Auto merge of #131988 - matthiaskrgr:rollup-tx173wn, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #126588 (Added more scenarios where comma to be removed in the function arg)
 - #131728 (bootstrap: extract builder cargo to its own module)
 - #131968 (Rip out old effects var handling code from traits)
 - #131981 (Remove the `BoundConstness::NotConst` variant)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-10-21 06:13:34 +00:00
Matthias Krüger
62b7293a90
Rollup merge of #131981 - compiler-errors:bound-constness, r=cjgillot
Remove the `BoundConstness::NotConst` variant

I find it easier to represent `BoundConstness::NotConst` as just `None` for some refactorings I'm doing.
2024-10-21 07:01:37 +02:00
Matthias Krüger
4f6750b86c
Rollup merge of #131968 - compiler-errors:old-effect-handling, r=fee1-dead
Rip out old effects var handling code from traits

Traits no longer have an effect parameter, so this removes logic associated with it. It also removes logic surrounding confirming `~const Destruct` bounds, which I added a looooong time ago, and which I don't feel like we need anymore -- if it needs to be added back, it should be rewritten :D

cc `@fee1-dead`
2024-10-21 07:01:37 +02:00
Matthias Krüger
09a22b8672
Rollup merge of #131728 - jieyouxu:boopstrap, r=onur-ozkan
bootstrap: extract builder cargo to its own module

I was looking at our cargo rustflags/rustdocflags usages, and I found `builder.rs` to be a large
file which made it hard to digest. This PR tries to break out the cargo command wrapper parts to
its own submodule to make it easier to identify builder cargo-specific logic.

This PR:

- Extracts the cargo command wrapper to its own module and also move `Builder::{bare_,}cargo` impl
  to the submodule.
- Reorganizes some imports in `lib.rs` (no functional changes).
- Slightly adjusts some docs in `builder.rs`.

This PR is basically just moving code around, and should not contain any functional changes.

Before this PR, `builder.rs` was 2743 lines. After this PR, `builder.rs` is down to a more
manageable 1386 lines and `cargo.rs` is 1085 lines.
2024-10-21 07:01:36 +02:00
Matthias Krüger
9ff4dab396
Rollup merge of #126588 - linyihai:trim-extra-comma, r=petrochenkov
Added more scenarios where comma to be removed in the function arg

This is an attempt to address the problem methion in https://github.com/rust-lang/rust/issues/106304#issuecomment-1837273666.

Copy the annotation to explain the fix

If the next Error::Extra ("next") doesn't next to current ("current")

```
fn foo(_: (), _: u32) {}
- foo("current", (), 1u32, "next")
+ foo((), 1u32)
```

If the previous error is not a `Error::Extra`, then do not trim the next comma

```
- foo((), "current", 42u32, "next")
+ foo((), 42u32)
```

Frankly, this is a fix from a test case and may not cover all scenarios
2024-10-21 07:01:36 +02:00
bors
f2ba41113d Auto merge of #130950 - compiler-errors:yeet-eval, r=BoxyUwU
Continue to get rid of `ty::Const::{try_}eval*`

This PR mostly does:

* Removes all of the `try_eval_*` and `eval_*` helpers from `ty::Const`, and replace their usages with `try_to_*`.
* Remove `ty::Const::eval`.
* Rename `ty::Const::normalize` to `ty::Const::normalize_internal`. This function is still used in the normalization code itself.
* Fix some weirdness around the `TransmuteFrom` goal.

I'm happy to split it out further; for example, I could probably land the first part which removes the helpers, or the changes to codegen which are more obvious than the changes to tools.

r? BoxyUwU

Part of https://github.com/rust-lang/rust/issues/130704
2024-10-21 03:46:28 +00:00
许杰友 Jieyou Xu (Joe)
2b4bf2dbb0 bootstrap: move builder.rs under builder/ directory 2024-10-21 10:34:31 +08:00
许杰友 Jieyou Xu (Joe)
1d77715f83 bootstrap: minor docs cleanup 2024-10-21 10:34:31 +08:00
许杰友 Jieyou Xu (Joe)
4b28e52f32 bootstrap: extract builder cargo to its own module
I found builder.rs to be a massive file which made it hard to digest. To
make `RUSTFLAGS` usage hardening easier later, I extracted the cargo
part in `builder.rs` into its own module.
2024-10-21 10:34:30 +08:00
bors
fb32dd41ed Auto merge of #120869 - devnexen:update_fbsd_ci, r=Mark-Simulacrum
ci update freebsd version proposal, freebsd 12 being eol

raising to the lowest still active supported freebsd version.
From 13.1 (already eol too), freebsd introduces a cpu affinity layer
with linux. It also introduces a api compatible copy_file_range which
can be used like its linux's counterpart.
The former is essential to build https://github.com/rust-lang/rust/pull/120589, therefore breaks the backward
compatibility with the previous FreeBSD releases.

Blocked on https://github.com/rust-lang/rust/issues/130465
2024-10-21 00:13:09 +00:00
bors
7ed1a51b25 Auto merge of #131980 - matthiaskrgr:rollup-iy5nw71, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #131814 (`optimize` attribute applied to things other than methods/functions/c…)
 - #131927 (Check for filecheck directives in files marked `skip-filecheck`)
 - #131967 (Remove `lower_mono_bounds`)
 - #131973 (fix(rustdoc-json-types): document rustc-hash feature)
 - #131976 (feat(rustdoc-json-types): mark simple enums as copy)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-10-20 21:40:21 +00:00
Matthias Krüger
4b658657da
Rollup merge of #131976 - jalil-salame:rustdoc-types-copy-enums, r=aDotInTheVoid
feat(rustdoc-json-types): mark simple enums as copy

Fixes rust-lang/rustdoc-types#26 and some typos in the documentation

r? `@aDotInTheVoid`

I have been assigning these PRs to you `@aDotInTheVoid,` is that okay? I think I'm out of PRs for now, but for future reference c:
2024-10-20 21:04:15 +02:00
Matthias Krüger
c2ed685238
Rollup merge of #131973 - jalil-salame:rustdoc-types-document-feature, r=aDotInTheVoid
fix(rustdoc-json-types): document rustc-hash feature

The `rustc-hash` feature is publicly exposed by the `rustdoc-types`. It is already documented in that crate's README and Cargo.toml, but we might as well add some information to the crate docs themselves c:

Follow up to:
- #131936
- [rust-lang/rustdoc-types#42][1]

[1]: https://github.com/rust-lang/rustdoc-types/pull/42

r? `@aDotInTheVoid`
2024-10-20 21:04:14 +02:00
Matthias Krüger
2cded97c96
Rollup merge of #131967 - compiler-errors:lower-mono, r=fmease
Remove `lower_mono_bounds`

I'm not convinced about the usefulness of `lower_mono_bounds`, especially since we have *so* many lower-bound-like fns in HIR lowering, so I've just inlined it into its callers.
2024-10-20 21:04:14 +02:00
Matthias Krüger
7fbed7b07e
Rollup merge of #131927 - clubby789:skip-filecheck-directives, r=Mark-Simulacrum
Check for filecheck directives in files marked `skip-filecheck`

cc #116971
2024-10-20 21:04:13 +02:00
Matthias Krüger
2a9b6d9626
Rollup merge of #131814 - Borgerr:misapplied-optimize-attribute, r=jieyouxu
`optimize` attribute applied to things other than methods/functions/c…

…losures gives an error (#128488)

Duplicate of #128943, which I had accidentally closed when rebasing.

cc. `@jieyouxu` `@compiler-errors` `@nikomatsakis` `@traviscross` `@pnkfelix.`
2024-10-20 21:04:13 +02:00
bors
662180b34d Auto merge of #131949 - Noratrieb:fxhashup-thanks-alona, r=WaffleLapkin
Update rustc-hash to version 2 but again

it's like #129533 but not closed by bors and rebased

r? WaffleLapkin meow
2024-10-20 19:01:54 +00:00
Michael Goulet
61ed4cb5b4 Remove the BoundConstness::NotConst variant 2024-10-20 18:33:59 +00:00
Jalil David Salamé Messina
afa75f0aa5
fix(rustdoc-json-types): typos
Typos found some typos in the file, so I fixed them c:
2024-10-20 19:01:36 +02:00
Jalil David Salamé Messina
f047591652
feat(rustdoc-json-types): mark simple enums as copy
Fixes [rust-lang/rustdoc-types#26](https://github.com/rust-lang/rustdoc-types/issues/26)
2024-10-20 19:01:36 +02:00
bors
de977a5acf Auto merge of #131970 - matthiaskrgr:rollup-nr32ksd, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #121560 (Allow `#[deny]` inside `#[forbid]` as a no-op)
 - #131365 (Fix missing rustfmt in msi installer #101993)
 - #131647 (Register `src/tools/unicode-table-generator` as a runnable tool)
 - #131843 (compiler: Error on layout of enums with invalid reprs)
 - #131926 (Align boolean option descriptions in `configure.py`)
 - #131961 (compiletest: tidy up how `tidy` and `tidy` (html version) are disambiguated)
 - #131962 (Make `llvm::set_section` take a `&CStr`)
 - #131964 (add latest crash tests)
 - #131965 (remove outdated comment)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-10-20 16:34:35 +00:00
Jalil David Salamé Messina
880d565df1
fix(rustdoc-json-types): document rustc-hash feature
The `rustc-hash` feature is publicly exposed by the `rustdoc-types`. It
is already documented in that crate's README and Cargo.toml, but we
might as well add some information to the crate docs themselves c:

Follow up to:
- #131936
- [rust-lang/rustdoc-types#42][1]

[1]: https://github.com/rust-lang/rustdoc-types/pull/42
2024-10-20 18:31:29 +02:00
klensy
2920ed0999 fix docs 2024-10-20 18:25:38 +03:00
klensy
8abe67c949 replace FindFirstFileW with FindFirstFileExW and apply optimization 2024-10-20 18:24:55 +03:00
Matthias Krüger
a860657c04
Rollup merge of #131965 - ChrisDenton:outdated-comment, r=jieyouxu
remove outdated comment

https://github.com/rust-lang/rust/issues/44234 was closed, apparently solved by https://github.com/rust-lang/rust/pull/45353
2024-10-20 16:54:13 +02:00
Matthias Krüger
5533c96132
Rollup merge of #131964 - matthiaskrgr:crashes2010, r=jieyouxu
add latest crash tests

r? `@jieyouxu`
2024-10-20 16:54:12 +02:00
Matthias Krüger
da8a11550c
Rollup merge of #131962 - Zalathar:llvm-set-section, r=Swatinem,workingjubilee
Make `llvm::set_section` take a `&CStr`

There's no reason to convert the section name to an intermediate `String`, when the LLVM-C API wants a C string anyway.

Follow-up to #131876.
2024-10-20 16:54:12 +02:00
Matthias Krüger
0d4cf0521e
Rollup merge of #131961 - jieyouxu:dirty, r=Zalathar
compiletest: tidy up how `tidy` and `tidy` (html version) are disambiguated

Rename `has_tidy` -> `has_html_tidy` (`tidy` is also a bootstrap tool, but rustdoc uses a html tidy that has the same binary name). Follow-up to #131941.

Also apparently `runtest.rs` is short enough now, we can delete the `tidy` (bootstrap version) ignore for file length.
2024-10-20 16:54:11 +02:00
Matthias Krüger
2f77343eec
Rollup merge of #131926 - clubby789:configure-enable, r=Kobzol
Align boolean option descriptions in `configure.py`

Boolean options are currently printed as
```
Options
        --enable-debug  OR  --disable-debug enables debugging environment; does not affect optimization of bootstrapped code
        --enable-docs  OR  --disable-docs build standard library documentation
        --enable-compiler-docs  OR  --disable-compiler-docs build compiler documentation
        --enable-optimize-tests  OR  --disable-optimize-tests build tests with optimizations
        --enable-verbose-tests  OR  --disable-verbose-tests enable verbose output when running tests
        --enable-ccache  OR  --disable-ccache invoke gcc/clang via ccache to reuse object files between builds
        --enable-sccache  OR  --disable-sccache invoke gcc/clang via sccache to reuse object files between builds
        --enable-local-rust  OR  --disable-local-rust use an installed rustc rather than downloading a snapshot
        --local-rust-root=VAL          set prefix for local rust binary
        --enable-local-rebuild  OR  --disable-local-rebuild assume local-rust matches the current version, for rebuilds; implies local-rust, and is implied if local-rust already matches the current version
```
as of #131117

imo, this is a little difficult to skim. This PR changes this to align the `OR`s and push the description onto a newline:

```
Options
        --enable-debug                     OR --disable-debug
                enables debugging environment; does not affect optimization of bootstrapped code
        --enable-docs                      OR --disable-docs
                build standard library documentation
        --enable-compiler-docs             OR --disable-compiler-docs
                build compiler documentation
        --enable-optimize-tests            OR --disable-optimize-tests
                build tests with optimizations
        --enable-verbose-tests             OR --disable-verbose-tests
                enable verbose output when running tests
        --enable-ccache                    OR --disable-ccache
                invoke gcc/clang via ccache to reuse object files between builds
        --enable-sccache                   OR --disable-sccache
                invoke gcc/clang via sccache to reuse object files between builds
        --enable-local-rust                OR --disable-local-rust
                use an installed rustc rather than downloading a snapshot
        --local-rust-root=VAL          set prefix for local rust binary
        --enable-local-rebuild             OR --disable-local-rebuild
                assume local-rust matches the current version, for rebuilds; implies local-rust, and is implied if local-rust already matches the current version
    ```
2024-10-20 16:54:10 +02:00
Matthias Krüger
6d43de643e
Rollup merge of #131843 - workingjubilee:thaw-impossible-reprs, r=lukas-code
compiler: Error on layout of enums with invalid reprs

Surprising no one, the ICEs with the same message have the same root cause.

Invalid reprs can reach layout computation for various reasons. For instance, the compiler may want to use its layout computations to discern if a combination of layout-affecting attributes results in a valid type to begin with by e.g. computing its size. When the input is bad, return an error reflecting that the answer to the question is not a useful one.
2024-10-20 16:54:10 +02:00
Matthias Krüger
fb42a4581b
Rollup merge of #131647 - jieyouxu:unicode-table-generator, r=Mark-Simulacrum
Register `src/tools/unicode-table-generator` as a runnable tool

It seems like `src/tools/unicode-table-generator` is not currently managed by bootstrap. This PR wires it up with bootstrap as a runnable tool.

This tool seems to take two possible args:

1. (Mandatory) path to `library/core/src/unicode/unicode_data.rs`, and
2. (Optional) path to generate a test file.

I only passed the mandatory path to `unicode_data.rs` in bootstrap and didn't do anything about (2). I'm not sure about how this tool is supposed to be run.

`Cargo.lock` is modified because I renamed `unicode-table-generator`'s bin name to match the tool name, as bootstrap's tool running logic expects the bin name to be derived from the tool name.

I also added a triagebot message to remind to not manually edit the library source file and edit the tool then regenerate instead, but this should probably be a tidy check (if that's desirable then that can be in a follow-up PR, though may be overkill).

Helps with #131640 but does not close it because still no docs.

r? `@Mark-Simulacrum` (since I think you authored this tool?)
2024-10-20 16:54:09 +02:00
Matthias Krüger
17ac4c8fb5
Rollup merge of #131365 - heiseish:fix-issue-101993, r=Mark-Simulacrum
Fix missing rustfmt in msi installer #101993

# Context
- Fixed missing `rustfmt`, `clippy`, `miri` and `rust-analyzer` in msi installer
- Fixed missing `rustfmt` for apple darwin installer
- Closes #101993

r​? `@jyn514`
- Please let me know if I should request from someone else instead. I divided the changes into 3 separate commits for the ease of review. The refactoring commit `fbdfd5c03c3c979bcf105ccdd05ff4ab9f37a763` is a bit more involved, but I think it helps in the long term for readability and to avoid bugs.
- I changed `build-manifest` to `build_manifest` in order to invoke it as a library. Not sure if this is gonna break any upstream processes. I checked `generate-manifest-list` and `generate-release` but didn't find any obvious reference
- Will push fixes for linting later
2024-10-20 16:54:09 +02:00
Matthias Krüger
7b714d4735
Rollup merge of #121560 - Noratrieb:stop-lint-macro-nonsense, r=jieyouxu
Allow `#[deny]` inside `#[forbid]` as a no-op

Forbid cannot be overriden. When someome tries to do this anyways, it results in a hard error. That makes sense.

Except it doesn't, because macros. Macros may reasonably use `#[deny]` (or `#[warn]` for an allow-by-default lint) in their expansion to assert that their expanded code follows the lint. This is doesn't work when the output gets expanded into a `forbid()` context. This is pretty silly, since both the macros and the code agree on the lint!

By making it a warning instead, we remove the problem with the macro, which is now nothing as warnings are suppressed in macro expanded code, while still telling users that something is up.

fixes #121483
2024-10-20 16:54:08 +02:00
ash
080103f1ed misapplied optimize attribute throws a compilation error (#128488) 2024-10-20 08:34:15 -06:00
Michael Goulet
10b07961a2 Inline lower_mono_bounds into lower_poly_bounds 2024-10-20 13:53:39 +00:00
Michael Goulet
6f6f91ab82 Rip out old effects var handling code from traits 2024-10-20 13:40:22 +00:00
Michael Goulet
b922ae07b3 Make LowerPolyBounds take an IntoIterator 2024-10-20 13:38:41 +00:00
klensy
22a9a8b76e replace FindFirstFileW with FindFirstFileExW and regenerate bindings 2024-10-20 16:05:49 +03:00
Lin Yihai
f1070825bb Added more scenarios where commas need to be removed 2024-10-20 17:14:53 +08:00
Jubilee Young
9f4c9155d4 compiler: Reject impossible reprs during enum layout 2024-10-20 02:12:58 -07:00
Jubilee Young
68d1fd9427 compiler: pre-move code for fixing enum layout ICEs 2024-10-20 02:09:22 -07:00
Chris Denton
ef5a56f7bc
Remove outdated comment
#44234 is resolved
2024-10-20 08:34:25 +00:00
Matthias Krüger
eca5359b83 add latest crash tests 2024-10-20 10:05:39 +02:00
Noratrieb
0c8d81b4df Stop relying on hashmap iteration for unused macro rules arms 2024-10-20 00:12:52 -07:00