Commit graph

272945 commits

Author SHA1 Message Date
Esteban Küber
0f82cfffda Keep track of patterns that could have introduced a binding, but didn't
When we recover from a pattern parse error, or a pattern uses `..`, we keep track of that and affect resolution error for missing bindings that could have been provided by that pattern. We differentiate between `..` and parse recovery. We silence resolution errors likely caused by the pattern parse error.

```
error[E0425]: cannot find value `title` in this scope
  --> $DIR/struct-pattern-with-missing-fields-resolve-error.rs:19:30
   |
LL |         println!("[{}]({})", title, url);
   |                              ^^^^^ not found in this scope
   |
note: `Website` has a field `title` which could have been included in this pattern, but it wasn't
  --> $DIR/struct-pattern-with-missing-fields-resolve-error.rs:17:12
   |
LL | / struct Website {
LL | |     url: String,
LL | |     title: Option<String> ,
   | |     ----- defined here
LL | | }
   | |_-
...
LL |       if let Website { url, .. } = website {
   |              ^^^^^^^^^^^^^^^^^^^ this pattern doesn't include `title`, which is available in `Website`
```

Fix #74863.
2024-12-13 21:51:33 +00:00
bors
21fe748be1 Auto merge of #134177 - matthiaskrgr:rollup-hgp8q60, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #132975 (De-duplicate and improve definition of core::ffi::c_char)
 - #133598 (Change `GetManyMutError` to match T-libs-api decision)
 - #134148 (add comments in check_expr_field)
 - #134163 (coverage: Rearrange the code for embedding per-function coverage metadata)
 - #134165 (wasm(32|64): update alignment string)
 - #134170 (Subtree update of `rust-analyzer`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-12-11 19:06:46 +00:00
Matthias Krüger
531e578ee5
Rollup merge of #134170 - lnicola:sync-from-ra, r=lnicola
Subtree update of `rust-analyzer`

r? `@ghost`
2024-12-11 20:00:22 +01:00
Matthias Krüger
eefefbea2f
Rollup merge of #134165 - durin42:wasm-target-string, r=jieyouxu
wasm(32|64): update alignment string

See llvm/llvm-project@c5ab70c508

`@rustbot` label: +llvm-main
2024-12-11 20:00:21 +01:00
Matthias Krüger
13c13ee4ec
Rollup merge of #134163 - Zalathar:covfun, r=SparrowLii,jieyouxu
coverage: Rearrange the code for embedding per-function coverage metadata

This is a series of refactorings to the code that prepares and embeds per-function coverage metadata records (“covfun records”) in the `__llvm_covfun` linker section of the final binary. The `llvm-cov` tool reads this metadata from the binary when preparing a coverage report.

Beyond general cleanup, a big motivation behind these changes is to pave the way for re-landing an updated version of #133418.

---

There should be no change in compiler output, as demonstrated by the absence of (meaningful) changes to coverage tests.

The first patch is just moving code around, so I suggest looking at the other patches to see the actual changes.

---

try-job: x86_64-gnu
try-job: x86_64-msvc
try-job: aarch64-apple
2024-12-11 20:00:18 +01:00
Matthias Krüger
90a42c2519
Rollup merge of #134148 - dev-ardi:cleanup_check_field_expr, r=compiler-errors
add comments in check_expr_field

Nothing special, just a few comments and a couple of small cleanups.
2024-12-11 20:00:15 +01:00
Matthias Krüger
2e60288ce0
Rollup merge of #133598 - ChayimFriedman2:get-many-mut-detailed-err, r=scottmcm
Change `GetManyMutError` to match T-libs-api decision

That is, differentiate between out-of-bounds and overlapping indices, and remove the generic parameter `N`.

I also exported `GetManyMutError` from `alloc` (and `std`), which was apparently forgotten.

Changing the error to carry additional details means LLVM no longer generates separate short-circuiting branches for the checks, instead it generates one branch at the end. I therefore changed the  code to use early returns to make LLVM generate jumps. Benchmark results between the approaches are somewhat mixed, but I chose this approach because it is significantly faster with ranges and also faster with `unwrap()`.

