about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2025-02-17Remove unused `Map::hir_node_by_def_id` method.Nicholas Nethercote-8/+0
2025-02-17Rename `rustc_middle/src/hir/map/mod.rs` as `map.rs`.Nicholas Nethercote-0/+0
There is no need for the extra subdirectory, and this makes the `map` module consistent with its sibling modules `nested_filter` and `place`.
2025-02-17Clarify `impl Map for !`.Nicholas Nethercote-7/+7
All the methods are unreachable, so make that clearer.
2025-02-17Avoid unnecessary use of the `Map` trait.Nicholas Nethercote-2/+2
The `Map` trait is there for cases where `tcx` isn't available. This isn't one of those cases, so it's simpler to just call through `tcx` directly.
2025-02-17Remove `SwitchIntTarget`.Nicholas Nethercote-18/+10
It's only passed to `Analysis::apply_switch_int_edge_effect`, and the existing impls of that method only use the `value` field. So pass that instead.
2025-02-17Update and clarify the comment on `SwitchTargets`.Nicholas Nethercote-11/+19
2025-02-17Add `SwitchTargetValue`.Nicholas Nethercote-12/+33
This is much clearer than `Option<u128>`.
2025-02-17Add a useful comment.Nicholas Nethercote-2/+9
2025-02-17Refactor `apply_effects_in_block`.Nicholas Nethercote-13/+7
Very minor changes that will make the next few commits easier to follow.
2025-02-17Rename `pattern_complexity` attr as `pattern_complexity_limit`.Nicholas Nethercote-4/+4
For consistency with `recursion_limit`, `move_size_limit`, and `type_length_limit`.
2025-02-17Move `rustc_middle::limits` to `rustc_interface`.Nicholas Nethercote-26/+23
It's always good to make `rustc_middle` smaller. `rustc_interface` is the best destination, because it's the only crate that calls `get_recursive_limit`.
2025-02-17Improve comments about limits.Nicholas Nethercote-7/+8
2025-02-17Merge `get_limit` and `get_limit_size`.Nicholas Nethercote-13/+2
Thanks to the previous commit, they no longer need to be separate.
2025-02-17Add `pattern_complexity_limit` to `Limits`.Nicholas Nethercote-34/+50
It's similar to the other limits, e.g. obtained via `get_limit`. So it makes sense to handle it consistently with the other limits. We now use `Limit`/`usize` in most places instead of `Option<usize>`, so we use `Limit::new(usize::MAX)`/`usize::MAX` to emulate how `None` used to work. The commit also adds `Limit::unlimited`.
2025-02-16Move hashes from rustc_data_structure to rustc_hashes so they can be shared ↵Ben Kimock-62/+102
with rust-analyzer
2025-02-16Pass through of target features to llvm-bitcode-linker and handling themkulst-0/+6
The .ptx version produced by llc can be specified by passing it with --mattr. Currently it is not possible to specify the .ptx version with -Ctarget-feature because these are not passed through to llvm-bitcode-linker and handled by it. This commit adds both. --target-feature and -mattr are passed with equals to mitigate issues when the value starts with a - (minus).
2025-02-16Persist target features used for codegen beyond tcxkulst-0/+3
Bitcode linkers like llvm-bitcode-linker or bpf linker hand over the target features to llvm during link stage. During link stage the `TyCtxt` is already gone so it is not possible to create a query for the global backend features any longer. The features preserved in `Session.target_features` only incorporate target features known to rustc. This would contradict with the behaviour during codegen stage which also passes target features to llvm which are unknown to rustc. This commit adds target features as a field to the `CrateInfo` struct and queries the target features in its new function. This way the target features are preserved beyond tcx and available at link stage. To make sure the `global_backend_features` query is always registered even if the CodegenBackend does not register it, this registration is added to the `provide`function of the `rustc_codegen_ssa` crate.
2025-02-16Remove SSE ABI from i586-pc-windows-msvcNoratrieb-0/+1
As an i586 target, it should not have SSE. This caused the following warning to be emitted: ``` warning: target feature `sse2` must be enabled to ensure that the ABI of the current target can be implemented correctly | = note: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #116344 <https://github.com/rust-lang/rust/issues/116344> warning: 1 warning emitted ```
2025-02-16Fix const items not being allowed to be called `r#move` or `r#static`Noratrieb-3/+5
Because of an ambiguity with const closures, the parser needs to ensure that for a const item, the `const` keyword isn't followed by a `move` or `static` keyword, as that would indicate a const closure: ```rust fn main() { const move // ... } ``` This check did not take raw identifiers into account, therefore being unable to distinguish between `const move` and `const r#move`. The latter is obviously not a const closure, so it should be allowed as a const item. This fixes the check in the parser to only treat `const ...` as a const closure if it's followed by the *proper keyword*, and not a raw identifier. Additionally, this adds a large test that tests for all raw identifiers in all kinds of positions, including `const`, to prevent issues like this one from occurring again.
2025-02-16Rollup merge of #137112 - scottmcm:box-drop-no-nonnull-project, r=oli-obkMatthias Krüger-9/+50
Don't project into `NonNull` when dropping a `Box` Another step towards banning these projections. Tracking Issue #133652
2025-02-16Rollup merge of #137102 - compiler-errors:name_regions2, r=oli-obkMatthias Krüger-7/+31
Rework `name_regions` to not rely on reverse scc graph for non-member-constrain usages Fixes https://github.com/rust-lang/rust/issues/137015 Splits the `name_regions` into two versions: One meant for member region constraint error reporting (which I've renamed to `name_regions_for_member_constraint`), and one meant *just* to replace region vids with an external region. Use the latter in the usage sites I added in #136559, since the regions returned by `name_regions_for_member_constraint` are also not *totally* accurate (which is fine for how they're used for member region constraint error reporting -- they're intentionally returning overapproximated universal regions so that we have something to name in `+ use<'a>` suggestions, because opaques can only capture universal regions and since member region constraints don't insert any edges into the region graph, the error region is probably gonna be shorter than a universal region) and because that function requires the reverse scc graph to have been computed which isn't done for our usages in #136559.
2025-02-16Rollup merge of #137072 - Urgau:check-cfg-load-builtins-at-once, r=NoratriebMatthias Krüger-6/+15
Load all builtin targets at once instead of one by one in check-cfg This PR adds a method on `rustc_target::Target` to load all the builtin targets at once, and then uses that method when constructing the `target_*` values in check-cfg instead of load loading each target one by one by their name, which requires a lookup and was more of a hack anyway. This may give us some performance improvements as we won't need to do the lookup for the _currently_ 287 targets we have.
2025-02-16invalid_from_utf8[_unchecked]: also lint inherent methodsPavel Grigorenko-3/+15
2025-02-16Auto merge of #136363 - notriddle:notriddle/unresolved-link-unused-refdef, ↵bors-2/+16
r=GuillaumeGomez rustdoc: improve refdef handling in the unresolved link lint This commit takes advantage of a feature in pulldown-cmark that makes the list of link definitions available to the consuming application. It produces unresolved link warnings for refdefs that aren't used, and can now produce exact spans for the dest even when it has escapes. Closes #133150 since this lint would have caught the mistake in that issue, and, along with https://github.com/rust-lang/rust-clippy/pull/13707, most mistakes in this class should produce a warning from one of them.
2025-02-16Auto merge of #137111 - jhpratt:rollup-izd98sx, r=jhprattbors-48/+91
Rollup of 5 pull requests Successful merges: - #135797 (Import initial generated 1.85 relnotes) - #135909 (Export kernel descriptor for amdgpu kernels) - #136545 (nvptx64: update default alignment to match LLVM 21) - #137092 (abi_unsupported_vector_types: say which type is the problem) - #137097 (Ignore Self in bounds check for associated types with Self:Sized) r? `@ghost` `@rustbot` modify labels: rollup
2025-02-15Don't project into `NonNull` when dropping a `Box`Scott McMurray-9/+50
2025-02-16Rollup merge of #137097 - compiler-errors:sized-bound-self, r=oli-obkJacob Pratt-0/+3
Ignore Self in bounds check for associated types with Self:Sized Fixes https://github.com/rust-lang/rust/issues/137053 This is morally a fix of https://github.com/rust-lang/rust/pull/112319, since the `Self: Sized` check was just missing here. r? oli-obk
2025-02-16Rollup merge of #137092 - ↵Jacob Pratt-15/+20
RalfJung:abi_unsupported_vector_types-better-error, r=compiler-errors abi_unsupported_vector_types: say which type is the problem
2025-02-16Rollup merge of #136545 - durin42:nvptx64-align, r=nikicJacob Pratt-1/+7
nvptx64: update default alignment to match LLVM 21 This changed in llvm/llvm-project@91cb8f5d3202870602c6bef807bc4c7ae8a32790. The commit itself is mostly about some intrinsic instructions, but as an aside it also mentions something about addrspace for tensor memory, which I believe is what this string is telling us. `@rustbot` label: +llvm-main
2025-02-16Rollup merge of #135909 - Flakebi:amdgpu-kd, r=jieyouxu,workingjubileeJacob Pratt-32/+61
Export kernel descriptor for amdgpu kernels The host runtime (HIP or HSA) expects a kernel descriptor object for each kernel in the ELF file. The amdgpu LLVM backend generates the object. It is created as a symbol with the name of the kernel plus a `.kd` suffix. Add it to the exported symbols in the linker script, so that it can be found. For reference, the symbol is created here in LLVM: https://github.com/llvm/llvm-project/blob/d5457e4c1619e5dbeefd49841e284cbc24d35cb4/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp#L966 I wrote [a test](https://github.com/Flakebi/rust/commit/6a9115b121b48a8cd4aaf100551569dc70c6c704) for this as well, I’ll add that once the target is merged and working. With this, all PRs to get working code for amdgpu are open (this + the target + the two patches adding addrspacecasts for alloca and global variables). Tracking issue: #135024 r? `@workingjubilee`
2025-02-16Auto merge of #137078 - bjorn3:sync_cg_clif-2025-02-15, r=bjorn3bors-13/+20
Subtree sync for rustc_codegen_cranelift This fixes a miscompilation (https://github.com/rust-lang/rustc_codegen_cranelift/issues/1560) r? `@ghost` `@rustbot` label +A-codegen +A-cranelift +T-compiler
2025-02-15HIR analysis: Remove unnecessary abstraction over list of clausesLeón Orell Valerian Liehr-206/+114
2025-02-15Rework name_regions to not rely on reverse scc graph for ↵Michael Goulet-7/+31
non-member-constrain usages
2025-02-15Ignore Self in bounds check for associated types with Self:SizedMichael Goulet-0/+3
2025-02-15rustdoc: improve refdef handling in the unresolved link lintMichael Howell-2/+16
This commit takes advantage of a feature in pulldown-cmark that makes the list of link definitions available to the consuming application. It produces unresolved link warnings for refdefs that aren't used, and can now produce exact spans for the dest even when it has escapes.
2025-02-15Rollup merge of #136808 - chenyukang:yukang-fix-arg-list-error-129273, ↵Matthias Krüger-16/+13
r=estebank Try to recover from path sep error in type parsing Fixes #129273 Error using `:` in the argument list may mess up the parser. case `tests/ui/suggestions/struct-field-type-including-single-colon` also changed, seems it's the same meaning, should be OK. r? `@estebank`
2025-02-15Rollup merge of #136490 - Skepfyr:no-field-rest-pattern-attrs, r=compiler-errorsMatthias Krüger-11/+11
Do not allow attributes on struct field rest patterns Fixes #81282. This removes support for attributes on struct field rest patterns (the `..` bit) from the parser. Previously any attributes were being parsed but dropped from the AST, so didn't work and were deleted by rustfmt. This needs an equivalent change to the reference but I wanted to see how this PR is received first. The error message it produces isn't great, however it does match the error you get if you try to add attributes to .. in struct expressions atm, although I can understand wanting to do better given this was previously accepted. I think I could move attribute parsing back up to where it was and then emit a specific new error for this case, however I might need some guidance as this is the first time I've messed around inside the compiler. While this is technically breaking I don't think it's much of an issue: attributes in this position don't currently do anything and rustfmt outright deletes them, meaning it's incredibly unlikely to affect anyone. I have already made the equivalent change to *add* support for attributes (mostly) but the conversation in the linked issue suggested it would be more reasonable to just remove them (and pointed out it's much easier to add support later if we realise we need them).
2025-02-15Rollup merge of #127581 - fmease:fix-crate_name-validation, r=bjorn3Matthias Krüger-137/+154
Fix crate name validation Reject macro calls inside attribute `#![crate_name]` like in `#![crate_name = concat!("na", "me")]`. Prior to #117584, the result of the expansion (here: `"name"`) would actually be properly picked up by the compiler and used as the crate name. However since #117584 / on master, we extract the "value" (i.e., the *literal* string literal) of the `#![crate_name]` much earlier in the pipeline way before macro expansion and **skip**/**ignore** any `#![crate_name]`s "assigned to" a macro call. See also #122001. T-lang has ruled to reject `#![crate_name = MACRO!(...)]` outright very similar to other built-in attributes whose value we need early like `#![crate_type]`. See accepted FCP: https://github.com/rust-lang/rust/issues/122001#issuecomment-2023203182. Note that the check as implemented in this PR is even more "aggressive" compared to the one of `#![crate_type]` by running as early as possible in order to reject `#![crate_name = MACRO!(...)]` even in "non-normal" executions of `rustc`, namely on *print requests* (e.g., `--print=crate-name` and `--print=file-names`). If I were to move the validation step a bit further back close to the `#![crate_type]` one, `--print=crate-name` (etc.) would *not* exit fatally with an error in this kind of situation but happily report an incorrect crate name (i.e., the "crate name" as if `#![crate_name]` didn't exist / deduced from other sources like `--crate-name` or the file name) which would match the behavior on master. Again, see also #122001. I'm mentioning this explicitly because I'm not sure if it was that clear in the FCP'ed issue. I argue that my current approach is the most reasonable one. I know (from reading the code and from past experiments) that various print requests are still quite broken (mostly lack of validation). To the best of my knowledge, there's no print request whose output references/contains a crate *type*, so there's no "inherent need" to move `#![crate_type]`'s validation to happen earlier. --- Fixes #122001. https://github.com/rust-lang/rust/labels/relnotes: Compatibility. Breaking change.
2025-02-15abi_unsupported_vector_types: say which type is the problemRalf Jung-15/+20
2025-02-15Replace some u64 hashes with Hash64Ben Kimock-15/+25
2025-02-15Load all builtin targets at once instead of one by oneUrgau-6/+15
This should give us some performance improvements as we won't need to do the lookup for the _currently_ 287 targets we have.
2025-02-15Reject macro calls inside of `#![crate_name]`León Orell Valerian Liehr-114/+128
2025-02-15Merge commit '557ed8ebb7e981817d03c87352892c394183dd70' into ↵bjorn3-13/+20
sync_cg_clif-2025-02-15
2025-02-15Rollup merge of #137056 - geetanshjuneja:pub, r=RalfJungJacob Pratt-1/+2
made check_argument_compat public for use in miri Links to [issue](https://github.com/rust-lang/miri/issues/3842) and it's [PR](https://github.com/rust-lang/miri/pull/4185#issuecomment-2657554989) in miri.
2025-02-15Rollup merge of #137029 - chenyukang:yukang-fix-unused-check, ↵Jacob Pratt-24/+0
r=jieyouxu,compiler-errors Remove unnecessary check code in unused_delims After PR #108297, we make sure there is no unmatched delims in early lint check.
2025-02-15Rollup merge of #137028 - Zalathar:thir-pat-expr, r=compiler-errorsJacob Pratt-38/+44
mir_build: Clarify some code for lowering `hir::PatExpr` to THIR A few loosely-related improvements to the code that lowers certain parts of HIR patterns to THIR. I was originally deferring this until after #136529, but that PR probably won't happen, whereas these changes should hopefully be uncontroversial. r? Nadrieril or reroll
2025-02-15add a doc commentRalf Jung-0/+1
2025-02-15fix: Alloc new errorcode E0803 for E0495xizheyin-2/+49
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-02-15made check_argument_compat publicgeetanshjuneja-1/+1
2025-02-15Clean up rustc_session::output::{find,validate}_crate_nameLeón Orell Valerian Liehr-56/+59