about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2024-07-12Auto merge of #127382 - estebank:const-let, r=compiler-errorsbors-26/+56
Use verbose style when suggesting changing `const` with `let`
2024-07-11Auto merge of #127614 - matthiaskrgr:rollup-8geziwi, r=matthiaskrgrbors-81/+125
Rollup of 8 pull requests Successful merges: - #124599 (Suggest borrowing on fn argument that is `impl AsRef`) - #127572 (Don't mark `DEBUG_EVENT` struct as `repr(packed)`) - #127588 (core: Limit remaining f16 doctests to x86_64 linux) - #127591 (Make sure that labels are defined after the primary span in diagnostics) - #127598 (Allows `#[diagnostic::do_not_recommend]` to supress trait impls in suggestions as well) - #127599 (Rename `lazy_cell_consume` to `lazy_cell_into_inner`) - #127601 (check is_ident before parse_ident) - #127605 (Remove extern "wasm" ABI) r? `@ghost` `@rustbot` modify labels: rollup
2024-07-11Account for `let foo = expr`; to suggest `const foo: Ty = expr;`Esteban Küber-22/+51
2024-07-11Use verbose style when suggesting changing `const` with `let`Esteban Küber-5/+6
2024-07-11Rollup merge of #127605 - nikic:remove-extern-wasm, r=oli-obkMatthias Krüger-59/+24
Remove extern "wasm" ABI Remove the unstable `extern "wasm"` ABI (`wasm_abi` feature tracked in #83788). As discussed in https://github.com/rust-lang/rust/pull/127513#issuecomment-2220410679 and following, this ABI is a failed experiment that did not end up being used for anything. Keeping support for this ABI in LLVM 19 would require us to switch wasm targets to the `experimental-mv` ABI, which we do not want to do. It should be noted that `Abi::Wasm` was internally used for two things: The `-Z wasm-c-abi=legacy` ABI that is still used by default on some wasm targets, and the `extern "wasm"` ABI. Despite both being `Abi::Wasm` internally, they were not the same. An explicit `extern "wasm"` additionally enabled the `+multivalue` feature. I've opted to remove `Abi::Wasm` in this patch entirely, instead of keeping it as an ABI with only internal usage. Both `-Z wasm-c-abi` variants are now treated as part of the normal C ABI, just with different different treatment in adjust_for_foreign_abi.
2024-07-11Rollup merge of #127601 - trevyn:issue-127600, r=compiler-errorsMatthias Krüger-2/+2
check is_ident before parse_ident Closes #127600
2024-07-11Rollup merge of #127598 - ↵Matthias Krüger-0/+19
weiznich:diagnostic_do_not_recommend_also_skips_help, r=compiler-errors Allows `#[diagnostic::do_not_recommend]` to supress trait impls in suggestions as well This commit changes the error reporting mechanism for not implemented traits to skip impl marked as `#[diagnostic::do_not_recommend]` in the help part of the error message ("the following other types implement trait `Foo`:"). The main use case here is to allow crate authors to skip non-meaningful confusing suggestions. A common example for this are fully generic impls on tuples. Related to https://github.com/rust-lang/rust/issues/51992 r? `@compiler-errors`
2024-07-11Rollup merge of #127591 - compiler-errors:label-after-primary, r=lcnrMatthias Krüger-1/+10
Make sure that labels are defined after the primary span in diagnostics Putting a `#[label]` before a `#[primary_span]` results in that label being overwritten, due to the semantics of `Diagnostic::span` and the fact that labels are stored in the `MultiSpan` of the diagnostic. This isn't possible to fix in general, since a lot of code actually *relies* in this overwriting behavior (e.g. `rustc_on_unimplemented`). However, it's useful to enforce this for derive-diagnostics, since this is certainly never what you intend to do in a derived diagnostic, where all the fields are meaningful parts of the diagnostic being rendered. This only matters for `#[label]`, since those are the ones stored in the `MultiSpan` of the error. We could also make this "just work" by sorting the attrs or processing the primary span attr first, however I think it's kinda pointless to do. There was 1 case where this mattered, but we literally didn't have a test exercising that diagnostic 🙃
2024-07-11Rollup merge of #124599 - estebank:issue-41708, r=wesleywiserMatthias Krüger-19/+70
Suggest borrowing on fn argument that is `impl AsRef` When encountering a move conflict, on an expression that is `!Copy` passed as an argument to an `fn` that is `impl AsRef`, suggest borrowing the expression. ``` error[E0382]: use of moved value: `bar` --> f204.rs:14:15 | 12 | let bar = Bar; | --- move occurs because `bar` has type `Bar`, which does not implement the `Copy` trait 13 | foo(bar); | --- value moved here 14 | let baa = bar; | ^^^ value used here after move | help: borrow the value to avoid moving it | 13 | foo(&bar); | + ``` Fix #41708
2024-07-11Auto merge of #127487 - tgross35:f16-f128-simd, r=Amanieubors-0/+2
Add `f16` and `f128` as simd types in LLVM `@sayantn` is working on adding SIMD for `f16` and hitting the `FloatingPointVector` error. This should fix it and unblock adding support for `simd_fma` and `simd_fabs` in stdarch.
2024-07-11Auto merge of #127311 - oli-obk:do_not_count_errors, r=compiler-errorsbors-0/+3
Avoid follow-up errors and ICEs after missing lifetime errors on data structures Tuple struct constructors are functions, so when we call them typeck will use the signature tuple struct constructor function to provide type hints. Since typeck mostly ignores and erases lifetimes, we end up never seeing the error lifetime in writeback, thus not tainting the typeck result. Now, we eagerly taint typeck results by tainting from `resolve_vars_if_possible`, which is called all over the place. I did not carry over all the `crashes` test suite tests, as they are really all the same cause (missing or unknown lifetime names in tuple struct definitions or generic arg lists). fixes #124262 fixes #124083 fixes #125155 fixes #125888 fixes #125992 fixes #126666 fixes #126648 fixes #127268 fixes #127266 fixes #127304
2024-07-11Avoid follow-up errors and ICEs after missing lifetime errors on data structuresOli Scherer-0/+3
2024-07-11Remove extern "wasm" ABINikita Popov-59/+24
Remove the unstable `extern "wasm"` ABI (`wasm_abi` feature tracked in #83788). As discussed in https://github.com/rust-lang/rust/pull/127513#issuecomment-2220410679 and following, this ABI is a failed experiment that did not end up being used for anything. Keeping support for this ABI in LLVM 19 would require us to switch wasm targets to the `experimental-mv` ABI, which we do not want to do. It should be noted that `Abi::Wasm` was internally used for two things: The `-Z wasm-c-abi=legacy` ABI that is still used by default on some wasm targets, and the `extern "wasm"` ABI. Despite both being `Abi::Wasm` internally, they were not the same. An explicit `extern "wasm"` additionally enabled the `+multivalue` feature. I've opted to remove `Abi::Wasm` in this patch entirely, instead of keeping it as an ABI with only internal usage. Both `-Z wasm-c-abi` variants are now treated as part of the normal C ABI, just with different different treatment in adjust_for_foreign_abi.
2024-07-11check is_ident before parse_identtrevyn-2/+2
2024-07-11Auto merge of #127097 - compiler-errors:async-closure-lint, r=oli-obkbors-18/+152
Implement simple, unstable lint to suggest turning closure-of-async-block into async-closure We want to eventually suggest people to turn `|| async {}` to `async || {}`. This begins doing that. It's a pretty rudimentary lint, but I wanted to get something down so I wouldn't lose the code. Tracking: * #62290
2024-07-11Allows `#[diagnostic::do_not_recommend]` to supress trait impls in ↵Georg Semmler-0/+19
suggestions as well This commit changes the error reporting mechanism for not implemented traits to skip impl marked as `#[diagnostic::do_not_recommend]` in the help part of the error message ("the following other types implement trait `Foo`:"). The main use case here is to allow crate authors to skip non-meaningful confusing suggestions. A common example for this are fully generic impls on tuples.
2024-07-11Auto merge of #127575 - chenyukang:yukang-fix-struct-fields-ice, ↵bors-26/+56
r=compiler-errors Avoid "no field" error and ICE on recovered ADT variant Fixes https://github.com/rust-lang/rust/issues/126744 Fixes https://github.com/rust-lang/rust/issues/126344, a more general fix compared with https://github.com/rust-lang/rust/pull/127426 r? `@oli-obk` From `@compiler-errors` 's comment https://github.com/rust-lang/rust/pull/127502#discussion_r1669538204 Seems most of the ADTs don't have taint, so maybe it's not proper to change `TyCtxt::type_of` query.
2024-07-10Fix diagnostic and add a test for itMichael Goulet-1/+1
2024-07-10Make sure that labels are defined after the primary span in diagnosticsMichael Goulet-0/+9
2024-07-10Auto merge of #127560 - oli-obk:safe_clobber, r=nnethercotebors-14/+3
Make `visit_clobber`'s impl safe This was originally introduced in #58061 but I didn't see any perf discussion about it, so let's see what perf says. r? `@nnethercote`
2024-07-10Auto merge of #127419 - trevyn:issue-125446, r=fee1-deadbors-61/+101
Add suggestions for possible missing `fn`, `struct`, or `enum` keywords Closes #125446 Closes #65381
2024-07-11report pat no field error no recoverd struct variantyukang-26/+56
2024-07-10Rollup merge of #127570 - lcnr:normalize-cool, r=compiler-errorsMatthias Krüger-13/+10
small normalization improvement r? `@compiler-errors`
2024-07-10Rollup merge of #127568 - lcnr:undo-leakcheck, r=oli-obkMatthias Krüger-54/+12
instantiate higher ranked goals in candidate selection again This reverts #119820 as that PR has a significant impact and breaks code which *feels like it should work*. The impact ended up being larger than we expected during the FCP and we've ended up with some ideas for how we can work around this issue in the next solver. This has been discussed in the previous high bandwidth t-types meeting: https://rust-lang.zulipchat.com/#narrow/stream/326132-t-types.2Fmeetings/topic/2024-07-09.20high.20bandwidth.20meeting. We'll therefore keep this inconsistency between the two solvers for now and will have to deal with it before stabilizating the use of the new solver outside of coherence: https://github.com/rust-lang/trait-system-refactor-initiative/issues/120. fixes #125194 after a beta-backport. The pattern which is more widely used than expected and feels like it should work, especially without deep knowledge of the type system is ```rust trait Trait<'a> {} impl<'a, T> Trait<'a> for T {} fn trait_bound<T: for<'a> Trait<'a>>() {} // A function with a where-bound which is more restrictive than the impl. fn function1<T: Trait<'static>>() { // stable: ok // with #119820: error as we prefer the where-bound over the impl // with this PR: back to ok trait_bound::<T>(); } ``` r? `@rust-lang/types`
2024-07-10Rollup merge of #127094 - Borgerr:E0191-suggestion-correction, r=fmeaseMatthias Krüger-1/+13
E0191 suggestion correction, inserts turbofish closes #91997
2024-07-10simplify and future-proof `needs_normalization`lcnr-13/+10
2024-07-10instantiate higher ranked goals in candidate selectionlcnr-54/+12
reverts #119820
2024-07-10Update `Cargo.lock` and remove duplicated implGuillaume Gomez-10/+6
2024-07-10Merge commit '98ed962c7d3eebe12c97588e61245273d265e72f' into masterGuillaume Gomez-1137/+2684
2024-07-10Make `visit_clobber`'s impl safeOli Scherer-14/+3
2024-07-10Auto merge of #127549 - jhpratt:rollup-o1mbmhr, r=jhprattbors-35/+201
Rollup of 8 pull requests Successful merges: - #124211 (Bump `elided_lifetimes_in_associated_constant` to deny) - #125627 (migration lint for `expr2024` for the edition 2024) - #127091 (impl FusedIterator and a size hint for the error sources iter) - #127461 (Fixup failing fuchsia tests) - #127484 (`#[doc(alias)]`'s doc: say that ASCII spaces are allowed) - #127508 (small search graph refactor) - #127521 (Remove spastorino from SMIR) - #127532 (documentation: update cmake version) r? `@ghost` `@rustbot` modify labels: rollup
2024-07-10Rollup merge of #127508 - lcnr:search-graph-prep, r=compiler-errorsJacob Pratt-34/+32
small search graph refactor small improvements which shouldn't impact behavior. r? ``````@compiler-errors``````
2024-07-10Rollup merge of #125627 - vincenzopalazzo:macros/cargo-fix-expr2024, ↵Jacob Pratt-0/+168
r=compiler-errors,eholk migration lint for `expr2024` for the edition 2024 This is adding a migration lint for the current (in the 2021 edition and previous) to move expr to expr_2021 from expr Issue https://github.com/rust-lang/rust/issues/123742 I created also a repository to test out the migration https://github.com/vincenzopalazzo/expr2024-cargo-fix-migration Co-Developed-by: ``@eholk``
2024-07-10Rollup merge of #124211 - ↵Jacob Pratt-1/+1
compiler-errors:bump-elided_lifetimes_in_associated_constant, r=BoxyUwU Bump `elided_lifetimes_in_associated_constant` to deny It's been 5 versions since this was last bumped. Let's bump it up again.
2024-07-10Auto merge of #127496 - tgross35:f16-f128-pattern-fixme, r=Nadrierilbors-1/+2
Update `f16`/`f128` FIXMEs that needed `(NEG_)INFINITY` Just a small fix to the pattern matching tests now that we can. Also contains a small unrelated comment tweak.
2024-07-10Auto merge of #127495 - compiler-errors:more-trait-error-reworking, r=lcnrbors-1126/+1168
More trait error reworking More work on #127492, specifically those sub-bullets under "Move trait error reporting to `error_reporting::traits`". Stacked on top of #127493. This does introduce new `TypeErrCtxt.*Ext` traits, but those will be deleted soon. Splitting this work into bite-sized pieces is the only way that it's gonna be feasible to both author and review ❤️ r? lcnr
2024-07-09E0191 suggestion correction, inserts turbofish without dyn (#91997)Ashton Hunt-1/+13
2024-07-09Auto merge of #127358 - oli-obk:taint_itemctxt, r=fmeasebors-191/+203
Automatically taint when reporting errors from ItemCtxt This isn't very robust yet, as you need to use `itemctxt.dcx()` instead of `tcx.dcx()` for it to take effect, but it's at least more convenient than sprinkling `set_tainted_by_errors` calls in individual places. based on https://github.com/rust-lang/rust/pull/127357 r? `@fmease`
2024-07-09Auto merge of #127234 - ZhuUx:inlined-expr, r=davidtwco,Zalatharbors-0/+6
[Coverage][MCDC] Group mcdc tests and fix panic when generating mcdc code for inlined expressions. ### Changes 1. Group all mcdc tests to one directory. 2. Since mcdc instruments different mappings for boolean expressions with normal branch coverage as #125766 introduces, it would be better also trace branch coverage results in mcdc tests. 3. So far rustc does not call `CoverageInfoBuilderMethods::init_coverage` for inlined functions. As a result, it could panic if it tries to instrument mcdc statements for inlined functions due to uninitialized cond bitmaps. We can reproduce this issue by current nightly rustc and [the test](https://github.com/rust-lang/rust/pull/127234/files#diff-c81af6bf4869aa42f5c7334e3e86344475de362f673f54ce439ec75fcb5ac3e5) with flag `--release`. This patch fixes it.
2024-07-09Adds expr_2024 migration litVincenzo Palazzo-0/+168
This is adding a migration lint for the current (in the 2021 edition and previous) to move expr to expr_2021 from expr Co-Developed-by: Eric Holk Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2024-07-09Auto merge of #127028 - Nadrieril:fix-or-pat-expansion, r=matthewjasperbors-0/+3
Fix regression in the MIR lowering of or-patterns In https://github.com/rust-lang/rust/pull/126553 I made a silly indexing mistake and regressed the MIR lowering of or-patterns. This fixes it. r? `@compiler-errors` because I'd like this to be merged quickly :pray:
2024-07-09Split out fulfillment error reporting a bit moreMichael Goulet-208/+221
2024-07-09Move some stuff into the ambiguity and suggestion modulesMichael Goulet-734/+742
2024-07-09Split out overflow handling into its own moduleMichael Goulet-187/+208
2024-07-09Auto merge of #127500 - compiler-errors:consolidate-region-errors, r=lcnrbors-1270/+1273
Consolidate region error reporting in `rustc_infer` More work on https://github.com/rust-lang/rust/issues/127492. Separate but important step, since I'm gonna likely pull everything else here into another module. I don't think I'm confident whether `nice_region_error` should be a submodule of the new `rustc_infer::infer::error_reporting::region` module, so I left it alone for now. r? lcnr
2024-07-09Auto merge of #127493 - compiler-errors:crate-level-import, r=lcnrbors-120/+124
Move trait selection error reporting to its own top-level module This effectively moves `rustc_trait_selection::traits::error_reporting` to `rustc_trait_selection::error_reporting::traits`. There are only a couple of actual changes to the code, like moving the `pretty_impl_header` fn out of the specialization module for privacy reasons. This is quite pointless on its own, but having `error_reporting` as a top-level module in `rustc_trait_selection` is very important to make sure we have a meaningful file structure for when we move **type** error reporting (and region error reporting, with which it's incredibly entangled currently) into `rustc_trait_selection`. I've opened a tracking issue here: #127492 r? lcnr
2024-07-09Auto merge of #127001 - beetrees:f16-debuginfo, r=michaelwoeristerbors-3/+40
Add Natvis visualiser and debuginfo tests for `f16` To render `f16`s in debuggers on MSVC targets, this PR changes the compiler to output `f16`s as `struct f16 { bits: u16 }`, and includes a Natvis visualiser that manually converts the `f16`'s bits to a `float` which is can then be displayed by debuggers. `gdb`, `lldb` and `cdb` tests are also included for `f16` . `f16`/`f128` MSVC debug info issue: #121837 Tracking issue: #116909
2024-07-09cycle_participants to nested_goalslcnr-11/+11
2024-07-09Remove HirTyLowerer::set_tainted_by_errors, since it is now redundantOli Scherer-96/+97
2024-07-09Automatically taint when reporting errors from ItemCtxtOli Scherer-98/+109