Commit Graph

268913 Commits

Author SHA1 Message Date
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
bfab34af4c Auto merge of #131957 - GuillaumeGomez:rm-unused, r=notriddle
Remove unused `recoverable` argument in collect_intra_doc_links

r? `@notriddle`
2024-10-20 05:58:20 +00:00
bors
d68c327796 Auto merge of #131958 - Zalathar:rollup-gkuk3n1, r=Zalathar
Rollup of 4 pull requests

Successful merges:

 - #131876 (compiler: Use LLVM's Comdat support)
 - #131941 (compiletest: disambiguate html-tidy from rust tidy tool)
 - #131942 (compiler: Adopt rust-analyzer impls for `LayoutCalculatorError`)
 - #131945 (rustdoc: Clean up footnote handling)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-10-20 03:34:09 +00:00
Stuart Cook
456821be88
Rollup merge of #131945 - aDotInTheVoid:footnote-time, r=notriddle
rustdoc: Clean up footnote handling

Best reviewed commit by commit.

Extracts footnote handling logic into it's own file (first commit) and then makes that file slightly nicer to read/understand.

No functional changes, but lays the groundwork for making more changes to footnotes (eg #131901, #131946)
2024-10-20 14:06:05 +11:00
Stuart Cook
63fccf0c2f
Rollup merge of #131942 - workingjubilee:reduce-haruspicy, r=lukas-code,lnicola
compiler: Adopt rust-analyzer impls for `LayoutCalculatorError`

We're about to massively churn the internals of `rustc_abi`. To minimize the immediate and future impact on rust-analyzer, as a subtree that depends on this crate, grow some API on `LayoutCalculatorError` that reflects their uses of it. This way we can nest the type in theirs, and they can just call functions on it without having to inspect and flatten-out its innards.
2024-10-20 14:06:04 +11:00
Stuart Cook
28a5ef9175
Rollup merge of #131941 - lolbinarycat:compiletest-need-html-tidy, r=clubby789
compiletest: disambiguate html-tidy from rust tidy tool

when i first saw this error message i was very confused, i thought it was talking about `src/tools/tidy`.  now it should be much more clear what tool should be installed.
2024-10-20 14:06:03 +11:00
Stuart Cook
0bfc49b053
Rollup merge of #131876 - workingjubilee:llvm-c-c-c-comdat, r=Zalathar
compiler: Use LLVM's Comdat support

Acting on these long-ago issues:
- https://github.com/rust-lang/rust/issues/46437
- https://github.com/rust-lang/rust/issues/68955
2024-10-20 14:06:03 +11:00
Guillaume Gomez
3e67fbda5e Remove unused recoverable argument in collect_intra_doc_links 2024-10-20 04:46:29 +02:00
bors
54791efd82 Auto merge of #131911 - lcnr:probe-no-more-leak-2, r=compiler-errors
refactor fudge_inference, handle effect vars

this makes it easier to use fudging outside of `fudge_inference_if_ok`, which is likely necessary to handle inference variable leaks on rollback.

We now also uses exhaustive matches where possible and improve the code to handle effect vars.

r? `@compiler-errors` `@BoxyUwU`
2024-10-20 00:59:01 +00:00
bors
b596184f3b Auto merge of #131948 - matthiaskrgr:rollup-c9rvzu6, r=matthiaskrgr
Rollup of 12 pull requests

Successful merges:

 - #116863 (warn less about non-exhaustive in ffi)
 - #127675 (Remove invalid help diagnostics for const pointer)
 - #131772 (Remove `const_refs_to_static` TODO in proc_macro)
 - #131789 (Make sure that outer opaques capture inner opaques's lifetimes even with precise capturing syntax)
 - #131795 (Stop inverting expectation in normalization errors)
 - #131920 (Add codegen test for branchy bool match)
 - #131921 (replace STATX_ALL with (STATX_BASIC_STATS | STATX_BTIME) as former is deprecated)
 - #131925 (Warn on redundant `--cfg` directive when revisions are used)
 - #131931 (Remove unnecessary constness from `lower_generic_args_of_path`)
 - #131932 (use tracked_path in rustc_fluent_macro)
 - #131936 (feat(rustdoc-json-types): introduce rustc-hash feature)
 - #131939 (Get rid of `OnlySelfBounds`)

Failed merges:

 - #131181 (Compiletest: Custom differ)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-10-19 22:33:42 +00:00
Matthias Krüger
2ecfdbaea7
Rollup merge of #131939 - compiler-errors:predicate-filter, r=fmease
Get rid of `OnlySelfBounds`

We turn `PredicateFilter` into a newtyped bool called `OnlySelfBounds`. There's no reason to lose the information of the `PredicateFilter`, so let's just pass it all the way through.
2024-10-19 22:01:01 +02:00
Matthias Krüger
ab7e0d0bdd
Rollup merge of #131936 - jalil-salame:rustdoc-types-rustc-hash, r=aDotInTheVoid
feat(rustdoc-json-types): introduce rustc-hash feature

This allows the public `rustdoc-types` crate to expose this feature easily and allows consumers of the crate to get the performance advantages from doing so.

The reasoning for this was discussed on [Zulip][1]

Changes:
- Make `rustc-hash` optional but default to including it
- Rename all occurrences of `FxHashMap` to `HashMap`.
- Feature gate the import and rename the imported `FxHashMap` to `HashMap`
- Introduce a type alias `FxHashMap` which resolves to the currently used `HashMap` (`rustc_hash::FxHashMap` or `std::collections::HashMap`) for use in `src/librustdoc`.

[1]: https://rust-lang.zulipchat.com/#narrow/channel/266220-t-rustdoc/topic/rustc-hash.20and.20performance.20of.20rustdoc-types

**extra context from the zulip thread:**

- `@obi1kenobi` requested benchmarks of the switch to `rustc-hash`
- I benchmarked switching `rustdoc-types` to `rustc-hash` which yielded a ~300ms improvement to `cargo-semver-checks`'s index building step (this step is done twice so the improvements are ~150ms per index).
- The benchmarks were presented in Zulip and people were in favor of introducing `rustc-hash` to the public `rustdoc-types` crate.
- There were differing opinions on how to introduce the dependency:
  1. "Hard" dependency: remove use of `std::collections::HashMap` in favor of `FxHashMap`.
  2. "Soft" dependency: make optional and introduce a feature then enable/disable it by default (this PR).
  3. ~~Make `rustdoc-types` generic and expose the `RandomState`~~ (a lot of work & complexity for little gain over a feature gate).

`@obi1kenobi` and I prefer the feature gate so that is what I am adding here.

My reasons for the preference are:
- `cargo-semver-checks` is especially perf sensitive, we don't expect people to care about ~150ms extra time when reading in a 500MB file (the size of the sample we used for benchmarking).
- Keeping `rustdoc-types` lean by having its only direct dependency be `serde` is nice for the general consumer of the crate.
- `rustc-hash` is not HashDOS resistant (but it is questionable whether `rustdoc-types` would be used on adversarial inputs).

r? `@aDotInTheVoid`
2024-10-19 22:01:00 +02:00
Matthias Krüger
d077d9b868
Rollup merge of #131932 - usamoi:tracked-path, r=Nadrieril
use tracked_path in rustc_fluent_macro

According to comments in https://github.com/rust-lang/rust/issues/99515#issuecomment-2135003881, the trick used in `rustc_fluent_macro` may be broken by caching decl macros. So use `proc_macro::tracked_path::path` to ensure it works.
2024-10-19 22:01:00 +02:00
Matthias Krüger
426e90682e
Rollup merge of #131931 - compiler-errors:constness-valid, r=fmease
Remove unnecessary constness from `lower_generic_args_of_path`

We pass `NotConst` to all callsites of `lower_generic_args_of_path` except for `lower_poly_trait_ref`, so let's not do that.
2024-10-19 22:00:59 +02:00
Matthias Krüger
efd940d24a
Rollup merge of #131925 - clubby789:redundant-revision-cfg, r=jieyouxu
Warn on redundant `--cfg` directive when revisions are used

r? ``@jieyouxu``

Fixes #131390
Not sure of the best way to test this
2024-10-19 22:00:59 +02:00
Matthias Krüger
d881cc6723
Rollup merge of #131921 - klensy:statx_all, r=ChrisDenton
replace STATX_ALL with (STATX_BASIC_STATS | STATX_BTIME) as former is deprecated

STATX_ALL was deprecated in 581701b7ef and suggested to use equivalent (STATX_BASIC_STATS | STATX_BTIME) combination, to prevent future surprises.
2024-10-19 22:00:58 +02:00
Matthias Krüger
91e46844c8
Rollup merge of #131920 - clubby789:108395-test, r=jieyouxu
Add codegen test for branchy bool match

Closes #108395
2024-10-19 22:00:58 +02:00
Matthias Krüger
559f8ce726
Rollup merge of #131795 - compiler-errors:expectation, r=Nadrieril
Stop inverting expectation in normalization errors

We have some funky special case logic to invert the expectation and actual type for normalization errors depending on their cause code. IMO most of the error messages get better, except for `try {}` blocks' type expectations. I think that these need to be special cased in some other way, rather than via this hack.

Fixes #131763
2024-10-19 22:00:57 +02:00
Matthias Krüger
bc22740882
Rollup merge of #131789 - compiler-errors:capture-more, r=fmease
Make sure that outer opaques capture inner opaques's lifetimes even with precise capturing syntax

When lowering an opaque, we must capture and duplicate all of the lifetimes in the opaque's bounds to correctly lower the opaque's bounds. We do this *even if* the lifetime is not captured according to the `+ use<>` precise capturing bound; in that case, we will later reject that captured lifetime. For example, Given an opaque like `impl Sized + 'a + use<>`, we will still duplicate `'a` but later error that it is not mentioned in the `use<>` bound.

The current heuristic was not properly handling cases like:

```
//@ edition: 2024
fn foo<'a>() -> impl Trait<Assoc = impl Trait2> + use<> {}
```

Which forces the outer `impl Trait` to capture `'a` since `impl Trait2` *implicitly* captures `'a` due to the new lifetime capture rules for edition 2024. We were only capturing lifetimes syntactically mentioned in the bounds. (Note that this still is an error; we just need to capture `'a` so it is handled later in the compiler correctly -- hence the ICE in #131769 where a late-bound lifetime was being referenced outside of its binder).

This PR reworks the way we collect lifetimes to capture and duplicate in AST lowering to fix this.

Fixes #131769
2024-10-19 22:00:57 +02:00
Matthias Krüger
e0b8e787c1
Rollup merge of #131772 - GnomedDev:remove-proc_macro-todo, r=petrochenkov
Remove `const_refs_to_static` TODO in proc_macro

Noticed this TODO, and with `const_refs_to_static` being stable now we can sort it out.
2024-10-19 22:00:56 +02:00
Matthias Krüger
268fa31596
Rollup merge of #127675 - chenyukang:yukang-fix-127562-addr, r=petrochenkov
Remove invalid help diagnostics for const pointer

Partially addresses #127562
2024-10-19 22:00:55 +02:00
Matthias Krüger
b2d132f10e
Rollup merge of #116863 - workingjubilee:non-exhaustive-is-not-ffi-unsafe, r=jieyouxu
warn less about non-exhaustive in ffi

Bindgen allows generating `#[non_exhaustive] #[repr(u32)]` enums. This results in nonintuitive nonlocal `improper_ctypes` warnings, even when the types are otherwise perfectly valid in C.

Adjust for actual tooling expectations by avoiding warning on simple enums with only unit variants.

Closes https://github.com/rust-lang/rust/issues/116831
2024-10-19 22:00:54 +02:00
bors
da935398d5 Auto merge of #131907 - saethlin:update-compiler-builtins, r=tgross35
Update `compiler-builtins` to 0.1.134

I'm modeling this PR after https://github.com/rust-lang/rust/pull/131314.

This pulls in https://github.com/rust-lang/compiler-builtins/pull/713 which should mitigate the problem reported and discussed in https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Hello.20World.20on.20sparc-unknown-none-elf.20crashes
2024-10-19 20:00:08 +00:00
Alona Enraght-Moony
9435afc0fb rustdoc: Refractor footnote handling 2024-10-19 19:24:54 +00:00
binarycat
53974b1786 compiletest: disambiguate html-tidy from rust tidy tool 2024-10-19 13:11:26 -05:00
Jubilee Young
e1d6164607 rust-analyzer: Nest LayoutCalculatorError in hir_ty::LayoutError 2024-10-19 11:09:24 -07:00
Jubilee Young
6a834b4df8 compiler: Adopt rust-analyzer impls for LayoutCalculatorError 2024-10-19 11:09:09 -07:00
Michael Goulet
70746d078e Make sure that outer opaques capture inner opaques's lifetimes even with precise capturing syntax 2024-10-19 18:02:26 +00:00
Michael Goulet
9989b1b0d5 Use PredicateFilter instead of OnlySelfBounds 2024-10-19 18:02:11 +00:00
Jubilee Young
492760020e llvm: Delete LLVMRustSetComdat 2024-10-19 10:46:10 -07:00
Jubilee Young
45d61b0d26 cg_llvm: Reuse LLVM-C Comdat support
Migrate `llvm::set_comdat` and `llvm::SetUniqueComdat` to LLVM-C FFI.

Note, now we can call `llvm::set_comdat` only when the target actually
supports adding comdat. As this has no convenient LLVM-C API, we
implement this as `TargetOptions::supports_comdat`.

Co-authored-by: Stuart Cook <Zalathar@users.noreply.github.com>
2024-10-19 10:46:10 -07:00
bors
8069f8d17a Auto merge of #131934 - matthiaskrgr:rollup-pd3dwxu, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #127462 (std: uefi: Add basic Env variables)
 - #131537 (Fix range misleading field access)
 - #131838 (bootstrap: allow setting `--jobs` in config.toml)
 - #131890 (Update `use` keyword docs to describe precise capturing)
 - #131899 (Mark unexpected variant res suggestion as having placeholders)
 - #131908 (rustdoc: Switch from FxHash to sha256 for static file hashing.)
 - #131916 (small interpreter error cleanup)
 - #131919 (zero-sized accesses are fine on null pointers)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-10-19 16:46:43 +00:00
Jalil David Salamé Messina
d1fa49b2e6
feat(rustdoc-json-types): introduce rustc-hash feature
This allows the public `rustdoc-types` crate to expose this feature
easily and allows consumers of the crate to get the performance
advantages from doing so.

The reasoning for this was discussed on [Zulip][1]

Changes:
- Make `rustc-hash` optional but default to including it
- Rename all occurrences of `FxHashMap` to `HashMap`.
- Feature gate the import and rename the imported `FxHashMap` to
  `HashMap`
- Introduce a type alias `FxHashMap` which resolves to the currently
  used `HashMap` (`rustc_hash::FxHashMap` or
  `std::collections::HashMap`) for use in `src/librustdoc`.

[1]: https://rust-lang.zulipchat.com/#narrow/channel/266220-t-rustdoc/topic/rustc-hash.20and.20performance.20of.20rustdoc-types
2024-10-19 18:15:09 +02:00
Ben Kimock
5aeb662045 Update compiler-builtins to 0.1.134 2024-10-19 11:47:43 -04:00
Matthias Krüger
7a6d4368b7
Rollup merge of #131919 - RalfJung:zero-sized-accesses, r=jhpratt
zero-sized accesses are fine on null pointers

We entirely forgot to update all the function docs when changing the central docs. That's the problem with helpfully repeating shared definitions in tons of places...
2024-10-19 17:25:36 +02:00
Matthias Krüger
0a5d65b25f
Rollup merge of #131916 - RalfJung:interpret-err, r=jieyouxu
small interpreter error cleanup

- Add `InterpretResult::map_err_kind` for the common case of swapping out the error kind (while preserving the backtrace pointing to the original error source)
- Rename `InterpError` -> `InterpErrorKind` to be consistent with the `kind` field name, and make it more clear that this is not the final error type
2024-10-19 17:25:35 +02:00
Matthias Krüger
1dcb77b25f
Rollup merge of #131908 - aDotInTheVoid:rustdoc-gamer-hashing, r=notriddle,GuillaumeGomez
rustdoc: Switch from FxHash to sha256 for static file hashing.

Fixes https://github.com/rust-lang/rust/pull/129533#issuecomment-2422891519

fxhash isn't well defined, and it's implementation is being changed in #129533. But because rustdoc uses it for static files (and encodes that hashing in rustdoc.css), this broke our tests. Given that this isn't performace critical, I think the right fix is to used a well-defined hash that will never change its definition. I've picked (rather arbitrarily) sha256.
2024-10-19 17:25:35 +02:00
Matthias Krüger
ff55ec0336
Rollup merge of #131899 - compiler-errors:placeholder, r=lqd
Mark unexpected variant res suggestion as having placeholders

Fixes #131878
2024-10-19 17:25:34 +02:00
Matthias Krüger
1cc036d18b
Rollup merge of #131890 - printfn:precise-capturing-docs, r=traviscross
Update `use` keyword docs to describe precise capturing

I noticed that the standard library keyword docs for the `use` keyword haven't been updated yet to describe the new precise capturing syntax.
2024-10-19 17:25:34 +02:00
Matthias Krüger
21475b7b69
Rollup merge of #131838 - jieyouxu:boopjob, r=onur-ozkan
bootstrap: allow setting `--jobs` in config.toml

Allow setting `--jobs` in config.toml's `[build]` section.

```toml
[build]
jobs = 0
```

If this is unset or set to zero in config.toml, we look at `--jobs` flag. If that is also unset, then we fallback to `std:🧵:available_parallelism`. If that is not available, then we default to `1`. The flags and `available_parallelism` fallback are already setup, this PR just adds a config.toml option to wire that up.

Closes #131836.

r? bootstrap
2024-10-19 17:25:33 +02:00
Matthias Krüger
a394d4928b
Rollup merge of #131537 - hirschenberger:master, r=compiler-errors
Fix range misleading field access

Fixes #131471 by checking if the range-start is a literal.
2024-10-19 17:25:33 +02:00
Matthias Krüger
5a3ecd53e4
Rollup merge of #127462 - Ayush1325:uefi-env, r=joboet
std: uefi: Add basic Env variables

- Implement environment variable functions
- Using EFI Shell protocol.
2024-10-19 17:25:33 +02:00
Alona Enraght-Moony
ebb842328a rustdoc: Extract footnote logic into it's own module. 2024-10-19 14:37:11 +00:00
Michael Goulet
ad2a649aab Remove unnecessary constness 2024-10-19 10:36:56 -04:00
usamoi
fa478239b1 use tracked_path in rustc_fluent_macro 2024-10-19 22:32:38 +08:00
bors
a2a1206811 Auto merge of #131211 - bjorn3:rust_abi_follow_c_rules, r=nikic,jieyouxu
Return values larger than 2 registers using a return area pointer

LLVM and Cranelift disagree about how to return values that don't fit in the registers designated for return values. LLVM will force the entire return value to be passed by return area pointer, while Cranelift will look at each IR level return value independently and decide to pass it in a register or not, which would result in the return value being passed partially in registers and partially through a return area pointer.

While Cranelift may need to be fixed as the LLVM behavior is generally more correct with respect to the surface language, forcing this behavior in rustc itself makes it easier for other backends to conform to the Rust ABI and for the C ABI rustc already handles this behavior anyway.

In addition LLVM's decision to pass the return value in registers or using a return area pointer depends on how exactly the return type is lowered to an LLVM IR type. For example `Option<u128>` can be lowered as `{ i128, i128 }` in which case the x86_64 backend would use a return area pointer, or it could be passed as `{ i32, i128 }` in which case the x86_64 backend would pass it in registers by taking advantage of an LLVM ABI extension that allows using 3 registers for the x86_64 sysv call conv rather than the officially specified 2 registers.

This adjustment is only necessary for the Rust ABI as for other ABI's the calling convention implementations in rustc_target already ensure any return value which doesn't fit in the available amount of return registers is passed in the right way for the current target.

Helps with https://github.com/rust-lang/rustc_codegen_cranelift/issues/1525
cc https://github.com/bytecodealliance/wasmtime/issues/9250
2024-10-19 14:21:46 +00:00
bjorn3
cc7044b080 Fix test expectations for 32bit x86 2024-10-19 13:09:21 +00:00
clubby789
d82a21f9ad Warn on redundant --cfg directive when revisions are used 2024-10-19 12:40:12 +00:00
bors
c926476d01 Auto merge of #131816 - Zalathar:profiler-feature, r=Kobzol
Make `profiler_builtins` an optional dependency of sysroot, not std

This avoids unnecessary rebuilds of std (and the compiler) when `build.profiler` is toggled off or on.

Fixes #131812.

---

Background: The `profiler_builtins` crate has been an optional dependency of std (behind a cargo feature) ever since it was added back in #42433. But as far as I can tell that has only ever been a convenient way to force the crate to be built, not a genuine dependency.

The side-effect of this false dependency is that toggling `build.profiler` causes a rebuild of std and the compiler, which shouldn't be necessary. This PR therefore makes `profiler_builtins` an optional dependency of the dummy sysroot crate (#108865), rather than a dependency of std.

What makes this change so small is that all of the necessary infrastructure already exists. Previously, bootstrap would enable the `profiler` feature on the sysroot crate, which would forward that feature to std. Now, enabling that feature directly enables sysroot's `profiler_builtins` dependency instead.

---

I believe this is more of a bootstrap change than a libs change, so tentatively:
r? bootstrap
2024-10-19 10:55:40 +00:00