summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2024-06-06Revert "Rollup merge of #124099 - voidc:disallow-ambiguous-expr-attrs, ↵Rémy Rakic-30/+13
r=davidtwco" This reverts commit 57dad1d75e562ff73051c1c43b07eaf65c7dbd74, reversing changes made to 36316df9fe6c3e246153fe6e78967643cf08c148.
2024-06-06ast: Revert a breaking attribute visiting order changeVadim Petrochenkov-1/+1
(cherry picked from commit 6e67eaa311c8e2992ccc64cf6a9e8f311a02a5d4)
2024-06-06Revert "Rollup merge of #123979 - oli-obk:define_opaque_types7, ↵Oli Scherer-15/+2
r=compiler-errors" This reverts commit f939d1ff4820844595d0f50f94038869f1445d08, reversing changes made to 183c706305d8c4e0ccb0967932381baf7e0c3611. (cherry picked from commit 56c135c9253563f92755b0a9cd54ec67f7c17fc7)
2024-06-06Fix ICE in non-operand `aggregate_raw_ptr` instrinsic codegenScott McMurray-1/+5
(cherry picked from commit f60f2e8cb07d21b7d5b0fa7f96dacd2e806b98e4)
2024-06-06Handle Deref expressions in invalid_reference_castingBen Kimock-2/+4
(cherry picked from commit 2bb25d3f4ac8796a50f45409f3ef461ce83295f3)
2024-06-06Handle field projections like slice indexing in invalid_reference_castingBen Kimock-1/+2
(cherry picked from commit 0ca1a94b2bd58d19a1bd492300abd5bffe5263fb)
2024-06-06Fix insufficient logic when searching for the underlying allocationUrgau-0/+7
in the `invalid_reference_casting` lint, when trying to lint on bigger memory layout casts. (cherry picked from commit cd6a0c8c77575056f95d79ae1f5c460794e1388f)
2024-05-27revert leak check changes in candidate winnowinglcnr-12/+7
reverts the behavior changes of #119820 to give some additional time to `sqlx` as it is affected by this change.
2024-05-24Only make GAT ambiguous in match_projection_projections considering shallow ↵Michael Goulet-1/+11
resolvability (cherry picked from commit fa829feb2f7a3fee5890f3acf57b66029b123d18)
2024-05-24Add v0 symbol mangling for `f16` and `f128`Trevor Gross-3/+2
As discussed at <https://github.com/rust-lang/rust/pull/122106>, use the crate encoding to represent new primitives. (cherry picked from commit 809b84edba988408071630b1e89a8c06be07aeed)
2024-05-16Make `non-local-def` lint Allow by defaultWesley Wiser-1/+1
(cherry picked from commit 23015b9ff4a7f829c2e0c884bdc0bcdb3c6d86f7)
2024-05-16Don't do post-method-probe error reporting steps if we're in a suggestionMichael Goulet-9/+37
(cherry picked from commit 2e4c90c3f7c11c745a5d787809ad36c49970a25b)
2024-05-16Fix ICEs in diagnostic::on_unimplementedMichael Goulet-51/+69
(cherry picked from commit 7dbdbaaa8e4ce77f9b2f1428c82f7166fe6f02fb)
2024-05-16Do not ICE on foreign malformed `diagnostic::on_unimplemented`Esteban Küber-6/+8
Fix #124651. (cherry picked from commit 4847f2249f03b249956d2daa90a12f4ee66543a8)
2024-05-09Consider inner modules to be local in the `non_local_definitions` lintUrgau-5/+11
(cherry picked from commit 21c688af86a52cf5d44c69c274179e7410e01a49)
2024-04-28Mark more entries in rustc_data_structures as no_inline for docsMark Rousskov-0/+6
This is a workaround for #122758, but it's not clear why 1.79 requires a more extensive amount of no_inline than the previous release. Seems like there's something relatively subtle happening here.
2024-04-28Replace version placeholders for 1.79Mark Rousskov-14/+14
2024-04-27Rollup merge of #124437 - linyihai:doc-link-typeck, r=compiler-errorsMatthias Krüger-1/+1
doc: Make the `mod.rs` in the comment point to the correct location The origin `mod.rs` had moved to `rustc_hir_analysis::check`, but the annotation doesn't point to it. See [the origin PR](https://github.com/rust-lang/rust/pull/61857/files#diff-b65997b61ccd8d8e08238c925d631207671aca506e93ce7c5cfa0bec134c0a8e).
2024-04-27Rollup merge of #124425 - saethlin:ceci-nest-pas-une-ice, r=compiler-errorsMatthias Krüger-6/+3
Do not ICE on invalid consts when walking mono-reachable blocks The `bug!` here was written under the logic of "this condition is impossible, right?" except that of course, if the compiler is given code that results in an compile error, then the situation is possible. So now we just direct errors into the already-existing path for when we can't do a mono-time optimization.
2024-04-27Rollup merge of #124394 - gurry:123863-ice-unexpected-region, r=lcnrMatthias Krüger-0/+2
Fix ICE on invalid const param types Fixes ICE #123863 which occurs because the const param has a type which is not a `bool`, `char` or an integral type. The ICEing code path begins here in `typeck_with_fallback`: https://github.com/rust-lang/rust/blob/cb3752d20e0f5d24348062211102a08d46fbecff/compiler/rustc_hir_typeck/src/lib.rs#L167 The `fallback` invokes the `type_of` query and that eventually ends up calling `ct_infer` from the lowering code over here: https://github.com/rust-lang/rust/blob/cb3752d20e0f5d24348062211102a08d46fbecff/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs#L561 and `ct_infer` ICEs at this location: https://github.com/rust-lang/rust/blob/cb3752d20e0f5d24348062211102a08d46fbecff/compiler/rustc_hir_analysis/src/collect.rs#L392 To fix the ICE it I'm triggering a `span_delayed_bug` before we hit `ct_infer` if the type of the const param is not one of the supported types ### Edit On `@lcnr's` suggestion I've changed the approach to not let `ReStatic` region hit the `bug!` in `ct_infer` instead of triggering a `span_delayed_bug`.
2024-04-27Rollup merge of #124370 - ShE3py:substitution-part-offset, r=fee1-deadMatthias Krüger-2/+2
Fix substitution parts having a shifted underline in some cases If two suggestions parts are side by side, the underline's offset: (WIP PR as an example, not yet pushed) ``` error: expected a pattern, found an expression --> ./main.rs:4:9 | 4 | 1 + 2 => 3 | ^^^^^ arbitrary expressions are not allowed in patterns | help: check the value in an arm guard | 4 | n if n == 1 + 2 => 3 | ~ +++++++++++++ ``` The emitter didn't take into account that the string had shrunk/grown if two substitution parts were side-by-side (surprisingly, there was only one case in the ui testsuite.) ``` help: check the value in an arm guard | 4 | n if n == 1 + 2 => 3 | ~ +++++++++++++ ``` ``@rustbot`` label +A-suggestion-diagnostics
2024-04-27doc: Replace mod.rs with the appropriate linkLin Yihai-1/+1
2024-04-27Rollup merge of #124382 - petrochenkov:itemvisit, r=lcnrMatthias Krüger-336/+364
ast: Generalize item kind visiting And avoid duplicating logic for visiting `Item`s with different kinds (regular, associated, foreign). The diff is better viewed with whitespace ignored.
2024-04-27Fix ICE on invalid const param typesGurinder Singh-0/+2
2024-04-26Do not ICE on invalid consts when walking mono-reachable blocksBen Kimock-6/+3
2024-04-26Rollup merge of #124391 - nnethercote:builtin_macros-cleanups, r=fee1-deadJacob Pratt-341/+352
`rustc_builtin_macros` cleanups Some improvements I found while looking over this code. r? ``@fee1-dead``
2024-04-26Rollup merge of #124341 - petrochenkov:nomacvisit, r=compiler-errorsJacob Pratt-12/+3
resolve: Remove two cases of misleading macro call visiting Macro calls are ephemeral, they should not add anything to the definition tree, even if their AST could contains something with identity. Thankfully, macro call AST cannot contain anything like that, so these walks are just noops. In majority of other places in def_collector / build_reduced_graph they are already not visited. (Also, a minor match reformatting is included.)
2024-04-26Auto merge of #122385 - lcnr:analyze-obligations-for-infer, r=compiler-errorsbors-321/+589
`obligations_for_self_ty`: use `ProofTreeVisitor` for nested goals As always, dealing with proof trees continues to be a hacked together mess. After this PR and #124380 the only remaining blocker for core is https://github.com/rust-lang/trait-system-refactor-initiative/issues/90. There is also a `ProofTreeVisitor` issue causing an ICE when compiling `alloc` which I will handle in a separate PR. This issue likely affects coherence diagnostics more generally. The core idea is to extend the proof tree visitor to support visiting nested candidates without using a `probe`. We then simply recurse into nested candidates if they are the only potentially applicable candidate for a given goal and check whether the self type matches the expected one. For that to work, we need to improve `CanonicalState` to also handle unconstrained inference variables created inside of the trait solver. This is done by extending the `var_values` of `CanoncalState` with each fresh inference variables. Furthermore, we also store the state of all inference variables at the end of each probe. When recursing into `InspectCandidates` we then unify the values of all these states. r? `@compiler-errors`
2024-04-26Adjust some `pub`s.Nicholas Nethercote-81/+81
2024-04-26Auto merge of #120845 - petrochenkov:debmac, r=oli-obkbors-122/+78
debuginfo: Stabilize `-Z debug-macros`, `-Z collapse-macro-debuginfo` and `#[collapse_debuginfo]` `-Z debug-macros` is "stabilized" by enabling it by default and removing. `-Z collapse-macro-debuginfo` is stabilized as `-C collapse-macro-debuginfo`. It now supports all typical boolean values (`parse_opt_bool`) in addition to just yes/no. Default value of `collapse_debuginfo` was changed from `false` to `external` (i.e. collapsed if external, not collapsed if local) - https://github.com/rust-lang/rust/issues/100758#issuecomment-1935815625 describes some debugging scenarios that motivate this default as reasonable. `#[collapse_debuginfo]` attribute without a value is no longer supported to avoid guessing the default. Stabilization report: https://github.com/rust-lang/rust/pull/120845#issuecomment-1939145242 Closes https://github.com/rust-lang/rust/issues/100758 Closes https://github.com/rust-lang/rust/issues/41743 Closes https://github.com/rust-lang/rust/issues/39153
2024-04-25Rollup merge of #124381 - compiler-errors:derived-for-wf, r=lcnrMichael Goulet-6/+11
Renamed `DerivedObligation` to `WellFormedDeriveObligation` It's used when computing `WellFormed` obligations, so let's give it a less ambiguous name.
2024-04-25Rollup merge of #124379 - compiler-errors:remove-new-solver-lookup-behavior, ↵Michael Goulet-63/+18
r=lcnr Remove special-casing for `SimplifiedType` for next solver It's unnecessary due to the way that we fully normalize the self type before assembly begins. r? lcnr
2024-04-26Move some functions from `rustc_expand` to `rustc_builtin_macros`.Nicholas Nethercote-237/+234
These functions are only used in `rustc_builtin_macros`, so it makes sense for them to live there. This allows them to be changed from `pub` to `pub(crate)`.
2024-04-26Introduce `DeriveResolution`.Nicholas Nethercote-20/+32
Making this a proper struct, and giving its fields names, makes things easier to understand.
2024-04-25Renamed DerivedObligation to WellFormedDeriveObligationMichael Goulet-6/+11
2024-04-25Auto merge of #124386 - matthiaskrgr:rollup-0a6yr00, r=matthiaskrgrbors-30/+109
Rollup of 3 pull requests Successful merges: - #124313 (Detect borrow error involving sub-slices and suggest `split_at_mut`) - #124374 (Don't ICE when `codegen_select_candidate` returns ambiguity in new solver) - #124380 (`Range` iteration specialization: remove trivial bounds) r? `@ghost` `@rustbot` modify labels: rollup
2024-04-25use `EagerResolver`lcnr-1/+3
2024-04-25ast: Visit item components in "natural" orderVadim Petrochenkov-4/+4
2024-04-25ast: Generalize item kind visitingVadim Petrochenkov-333/+361
And avoid duplicating logic for visiting `Item`s with different kinds (regular, associated, foreign).
2024-04-25hir typeck: look into nested goalslcnr-288/+548
uses a `ProofTreeVisitor` to look into nested goals when looking at the pending obligations during hir typeck. Used by closure signature inference, coercion, and for async functions.
2024-04-25debuginfo: Stabilize `-Z debug-macros`, `-Z collapse-macro-debuginfo` and ↵Vadim Petrochenkov-122/+78
`#[collapse_debuginfo]` `-Z debug-macros` is "stabilized" by enabling it by default and removing. `-Z collapse-macro-debuginfo` is stabilized as `-C collapse-macro-debuginfo`. It now supports all typical boolean values (`parse_opt_bool`) in addition to just yes/no. Default value of `collapse_debuginfo` was changed from `false` to `external` (i.e. collapsed if external, not collapsed if local). `#[collapse_debuginfo]` attribute without a value is no longer supported to avoid guessing the default.
2024-04-25Rollup merge of #124374 - compiler-errors:fix-ambiguity-ice, r=lcnrMatthias Krüger-12/+5
Don't ICE when `codegen_select_candidate` returns ambiguity in new solver Because we merge identical candidates, we may have >1 impl candidate to in `codegen_select_error` but *not* have a trait error. r? lcnr
2024-04-25Rollup merge of #124313 - estebank:split-at-mut, r=fee1-deadMatthias Krüger-18/+104
Detect borrow error involving sub-slices and suggest `split_at_mut` ``` error[E0499]: cannot borrow `foo` as mutable more than once at a time --> $DIR/suggest-split-at-mut.rs:13:18 | LL | let a = &mut foo[..2]; | --- first mutable borrow occurs here LL | let b = &mut foo[2..]; | ^^^ second mutable borrow occurs here LL | a[0] = 5; | ---- first borrow later used here | = help: use `.split_at_mut(position)` or similar method to obtain two mutable non-overlapping sub-slices ``` Address most of #58792. For follow up work, we should emit a structured suggestion for cases where we can identify the exact `let (a, b) = foo.split_at_mut(2);` call that is needed.
2024-04-25Remove special-casing for SimplifiedType for next solverMichael Goulet-63/+18
2024-04-25review comment: rename methodEsteban Küber-5/+8
2024-04-25Auto merge of #124377 - matthiaskrgr:rollup-ajxjq35, r=matthiaskrgrbors-7/+7
Rollup of 2 pull requests Successful merges: - #124287 (Improved code with clippy) - #124326 (tests: remove few ignore-stage2) r? `@ghost` `@rustbot` modify labels: rollup
2024-04-25Rollup merge of #124287 - 41Leahcim:master, r=fmeaseMatthias Krüger-7/+7
Improved code with clippy I haven't used the bootstrapped compiler, but I think I have made some improvements using clippy. I have already made the following changes to the compiler: Replaced `self.first().is_digit(10)` with `self.first().is_ascii_digit()` on lines 633, 664, and 680 of compiler/rust_lexer/src/lib.rs. Removed unnecessary cast on line 262 of compiler/rustc_lexer/src/unescape.rs Replaced ok_or_else with ok_or on line 303 of compiler/rustc_lexer/src/unescape.rs Replaced `!std::env::var("RUSTC_BOOTSTRAP").is_ok()` with `std::env::var("RUSTC_BOOTSTRAP").is_err()` on line 4 of compiler/rustc_macros/build.rs Removed needless borrow for generic argument `env`on line 53 of compiler/rust_llvm/build.rs
2024-04-25Check equivalence of indices in more casesEsteban Küber-1/+7
2024-04-25Don't suggest `split_at_mut` when the multiple borrows have the same indexEsteban Küber-2/+41
2024-04-25Mention `split_at_mut` when mixing mutability in indexing opsEsteban Küber-2/+17
Emit suggestion when encountering ```rust let a = &mut foo[0]; let b = &foo[1]; a.use_mut(); ```