about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2023-11-28Fix coroutine validation for mixed panic strategyTomasz Miąsko-12/+4
Validation introduced in #113124 allows UnwindAction::Continue and TerminatorKind::Resume to occur only in functions with ABI that can unwind. The function ABI depends on the panic strategy, which can vary across crates. Usually MIR is built and validated in the same crate. The coroutine drop glue thus far was an exception. As a result validation could fail when mixing different panic strategies. Avoid the problem by executing AbortUnwindingCalls along with the validation.
2023-11-28thir-unsafeck: print list of missing target features when calling a function ↵Eduardo Sánchez Muñoz-19/+122
with target features outside an unsafe block
2023-11-28Fix spans for bad await in inline constMichael Goulet-17/+18
2023-11-28Eagerly return ExprKind::Err on yield/await in wrong coroutine contextMichael Goulet-3/+3
2023-11-28Suggest `let` or `==` on typo'd let-chainEsteban Küber-8/+70
When encountering a bare assignment in a let-chain, suggest turning the assignment into a `let` expression or an equality check. ``` error: expected expression, found `let` statement --> $DIR/bad-if-let-suggestion.rs:5:8 | LL | if let x = 1 && i = 2 {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions help: you might have meant to continue the let-chain | LL | if let x = 1 && let i = 2 {} | +++ help: you might have meant to compare for equality | LL | if let x = 1 && i == 2 {} | + ```
2023-11-28fix the issue of suggest unwrap/expect for shorthand fieldyukang-0/+6
2023-11-28Rollup merge of #118378 - cormacrelf:bugfix/linker-plugin-lto-wasm, ↵Matthias Krüger-1/+27
r=petrochenkov Perform LTO optimisations with wasm-ld + -Clinker-plugin-lto Fixes (partially) #60059. Technically, `--target wasm32-unknown-unknown -Clinker-plugin-lto` would complete without errors before, but it was not producing optimized code. At least, it may have been but it was probably not the opt-level people intended. Similarly to #118377, this could benefit from a warning about using an explicit libLTO path with LLD, which will ignore it and use its internal LLVM. Especially given we always use lld on wasm targets. I left the code open to that possibility rather than making it perfectly neat.
2023-11-28def collector: Set correct namespace in `DefPathData` for foreign typesVadim Petrochenkov-16/+10
2023-11-28resolve: Feed the `def_kind` query immediately on `DefId` creationVadim Petrochenkov-171/+160
2023-11-28unwrap return Option value, as it always returns Some for some fnsklensy-29/+19
2023-11-28move write_aggregate into step file, and also extract write_repeat into ↵Ralf Jung-60/+72
separate function
2023-11-28Name explicit registers in conflict register errors for inline assemblyGeorge Wort-6/+27
2023-11-28Auto merge of #118405 - matthiaskrgr:rollup-3a2eevc, r=matthiaskrgrbors-5/+11
Rollup of 7 pull requests Successful merges: - #115331 (optimize str::iter::Chars::advance_by) - #118236 (Update mod comment) - #118299 (Update `OnceLock` documentation to give a concrete 'lazy static' example, and expand on the existing example.) - #118314 (Rename `{collections=>alloc}{tests,benches}`) - #118341 (Simplify indenting in THIR printing) - #118366 (Detect and reject malformed `repr(Rust)` hints) - #118397 (Fix comments for unsigned non-zero `checked_add`, `saturating_add`) r? `@ghost` `@rustbot` modify labels: rollup
2023-11-28Rollup merge of #118366 - fmease:detect-reject-malformed-rust-repr, ↵Matthias Krüger-3/+3
r=compiler-errors Detect and reject malformed `repr(Rust)` hints Fixes #118334.
2023-11-28Rollup merge of #118341 - Mark-Simulacrum:shrink-thir-print, r=compiler-errorsMatthias Krüger-2/+8
Simplify indenting in THIR printing This cuts >100kb from a local librustc_driver.so build, and seems just obviously simpler.
2023-11-28Auto merge of #118282 - fee1-dead-contrib:enforce-more, r=compiler-errorsbors-16/+28
effects: Run `enforce_context_effects` for all method calls So that we also perform checks when overloaded `PartialEq`s are called. r? `@compiler-errors`
2023-11-28Remove unnecessary `Option` from ↵Nicholas Nethercote-16/+19
`LoweringContext::allow_{try_trait,gen_future}`. Also remove some unnecessary slicing.
2023-11-28Add `LoweringContext::new`.Nicholas Nethercote-37/+41
2023-11-28Create `LoweringContext::lower_assoc_item`.Nicholas Nethercote-31/+37
By moving most of `ItemLowerer::lower_assoc_item` into it. This is similar to `LoweringContext::lower_foreign_item`.
2023-11-28Avoid an unnecessary `by_ref`.Nicholas Nethercote-1/+1
2023-11-28Reduce exposure of some things.Nicholas Nethercote-3/+3
2023-11-28Remove unused feature.Nicholas Nethercote-1/+0
2023-11-28Remove a comment.Nicholas Nethercote-1/+0
It was merged by accident in a previous PR.
2023-11-28Pass +forced-atomics feature for riscv32{i,im,imc}-unknown-none-elfTaiki Endo-5/+6
2023-11-28Remove `hir::BinOp`, `hir::BinOpKind`, and `hir::UnOp`.Nicholas Nethercote-178/+17
They're identical to the same-named types from `ast`. I find it silly (and inefficient) to have all this boilerplate code to convert one type to an identical type. There is already a small amount of type sharing between the AST and HIR, e.g. `Attribute`, `MacroDef`. The commit adds a `pub use` to `rustc_hir` so that, for example, `ast::BinOp` can also be referred to as `hir::BinOp`. This is so the many existing `hir`-qualified mentions of these types don't need to change. The commit also moves a couple of operations from the (removed) HIR types to the AST types, e.g. `is_by_value`.
2023-11-27Rollup merge of #118382 - shepmaster:unused-tuple-struct-field-cleanup, ↵Michael Goulet-9/+8
r=compiler-errors Address unused tuple struct fields in the compiler r? `@compiler-errors`
2023-11-27Rollup merge of #118381 - Enselic:edit-dist-len, r=WaffleLapkinMichael Goulet-1/+5
rustc_span: Use correct edit distance start length for suggestions Otherwise the suggestions can be off-base for non-ASCII identifiers. For example suggesting that `Ok` is a name similar to `读文`. Closes https://github.com/rust-lang/rust/issues/72553.
2023-11-27Rollup merge of #118374 - klensy:collect_active_jobs, r=compiler-errorsMichael Goulet-20/+14
QueryContext: rename try_collect_active_jobs -> collect_active_jobs, change return type from Option<QueryMap> to QueryMap As there currently always Some(...) inside.
2023-11-27Rollup merge of #118202 - azhogin:azhogin/link_args_wrapping, r=petrochenkovMichael Goulet-34/+40
Added linker_arg(s) Linker trait methods for link-arg to be prefixed "-Wl," for cc-like linker args and not verbatim https://github.com/rust-lang/rust/issues/99427#issuecomment-1234443468 > here's one possible improvement to -l link-arg making it more portable between linkers and useful - befriending it with the verbatim modifier (https://github.com/rust-lang/rust/issues/99425). > > -l link-arg:-verbatim=-foo would add -Wl,-foo (or equivalent) when C compiler is used as a linker, and just -foo when bare linker is used. > -l link-arg:+verbatim=-bar on the other hand would always pass just -bar.
2023-11-27Rollup merge of #118172 - ouz-a:improve_emit_stable1, r=celinvalMichael Goulet-18/+286
Add `pretty_terminator` to pretty stable-mir ~Because we don't have successors in `stable_mir` this is somewhat lacking but it's better than nothing~, also fixed bug(?) with `Opaque` which printed extra `"` when we try to print opaqued `String`. **Edit**: Added successors so this covers Terminators as a whole. r? `@celinval`
2023-11-27Rollup merge of #117526 - estebank:issue-24157, r=b-naberMichael Goulet-4/+41
Account for `!` arm in tail `match` expr On functions with a default return type that influences the coerced type of `match` arms, check if the failing arm is actually of type `!`. If so, suggest changing the return type so the coercion against the prior arms is successful. ``` error[E0308]: `match` arms have incompatible types --> $DIR/match-tail-expr-never-type-error.rs:9:13 | LL | fn bar(a: bool) { | - help: try adding a return type: `-> i32` LL | / match a { LL | | true => 1, | | - this is found to be of type `{integer}` LL | | false => { LL | | never() | | ^^^^^^^ | | | | | expected integer, found `()` | | this expression is of type `!`, but it get's coerced to `()` due to its surrounding expression LL | | } LL | | } | |_____- `match` arms have incompatible types ``` Fix #24157.
2023-11-27Rollup merge of #111133 - hkmatsumoto:handle-python-slicing, r=TaKO8KiMichael Goulet-11/+33
Detect Python-like slicing and suggest how to fix Fix #108215
2023-11-28Rename `BinOpKind::lazy` as `BinOpKind::is_lazy`.Nicholas Nethercote-4/+5
To match `BinOpKind::is_comparison` and `hir::BinOpKind::is_lazy`.
2023-11-28Rework `ast::BinOpKind::to_string` and `ast::UnOp::to_string`.Nicholas Nethercote-8/+8
- Rename them both `as_str`, which is the typical name for a function that returns a `&str`. (`to_string` is appropriate for functions returning `String` or maybe `Cow<'a, str>`.) - Change `UnOp::as_str` from an associated function (weird!) to a method. - Avoid needless `self` dereferences.
2023-11-27Auto merge of #117947 - Dirbaio:drop-llvm-15, r=cuviperbors-131/+35
Update the minimum external LLVM to 16. With this change, we'll have stable support for LLVM 16 and 17. For reference, the previous increase to LLVM 15 was #114148 [Relevant zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/riscv.20forced-atomics)
2023-11-27Auto merge of #117200 - rmehri01:repeated_help, r=WaffleLapkinbors-34/+76
Don't add redundant help for object safety violations Fixes #117186 r? WaffleLapkin
2023-11-27Address unused tuple struct fields in the compilerJake Goulding-9/+8
2023-11-27add otherwise into targetsouz-a-3/+5
2023-11-27Print list of missing target features when calling a function with target ↵Eduardo Sánchez Muñoz-57/+123
features outside an unsafe block
2023-11-27rustc_span: Use correct edit distance start length for suggestionsMartin Nordholts-1/+5
Otherwise the suggestions can be off-base for non-ASCII identifiers. For example suggesting that `Ok` is a name similar to `读文`.
2023-11-27Auto merge of #118118 - spastorino:do-not-erase-late-bound-regions-on-iat, ↵bors-116/+104
r=compiler-errors Do not erase late bound regions when selecting inherent associated types In the fix for #97156 we would want the following code: ```rust #![feature(inherent_associated_types)] #![allow(incomplete_features)] struct Foo<T>(T); impl Foo<fn(&'static ())> { type Assoc = u32; } trait Other {} impl Other for u32 {} // FIXME(inherent_associated_types): Avoid emitting two diagnostics (they only differ in span). // FIXME(inherent_associated_types): Enhancement: Spruce up the diagnostic by saying something like // "implementation is not general enough" as is done for traits via // `try_report_trait_placeholder_mismatch`. fn bar(_: Foo<for<'a> fn(&'a ())>::Assoc) {} //~^ ERROR mismatched types //~| ERROR mismatched types fn main() {} ``` to fail with ... ``` error[E0220]: associated type `Assoc` not found for `Foo<for<'a> fn(&'a ())>` in the current scope --> tests/ui/associated-inherent-types/issue-109789.rs:18:36 | 4 | struct Foo<T>(T); | ------------- associated item `Assoc` not found for this struct ... 18 | fn bar(_: Foo<for<'a> fn(&'a ())>::Assoc) {} | ^^^^^ associated item not found in `Foo<for<'a> fn(&'a ())>` | = note: the associated type was found for - `Foo<fn(&'static ())>` error: aborting due to previous error For more information about this error, try `rustc --explain E0220`. ``` This PR fixes the ICE we are currently getting "was a subtype of Foo<Binder(fn(&ReStatic ()), [])> during selection but now it is not" Also fixes #112631 r? `@lcnr`
2023-11-27Account for `!` arm in tail `match` exprEsteban Küber-4/+41
On functions with a default return type that influences the coerced type of `match` arms, check if the failing arm is actually of type `!`. If so, suggest changing the return type so the coercion against the prior arms is successful. ``` error[E0308]: `match` arms have incompatible types --> $DIR/match-tail-expr-never-type-error.rs:9:13 | LL | fn bar(a: bool) { | - help: try adding a return type: `-> i32` LL | / match a { LL | | true => 1, | | - this is found to be of type `{integer}` LL | | false => { LL | | never() | | ^^^^^^^ | | | | | expected integer, found `()` | | this expression is of type `!`, but it get's coerced to `()` due to its surrounding expression LL | | } LL | | } | |_____- `match` arms have incompatible types ``` Fix #24157.
2023-11-28Perform LTO optimisations with wasm-ld + -Clinker-plugin-ltoCormac Relf-1/+27
2023-11-27QueryContext: rename try_collect_active_jobs -> collect_active_jobs and ↵klensy-20/+14
change it's return type from Option<QueryMap> to QueryMap As there currently always Some(...) inside
2023-11-27Added linker_arg(s) Linker trait methods for link-arg to be prefixed "-Wl," ↵Andrew Zhogin-34/+40
for cc-like linker args and not verbatim
2023-11-27Rollup merge of #118359 - hkmatsumoto:suggest-box-ref, r=TaKO8KiTakayuki Maeda-2/+19
Suggest swapping the order of `ref` and `box` It is not valid grammar to write `ref box <ident>` in patterns, but `box ref <ident>` is. This patch adds a diagnostic to suggest swapping them, analogous to what we do for `mut let`.
2023-11-27Rollup merge of #118340 - compiler-errors:tweaks, r=lqdTakayuki Maeda-10/+10
Use helper functions in `pretty.rs` instead of accessing the `Cell`s manually Pulled this out of another PR that I never landed.
2023-11-27Rollup merge of #118095 - ferrocene:apply-cortex-a53-fix, r=davidtwcoTakayuki Maeda-0/+5
Enable the Arm Cortex-A53 errata mitigation on aarch64-unknown-none Arm Cortex-A53 CPUs have an errata related to a specific sequence of instructions - errata number 843419 (https://documentation-service.arm.com/static/5fa29fddb209f547eebd361d). There is a mitigation that can be applied at link-time which detects the when sequence of instructions exists at a specific alignment. When detected, the linker re-writes those instructions and either changes an ADRP to an ADR, or bounces to a veneer to break the sequence. The linker argument to enable the mitigation is "--fix-cortex-a53-843419", and this is supported by GNU ld and LLVM lld. The gcc argument to enable the flag is "-mfix-cortex-a53-843419". Because the aarch64-unknown-none target uses rust-lld directly, this patch causes rustc to emit the "--fix-cortex-a53-843419" argument when calling the linker, just like aarch64-linux-gnu-gcc on Ubuntu 22.04 does. Failure to enable this mitigation in the linker can cause the production of instruction sequences that do not execute correctly on Arm Cortex-A53.
2023-11-27Change help message to make some sense in broader contextHirochika Matsumoto-1/+1
2023-11-27Address review feedbacksHirochika Matsumoto-16/+17
Also addressed merge conflicts upon rebasing.