Commit Graph

35789 Commits

Author SHA1 Message Date
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 `pub`s. 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.expect`ing 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 `use`s 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
Dorian Péron ae8c023983 mcdc-coverage: Add decision_depth field in structs
Add decision_depth field to TVBitmapUpdate/CondBitmapUpdate statements
Add decision_depth field to BcbMappingKinds MCDCBranch and MCDCDecision
Add decision_depth field to MCDCBranchSpan and MCDCDecisionSpan
2024-04-29 09:13:40 +00:00
Nicholas Nethercote 52e9a23bdc Remove `extern crate smallvec` from a couple of crates. 2024-04-29 18:47:54 +10:00
Nicholas Nethercote 1ab34f063b Remove `extern crate bitflags` from a couple of crates. 2024-04-29 18:47:54 +10:00
Nicholas Nethercote 7418aa1a07 Remove `extern crate rustc_data_structures` from numerous crates. 2024-04-29 18:45:14 +10:00
Dorian Péron 3c2f48ede9 mcdc-coverage: Add possibility for codegen llvm to handle several condition bitmaps 2024-04-29 08:41:15 +00:00
Lin Yihai 589c2fe24d Add raw identifier in a typo suggestion 2024-04-29 15:02:12 +08:00
Zalathar a25a11ad73 coverage: Avoid hard-coded values when visiting logical ops
Instead of separately hard-coding the operation being visited, we can get it
from the match arm pattern by using an as-pattern.
2024-04-29 16:41:10 +10:00
Nicholas Nethercote f3e05d1609 Remove `extern crate rustc_data_structures` from `rustc_query_system`. 2024-04-29 15:40:29 +10:00
Nicholas Nethercote 99e036bd21 Remove `extern crate rustc_middle` from numerous crates. 2024-04-29 14:50:45 +10:00
Nicholas Nethercote e6b3e20243 Remove `extern crate rustc_session` from `rustc_lint`. 2024-04-29 13:57:41 +10:00
Gurinder Singh 254a9fbe86 Prohibit const prop of unions in `KnownPanicsLint`
as they have a potential to ICE during layout calculation
2024-04-29 08:16:26 +05:30
Nicholas Nethercote 6ce258f657 Remove `extern crate rustc_macros` from `rustc_middle`. 2024-04-29 11:19:16 +10:00
Nicholas Nethercote 4814fd0a4b Remove `extern crate rustc_macros` from numerous crates. 2024-04-29 10:21:54 +10:00
bors 1fffb2a355 Auto merge of #124431 - chenyukang:yukang-fix-rustdoc-124363, r=Nadrieril
Fix the assertion crash from rustdoc document indent widths

Fixes #124363
2024-04-28 21:20:07 +00:00
est31 4284bca720 Add a note to the ArbitraryExpressionInPattern error 2024-04-28 21:27:26 +02:00