about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2024-09-18Rollup merge of #130510 - samueltardieu:doc-letstmt-assign-desugar, ↵Matthias Krüger-1/+2
r=compiler-errors doc: the source of `LetStmt` can also be `AssignDesugar` For example, the two following statements are desugared into a block whose `LetStmt` source is `AssignDesugar`: ```rust _ = ignoring_some_result(); (a, b) = (b, a); ```
2024-09-18Rollup merge of #130509 - krasimirgg:llvm-20-2, r=nikicMatthias Krüger-0/+4
llvm-wrapper: adapt for LLVM API changes, second try This is a re-work of https://github.com/rust-lang/rust/pull/129749 after LLVM brought back the APIs used by rust. No functional changes intended. `@rustbot` label: +llvm-main r? `@nikic` cc: `@tmandry`
2024-09-18Rollup merge of #130507 - Urgau:check-cfg-raw-keywords, r=jieyouxuMatthias Krüger-4/+13
Improve handling of raw-idents in check-cfg This PR improves the handling of raw-idents in the check-cfg diagnostics. In particular the list of expected names and the suggestion now correctly take into account the "keyword-ness" of the ident, and correctly prefix the ident with `r#` when necessary. `@rustbot` labels +F-check-cfg
2024-09-18Rollup merge of #130457 - nnethercote:cleanup-codegen-traits, r=bjorn3Matthias Krüger-226/+154
Cleanup codegen traits The traits governing codegen are quite complicated and hard to follow. This PR cleans them up a bit. r? `@bjorn3`
2024-09-18doc: the source of `LetStmt` can also be `AssignDesugar`Samuel Tardieu-1/+2
For example, the two following statements are desugared into a block whose `LetStmt` source is `AssignDesugar`: ```rust _ = ignoring_some_result(); (a, b) = (b, a); ```
2024-09-18llvm-wrapper: adapt for LLVM API changes, second tryKrasimir Georgiev-0/+4
2024-09-18Auto merge of #130500 - matthiaskrgr:rollup-lfx3bb4, r=matthiaskrgrbors-1/+10
Rollup of 3 pull requests Successful merges: - #130466 (tests: add repr/transparent test for aarch64) - #130468 (Make sure that def id <=> lang item map is bidirectional) - #130499 (Add myself to the libs review rotation) r? `@ghost` `@rustbot` modify labels: rollup
2024-09-18Improve handling of raw-idents in check-cfgUrgau-4/+13
2024-09-18Rollup merge of #130468 - compiler-errors:bidi, r=NadrierilMatthias Krüger-1/+10
Make sure that def id <=> lang item map is bidirectional Self-explanatory from assertion. Just makes sure of an invariant that I forgot to enforce when I added `LanguageItems::from_def_id`.
2024-09-18Rollup merge of #130496 - jder:issue-130400, r=compiler-errorsMatthias Krüger-1/+1
Fix circular fn_sig queries to correct number of args for methods Fixes #130400. This was a [debug assert](https://github.com/rust-lang/rust/blob/28e8f01c2a2f33fb4214925a704e3223b372cad5/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs#L2557) added to some argument error reporting code in #129320 which verified that the number of params (from the HIR) matched the `matched_inputs` which ultimately come from ty::FnSig. In the reduced test case: ``` fn foo(&mut self) -> _ { foo() } ``` There is a circular dependency computing the ty::FnSig -- when trying to compute it, we try to figure out the return value, which again depends on this ty::FnSig. In #105162, this was supported by short-circuiting the cycle by synthesizing a FnSig with error types for parameters. The [code in question](https://github.com/rust-lang/rust/pull/105162/files#diff-a65feec6bfffb19fbdc60a80becd1030c82a56c16b177182cd277478fdb04592R44) computes the number of parameters by taking the number of parameters from the hir::FnDecl and adding 1 if there is an implicit self parameter. I might be missing a subtlety here, but AFAICT the adjustment for implicit self args is unnecessary and results in one too many args. For example, for this non-errorful code: ``` trait Foo { fn bar(&self) {} } ``` The resulting hir::FnDecl and ty::FnSig both have the same number of inputs -- 1. So, this PR removes that adjustment and adds a test for the debug ICE. r? `@compiler-errors`
2024-09-18Rollup merge of #130489 - compiler-errors:raw-lt-lint, r=jieyouxuMatthias Krüger-0/+3
Ensure that `keyword_ident` lint doesn't trigger on `'r#kw` lifetime Fixes #130486
2024-09-18Rollup merge of #130116 - veera-sivarajan:freeze-suggestions, r=chenyukangMatthias Krüger-37/+102
Implement a Method to Seal `DiagInner`'s Suggestions This PR adds a method on `DiagInner` called `.seal_suggestions()` to prevent new suggestions from being added while preserving existing suggestions. This is useful because currently there is no way to prevent new suggestions from being added to a diagnostic. `.disable_suggestions()` is the closest but it gets rid of all suggestions before and after the call. Therefore, `.seal_suggestions()` can be used when, for example, misspelled keyword is detected and reported. In such cases, we may want to prevent other suggestions from being added to the diagnostic, as they would likely be meaningless once the misspelled keyword is identified. For context: https://github.com/rust-lang/rust/pull/129899#discussion_r1741307132 To store an additional state, the type of the `suggestions` field in `DiagInner` was changed into a three variant enum. While this change affects files across different crates, care was taken to preserve the existing code's semantics. This is validated by the fact that all UI tests pass without any modifications. r? chenyukang
2024-09-17Fix circular fn_sig queries to return the correct number of arguments for ↵Jesse Rusak-1/+1
methods
2024-09-17Store raw ident span for raw lifetimeMichael Goulet-0/+3
2024-09-17Auto merge of #130483 - matthiaskrgr:rollup-q1r0g0y, r=matthiaskrgrbors-24/+3
Rollup of 5 pull requests Successful merges: - #129477 (Fix fluent diagnostics) - #129674 (Add new_cyclic_in for Rc and Arc) - #130452 (Update Trusty target maintainers) - #130467 (Miri subtree update) - #130477 (Revert #129749 to fix segfault in LLVM) r? `@ghost` `@rustbot` modify labels: rollup
2024-09-17Rollup merge of #130477 - tmandry:revert-llvm-20-lto, r=tmandryMatthias Krüger-7/+3
Revert #129749 to fix segfault in LLVM This reverts commit 8c7a7e346be4cdf13e77ab4acbfb5ade819a4e60, reversing changes made to a00bd75b6c5c96d0a35afa2dc07ce3155112d278. Reported in https://github.com/rust-lang/rust/pull/129749#issuecomment-2354417960. `@nikic's` theory is that the LLVM API changed in a way that makes it impossible to use concurrently from multiple threads (https://github.com/llvm/llvm-project/pull/106427#issuecomment-2354783802). I pinged `@krasimirgg` who was fine with reverting. r? `@rust-lang/wg-llvm`
2024-09-17Rollup merge of #129477 - Xiretza:fix-fluent-diagnostics, r=compiler-errorsMatthias Krüger-17/+0
Fix fluent diagnostics This line number calculation was both wrong and unnecessary.
2024-09-17Rollup merge of #130469 - compiler-errors:wc-obj-safety, r=jackh726Matthias Krüger-0/+5
Mark `where_clauses_object_safety` as removed r? lcnr
2024-09-17Rollup merge of #130458 - nnethercote:rustc_codegen_ssa-cleanups, r=jieyouxuMatthias Krüger-318/+299
`rustc_codegen_ssa` cleanups Just some minor improvements I found while reading through this code. r? ``@jieyouxu``
2024-09-17Rollup merge of #130440 - compiler-errors:rpitit-opaque-hidden, r=jieyouxuMatthias Krüger-0/+12
Don't ICE in `opaque_hidden_inferred_bound` lint for RPITIT in trait with no default method body Inline comment should explain the fix. Fixes #130422
2024-09-17Rollup merge of #130314 - compiler-errors:mac-prec, r=davidtwcoMatthias Krüger-14/+10
Use the same precedence for all macro-like exprs No need to make these have a different precedence since they're all written like `whatever!(expr)`, and it makes it simpler when adding new macro-based built-in operators in the future.
2024-09-17Rollup merge of #130275 - compiler-errors:extern-crate, r=lcnrMatthias Krüger-0/+1
Don't call `extern_crate` when local crate name is the same as a dependency and we have a trait error #124944 implemented logic to point out when a trait bound failure involves a *trait* and *type* who come from identically named but different crates. This logic calls the `extern_crate` query which is not valid on `LOCAL_CRATE` cnum, so let's filter that out eagerly. Fixes #130272 Fixes #129184
2024-09-17Rollup merge of #130201 - compiler-errors:foreign-synthetic-body, r=lcnrMatthias Krüger-20/+42
Encode `coroutine_by_move_body_def_id` in crate metadata We synthesize the MIR for a by-move body for the `FnOnce` implementation of async closures. It can be accessed with the `coroutine_by_move_body_def_id` query. We weren't encoding this query in the metadata though, nor were we properly recording that synthetic MIR in `mir_keys`, so the `optimized_mir` wasn't getting encoded either! Stacked on top is a fix to consider `DefKind::SyntheticCoroutineBody` to return true in several places I missed. Specifically, we should consider the def-kind in `fn DefKind::is_fn_like()`, since that's what we were using to make sure we ensure `query mir_inliner_callees` before the MIR gets stolen for the body. This led to some CI failures that were caught by miri but which I added a test for.
2024-09-17Rollup merge of #129988 - arnaudgolfouse:modify-locale_resources, r=davidtwcoMatthias Krüger-2/+4
Use `Vec` in `rustc_interface::Config::locale_resources` This allows a third-party tool to injects its own resources, when receiving the config via `rustc_driver::Callbacks::config`.
2024-09-17Rollup merge of #128961 - GKFX:issue-128930-explain-missing-option, r=jieyouxuMatthias Krüger-3/+16
Fix #128930: Print documentation of CLI options missing their arg Fix #128930. Failing to give an argument to CLI options which require it now prints something like: ``` $ rustc --print error: Argument to option 'print' missing Usage: --print [crate-name|file-names|sysroot|target-libdir|cfg|check-cfg|calling-conventions|target-list|target-cpus|target-features|relocation-models|code-models|tls-models|target-spec-json|all-target-specs-json|native-static-libs|stack-protector-strategies|link-args|deployment-target] Compiler information to print on stdout ```
2024-09-17fluent_macro: fix diagnostics for fluent parse failuresXiretza-17/+0
This line number calculation was both wrong and unnecessary.
2024-09-17Mark where_clauses_object_safety as removedMichael Goulet-0/+5
2024-09-17Make sure that def id <=> lang item map is bidirectionalMichael Goulet-1/+10
2024-09-17Auto merge of #129073 - compiler-errors:receiver-variance, r=lcnrbors-6/+24
Relate receiver invariantly in method probe for `Mode::Path` Effectively reverts part of #126128 Fixes #126227 This PR changes method probing to use equality for fully path-based method lookup, and subtyping for receiver `.` method lookup. r? lcnr
2024-09-17Auto merge of #130455 - compiler-errors:inline-ordering, r=saethlinbors-10/+0
Remove semi-nondeterminism of `DefPathHash` ordering from inliner Déjà vu or something because I kinda thought I had put this PR up before. I recall a discussion somewhere where I think it was `@saethlin` mentioning that this check was no longer needed since we have "proper" cycle detection. Putting that up as a PR now. This may slighlty negatively affect inlining, since the cycle breaking here means that we still inlined some cycles when the def path hashes were ordered in certain ways, this leads to really bad nondeterminism that makes minimizing ICEs and putting up inliner bugfixes difficult. r? `@cjgillot` or `@saethlin` or someone else idk
2024-09-17Merge some impl blocks.Nicholas Nethercote-4/+0
2024-09-17Rename some lifetimes.Nicholas Nethercote-7/+5
`'mir` is not a good lifetime name in `LocalAnalyzer`, because it's used on two unrelated fields. `'a` is more standard for a situation like this (e.g. #130022).
2024-09-17Streamline `coroutine_kind_label`.Nicholas Nethercote-26/+13
2024-09-17Remove unnecessary `cx` argument.Nicholas Nethercote-11/+8
Because `bx` contains a `cx`.
2024-09-17Streamline `bin_op_to_[if]cmp_predicate`.Nicholas Nethercote-43/+13
2024-09-17Clean up formatting.Nicholas Nethercote-48/+72
Reflow overly long comments, plus some minor whitespace improvements.
2024-09-17Minimize visibilities.Nicholas Nethercote-179/+188
This makes it much clearer which things are used outside the crate.
2024-09-17Auto merge of #130456 - matthiaskrgr:rollup-h2qvk1f, r=matthiaskrgrbors-153/+176
Rollup of 4 pull requests Successful merges: - #130380 (coverage: Clarify some parts of coverage counter creation) - #130427 (run_make_support: rectify symlink handling) - #130447 (rustc_llvm: update for llvm/llvm-project@2ae968a0d9fb61606b020e898d88…) - #130448 (fix: Remove duplicate `LazyLock` example.) r? `@ghost` `@rustbot` modify labels: rollup
2024-09-16Fix a couple more DefKind discrepancies between DefKind::Closure and ↵Michael Goulet-3/+10
DefKind::SyntheticCoroutineBody
2024-09-17Rollup merge of #130447 - durin42:llvm-20-fix-instrumentation-hdr, r=cuviperMatthias Krüger-2/+6
rustc_llvm: update for llvm/llvm-project@2ae968a0d9fb61606b020e898d88… …4c82dd0ed8b5 Just a simple header move. `@rustbot` label: +llvm-main
2024-09-17Rollup merge of #130380 - Zalathar:counters, r=jieyouxuMatthias Krüger-151/+170
coverage: Clarify some parts of coverage counter creation This is a series of semi-related changes that are trying to make the `counters` module easier to read, understand, and modify. For example, the existing code happens to avoid ever using the count for a `TerminatorKind::Yield` node as the count for its sole out-edge (since doing so would be incorrect), but doesn't do so explicitly, so seemingly-innocent changes can result in baffling test failures. This PR also takes the opportunity to simplify some debug-logging code that was making its surrounding code disproportionately hard to read. There should be no changes to the resulting coverage instrumentation/mappings, as demonstrated by the absence of changes to the coverage test suite.
2024-09-16Remove semi-nondeterminism of DefPathHash ordering from inlinerMichael Goulet-10/+0
2024-09-17Auto merge of #129970 - lukas-code:LayoutCalculator, r=compiler-errorsbors-1133/+1144
layout computation: gracefully handle unsized types in unexpected locations This PR reworks the layout computation to eagerly return an error when encountering an unsized field where a sized field was expected, rather than delaying a bug and attempting to recover a layout. This is required, because with trivially false where clauses like `[T]: Sized`, any field can possible be an unsized type, without causing a compile error. Since this PR removes the `delayed_bug` method from the `LayoutCalculator` trait, it essentially becomes the same as the `HasDataLayout` trait, so I've also refactored the `LayoutCalculator` to be a simple wrapper struct around a type that implements `HasDataLayout`. The majority of the diff is whitespace changes, so viewing with whitespace ignored is advised. implements https://github.com/rust-lang/rust/pull/123169#issuecomment-2025788480 r? `@compiler-errors` or compiler fixes https://github.com/rust-lang/rust/issues/123134 fixes https://github.com/rust-lang/rust/issues/124182 fixes https://github.com/rust-lang/rust/issues/126939 fixes https://github.com/rust-lang/rust/issues/127737
2024-09-17Use associative type defaults in `{Layout,FnAbi}OfHelpers`.Nicholas Nethercote-34/+5
This avoids some repetitive boilerplate code.
2024-09-17Rename supertraits of `CodegenMethods`.Nicholas Nethercote-88/+98
Supertraits of `BuilderMethods` are all called `XyzBuilderMethods`. Supertraits of `CodegenMethods` are all called `XyzMethods`. This commit changes the latter to `XyzCodegenMethods`, for consistency.
2024-09-17Move some supertraits outward.Nicholas Nethercote-11/+19
Specifically, put them where they are genuinely required, i.e. the outermost place they can be.
2024-09-17Tweak and explain the `BuilderMethods`/`CodegenMethods` connection.Nicholas Nethercote-3/+6
2024-09-17Remove unneeded bounds from `CodegenMethods` and `BuilderMethods`.Nicholas Nethercote-12/+2
Some of these are pulled in indirectly, e.g. `MiscMethods` via `TypeMethods`.
2024-09-17Rename `{ArgAbi,IntrinsicCall}Methods`.Nicholas Nethercote-14/+14
They both are part of `BuilderMethods`, and so should have `Builder` in their name like all the other traits in `BuilderMethods`.
2024-09-17Remove `BackendTypes` constraint from traits that don't need it.Nicholas Nethercote-6/+2