Commit Graph

262101 Commits

Author SHA1 Message Date
Martin Kröning
4da966c30e
fix(pal/hermit): deny(unsafe_op_in_unsafe_fn)
Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
2024-08-01 12:34:43 +02:00
Martin Kröning
b21af629ef
refactor(pal/hermit): make ENV a non-mutable static
Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
2024-08-01 12:34:43 +02:00
Martin Kröning
127b469b7e
refactor(pal/hermit): use default impl of GlobalAlloc::alloc_zeroed
Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
2024-07-31 13:31:41 +02:00
Martin Kröning
76b4a86b57
refactor(pal/hermit): return ! to satisfy rust-analyzer
This silences this rust-analyzer-specific error: `expected !, found ()`

Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
2024-07-31 13:31:41 +02:00
bors
83dcdb3a5d Auto merge of #128075 - Oneirical:try-your-damnetest, r=jieyouxu
Migrate `rlib-format-packed-bundled-libs-2`, `native-link-modifier-whole-archive` and `no-builtins-attribute` `run-make` tests to rmake

Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).

Please try:

try-job: x86_64-msvc
try-job: test-various
try-job: armhf-gnu
try-job: aarch64-apple
try-job: x86_64-gnu-llvm-18
2024-07-31 00:36:46 +00:00
bors
249cf71f11 Auto merge of #128413 - matthiaskrgr:rollup-nrfcvdq, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #128357 (Detect non-lifetime binder params shadowing item params)
 - #128367 (CI: rfl: build the generated doctests and documentation)
 - #128376 (Mark `Parser::eat`/`check` methods as `#[must_use]`)
 - #128379 (the output in stderr expects panic-unwind)
 - #128380 (make `///` doc comments compatible with naked functions)
 - #128382 (cargo-miri: better error when we seem to run inside bootstrap but something is wrong)
 - #128398 (tidy: Fix quote in error message)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-07-30 21:50:34 +00:00
Matthias Krüger
42a0cc8e71
Rollup merge of #128398 - awilfox:awilfox/fix-tidy-quote, r=jieyouxu
tidy: Fix quote in error message

I noticed that the backticks around the error code wasn't done properly in this string when I was building Rust 1.80.0 and found it is still this way in nightly.  Example:

```
warning: Error code `E0595` needs to have at least one UI test in the `tests/error-codes/` directory`!
warning: Error code E0602`` has a UI test file, but doesn't contain its own error code!
warning: Error code `E0619` needs to have at least one UI test in the `tests/error-codes/` directory`!
```

This commit fixes it to match the other warning strings.
2024-07-30 22:51:40 +02:00
Matthias Krüger
49327a04a2
Rollup merge of #128382 - RalfJung:cargo-miri-assert, r=oli-obk
cargo-miri: better error when we seem to run inside bootstrap but something is wrong

Cc https://github.com/rust-lang/miri/issues/3775
2024-07-30 22:51:40 +02:00
Matthias Krüger
e6a82d2878
Rollup merge of #128380 - folkertdev:naked-compatible-doc-comment, r=bjorn3
make `///` doc comments compatible with naked functions

tracking issue: https://github.com/rust-lang/rust/issues/90957

reported in https://github.com/rust-lang/rust/pull/127853#issuecomment-2257323333

it turns out `/// doc comment` and `#[doc = "doc comment"]` are represented differently, at least at the point where we perform the check for what should be allowed. The `///` style doc comment is now also allowed.

r? ``@bjorn3``

cc ``@hsanzg``
2024-07-30 22:51:39 +02:00
Matthias Krüger
7ea1f7265f
Rollup merge of #128379 - Dajamante:aïssata_needs_unwind, r=pietroalbini
the output in stderr expects panic-unwind

r​? ``@pietroalbini``
2024-07-30 22:51:39 +02:00
Matthias Krüger
6f0b237c72
Rollup merge of #128376 - compiler-errors:finish-ur-vegetables, r=jieyouxu
Mark `Parser::eat`/`check` methods as `#[must_use]`

These methods return a `bool`, but we probably should either use these values or explicitly throw them away (e.g. when we just want to unconditionally eat a token if it exists).

I changed a few places from `eat` to `expect`, but otherwise I tried to leave a comment explaining why the `eat` was okay.

This also adds a test for the `pattern_type!` macro, which used to silently accept a missing `is` token.
2024-07-30 22:51:38 +02:00
Matthias Krüger
894db1f22f
Rollup merge of #128367 - ojeda:rfl-ci-build-doctests-and-docs, r=Kobzol
CI: rfl: build the generated doctests and documentation

