Commit Graph

10336 Commits

Author SHA1 Message Date
Rémy Rakic bb865cb83f remove unneeded extern crate in rmake test 2024-05-29 10:37:21 +00:00
bors 71213fd607 Auto merge of #125539 - matthiaskrgr:cräsh, r=jieyouxu
crashes: increment the number of tracked ones

r? `@jieyouxu`
2024-05-28 00:28:52 +00:00
bors 84b40fc908 Auto merge of #125628 - matthiaskrgr:rollup-3zk9v3w, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #125339 (The number of tests does not depend on the architecture's pointer width)
 - #125542 (Migrate rustdoc verify output files)
 - #125616 (MIR validation: ensure that downcast projection is followed by field projection)
 - #125625 (Use grep to implement verify-line-endings)

Failed merges:

 - #125573 (Migrate `run-make/allow-warnings-cmdline-stability` to `rmake.rs`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-05-27 20:49:23 +00:00
Matthias Krüger e8dd585dd8
Rollup merge of #125542 - GuillaumeGomez:migrate-rustdoc-verify-output-files, r=jieyouxu
Migrate rustdoc verify output files

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

r? ```@jieyouxu```
2024-05-27 20:43:25 +02:00
bors f00b02e6bb Auto merge of #125599 - camelid:clarify-stability, r=notriddle,GuillaumeGomez
rustdoc: Clarify const-stability with regard to normal stability

Fixes #125511.

- Elide const-unstable if also unstable overall
- Show "const" for const-unstable if also overall unstable
2024-05-27 18:42:42 +00:00
Matthias Krüger bae945201f remove fixed crashes, add fixed crashes to tests, add new cashed found in the meantime 2024-05-27 20:41:09 +02:00
Matthias Krüger e5d100363a crashes: increment the number of tracked ones 2024-05-27 17:32:56 +02:00
bors b0f8618938 Auto merge of #125413 - lcnr:ambig-drop-region-constraints, r=compiler-errors
drop region constraints for ambiguous goals

See the comment in `compute_external_query_constraints`. While the underlying issue is preexisting, this fixes a bug introduced by #125343.

It slightly weakens the leak chec, even if we didn't have any test which was affected. I want to write such a test before merging this PR.

r? `@compiler-errors`
2024-05-27 15:28:51 +00:00
Guillaume Gomez bdf3864d51 Migrate `run-make/rustdoc-verify-output-files` to `rmake.rs` 2024-05-27 14:41:19 +02:00
Guillaume Gomez 7083131c92
Rollup merge of #125607 - GuillaumeGomez:migrate-compile-stdin, r=jieyouxu
Migrate `run-make/compile-stdin` to `rmake.rs`

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

r? `@jieyouxu`
2024-05-27 13:10:37 +02:00
Guillaume Gomez e4abfaeb62 Migrate `run-make/compile-stdin` to `rmake.rs` 2024-05-27 11:37:27 +02:00
bors b582f807fa Auto merge of #125410 - fmease:adj-lint-diag-api, r=nnethercote
[perf] Delay the construction of early lint diag structs

Attacks some of the perf regressions from https://github.com/rust-lang/rust/pull/124417#issuecomment-2123700666.

See individual commits for details. The first three commits are not strictly necessary.
However, the 2nd one (06bc4fc671, *Remove `LintDiagnostic::msg`*) makes the main change way nicer to implement.
It's also pretty sweet on its own if I may say so myself.
2024-05-27 08:44:12 +00:00
bors fec98b3bbc Auto merge of #125468 - BoxyUwU:remove_defid_from_regionparam, r=compiler-errors
Remove `DefId` from `EarlyParamRegion`

Currently we represent usages of `Region` parameters via the `ReEarlyParam` or `ReLateParam` variants. The `ReEarlyParam` is effectively equivalent to `TyKind::Param` and `ConstKind::Param` (i.e. it stores a `Symbol` and a `u32` index) however it also stores a `DefId` for the definition of the lifetime parameter.

