about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2023-12-03Parse a pattern with no armNadrieril-151/+221
2023-12-02Auto merge of #118175 - lqd:unify-live-loans, r=matthewjasperbors-102/+98
Centralize live loans maintenance to fix scope differences due to liveness As found in the recent [polonius crater run](https://github.com/rust-lang/rust/pull/117593#issuecomment-1801398892), NLLs and the location-insensitive polonius computed different scopes on some specific CFG shapes, e.g. the following. ![image](https://github.com/rust-lang/rust/assets/247183/c3649f5e-3058-454e-854e-1a6b336bdd5e) I had missed that liveness data was pushed from different sources than just the liveness computation: there are a few places that do this -- and some of them may be unneeded or at the very least untested, as no tests changed when I tried removing some of them. Here, `_6` is e.g. dead on entry to `bb2[0]` during `liveness::trace`, but its regions will be marked as live later during "constraint generation" (which I plan to refactor away and put in the liveness module soon). This should cause the inflowing loans to be marked live, but they were only computed in `liveness::trace`. Therefore, this PR moves live loan maintenance to `LivenessValues`, so that the various places pushing liveness data will all also update live loans at the same time -- except for promoteds which I don't believe need them, and their liveness handling is already interesting/peculiar. All the regressions I saw in the initial crater run were related to this kind of shapes, and this change did fix all of them on the [next run](https://github.com/rust-lang/rust/pull/117593#issuecomment-1826132145). r? `@matthewjasper` (This will conflict with #117880 but whichever lands first is fine by me, the end goal is the same for both)
2023-12-01Auto merge of #113923 - DianQK:restore-no-builtins-lto, r=pnkfelixbors-80/+28
Restore `#![no_builtins]` crates participation in LTO. After #113716, we can make `#![no_builtins]` crates participate in LTO again. `#![no_builtins]` with LTO does not result in undefined references to the error. I believe this type of issue won't happen again. Fixes #72140. Fixes #112245. Fixes #110606. Fixes #105734. Fixes #96486. Fixes #108853. Fixes #108893. Fixes #78744. Fixes #91158. Fixes https://github.com/rust-lang/cargo/issues/10118. Fixes https://github.com/rust-lang/compiler-builtins/issues/347. The `nightly-2023-07-20` version does not always reproduce problems due to changes in compiler-builtins, core, and user code. That's why this issue recurs and disappears. Some issues were not tested due to the difficulty of reproducing them. r? pnkfelix cc `@bjorn3` `@japaric` `@alexcrichton` `@Amanieu`
2023-12-01Auto merge of #115993 - bvanjoi:fix-115966, r=petrochenkovbors-26/+44
vis note for no pub reexports glob import Fixes #115966 Only trigger the `unused_import` lint when it's not being used. r? `@petrochenkov`
2023-12-01improve NLL/polonius scope equality assertionRémy Rakic-1/+2
2023-12-01move and maintain live loans in `LivenessValues`Rémy Rakic-97/+94
Liveness data is pushed from multiple parts of NLL. Instead of changing the call sites to maintain live loans, move the latter to `LivenessValues` where this liveness data is pushed to, and maintain live loans there. This fixes the differences in polonius scopes on some CFGs where a variable was dead in tracing but as a MIR terminator its regions were marked live from "constraint generation"
2023-12-01rename a couple of trivial variablesRémy Rakic-3/+3
for consistency with how they're named everywhere else
2023-12-01remove useless debug logRémy Rakic-2/+0
2023-12-01Auto merge of #117472 - jmillikin:stable-c-str-literals, r=Nilstriebbors-8/+4
Stabilize C string literals RFC: https://rust-lang.github.io/rfcs/3348-c-str-literal.html Tracking issue: https://github.com/rust-lang/rust/issues/105723 Documentation PR (reference manual): https://github.com/rust-lang/reference/pull/1423 # Stabilization report Stabilizes C string and raw C string literals (`c"..."` and `cr#"..."#`), which are expressions of type [`&CStr`](https://doc.rust-lang.org/stable/core/ffi/struct.CStr.html). Both new literals require Rust edition 2021 or later. ```rust const HELLO: &core::ffi::CStr = c"Hello, world!"; ``` C strings may contain any byte other than `NUL` (`b'\x00'`), and their in-memory representation is guaranteed to end with `NUL`. ## Implementation Originally implemented by PR https://github.com/rust-lang/rust/pull/108801, which was reverted due to unintentional changes to lexer behavior in Rust editions < 2021. The current implementation landed in PR https://github.com/rust-lang/rust/pull/113476, which restricts C string literals to Rust edition >= 2021. ## Resolutions to open questions from the RFC * Adding C character literals (`c'.'`) of type `c_char` is not part of this feature. * Support for `c"..."` literals does not prevent `c'.'` literals from being added in the future. * C string literals should not be blocked on making `&CStr` a thin pointer. * It's possible to declare constant expressions of type `&'static CStr` in stable Rust (as of v1.59), so C string literals are not adding additional coupling on the internal representation of `CStr`. * The unstable `concat_bytes!` macro should not accept `c"..."` literals. * C strings have two equally valid `&[u8]` representations (with or without terminal `NUL`), so allowing them to be used in `concat_bytes!` would be ambiguous. * Adding a type to represent C strings containing valid UTF-8 is not part of this feature. * Support for a hypothetical `&Utf8CStr` may be explored in the future, should such a type be added to Rust.
2023-12-01Auto merge of #118216 - lqd:constraint-generation-non-non, r=matthewjasperbors-432/+454
Refactor NLL constraint generation and most of polonius fact generation As discussed in #118175, NLL "constraint generation" is only about liveness, but currently also contains legacy polonius fact generation. The latter is quite messy, and this PR cleans this up to prepare for its future removal: - splits polonius fact generation out of NLL constraint generation - merges NLL constraint generation to its more natural place, liveness - extracts all of the polonius fact generation from NLLs apart from MIR typeck (as fact generation is somewhat in a single place there already, but should be cleaned up) into its own explicit module, with a single entry point instead of many. There should be no behavior changes, and tests seem to behave the same as master: without polonius, with legacy polonius, with the in-tree polonius. I've split everything into smaller logical commits for easier review, as it required quite a bit of code to be split and moved around, but it should all be trivial changes. r? `@matthewjasper`
2023-12-01Auto merge of #118493 - TaKO8Ki:rollup-jfkdbyo, r=TaKO8Kibors-1/+1
Rollup of 3 pull requests Successful merges: - #118483 (rustdoc: `div.where` instead of fmt-newline class) - #118486 (generic_const_exprs: suggest to add the feature, not use it) - #118489 (Wesley is on vacation) r? `@ghost` `@rustbot` modify labels: rollup
2023-12-01Rollup merge of #118486 - RalfJung:add-feature, r=compiler-errorsTakayuki Maeda-1/+1
generic_const_exprs: suggest to add the feature, not use it Usually our missing feature messages look something like ``` = help: add `#![feature(inline_const)]` to the crate attributes to enable ``` However `generic_const_exprs` used a different verb. That's inconsistent and it also means playground won't add that nice hyperlink to add the feature automatically. So let's use the same verb as everywhere else.
2023-12-01vis note for no pub reexports glob importbohan-26/+44
2023-12-01Auto merge of #118482 - RalfJung:interpret-local-type, r=WaffleLapkinbors-0/+3
explain a good reason for why LocalValue does not store the type of the local As found out by `@lcnr` in https://github.com/rust-lang/rust/pull/112307, storing the type here can lead to subtle bugs when it gets out of sync with the MIR body. That's not the reason why the interpreter does it this way I think, but good thing we dodged that bullet. :)
2023-12-01Auto merge of #118461 - celinval:smir-switch-targets, r=ouz-abors-44/+69
Change `SwitchTarget` representation in StableMIR The new structure encodes its invariant, which reduces the likelihood of having an inconsistent representation. It is also more intuitive and user friendly. I encapsulated the structure for now in case we decide to change it back. ### Notes: 1. I had to change the `Successors` type, since there's a conflict on the iterator type. We could potentially implement an iterator here, but I would prefer keeping it simple for now, and add a `successors_iter()` method if needed. 2. I removed `CoroutineDrop` for now since it we never create it. We can add it when we add support to other MIR stages.
2023-12-01Auto merge of #118472 - nnethercote:rustc_session, r=bjorn3bors-117/+86
`rustc_session` cleanups r? `@bjorn3`
2023-11-30Auto merge of #116892 - ojeda:rethunk, r=wesleywiserbors-10/+84
Add `-Zfunction-return={keep,thunk-extern}` option This is intended to be used for Linux kernel RETHUNK builds. With this commit (optionally backported to Rust 1.73.0), plus a patched Linux kernel to pass the flag, I get a RETHUNK build with Rust enabled that is `objtool`-warning-free and is able to boot in QEMU and load a sample Rust kernel module. Issue: https://github.com/rust-lang/rust/issues/116853.
2023-12-01Clarify the `lockfile` field in `IncrCompSession`.Nicholas Nethercote-3/+6
2023-12-01Remove unused field from `IncrCompSession`.Nicholas Nethercote-11/+5
2023-12-01Move `WasiExecModel`.Nicholas Nethercote-7/+7
All the other option enums are defined in `config.rs`.
2023-12-01Reduce `pub` exposure.Nicholas Nethercote-7/+5
2023-11-30Auto merge of #117805 - estebank:arg-fn-mismatch, r=petrochenkovbors-18/+173
On Fn arg mismatch for a fn path, suggest a closure When encountering a fn call that has a path to another fn being passed in, where an `Fn` impl is expected, and the arguments differ, suggest wrapping the argument with a closure with the appropriate arguments. The last `help` is new: ``` error[E0631]: type mismatch in function arguments --> $DIR/E0631.rs:9:9 | LL | fn f(_: u64) {} | ------------ found signature defined here ... LL | foo(f); | --- ^ expected due to this | | | required by a bound introduced by this call | = note: expected function signature `fn(usize) -> _` found function signature `fn(u64) -> _` note: required by a bound in `foo` --> $DIR/E0631.rs:3:11 | LL | fn foo<F: Fn(usize)>(_: F) {} | ^^^^^^^^^ required by this bound in `foo` help: consider wrapping the function in a closure | LL | foo(|arg0: usize| f(/* u64 */)); | +++++++++++++ +++++++++++ ```
2023-11-30generic_const_exprs: suggest to add the feature, not use itRalf Jung-1/+1
2023-11-30Fix SwitchTarget pretty printCelina G. Val-4/+1
We currently rely on the order of successors to be conditional branches first, followed by the otherwise target.
2023-11-30Change SwitchTarget representationCelina G. Val-44/+72
The new structure encodes its invariant, which reduces the likelihood of having an inconsistent representation. It is also more intuitive and user friendly. I encapsulated the structure for now in case we decide to change it back.
2023-11-30Add `-Zfunction-return={keep,thunk-extern}` optionMiguel Ojeda-9/+83
This is intended to be used for Linux kernel RETHUNK builds. With this commit (optionally backported to Rust 1.73.0), plus a patched Linux kernel to pass the flag, I get a RETHUNK build with Rust enabled that is `objtool`-warning-free and is able to boot in QEMU and load a sample Rust kernel module. Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2023-11-30Enable link-arg link kind inside of #[link] attributezetanumbers-1/+17
- Implement link-arg as an attribute - Apply suggestions from review - Co-authored-by: Vadim Petrochenkov <vadim.petrochenkov@gmail.com> - Add unstable book entry
2023-11-30explain a good reason for why LocalValue does not store the type of the localRalf Jung-0/+3
2023-11-30rustc_codegen_llvm: remove outdated count in commentMiguel Ojeda-1/+1
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2023-11-30Auto merge of #118473 - matthiaskrgr:rollup-q96bm3u, r=matthiaskrgrbors-34/+20
Rollup of 5 pull requests Successful merges: - #118452 (rustdoc-search: allow spaces around `::` in path query) - #118453 (Tweak message on ADT with private fields building) - #118456 (rustc_span: Remove unused symbols.) - #118458 (rustdoc: remove small from `small-section-header`) - #118464 (Dispose llvm::TargetMachines prior to llvm::Context being disposed) r? `@ghost` `@rustbot` modify labels: rollup
2023-11-30Rollup merge of #118464 - wesleywiser:fix_dispose_ordering, r=NilstriebMatthias Krüger-6/+18
Dispose llvm::TargetMachines prior to llvm::Context being disposed If the TargetMachine is disposed after the Context is disposed, it can lead to use after frees in some cases. I've observed this happening occasionally on code compiled for aarch64-pc-windows-msvc using `-Zstack-protector=strong` but other users have reported AVs from host aarch64-pc-windows-msvc compilers as well. I was not able to extract a self-contained test case yet so there is no accompanying test. Fixes #118462
2023-11-30Rollup merge of #118456 - aDotInTheVoid:unused-symbols, r=WaffleLapkinMatthias Krüger-27/+0
rustc_span: Remove unused symbols. As noted here, there is no guarantee that all pre-interned symbols are used. https://github.com/rust-lang/rust/blob/b10cfcd65fd7f7b1ab9beb34798b2108de003452/compiler/rustc_span/src/symbol.rs#L124-L125 This was done starting with using ripgrep to search for `sym::whatever`. I removed anything that didn't show up. However this had a huge number of false positives, due to extensive macro use. Then there was a manual phase of adding back all the ones used my macros. I don't think this was worth my time to do, but it's done now . ¯\_(ツ)_/¯
2023-11-30Rollup merge of #118453 - estebank:priv-fields, r=compiler-errorsMatthias Krüger-1/+2
Tweak message on ADT with private fields building When trying to create an inaccessible ADT due to private fields, handle the case when no fields were passed. ``` error: cannot construct `Foo` with struct literal syntax due to private fields --> $DIR/issue-76077.rs:8:5 | LL | foo::Foo {}; | ^^^^^^^^ | = note: private field `you_cant_use_this_field` that was not provided ```
2023-11-30Auto merge of #118408 - RalfJung:aggregate-assign-uninit, r=saethlinbors-60/+72
miri: add test checking that aggregate assignments reset memory to uninit Also, `write_aggregate` is really just a helper for evaluating `Aggregate` rvalues, so it should be in `step.rs`, not `place.rs`. Also factor out `Repeat` rvalues into their own function while we are at it. r? `@saethlin` Fixes https://github.com/rust-lang/miri/issues/3195
2023-11-30Inline and remove `select_debuginfo_compression`.Nicholas Nethercote-9/+1
It's trivial and has a single callsite.
2023-11-30Sort `PRINT_KINDS`.Nicholas Nethercote-13/+15
Alphabetical order is nicer than random order.
2023-11-30Improve integer interning in `default_configuration`.Nicholas Nethercote-10/+9
We have `sym::integer` for interning integers. Using it lets us use symbols directy, and not have to explicitly go through strings.
2023-11-30Move `is_ascii_ident` to where it's used.Nicholas Nethercote-13/+13
2023-11-30Update a comment.Nicholas Nethercote-1/+1
Save analysis was removed a while ago.
2023-11-30Remove unused `FileMatch`.Nicholas Nethercote-6/+0
2023-11-30Move `MetadataLoader{,Dyn}` to `rustc_metadata`.Nicholas Nethercote-28/+21
They're not used in `rustc_session`, and `rustc_metadata` is a more obvious location. `MetadataLoader` was originally put into `rustc_session` in #41565 to avoid a dependency on LLVM, but things have changed a lot since then and that's no longer relevant, e.g. `rustc_codegen_llvm` depends on `rustc_metadata`.
2023-11-30Reorder some `use` items.Nicholas Nethercote-10/+6
2023-11-30Remove unused features.Nicholas Nethercote-2/+0
2023-11-30Auto merge of #118379 - compiler-errors:const-params-for-partialeq, r=fee1-deadbors-46/+72
Fix `PartialEq` args when `#[const_trait]` is enabled This is based off of your PR that enforces effects on all methods, so just see the last commits. r? fee1-dead
2023-11-30Auto merge of #117565 - estebank:issue-100825, r=Nilstriebbors-131/+236
Tweak parsing recovery of enums, for exprs and match arm patterns Tweak recovery of `for (pat in expr) {}` for more accurate spans. When encountering `match` arm `(pat if expr) => {}`, recover and suggest removing parentheses. Fix #100825. When encountering malformed enums, try more localized per-variant parse recovery. Move parser recovery tests to subdirectory.
2023-11-29Update compiler/rustc_codegen_llvm/src/lib.rsWesley Wiser-1/+1
Co-authored-by: Josh Stone <cuviper@gmail.com>
2023-11-29Dispose llvm::TargetMachines prior to llvm::Context being disposedWesley Wiser-6/+18
If the TargetMachine is disposed after the Context is disposed, it can lead to use after frees in some cases. I've observed this happening occasionally on code compiled for aarch64-pc-windows-msvc using `-Zstack-protector=strong` but other users have reported AVs from host aarch64-pc-windows-msvc compilers as well.
2023-11-30Auto merge of #114499 - taiki-e:riscv-forced-atomics, r=Amanieubors-5/+6
Pass +forced-atomics feature for riscv32{i,im,imc}-unknown-none-elf As said in https://github.com/rust-lang/rust/pull/98333#issuecomment-1666375293, `forced-atomics` target feature is also needed to enable atomic load/store on these targets (otherwise, libcalls are generated): https://godbolt.org/z/433qeG7vd ~~This PR is currently marked as a draft because:~~ - ~~`forced-atomics` target feature is currently broken (https://github.com/rust-lang/rust/issues/114153).~~ EDIT: Fixed - ~~`forced-atomics` target feature has been added in LLVM 16 (https://github.com/llvm/llvm-project/commit/f5ed0cb217a9988f97b55f2ccb053bca7b41cc0c), but the current minimum LLVM version [is 15](https://github.com/rust-lang/rust/blob/90f0b24ad3e7fc0dc0e419c9da30d74629cd5736/src/bootstrap/llvm.rs#L557). In LLVM 15, the atomic load/store of these targets generates libcalls anyway.~~ EDIT: LLVM 15 has been dropped Depending on the policy on the minimum LLVM version for these targets, this may be blocked until the minimum LLVM version is increased to 16. r? `@Amanieu`
2023-11-29review comments and rebase fixesEsteban Küber-65/+64
2023-11-29rustc_span: Remove unused symbols.Alona Enraght-Moony-27/+0