about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2025-01-23Remove query normalize from normalize type opMichael Goulet-6/+2
2025-01-23Allow `arena_cache` queries to return `Option<&'tcx T>`Zalathar-9/+64
2025-01-22rustc_codegen_llvm: remove outdated asm-to-obj codegen noteKen Matsui-6/+3
Remove comment about missing integrated assembler handling, which was removed in commit 02840ca.
2025-01-22Auto merge of #135896 - matthiaskrgr:rollup-g6rv7za, r=matthiaskrgrbors-630/+693
Rollup of 9 pull requests Successful merges: - #132983 (Edit dangling pointers ) - #135409 (Fix ICE-133117: multiple never-pattern arm doesn't have false_edge_start_block) - #135557 (Point at invalid utf-8 span on user's source code) - #135596 (Properly note when query stack is being cut off) - #135794 (Detect missing fields with default values and suggest `..`) - #135814 (ci: use ghcr buildkit image) - #135826 (Misc. `rustc_resolve` cleanups) - #135837 (Remove test panic from File::open) - #135856 (Library: Finalize dyn compatibility renaming) r? `@ghost` `@rustbot` modify labels: rollup
2025-01-22Enable kernel sanitizers for aarch64-unknown-none-softfloatJubilee Young-1/+3
We want kernels to be able to use this bare metal target, so let's enable the sanitizers that kernels want to use.
2025-01-22Rollup merge of #135826 - yotamofek:resolve-cleanups4, r=petrochenkovMatthias Krüger-606/+562
Misc. `rustc_resolve` cleanups Hopefully this PR should make `rustc_resolve` a bit cleaner. Each commit here stands on its own. I tried to only include changes that are easy to review, and are a clear improvement. (but I'll be happy to revert any changes that turn out to be more controversial than I'd thought) Best viewed with whitespace ignored 😁 (especially [these two commits](https://github.com/rust-lang/rust/pull/135826/files/a93616acf3118ef233027d74e8c636f9b79c342d..ae87d005bc92cbecc47b554e634d1bd3d22e1068?diff=unified&w=1))
2025-01-22Rollup merge of #135794 - estebank:non-exhaustive-dfv-ctor, r=jieyouxuMatthias Krüger-0/+30
Detect missing fields with default values and suggest `..` When a struct ctor use has missing fields, if all those missing fields have defaults, suggest `..`: ``` error[E0063]: missing fields `field1` and `field2` in initializer of `S` --> $DIR/non-exhaustive-ctor.rs:16:13 | LL | let _ = S { field: () }; | ^ missing `field1` and `field2` | help: all remaining fields have default values, you can use those values with `..` | LL | let _ = S { field: (), .. }; | ++++ ```
2025-01-22Rollup merge of #135596 - compiler-errors:stack, r=oli-obkMatthias Krüger-11/+16
Properly note when query stack is being cut off cc #70953 also, i'm not certain whether we should even limit this at all. i don't see the problem with printing the full query stack, apparently it was limited b/c we used to ICE? but we're already printing the full stack to disk since #108714. r? oli-obk
2025-01-22Rollup merge of #135557 - estebank:wtf8, r=fee1-deadMatthias Krüger-9/+70
Point at invalid utf-8 span on user's source code ``` error: couldn't read `$DIR/not-utf8-bin-file.rs`: stream did not contain valid UTF-8 --> $DIR/not-utf8-2.rs:6:5 | LL | include!("not-utf8-bin-file.rs"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: byte `193` is not valid utf-8 --> $DIR/not-utf8-bin-file.rs:2:14 | LL | let _ = "�|�␂!5�cc␕␂��"; | ^ = note: this error originates in the macro `include` (in Nightly builds, run with -Z macro-backtrace for more info) ``` When we attempt to load a Rust source code file, if there is a OS file failure we try reading the file as bytes. If that succeeds we try to turn it into UTF-8. If *that* fails, we provide additional context about *where* the file has the first invalid UTF-8 character. Fix #76869.
2025-01-22Rollup merge of #135409 - ↵Matthias Krüger-2/+9
Shunpoco:issue-133117-ICE-never-false-edge-start-block, r=Nadrieril Fix ICE-133117: multiple never-pattern arm doesn't have false_edge_start_block Fixes #133117 , and close fixes #133063 , fixes #130779 In order to fix ICE-133117, at first I needed to tackle to ICE-133063 (this fixed 130779 as well). ### ICE-133063 and ICE-130779 This ICE is caused by those steps: 1. An arm has or-pattern, and all of the sub-candidates are never-pattern 2. In that case, all sub-candidates are removed in remove_never_subcandidates(). So the arm (candidate) has no sub-candidate. 3. In the current implementation, if there is no sub-candidate, the function assigns `pre_binding_block` into the candidate ([here](https://github.com/rust-lang/rust/blob/master/compiler/rustc_mir_build/src/builder/matches/mod.rs#L2002-L2004)). However, otherwise_block should be assigned to the candidate as well, because the otherwise_block is unwrapped in multiple place (like in lower_match_tree()). As a result, it causes the panic. I simply added the same block as pre_binding_block into otherwise_block, but I'm wondering if there is a better block to assign to otherwise_block (is it ok to assign the same block into pre_binding and otherwise?) ### ICE-133117 This is caused by those steps: 1. There are two arms, both are or-pattern and each has one match-pair (in the test code, both are `(!|!)`), and the second arm has a guard. 2. In match_candidate() for the first arm, it expands the second arm’s sub-candidates as well ([here](https://github.com/rust-lang/rust/blob/master/compiler/rustc_mir_build/src/builder/matches/mod.rs#L1800-L1805)). As a result, the root candidate of the second arm is not evaluated/modified in match_candidate(). So a false_edge_start_block is not assigned to the candidate. 3. merge_trivial_subcandidates() is called against the candidate for the second arm. It just returns immediately because the candidate has a guard. So a flase_edge_start_block is not assigned to the candidate also in this function. 4. remove_never_subcandidates() is called against the candidate. Since all sub-candidates are never-pattern. they are removed. 5. In lower_match_tree(), since there is no sub-candidate for the candidate, the candidate itself is evaluated in visit_leave_rev ([here](https://github.com/rust-lang/rust/blob/master/compiler/rustc_mir_build/src/builder/matches/mod.rs#L1532)). Because the candidate has no false_edge_start_block, it causes the panic. So I modified the order of if blocks in merge_trivial_subcandidates() to assign a false_edge_start_block if the candidate doesn't have.
2025-01-22Rollup merge of #132983 - Anthony-Eid:dangling-pointers-lint, r=UrgauMatthias Krüger-2/+6
Edit dangling pointers Closes: #132283
2025-01-22Don't ICE in coerce when autoderef fails to structurally normalize non-WF ↵Michael Goulet-3/+11
type in new solver
2025-01-22Rollup merge of #135875 - BoxyUwU:enter_forall_no_copy, r=lcnrMatthias Krüger-4/+4
Remove `Copy` bound from `enter_forall` idk why we ever required this, `TypeFoldable` implies `Clone`
2025-01-22Rollup merge of #135874 - oli-obk:push-vrvyyrtyxkxm, r=compiler-errorsMatthias Krüger-32/+36
Enforce that all spans are lowered in ast lowering This should ensure that incremental is used as extensively as possible. It's only a debug assertion, and only enabled when incremental is enabled (as we only lower spans to relative spans then).
2025-01-22Rollup merge of #135866 - BoxyUwU:dont_pick_fnptr_nested_goals, r=lcnrMatthias Krüger-2/+21
Don't pick `T: FnPtr` nested goals as the leaf goal in diagnostics for new solver r? `@lcnr` See `tests/ui/traits/next-solver/diagnostics/dont-pick-fnptr-bound-as-leaf.rs` for a minimized example of what code this affects the diagnostics off. The output of running nightly `-Znext-solver` on that test is the following: ``` error[E0277]: the trait bound `Foo: Trait` is not satisfied --> src/lib.rs:14:20 | 14 | requires_trait(Foo); | -------------- ^^^ the trait `FnPtr` is not implemented for `Foo` | | | required by a bound introduced by this call | note: required for `Foo` to implement `Trait` --> src/lib.rs:7:16 | 7 | impl<T: FnPtr> Trait for T {} | ----- ^^^^^ ^ | | | unsatisfied trait bound introduced here note: required by a bound in `requires_trait` --> src/lib.rs:11:22 | 11 | fn requires_trait<T: Trait>(_: T) {} | ^^^^^ required by this bound in `requires_trait` ``` Part of rust-lang/trait-system-refactor-initiative#148
2025-01-22Rollup merge of #135816 - BoxyUwU:root_normalizes_to_goal_ice, r=lcnrMatthias Krüger-96/+75
Use `structurally_normalize` instead of manual `normalizes-to` goals in alias relate errors r? `@lcnr` I added `structurally_normalize_term` so that code that is generic over ty or const can use the structurally normalize helpers. See `tests/ui/traits/next-solver/diagnostics/alias_relate_error_uses_structurally_normalize.rs` for a description of the reason for the (now fixed) ICEs
2025-01-22Rollup merge of #135156 - Zalathar:debuginfo-flags, r=cuviperMatthias Krüger-117/+87
Make our `DIFlags` match `LLVMDIFlags` in the LLVM-C API In order to be able to use a mixture of LLVM-C and C++ bindings for debuginfo, our Rust-side `DIFlags` needs to have the same layout as LLVM-C's `LLVMDIFlags`, and we also need to be able to convert it to the `DIFlags` accepted by LLVM's C++ API. Internally, LLVM converts between the two types with a simple cast. We can't necessarily rely on that always being true, and LLVM doesn't expose a conversion function, so we have two potential options: - Convert each bit/subvalue individually - Statically assert that doing a cast is actually fine As long as both types do remain the same under the hood (which seems likely), the static-assert-and-cast approach is easier and faster. If the static assertions ever start failing against some future version of LLVM, we'll have to switch over to the convert-each-subvalue approach, which is a bit more error-prone. --- Extracted from #134009, though this PR ended up choosing the static-assert-and-cast approach over the convert-each-subvalue approach.
2025-01-22Rollup merge of #134396 - mustartt:byval-pointer-natural-alignment, ↵Matthias Krüger-1/+3
r=wesleywiser AIX: use align 8 for byval parameter On AIX, byval pointer arguments are aligned to 8 bytes based on the 64bit register size. For example, the C callee https://godbolt.org/z/5f4vnG6bh will expect the following argument. ``` ptr nocapture noundef readonly byval(%struct.TwoU64s) align 8 %0 ``` This case is captured by `run-make/extern-fn-explicit-align`
2025-01-22Rollup merge of #133372 - cramertj:rework-dyn-suggestions, r=fmeaseMatthias Krüger-86/+114
Refactor dyn-compatibility error and suggestions This CL makes a number of small changes to dyn compatibility errors: - "object safety" has been renamed to "dyn-compatibility" throughout - "Convert to enum" suggestions are no longer generated when there exists a type-generic impl of the trait or an impl for `dyn OtherTrait` - Several error messages are reorganized for user readability Additionally, the dyn compatibility error creation code has been split out into functions. cc #132713 cc #133267 r? `@compiler-errors`
2025-01-22Refactor dyn-compatibility error and suggestionsTaylor Cramer-86/+114
This CL makes a number of small changes to dyn compatibility errors: - "object safety" has been renamed to "dyn-compatibility" throughout - "Convert to enum" suggestions are no longer generated when there exists a type-generic impl of the trait or an impl for `dyn OtherTrait` - Several error messages are reorganized for user readability Additionally, the dyn compatibility error creation code has been split out into functions. cc #132713 cc #133267
2025-01-22[AIX] Lint on structs that have a different alignment in AIX's C ABIAmy Kwan-5/+135
2025-01-22remove implied end of sliceMarijn Schouten-1/+1
2025-01-22Auto merge of #134478 - compiler-errors:attr-span, r=oli-obkbors-23/+55
Properly record metavar spans for other expansions other than TT This properly records metavar spans for nonterminals other than tokentree. This means that we operations like `span.to(other_span)` work correctly for macros. As you can see, other diagnostics involving metavars have improved as a result. Fixes #132908 Alternative to #133270 cc `@ehuss` cc `@petrochenkov`
2025-01-22Remove `Copy` bound from `enter_forall`Boxy-4/+4
2025-01-22Enforce that all spans are lowered in ast loweringOli Scherer-32/+36
2025-01-22Also check for associated fns on primitives in E0223 similar-path check.Zachary S-3/+9
2025-01-22For E0223, suggest associated functions that are similar to the path, even ↵Zachary S-4/+6
if there are multiple inherent impls to check.
2025-01-22Rename `structurally_normalize` to `structurally_normalize_ty`Boxy-13/+13
2025-01-22Use `structurally_normalize` instead of manual `normalizes-to` goalsBoxy-83/+62
2025-01-22Don't pick `T: FnPtr` nested goalsBoxy-2/+21
2025-01-22Update lint tests with new dangling pointers messageAnthony Eid-2/+2
2025-01-22Auto merge of #135674 - scottmcm:assume-better, r=estebankbors-29/+39
Update our range `assume`s to the format that LLVM prefers I found out in https://github.com/llvm/llvm-project/issues/123278#issuecomment-2597440158 that the way I started emitting the `assume`s in #109993 was suboptimal, and as seen in that LLVM issue the way we're doing it -- with two `assume`s sometimes -- can at times lead to CVP/SCCP not realize what's happening because one of them turns into a `ne` instead of conveying a range. So this updates how it's emitted from ``` assume( x >= LOW ); assume( x <= HIGH ); ``` or ``` // (for ranges that wrap the range) assume( (x <= LOW) | (x >= HIGH) ); ``` to ``` assume( (x - LOW) <= (HIGH - LOW) ); ``` so that we don't need multiple `icmp`s nor multiple `assume`s for a single value, and both wrappping and non-wrapping ranges emit the same shape. (And we don't bother emitting the subtraction if `LOW` is zero, since that's trivial for us to check too.)
2025-01-22modify commentShunpoco-1/+1
Signed-off-by: Shunpoco <tkngsnsk313320@gmail.com>
2025-01-22address review: modify matches/mod.rsShunpoco-4/+9
The candidate shouldn't have false_edge_start_block if it has sub candidates. In remove_never_subcandidates(), the false_edge_start_block from the first sub candidte is assigned to a value and the value is later used if all sub candidates are removed and candidate doesn't have false_edge_start_block. In merge_trivial_subcandidates, I leave the if block which assign a false_edge_start_block into the candidate as before I put this commit since compile panics. Signed-off-by: Shunpoco <tkngsnsk313320@gmail.com>
2025-01-21Only assert the `Parser` size on specific archesJosh Stone-2/+3
The size of this struct depends on the alignment of `u128`, for example powerpc64le and s390x have align-8 and end up with only 280 bytes. Our 64-bit tier-1 arches are the same though, so let's just assert on those.
2025-01-22Auto merge of #135848 - matthiaskrgr:rollup-sftciqm, r=matthiaskrgrbors-25/+31
Rollup of 8 pull requests Successful merges: - #132232 (CI: build FreeBSD artifacts on FreeBSD 13.4) - #135706 (Move `supertrait_def_ids` into the elaborate module like all other fns) - #135750 (Add an example of using `carrying_mul_add` to write wider multiplication) - #135793 (Ignore `mermaid.min.js`) - #135810 (Add Kobzol on vacation) - #135821 (fix OsString::from_encoded_bytes_unchecked description) - #135824 (tests: delete `cat-and-grep-sanity-check`) - #135833 (Add fixme and test for issue #135289) Failed merges: - #135816 (Use `structurally_normalize` instead of manual `normalizes-to` goals in alias relate errors) r? `@ghost` `@rustbot` modify labels: rollup
2025-01-22Point at invalid utf-8 span on user's source codeEsteban Küber-9/+70
``` error: couldn't read `$DIR/not-utf8-bin-file.rs`: stream did not contain valid UTF-8 --> $DIR/not-utf8-2.rs:6:5 | LL | include!("not-utf8-bin-file.rs"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: `[193]` is not valid utf-8 --> $DIR/not-utf8-bin-file.rs:2:14 | LL | let _ = "�|�␂!5�cc␕␂��"; | ^ = note: this error originates in the macro `include` (in Nightly builds, run with -Z macro-backtrace for more info) ``` When we attempt to load a Rust source code file, if there is a OS file failure we try reading the file as bytes. If that succeeds we try to turn it into UTF-8. If *that* fails, we provide additional context about *where* the file has the first invalid UTF-8 character. Fix #76869.
2025-01-21remove long-deprecated no-op attributes no_start and crate_idRalf Jung-31/+2
2025-01-21Rollup merge of #135833 - lqd:add-ice-test, r=compiler-errorsMatthias Krüger-0/+6
Add fixme and test for issue #135289 This PR: - adds a test minimizing issue #135289 for PR #135310 - adds a fixme about the suboptimal fix for the ICE I've verified the test indeed ICEs with 3f2f695d68334ca4ecc8aec0aa38b5391051c987 reverted. r? `@estebank`
2025-01-21Rollup merge of #135706 - compiler-errors:elaborate, r=lcnrMatthias Krüger-25/+25
Move `supertrait_def_ids` into the elaborate module like all other fns It's strange that this is the only elaborate-like fn on tcx. r? lcnr
2025-01-21Auto merge of #135487 - klensy:windows-0.59, r=Mark-Simulacrumbors-8/+8
bump compiler and tools to windows 0.59, bootstrap to 0.57 This bumps compiler and tools to windows 0.59 (temporary dupes version, as `sysinfo` still depend on <= 0.57). Bootstrap bumps only to 0.57 (the same sysinfo dep). This additionally resolves my comment https://github.com/rust-lang/rust/pull/130874#issuecomment-2393562071 Will work on it in follow up pr: There still some sus imports for `rustc_driver.dll` like ws2_32 or RoOriginateErrorW, but i will look at them later.
2025-01-21Detect missing fields with default values and suggest `..`Esteban Küber-0/+30
When a struct definition has default field values, and the use struct ctor has missing field, if all those missing fields have defaults suggest `..`: ``` error[E0063]: missing fields `field1` and `field2` in initializer of `S` --> $DIR/non-exhaustive-ctor.rs:16:13 | LL | let _ = S { field: () }; | ^ missing `field1` and `field2` | help: all remaining fields have defaults, use `..` | LL | let _ = S { field: (), .. }; | ++++ ```
2025-01-21Auto merge of #134299 - RalfJung:remove-start, r=compiler-errorsbors-441/+116
remove support for the (unstable) #[start] attribute As explained by `@Noratrieb:` `#[start]` should be deleted. It's nothing but an accidentally leaked implementation detail that's a not very useful mix between "portable" entrypoint logic and bad abstraction. I think the way the stable user-facing entrypoint should work (and works today on stable) is pretty simple: - `std`-using cross-platform programs should use `fn main()`. the compiler, together with `std`, will then ensure that code ends up at `main` (by having a platform-specific entrypoint that gets directed through `lang_start` in `std` to `main` - but that's just an implementation detail) - `no_std` platform-specific programs should use `#![no_main]` and define their own platform-specific entrypoint symbol with `#[no_mangle]`, like `main`, `_start`, `WinMain` or `my_embedded_platform_wants_to_start_here`. most of them only support a single platform anyways, and need cfg for the different platform's ways of passing arguments or other things *anyways* `#[start]` is in a super weird position of being neither of those two. It tries to pretend that it's cross-platform, but its signature is a total lie. Those arguments are just stubbed out to zero on ~~Windows~~ wasm, for example. It also only handles the platform-specific entrypoints for a few platforms that are supported by `std`, like Windows or Unix-likes. `my_embedded_platform_wants_to_start_here` can't use it, and neither could a libc-less Linux program. So we have an attribute that only works in some cases anyways, that has a signature that's a total lie (and a signature that, as I might want to add, has changed recently, and that I definitely would not be comfortable giving *any* stability guarantees on), and where there's a pretty easy way to get things working without it in the first place. Note that this feature has **not** been RFCed in the first place. *This comment was posted [in May](https://github.com/rust-lang/rust/issues/29633#issuecomment-2088596042) and so far nobody spoke up in that issue with a usecase that would require keeping the attribute.* Closes https://github.com/rust-lang/rust/issues/29633 try-job: x86_64-gnu-nopt try-job: x86_64-msvc-1 try-job: x86_64-msvc-2 try-job: test-various
2025-01-21Move supertrait_def_ids into the elaborate module like all other fnsMichael Goulet-25/+25
2025-01-21add fixme in typoed const pattern lintRémy Rakic-0/+6
2025-01-21remove support for the #[start] attributeRalf Jung-441/+116
2025-01-21bumpt compiler and tools to windows 0.59klensy-8/+8
2025-01-21rustc_resolve: don't open-code `Option::filter`Yotam Ofek-4/+1
2025-01-21rustc_resolve: use `Iterator` combinators instead of `for` loops where ↵Yotam Ofek-26/+12
applicable
2025-01-21rustc_resolve: reduce rightwards drift with `let..else` 👉💨Yotam Ofek-381/+387