Commit graph

249351 commits

Author SHA1 Message Date
clubby789 39e36af856 Bump cargo update PR more often 2024-03-14 11:24:09 +00:00
bors cb580ff677 Auto merge of #122243 - RalfJung:local-place-sanity-check, r=oli-obk
interpret: ensure that Place is never used for a different frame

We store the address where the stack frame stores its `locals`. The idea is that even if we pop and push, or switch to a different thread with a larger number of frames, then the `locals` address will most likely change so we'll notice that problem. This is made possible by some recent changes by `@WaffleLapkin,` where we no longer use `Place` across things that change the number of stack frames.

I made these debug assertions for now, just to make sure this can't cost us any perf.

The first commit is unrelated but it's a one-line comment change so it didn't warrant a separate PR...

r? `@oli-obk`
2024-03-14 07:28:07 +00:00
bors 6f3eb1ce3d Auto merge of #122454 - matthiaskrgr:rollup-xbmufdc, r=matthiaskrgr
Rollup of 11 pull requests

Successful merges:

 - #122422 (compiletest: Allow `only-unix` in test headers)
 - #122424 (fix: typos)
 - #122425 (Increase timeout for new bors bot)
 - #122426 (Fix StableMIR `WrappingRange::is_full` computation)
 - #122429 (Add Exploit Mitigations PG to triagebot.toml)
 - #122430 (Generate link to `Local` in `hir::Let` documentation)
 - #122434 (pattern analysis: rename a few types)
 - #122437 (pattern analysis: remove `MaybeInfiniteInt::JustAfterMax`)
 - #122438 (Safe Transmute: Require that source referent is smaller than destination)
 - #122442 (extend docs of -Zprint-mono-items)
 - #122449 (Delay a bug for stranded opaques)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-03-14 04:54:37 +00:00
bors 5ac0b2d021 Auto merge of #122347 - oli-obk:track_errors13, r=compiler-errors
Revert "Auto merge of #122140 - oli-obk:track_errors13, r=davidtwco"

This reverts commit 65cd843ae0, reversing changes made to d255c6a57c.

reverts https://github.com/rust-lang/rust/pull/122140

It was a large regression in wall time due to trashing CPU caches
2024-03-14 02:54:10 +00:00
bors c7fed9f854 Auto merge of #122204 - pnkfelix:downgrade-const-eval-dnagling-ptr-in-final-to-future-incompat-lint, r=wesleywiser
Downgrade const eval dangling ptr in final to future incompat lint

Short term band-aid for issue #121610, downgrading the prior hard error to a future-incompat lint (tracked in issue #122153).

Note we should not mark #121610 as resolved until after this (or something analogous) is beta backported.
2024-03-14 00:06:26 +00:00
Matthias Krüger c52ce4eabb
Rollup merge of #122449 - compiler-errors:stranded-opaque, r=oli-obk
Delay a bug for stranded opaques

r? oli-obk

Fixes #122445
2024-03-13 20:01:58 +01:00
Matthias Krüger 8d2f79c3f1
Rollup merge of #122442 - RalfJung:print-mono-items, r=compiler-errors
extend docs of -Zprint-mono-items

Currently the values one can set this to are not documented anywhere.

I think ideally this flag wouldn't overwrite the collector's behavior, a "print" flag should just print what happens but not change what happens. But our codegen-units tests rely on being able to collect all items without the other side-effects of `-C link-dead-code` and I can't tell whether that reliance is incidental or crucial, so I'm not touching this and just documenting the (messy) status quo.
2024-03-13 20:01:58 +01:00
Matthias Krüger 89c3fa92d4
Rollup merge of #122438 - jswrenn:check-referent-size, r=compiler-errors
Safe Transmute: Require that source referent is smaller than destination

`BikeshedIntrinsicFrom` currently models transmute-via-union; i.e., it attempts to provide a `where` bound for this function:
```rust
pub unsafe fn transmute_via_union<Src, Dst>(src: Src) -> Dst {
    use core::mem::*;

    #[repr(C)]
    union Transmute<T, U> {
        src: ManuallyDrop<T>,
        dst: ManuallyDrop<U>,
    }

    let transmute = Transmute { src: ManuallyDrop::new(src) };

    // SAFETY: The caller must guarantee that the transmutation is safe.
    let dst = transmute.dst;

    ManuallyDrop::into_inner(dst)
}
```
A quirk of this model is that it admits padding extensions in value-to-value transmutation: The destination type can be bigger than the source type, so long as the excess consists of uninitialized bytes. However, this isn't permissible for reference-to-reference transmutations (introduced in #110662) — extra referent bytes cannot come from thin air.