This was used in roughly two places:
- Borrowck diagnostics instead of threading the appropriate `body_id` down to relevant locations. Interestingly there were already some places that had to pass down a `DefId` manually.
- Some opaque type checking logic was using the `DefId` field to track captured lifetimes

I've split this PR up into a commit for generate rote changes to diagnostics code to pass around a `DefId` manually everywhere, and another commit for the opaque type related changes which likely require more careful review as they might change the semantics of lints/errors.

Instead of manually passing the `DefId` around everywhere I previously tried to bundle it in with `TypeErrCtxt` but ran into issues with some call sites of `infcx.err_ctxt` being unable to provide a `DefId`, particularly places involved with trait solving and normalization. It might be worth investigating adding some new wrapper type to pass this around everywhere but I think this might be acceptable for now.

This pr also has the effect of reducing the size of `EarlyParamRegion` from 16 bytes -> 8 bytes. I wouldn't expect this to have any direct performance improvement however, other variants of `RegionKind` over `8` bytes are all because they contain a `BoundRegionKind` which is, as far as I know, mostly there for diagnostics. If we're ever able to remove this it would shrink the `RegionKind` type from `24` bytes to `12` (and with clever bit packing we might be able to get it to `8` bytes). I am curious what the performance impact would be of removing interning of `Region`'s if we ever manage to shrink `RegionKind` that much.

Sidenote: by removing the `DefId` the `Debug` output for `Region` has gotten significantly nicer. As an example see this opaque type debug print before vs after this PR:
`Opaque(DefId(0:13 ~ impl_trait_captures[aeb9]::foo::{opaque#0}), [DefId(0:9 ~ impl_trait_captures[aeb9]::foo::'a)_'a/#0, T, DefId(0:9 ~ impl_trait_captures[aeb9]::foo::'a)_'a/#0])`
`Opaque(DefId(0:13 ~ impl_trait_captures[aeb9]::foo::{opaque#0}), ['a/#0, T, 'a/#0])`

r? `@compiler-errors` (I would like someone who understands the opaque type setup to atleast review the type system commit, but the rest is likely reviewable by anyone)
2024-05-27 06:36:57 +00:00
Noah Lev 699d28f968 rustdoc: Show "const" for const-unstable if also overall unstable
If a const function is unstable overall (and thus, in all circumstances
I know of, also const-unstable), we should show the option to use it as
const. You need to enable a feature to use the function at all anyway.

If the function is stabilized without also being const-stabilized, then
we do not show the const keyword and instead show "const: unstable" in
the version info.
2024-05-26 21:06:02 -07:00
Jubilee 25b079a1cf
Rollup merge of #125559 - scottmcm:simplify-shift-ubcheck, r=workingjubilee
Simplify the `unchecked_sh[lr]` ub-checks a bit

It can use the constant in the check, rather than passing it as a parameter.
2024-05-26 15:28:28 -07:00
Jubilee b65b2b6ced
Rollup merge of #125469 - compiler-errors:dont-skip-inner-const-body, r=cjgillot
Don't skip out of inner const when looking for body for suggestion

Self-explanatory title, I'll point out the important logic in an inline comment.

Fixes #125370
2024-05-26 15:28:27 -07:00
Jubilee 09e75921f3
Rollup merge of #125466 - compiler-errors:dont-probe-for-ambig-in-sugg, r=jieyouxu
Don't continue probing for method if in suggestion and autoderef hits ambiguity

The title is somewhat self-explanatory. When we hit ambiguity in method autoderef steps, we previously would continue to probe for methods if we were giving a suggestion. This seems useless, and causes an ICE when we are not able to unify the receiver later on in confirmation.

Fixes #125432
2024-05-26 15:28:27 -07:00
Jubilee 5860d43af3
Rollup merge of #125046 - bjorn3:no_mutable_static_linkage, r=cjgillot
Only allow immutable statics with #[linkage]
2024-05-26 15:28:26 -07:00
Jubilee 866630d004
Rollup merge of #124048 - veera-sivarajan:bugfix-123773-c23-variadics, r=compiler-errors
Support C23's Variadics Without a Named Parameter