Benchmark (`jumps` refer to short-circuiting, `acc` is not short-circuiting):
```rust
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use my_crate::{get_many_check_valid_acc, get_many_check_valid_jumps, GetManyMutError};

mod externs {
    #[unsafe(no_mangle)]
    fn foo() {}
    #[unsafe(no_mangle)]
    fn bar() {}
    #[unsafe(no_mangle)]
    fn baz() {}
}

unsafe extern "C" {
    safe fn foo();
    safe fn bar();
    safe fn baz();
}

fn bench_method(c: &mut Criterion) {
    c.bench_function("jumps two usize", |b| {
        b.iter(|| get_many_check_valid_jumps(&[black_box(1), black_box(5)], black_box(10)))
    });
    c.bench_function("jumps two usize unwrap", |b| {
        b.iter(|| get_many_check_valid_jumps(&[black_box(1), black_box(5)], black_box(10)).unwrap())
    });
    c.bench_function("jumps two usize ok", |b| {
        b.iter(|| get_many_check_valid_jumps(&[black_box(1), black_box(5)], black_box(10)).ok())
    });
    c.bench_function("jumps three usize", |b| {
        b.iter(|| {
            get_many_check_valid_jumps(&[black_box(1), black_box(5), black_box(7)], black_box(10))
        })
    });
    c.bench_function("jumps three usize match", |b| {
        b.iter(|| {
            match get_many_check_valid_jumps(
                &[black_box(1), black_box(5), black_box(7)],
                black_box(10),
            ) {
                Err(GetManyMutError::IndexOutOfBounds) => foo(),
                Err(GetManyMutError::OverlappingIndices) => bar(),
                Ok(()) => baz(),
            }
        })
    });
    c.bench_function("jumps two Range", |b| {
        b.iter(|| {
            get_many_check_valid_jumps(
                &[black_box(1)..black_box(5), black_box(7)..black_box(8)],
                black_box(10),
            )
        })
    });
    c.bench_function("jumps two RangeInclusive", |b| {
        b.iter(|| {
            get_many_check_valid_jumps(
                &[black_box(1)..=black_box(5), black_box(7)..=black_box(8)],
                black_box(10),
            )
        })
    });

    c.bench_function("acc two usize", |b| {
        b.iter(|| get_many_check_valid_acc(&[black_box(1), black_box(5)], black_box(10)))
    });
    c.bench_function("acc two usize unwrap", |b| {
        b.iter(|| get_many_check_valid_acc(&[black_box(1), black_box(5)], black_box(10)).unwrap())
    });
    c.bench_function("acc two usize ok", |b| {
        b.iter(|| get_many_check_valid_acc(&[black_box(1), black_box(5)], black_box(10)).ok())
    });
    c.bench_function("acc three usize", |b| {
        b.iter(|| {
            get_many_check_valid_acc(&[black_box(1), black_box(5), black_box(7)], black_box(10))
        })
    });
    c.bench_function("acc three usize match", |b| {
        b.iter(|| {
            match get_many_check_valid_jumps(
                &[black_box(1), black_box(5), black_box(7)],
                black_box(10),
            ) {
                Err(GetManyMutError::IndexOutOfBounds) => foo(),
                Err(GetManyMutError::OverlappingIndices) => bar(),
                Ok(()) => baz(),
            }
        })
    });
    c.bench_function("acc two Range", |b| {
        b.iter(|| {
            get_many_check_valid_acc(
                &[black_box(1)..black_box(5), black_box(7)..black_box(8)],
                black_box(10),
            )
        })
    });
    c.bench_function("acc two RangeInclusive", |b| {
        b.iter(|| {
            get_many_check_valid_acc(
                &[black_box(1)..=black_box(5), black_box(7)..=black_box(8)],
                black_box(10),
            )
        })
    });
}

criterion_group!(benches, bench_method);
criterion_main!(benches);
```
Benchmark results:
```none
jumps two usize          time:   [586.44 ps 590.20 ps 594.50 ps]
jumps two usize unwrap   time:   [390.44 ps 393.63 ps 397.44 ps]
jumps two usize ok       time:   [585.52 ps 591.74 ps 599.38 ps]
jumps three usize        time:   [976.51 ps 983.79 ps 991.51 ps]
jumps three usize match  time:   [390.82 ps 393.80 ps 397.07 ps]
jumps two Range          time:   [1.2583 ns 1.2640 ns 1.2695 ns]
jumps two RangeInclusive time:   [1.2673 ns 1.2770 ns 1.2877 ns]
acc two usize            time:   [592.63 ps 596.44 ps 600.52 ps]
acc two usize unwrap     time:   [582.65 ps 587.07 ps 591.90 ps]
acc two usize ok         time:   [581.59 ps 587.82 ps 595.71 ps]
acc three usize          time:   [894.69 ps 901.23 ps 908.24 ps]
acc three usize match    time:   [392.68 ps 395.73 ps 399.17 ps]
acc two Range            time:   [1.5531 ns 1.5617 ns 1.5711 ns]
acc two RangeInclusive   time:   [1.5746 ns 1.5840 ns 1.5939 ns]
```
2024-12-11 20:00:14 +01:00
Matthias Krüger
fe516ef9f4
Rollup merge of #132975 - arichardson:ffi-c-char, r=tgross35
De-duplicate and improve definition of core::ffi::c_char