This PR patches our analysis for reference-to-reference transmutations to require that the destination referent is no larger than the source referent.

r? `@compiler-errors`
2024-03-13 20:01:58 +01:00
Matthias Krüger 5c2aa6dc6f
Rollup merge of #122437 - Nadrieril:no-after-max, r=compiler-errors
pattern analysis: remove `MaybeInfiniteInt::JustAfterMax`

It was inherited from before half-open ranges, but it doesn't pull its weight anymore. We lose a tiny bit of diagnostic precision as can be seen in the test. I'm generally in favor of half-open ranges over explicit `x..=MAX` ranges anyway.
2024-03-13 20:01:57 +01:00
Matthias Krüger b3376bb92f
Rollup merge of #122434 - Nadrieril:renames, r=compiler-errors
pattern analysis: rename a few types

A few long overdue renames. `ValidityConstraint` was supposed to serve double purpose but I don't need that anymore. I don't know what I was thinking with `TypeCx` I think I was trying to be clever. That's fixed now 😄

r? ``@compiler-errors``
2024-03-13 20:01:57 +01:00
Matthias Krüger b84d1b8ec9
Rollup merge of #122430 - GuillaumeGomez:link-to-local, r=TaKO8Ki
Generate link to `Local` in `hir::Let` documentation

This PR adds a missing link generation to `Local` type.
2024-03-13 20:01:56 +01:00
Matthias Krüger c6acc47081
Rollup merge of #122429 - rcvalle:rust-triagebot-add-exploit-mitigations-pg, r=wesleywiser
Add Exploit Mitigations PG to triagebot.toml
2024-03-13 20:01:56 +01:00
Matthias Krüger 96a41ce513
Rollup merge of #122426 - celinval:smir-fix-full, r=oli-obk
Fix StableMIR `WrappingRange::is_full` computation

`WrappingRange::is_full` computation assumed that to be full the range couldn't wrap, which is not necessarily true.

For example, a range of 1..=0 is a valid representation of a full wrapping range.
2024-03-13 20:01:55 +01:00
Matthias Krüger cf79540874
Rollup merge of #122425 - Kobzol:new-bors-update-timeout, r=lqd
Increase timeout for new bors bot

2 hours isn't enough even to run an uncached try build.. :)

r? ``@Mark-Simulacrum``
2024-03-13 20:01:55 +01:00
Matthias Krüger ff5e1eb8ac
Rollup merge of #122424 - testwill:typos, r=michaelwoerister
fix: typos
2024-03-13 20:01:54 +01:00
Matthias Krüger fa98724d02
Rollup merge of #122422 - Enselic:only-unix, r=oli-obk
compiletest: Allow `only-unix` in test headers

The header `ignore-unix` is already allowed. Also extend tests.

This is needed by https://github.com/rust-lang/rust/pull/121573 which I am splitting up into smaller and more digestible PRs.
2024-03-13 20:01:54 +01:00
Felix S. Klock II 8f45a9e93d include 32-bit variant for updated test of miri diagnostics. 2024-03-13 14:53:04 -04:00
Michael Goulet 026eb3dd64 Delay a bug for stranded opaques 2024-03-13 13:44:00 -04:00
Jack Wrenn 216df4a8e6 safe transmute: require that src referent is smaller than dst
The source referent absolutely must be smaller than the destination
referent of a ref-to-ref transmute; the excess bytes referenced
cannot arise from thin air, even if those bytes are uninitialized.
2024-03-13 15:53:48 +00:00
bors 3cbb93223f Auto merge of #121668 - erikdesjardins:commonprim, r=scottmcm,oli-obk
Represent `Result<usize, Box<T>>` as ScalarPair(i64, ptr)

This allows types like `Result<usize, std::io::Error>` (and integers of differing sign, e.g. `Result<u64, i64>`) to be passed in a pair of registers instead of through memory, like `Result<u64, u64>` or `Result<Box<T>, Box<U>>` are today.

Fixes #97540.