Fixes #123773

This PR removes the static check that disallowed extern functions
with ellipsis (varargs) as the only parameter since this is now
valid in C23.

This will not break any existing code as mentioned in the proposal
document: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2975.pdf.

Also, adds a doc comment for `check_decl_cvariadic_pos()` and
fixes the name of the function (`varadic` -> `variadic`).
2024-05-26 15:28:26 -07:00
Matthias Krüger 5fef6c511d
Rollup merge of #125508 - scottmcm:fix-125506, r=Nilstrieb
Stop SRoA'ing `DynMetadata` in MIR

Fixes #125506
2024-05-26 13:43:07 +02:00
bors 5fe5543502 Auto merge of #124661 - RalfJung:only-structural-consts-in-patterns, r=pnkfelix
Turn remaining non-structural-const-in-pattern lints into hard errors

This completes the implementation of https://github.com/rust-lang/rust/issues/120362 by turning our remaining future-compat lints into hard errors: indirect_structural_match and pointer_structural_match.

They have been future-compat lints for a while (indirect_structural_match for many years, pointer_structural_match since Rust 1.75 (released Dec 28, 2023)), and have shown up in dependency breakage reports since Rust 1.78 (just released on May 2, 2024). I don't expect a lot of code will still depend on them, but we will of course do a crater run.

A lot of cleanup is now possible in const_to_pat, but that is deferred to a later PR.

Fixes https://github.com/rust-lang/rust/issues/70861
2024-05-26 07:55:47 +00:00
Noah Lev fa7a3f9049 rustdoc: Elide const-unstable if also unstable overall
It's confusing because if a function is unstable overall, there's no
need to highlight the constness is also unstable. Technically, these
attributes (overall stability and const-stability) are separate, but in
practice, we don't even show the const-unstable's feature flag (it's
normally the same as the overall function).
2024-05-25 23:05:27 -07:00
bors 75e2c5dcd0 Auto merge of #125518 - saethlin:check-arguments-new-in-const, r=joboet
Move the checks for Arguments constructors to inline const

Thanks `@Skgland` for pointing out this opportunity: https://github.com/rust-lang/rust/pull/117804#discussion_r1612964362
2024-05-26 01:10:39 +00:00
Scott McMurray 0c84361342 Simplify the `unchecked_sh[lr]` ub-checks a bit 2024-05-25 15:58:26 -07:00
Matthias Krüger 1e841638e3
Rollup merge of #124080 - oli-obk:define_opaque_types10, r=compiler-errors
Some unstable changes to where opaque types get defined

None of these can be reached from stable afaict.

r? ``@compiler-errors``

cc https://github.com/rust-lang/rust/issues/116652
2024-05-25 22:15:17 +02:00
Matthias Krüger 890982e47b
Rollup merge of #121377 - pitaj:lazy_cell_fn_pointer, r=dtolnay
Stabilize `LazyCell` and `LazyLock`

Closes #109736

