Commit Graph

36007 Commits

Author SHA1 Message Date
Nicholas Nethercote
58a06b6a99 Remove enum_from_u32.
It's a macro that just creates an enum with a `from_u32` method. It has
two arms. One is unused and the other has a single use.

This commit inlines that single use and removes the whole macro. This
increases readability because we don't have two different macros
interacting (`enum_from_u32` and `language_item_table`).
2024-05-09 09:01:59 +10:00
Nicholas Nethercote
d3d01e1cd3 Remove vec_linked_list.
It provides a way to effectively embed a linked list within an
`IndexVec` and also iterate over that list. It's written in a very
generic way, involving two traits `Links` and `LinkElem`. But the
`Links` trait is only impl'd for `IndexVec` and `&IndexVec`, and the
whole thing is only used in one module within `rustc_borrowck`. So I
think it's over-engineered and hard to read. Plus it has no comments.

This commit removes it, and adds a (non-generic) local iterator for the
use within `rustc_borrowck`. Much simpler.
2024-05-09 08:13:24 +10:00
Nicholas Nethercote
f5d7d346a4 Remove TinyList.
It is optimized for lists with a single element, avoiding the need for
an allocation in that case. But `SmallVec<[T; 1]>` also avoids the
allocation, and is better in general: more standard, log2 number of
allocations if the list exceeds one item, and a much more capable API.

This commit removes `TinyList` and converts the two uses to
`SmallVec<[T; 1]>`. It also reorders the `use` items in the relevant
file so they are in just two sections (`pub` and non-`pub`), ordered
alphabetically, instead of many sections. (This is a relevant part of
the change because I had to decide where to add a `use` item for
`SmallVec`.)
2024-05-09 08:13:24 +10:00
Nicholas Nethercote
d7814e72eb Document Pu128.
And move the `repr` line after the `derive` line, where it's harder to
overlook. (I overlooked it initially, and didn't understand how this
type worked.)
2024-05-09 08:13:24 +10:00
Matthias Krüger
782ef18168
Rollup merge of #124909 - compiler-errors:struct-tail-leftovers, r=compiler-errors
Reapply the part of #124548 that bors forgot

https://github.com/rust-lang/rust/pull/124548#issuecomment-2101311205
r? compiler-errors
2024-05-08 23:33:28 +02:00
Matthias Krüger
294ac1b57d
Rollup merge of #124892 - jfgoog:update-cc, r=workingjubilee
Update cc crate to v1.0.97
2024-05-08 23:33:27 +02:00
Matthias Krüger
3e22ea9e2f
Rollup merge of #124876 - nnethercote:rm-use-crate-rustc_foo, r=compiler-errors
Simplify `use crate::rustc_foo::bar` occurrences.