r? `@ghost`
2024-03-13 15:25:35 +00:00
Ramon de C Valle 533ddf97c6 Add Exploit Mitigations PG to triagebot.toml
Add autolabels and mentions for the Exploit Mitigations PG to
triagebot.toml.
2024-03-13 08:24:06 -07:00
Ralf Jung 2366d97d81 extend docs of -Zprint-mono-items 2024-03-13 16:11:48 +01:00
Felix S. Klock II 9c33cc62aa placate tidy. 2024-03-13 10:51:12 -04:00
Felix S. Klock II 1ea091a7fc Rebase. Update expected output to match current output. 2024-03-13 10:50:17 -04:00
Wesley Wiser ae374cf04a Add produces as tidy requires 2024-03-13 10:32:42 -04:00
Felix S. Klock II 354c41eeb6 Updated the test to include more output normalization. 2024-03-13 10:32:42 -04:00
Felix S. Klock II 6ca46daded Added an "Explanation" header and expanded that section for the newly added lint. 2024-03-13 10:32:41 -04:00
Felix S. Klock II 1c3424bfc1 Added deny(const_eval_mutable_ptr_in_final_value) attribute to all tests that were expecting the hard error for it.
I attempted to do this in a manner that preserved the line numbers to reduce the
review effort on the resulting diff, but we still have to deal with the
ramifications of how a future-incompat lint behaves compared to a hard-error (in
terms of its impact on the diagnostic output).
2024-03-13 10:32:41 -04:00
Felix S. Klock II f86b46a9cc regression test from 121610. 2024-03-13 10:32:41 -04:00
Felix S. Klock II a8549b4152 downgrade mutable-ptr-in-final-value from hard-error to future-incompat lint to address issue 121610. 2024-03-13 10:32:39 -04:00
bors 184c5ab180 Auto merge of #121589 - bvanjoi:fix-98291, r=petrochenkov
delay expand macro bang when there has indeterminate path

Related #98291

I will attempt to clarify the root problem through several examples:

Firstly,

```rs
// rustc code.rs --edition=2018

macro_rules! wrap {
    () => {
        macro_rules! _a {
            () => {
                "Hello world"
            };
        }
    };
}

wrap!();

use _a as a;

fn main() {
    format_args!(_a!());
}
```

The above case will compile successfully because `_a` is defined after the `wrap` expaned, ensuring `_a` can be resolved without any issues.

And,

```rs
// rustc code.rs --edition=2018

macro_rules! wrap {
    () => {
        macro_rules! _a {
            () => {
                "Hello world"
            };
        }
    };
}

wrap!();

use _a as a;

fn main() {
    format_args!("{}", a!());
}
```

The above example will also compile successfully because the `parse_args` in `expand_format_args_impl` will return a value `MacroInput { fmtstr: Expr::Lit::Str, args: [Expr::MacroCall]}`. Since the graph for `args` will be build lately, `a` will eventually be resolved.

However, in the case of:

```rs
// rustc code.rs --edition=2018

macro_rules! wrap {
    () => {
        macro_rules! _a {
            () => {
                "Hello world"
            };
        }
    };
}

wrap!();

use _a as a;

fn main() {
    format_args!(a!());
}
```

The result of `parse_args` is `MacroInput {fmtstr: Expr::Lit::Macro, args: [] }`, we attempt to expand `fmtstr` **eagerly** within `expr_to_spanned_string`. Although we have recorded `(root, _a)` into resolutions, `use _a as a` is an indeterminate import, which will not try to resolve under the conditions of `expander.monotonic = false`.

Therefore, I've altered the strategy for resolving indeterminate imports, ensuring it will also resolve during eager expansion. This could be a significant change to the resolution infra. However, I think it's acceptable if the goal of avoiding resolution under eager expansion is to save time.

r? `@petrochenkov`
2024-03-13 13:20:42 +00:00
Nadrieril c4236785c7 Remove MaybeInfiniteInt::JustAfterMax
It was inherited from before half-open ranges, but it doesn't pull its
weight anymore. We lose a tiny bit of diagnostic precision.
2024-03-13 14:17:11 +01:00
Nadrieril f27540697e Rename RustcMatchCheckCtxt -> RustcPatCtxt 2024-03-13 14:07:44 +01:00
Nadrieril 4fc35c46ff Rename TypeCx -> PatCx 2024-03-13 13:56:38 +01:00
Nadrieril cb15bf6256 Rename ValidityConstraint -> PlaceValidity
The old name came from a time where I wanted to reuse it for
differentiating wildcards from bindings. I don't plan to do this
anymore.
2024-03-13 13:53:18 +01:00
Guillaume Gomez d919b04e59 Generate link to Local in hir::Let documentation 2024-03-13 11:24:51 +01:00
bors 9ce37dc729 Auto merge of #122240 - RalfJung:miri-addr-reuse, r=oli-obk
miri: add some chance to reuse addresses of previously freed allocations

