about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2024-05-21don't inhibit random field reordering on repr(packed(1))Ralf Jung-15/+10
2024-05-21Auto merge of #123812 - compiler-errors:additional-fixes, r=fmeasebors-152/+137
Follow-up fixes to `report_return_mismatched_types` Some renames, simplifications, fixes, etc. Follow-ups to #123804. I don't think it totally disentangles this code, but it does remove some of the worst offenders on the "I am so confused" scale (e.g. `get_node_fn_decl`).
2024-05-21Auto merge of #125284 - compiler-errors:uplift-misc, r=lcnrbors-238/+309
Uplift `RegionVid`, `TermKind` to `rustc_type_ir`, and `EagerResolver` to `rustc_next_trait_solver` - Uplift `RegionVid`. This was complicated due to the fact that we implement `polonius_engine::Atom` for `RegionVid` -- but I just separated that into `PoloniusRegionVid`, and added `From`/`Into` impls so it can be defined in `rustc_borrowck` separately. Coherence 😵 - Change `InferCtxtLike` to expose `opportunistically_resolve_{ty,ct,lt,int,float}_var` so that we can uplift `EagerResolver` for use in the canonicalization methods. - Uplift `TermKind` much like `GenericArgKind` All of this is miscellaneous dependencies for making more `EvalCtxt` methods generic.
2024-05-20Inline get_node_fn_decl into get_fn_decl, simplify/explain logic in ↵Michael Goulet-99/+90
report_return_mismatched_types
2024-05-20Rename confusing function nameMichael Goulet-9/+9
2024-05-20Remove redundant blk_id parameterMichael Goulet-25/+32
2024-05-20No need to pass parent of block for BlockTailExpressionMichael Goulet-2/+1
2024-05-20Consolidate two arms doing the same thingMichael Goulet-16/+13
2024-05-20Remove get_parent_fn_decl; it's redundantMichael Goulet-12/+3
2024-05-21Rollup merge of #125346 - tbu-:pr_rm_path_to_str, r=wesleywiserMatthias Krüger-15/+14
Remove some `Path::to_str` from `rustc_codegen_llvm` Unnecessary panic paths when there's a better option.
2024-05-21Rollup merge of #125308 - lcnr:search-graph-5, r=compiler-errorsMatthias Krüger-153/+258
track cycle participants per root The search graph may have multiple roots, e.g. in ``` A :- B B :- A, C C :- D D :- C ``` we first encounter the `A -> B -> A` cycle which causes `A` to be a root. We then later encounter the `C -> D -> C` cycle as a nested goal of `B`. This cycle is completely separate and `C` will get moved to the global cache. This previously caused us to use `[B, D]` as the `cycle_participants` for `C` and `[]` for `A`. split off from #125167 as I would like to merge this change separately and will rebase that PR on top of this one. There is no test for this issue and I don't quite know how to write one. It is probably worth it to generalize the search graph to enable us to write unit tests for it. r? `@compiler-errors`
2024-05-21Rollup merge of #125158 - Nilstrieb:block-indent, r=compiler-errorsMatthias Krüger-1/+1
hir pretty: fix block indent before: ```rust fn main() { { { ::std::io::_print(format_arguments::new_const(&["Hello, world!\n"])); }; } } ``` after: ```rust fn main() { { { ::std::io::_print(format_arguments::new_const(&["Hello, world!\n"])); }; } } ``` AST pretty does the same.
2024-05-21Rollup merge of #124283 - surechen:fix_123558, r=estebankMatthias Krüger-6/+209
Note for E0599 if shadowed bindings has the method. implement #123558 Use a visitor to find earlier shadowed bingings which has the method. r? ``@estebank``
2024-05-20Remove some `Path::to_str` from `rustc_codegen_llvm`Tobias Bucher-15/+14
Unnecessary panic paths when there's a better option.
2024-05-20track cycle participants per entrylcnr-50/+128
2024-05-20move global cache lookup into fnlcnr-58/+62
2024-05-20move fixpoint step into subfunctionlcnr-53/+76
2024-05-20Auto merge of #125219 - Urgau:check-cfg-cargo-config, r=fmeasebors-22/+39
Update `unexpected_cfgs` lint for Cargo new `check-cfg` config This PR updates the diagnostics output of the `unexpected_cfgs` lint for Cargo new `check-cfg` config. It's a simple and cost-less alternative to the build-script `cargo::rustc-check-cfg` instruction. ```toml [lints.rust] unexpected_cfgs = { level = "warn", check-cfg = ['cfg(foo, values("bar"))'] } ``` This PR also adds a Cargo specific section regarding check-cfg and Cargo inside rustc's book (motivation is described inside the file, but mainly check-cfg is a rustc feature not a Cargo one, Cargo only enabled the feature, it does not own it; T-cargo even considers the `check-cfg` lint config to be an implementation detail). This PR also updates the links to refer to that sub-page when using Cargo from rustc. As well as updating the lint doc to refer to the check-cfg docs. ~**Not to be merged before https://github.com/rust-lang/cargo/pull/13913 reaches master!**~ (EDIT: merged in https://github.com/rust-lang/rust/pull/125237) `@rustbot` label +F-check-cfg r? `@fmease` *(feel free to roll)* Fixes https://github.com/rust-lang/rust/issues/124800 cc `@epage` `@weihanglo`
2024-05-20hir pretty: fix block indentNilstrieb-1/+1
2024-05-20Uplift TermKindMichael Goulet-20/+41
2024-05-20Rework var resolution in InferCtxtLike, uplift EagerResolverMichael Goulet-159/+198
2024-05-20Uplift RegionVidMichael Goulet-64/+75
2024-05-20Rollup merge of #125314 - jdonszelmann:global-registration-feature-gate, ↵Matthias Krüger-0/+4
r=pnkfelix Add an experimental feature gate for global registration See #125119 for the tracking issue.
2024-05-20Rollup merge of #125173 - scottmcm:never-checked, r=davidtwcoMatthias Krüger-165/+162
Remove `Rvalue::CheckedBinaryOp` Zulip conversation: <https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/intrinsics.20vs.20binop.2Funop/near/438729996> cc `@RalfJung` While it's a draft, r? ghost
2024-05-20Rollup merge of #125106 - Zalathar:expressions, r=davidtwcoMatthias Krüger-7/+82
coverage: Memoize and simplify counter expressions When creating coverage counter expressions as part of coverage instrumentation, we often end up creating obviously-redundant expressions like `c1 + (c0 - c1)`, which is equivalent to just `c0`. To avoid doing so, this PR checks when we would create an expression matching one of 5 patterns, and uses the simplified form instead: - `(a - b) + b` → `a`. - `(a + b) - b` → `a`. - `(a + b) - a` → `b`. - `a + (b - a)` → `b`. - `a - (a - b)` → `b`. Of all the different ways to combine 3 operands and 2 operators, these are the patterns that allow simplification. (Some of those patterns currently don't occur in practice, but are included anyway for completeness, to avoid having to add them later as branch coverage and MC/DC coverage support expands.) --- This PR also adds memoization for newly-created (or newly-simplified) counter expressions, to avoid creating duplicates. This currently makes no difference to the final mappings, but is expected to be useful for MC/DC coverage of match expressions, as proposed by https://github.com/rust-lang/rust/pull/124278#issuecomment-2106754753.
2024-05-20Rollup merge of #124917 - cardigan1008:issue-124819, r=pnkfelixMatthias Krüger-0/+1
Check whether the next_node is else-less if in get_return_block Fix #124819
2024-05-20Rollup merge of #124682 - estebank:issue-40990, r=pnkfelixMatthias Krüger-35/+131
Suggest setting lifetime in borrowck error involving types with elided lifetimes ``` error: lifetime may not live long enough --> $DIR/ex3-both-anon-regions-both-are-structs-2.rs:7:5 | LL | fn foo(mut x: Ref, y: Ref) { | ----- - has type `Ref<'_, '1>` | | | has type `Ref<'_, '2>` LL | x.b = y.b; | ^^^^^^^^^ assignment requires that `'1` must outlive `'2` | help: consider introducing a named lifetime parameter | LL | fn foo<'a>(mut x: Ref<'a, 'a>, y: Ref<'a, 'a>) { | ++++ ++++++++ ++++++++ ``` As can be seen above, it currently doesn't try to compare the `ty::Ty` lifetimes that diverged vs the `hir::Ty` to correctly suggest the following ``` help: consider introducing a named lifetime parameter | LL | fn foo<'a>(mut x: Ref<'_, 'a>, y: Ref<'_, 'a>) { | ++++ ++++++++ ++++++++ ``` but I believe this to still be an improvement over the status quo. Fix #40990.
2024-05-20address nitFelix S Klock II-1/+1
2024-05-20Rollup merge of #125255 - compiler-errors:eval-ctxt-generic, r=lcnrMatthias Krüger-174/+212
Make `EvalCtxt` generic over `InferCtxtLike` ...but don't change any of the impls, yet! These can get uplifted as we add more methods to `InferCtxtLike`/`Interner` :3 This is built on top of #125230. r? lcnr
2024-05-20Note for E0599 if shadowed bindings has the method.surechen-6/+209
implement #123558
2024-05-20Fix quote escaping inside check-cfg valueUrgau-3/+2
2024-05-20Rollup merge of #125302 - workingjubilee:prefer-my-stack-neat, r=compiler-errorsMatthias Krüger-9/+33
defrost `RUST_MIN_STACK=ice rustc hello.rs` I didn't think too hard about testing my previous PR rust-lang/rust#122847 which makes our stack overflow handler assist people in discovering the `RUST_MIN_STACK` variable (which apparently is surprisingly useful for Really Big codebases). After it was merged, some useful comments left in a drive-by review led me to discover I had added an ICE. This reworks the code a bit to explain the rationale, remove the ICE that I introduced, and properly test one of the diagnostics.
2024-05-20Rollup merge of #125301 - jwong101:fix-static-coro-suggest, r=compiler-errorsMatthias Krüger-0/+4
fix suggestion in E0373 for !Unpin coroutines Coroutines can be prefixed with the `static` keyword to make them `!Unpin`. However, given the following function: ```rust fn check() -> impl Sized { let x = 0; #[coroutine] static || { yield; x } } ``` We currently suggest prefixing `move` before `static`, which is syntactically incorrect: ``` error[E0373]: coroutine may outlive the current function, but it borrows ... --> src/main.rs:6:5 | 6 | static || { | ^^^^^^^^^ may outlive borrowed value `x` 7 | yield; 8 | x | - `x` is borrowed here | note: coroutine is returned here --> src/main.rs:6:5 | 6 | / static || { 7 | | yield; 8 | | x 9 | | } | |_____^ help: to force the coroutine to take ownership of `x` (and any other referenced variables), use the `move` keyword | // this is syntactically incorrect, it should be `static move ||` 6 | move static || { | ++++ ``` This PR suggests adding `move` after `static` for these coroutines. I also added a UI test for this case.
2024-05-20Rollup merge of #125282 - WaffleLapkin:never-type-unsafe-improvements, ↵Matthias Krüger-38/+47
r=compiler-errors Never type unsafe lint improvements - Move linting code to a separate method - Remove mentions of `core::convert::absurd` (#124311 was rejected) - Make the lint into FCW The last thing is a bit weird though. On one hand it should be `EditionSemanticsChange(2024)`, but on the other hand it shouldn't, because we also plan to break it on all editions some time later. _Also_, it's weird that we don't have `FutureReleaseSemanticsChangeReportInDeps`, IMO "this might cause UB in a future release" is important enough to be reported in deps... IMO we ought to have three enums instead of [`FutureIncompatibilityReason`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint_defs/enum.FutureIncompatibilityReason.html#): ```rust enum IncompatibilityWhen { FutureRelease, Edition(Edition), } enum IncompatibilyWhat { Error, SemanticChange, } enum IncompatibilityReportInDeps { No, Yes, } ``` Tracking: - https://github.com/rust-lang/rust/issues/123748
2024-05-19note value of RUST_MIN_STACK and explain unsettingJubilee Young-3/+9
2024-05-19defrost RUST_MIN_STACK=ice rustc hello.rsJubilee Young-9/+27
An earlier commit included the change for a suggestion here. Unfortunately, it also used unwrap instead of dying properly. Roll out the ~~rice paper~~ EarlyDiagCtxt before we do anything that might leave a mess.
2024-05-19fix suggestion in E0373 for !Unpin coroutinesJoshua Wong-0/+4
Coroutines can be prefixed with the `static` keyword to make them `!Unpin`. However, given the following function: ```rust fn check() -> impl Sized { let x = 0; #[coroutine] static || { yield; x } } ``` We currently suggest prefixing `move` before `static`, which is syntactically incorrect: ``` error[E0373]: coroutine may outlive the current function, but it borrows ... --> src/main.rs:6:5 | 6 | static || { | ^^^^^^^^^ may outlive borrowed value `x` 7 | yield; 8 | x | - `x` is borrowed here | note: coroutine is returned here --> src/main.rs:6:5 | 6 | / static || { 7 | | yield; 8 | | x 9 | | } | |_____^ help: to force the coroutine to take ownership of `x` (and any other referenced variables), use the `move` keyword | // this is syntactically incorrect, it should be `static move ||` 6 | move static || { | ++++ ``` This PR suggests adding `move` after `static` for these coroutines.
2024-05-19Make EvalCtxt generic over internerMichael Goulet-121/+138
2024-05-19Make search graph generic over internerMichael Goulet-54/+75
2024-05-19Auto merge of #125294 - matthiaskrgr:rollup-w42c829, r=matthiaskrgrbors-12/+8
Rollup of 4 pull requests Successful merges: - #124948 (chore: Remove repeated words (extension of #124924)) - #124992 (Add example to IsTerminal::is_terminal) - #125279 (make `Debug` impl for `Term` simpler) - #125286 (Miri subtree update) r? `@ghost` `@rustbot` modify labels: rollup
2024-05-19Rollup merge of #125279 - WaffleLapkin:unpacktermindebug, ↵Matthias Krüger-8/+4
r=aDotInTheVoid,Nilstrieb,BoxyUwU make `Debug` impl for `Term` simpler meow
2024-05-19Rollup merge of #124948 - blyxyas:remove-repeated-words, r=compiler-errorsMatthias Krüger-4/+4
chore: Remove repeated words (extension of #124924) When I saw #124924 I thought "Hey, I'm sure that there are far more than just two typos of this nature in the codebase". So here's some more typo-fixing. Some found with regex, some found with a spellchecker. Every single one manually reviewed by me (along with hundreds of false negatives by the tools)
2024-05-19Auto merge of #125006 - spastorino:generics-is-empty, r=compiler-errorsbors-15/+23
Add and use generics.is_empty() and generics.is_own_empty, rather than using generics' attributes r? `@compiler-errors` Related to #123929
2024-05-19Link to the check-cfg doc section in the `unexpected_cfgs` lint docUrgau-4/+7
2024-05-19Refer to the Cargo specific doc in the check-cfg diagnosticsUrgau-2/+4
2024-05-19Prefer suggesting string-literal for Cargo `check-cfg` lint configUrgau-18/+29
2024-05-19Rollup merge of #125270 - pietroalbini:pa-no-sad-contributors, r=NilstriebMichael Goulet-6/+13
Followup fixes from #123344 ``@Nilstrieb`` doesn't deserve [to be sad](https://github.com/rust-lang/rust/pull/123344#issuecomment-2100978863), so this PR addresses the two pieces of feedback from that PR. r? ``@Nilstrieb``
2024-05-19make `Debug` impl for `Term` simplerWaffle Lapkin-8/+4
2024-05-19Add and use generics.is_empty() and generics.is_own_empty, rather than using ↵Santiago Pastorino-15/+23
generics' attributes
2024-05-19fix typoPietro Albini-6/+6