They can just be written as `use rustc_foo::bar`, which is far more standard. (I didn't even know that a `crate::` prefix was valid.)

r? ``@eholk``
2024-05-08 23:33:26 +02:00
Matthias Krüger
952f12ea7a
Rollup merge of #124869 - compiler-errors:keyword, r=Nilstrieb
Make sure we don't deny macro vars w keyword names

`$async:ident`, etc are all valid.

Fixes #124862
2024-05-08 23:33:26 +02:00
Matthias Krüger
d8a3a69ad1
Rollup merge of #124587 - reitermarkus:use-generic-nonzero, r=dtolnay
Generic `NonZero` post-stabilization changes.

Tracking issue: https://github.com/rust-lang/rust/issues/120257

r? ``@dtolnay``
2024-05-08 23:33:25 +02:00
Matthias Krüger
d30af5e168
Rollup merge of #123344 - pietroalbini:pa-unused-imports, r=Nilstrieb
Remove braces when fixing a nested use tree into a single item

[Back in 2019](https://github.com/rust-lang/rust/pull/56645) I added rustfix support for the `unused_imports` lint, to automatically remove them when running `cargo fix`. For the most part this worked great, but when removing all but one childs of a nested use tree it turned `use foo::{Unused, Used}` into `use foo::{Used}`. This is slightly annoying, because it then requires you to run `rustfmt` to get `use foo::Used`.

This PR automatically removes braces and the surrouding whitespace when all but one child of a nested use tree are unused. To get it done I had to add the span of the nested use tree to the AST, and refactor a bit the code I wrote back then.

A thing I noticed is, there doesn't seem to be any `//@ run-rustfix` test for fixing the `unused_imports` lint. I created a test in `tests/suggestions` (is that the right directory?) that for now tests just what I added in the PR. I can followup in a separate PR to add more tests for fixing `unused_lints`.

This PR is best reviewed commit-by-commit.
2024-05-08 23:33:24 +02:00
Veera
21ccec0cc8 Fix Error Messages for break Inside Coroutines
Previously, `break` inside `gen` blocks and functions
were incorrectly identified to be enclosed by a closure.

This PR fixes it by displaying an appropriate error message
for async blocks, async closures, async functions, gen blocks,
gen closures, gen functions, async gen blocks, async gen closures
and async gen functions.

Note: gen closure and async gen closure are not supported by the
compiler yet but I have added an error message here assuming that
they might be implemented in the future.

Also, fixes grammar in a few places by replacing
`inside of a $coroutine` with `inside a $coroutine`.
2024-05-08 17:32:25 -04:00
Gurinder Singh
cacc0829ff Handle normalization failure in struct_tail_erasing_lifetimes
Fixes an ICE that occurred when the struct in question has an error
2024-05-08 17:24:17 -04:00
Ben Kimock
0ca1a94b2b Handle field projections like slice indexing in invalid_reference_casting 2024-05-08 17:21:06 -04:00
Markus Reiter
bd8e565e16
Use generic NonZero. 2024-05-08 21:37:55 +02:00
Markus Reiter
7531eafa7e
Simplify suggestion. 2024-05-08 21:37:54 +02:00
Xavier Denis
d4c6c772c3 Make a minimal amount of region APIs public 2024-05-08 19:22:04 +02:00
James Farrell
fbc2abd6be Update cc crate to v1.0.97 2024-05-08 15:06:35 +00:00
Matthias Krüger
9fce3dc685
Rollup merge of #124761 - Urgau:ref-casting_bigger_slice_index, r=jieyouxu
Fix insufficient logic when searching for the underlying allocation

This PR fixes the logic inside the `invalid_reference_casting` lint, when trying to lint on bigger memory layout casts.

More specifically when looking for the "underlying allocation" we were wrongly assuming that when we got `&mut slice[index]` that `slice[index]` was the allocation, but it's not.

Fixes https://github.com/rust-lang/rust/issues/124685
2024-05-08 17:03:09 +02:00
Matthias Krüger
e997508ecb
Rollup merge of #124548 - gurry:113272-ice-failed-to-normalize, r=compiler-errors
Handle normalization failure in `struct_tail_erasing_lifetimes`

Fixes #113272

The ICE occurred because the struct being normalized had an error. This PR adds some defensive code to guard against that.
2024-05-08 17:03:08 +02:00
bors
e3029d220f Auto merge of #124858 - alexcrichton:some-wasi-changes, r=michaelwoerister
rustc: Some small changes for the wasm32-wasip2 target

This commit has a few changes for the wasm32-wasip2 target. The first two are aimed at improving the compatibility of using `clang` as an external linker driver on this target. The default target to LLVM is updated to match the Rust target and additionally the `-fuse-ld=lld` argument is dropped since that otherwise interferes with clang's own linker detection. The only linker on wasm targets is LLD but on the wasip2 target a wrapper around LLD, `wasm-component-ld`, is used to drive the process and perform steps necessary for componentization.

The final commit changes the output of all objects on the wasip2 target to being PIC by default. This improves compatibilty with shared libaries but notably does not mean that there's a turnkey solution for shared libraries. The hope is that by having the standard libray work both with and without dynamic libraries will make experimentation easier.
2024-05-08 11:39:26 +00:00
Nicholas Nethercote
b68b92041c Simplify use crate::rustc_foo::bar occurrences.
They can just be written as `use rustc_foo::bar`, which is far more
standard. (I didn't even know that a `crate::` prefix was valid.)
2024-05-08 16:57:31 +10:00
bors
5ce96b1d0f Auto merge of #124779 - workingjubilee:debug-formatting-my-beloved, r=compiler-errors
Improve `rustc_parse::Parser`'s debuggability

The main event is the final commit where I add `Parser::debug_lookahead`. Everything else was basically cleaning up things that bugged me (debugging, as it were) until I felt comfortable enough to actually work on it.

The motivation is that it's annoying as hell to try to figure out how the debug infra works in rustc without having basic queries like `debug!(?parser);` come up "empty". However, Parser has a lot of fields that are mostly irrelevant for most debugging, like the entire ParseSess. I think `Parser::debug_lookahead` with a capped lookahead might be fine as a general-purpose Debug impl, but this adapter version was suggested to allow more choice, and admittedly, it's a refined version of what I was already handrolling just to get some insight going.
2024-05-08 05:11:18 +00:00
Michael Goulet
7dbdbaaa8e Fix ICEs in diagnostic::on_unimplemented 2024-05-07 23:13:44 -04:00
Nicholas Nethercote
55b6ff8e41 Remove extern crate tracing.
`use` is a nicer way of doing things.
2024-05-08 12:52:31 +10:00
Jubilee Young
5e67a3783c compiler: add Parser::debug_lookahead
I tried debugging a parser-related issue but found it annoying to not be
able to easily peek into the Parser's token stream.

Add a convenience fn that offers an opinionated view into the parser,
but one that is useful for answering basic questions about parser state.
2024-05-07 19:10:29 -07:00
Jubilee Young
c70290da0a compiler: derive Debug in parser
It's annoying to debug the parser if you have to stop every five seconds
to add a Debug impl.
2024-05-07 19:09:39 -07:00
Nicholas Nethercote
56dc98b580 Remove unused step_trait feature.
Also sort the features.
2024-05-08 11:00:19 +10:00
bors
a60f077c38 Auto merge of #124683 - estebank:issue-124651, r=compiler-errors
Do not ICE on foreign malformed `diagnostic::on_unimplemented`

Fix #124651.
2024-05-08 00:54:38 +00:00
Michael Goulet
1d9d6715ae Make sure we don't deny macro vars w keyword names 2024-05-07 19:13:33 -04:00
bors
5486f0c1c2 Auto merge of #124223 - Zalathar:conditional-let, r=compiler-errors
coverage: Branch coverage support for let-else and if-let

This PR adds branch coverage instrumentation for let-else and if-let, including let-chains.

This lifts two of the limitations listed at #124118.
2024-05-07 22:28:51 +00:00
Alex Crichton
38b2bd782b rustc: Change wasm32-wasip2 to PIC-by-default
This commit changes the new `wasm32-wasip2` target to being PIC by
default rather than the previous non-PIC by default. This change is
intended to make it easier for the standard library to be used in a
shared object in its precompiled form. This comes with a hypothetical
modest slowdown but it's expected that this is quite minor in most use
cases or otherwise wasm compilers and/or optimizing runtimes can elide
the cost.
2024-05-07 13:26:01 -07:00
bors
faefc618cf Auto merge of #124219 - gurry:122989-ice-unexpected-anon-const, r=compiler-errors
Do not ICE on `AnonConst`s in `diagnostic_hir_wf_check`

Fixes #122989

Below is the snippet from #122989 that ICEs:
```rust
trait Traitor<const N: N<2> = 1, const N: N<2> = N> {
    fn N(&N) -> N<2> {
        M
    }
}

trait N<const N: Traitor<2> = 12> {}
```

The `AnonConst` that triggers the ICE is the `2` in the param `const N: N<2> = 1`. The currently existing code in `diagnostic_hir_wf_check` deals only with `AnonConst`s that are default values of some param, but  the `2` is not a default value. It is just an `AnonConst` HIR node inside a `TraitRef` HIR node corresponding to `N<2>`. Therefore the existing code cannot handle it and this PR ensures that it does.
2024-05-07 20:01:18 +00:00
bors
b923ea4924 Auto merge of #124849 - matthiaskrgr:rollup-68humsk, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #124738 (rustdoc: dedup search form HTML)
 - #124827 (generalize hr alias: avoid unconstrainable infer vars)
 - #124832 (narrow down visibilities in `rustc_parse::lexer`)
 - #124842 (replace another Option<Span> by DUMMY_SP)
 - #124846 (Don't ICE when we cannot eval a const to a valtree in the new solver)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-05-07 17:44:06 +00:00
Matthias Krüger
067f6327a5
Rollup merge of #124846 - compiler-errors:const-eval, r=lcnr
Don't ICE when we cannot eval a const to a valtree in the new solver

Use `const_eval_resolve` instead of `try_const_eval_resolve` because naming aside, the former doesn't ICE when a value can't be evaluated to a valtree.

r? lcnr
2024-05-07 18:12:56 +02:00
Matthias Krüger
a29a7d1551
Rollup merge of #124842 - RalfJung:option-span, r=compiler-errors
replace another Option<Span> by DUMMY_SP

This was missed in https://github.com/rust-lang/rust/pull/122480.
2024-05-07 18:12:56 +02:00
Matthias Krüger
fdeac24c52
Rollup merge of #124832 - linyihai:visibility-of-lexer, r=fmease
narrow down visibilities in `rustc_parse::lexer`

Found something visibility can be narrowed down on `rustc_parse::lexer`.

The mods only used in lexer, so it is ok to limit visibility to `pub(super)`,
see https://github.com/rust-lang/rust/blob/master/compiler/rustc_parse/src/lexer/mod.rs#L22-L25
2024-05-07 18:12:55 +02:00
Matthias Krüger
4a5bf7b06e
Rollup merge of #124827 - lcnr:generalize-incomplete, r=compiler-errors
generalize hr alias: avoid unconstrainable infer vars

fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/108

see inline comments for more details

r? `@compiler-errors` cc `@BoxyUwU`
2024-05-07 18:12:55 +02:00
lcnr
690d5aa417 generalize hr alias: avoid unconstrainable infer vars 2024-05-07 15:58:06 +00:00
Michael Goulet
b58f5a7800 Don't ICE when we cannot eval a const to a valtree in the new solver 2024-05-07 11:14:25 -04:00
bors
0f40f14b61 Auto merge of #123332 - Nadrieril:testkind-never, r=matthewjasper
never patterns: lower never patterns to `Unreachable` in MIR

This lowers a `!` pattern to "goto Unreachable". Ideally I'd like to read from the place to make it clear that the UB is coming from an invalid value, but that's tricky so I'm leaving it for later.

r? `@compiler-errors` how do you feel about a lil bit of MIR lowering
2024-05-07 15:14:20 +00:00
Ralf Jung
1d87efc1da replace another Option<Span> by DUMMY_SP 2024-05-07 14:52:42 +02:00
bors
d71b3f486a Auto merge of #124813 - maurer:llvm-aarch64-fn32, r=nikic
Adjust 64-bit ARM data layouts for LLVM update

LLVM has updated data layouts to specify `Fn32` on 64-bit ARM to avoid C++ accidentally underaligning functions when trying to comply with member function ABIs.

This should only affect Rust in cases where we had a similar bug (I don't believe we have one), but our data layout must match to generate code.

As a compatibility adaptatation, if LLVM is not version 19 yet, `Fn32` gets voided from the data layout.

See llvm/llvm-project#90415

`@rustbot` label: +llvm-main
cc `@krasimirgg`
r? `@durin42`
2024-05-07 03:46:03 +00:00
Lin Yihai
f9bb5df5a0 narrow down visibilities in rustc_parse::lexer 2024-05-07 11:02:28 +08:00
Nicholas Nethercote
351c0fa2a3 Reorder top-level crate items.
- `use` before `mod`
- `pub` before `non-pub`
- Alphabetical order within sections
2024-05-07 10:20:04 +10:00
Nicholas Nethercote
df8fe7dd34 Remove macro_use from stable_hasher.
Normal `use` items are nicer.
2024-05-07 10:19:12 +10:00
Matthias Krüger
284b5530b8
Rollup merge of #124809 - lcnr:prepopulate-opaques, r=compiler-errors
borrowck: prepopulate opaque storage more eagerly

otherwise we ICE due to ambiguity when normalizing while computing implied bounds.

r? ``@compiler-errors``
2024-05-06 21:46:06 +02:00
Matthias Krüger
f76c8f7f77
Rollup merge of #124759 - compiler-errors:impl-args, r=lcnr
Record impl args in the proof tree in new solver

Rather than rematching them during select.

Also use `ImplSource::Param` instead of `ImplSource::Builtin` for alias-bound candidates, so we don't ICE in `Instance::resolve`.

r? lcnr
2024-05-06 21:46:05 +02:00
Michael Goulet
e34723997a Use correct ImplSource for alias bounds 2024-05-06 14:38:35 -04:00
Michael Goulet
2af0871297 Update ena to 0.14.3 2024-05-06 14:32:39 -04:00
Michael Goulet
207b4b8e88 Record impl args in the InsepctCandiate rather than rematching during select 2024-05-06 14:17:22 -04:00
Matthew Maurer
4d397d33da Adjust 64-bit ARM data layouts for LLVM update
LLVM has updated data layouts to specify `Fn32` on 64-bit ARM to avoid
C++ accidentally underaligning functions when trying to comply with
member function ABIs.

This should only affect Rust in cases where we had a similar bug (I
don't believe we have one), but our data layout must match to generate
code.

As a compatibility adaptatation, if LLVM is not version 19 yet, `Fn32`
gets voided from the data layout.

See llvm/llvm-project#90415
2024-05-06 16:53:17 +00:00
Matthias Krüger
ad73b1623d
Rollup merge of #124808 - compiler-errors:super, r=lcnr
Use `super_fold` in `RegionsToStatic` visitor

so as to avoid an infinite stack cycle

fixes #124805
r? lcnr
2024-05-06 18:50:36 +02:00
Matthias Krüger
43de8225dc
Rollup merge of #124771 - compiler-errors:cand-has-failing-wc, r=lcnr
Don't consider candidates with no failing where clauses when refining obligation causes in new solver

Improves error messages when we have param-env candidates that don't deeply unify (i.e. after alias-bounds).

r? lcnr
2024-05-06 18:50:35 +02:00
Matthias Krüger
2d557ba9f4
Rollup merge of #124724 - compiler-errors:prefer-lower, r=lcnr
Prefer lower vtable candidates in select in new solver

Also, adjust the select visitor to only winnow when the *parent* goal is `Certainty::Yes`. This means that we won't winnow in cases when we have any ambiguous inference guidance from two candidates.

r? lcnr
2024-05-06 18:50:35 +02:00
Michael Goulet
116f95bb46 Use super_fold in RegionsToStatic visitor 2024-05-06 12:22:15 -04:00
lcnr
5714c1f364 switch new solver to directly inject opaque types 2024-05-06 16:19:32 +00:00
lcnr
24ee32cf70 borrowck: more eagerly prepopulate opaques 2024-05-06 16:04:57 +00:00
Michael Goulet
4e3350d43b Don't consider candidates with no failing where clauses 2024-05-06 11:32:50 -04:00
lcnr
5f044f3528 BorrowckInferCtxt: infcx by value 2024-05-06 15:20:13 +00:00
Michael Goulet
a4ee20eb13 Prefer lower vtable candidates in select in new solver 2024-05-06 10:48:39 -04:00
beetrees
3769fddba2
Refactor float Primitives to a separate Float type 2024-05-06 14:56:10 +01:00
bors
69f53f5e55 Auto merge of #124679 - Urgau:check-cfg-structured-cli-errors, r=nnethercote
Improve check-cfg CLI errors with more structured diagnostics

This PR improve check-cfg CLI errors with more structured diagnostics.

In particular it now shows the statement where the error occurred, what kind lit it is, as well as pointing users to the doc for more details.

`@rustbot` label +F-check-cfg
2024-05-06 07:46:27 +00:00
Urgau
228496e4f5 Improve check-cfg CLI errors with more structured diagnostics 2024-05-06 07:44:41 +02:00
Urgau
0b418f2b03 Return coherent description for boolean instead of panicking 2024-05-06 07:44:41 +02:00
bors
d287f3e4ee Auto merge of #124784 - matthiaskrgr:rollup-e9pg3v4, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - #124742 (Add `rustfmt` cfg to well known cfgs list)
 - #124765 ([rustdoc] Fix bad color for setting cog in ayu theme)
 - #124768 ([resubmission] Meta: Enable the brand new triagebot transfer command)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-05-06 05:39:09 +00:00
Matthias Krüger
3d97660f40
Rollup merge of #124742 - Urgau:check-cfg-rustfmt, r=fmease
Add `rustfmt` cfg to well known cfgs list

This PR adds the `rustfmt` cfg to the well known cfgs list.

Related to https://github.com/rust-lang/rust/issues/124735
2024-05-06 06:21:03 +02:00
bors
96f1da8268 Auto merge of #124638 - nnethercote:mv-expand-tests, r=compiler-errors
Move some tests from `rustc_expand` to `rustc_parse`.

There are some test cases involving `parse` and `tokenstream` and `mut_visit` that are located in `rustc_expand`. Because it used to be the case that constructing a `ParseSess` required the involvement of `rustc_expand`. However, since #64197 merged (a long time ago) `rust_expand` no longer needs to be involved.

This commit moves the tests into `rustc_parse`. This is the optimal place for the `parse` tests. It's not ideal for the `tokenstream` and `mut_visit` tests -- they would be better in `rustc_ast` -- but they still rely on parsing, which is not available in `rustc_ast`. But `rustc_parse` is lower down in the crate graph and closer to `rustc_ast` than `rust_expand`, so it's still an improvement for them.

The exact renaming is as follows:

- rustc_expand/src/mut_visit/tests.rs -> rustc_parse/src/parser/mut_visit/tests.rs
- rustc_expand/src/tokenstream/tests.rs -> rustc_parse/src/parser/tokenstream/tests.rs
- rustc_expand/src/tests.rs + rustc_expand/src/parse/tests.rs -> compiler/rustc_parse/src/parser/tests.rs

The latter two test files are combined because there's no need for them to be separate, and having a `rustc_parse::parser::parse` module would be weird. This also means some `pub(crate)`s can be removed.

r? `@compiler-errors`
2024-05-06 03:31:30 +00:00
Zalathar
0c12a3b1d4 coverage: Tidy imports in rustc_mir_transform::coverage 2024-05-06 12:13:31 +10:00
Zalathar
56c6288c6f coverage: Rename CoverageSpans to ExtractedMappings 2024-05-06 12:13:30 +10:00
Zalathar
84cedbec9d coverage: Destructure the mappings struct to make sure we don't miss any 2024-05-06 12:13:30 +10:00
Zalathar
83852d9bf3 coverage: Don't recompute the number of test vector bitmap bytes
The code in `extract_mcdc_mappings` that allocates these bytes already knows
how many are needed in total, so there's no need to immediately recompute that
value in the calling function.
2024-05-06 12:13:30 +10:00
Zalathar
496ae1ee1c coverage: Make the special case for async functions exit early 2024-05-06 12:13:30 +10:00
Zalathar
1a26404f10 coverage: Separately compute the set of BCBs with counter mappings 2024-05-06 12:13:30 +10:00
bors
80420a693f Auto merge of #124747 - MasterAwesome:master, r=davidtwco
Support Result<T, E> across FFI when niche optimization can be used (v2)

This PR is identical to #122253, which was approved and merged but then removed from master by a force-push due to a [CI bug](https://rust-lang.zulipchat.com/#narrow/stream/242791-t-infra/topic/ci.20broken.3F).

r? ghost

Original PR description:

---

Allow allow enums like `Result<T, E>` to be used across FFI if the T/E can be niche optimized and the non-niche-optimized type is FFI safe.

Implementation of https://github.com/rust-lang/rfcs/pull/3391
Tracking issue: https://github.com/rust-lang/rust/issues/110503

Additional ABI and codegen tests were added in https://github.com/rust-lang/rust/pull/115372
2024-05-06 00:55:49 +00:00
Jubilee Young
e0192f48c9 compiler: Privatize Parser::current_closure
This was added as pub in 2021 and remains only privately used in 2024!
2024-05-05 16:56:23 -07:00
Nicholas Nethercote
2acbe9c743 Move some tests from rustc_expand to rustc_parse.
There are some test cases involving `parse` and `tokenstream` and
`mut_visit` that are located in `rustc_expand`. Because it used to be
the case that constructing a `ParseSess` required the involvement of
`rustc_expand`. However, since #64197 merged (a long time ago)
`rust_expand` no longer needs to be involved.

This commit moves the tests into `rustc_parse`. This is the optimal
place for the `parse` tests. It's not ideal for the `tokenstream` and
`mut_visit` tests -- they would be better in `rustc_ast` -- but they
still rely on parsing, which is not available in `rustc_ast`. But
`rustc_parse` is lower down in the crate graph and closer to `rustc_ast`
than `rust_expand`, so it's still an improvement for them.

The exact renaming is as follows:

- rustc_expand/src/mut_visit/tests.rs -> rustc_parse/src/parser/mut_visit/tests.rs
- rustc_expand/src/tokenstream/tests.rs -> rustc_parse/src/parser/tokenstream/tests.rs
- rustc_expand/src/tests.rs + rustc_expand/src/parse/tests.rs ->
  compiler/rustc_parse/src/parser/tests.rs

The latter two test files are combined because there's no need for them
to be separate, and having a `rustc_parse::parser::parse` module would
be weird. This also means some `pub(crate)`s can be removed.
2024-05-06 09:06:02 +10:00
bors
9c9b568792 Auto merge of #124603 - Zalathar:mcdc-mappings, r=Nadrieril
coverage: Split out MC/DC mappings from `BcbMappingKind`

These variants were added to `BcbMappingKind` as part of the [MC/DC coverage](https://en.wikipedia.org/wiki/Modified_Condition/Decision_Coverage) implementation in #123409, because that was the path-of-least-resistance for integrating them into the existing code.

However, they ultimately represent complex concepts that the enum was not intended to handle, leading to more complexity in the code that processes them. This PR therefore follows in the footsteps of #124545, and splits the MC/DC mappings out into their own dedicated vectors of structs.

After that, `BcbMappingKind` itself ends up having only one variant (`Code`), so this PR also flattens that enum into its enclosing struct, renamed to `mapping::CodeMapping`.

---

No functional changes.

This will conflict slightly with #124571, but hopefully that should be easy to resolve either way.

`@rustbot` label +A-code-coverage
2024-05-05 19:23:20 +00:00
Urgau
cd6a0c8c77 Fix insufficient logic when searching for the underlying allocation
in the `invalid_reference_casting` lint, when trying to lint on
bigger memory layout casts.
2024-05-05 19:14:20 +02:00
Mads Marquart
8f0d35769d Refactor Apple target_abi
This was bundled together with `Arch`, which complicated a few code
paths and meant we had to do more string matching than necessary.
2024-05-05 19:09:42 +02:00
bors
7c4ac0603e Auto merge of #124752 - GuillaumeGomez:rollup-a4qagbd, r=GuillaumeGomez
Rollup of 6 pull requests

Successful merges:

 - #124148 (rustdoc-search: search for references)
 - #124668 (Fix bootstrap panic when build from tarball)
 - #124736 (compiler: upgrade time from 0.3.34 to 0.3.36)
 - #124748 (Fix unwinding on 32-bit watchOS ARM (v2))
 - #124749 (Stabilize exclusive_range_pattern (v2))
 - #124750 (Document That `f16` And `f128` Hardware Support is Limited (v2))

r? `@ghost`
`@rustbot` modify labels: rollup
2024-05-05 14:59:34 +00:00
Guillaume Gomez
d3e042dc4e
Rollup merge of #124749 - RossSmyth:stable_range, r=davidtwco
Stabilize exclusive_range_pattern (v2)

This PR is identical to #124459, which was approved and merged but then removed from master by a force-push due to a [CI bug](https://rust-lang.zulipchat.com/#narrow/stream/242791-t-infra/topic/ci.20broken.3F).

r? ghost

Original PR description:

---

Stabilization report: https://github.com/rust-lang/rust/issues/37854#issuecomment-1842398130
FCP: https://github.com/rust-lang/rust/issues/37854#issuecomment-1872520294

Stabilization was blocked by a lint that was merged here: #118879

Documentation PR is here: rust-lang/reference#1484

`@rustbot` label +F-exclusive_range_pattern +T-lang
2024-05-05 16:42:48 +02:00
Guillaume Gomez
3953df53f8
Rollup merge of #124736 - calebsander:feature/upgrade-time, r=dtolnay
compiler: upgrade time from 0.3.34 to 0.3.36

This ensures the version of `time` used in `rustc` includes this change: https://github.com/time-rs/time/pull/671.
This fix is a necessary prerequisite for #99969, which adds `FromIterator` implementations for `Box<str>`. Previously, `time` had an `Into::into` that resolved to the identity impl followed by a `collect::<Result<Box<_>, _>>()`. With the new FromIterator implementations for Box<str>, the Into::into resolution is ambiguous and time fails to compile. Thanks to `@dtolnay` for the analysis in https://github.com/rust-lang/rust/pull/99969#issuecomment-2001422230.
The `time` fix removes the identity `Into::into` conversion, allowing `time` to compile with the new `FromIterator` implementations. This version of `time` also matches what `cargo` recently switched to in https://github.com/rust-lang/cargo/pull/13834.
2024-05-05 16:42:47 +02:00
bors
06e88c306a Auto merge of #123125 - gurry:122561-bad-note-non-zero-loop-iters-2, r=estebank
Remove suggestion about iteration count in coerce

Fixes #122561

The iteration count-centric suggestion was implemented in PR #100094, but it was based on the wrong assumption that the type mismatch error depends on the number of times the loop iterates. As it turns out, that is not true (see this comment for details: https://github.com/rust-lang/rust/pull/122679#issuecomment-2017432531)

This PR attempts to remedy the situation by changing the suggestion from the one centered on iteration count to a simple suggestion to add a return value.

It should also fix #100285 by simply making it redundant.
2024-05-05 12:51:37 +00:00
Urgau
f90b15b7fc Add rustfmt cfg to well known cfgs list 2024-05-05 14:30:35 +02:00
Caleb Sander
43c8e139fd compiler: upgrade time from 0.3.34 to 0.3.36
This ensures the version of time used in rustc includes this change:
https://github.com/time-rs/time/pull/671.
This fix is a necessary prerequisite for #99969,
which adds FromIterator implementations for Box<str>.
Previously, time had an Into::into that resolved to the identity impl
followed by a collect::<Result<Box<_>, _>>().
With the new FromIterator implementations for Box<str>,
the Into::into resolution is ambiguous and time fails to compile.
The fix removes the identity Into::into conversion,
allowing time to compile with the new FromIterator implementations.
This version of time also matches what cargo recently switched to
in https://github.com/rust-lang/cargo/pull/13834.
2024-05-04 21:18:41 -07:00
bors
02f7806ecd Auto merge of #124606 - scottmcm:less-expect, r=cjgillot
Stop `llvm.expect`ing assert terminators

We're putting `llvm.expect` calls before the <https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/enum.TerminatorKind.html#variant.Assert> terminators.

But we don't need them.  One of the arms is always to a panic function that's marked `#[cold]`, which is `cold` <https://llvm.org/docs/LangRef.html#function-attributes> in LLVM, which

> When computing edge weights, basic blocks post-dominated by a cold function call are also considered to be cold; and, thus, given low weight.

So even without us emitting the extra intrinsic call, LLVM knows what to expect for the `br`.  Thus we can save the (small) effort of emitting it and then LLVM optimizing it out.

r? compiler
2024-05-05 01:06:22 +00:00
Matthias Krüger
5d413c111a
Rollup merge of #124720 - RalfJung:interpret-drop, r=compiler-errors
interpret: Drop: always evaluate place

That way we can also avoid dealing with `instantiate_from_frame_and_normalize_erasing_regions`.
2024-05-04 22:27:33 +02:00
Matthias Krüger
07dc4aa837
Rollup merge of #124718 - compiler-errors:record-impl-args, r=lcnr
Record impl args in the proof tree

Weren't recording these since they went through a different infcx method

r? lcnr
2024-05-04 22:27:33 +02:00
Matthias Krüger
79071ee3a9
Rollup merge of #124717 - compiler-errors:do-not-recomment-next-solver, r=lcnr
Implement `do_not_recommend` in the new solver

Put the test into `diagnostic_namespace` test folder even though it's not in the diagnostic namespace, because it should be soon.

r? lcnr
cc `@weiznich`
2024-05-04 22:27:32 +02:00
Matthias Krüger
6ece08f41f
Rollup merge of #124713 - Urgau:check-cfg-update-cargo-diagnostics, r=jieyouxu
Update Cargo specific diagnostics in check-cfg

This PR updates the Cargo specific diagnostics for check-cfg/`unexpected_cfgs` lint.

Specifically it update to new url and use the double-column (instead of one) in the Cargo directive suggestion.

`@rustbot` label +F-check-cfg
cc `@weihanglo`
2024-05-04 22:27:32 +02:00
Matthias Krüger
7fbfd8d770
Rollup merge of #124690 - compiler-errors:only-ambig-if-ambig, r=lcnr
Only consider ambiguous goals when finding best obligation for ambiguities

We don't care about ambiguous goals when reporting true errors, and vice versa for ambiguities.

r? lcnr
2024-05-04 22:27:31 +02:00
Ralf Jung
f0dee6bbe5 some comments or dynamic drop handling 2024-05-04 20:04:01 +02:00
Ralf Jung
86a933a574 interpret: Drop: always evaluate place 2024-05-04 19:59:11 +02:00
Michael Goulet
50338aa59a Record impl args in the proof tree 2024-05-04 12:57:01 -04:00
Michael Goulet
b33599485b Implement do_not_recommend in the new solver 2024-05-04 12:51:10 -04:00
Matthias Krüger
743be1e35e
Rollup merge of #124715 - RalfJung:interpret-noreturn, r=compiler-errors
interpret, miri: uniform treatments of intrinsics/functions with and without return block

A long time ago we didn't have a `dest: &MPlaceTy<'tcx, Self::Provenance>` for diverging functions, and since `dest` is used so often we special-cased these non-returning intrinsics and functions so that we'd have `dest` available everywhere else. But this has changed a while ago, now only the return block `ret` is optional, and there's a convenient `return_to_block` function for dealing with the `None` case.

So there no longer is any reason to treat diverging intrinsics/functions any different from those that do return.
2024-05-04 18:36:38 +02:00
Matthias Krüger
9af1e8ce42
Rollup merge of #124584 - Nilstrieb:entrypointy, r=fee1-dead
Various improvements to entrypoint code

This moves some code around and adds some documentation comments to make it easier to understand what's going on with the entrypoint logic, which is a bit complicated.

The only change in behavior is consolidating the error messages for unix_sigpipe to make the code slightly simpler.
2024-05-04 18:36:37 +02:00
Michael Goulet
6714216eaa Only consider ambiguous goals when finding best obligation for ambiguities 2024-05-04 12:05:36 -04:00
Ralf Jung
8e4466497f interpret, miri: uniform treatments of intrinsics/functions with and without return block 2024-05-04 17:39:29 +02:00
Urgau
dcf6853693 Update Cargo diagnostics in check-cfg 2024-05-04 17:26:15 +02:00
Nadrieril
57e8aebb6c Lower never patterns to Unreachable in mir 2024-05-04 16:30:01 +02:00
Nilstrieb
1572c0dcd7 Various improvements to entrypoint code
This moves some code around and adds some documentation comments to make
it easier to understand what's going on with the entrypoint logic, which
is a bit complicated.

The only change in behavior is consolidating the error messages for
unix_sigpipe to make the code slightly simpler.
2024-05-04 14:48:42 +02:00
Matthias Krüger
81b43b759c
Rollup merge of #124677 - djkoloski:set_fuchsia_frame_pointer, r=tmandry
Set non-leaf frame pointers on Fuchsia targets

This is part of our work to enable shadow call stack sanitization on Fuchsia, see [this Fuchsia issue](https://g-issues.fuchsia.dev/issues/327643884).

r? ``@tmandry``
2024-05-04 12:37:22 +02:00
Matthias Krüger
ceb7b5e70e
Rollup merge of #124293 - oli-obk:miri_intrinsic_fallback_body, r=RalfJung
Let miri and const eval execute intrinsics' fallback bodies

fixes https://github.com/rust-lang/miri/issues/3397

r? ``@RalfJung``
2024-05-04 12:37:22 +02:00
Michael Goulet
a55d30f53c
Rollup merge of #124687 - fee1-dead-contrib:private-clauses, r=compiler-errors
Make `Bounds.clauses` private

Construct it through `Bounds::default()`, then consume the clauses via the method `Bounds::clauses()`.

This helps with effects desugaring where `clauses()` is not only the clauses within the `clauses` field.
2024-05-03 23:34:25 -04:00
Michael Goulet
356b6c70ab
Rollup merge of #124648 - nnethercote:trim-crate-graph, r=jackh726
Trim crate graph

This PR removes some unnecessary `Cargo.toml` entries, and makes some other small related cleanups that I found while looking at this stuff.

r? ```@pnkfelix```
2024-05-03 23:34:22 -04:00
Michael Goulet
9dfd527c6f
Rollup merge of #124480 - Enselic:on-broken-pipe, r=jieyouxu
Change `SIGPIPE` ui from `#[unix_sigpipe = "..."]` to `-Zon-broken-pipe=...`

In the stabilization [attempt](https://github.com/rust-lang/rust/pull/120832) of `#[unix_sigpipe = "sig_dfl"]`, a concern was [raised ](https://github.com/rust-lang/rust/pull/120832#issuecomment-2007394609) related to using a language attribute for the feature: Long term, we want `fn lang_start()` to be definable by any crate, not just libstd. Having a special language attribute in that case becomes awkward.

So as a first step towards the next stabilization attempt, this PR changes the `#[unix_sigpipe = "..."]` attribute to a compiler flag `-Zon-broken-pipe=...` to remove that concern, since now the language is not "contaminated" by this feature.

Another point was [also raised](https://github.com/rust-lang/rust/pull/120832#issuecomment-1987023484), namely that the ui should not leak **how** it does things, but rather what the **end effect** is. The new flag uses the proposed naming. This is of course something that can be iterated on further before stabilization.

Tracking issue: https://github.com/rust-lang/rust/issues/97889
2024-05-03 23:34:22 -04:00
Michael Goulet
e3bf0a13cf
Rollup merge of #124418 - compiler-errors:better-cause, r=lcnr
Use a proof tree visitor to refine the `Obligation` for error reporting in new solver

With the magic of `ProofTreeVisitor`, we can close the gap that we have on `ObligationCause`s being not as descriptive in the new trait solver.

r? lcnr

Needs some work and obviously documentation.
2024-05-03 23:34:21 -04:00
Alex Crichton
400e75494a rustc: Don't pass -fuse-ld=lld on wasm targets
This argument isn't necessary for WebAssembly targets since `wasm-ld` is
the only linker for the targets. Passing it otherwise interferes with
Clang's linker selection on `wasm32-wasip2` so avoid it altogether.
2024-05-03 19:47:15 -07:00
Deadbeef
921e74fa57 Make Bounds.clauses private 2024-05-04 10:20:39 +08:00
Zalathar
6968123c3f coverage: Rename BcbBranchPair to mappings::BranchPair
This makes it consistent with the other mapping structs introduced by this PR.
2024-05-04 11:26:05 +10:00
Zalathar
76d8d01604 coverage: Flatten BcbMappingKind into mappings::CodeMapping
Now that branch and MC/DC mappings have been split out into separate types and
vectors, this enum is no longer needed, since it only represents ordinary
"code" regions.

(We can revisit this decision if we ever add support for other region kinds,
such as skipped regions or expansion regions. But at that point, we might just
add new structs/vectors for those kinds as well.)
2024-05-04 11:26:05 +10:00
Zalathar
cf2d741d40 coverage: Extract helper region_for_span 2024-05-04 11:26:05 +10:00
Zalathar
23b6508181 coverage: Split out MC/DC branches from BcbMappingKind 2024-05-04 11:26:05 +10:00
Zalathar
af33fc85de coverage: Split out MC/DC decisions from BcbMappingKind 2024-05-04 11:26:02 +10:00
bors
09cd00fea4 Auto merge of #124401 - oli-obk:some_hir_cleanups, r=cjgillot
Some hir cleanups

It seemed odd to not put `AnonConst` in the arena, compared with the other types that we did put into an arena. This way we can also give it a `Span` without growing a lot of other HIR data structures because of the extra field.

r? compiler
2024-05-04 00:32:27 +00:00
Alex Crichton
7a77108809 rustc: Change LLVM target for the wasm32-wasip2 Rust target
This commit changes the LLVM target of for the Rust `wasm32-wasip2`
target to `wasm32-wasip2` as well. LLVM does a bit of detection on the
target string to know when to call `wasm-component-ld` vs `wasm-ld` so
otherwise clang is invoking the wrong linker.
2024-05-03 15:57:31 -07:00
Esteban Küber
4847f2249f Do not ICE on foreign malformed diagnostic::on_unimplemented
Fix #124651.
2024-05-03 21:53:19 +00:00
bors
d2d24e395a Auto merge of #123602 - cjgillot:gvn-borrowed, r=oli-obk
Account for immutably borrowed locals in MIR copy-prop and GVN

For the most part, we consider that immutably borrowed `Freeze` locals still fulfill SSA conditions. As the borrow is immutable, any use of the local will have the value given by the single assignment, and there can be no surprise.

This allows copy-prop to merge a non-borrowed local with a borrowed local. We chose to keep copy-classes heads unborrowed, as those may be easier to optimize in later passes.

This also allows to GVN the value behind an immutable borrow. If a SSA local is borrowed, dereferencing that borrow is equivalent to copying the local's value: re-executing the assignment between the borrow and the dereference would be UB.

r? `@ghost` for perf
2024-05-03 21:50:13 +00:00
bors
befabbc9e5 Auto merge of #124675 - matthiaskrgr:rollup-x6n79ua, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #122492 (Implement ptr_as_ref_unchecked)
 - #123815 (Fix cannot usage in time.rs)
 - #124059 (default_alloc_error_hook: explain difference to default __rdl_oom in alloc)
 - #124510 (Add raw identifier in a typo suggestion)
 - #124555 (coverage: Clean up creation of MC/DC condition bitmaps)
 - #124593 (Describe and use CStr literals in CStr and CString docs)
 - #124630 (CI: remove `env-x86_64-apple-tests` YAML anchor)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-05-03 19:46:04 +00:00
David Koloski
063770972a Set non-leaf frame pointers on Fuchsia targets 2024-05-03 19:01:44 +00:00
Matthias Krüger
613bccc4ca
Rollup merge of #124555 - Zalathar:init-coverage, r=nnethercote
coverage: Clean up creation of MC/DC condition bitmaps

This PR improves the code for creating and initializing [MC/DC](https://en.wikipedia.org/wiki/Modified_condition/decision_coverage) condition bitmap variables, as introduced by #123409 and modified by #124255.

- The condition bitmap variables are now created eagerly at the start of per-function codegen, via a new `init_coverage` method in `CoverageInfoBuilderMethods`. This avoids having to retroactively create the bitmaps while doing codegen for an individual coverage statement.
- As a result, we can now create and initialize those bitmaps using existing safe APIs, instead of having to perform our own unsafe call to `llvm::LLVMBuildAlloca`.
- This PR also tweaks the way we count the number of condition bitmaps needed, by tracking the total number of bitmaps needed (max depth + 1), instead of only tracking the maximum depth. This reduces the potential for subtle off-by-one confusion.
2024-05-03 20:33:46 +02:00
Matthias Krüger
bd305e10c2
Rollup merge of #124510 - linyihai:raw-ident-in-typo-suggestion, r=fmease
Add raw identifier in a typo suggestion

Fixes #68962
2024-05-03 20:33:45 +02:00
bors
0d7b2fb797 Auto merge of #123441 - saethlin:fixed-len-file-names, r=oli-obk
Stabilize the size of incr comp object file names

The current implementation does not produce stable-length paths, and we create the paths in a way that makes our allocation behavior is nondeterministic. I think `@eddyb` fixed a number of other cases like this in the past, and this PR fixes another one. Whether that actually matters I have no idea, but we still have bimodal behavior in rustc-perf and the non-uniformity in `find` and `ls` was bothering me.

I've also removed the truncation of the mangled CGU names. Before this PR incr comp paths look like this:
```
target/debug/incremental/scratch-38izrrq90cex7/s-gux6gz0ow8-1ph76gg-ewe1xj434l26w9up5bedsojpd/261xgo1oqnd90ry5.o
```
And after, they look like this:
```
target/debug/incremental/scratch-035omutqbfkbw/s-gux6borni0-16r3v1j-6n64tmwqzchtgqzwwim5amuga/55v2re42sztc8je9bva6g8ft3.o
```

On the one hand, I'm sure this will break some people's builds because they're on Windows and only a few bytes from the path length limit. But if we're that seriously worried about the length of our file names, I have some other ideas on how to make them smaller. And last time I deleted some hash truncations from the compiler, there was a huge drop in the number if incremental compilation ICEs that were reported: https://github.com/rust-lang/rust/pull/110367https://github.com/rust-lang/rust/pull/110367

---

Upon further reading, this PR actually fixes a bug. This comment says the CGU names are supposed to be a fixed-length hash, and before this PR they aren't: ca7d34efa9/compiler/rustc_monomorphize/src/partitioning.rs (L445-L448)
2024-05-03 17:41:48 +00:00
Matthias Krüger
08d9992812
Rollup merge of #124588 - compiler-errors:ocx, r=lcnr
Use `ObligationCtxt` in favor of `TraitEngine` in many more places

r? lcnr
2024-05-03 15:26:10 +02:00
Matthias Krüger
eaca729e0b
Rollup merge of #124492 - Strophox:adjust-allocbytes, r=RalfJung
Generalize `adjust_from_tcx` for `Allocation`

Previously, `adjust_from_tcx` would take an `Allocation` and "adjust allocation from the ones in `tcx` to a custom Machine instance [...]".
This PR generalizes this so the Machine instance can also determine the `Bytes` type of the output `Allocation`.

r? `@RalfJung`
2024-05-03 15:26:09 +02:00
Strophox
38181cba79 remove trait bounds on AllocBytes 2024-05-03 15:00:37 +02:00
Strophox
235770c851 Cow::from(&*...) changed to Cow::Owned(Vec::from(...)) 2024-05-03 13:47:16 +02:00
Strophox
47e2cc2ea1 generalize adjust_from_tcx 2024-05-03 13:47:16 +02:00
Oli Scherer
821d23b329 Ensure miri only uses fallback bodies that have manually been vetted to preserve all UB that the native intrinsic would have 2024-05-03 09:16:57 +00:00
Oli Scherer
351658ae66 Let miri and const eval execute intrinsics' fallback bodies 2024-05-03 09:01:12 +00:00
Nicholas Nethercote
a503893567 Fix Cargo.toml whitespace. 2024-05-03 16:03:17 +10:00
Nicholas Nethercote
a74a272a5b Use parse renaming of rustc_parse_format.
This is a case where `rustc_parse_format` is renamed as `parse` but a
couple of places don't take advantage.
2024-05-03 16:03:15 +10:00
Nicholas Nethercote
1ad91bb1eb Remove some low-value use renamings.
There are a few common abbreviations like `use rustc_ast as ast` and
`use rust_hir as hir` for names that are used a lot. But there are also
some cases where a crate is renamed just once in the whole codebase, and
that ends up making things harder to read rather than easier. This
commit removes them.
2024-05-03 16:03:12 +10:00
Nicholas Nethercote
9b3ef5404c Remove some unneeded Cargo.toml dependencies.
I found these with a hacky shell script.
2024-05-03 15:33:52 +10:00
Matthias Krüger
e6c82d9b59
Rollup merge of #124637 - fmease:ast-pretty-ty-asc-builtin-syn, r=compiler-errors
AST pretty: Use `builtin_syntax` for type ascription

Follow-up to #122806.
CC #124619.
2024-05-03 06:04:24 +02:00
Matthias Krüger
a9edd38d18
Rollup merge of #124610 - nnethercote:typenum, r=lcnr
Tweak `consts_may_unify`

r? ````@lcnr````
2024-05-03 06:04:22 +02:00
Michael Goulet
92861517aa Take ocx by move for pending obligations 2024-05-02 22:03:01 -04:00
Michael Goulet
d9eb5232b6 Use ObligationCtxt in favor of TraitEngine in many places 2024-05-02 22:03:01 -04:00
Michael Goulet
34e91ece90 Higher ranked goal source, do overflow handling less badly 2024-05-02 21:56:14 -04:00
Michael Goulet
3e03b1b190 Use a proof tree visitor to refine the Obligation for error reporting 2024-05-02 21:56:14 -04:00
Michael Goulet
382d0f73ad Record more kinds of things as impl where bounds 2024-05-02 21:56:14 -04:00
Michael Goulet
6e3808e274 Store goal source in InspectGoal 2024-05-02 21:56:14 -04:00
Michael Goulet
837bde11a2 Record certainty before evaluating nesteds, so we make candidates 2024-05-02 21:56:14 -04:00
Ross Smyth
6967d1c0fc Stabilize exclusive_range 2024-05-02 19:42:31 -04:00
León Orell Valerian Liehr
3a3df3e638
AST pretty: Use builtin_syntax for type ascription 2024-05-03 01:10:22 +02:00
Nicholas Nethercote
3a3a15d753 Refactor Frame.
It is currently an enum and the `tts` and `idx` fields are repeated
across the two variants.

This commit splits it into a struct `Frame` and an enum `FrameKind`, to
factor out the duplication. The commit also renames `Frame::new` as
`Frame::new_delimited` and adds `Frame::new_sequence`. I.e. both
variants now have a constructor.
2024-05-03 09:06:26 +10:00
Nicholas Nethercote
5ac017e772 Type annotate repeats.
Because the type is not obvious, and this clarifies things.
2024-05-03 09:06:26 +10:00
Nicholas Nethercote
ae7e32880a Introduce Invocation::span_mut.
Alongside the existing `Invocation::span`.
2024-05-03 09:06:26 +10:00
Nicholas Nethercote
1c15b6ae9c Replace a hard-to-read line.
Too clever by half, IMO.
2024-05-03 09:06:26 +10:00
Nicholas Nethercote
3b6978196d Tweak fully_expand_fragment loop.
Control flow never gets past the end of the `ExpandResult::Retry` match
arm, due to the `span_bug` and the `continue`. Therefore, the code after
the match can only be reached from the `ExpandResult::Ready` arm.

This commit moves that code after the match into the
`ExpandResult::Ready` arm, avoiding the need for the `continue` in the
`ExpandResult::Retry` arm.
2024-05-03 09:06:26 +10:00
Nicholas Nethercote
79c4d0202f Remove unnecessary pubs. 2024-05-03 09:06:26 +10:00
Nicholas Nethercote
c9c964fc37 Fix some comment formatting. 2024-05-03 09:06:26 +10:00
Nicholas Nethercote
d7f5319b6d Inline and remove three DummyResult methods.
They each have a single call site.
2024-05-03 09:06:26 +10:00
Nicholas Nethercote
e809df6ed4 Remove unnecessary re-export of MacroKind. 2024-05-03 09:06:25 +10:00
Nicholas Nethercote
189a8a6925 De-pub some rustc_expand modules. 2024-05-03 09:06:25 +10:00
Nicholas Nethercote
3f055893b4 Remove unused ExpCtxt methods. 2024-05-03 09:06:25 +10:00
Nicholas Nethercote
7c6d36345f Remove an unnecessary #[macro_use]. 2024-05-03 09:06:25 +10:00
Nicholas Nethercote
d817856978 Remove an unnecessary re-export of rustc_span::hygiene. 2024-05-03 09:06:25 +10:00
Nicholas Nethercote
aabb90d254 rustc_expand: clean up attributes.
Sort them, and remove the unused ones (`lint_reasons` and
`proc_macro_span`).
2024-05-03 09:06:23 +10:00
Nicholas Nethercote
3722eb0b8f Tweak consts_may_unify.
`ConstKind::Value` is the only variant where control flow leaves the
first match on `impl_ct.kind()`, so there is no need for a second match
on the same expression later on.
2024-05-03 08:07:48 +10:00
Martin Nordholts
cde0cde151 Change SIGPIPE ui from #[unix_sigpipe = "..."] to -Zon-broken-pipe=...
In the stabilization attempt of `#[unix_sigpipe = "sig_dfl"]`, a concern
was raised related to using a language attribute for the feature: Long
term, we want `fn lang_start()` to be definable by any crate, not just
libstd. Having a special language attribute in that case becomes
awkward.

So as a first step towards towards the next stabilization attempt, this
PR changes the `#[unix_sigpipe = "..."]` attribute to a compiler flag
`-Zon-broken-pipe=...` to remove that concern, since now the language
is not "contaminated" by this feature.

Another point was also raised, namely that the ui should not leak
**how** it does things, but rather what the **end effect** is. The new
flag uses the proposed naming. This is of course something that can be
iterated on further before stabilization.
2024-05-02 19:48:29 +02:00
Matthias Krüger
a248411a97
Rollup merge of #124627 - RalfJung:interpret-doc-no-inline, r=fmease
interpret: hide some reexports in rustdoc

Cc https://github.com/rust-lang/rust/issues/124608
2024-05-02 19:42:50 +02:00
Matthias Krüger
d6940fb43d
Rollup merge of #124624 - WaffleLapkin:old_unit, r=fmease
Use `tcx.types.unit` instead of `Ty::new_unit(tcx)`

I don't think there is any need for the function, given that we can just access the `.types`, similarly to all other primitives?
2024-05-02 19:42:50 +02:00
Matthias Krüger
fe62bc5ea5
Rollup merge of #124623 - lcnr:coherence-uwu, r=compiler-errors
shallow resolve in orphan check

r? ``@compiler-errors`` cc https://github.com/rust-lang/rust/pull/124588#pullrequestreview-2036012292
2024-05-02 19:42:49 +02:00
Matthias Krüger
490c0d60f8
Rollup merge of #124579 - RalfJung:align-bytes-usize, r=fmease
Align: add bytes_usize and bits_usize

This matches `Size::bytes/bits_usize`. I recently wanted this in Miri as well.
2024-05-02 19:42:48 +02:00
Matthias Krüger
e9e2ebb051
Rollup merge of #124414 - lqd:subdiagnostics, r=davidtwco
remove extraneous note on `UnableToRunDsymutil` diagnostic

If I understand [this FIXME](1367827eac/compiler/rustc_macros/src/diagnostics/diagnostic.rs (L205)) correctly, it seems we don't yet validate subdiagnostics, so `#[note]` and co in the `#[derive(Diagnostic]` item could be out-of-sync with the fluent message, without causing compile errors.

It was the case for `rustc_codegen_ssa::errors::UnableToRunDsymutil`, causing the ICE in #124392.

I've grepped and scripted my way through most of our diagnostics structs and fluent bundles and the above was the only such extraneous `#[note]`/`#[note(name)]`/`#[help]`/`#[warning]` I could find, so hopefully there aren't many others like it.

I haven't checked if the opposite can happen, a `.note = ` in a fluent message that is lacking a corresponding `#[note]` on the struct and not causing an error, but maybe it's possible?

r? ``@davidtwco``
fixes #124392
2024-05-02 19:42:48 +02:00
Ralf Jung
dba1849c22 interpret: hide some reexports in rustdoc 2024-05-02 18:47:36 +02:00
Waffle Lapkin
698d7a031e Inline & delete Ty::new_unit, since it's just a field access 2024-05-02 17:49:23 +02:00
lcnr
c4e882fd99 shallow resolve in orphan check 2024-05-02 15:44:05 +00:00
Guillaume Gomez
871f047c4c
Rollup merge of #124582 - RalfJung:std-not-found, r=Nilstrieb
always print nice 'std not found' error when std is not found

Fixes https://github.com/rust-lang/miri/issues/3529

Arguably Miri is doing something odd by letting people create no-std sysroots for arbitrary targets -- but equally arguably, there's no good reason for rustc to special-case the host triple here. Being a non-host triple does not imply the target is a no-std target, after all.
2024-05-02 15:11:22 +02:00
Guillaume Gomez
df9f8d0153
Rollup merge of #124568 - Urgau:non-local-defs-doctest, r=michaelwoerister,GuillaumeGomez
Adjust `#[macro_export]`/doctest help suggestion for non_local_defs lint

This PR adjust the help suggestion of the `non_local_definitions` lint when encountering a `#[macro_export]` at top-level doctest.

So instead of a non-sentential help suggestion to move the `macro_rules!` up above the `rustdoc`-generated function. We now suggest users to declare their own function.

Fixes *(partially, needs backport)* #124534
2024-05-02 15:11:22 +02:00
bors
f5efc3c286 Auto merge of #124521 - Mark-Simulacrum:bootstrap-bump, r=albertlarsan68
Bump bootstrap compiler to latest beta

https://forge.rust-lang.org/release/process.html#master-bootstrap-update-t-2-day-tuesday

This also cherry-picks d716d72586548963f32e5c8d57c41db0065fa6e0 from the beta branching, to continue to workaround #122758.

r? bootstrap
2024-05-02 09:21:43 +00:00
Scott McMurray
c04b95512d Stop llvm.expecting assert terminators 2024-05-01 23:14:13 -07:00
bors
fcc06c894b Auto merge of #123939 - WaffleLapkin:never-fallback-unsafe-lint, r=compiler-errors
Add a lint against never type fallback affecting unsafe code

~~I'm not very happy with the code quality... `VecGraph` not allowing you to get predecessors is very annoying. This should work though, so there is that.~~ (ended up updating `VecGraph` to support getting predecessors)

~~First few commits are from https://github.com/rust-lang/rust/pull/123934 https://github.com/rust-lang/rust/pull/123980~~
2024-05-02 02:41:40 +00:00
Mark Rousskov
a64f941611 Step bootstrap cfgs 2024-05-01 22:19:11 -04:00
Waffle Lapkin
b5626172d1 Split hir_typeck_never_type_fallback_flowing_into_unsafe into 5 slugs 2024-05-02 03:49:49 +02:00
Waffle Lapkin
0df43db50c Add proper support for all kinds of unsafe ops to the lint
(never_type_fallback_flowing_into_unsafe)
2024-05-02 03:49:49 +02:00
Waffle Lapkin
3c815a644c Add UnordMap::try_insert 2024-05-02 03:49:46 +02:00
Waffle Lapkin
fe9c5e6510 Reorganize uses 2024-05-02 03:47:32 +02:00
Maybe Waffle
b63cb6fd81 Add an explanation about never type fallback 2024-05-02 03:47:32 +02:00
Maybe Waffle
aa0a916c81 Add a lint against never type fallback affecting unsafe code 2024-05-02 03:47:32 +02:00
Maybe Waffle
ff0bfea45f Convert if to match 2024-05-02 03:47:32 +02:00
Mark Rousskov
43f9a5ec0c Mark more entries in rustc_data_structures as no_inline for docs
This is a workaround for #122758, but it's not clear why 1.79 requires a
more extensive amount of no_inline than the previous release. Seems like
there's something relatively subtle happening here.
2024-05-01 21:01:51 -04:00
Mark Rousskov
bd7d328807 Replace version placeholders for 1.79 2024-05-01 21:01:51 -04:00
bors
f92d49b7fe Auto merge of #124529 - compiler-errors:select, r=lcnr
Rewrite select (in the new solver) to use a `ProofTreeVisitor`

We can use a proof tree visitor rather than collecting and recomputing all the nested goals ourselves.

Based on #124415
2024-05-02 00:36:38 +00:00
Michael Goulet
9834c8307f Rewrite select to use a ProofTreeVisitor 2024-05-01 14:19:34 -04:00
Matthias Krüger
0dbe07f201
Rollup merge of #124566 - lcnr:normalizes-to-proof-tree, r=compiler-errors
fix `NormalizesTo` proof tree issue

fixes #124422
cc #121848

r? ``@compiler-errors``
2024-05-01 20:05:26 +02:00
Matthias Krüger
38cbad9d26
Rollup merge of #124542 - CBSpeir:diagnostic-item-enumerate-method, r=scottmcm
Add diagnostic item for `std::iter::Iterator::enumerate`

Adds a diagnostic item for the `std::iter:Iterator::enumerate` trait method. This change, along with PR https://github.com/rust-lang/rust/pull/124308, will be used by the clippy `unused_enumerate_index` lint to move away from paths to using diagnostic items.

see: https://github.com/rust-lang/rust-clippy/issues/5393
2024-05-01 20:05:26 +02:00
Ralf Jung
6115cf6f41 always print nice 'std not found error' when std is not found 2024-05-01 17:11:49 +02:00
lcnr
f323f9dedb review 2024-05-01 15:03:15 +00:00
Urgau
712560cd03 Adjust #[macro_export]/doctest help suggestion for non_local_defs lint 2024-05-01 16:57:20 +02:00
Ralf Jung
65d74785d7 Align: add bytes_usize and bits_usize 2024-05-01 15:57:33 +02:00
bors
378a43a065 Auto merge of #124539 - Urgau:non-local-defs_modulo_modules, r=lcnr
Consider inner modules to be local in the `non_local_definitions` lint

This PR implements the [proposed fix](https://github.com/rust-lang/rust/issues/124396#issuecomment-2079553642) for #124396, that is to consider inner modules to be local in the `non_local_definitions` lint.

This PR is voluntarily kept as minimal as possible so it can be backported easily.

T-lang [nomination](https://github.com/rust-lang/rust/issues/124396#issuecomment-2079692820) will need to be removed before this can be merged.

Fixes *(nearly, needs backport)* https://github.com/rust-lang/rust/issues/124396
2024-05-01 06:21:31 +00:00
Gurinder Singh
0c71c9d74b Handle normalization failure in struct_tail_erasing_lifetimes
Fixes an ICE that occurred when the struct in question has an error
2024-05-01 09:29:33 +05:30
bors
f5355b93ba Auto merge of #124356 - fmease:fewer-magic-numbers-in-names, r=lcnr
Cleanup: Replace item names referencing GitHub issues or error codes with something more meaningful

**lcnr** in https://github.com/rust-lang/rust/pull/117164#pullrequestreview-1969935387:

> […] while I know that there's precendent to name things `Issue69420`, I really dislike this as it requires looking up the issue to figure out the purpose of such a variant. Actually referring to the underlying issue, e.g. `AliasMayNormToUncovered` or whatever and then linking to the issue in a doc comment feels a lot more desirable to me. We should ideally rename all the functions and enums which currently use issue numbers.

I've grepped through `compiler/` like crazy and think that I've found all instances of this pattern.
However, I haven't renamed `compute_2229_migrations_*`. Should I?

The first commit introduces an abhorrent and super long name for an item because naming is hard but also scary looking / unwelcoming names are good for things related to temporary-ish backcompat hacks. I'll let you discover it by yourself.

Contains a bit of drive-by cleanup and a diag migration bc that was the simplest option.

r? lcnr or compiler
2024-05-01 00:04:36 +00:00
Zalathar
de972b7321 coverage: Replace max_decision_depth with num_condition_bitmaps
This clearly distinguishes individual decision-depth indices from the total
number of condition bitmaps to allocate.
2024-05-01 09:55:22 +10:00
Zalathar
0b3a47900e coverage: Set up MC/DC bitmaps without additional unsafe code
Because this now always takes place at the start of the function, we can just
use the normal `alloca` method and then initialize each bitmap immediately.

This patch also moves bitmap setup out of the `mcdc_parameters` method, because
there is no longer any particular reason for it to be there.
2024-05-01 09:55:22 +10:00
Zalathar
52d608b560 coverage: Eagerly do start-of-function codegen for coverage 2024-05-01 09:06:53 +10:00
bors
f705de5962 Auto merge of #117164 - fmease:orphan-norm, r=lcnr
Lazily normalize inside trait ref during orphan check & consider ty params in rigid alias types to be uncovered

Fixes #99554, fixes rust-lang/types-team#104.
Fixes #114061.

Supersedes #100555.

Tracking issue for the future compatibility lint: #124559.

r? lcnr
2024-04-30 20:51:46 +00:00
León Orell Valerian Liehr
2a1d748254
Replace item names containing an error code with something more meaningful
or inline such functions if useless.
2024-04-30 22:27:19 +02:00
León Orell Valerian Liehr
dec1d16a9b
Give an item related to issue 27438 a more meaningful name 2024-04-30 22:27:19 +02:00
León Orell Valerian Liehr
9e739b723b
Give items related to issue 33140 a more meaningful name 2024-04-30 22:27:19 +02:00
lcnr
da969d41a3 fix NormalizesTo proof tree issue 2024-04-30 20:03:33 +00:00
León Orell Valerian Liehr
951e902562
Normalize trait ref before orphan check & consider ty params in alias types to be uncovered 2024-04-30 21:54:54 +02:00
bors
20aa2d81e3 Auto merge of #124558 - matthiaskrgr:rollup-axi1bxu, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - #123247 (Mention Both HRTB and Generic Lifetime Param in `E0637` documentation)
 - #124511 (Remove many `#[macro_use] extern crate foo` items)
 - #124550 (Remove redundant union check in `KnownPanicsLint` const prop)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-04-30 13:13:54 +00:00
Matthias Krüger
5a4e83c2e0
Rollup merge of #124550 - gurry:remove-redundant-code, r=oli-obk
Remove redundant union check in `KnownPanicsLint` const prop

Removes the below check which prevents unions from being const propagated:f9dca46218/compiler/rustc_mir_transform/src/known_panics_lint.rs (L587-L594)

It is not needed because after PR #124504 we mark unions as `NoPropagation` over here: f9dca46218/compiler/rustc_mir_transform/src/known_panics_lint.rs (L899-L902) which is enough to prevent them from being const propagated.
2024-04-30 15:04:09 +02:00
Matthias Krüger
784316eadc
Rollup merge of #124511 - nnethercote:rm-extern-crates, r=fee1-dead
Remove many `#[macro_use] extern crate foo` items

This requires the addition of more `use` items, which often make the code more verbose. But they also make the code easier to read, because `#[macro_use]` obscures where macros are defined.

r? `@fee1-dead`
2024-04-30 15:04:08 +02:00
Matthias Krüger
7427812261
Rollup merge of #123247 - veera-sivarajan:fix-error-code-E0637-example-code, r=fmease
Mention Both HRTB and Generic Lifetime Param in `E0637` documentation

The compiler (rustc 1.77.0) error for `and_without_explicit_lifetime()` in the erroneous code example suggests using a HRTB. But, the corrected example uses an explicit lifetime parameter.

This PR fixes it so that the documentation and the compiler suggestion for error code `E0637` are consistent with each other.
2024-04-30 15:04:08 +02:00
Zalathar
7c87ad0430 coverage: Add branch coverage support for if-let and let-chains 2024-04-30 22:35:55 +10:00
Zalathar
c9dd07dd5e coverage: Add branch coverage support for let-else 2024-04-30 22:35:54 +10:00
bors
a7431167e0 Auto merge of #124545 - Zalathar:mappings, r=oli-obk
coverage: Split off `mappings.rs` from `spans.rs` and `from_mir.rs`

Originally, `spans.rs` was mainly concerned with extracting and post-processing spans from MIR, so that they could be used for block coverage instrumentation.

Over time it has organically expanded to include more responsibilities, especially relating to branch coverage and MC/DC coverage, that don't really fit its current name.

This PR therefore takes all the extra code that is *not* part of the old span-refinement engine, and moves it out into a new `mappings.rs` file.

---

No functional changes. I have deliberately avoided doing any follow-up (such as renaming types or functions), because this particular change is very rot-prone, and I want it to be as simple and self-contained as possible.

`@rustbot` label +A-code-coverage
2024-04-30 11:08:12 +00:00
Gurinder Singh
741d40f327 Remove redundant union check in `KnownPanicsLint const prop
because we are already marking unions `NoPropagation` in
`CanConstProp::check()`. That is enough to prevent any attempts
at const propagating unions and this second check is not needed.

Also improve a comment in `CanConstProp::check()`
2024-04-30 15:17:47 +05:30
bors
47314eb427 Auto merge of #124399 - ZhuUx:split-mcdc, r=Zalathar
Split mcdc code to a sub module of coverageinfo

A further work from #124217 . I have made relatively large changes when working on #124278 so that it would better split them from `coverageinfo.rs` to avoid potential troubling merge work with improved branch coverage by `@Zalathar` .

Besides `BlockMarkerGenerator` is added to avoid ownership problems (mostly needed for following change of #124278 )

All code changes are done in [a37d737a](a3d737a086) while the second commit just renames the file.

cc `@RenjiSann` `@Zalathar`
This will impact your current work.
2024-04-30 09:03:56 +00:00
Gurinder Singh
6289ed8428 Remove note about iteration count in coerce
and replace it with a simple note suggesting
returning a value.

The type mismatch error was never due to
how many times the loop iterates. It is more
because of the peculiar structure of what the for
loop desugars to. So the note talking about
iteration count didn't make sense
2024-04-30 12:46:59 +05:30
Nicholas Nethercote
2088de2889 Remove extern crate scoped_tls from stable_mir. 2024-04-30 16:47:49 +10:00
Nicholas Nethercote
6341935a13 Remove extern crate tracing from numerous crates. 2024-04-30 16:47:49 +10:00
bors
f973a15a10 Auto merge of #124547 - matthiaskrgr:rollup-9tv8upg, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #124519 (adapt a codegen test for llvm 19)
 - #124524 (Add StaticForeignItem and use it on ForeignItemKind)
 - #124540 (Give proof tree visitors the ability to instantiate nested goals directly)
 - #124543 (codegen tests: Tolerate `range()` qualifications in enum tests)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-04-30 04:52:01 +00:00
Matthias Krüger
ed00f668ac
Rollup merge of #124540 - compiler-errors:nested-goals, r=lcnr
Give proof tree visitors the ability to instantiate nested goals directly

Useful when we want to look at the nested goals but not necessarily visit them (e.g. in select).

r? lcnr
2024-04-30 06:43:43 +02:00
Matthias Krüger
ea3d99eaa8
Rollup merge of #124524 - spastorino:make-foreign-static-use-struct, r=oli-obk
Add StaticForeignItem and use it on ForeignItemKind

This is in preparation for unsafe extern blocks that adds a safe variant for functions inside extern blocks.

r? `@oli-obk`
cc `@compiler-errors`
2024-04-30 06:43:42 +02:00
zhuyunxing
6c8b492f02 coverage. Split mcdc builder to a sub module of coverageinfo 2024-04-30 12:17:35 +08:00
zhuyunxing
e198c51f16 coverage. Add MCDCInfoBuilder to isolate all mcdc stuff from BranchInfoBuilder 2024-04-30 12:17:25 +08:00
zhuyunxing
a76e250abd coverage. Add BlockMarkerGen to avoid ownership gymnastics 2024-04-30 11:19:23 +08:00
Zalathar
ba87e5bb3e coverage: Split off mappings.rs from spans.rs and from_mir.rs 2024-04-30 13:17:21 +10:00
Zalathar
7d1c6af3dc coverage: Prepare to split spans.rs into two files 2024-04-30 13:16:58 +10:00
bors
f9dca46218 Auto merge of #124507 - Zalathar:coverage-level, r=compiler-errors
coverage: Replace boolean options with a `CoverageLevel` enum

After #123409, and some discussion at https://github.com/rust-lang/rust/issues/79649#issuecomment-2042093553 and #124120, it became clear to me that we should have a unified concept of “coverage level”, instead of having several separate boolean flags that aren't actually independent.

This PR therefore introduces a `CoverageLevel` enum, to replace the existing boolean flags for `branch` and `mcdc`.

The `no-branch` value (for `-Zcoverage-options`) has been renamed to `block`, instructing the compiler to only instrument for block coverage, with no branch coverage or MD/DC instrumentation.

`@rustbot` label +A-code-coverage
cc `@ZhuUx` `@Lambdaris` `@RenjiSann`
2024-04-30 02:47:25 +00:00
bors
74a8df6c65 Auto merge of #124398 - klensy:trailing-ws, r=compiler-errors
tests: remove some trailing ws

Cleans one more case of trailing whitespace in tests.
2024-04-30 00:42:32 +00:00
Christopher B. Speir
c8079e9390 Add diagnostic item for std::iter::Iterator::enumerate 2024-04-29 17:36:31 -05:00
Michael Goulet
7597d1504e Split out instantiate_nested_goals 2024-04-29 17:06:34 -04:00
Michael Goulet
13825dcc15 Take proof trees by value in inspect goal 2024-04-29 17:06:34 -04:00
Urgau
21c688af86 Consider inner modules to be local in the non_local_definitions lint 2024-04-29 22:54:04 +02:00
Matthias Krüger
42ab090be9
Rollup merge of #124488 - est31:arbitrary_expressions_error, r=pnkfelix
Add a note to the ArbitraryExpressionInPattern error

The current "arbitrary expressions aren't allowed in patterns" error is confusing, as it fires for code where it *looks* like a pattern but the compiler still treats it as an expression. That this is due to the `:expr` fragment specifier forcing the expression-ness property on the code.

In the test suite, the "arbitrary expressions aren't allowed in patterns" error can only be found in combination with macro_rules macros that force expression-ness of their content, namely via `:expr` metavariables. I also can't come up with cases where there would be an expression instead of a pattern, so I think it's always coming from an `:expr`.

In order to make the error less confusing, this adds a note explaining the weird `:expr` fragment behaviour.

Fixes #99380
2024-04-29 22:37:51 +02:00
Matthias Krüger
6ce9708ce5
Rollup merge of #124185 - beepster4096:move_data_base_local_infallible, r=pnkfelix
Remove optionality from MoveData::base_local

This is an artifact from when Places could be based on statics and not just locals. Now, all move paths either are locals or have parents, so this doesn't need to return Option anymore.
2024-04-29 22:37:50 +02:00
许杰友 Jieyou Xu (Joe)
ebce31a053
Rollup merge of #124522 - blyxyas:refactor-is-loaded, r=jieyouxu
[Refactor] Rename `Lint` and `LintGroup`'s `is_loaded` to `is_externally_loaded`

The field being named `is_loaded` was very confusing. Turns out it's true for lints that are registered by external tools like Clippy (I had to look at https://github.com/rust-lang/rust/pull/116412 to know what the variable meant). So I renamed `is_loaded` to `is_externally_loaded` and added some docs.
2024-04-29 18:03:25 +01:00
许杰友 Jieyou Xu (Joe)
0797adb327
Rollup merge of #124508 - Zalathar:op, r=jieyouxu
coverage: Avoid hard-coded values when visiting logical ops

This is a tiny little thing that I noticed during the final review of #123409, and I didn't want to hold up the whole PR just for this.

Instead of separately hard-coding the operation being visited, we can get it from the match arm pattern by using an as-pattern.

`@rustbot` label +A-code-coverage
2024-04-29 18:03:25 +01:00
许杰友 Jieyou Xu (Joe)
43265f5721
Rollup merge of #124504 - gurry:123710-union-ICE, r=oli-obk
Mark unions non-const-propagatable in `KnownPanicsLint` without calling layout

Fixes #123710

The ICE occurs during the layout calculation of the union `InvalidTag` in #123710 because the following assert fails:5fe8b697e7/compiler/rustc_abi/src/layout.rs (L289-L292)

The layout calculation is invoked by `KnownPanicsLint` when it is trying to figure out which locals it can const prop. Since `KnownPanicsLint` is never actually going to const props unions thanks to PR https://github.com/rust-lang/rust/pull/121628 there's no point calling layout to check if it can. So in this fix I skip the call to layout and just mark the local non-const propagatable if it is a union.
2024-04-29 18:03:24 +01:00
许杰友 Jieyou Xu (Joe)
0580588ec6
Rollup merge of #124484 - GKFX:offset_of_must_use, r=jieyouxu
Fix #124478 - offset_of! returns a temporary

This was due to the must_use() call. Adding HIR's `OffsetOf` to the must_use checking within the compiler avoids this issue while maintaining the lint output.

Fixes #124478. `@tgross35`
2024-04-29 18:03:24 +01:00
许杰友 Jieyou Xu (Joe)
4355749b16
Rollup merge of #124415 - compiler-errors:candidates, r=lcnr
Use probes more aggressively in new solver

....so that we have the right candidate information when assembling trait and normalizes-to goals.

Also gets rid of misc probes.

r? lcnr
2024-04-29 18:03:23 +01:00
许杰友 Jieyou Xu (Joe)
f1c53da1cf
Rollup merge of #124269 - scrabsha:sasha/fix-124206, r=dtolnay
Pretty-print parenthesis around binary in postfix match

Fixes #124206.
2024-04-29 18:03:22 +01:00
Santiago Pastorino
f06e0f7837
Add StaticForeignItem and use it on ForeignItemKind 2024-04-29 13:15:51 -03:00
Michael Goulet
2eb7c8196b Only register candidate if it is associated w a shallow certainty 2024-04-29 10:25:51 -04:00
Michael Goulet
7cf1c547c2 Actually use probes when needed and stop relying on existing outer probes 2024-04-29 10:25:51 -04:00
Michael Goulet
5776aec662 Make names more accurate 2024-04-29 10:25:05 -04:00
blyxyas
d31b7db8e4 [Refactor] Rename Lint and LintGroup\'s is_loaded to is_externally_loaded 2024-04-29 15:57:09 +02:00
est31
c6e946d0f0 Change wording 2024-04-29 14:53:38 +02:00
bors
7a58674259 Auto merge of #124255 - RenjiSann:renji/mcdc-nested-expressions, r=Zalathar
MCDC coverage: support nested decision coverage

#123409 provided the initial MCDC coverage implementation.

As referenced in #124144, it does not currently support "nested" decisions, like the following example :

```rust
fn nested_if_in_condition(a: bool, b: bool, c: bool) {
    if a && if b || c { true } else { false } {
        say("yes");
    } else {
        say("no");
    }
}
```

Note that there is an if-expression (`if b || c ...`) embedded inside a boolean expression in the decision of an outer if-expression.

This PR proposes a workaround for this cases, by introducing a Decision context stack, and by handing several `temporary condition bitmaps` instead of just one.
When instrumenting boolean expressions, if the current node is a leaf condition (i.e. not a `||`/`&&` logical operator nor a `!` not operator), we insert a new decision context, such that if there are more boolean expressions inside the condition, they are handled as separate expressions.

On the codegen LLVM side, we allocate as many `temp_cond_bitmap`s as necessary to handle the maximum encountered decision depth.
2024-04-29 11:54:49 +00:00
Zalathar
f9263374fb coverage: Replace boolean options with a CoverageLevel enum 2024-04-29 20:04:22 +10:00
Oli Scherer
fea1fe7f01 Avoid some def_span query calls 2024-04-29 09:48:19 +00:00
Sasha Pourcelot
c8ff8a4dc7 Pretty-print parenthesis around binary in postfix match
Signed-off-by: Sasha Pourcelot <sasha.pourcelot@protonmail.com>
2024-04-29 11:34:22 +02:00
Dorian Péron
60ca9b6e29 mcdc-coverage: Get decision_depth from THIR lowering
Use decision context stack to handle nested decisions:
- Introduce MCDCDecisionCtx
- Use a stack of MCDCDecisionCtx to handle nested decisions
2024-04-29 09:13:40 +00:00