The hope is that this can help us find ABA issues.

Unfortunately this needs rustc changes so I can't easily run the regular benchmark suite. I used `src/tools/miri/tests/pass/float_nan.rs` as a substitute:
```
Before:
Benchmark 1: ./x.py run miri --stage 0 --args src/tools/miri/tests/pass/float_nan.rs --args --edition=2021
  Time (mean ± σ):      9.570 s ±  0.013 s    [User: 9.279 s, System: 0.290 s]
  Range (min … max):    9.561 s …  9.579 s    2 runs

After:
Benchmark 1: ./x.py run miri --stage 0 --args src/tools/miri/tests/pass/float_nan.rs --args --edition=2021
  Time (mean ± σ):      9.698 s ±  0.046 s    [User: 9.413 s, System: 0.279 s]
  Range (min … max):    9.666 s …  9.731 s    2 runs
```
That's a ~1.3% slowdown, which seems fine to me. I have seen a lot of noise in this style of benchmarking so I don't quite trust this anyway; we can make further experiments in the Miri repo after this migrated there.

r? `@oli-obk`
2024-03-13 09:22:55 +00:00
bohan 8fcdf54a6b delay expand macro bang when there has indeterminate path 2024-03-13 16:11:16 +08:00
Celina G. Val e0488c0961 Fix StableMIR is_full computation
`WrappingRange::is_full` computation assumed that to be full the range
couldn't wrap, which is not necessarily true.

For example, a range of 1..=0 is a valid representation of a full
wrapping range.
2024-03-13 00:36:54 -07:00
Jakub Beránek cdeeed8dec
Increase timeout for new bors bot 2024-03-13 08:31:07 +01:00
bors 762d3170f6 Auto merge of #122423 - matthiaskrgr:rollup-qywgl45, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #121820 (pattern analysis: Store field indices in `DeconstructedPat` to avoid virtual wildcards)
 - #121908 (match lowering: don't collect test alternatives ahead of time)
 - #122203 (Add `intrinsic_name` to get plain intrinsic name)
 - #122226 (coverage: Remove or migrate all unstable values of `-Cinstrument-coverage`)
 - #122255 (Use `min_exhaustive_patterns` in core & std)
 - #122360 ( Don't Create `ParamCandidate` When Obligation Contains Errors )
 - #122383 (Enable PR tracking review assignment for rust-lang/rust)
 - #122386 (Move `Once` implementations to `sys`)
 - #122400 (Fix ICE in diagnostics for parenthesized type arguments)
 - #122410 (rustdoc: do not preload fonts when browsing locally)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-03-13 07:17:22 +00:00
guoguangwu ee8efd705b fix: typos
Signed-off-by: guoguangwu <guoguangwug@gmail.com>
2024-03-13 13:57:23 +08:00
Matthias Krüger 62e9e46937
Rollup merge of #122410 - rjeli:rustdoc-no-local-font-preload, r=notriddle
rustdoc: do not preload fonts when browsing locally

First PR, please let me know if I'm doing anything wrong.

As noted in #98769, currently `cargo doc --open` on macOS/Safari (17.2.1) doesn't load fonts due to a CORS issue. (webkit issue [here](https://bugs.webkit.org/show_bug.cgi?id=249887)). This patch moves the font preloads inside a js if statement as suggested in the GitHub issue.

I tried something more elegant with iterating over a tera array of fonts, but ran into issues, so here's the dumb fix. Only thing to note is that the font path is interpolated into a template string, so HTML escaping works fine, but it will break if there's a backtick or `${` in the font path. Not sure if this is a big deal.
2024-03-13 06:41:25 +01:00
Matthias Krüger 1ffa5ded58
Rollup merge of #122400 - wutchzone:122345, r=fmease
Fix ICE in diagnostics for parenthesized type arguments

The second time is the charm 🤞 😁

Fixes #122345