This stabilizes the [`LazyLock`](https://doc.rust-lang.org/stable/std/sync/struct.LazyLock.html) and [`LazyCell`](https://doc.rust-lang.org/stable/std/cell/struct.LazyCell.html) types:

```rust
static HASHMAP: LazyLock<HashMap<i32, String>> = LazyLock::new(|| {
    println!("initializing");
    let mut m = HashMap::new();
    m.insert(13, "Spica".to_string());
    m.insert(74, "Hoyten".to_string());
    m
});

let lazy: LazyCell<i32> = LazyCell::new(|| {
    println!("initializing");
    92
});
```

r? libs-api
2024-05-25 22:15:16 +02:00
bors 48f00110d0 Auto merge of #121571 - clarfonthey:unchecked-math-preconditions, r=saethlin
Add assert_unsafe_precondition to unchecked_{add,sub,neg,mul,shl,shr} methods

(Old PR is haunted, opening a new one. See #117494 for previous discussion.)

This ensures that these preconditions are actually checked in debug mode, and hopefully should let people know if they messed up. I've also replaced the calls (I could find) in the code that use these intrinsics directly with those that use these methods, so that the asserts actually apply.

More discussions on people misusing these methods in the tracking issue: https://github.com/rust-lang/rust/issues/85122.
2024-05-25 18:07:32 +00:00
Matthias Krüger 1d54ba8402
Rollup merge of #125527 - programmerjake:patch-2, r=workingjubilee
Add manual Sync impl for ReentrantLockGuard

Fixes: #125526
Tracking Issue: #121440

this impl is even shown in the summary in the tracking issue, but apparently was forgotten in the actual implementation
2024-05-25 12:54:38 +02:00
Matthias Krüger d747148ba8
Rollup merge of #125514 - compiler-errors:builtin-index, r=lcnr
Structurally resolve before `builtin_index` in EUV

r? lcnr
2024-05-25 12:54:37 +02:00
Matthias Krüger 3fc8fe0490
Rollup merge of #125513 - compiler-errors:impossible-drop, r=jackh726
Don't eagerly monomorphize drop for types that are impossible to instantiate

Self-explanatory title I think

Fixes #125509
2024-05-25 12:54:36 +02:00
Matthias Krüger 4d13c96c65
Rollup merge of #125498 - zmodem:avx512er, r=workingjubilee
Stop using the avx512er and avx512pf x86 target features

They are no longer supported by LLVM 19.

Fixes #125492
2024-05-25 12:54:35 +02:00
Matthias Krüger 7ea507e041
Rollup merge of #125451 - oli-obk:const_type_mismatch, r=compiler-errors
Fail relating constants of different types

fixes #121585
fixes #121858
fixes #124151

I gave this several attempts before, but we lost too many important diagnostics until I managed to make compilation never bail out early. We have reached this point, so now we can finally fix all those ICEs by bubbling up an error instead of continueing when we encounter a bug.
2024-05-25 12:54:34 +02:00
Scott McMurray d7248d7b71 Stop SRoA'ing `DynMetadata` in MIR 2024-05-25 00:44:47 -07:00
Michael Goulet 045f448e26 Don't eagerly monomorphize drop for types that are impossible to instantiate 2024-05-24 21:53:39 -04:00
Ben Kimock 18cb2fa851 Stabilize the runtime of libtest-padding
The body of these benchmarks is close to empty but not literally empty.
This was making the runtime of the benchmarks (which are compiled
without optimizations!) flicker between 9 ns and 10 ns runtime, which
changes the padding and breaks the test. Recent changes to the standard
library have pushed the runtime closer to 10 ns when unoptimized, which
is why we haven't seen such failures before in CI.

Contributors can also induce such failures before this PR by running the
run-make tests while the system is under heavy load.
2024-05-24 21:23:12 -04:00
bors 21e6de7eb6 Auto merge of #124187 - compiler-errors:self-ctor, r=petrochenkov
Warn (or error) when `Self` ctor from outer item is referenced in inner nested item

This implements a warning `SELF_CONSTRUCTOR_FROM_OUTER_ITEM` when a self constructor from an outer impl is referenced in an inner nested item. This is a proper fix mentioned https://github.com/rust-lang/rust/pull/117246#discussion_r1374648388.

This warning is additionally bumped to a hard error when the self type references generic parameters, since it's almost always going to ICE, and is basically *never* correct to do.

This also reverts part of https://github.com/rust-lang/rust/pull/117246, since I believe this is the proper fix and we shouldn't need the helper functions (`opt_param_at`/`opt_type_param`) any longer, since they shouldn't really ever be used in cases where we don't have this problem.
2024-05-25 01:17:55 +00:00
Ben Kimock 9763222f59 Move the checks for Arguments constructors to inline const 2024-05-24 21:09:15 -04:00
Jacob Lifshay f4b9ac68f3
Add manual Sync impl for ReentrantLockGuard
Fixes: #125526
2024-05-24 17:44:37 -07:00
Matthias Krüger f1eef384bb
Rollup merge of #125503 - aDotInTheVoid:rdj-keyword-attr, r=GuillaumeGomez
rustdoc-json: Add test for keywords with `--document-private-items`

Turns out this does work as-expected. I was worried that the rustdoc's clean would produce a `ItemKind::KeywordItem` for the module, and loose the module itself. But turns out we get this right.

Prompted by [this discussion on zulip](https://rust-lang.zulipchat.com/#narrow/stream/266220-t-rustdoc/topic/Where.20to.20find.20keyword.20entries.20in.20JSON.20rustdoc)

r? `@GuillaumeGomez`
2024-05-24 23:01:12 +02:00
Matthias Krüger 104e1a4bf2
Rollup merge of #125501 - compiler-errors:opaque-opaque-anon-ct, r=BoxyUwU
Resolve anon const's parent predicates to direct parent instead of opaque's parent

When an anon const is inside of an opaque, #99801 added a hack to resolve the anon const's parent predicates *not* to the opaque's predicates, but to the opaque's *parent's* predicates. This is insufficient when considering nested opaques.

This means that the `predicates_of` an anon const might reference duplicated lifetimes (installed by `compute_bidirectional_outlives_predicates`) when computing known outlives in MIR borrowck, leading to these ICEs:
Fixes #121574
Fixes #118403

~~Instead, we should be using the `OpaqueTypeOrigin` to acquire the owner item (fn/type alias/etc) of the opaque, whose predicates we're fine to mention.~~

~~I think it's a bit sketchy that we're doing this at all, tbh; I think it *should* be fine for the anon const to inherit the predicates of the opaque it's located inside. However, that would also mean that we need to make sure the `generics_of` that anon const line up in the same way.~~

~~None of this is important to solve right now; I just want to fix these ICEs so we can land #125468, which accidentally fixes these issues in a different and unrelated way.~~

edit: We don't need this special case anyways because we install the right parent item in `generics_of` anyways:
213ad10c8f/compiler/rustc_hir_analysis/src/collect/generics_of.rs (L150)

r? `@BoxyUwU`
2024-05-24 23:01:11 +02:00
Matthias Krüger 09047b8700
Rollup merge of #125485 - GuillaumeGomez:migrate-rmake-rustdoc, r=jieyouxu
Migrate `run-make/rustdoc-with-output-dir-option` to `rmake.rs`

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

r? `@jieyouxu`
2024-05-24 23:01:10 +02:00
Matthias Krüger fafe13aea4
Rollup merge of #125467 - compiler-errors:binop-in-bool-expectation, r=estebank
Only suppress binop error in favor of semicolon suggestion if we're in an assignment statement

Similar to #123722, we are currently too aggressive when delaying a binop error with the expectation that we'll emit another error elsewhere. This adjusts that heuristic to be more accurate, at the cost of some possibly poorer suggestions.

Fixes #125458
2024-05-24 23:01:09 +02:00
lcnr 24b5466892 drop region constraints for ambiguous goals 2024-05-24 20:32:35 +00:00
Michael Goulet 61aac551b8 Structurally resolve before builtin_index in EUV 2024-05-24 16:20:48 -04:00
Hans Wennborg 3fe3157858 Stop using the avx512er and avx512pf x86 target features
They are no longer supported by LLVM 19.

Fixes #125492
2024-05-24 20:12:42 +02:00
Michael Goulet de517b79bc Actually just remove the special case altogether 2024-05-24 13:16:06 -04:00
Boxy 796cb8031d Remove failing tests 2024-05-24 18:06:57 +01:00
Boxy fe2d7794ca Remove `DefId` from `EarlyParamRegion` (tedium/diagnostics) 2024-05-24 18:06:53 +01:00
Alona Enraght-Moony 3ee84983f1 rustdoc-json: Add test for keywords with `--document-private-items` 2024-05-24 16:40:20 +00:00
Oli Scherer 526090b901 Add regression tests 2024-05-24 14:01:49 +00:00