about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2024-02-06llvm-wrapper: remove llvm 12 hackklensy-6/+1
effectively reverts https://github.com/rust-lang/rust/commit/9a8acea78355b604dbeb29bc38bd4dbf7bfce95f
2024-02-06Auto merge of #120392 - compiler-errors:async-bound-modifier, r=davidtwco,fmeasebors-36/+216
Introduce support for `async` bound modifier on `Fn*` traits Adds `async` to the list of `TraitBoundModifiers`, which instructs AST lowering to map the trait to an async flavor of the trait. For now, this is only supported for `Fn*` to `AsyncFn*`, and I expect that this manual mapping via lang items will be replaced with a better system in the future. The motivation for adding these bounds is to separate the users of async closures from the exact trait desugaring of their callable bounds. Instead of users needing to be concerned with the `AsyncFn` trait, they should be able to write `async Fn()` and it will desugar to whatever underlying trait we decide is best for the lowering of async closures. Note: rustfmt support can be done in the rustfmt repo after a subtree sync.
2024-02-05Auto merge of #120313 - Nadrieril:graceful-error, r=compiler-errorsbors-14/+18
pattern_analysis: Gracefully abort on type incompatibility This leaves the option for a consumer of the crate to return `Err` instead of panicking on type error. rust-analyzer could use that (e.g. https://github.com/rust-lang/rust-analyzer/issues/15808). Since the only use of `TypeCx::bug` is in `Constructor::is_covered_by`, it is tempting to return `false` instead of `Err()`, but that would cause "non-exhaustive match" false positives. r? `@compiler-errors`
2024-02-05Auto merge of #117372 - Amanieu:stdarch_update, r=Mark-Simulacrumbors-2/+58
Update stdarch submodule Splits up #27731 into multiple tracking issues. Closes #27731
2024-02-05Rollup merge of #120661 - xen0n:loong-medium-cmodel, r=heiher,NilstriebMatthias Krüger-3/+4
target: default to the medium code model on LoongArch targets The Rust LoongArch targets have been using the default LLVM code model so far, which is "small" in LLVM-speak and "normal" in LoongArch-speak. As [described][1] in the "Code Model" section of LoongArch ELF psABI spec v20231219, one can only make function calls as far as ±128MiB with the "normal" code model; this is insufficient for very large software containing Rust components that needs to be linked into the big text section, such as Chromium. Because: * we do not want to ask users to recompile std if they are to build such software, * objects compiled with larger code models can be linked with those with smaller code models without problems, and * the "medium" code model is comparable to the "small"/"normal" one performance-wise (same data access pattern; each function call becomes 2-insn long and indirect, but this may be relaxed back into the direct 1-insn form in a future LLVM version), but is able to perform function calls within ±128GiB, it is better to just switch the targets to the "medium" code model, which is also "medium" in LLVM-speak. [1]: https://github.com/loongson/la-abi-specs/blob/v2.30/laelf.adoc#code-models
2024-02-05Rollup merge of #120518 - kxxt:riscv-split-debug-info, r=compiler-errorsMatthias Krüger-5/+20
riscv only supports split_debuginfo=off for now Disable packed/unpacked options for riscv linux/android. Other riscv targets already only have the off option. The packed/unpacked options might be supported in the future. See upstream issue for more details: https://github.com/llvm/llvm-project/issues/56642 Fixes #110224
2024-02-05Rollup merge of #116284 - RalfJung:no-nan-match, r=cjgillotMatthias Krüger-95/+80
make matching on NaN a hard error, and remove the rest of illegal_floating_point_literal_pattern These arms would never be hit anyway, so the pattern makes little sense. We have had a future-compat lint against float matches in general for a *long* time, so I hope we can get away with immediately making this a hard error. This is part of implementing https://github.com/rust-lang/rfcs/pull/3535. Closes https://github.com/rust-lang/rust/issues/41620 by removing the lint. https://github.com/rust-lang/reference/pull/1456 updates the reference to match.
2024-02-05target: default to the medium code model on LoongArch targetsWANG Xuerui-3/+4
The Rust LoongArch targets have been using the default LLVM code model so far, which is "small" in LLVM-speak and "normal" in LoongArch-speak. As described in the "Code Model" section of LoongArch ELF psABI spec v20231219 [1], one can only make function calls as far as ±128MiB with the "normal" code model; this is insufficient for very large software containing Rust components that needs to be linked into the big text section, such as Chromium. Because: * we do not want to ask users to recompile std if they are to build such software, * objects compiled with larger code models can be linked with those with smaller code models without problems, and * the "medium" code model is comparable to the "small"/"normal" one performance-wise (same data access pattern; each function call becomes 2-insn long and indirect, but this may be relaxed back into the direct 1-insn form in a future LLVM version), but is able to perform function calls within ±128GiB, it is better to just switch the targets to the "medium" code model, which is also "medium" in LLVM-speak. [1]: https://github.com/loongson/la-abi-specs/blob/v2.30/laelf.adoc#code-models
2024-02-05Rollup merge of #120587 - lukas-code:miri-tail-normalize, r=RalfJungMatthias Krüger-1/+5
miri: normalize struct tail in ABI compat check fixes https://github.com/rust-lang/miri/issues/3282 extracted from https://github.com/rust-lang/rust/pull/120354, see https://github.com/rust-lang/rust/pull/120354#discussion_r1469154220 for context r? ```@RalfJung```
2024-02-05Rollup merge of #120569 - Zalathar:fn-sig, r=oli-obkMatthias Krüger-52/+56
coverage: Improve handling of function/closure spans This is a combination of some loosely-related changes that touch the same code: 1. Make unexpansion of closure bodies more precise, by unexpanding back to the context of the closure declaration, instead of unexpanding all the way back to the top-level context. This preserves the way we handle async desugaring and closures containing a single bang-macro, while also giving better results for closures defined in macros. 2. Skip the normal span-refinement code when dealing with the trivial outer part of an async function. 3. Be more explicit about the fact that `fn_sig_span` has been extended to the start of the function body, and is not necessarily present. --- `@rustbot` label +A-code-coverage
2024-02-05Rollup merge of #119600 - aDotInTheVoid:comment-fix, r=compiler-errorsMatthias Krüger-10/+9
Remove outdated references to librustc_middle The relevant comment is now in https://github.com/rust-lang/rust/blob/791a53f380d5cf800191f25941c94ace5099876e/compiler/rustc_middle/src/tests.rs#L3-L13
2024-02-05Auto merge of #120497 - compiler-errors:modulize, r=lcnrbors-1456/+1491
Move predicate, region, and const stuff into their own modules in middle This PR mostly moves things around, and in a few cases adds some `ty::` to the beginning of names to avoid one-off imports. I don't mean this to be the most *thorough* move/refactor. I just generally wanted to begin to split up `ty/mod.rs` and `ty/sty.rs` which are huge and hard to distinguish, and have a lot of non-ty stuff in them. r? lcnr
2024-02-05coverage: Make `fn_sig_span` optional, and note its quirksZalathar-11/+17
2024-02-05coverage: Hoist special handling of async function spansZalathar-26/+30
This sidesteps the normal span refinement code in cases where we know that we are only dealing with the special signature span that represents having called an async function.
2024-02-05coverage: Make unexpansion of closure bodies more preciseZalathar-18/+12
This improves the coverage instrumentation of closures declared in macros, as seen in `closure_macro.rs` and `closure_macro_async.rs`.
2024-02-04Auto merge of #120649 - matthiaskrgr:rollup-ek80j61, r=matthiaskrgrbors-130/+242
Rollup of 8 pull requests Successful merges: - #119759 (Add FileCheck annotations to dataflow-const-prop tests) - #120323 (On E0277 be clearer about implicit `Sized` bounds on type params and assoc types) - #120473 (Only suggest removal of `as_*` and `to_` conversion methods on E0308) - #120540 (add test for try-block-in-match-arm) - #120547 (`#![feature(inline_const_pat)]` is no longer incomplete) - #120552 (Correctly check `never_type` feature gating) - #120555 (put pnkfelix (me) back on the review queue.) - #120556 (Improve the diagnostics for unused generic parameters) r? `@ghost` `@rustbot` modify labels: rollup
2024-02-04Auto merge of #120624 - matthiaskrgr:rollup-3gvcl20, r=matthiaskrgrbors-110/+21
Rollup of 8 pull requests Successful merges: - #120484 (Avoid ICE when is_val_statically_known is not of a supported type) - #120516 (pattern_analysis: cleanup manual impls) - #120517 (never patterns: It is correct to lower `!` to `_`.) - #120523 (Improve `io::Read::read_buf_exact` error case) - #120528 (Store SHOULD_CAPTURE as AtomicU8) - #120529 (Update data layouts in custom target tests for LLVM 18) - #120531 (Remove a bunch of `has_errors` checks that have no meaningful or the wrong effect) - #120533 (Correct paths for hexagon-unknown-none-elf platform doc) r? `@ghost` `@rustbot` modify labels: rollup
2024-02-04Rollup merge of #120556 - fmease:improve-unused-generic-param-diags, r=oli-obkMatthias Krüger-57/+125
Improve the diagnostics for unused generic parameters * Don't emit two errors (namely E0091 *and* E0392) for unused type parameters on *lazy* type aliases * Fix the diagnostic help message of E0392 for *lazy* type aliases: Don't talk about the “fields” of lazy type aliases (use the term “body” instead) and don't suggest `PhantomData` for them, it doesn't make much sense * Consolidate the diagnostics for E0091 (unused type parameters in type aliases) and E0392 (unused generic parameters due to bivariance) and make it translatable * Still keep the error codes distinct (for now) * Naturally leads to better diagnostics for E0091 r? ```@oli-obk``` (to ballast your review load :P) or compiler
2024-02-04Rollup merge of #120552 - GuillaumeGomez:never-type-feature-gate, ↵Matthias Krüger-0/+13
r=compiler-errors Correctly check `never_type` feature gating Fixes #120542. The feature wasn't tested on return type of a generic function type, so it got under the radar in https://github.com/rust-lang/rust/pull/120316. r? ```@compiler-errors```
2024-02-04Rollup merge of #120547 - matthewjasper:complete-inline-const-pat, ↵Matthias Krüger-1/+1
r=compiler-errors `#![feature(inline_const_pat)]` is no longer incomplete Now that borrow checking and safety checking is implemented for inline constant patterns, the incomplete feature status is not necessary. Stabilizing this feature requires more testing and has some of the same unresolved questions as inline constants. cc #76001
2024-02-04Rollup merge of #120473 - estebank:issue-114329, r=TaKO8KiMatthias Krüger-0/+2
Only suggest removal of `as_*` and `to_` conversion methods on E0308 Instead of ``` error[E0308]: mismatched types --> tests/ui/suggestions/only-suggest-removal-of-conversion-method-calls.rs:9:5 | 4 | fn get_name() -> String { | ------ expected `String` because of return type ... 9 | your_name.trim() | ^^^^^^^^^^^^^^^^ expected `String`, found `&str` | help: try removing the method call | 9 - your_name.trim() 9 + your_name ``` output ``` error[E0308]: mismatched types --> $DIR/only-suggest-removal-of-conversion-method-calls.rs:9:5 | LL | fn get_name() -> String { | ------ expected `String` because of return type ... LL | your_name.trim() | ^^^^^^^^^^^^^^^^- help: try using a conversion method: `.to_string()` | | | expected `String`, found `&str` ``` Fix #114329.
2024-02-03Rollup merge of #120531 - oli-obk:track_errors7, r=estebankMatthias Krüger-13/+1
Remove a bunch of `has_errors` checks that have no meaningful or the wrong effect r? `@nnethercote`
2024-02-03Rollup merge of #120517 - Nadrieril:lower-never-as-wildcard, r=compiler-errorsMatthias Krüger-2/+3
never patterns: It is correct to lower `!` to `_`. This is just a comment update but a non-trivial one: it is correct to lower `!` patterns as `_`. The reasoning is that `!` matches all the possible values of the type, since the type is empty. Moreover, we do want to warn that the `Err` is redundant in: ```rust match x { !, Err(!), } ``` which is consistent with `!` behaving like a wildcard. I did try to introduce `Constructor::Never` and it ended up needing to behave exactly like `Constructor::Wildcard`. r? ```@compiler-errors```
2024-02-03Rollup merge of #120516 - Nadrieril:cleanup-impls, r=compiler-errorsMatthias Krüger-91/+4
pattern_analysis: cleanup manual impls https://github.com/rust-lang/rust/pull/120420 introduced some unneeded manual impls. I remove them here. r? ```@Nilstrieb```
2024-02-03Rollup merge of #120484 - Teapot4195:issue-120480-fix, r=compiler-errorsMatthias Krüger-4/+13
Avoid ICE when is_val_statically_known is not of a supported type 2 ICE with 1 stone! 1. Implement `llvm.is.constant.ptr` to avoid first ICE in linked issue. 2. return `false` when the argument is not one of `i*`/`f*`/`ptr` to avoid second ICE. fixes #120480
2024-02-03Rollup merge of #120616 - fmease:fix-ice-const-eval-fail-undef-field-access, ↵Matthias Krüger-1/+5
r=compiler-errors Fix ICE on field access on a tainted type after const-eval failure Fixes #120615. r? oli-obk or compiler
2024-02-03Rollup merge of #120610 - petrochenkov:maybeownogen, r=cjgillotMatthias Krüger-32/+17
hir: Remove the generic type parameter from `MaybeOwned` It's only ever used with a reference to `OwnerInfo` as an argument. Follow up to https://github.com/rust-lang/rust/pull/120346.
2024-02-03Rollup merge of #120592 - trevyn:cleanup-to-string, r=NilstriebMatthias Krüger-15/+15
Remove unnecessary `.to_string()`/`.as_str()`s
2024-02-03Rollup merge of #120573 - nnethercote:rm-BorrowckErrors-tainted_by_errors, ↵Matthias Krüger-91/+88
r=oli-obk Remove `BorrowckErrors::tainted_by_errors` This PR removes one of the `tainted_by_errors` occurrences, replacing it with direct use of `ErrorGuaranteed`. r? `@oli-obk`
2024-02-03Rollup merge of #120571 - nnethercote:misc-diagnostics, r=oli-obkMatthias Krüger-152/+108
Miscellaneous diagnostics cleanups All found while working on some speculative, invasive changes, but worth doing in their own right. r? `@oli-obk`
2024-02-03Rollup merge of #120570 - fmease:change-ty-to-ct-param-sugg, r=compiler-errorsMatthias Krüger-14/+82
Suggest changing type to const parameters if we encounter a type in the trait bound position The first commit is just drive-by cleanup. Provide a structured suggestion if the user forgot to prefix a “const parameter” with `const`, e.g., in `struct Tagged<TAG: u64>;`. This happens to me from time to time. Maybe C++ devs are also prone to this mistake given template syntax looks like `template<typename T, uint32_t N>`.
2024-02-03Rollup merge of #119543 - usamoi:avx512fp16, r=oli-obkMatthias Krüger-1/+2
add avx512fp16 to x86 target features std_detect avx512fp16: https://github.com/rust-lang/stdarch/pull/1508
2024-02-03Check for presence of field in typeck results before visiting itLeón Orell Valerian Liehr-1/+5
Co-authored-by: Michael Goulet <michael@errs.io>
2024-02-03hir: Remove the generic type parameter from `MaybeOwned`Vadim Petrochenkov-32/+17
It's only ever used with a reference to `OwnerInfo` as an argument.
2024-02-02Remove unnecessary `.to_string()`/`.as_str()`strevyn-15/+15
2024-02-03Use `StringPart` more.Nicholas Nethercote-43/+38
2024-02-03Simplify future breakage control flow.Nicholas Nethercote-18/+8
`emit_future_breakage` calls `self.dcx().take_future_breakage_diagnostics()` and then passes the result to `self.dcx().emit_future_breakage_report(diags)`. This commit removes the first of these and lets `emit_future_breakage_report` do the taking. It also inlines and removes what is left of `emit_future_breakage`, which has a single call site.
2024-02-03Fix an incorrect comment.Nicholas Nethercote-1/+1
2024-02-03Improve a local variable name.Nicholas Nethercote-2/+2
2024-02-03Use `DiagnosticArgName` in a few more places.Nicholas Nethercote-17/+18
2024-02-03Remove some unnecessary `clone` calls.Nicholas Nethercote-6/+4
2024-02-03`SilentEmitter::fatal_note` doesn't need to be optional.Nicholas Nethercote-13/+11
2024-02-03`Diagnostic` cleanupsNicholas Nethercote-26/+9
- `emitted_at` isn't used outside the crate. - `code` and `messages` are public fields, so there's no point have trivial getters/setters for them. - `suggestions` is public, so the comment about "functionality on `Diagnostic`" isn't needed.
2024-02-03Remove an out-of-date comment.Nicholas Nethercote-1/+0
`DiagnosticBuilderInner` was removed some time ago.
2024-02-03Make some fatal errors more concise.Nicholas Nethercote-5/+3
2024-02-02miri: normalize struct tail in ABI compat checkLukas Markeffsky-1/+5
2024-02-02Rename `BorrowckErrors` as `BorrowckDiags`.Nicholas Nethercote-26/+26
And some related things. Because it can hold non-error diagnostics.
2024-02-02Inline and remove `DiagnosticBuilder::into_diagnostic`.Nicholas Nethercote-7/+2
It now has a single call site.
2024-02-02Remove `BorrowckErrors::tainted_by_errors`.Nicholas Nethercote-59/+66
`BorrowckErrors` stores a mix of error and non-error diags in `buffered`. As a result, it downgrades `DiagnosticBuilder`s to `Diagnostic`s, losing the emission guarantees, and so has to use a `tainted_by_errors` field to record whether an error has occurred. This commit splits `buffered` into `buffered_errors` and `buffered_non_errors`, keeping them as `DiagnosticBuilder`s and preserving the emission guarantees. This also requires fixing a bunch of incorrect lifetimes on `DiagnosticBuilder` use points.
2024-02-02Remove `BorrowckErrors::set_tainted_by_errors`.Nicholas Nethercote-5/+0
It has no effect. Note that `infcx.set_tainted_by_errors()` is still called, so taintedness is still being propagated.