r? fmease
2024-03-13 06:41:24 +01:00
Matthias Krüger dff680d359
Rollup merge of #122386 - joboet:move_pal_once, r=jhpratt
Move `Once` implementations to `sys`

Part of https://github.com/rust-lang/rust/issues/117276.
2024-03-13 06:41:24 +01:00
Matthias Krüger a18a608c2c
Rollup merge of #122383 - apiraino:enable-pr-tracking, r=jackh726
Enable PR tracking review assignment for rust-lang/rust

This flag enables tracking pull requests review assignment to Rust contributors.

The URL pointing to the documentation will become real once https://github.com/rust-lang/rust-forge/pull/729 is merged

r? ``@jackh726``

cc: ``@Mark-Simulacrum``
2024-03-13 06:41:23 +01:00
Matthias Krüger 5d131407da
Rollup merge of #122360 - veera-sivarajan:bugfix-121941, r=compiler-errors
Don't Create `ParamCandidate` When Obligation Contains Errors

Fixes #121941

I'm not sure if I understand this correctly but this bug was caused by an error type incorrectly matching against `ParamCandidate`. This was introduced by the changes made in #72621 (figured using cargo-bisect-rustc).

This PR fixes it by skipping `ParamCandidate` generation when an error type is involved. Also, this is similar to #73005 but addresses `ParamCandidate` instead of `ImplCandidate`.
2024-03-13 06:41:23 +01:00
Matthias Krüger e42a702430
Rollup merge of #122255 - Nadrieril:min_exh_pats-libs, r=scottmcm
Use `min_exhaustive_patterns` in core & std

[`min_exhaustive_patterns`](https://github.com/rust-lang/rust/issues/119612) provides a subset of the functionality of [`exhaustive_patterns`](https://github.com/rust-lang/rust/issues/51085) which is likely to be stabilized much earlier than the full feature.

The subset covers all the compiler and std use cases. `compiler/` [already uses it](9dd6eda778); this PR switches `std` over.
2024-03-13 06:41:22 +01:00
Matthias Krüger 8b9ef3b996
Rollup merge of #122226 - Zalathar:zcoverage-options, r=nnethercote
coverage: Remove or migrate all unstable values of `-Cinstrument-coverage`

(This PR was substantially overhauled from its original version, which migrated all of the existing unstable values intact.)

This PR takes the three nightly-only values that are currently accepted by `-Cinstrument-coverage`, completely removes two of them (`except-unused-functions` and `except-unused-generics`), and migrates the third (`branch`) over to a newly-introduced unstable flag `-Zcoverage-options`.

I have a few motivations for wanting to do this:

- It's unclear whether anyone actually uses the `except-unused-*` values, so this serves as an opportunity to either remove them, or prompt existing users to object to their removal.
- After #117199, the stable values of `-Cinstrument-coverage` treat it as a boolean-valued flag, so having nightly-only extra values feels out-of-place.
  - Nightly-only values also require extra ad-hoc code to make sure they aren't accidentally exposed to stable users.
- The new system allows multiple different settings to be toggled independently, which isn't possible in the current single-value system.
- The new system makes it easier to introduce new behaviour behind an unstable toggle, and then gather nightly-user feedback before possibly making it the default behaviour for all users.
- The new system also gives us a convenient place to put relatively-narrow options that won't ever be the default, but that nightly users might still want access to.
- It's likely that we will eventually want to give stable users more fine-grained control over coverage instrumentation. The new flag serves as a prototype of what that stable UI might eventually look like.

The `branch` option is a placeholder that currently does nothing. It will be used by #122322 to opt into branch coverage instrumentation.

---

I see `-Zcoverage-options` as something that will exist more-or-less indefinitely, though individual sub-options might come and go as appropriate. I think there will always be some demand for nightly-only toggles, so I don't see `-Zcoverage-options` itself ever being stable, though we might eventually stabilize something similar to it.
2024-03-13 06:41:22 +01:00
Matthias Krüger 8d78f8ee0a
Rollup merge of #122203 - adpaco-aws:smir-intrinsic-name, r=celinval
Add `intrinsic_name` to get plain intrinsic name

Add an `intrinsic_name` API to retrieve the plain intrinsic name. The plain name does not include type arguments (as `trimmed_name` does), which is more convenient to match with intrinsic symbols.
2024-03-13 06:41:21 +01:00