about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2025-07-13Move trait_item_def_id from ImplItemRef to ImplItem.Camille GILLOT-72/+62
2025-07-13Delegation: self parameter must be named exactly `self`.Camille GILLOT-7/+33
2025-07-13Remove usused depth.Camille GILLOT-4/+1
2025-07-13Auto merge of #143867 - fmease:rollup-5tll6m9, r=fmeasebors-1/+16
Rollup of 12 pull requests Successful merges: - rust-lang/rust#143776 (std: move NuttX to use arc4random for random number generation) - rust-lang/rust#143778 (Some const_trait_impl test cleanups) - rust-lang/rust#143782 (Disambiguate between rustc vs std having debug assertions in `run-make-support` and `run-make` tests) - rust-lang/rust#143791 (Update sysinfo version to `0.36.0`) - rust-lang/rust#143796 (Fix ICE for parsed attributes with longer path not handled by CheckAttribute) - rust-lang/rust#143798 (Remove format short command trait) - rust-lang/rust#143803 (New tracking issues for const_ops and const_cmp) - rust-lang/rust#143814 (htmldocck: better error messages for some negative directives) - rust-lang/rust#143817 (Access `wasi_sdk_path` instead of reading environment variable in bootstrap) - rust-lang/rust#143822 (./x test miri: fix cleaning the miri_ui directory) - rust-lang/rust#143823 ([COMPILETEST-UNTANGLE 5/N] Test mode adjustments and other assorted cleanups) - rust-lang/rust#143841 (Label clippy changes with `T-clippy`) Failed merges: - rust-lang/rust#143850 (Compiletest: Simplify {Html,Json}DocCk directive handling) r? `@ghost` `@rustbot` modify labels: rollup
2025-07-13Rollup merge of #143796 - JonathanBrouwer:fix-builtin-attribute-prefix, ↵León Orell Valerian Liehr-1/+16
r=jdonszelmann Fix ICE for parsed attributes with longer path not handled by CheckAttribute Fixes https://github.com/rust-lang/rust/issues/137590 Fixes https://github.com/rust-lang/rust/issues/143789 r? ```@jdonszelmann```
2025-07-13Auto merge of #143213 - dianne:lower-cond-tweaks, r=cjgillotbors-80/+34
de-duplicate condition scoping logic between AST→HIR lowering and `ScopeTree` construction There was some overlap between `rustc_ast_lowering::LoweringContext::lower_cond` and `rustc_hir_analysis::check::region::resolve_expr`, so I've removed the former and migrated its logic to the latter, with some simplifications. Consequences: - For `while` and `if` expressions' `let`-chains, this changes the `HirId`s for the `&&`s to properly correspond to their AST nodes. This is how guards were handled already. - This makes match guards share previously-duplicated logic with `if`/`while` expressions. This will also be used by guard pattern[^1] guards. - Aside from legacy syntax extensions (e.g. some builtin macros) that directly feed AST to the compiler, it's currently impossible to put attributes directly on `&&` operators in `let` chains[^2]. Nonetheless, attributes on `&&` operators in `let` chains in `if`/`while` expression conditions are no longer silently ignored and will be lowered. - This no longer wraps conditions in `DropTemps`, so the HIR and THIR will be slightly smaller. - `DesugaringKind::CondTemporary` is now gone. It's no longer applied to any spans, and all uses of it were dead since they were made to account for `if` and `while` being desugared to `match` on a boolean scrutinee. - Should be a marginal perf improvement beyond that due to leveraging [`ScopeTree` construction](https://github.com/rust-lang/rust/blob/5e749eb66f93ee998145399fbdde337e57cd72ef/compiler/rustc_hir_analysis/src/check/region.rs#L312-L355)'s clever handling of `&&` and `||`: - This removes some unnecessary terminating scopes that were placed around top-level `&&` and `||` operators in conditions. When lowered to MIR, logical operator chains don't create intermediate boolean temporaries, so there's no temporary to drop. The linked snippet handles wrapping the operands in terminating scopes as necessary, in case they create temporaries. - The linked snippet takes care of letting `let` temporaries live and terminating other operands, so we don't need separate traversals of `&&` chains for that. [^1]: rust-lang/rust#129967 [^2]: Case-by-case, here's my justification: `#[attr] e1 && e2` applies the attribute to `e1`. In `#[attr] (e1 && e2)` , the attribute is on the parentheses in the AST, plus it'd fail to parse if `e1` or `e2` contains a `let`. In `#[attr] expands_to_let_chain!()`, the attribute would already be ignored (rust-lang/rust#63221) and it'd fail to parse anyway; even if the expansion site is a condition, the expansion wouldn't be parsed with `Restrictions::ALLOW_LET`. If it *was* allowed, the notion of a "reparse context" from https://github.com/rust-lang/rust/issues/61733#issuecomment-509626449 would be necessary in order to make `let`-chains left-associative; multiple places in the compiler assume they are.
2025-07-13Auto merge of #140717 - mejrs:diagnostic_lints, r=oli-obkbors-30/+118
Split up the `unknown_or_malformed_diagnostic_attributes` lint This splits up the lint into the following lint group: - `unknown_diagnostic_attributes` - triggers if the attribute is unknown to the current compiler - `misplaced_diagnostic_attributes` - triggers if the attribute exists but it is not placed on the item kind it's meant for - `malformed_diagnostic_attributes` - triggers if the attribute's syntax or options are invalid - `malformed_diagnostic_format_literals` - triggers if the format string literal is invalid, for example if it has unpaired curly braces or invalid parameters - this pr doesn't create it, but future lints for things like deprecations can also go here. This PR does not start emitting lints in places that previously did not. ## Motivation I want to have finer control over what `unknown_or_malformed_diagnostic_attributes` does I have a project with fairly low msrv that is/will have a lower msrv than future diagnostic attributes. So lints will be emitted when I or others compile it on a lower msrv. At this time, there are two options to silence these lints: - `#[allow(unknown_or_malformed_diagnostic_attributes)]` - this risks diagnostic regressions if I (or others) mess up using the attribute, or if the attribute's syntax ever changes. - write a build script to detect the compiler version and emit cfgs, and then conditionally enable the attribute: ```rust #[cfg_attr(rust_version_99, diagnostic::new_attr_in_rust_99(thing = ..))]` struct Foo; ``` or conditionally `allow` the lint: ```rust // lib.rs #![cfg_attr(not(current_rust), allow(unknown_or_malformed_diagnostic_attributes))] ``` I like to avoid using build scripts if I can, so the following works much better for me. That is what this PR will let me do in the future: ```rust #[allow(unknown_diagnostic_attribute, reason = "attribute came out in rust 1.99 but msrv is 1.70")] #[diagnostic::new_attr_in_rust_99(thing = ..)]` struct Foo;
2025-07-12Clean up implementation of RPITIT assoc item loweringMichael Goulet-146/+110
2025-07-13query RPITIT in a trait or implbohan-151/+143
2025-07-13compute all rpitit of a traitbohan-56/+62
2025-07-12Auto merge of #143624 - tmiasko:copy-prop-borrowed, r=cjgillotbors-20/+6
Propagate from borrowed locals in CopyProp r? cjgillot
2025-07-12Auto merge of #143810 - matthiaskrgr:rollup-iw7a23z, r=matthiaskrgrbors-118/+288
Rollup of 9 pull requests Successful merges: - rust-lang/rust#143403 (Port several trait/coherence-related attributes the new attribute system) - rust-lang/rust#143633 (fix: correct assertion to check for 'noinline' attribute presence before removal) - rust-lang/rust#143647 (Clarify and expand documentation for std::sys_common dependency structure) - rust-lang/rust#143716 (compiler: doc/comment some codegen-for-functions interfaces) - rust-lang/rust#143747 (Add target maintainer information for aarch64-unknown-linux-musl) - rust-lang/rust#143759 (Fix typos in function names in the `target_feature` test) - rust-lang/rust#143767 (Bump `src/tools/x` to Edition 2024 and some cleanups) - rust-lang/rust#143769 (Remove support for SwitchInt edge effects in backward dataflow) - rust-lang/rust#143770 (build-helper: clippy fixes) r? `@ghost` `@rustbot` modify labels: rollup
2025-07-12Auto merge of #143766 - matthiaskrgr:rollup-0x7t69s, r=matthiaskrgrbors-25/+134
Rollup of 8 pull requests Successful merges: - rust-lang/rust#142391 (rust: library: Add `setsid` method to `CommandExt` trait) - rust-lang/rust#143302 (`tests/ui`: A New Order [27/N]) - rust-lang/rust#143303 (`tests/ui`: A New Order [28/28] FINAL PART) - rust-lang/rust#143568 (std: sys: net: uefi: tcp4: Add timeout support) - rust-lang/rust#143611 (Mention more APIs in `ParseIntError` docs) - rust-lang/rust#143661 (chore: Improve how the other suggestions message gets rendered) - rust-lang/rust#143708 (fix: Include frontmatter in -Zunpretty output ) - rust-lang/rust#143718 (Make UB transmutes really UB in LLVM) r? `@ghost` `@rustbot` modify labels: rollup try-job: i686-gnu-nopt-1 try-job: test-various
2025-07-11Rollup merge of #143769 - tmiasko:rm-backward-switch-int, r=lqdMatthias Krüger-48/+7
Remove support for SwitchInt edge effects in backward dataflow Those effects are untested and unused. Remove them along with the implementation of `BasicBlocks::switch_sources`.
2025-07-11Rollup merge of #143716 - ↵Matthias Krüger-10/+35
workingjubilee:document-some-codegen-backend-stuff, r=bjorn3,fee1-dead compiler: doc/comment some codegen-for-functions interfaces An out-of-date comment gets updated and some underdocumented functions get documented.
2025-07-11Rollup merge of #143633 - dillona:noinline-assert, r=fee1-deadMatthias Krüger-1/+1
fix: correct assertion to check for 'noinline' attribute presence before removal
2025-07-11Rollup merge of #143403 - GrigorenkoPV:attributes/traits, r=jdonszelmannMatthias Krüger-59/+245
Port several trait/coherence-related attributes the new attribute system Part of rust-lang/rust#131229 This ports: - `#[const_trait]` - `#[rustc_deny_explicit_impl]` - `#[rustc_do_not_implement_via_object]` - `#[rustc_coinductive]` - `#[type_const]` - `#[rustc_specialization_trait]` - `#[rustc_unsafe_specialization_marker]` - `#[marker]` - `#[fundamental]` - `#[rustc_paren_sugar]` - `#[rustc_allow_incoherent_impl]` - `#[rustc_coherence_is_core]` This also changes `#[marker]` to error on duplicates instead of warning. cc rust-lang/rust#142838, but I don't think it matters too much, since it's unstable. r? ``@oli-obk``
2025-07-11Fix ICE for parsed attributes with longer path not handled by CheckAttrVisitorJonathan Brouwer-1/+16
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-07-11Remove support for SwitchInt edge effects in backward dataflow analysesTomasz Miąsko-48/+7
Those effects are untested and unused. Remove them along with the implementation of `BasicBlocks::switch_sources`.
2025-07-11compiler: comment on some call-related codegen fn in cg_ssaJubilee Young-2/+29
Partially documents the situation due to LLVM CFI.
2025-07-11Call `get_switch_int_data` on a block with SwitchInt terminatorTomasz Miąsko-1/+1
Fix a mix-up of a block with its predecessors in handling of SwitchInt edge effects for backward analysis. Note that this functionality is currently unused, so change has no practical impact.
2025-07-11Rollup merge of #143718 - scottmcm:ub-transmute-is-ub, r=WaffleLapkinMatthias Krüger-10/+14
Make UB transmutes really UB in LLVM Ralf suggested in <https://github.com/rust-lang/rust/pull/143410#discussion_r2184928123> that UB transmutes shouldn't be trapping, which happened for the one path *that* PR was changing, but there's another path as well, so *this* PR changes that other path to match. r? codegen
2025-07-11Rollup merge of #143708 - epage:pretty, r=compiler-errorsMatthias Krüger-13/+113
fix: Include frontmatter in -Zunpretty output In the implementation (rust-lang/rust#140035), this was left as an open question for the tracking issue (rust-lang/rust#136889). My assumption is that this should be carried over. The test was carried over from rust-lang/rust#137193 which was superseded by rust-lang/rust#140035. Thankfully, either way, `-Zunpretty` is unstable and we can always change it even if we stabilize frontmatter.
2025-07-11Rollup merge of #143661 - Muscraft:other-suggestion-message, r=estebankMatthias Krüger-2/+7
chore: Improve how the other suggestions message gets rendered Note: This change is part of my ongoing work to use `annotate-snippets` as `rustc`'s emitter This change started as a way to remove some specialty code paths from `annotate-snippets`, by making the "and {} other candidates" message get rendered like a secondary message with no level, but turned into a fix for the message's Unicode output. Before this change, when using the Unicode output, the other suggestions message would get rendered outside of the main suggestion block, making it feel disconnected from what it was referring to. This change makes it so that the message is on the last line of the block, aligning its rendering with other secondary messages, and making it clear what the message is referring to. Before: ``` error[E0433]: failed to resolve: use of undeclared type `IntoIter` ╭▸ $DIR/issue-82956.rs:28:24 │ LL │ let mut iter = IntoIter::new(self); │ ━━━━━━━━ use of undeclared type `IntoIter` ╰╴ help: consider importing one of these structs ╭╴ LL + use std::array::IntoIter; ├╴ LL + use std::collections::binary_heap::IntoIter; ├╴ LL + use std::collections::btree_map::IntoIter; ├╴ LL + use std::collections::btree_set::IntoIter; ╰╴ and 9 other candidates ``` After: ``` error[E0433]: failed to resolve: use of undeclared type `IntoIter` ╭▸ $DIR/issue-82956.rs:28:24 │ LL │ let mut iter = IntoIter::new(self); │ ━━━━━━━━ use of undeclared type `IntoIter` ╰╴ help: consider importing one of these structs ╭╴ LL + use std::array::IntoIter; ├╴ LL + use std::collections::binary_heap::IntoIter; ├╴ LL + use std::collections::btree_map::IntoIter; ├╴ LL + use std::collections::btree_set::IntoIter; │ ╰ and 9 other candidates ```
2025-07-11Auto merge of #142911 - mejrs:unsized, r=compiler-errorsbors-86/+44
Remove support for dynamic allocas Followup to rust-lang/rust#141811
2025-07-10Rollup merge of #143744 - fmease:lta-expand-proper-depth, r=compiler-errorsTrevor Gross-2/+4
Properly track the depth when expanding free alias types Decrease the depth after the fold so as not to affect the depth for unrelated same-level constituent types. My bad. Fixes rust-lang/rust#142419.
2025-07-10Rollup merge of #143742 - estebank:borrow-suggestion, r=compiler-errorsTrevor Gross-104/+126
Rework borrowing suggestions to use `Expr` instead of just `Span` In the suggestion machinery for borrowing expressions and types, always use the available obligation `Span` to find the appropriate `Expr` to perform appropriateness checks no the `ExprKind` instead of on the textual snippet corresponding to the `Span`. (We were already doing this, but only for a subset of cases.) This now better handles situations where parentheses and `<>` are needed for correct syntax (`&(foo + bar)`, `(&foo).bar()`, `<&Foo>::bar()`, etc.). Unify the logic for the case where `&` *and* `&mut` are appropriate with the logic for only one of those cases. (Instead of having two branches for emitting the suggestion, we now have a single one, using `Diag::multipart_suggestions` always.) Handle the case when `S::foo()` should have been `<&S>::foo()` (instead of suggesting the prior `&S::foo()`. Fix rust-lang/rust#143393. Make `Diag::multipart_suggestions` always verbose. CC rust-lang/rust#141973.
2025-07-10Rollup merge of #143728 - LorrensP-2158466:refactor-resolve-extraction, ↵Trevor Gross-118/+143
r=petrochenkov Resolve refactor: extraction of `finalize_module_binding` and `single_import_can_define_name` This pr the work Vadim asked for in https://github.com/rust-lang/rust/pull/142547#issuecomment-3001339385. This part: > finalize_module_binding/single_import_can_define_name extraction Cherry-picked commits of b-naber. Extraction of 2 processes in `resolve_ident_in_module_unadjusted`: - `finalize_module_binding` - `single_import_can_define_name` r? ```@petrochenkov```
2025-07-10Rollup merge of #143722 - oli-obk:sound-llvm, r=dianqkTrevor Gross-7/+9
Make some "safe" llvm ops actually sound Noticed while doing other refactorings it may cause some extra unnecessary allocations, but the current use sites are rare ones anyway
2025-07-11Split up the `unknown_or_malformed_diagnostic_attributes` lintmejrs-30/+118
2025-07-10Rollup merge of #143640 - oli-obk:const-fn-traits, r=compiler-errorsMatthias Krüger-50/+55
Constify `Fn*` traits r? `@compiler-errors` `@fee1-dead` this should unlock a few things. A few `const_closures` tests have broken even more than before, but that feature is marked as incomplete anyway cc rust-lang/rust#67792
2025-07-10Rollup merge of #143632 - dillona:ffi-param-names, r=jieyouxuMatthias Krüger-2/+2
fix: correct parameter names in LLVMRustBuildMinNum and LLVMRustBuildMaxNum FFI declarations
2025-07-10Rollup merge of #143599 - folkertdev:x86-asm-syntax-global-naked-asm, r=AmanieuMatthias Krüger-7/+15
emit `.att_syntax` when global/naked asm use that option fixes https://github.com/rust-lang/rust/issues/143542 LLVM would error when using `-Cllvm-args=-x86-asm-syntax=intel` in combination with global/naked assembly with `att_syntax`. It turns out that for LLVM you do in this case need to emit `.att_syntax`. r? `@Amanieu`
2025-07-10Rollup merge of #143446 - usamoi:export-executable-symbols, r=bjorn3,oli-obkMatthias Krüger-16/+25
use `--dynamic-list` for exporting executable symbols closes rust-lang/rust#101610 cc rust-lang/rust#84161 https://sourceware.org/binutils/docs-2.39/ld/VERSION.html: > --dynamic-list=dynamic-list-file Specify the name of a dynamic list file to the linker. This is typically used when creating shared libraries to specify a list of global symbols whose references shouldn’t be bound to the definition within the shared library, or creating dynamically linked executables to specify a list of symbols which should be added to the symbol table in the executable. This option is only meaningful on ELF platforms which support shared libraries. `ld.lld --help`: > --dynamic-list=<file>: Similar to --export-dynamic-symbol-list. When creating a shared object, this additionally implies -Bsymbolic but does not set DF_SYMBOLIC > --export-dynamic-symbol-list=file: Read a list of dynamic symbol patterns. Apply --export-dynamic-symbol on each pattern > --export-dynamic-symbol=glob: (executable) Put matched symbols in the dynamic symbol table. (shared object) References to matched non-local STV_DEFAULT symbols shouldn't be bound to definitions within the shared object. Does not imply -Bsymbolic. > --export-dynamic: Put symbols in the dynamic symbol table Use `--dynamic-list` because it's older than `--export-dynamic-symbol-list` (binutils 2.35) try-job: dist-i586-gnu-i586-i686-musl
2025-07-10Properly track the depth when expanding free alias typesLeón Orell Valerian Liehr-2/+4
2025-07-10Make `Diag::multipart_suggestions` always verboseEsteban Küber-1/+1
2025-07-10Rework borrowing suggestions to use `Expr` instead of just `Span`Esteban Küber-103/+125
In the suggestion machinery for borrowing expressions and types, always use the available obligation `Span` to find the appropriate `Expr` to perform appropriateness checks no the `ExprKind` instead of on the textual snippet corresponding to the `Span`. Unify the logic for the case where `&` *and* `&mut` are appropriate with the logic for only one of those cases. Handle the case when `S::foo()` should have been `<&S>::foo()` (instead of suggesting the prior `&S::foo()`.
2025-07-10Add `BuilderMethods::unreachable_nonterminator`Scott McMurray-6/+12
So places that need `unreachable` but in the middle of a basic block can call that instead of figuring out the best way to do it.
2025-07-10fix: Include frontmatter in -Zunpretty outputEd Page-1/+9
In the implementation (#140035), this was left as an open question for the tracking issue (#136889). My assumption is that this should be carried over. Thankfully, either way, `-Zunpretty` is unstable and we can always change it even if we stabilize frontmatter.
2025-07-10test(lexer): Add frontmatter unit testEd Page-2/+84
2025-07-10chore: Improve how the other suggestions message gets renderedScott Schafer-2/+7
2025-07-10extract single_import_can_define_name and finalize_glob_module_bindingb-naber-118/+143
2025-07-10Rollup merge of #143675 - hkBst:overflowing-1, r=oli-obkMatthias Krüger-5/+4
improve lint doc text
2025-07-10Rollup merge of #143666 - nilehmann:nested_bodies_in_consumers, r=lcnrMatthias Krüger-54/+89
Re-expose nested bodies in rustc_borrowck::consumers After https://github.com/rust-lang/rust/pull/138499, it's not possible anymore to get borrowck information for nested bodies via `get_body_with_borrowck_facts`. This PR re-exposes nested bodies by returning a map containing the typeck root and all its nested bodies. To collect the bodies, a map is added to `BorrowCheckRootCtxt`, and a body is inserted every time `do_mir_borrowck` is called. r? ``@lcnr``
2025-07-10Rollup merge of #143663 - dillona:fix-typo, r=jdonszelmannMatthias Krüger-2/+2
fix: correct typo in attr_parsing_previously_accepted message key
2025-07-10Rollup merge of #143659 - GrigorenkoPV:attributes/inner-outer, r=jdonszelmannMatthias Krüger-42/+29
Use "Innermost" & "Outermost" terminology for `AttributeOrder` Follow-up to rust-lang/rust#143603. https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/attribute.20parsing.20rework/near/527768926 Also remove some outdated comments. cc `@jdonszelmann`
2025-07-10Rollup merge of #143657 - LorrensP-2158466:split-macro-map, r=petrochenkovMatthias Krüger-32/+52
Resolver: refact macro map into external and local maps Puts `MacroData` inside of the `ResolverArena` and splits `macro_map` into 2 maps: `local_macro_map` and `external_macro_map`. This way `get_macro_by_def_id` can take a `&Resolver` instead of a mutable one. Part of [#gsoc > Project: Parallel Macro Expansion](https://rust-lang.zulipchat.com/#narrow/channel/421156-gsoc/topic/Project.3A.20Parallel.20Macro.20Expansion/with/516965603) r? `@petrochenkov`
2025-07-10Rollup merge of #136906 - chenyukang:yukang-fix-136741-closure-body, r=oli-obkMatthias Krüger-5/+12
Add checking for unnecessary delims in closure body Fixes #136741
2025-07-10Auto merge of #143721 - tgross35:rollup-sjdfp6r, r=tgross35bors-25/+146
Rollup of 9 pull requests Successful merges: - rust-lang/rust#141996 (Fix `proc_macro::Ident`'s handling of `$crate`) - rust-lang/rust#142950 (mbe: Rework diagnostics for metavariable expressions) - rust-lang/rust#143011 (Make lint `ambiguous_glob_imports` deny-by-default and report-in-deps) - rust-lang/rust#143265 (Mention as_chunks in the docs for chunks) - rust-lang/rust#143270 (tests/codegen/enum/enum-match.rs: accept negative range attribute) - rust-lang/rust#143298 (`tests/ui`: A New Order [23/N]) - rust-lang/rust#143396 (Move NaN tests to floats/mod.rs) - rust-lang/rust#143398 (tidy: add support for `--extra-checks=auto:` feature) - rust-lang/rust#143644 (Add triagebot stdarch mention ping) r? `@ghost` `@rustbot` modify labels: rollup
2025-07-10Propagate from borrowed locals in CopyPropTomasz Miąsko-20/+6