Instead of having a list of unsigned char targets for each OS, follow the logic Clang uses and instead set the value based on architecture with a special case for Darwin and Windows operating systems. This makes it easier to support new operating systems targeting Arm/AArch64 without having to modify this config statement for each new OS. The new list does not quite match Clang since I noticed a few bugs in the Clang implementation (https://github.com/llvm/llvm-project/issues/115957).

Fixes https://github.com/rust-lang/rust/issues/129945
Closes https://github.com/rust-lang/rust/pull/131319
2024-12-11 20:00:12 +01:00
bors
1f3bf231e1 Auto merge of #134164 - jhpratt:rollup-s7z0vcc, r=jhpratt
Rollup of 8 pull requests

Successful merges:

 - #134079 (Add a note saying that `{u8,i8}::from_{be,le,ne}_bytes` is meaningless)
 - #134105 (Validate self in host predicates correctly)
 - #134136 (Exercise const trait interaction with default fields)
 - #134139 ([AIX] keep profile-rt symbol alive)
 - #134141 (Remove more traces of anonymous ADTs)
 - #134142 (Rudimentary heuristic to insert parentheses when needed for RPIT overcaptures lint)
 - #134158 (Rename `projection_def_id` to `item_def_id`)
 - #134160 (Add vacation entry for myself in triagebot.toml)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-12-11 15:31:52 +00:00
Orion Gonzalez
55806e5655 document check_expr_field 2024-12-11 13:48:50 +01:00
Augie Fackler
48b883287a wasm(32|64): update alignment string
See llvm/llvm-project@c5ab70c508

@rustbot label: +llvm-main
2024-12-11 05:52:59 -05:00
Zalathar
3f3a9bf7f5 coverage: Store intermediate region tables in CovfunRecord
This defers the call to `llvm_cov::write_function_mappings_to_buffer` until
just before its enclosing global variable is created.
2024-12-11 21:35:45 +11:00
Zalathar
512f3fdebe coverage: Only generate a CGU's covmap record if it has covfun records 2024-12-11 21:35:44 +11:00
Zalathar
9e6b7c17c8 coverage: Adjust a codegen test to ignore the order of covmap/covfun globals 2024-12-11 21:34:48 +11:00
Lukas Wirth
a18e38e6e2
Merge pull request #18663 from Veykril/push-syoklzkntykn
fix: Swallow rustfmt parsing panics
2024-12-11 10:06:28 +00:00
Laurențiu Nicola
81720881ae
Merge pull request #18662 from lnicola/sync-from-rust
internal: Sync from downstream
2024-12-11 10:05:39 +00:00
Lukas Wirth
e6fbb5c8e6 fix: Swallow rustfmt parsing panics 2024-12-11 10:52:04 +01:00
Laurențiu Nicola
884f57f9fc Bump rustc crates 2024-12-11 11:50:19 +02:00
Laurențiu Nicola
5db2aa865c Merge from rust-lang/rust 2024-12-11 11:49:08 +02:00
Laurențiu Nicola
1649eb6dd7 Preparing for merge from rust-lang/rust 2024-12-11 11:48:46 +02:00
Jacob Pratt
c384b28148
Rollup merge of #134160 - celinval:chores-vacation, r=jieyouxu
Add vacation entry for myself in triagebot.toml

It's that wonderful time of the year. 😃
2024-12-11 03:30:45 -05:00
Jacob Pratt
c4e27d67a7
Rollup merge of #134158 - compiler-errors:item-def-id, r=jackh726
Rename `projection_def_id` to `item_def_id`

Renames `projection_def_id` to `item_def_id`, since `item_def_id` is what we call the analogous method for ~~`AliasTerm`/`AliasTy`~~ `PolyExistentialProjection`. I keep forgetting that this one is not called `item_def_id`.
2024-12-11 03:30:44 -05:00
Jacob Pratt
f1030765f3
Rollup merge of #134142 - compiler-errors:paren-sug, r=jieyouxu
Rudimentary heuristic to insert parentheses when needed for RPIT overcaptures lint

We don't have basically any preexisting machinery to detect when parentheses are needed for *types*. AFAICT, all of the diagnostics we have for opaques just... fail when they suggest `+ 'a` when that's ambiguous.

Fixes #132853
2024-12-11 03:30:44 -05:00
Jacob Pratt
16b64938c2
Rollup merge of #134141 - compiler-errors:anon-adt, r=lqd
Remove more traces of anonymous ADTs

Anonymous ADTs were removed in #131045, but I forgot to remove this.
2024-12-11 03:30:43 -05:00
Jacob Pratt
2891a92e90
Rollup merge of #134139 - mustartt:pgo-linker-flag, r=saethlin
[AIX] keep profile-rt symbol alive

Clang passes `-u __llvm_profile_runtime` on AIX. https://reviews.llvm.org/D136192
We want to preserve the symbol in the case there are no instrumented object files.
2024-12-11 03:30:42 -05:00
Jacob Pratt
fe7fc76835
Rollup merge of #134136 - estebank:const-trait-default-field-test, r=jieyouxu
Exercise const trait interaction with default fields

Add a test case for using the result of a fn call of an associated function of a `const` trait in a struct default field.

```rust
struct X;
trait Trait {
    fn value() -> Self;
}
impl const Trait for X {
    fn value() -> Self { X }
}
struct S<T: const Trait> {
    a: T = T::value(),
}
```
2024-12-11 03:30:42 -05:00
Jacob Pratt
5cf16d8b1f
Rollup merge of #134105 - compiler-errors:validate-self-preds, r=wesleywiser
Validate self in host predicates correctly

`assert_only_contains_predicates_from` was added to make sure that we are computing predicates for the correct self type for a given `PredicateFilter`. That was not implemented correctly for `PredicateFilter::SelfOnly` when there are const predicates.

Fixes #133526
2024-12-11 03:30:41 -05:00
Jacob Pratt
43b4af5b77
Rollup merge of #134079 - tbu-:pr_doc_x8_to_from_xe_bytes, r=jhpratt
Add a note saying that `{u8,i8}::from_{be,le,ne}_bytes` is meaningless
2024-12-11 03:30:40 -05:00
Zalathar
6a8c016266 coverage: Reify CovfunRecord as an intermediate step 2024-12-11 18:25:10 +11:00
Lukas Wirth
536eea39e8
Merge pull request #18458 from Giga-Bowser/master
feat: Add diagnostic fix to remove unnecessary wrapper in type mismatch
2024-12-11 07:09:15 +00:00
Lukas Wirth
e1a27b8708
Merge pull request #18653 from SomeoneToIgnore/hash-completions
Hash completion items to properly match them during /resolve
2024-12-11 07:08:33 +00:00
Lukas Wirth
b20d1b80bb
Merge pull request #18657 from Giga-Bowser/generate-enum-variant
minor: Migrate `generate_enum_variant` to `SyntaxEditor`
2024-12-11 07:07:22 +00:00
Lukas Wirth
611c72f2f0
Merge pull request #18656 from roife/fix-issue-18639
feat: preserve order of parameters in extract_functions
2024-12-11 07:00:17 +00:00
Zalathar
7c4ac71ad1 coverage: Extract function metadata handling to a covfun submodule 2024-12-11 17:49:44 +11:00
bors
5a6036a180 Auto merge of #134137 - fmease:rollup-u1p7swx, r=fmease
Rollup of 9 pull requests

Successful merges:

 - #133583 (Fix type (exit → exist))
 - #134042 (Add the `power8-crypto` target feature)
 - #134094 (Tweak wording of non-const traits used as const bounds)
 - #134100 (Remove rustc_const_stable attribute on const NOOP)
 - #134103 (Don't ICE when encountering never in range pattern)
 - #134113 (run-make: Fix `assert_stderr_not_contains_regex`)
 - #134115 (rustc_target: ppc64 target string fixes for LLVM 20)
 - #134116 (stabilize const_nonnull_new)
 - #134120 (Remove Felix from ping groups and review rotation)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-12-11 05:31:46 +00:00
Celina G. Val
45ad5a5735
Add vacation entry in triagebot.toml 2024-12-10 19:36:52 -08:00
Tobias Bucher
e37d7c0f15 Add a note saying that {u8,i8}::from_{be,le,ne}_bytes is meaningless 2024-12-11 02:18:17 +01:00
Michael Goulet
ec68498317 Rename projection_def_id to item_def_id 2024-12-11 00:59:43 +00:00
Michael Goulet
e134c74904 Rudimentary heuristic to insert parentheses when needed for RPIT overcaptures lint 2024-12-10 20:42:47 +00:00
Michael Goulet
916d279236 Remove more traces of anonymous ADTs 2024-12-10 19:50:47 +00:00
Esteban Küber
979eb4e98e Further document default field test 2024-12-10 19:21:07 +00:00
León Orell Valerian Liehr
e60f6cdd3d
Rollup merge of #134120 - oli-obk:push-vryonyoqmonv, r=oli-obk
Remove Felix from ping groups and review rotation
2024-12-10 20:16:07 +01:00
León Orell Valerian Liehr
e822dfc415
Rollup merge of #134116 - RalfJung:const_nonnull_new, r=jhpratt
stabilize const_nonnull_new

FCP passed in https://github.com/rust-lang/rust/issues/93235

Closes #93235
2024-12-10 20:16:06 +01:00
León Orell Valerian Liehr
6d17cb833d
Rollup merge of #134115 - durin42:ppc64-target-string, r=jieyouxu
rustc_target: ppc64 target string fixes for LLVM 20

LLVM continues to clean these up, and we continue to make this consistent. This is similar to 9caced7bad, e985396145, and
a10e744faf.

```@rustbot``` label: +llvm-main
2024-12-10 20:16:05 +01:00
León Orell Valerian Liehr
0b9e74af2e
Rollup merge of #134113 - jyn514:run-make-contains, r=jieyouxu
run-make: Fix `assert_stderr_not_contains_regex`

It asserted on **stdout**, not stderr.

r? ``@jieyouxu``
2024-12-10 20:16:04 +01:00
León Orell Valerian Liehr
c5a83862a2
Rollup merge of #134103 - compiler-errors:never-pat-range, r=oli-obk
Don't ICE when encountering never in range pattern

Fixes #133947

r? oli-obk
2024-12-10 20:16:04 +01:00
León Orell Valerian Liehr
f621be4ecc
Rollup merge of #134100 - eholk:noop-rustc-const-stable, r=dtolnay
Remove rustc_const_stable attribute on const NOOP

This was accidentally reintroduced while editing #133089.

r? dtolnay
2024-12-10 20:16:03 +01:00
León Orell Valerian Liehr
185440a375
Rollup merge of #134094 - estebank:const-trait-errors, r=compiler-errors
Tweak wording of non-const traits used as const bounds

Use verbose suggestions and add additional labels/notes.

r? ``@compiler-errors``
2024-12-10 20:16:02 +01:00
León Orell Valerian Liehr
0064e731a6
Rollup merge of #134042 - sayantn:power8-crypto, r=jieyouxu
Add the `power8-crypto` target feature

Add the `power8-crypto` target feature. This will enable adding some new PPC intrinsics in stdarch (specifically AES, SHA and CLMUL intrinsics). The implied target feature is from [here](https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/PowerPC/PPC.td)

```@rustbot``` label A-target-feature O-PowerPC
2024-12-10 20:16:01 +01:00
León Orell Valerian Liehr
5bd9602e33
Rollup merge of #133583 - tbu-:pr_fix_typo2, r=compiler-errors
Fix type (exit → exist)
2024-12-10 20:16:00 +01:00