Cc ``@tgross35``
r? ``@Kobzol``
try-job: x86_64-rust-for-linux
2024-07-30 22:51:37 +02:00
Matthias Krüger
40edd4f1c6
Rollup merge of #128357 - compiler-errors:shadowed-non-lifetime-binder, r=petrochenkov
Detect non-lifetime binder params shadowing item params

We should check that `for<T>` shadows `T` from an item in the same way that `for<'a>` shadows `'a` from an item.

r? ``@petrochenkov`` since you're familiar w the nuances of rib kinds
2024-07-30 22:51:37 +02:00
bors
f8060d282d Auto merge of #128083 - Mark-Simulacrum:bump-bootstrap, r=albertlarsan68
Bump bootstrap compiler to new beta

https://forge.rust-lang.org/release/process.html#master-bootstrap-update-t-2-day-tuesday
2024-07-30 17:49:08 +00:00
bors
006c8df322 Auto merge of #124339 - oli-obk:supports_feature, r=wesleywiser
allow overwriting the output of `rustc --version`

Our wonderful bisection folk [have to work around](https://github.com/rust-lang/rust/issues/123276#issuecomment-2075001510) crates that do incomplete nightly/feature detection, as otherwise the bisection just points to where the feature detection breaks, and not to the actual breakage they are looking for.

This is also annoying behaviour to nightly users who did not opt-in to those nightly features. Most nightly users want to be in control of the nightly breakage they get, by

* choosing when to update rustc
* choosing when to update dependencies
* choosing which nightly features they are willing to take the breakage for

The reason this breakage occurs is that the build script of some crates run `rustc --version`, and if the version looks like nightly or dev, it will enable nightly features. These nightly features may break in random ways whenever we change something in nightly, so every release of such a crate will only work with a small range of nightly releases. This causes bisection to fail whenever it tries an unsupported nightly, even though that crate is not related to the bisection at all, but is just an unrelated dependency.

This PR (and the policy I want to establish with this FCP) is only for situations like the `version_check`'s `supports_feature` function. It is explicitly not for `autocfg` or similar feature-detection-by-building-rust-code, irrespective of my opinions on it and the similarity of nightly breakage that can occur with such schemes. These cause much less breakage, but should the breakage become an issue, they should get covered by this policy, too.

This PR allows changing the version and release strings reported by `rustc --version` via the `RUSTC_OVERRIDE_VERSION_STRING` env var. The bisection issue is then fixed by https://github.com/rust-lang/cargo-bisect-rustc/pull/335.

I mainly want to establish a compiler team policy:

> We do not consider feature detection on nightly (on stable via compiler version numbering is fine) a valid use case that we need to support, and if it causes problems, we are at liberty to do what we deem best - either actively working to prevent it or to actively ignore it. We may try to work with responsive and cooperative authors, but are not obligated to.

Should they subvert the workarounds that nightly users or cargo-bisect-rustc can use, we should be able to land rustc PRs that target the specific crates that cause issues for us and outright replace their build script's logic to disable nightly detection.

I am not including links to crates, PRs or issues here, as I don't actually care about the specific use cases and don't want to make it trivial to go there and leave comments. This discussion is going to be interesting enough on its own, without branching out.
2024-07-30 15:25:31 +00:00
Mark Rousskov
abb1ebaae1 Revert "opt-dist: dont overrwite config.toml when verifying"
This reverts commit c81a40bbc0.
2024-07-30 11:03:03 -04:00
A. Wilcox
b1b48dc584
tidy: Fix quote in error message 2024-07-30 09:35:12 -05:00
Michael Goulet
4776ac0f88 Suppress must_use on eat calls in rustfmt 2024-07-30 10:10:36 -04:00
Oli Scherer
92f263b792 Make RUSTC_OVERRIDE_VERSION_STRING overwrite the rendered version output, too 2024-07-30 14:08:02 +00:00
Oli Scherer
cbab16feaf Test RUSTC_OVERRIDE_VERSION_STRING 2024-07-30 14:08:02 +00:00
bors
595316b400 Auto merge of #127955 - chenyukang:yukang-fix-mismatched-delimiter-issue-12786, r=nnethercote
Add limit for unclosed delimiters in lexer diagnostic

Fixes #127868

The first commit shows the original diagnostic, and the second commit shows the changes.
2024-07-30 13:02:16 +00:00
bors
1ddedbaa59 Auto merge of #125929 - Bryanskiy:delegation-generics-3, r=petrochenkov
Delegation: support generics for delegation from free functions

(The PR was split from https://github.com/rust-lang/rust/pull/123958, explainer - https://github.com/Bryanskiy/posts/blob/master/delegation%20in%20generic%20contexts.md)

This PR implements generics inheritance from free functions to free functions and trait methods.

#### free functions to free functions:

```rust
fn to_reuse<T: Clone>(_: T) {}

reuse to_reuse as bar;
// desugaring:
fn bar<T: Clone>(x: T) {
  to_reuse(x)
}
```

Generics, predicates and signature are simply copied. Generic arguments in paths are ignored during generics inheritance:

```rust
fn to_reuse<T: Clone>(_: T) {}

reuse to_reuse::<u8> as bar;
// desugaring:
fn bar<T: Clone>(x: T) {
  to_reuse::<u8>(x) // ERROR: mismatched types
}
```

Due to implementation limitations callee path is lowered without modifications. Therefore, it is a compilation error at the moment.

#### free functions to trait methods:

```rust
trait Trait<'a, A> {
    fn foo<'b, B>(&self, x: A, y: B) {...}
}

reuse Trait::foo;
// desugaring:
fn foo<'a, 'b, This: Trait<'a, A>, A, B>(this: &This, x: A, y: B) {
  Trait::foo(this, x, y)
}
```

The inheritance is similar to the previous case but with some corrections:

- `Self` parameter converted into `T: Trait`
- generic parameters need to be reordered so that lifetimes go first

Arguments are similarly ignored.

---

In the future, we plan to  support generic inheritance for delegating from all contexts to all contexts (from free/trait/impl to free/trait /impl). These cases were considered first as the simplest from the implementation perspective.
2024-07-30 10:39:33 +00:00
Folkert
58bfd98baf
make /// doc comments compatible with naked functions 2024-07-30 12:20:18 +02:00
Ralf Jung
cc7e7bc096 cargo-miri: better error when we seem to run inside bootstrap but something is wrong 2024-07-30 12:13:04 +02:00
bors
e69c19ea0b Auto merge of #128336 - Bryanskiy:inst-binder-with-fresh, r=lcnr
Use Vec in instantiate_binder_with_fresh_vars

`FxHashMap`  was replaced with a pre-computed `Vec` of infer vars.

r? `@lcnr`
2024-07-30 08:15:17 +00:00
aissata
dadf3d2a97 the output in stderr expects panic-unwind 2024-07-30 08:16:47 +02:00
bors
7e3a971870 Auto merge of #128378 - matthiaskrgr:rollup-i3qz9uo, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #127574 (elaborate unknowable goals)
 - #128141 (Set branch protection function attributes)
 - #128315 (Fix vita build of std and forbid unsafe in unsafe in the os/vita module)
 - #128339 ([rustdoc] Make the buttons remain when code example is clicked)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-07-30 05:50:05 +00:00
bors
710ce90fbe Auto merge of #128250 - Amanieu:select_unpredictable, r=nikic
Add `select_unpredictable` to force LLVM to use CMOV

Since https://reviews.llvm.org/D118118, LLVM will no longer turn CMOVs into branches if it comes from a `select` marked with an `unpredictable` metadata attribute.

This PR introduces `core::intrinsics::select_unpredictable` which emits such a `select` and uses it in the implementation of `binary_search_by`.
2024-07-30 03:22:27 +00:00
Matthias Krüger
c2b085b4d4
Rollup merge of #128339 - GuillaumeGomez:click-code-example, r=notriddle
[rustdoc] Make the buttons remain when code example is clicked

Follow-up of https://github.com/rust-lang/rust/pull/125779.

One current issue we have with "run" button and the newly added copy code button is that if you're on mobile devices, you can't use them. I took a look at how `mdbook` is handling it and when you click on a code example, they show the buttons. I think it's a really good idea as if you want to copy the code on your mobile device, you will click on it, showing the buttons.

Feature can be tested [here](https://rustdoc.crud.net/imperio/click-code-example/foo/struct.Bar.html).

r? `@notriddle`
2024-07-30 04:31:55 +02:00
Matthias Krüger
f396a42ed6
Rollup merge of #128315 - zetanumbers:psvita-unsafe-in-unsafe, r=workingjubilee
Fix vita build of std and forbid unsafe in unsafe in the os/vita module

See #127747

r? `@workingjubilee`

`@pheki` `@nikarh`
2024-07-30 04:31:55 +02:00
Matthias Krüger
6b23cb5cdf
Rollup merge of #128141 - nikic:aarch64-bti, r=DianQK,cuviper
Set branch protection function attributes

Since LLVM 19, it is necessary to set not only module flags, but also function attributes for branch protection on aarch64. See e15d67cfc2 for the relevant LLVM change.

Fixes https://github.com/rust-lang/rust/issues/127829.
2024-07-30 04:31:54 +02:00
Matthias Krüger
ae92125a75
Rollup merge of #127574 - lcnr:coherence-check-supertrait, r=compiler-errors
elaborate unknowable goals

A reimplemented version of #124532 affecting only the new solver. Always trying to prove super traits ends up causing a fatal overflow error in diesel, so we cannot land this in the old solver.

The following test currently does not pass coherence:
```rust
trait Super {}
trait Sub<T>: Super {}

trait Overlap<T> {}
impl<T, U: Sub<T>> Overlap<T> for U {}
impl<T> Overlap<T> for () {}

fn main() {}
```

We check whether `(): Sub<?t>` holds. This stalls with ambiguity as downstream crates may add an impl for `(): Sub<Local>`. However, its super trait bound `(): Super` cannot be implemented downstream, so this one is known not to hold.

By trying to prove that all the super bounds of a trait before adding a coherence unknowable candidate, this compiles. This is necessary to prevent breakage from enabling `-Znext-solver=coherence` (#121848), see tests/ui/coherence/super-traits/super-trait-knowable-2.rs for more details. The idea is that while there may be an impl of the trait itself we don't know about, if we're able to prove that a super trait is definitely not implemented, then that impl would also never apply/not be well-formed.

This approach is different from #124532 as it allows tests/ui/coherence/super-traits/super-trait-knowable-3.rs to compile. The approach in #124532 only elaborating the root obligations while this approach tries it for all unknowable trait goals.

r? `@compiler-errors`
2024-07-30 04:31:54 +02:00
Michael Goulet
e4076e34f8 Mark Parser::eat/check methods as must_use 2024-07-29 21:29:08 -04:00
bors
dba8e2d2c2 Auto merge of #128234 - jcsp:retain-empty-case, r=tgross35
Optimize empty case in Vec::retain

While profiling some code that happens to call Vec::retain() in a tight loop, I noticed more runtime than expected in retain, even in a bench case where the vector was always empty.  When I wrapped my call to retain in `if !myvec.is_empty()` I saw faster execution compared with doing retain on an empty vector.

On closer inspection, Vec::retain is doing set_len(0) on itself even when the vector is empty, and then resetting the length again in BackshiftOnDrop::drop.

Unscientific screengrab of a flamegraph illustrating how we end up spending time in set_len and drop:
![image](https://github.com/user-attachments/assets/ebc72ace-84a0-4432-9b6f-1b3c96d353ba)
2024-07-30 00:55:52 +00:00
bors
368e2fd458 Auto merge of #128360 - matthiaskrgr:rollup-wwy5mkj, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #126247 (rustdoc: word wrap CamelCase in the item list table and sidebar)
 - #128104 (Not lint pub structs without pub constructors intentionally)
 - #128153 (Stop using `MoveDataParamEnv` for places that don't need a param-env)
 - #128284 (Stabilize offset_of_nested)
 - #128342 (simplify the use of `CiEnv`)
 - #128355 (triagebot: make sure Nora is called Nora)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-07-29 21:46:59 +00:00
Miguel Ojeda
77cc18fd79 CI: rfl: build the documentation
Since the `rfl` CI job has not had almost any issue for some weeks,
it is a good time to try to increase a bit the scope of what it tests.

The kernel does not use any particular `rustdoc` unstable issue (apart
from the doctests ones) so far, so in principle it should not introduce
extra issues here, and may be a good extra test case for Rust.

In addition, it may help to test new unstable features in the future.

In the worst case, we can revert it.

Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2024-07-29 23:19:02 +02:00
Miguel Ojeda
d280b8ca14 CI: rfl: build the generated doctests
We were already generating the doctests, which should already catch most
issues with our hack around `--test-builder` and `--no-run`.

However, we were not building the result of that transformation, thus
build it for completeness and to ensure the hack may not have produced
something completely broken.

In the worst case, we can revert it.

Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2024-07-29 23:18:15 +02:00
Matthias Krüger
c2616203bc
Rollup merge of #128355 - jieyouxu:rename-nora, r=aDotInTheVoid
triagebot: make sure Nora is called Nora

r? `@Noratrieb`
2024-07-29 21:26:14 +02:00
Matthias Krüger
4d78d11bf9
Rollup merge of #128342 - onur-ozkan:ci-env-usage, r=Kobzol
simplify the use of `CiEnv`

self-explanatory
2024-07-29 21:26:14 +02:00
Matthias Krüger
a73a025190
Rollup merge of #128284 - GKFX:stabilize-offset-of-nested, r=dtolnay,jieyouxu
Stabilize offset_of_nested

Tracking issue #120140. Closes #120140.

As the FCP is now nearing its end I have opened a stabilization PR. I have done this separately to the offset_of_enum feature, since that FCP has not started.

`@rustbot` label  F-offset_of_nested T-lang T-libs-api
2024-07-29 21:26:13 +02:00
Matthias Krüger
b02cf4c274
Rollup merge of #128153 - compiler-errors:mdpe, r=cjgillot
Stop using `MoveDataParamEnv` for places that don't need a param-env

I think not threading through a `ParamEnv` makes it clearer that these functions don't do anything particularly "type systems"-y.

r? cjgillot
2024-07-29 21:26:12 +02:00
Matthias Krüger
91b18a058c
Rollup merge of #128104 - mu001999-contrib:fix/128053, r=petrochenkov
Not lint pub structs without pub constructors intentionally

Fixes #128053
2024-07-29 21:26:12 +02:00
Matthias Krüger
9aedec9313
Rollup merge of #126247 - notriddle:notriddle/word-wrap-item-table, r=GuillaumeGomez
rustdoc: word wrap CamelCase in the item list table and sidebar

This is an alternative to https://github.com/rust-lang/rust/pull/126209. That is, it fixes the issue that affects the very long type names in https://docs.rs/async-stripe/0.31.0/stripe/index.html#structs.

This is, necessarily, a pile of nasty heuristics. We need to balance a few issues:

- Sometimes, there's no real word break. For example, `BTreeMap` should be `BTree<wbr>Map`, not `B<wbr>Tree<wbr>Map`.

- Sometimes, there's a legit word break, but the name is tiny and the HTML overhead isn't worth it. For example, if we're typesetting `TyCtx`, writing `Ty<wbr>Ctx` would have an HTML overhead of 50%. Line breaking inside it makes no sense.

# Screenshots

| Before | After |
| ------ | ----- |
| ![image](https://github.com/rust-lang/rust/assets/1593513/d51201fd-46c0-4f48-aee6-a477eadba288) | ![image](https://github.com/rust-lang/rust/assets/1593513/d8e77582-adcf-4966-bbfd-19dfdad7336a)
2024-07-29 21:26:11 +02:00
bors
612a33f20b Auto merge of #128350 - matthiaskrgr:rollup-bcuhts8, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #127882 (Don't elaborate associated types with Sized bounds in `trait_object_ty` in cfi)
 - #128174 (Don't record trait aliases as marker traits)
 - #128202 (Tell users not to file a bug when using internal library features)
 - #128239 (Don't ICE when encountering error regions when confirming object method candidate)
 - #128337 (skip assoc type during infer source visitor)
 - #128341 (Make `rustc_attr::parse_version` pub)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-07-29 19:25:46 +00:00
Guillaume Gomez
99906dc89c Add rustdoc GUI test to check click on code examples 2024-07-29 21:14:36 +02:00
Guillaume Gomez
a7cb1a5352 Make the buttons remain when code example is clicked 2024-07-29 21:14:35 +02:00
Michael Goulet
454c600004 Detect non-lifetime binder params shadowing item params 2024-07-29 14:26:21 -04:00
Michael Howell
ac303df4e2 rustdoc: move the wbr after the underscore, instead of before 2024-07-29 10:31:02 -07:00
Michael Howell
3bf8bcfbe0 rustdoc: properly handle path wrapping 2024-07-29 10:31:02 -07:00
Michael Howell
1d339b07ca rustdoc: use <wbr> in sidebar headers
This also improves sidebar layout, so instead of

    BTreeM
    ap

you get this

    BTree
    Map
2024-07-29 10:30:56 -07:00