about summary refs log tree commit diff
path: root/compiler/rustc_middle/src
AgeCommit message (Collapse)AuthorLines
2025-01-28Represent the raw pointer for a array length check as a new kind of fake borrowMichael Goulet-5/+62
2025-01-27Rollup merge of #136118 - oli-obk:push-qsslxsopnrmr, r=ZalatharGuillaume Gomez-4/+11
Change `collect_and_partition_mono_items` tuple return type to a struct https://github.com/rust-lang/rust/pull/133429 will add a new field to this tuple, so it seems prudent to turn it into a struct first to avoid confusion about what the tuple elements mean.
2025-01-27Rollup merge of #136114 - compiler-errors:more-idents, r=jieyouxuGuillaume Gomez-0/+9
Use identifiers more in diagnostics code This should make the diagnostics code slightly more correct when rendering idents in mixed crate edition situations. Kinda a no-op, but a cleanup regardless. r? oli-obk or reassign
2025-01-27Rollup merge of #135988 - bjorn3:workaround_parallel_rustc_crash, r=lqdGuillaume Gomez-15/+30
Add a workaround for parallel rustc crashing when there are delayed bugs This doesn't fix the root cause of this crash, but at least stops it from happening for the time being. Workaround for https://github.com/rust-lang/rust/issues/135870
2025-01-27Change `collect_and_partition_mono_items` tuple return type to a structOli Scherer-4/+11
2025-01-27Use identifiers in diagnostics more oftenMichael Goulet-0/+9
2025-01-27Add `TooGeneric` variant to `LayoutError` and emit `Unknown` oneFedericoBruzzone-4/+13
- `check-pass` test for a MRE of #135020 - fail test for #135138 - switch to `TooGeneric` for checking CMSE fn signatures - switch to `TooGeneric` for compute `SizeSkeleton` (for transmute) - fix broken tests
2025-01-26Compiler: Finalize dyn compatibility renamingLeón Orell Valerian Liehr-1/+1
2025-01-26Auto merge of #135753 - compiler-errors:from-ty-const, r=oli-obkbors-15/+5
Get rid of `mir::Const::from_ty_const` This function is strange, because it turns valtrees into `mir::Const::Value`, but the rest of the const variants stay as type system consts. All of the callsites except for one in `instsimplify` (array length simplification of `ptr_metadata` call) just go through the valtree arm of the function, so it's easier to just create a `mir::Const` directly for those. For the instsimplify case, if we have a type system const we should *keep* having a type system const, rather than turning it into a `mir::Const::Value`; it doesn't really matter in practice, though, bc `usize` has no padding, but it feels more principled.
2025-01-25Rollup merge of #136031 - lqd:polonius-debugger-episode-1, r=compiler-errorsJacob Pratt-23/+46
Expand polonius MIR dump This PR starts expanding the polonius MIR: - switches to an HTML file, to show graphs in the same document as the MIR dump, share them more easily since it's a single file that can be hosted as a gist, and also to allow for interactivity in the near future. - adds the regular NLL MIR + polonius constraints - embeds a mermaid version of the CFG, similar to the graphviz one, but that needs a smaller js than `dot`'s emscripten js from graphvizonline [Here's an example](https://gistpreview.github.io/?0c18f2a59b5e24ac0f96447aa34ffe00) of how it looks. --- In future PRs: mermaid graphs of the NLL region graph, of the NLL SCCs, of the polonius localized outlives constraints, and the interactive polonius MIR dump. r? ```@matthewjasper```
2025-01-25Rollup merge of #135951 - yotamofek:use-debug-helpers, r=SparrowLiiJacob Pratt-94/+55
Use `fmt::from_fn` in more places in the compiler Use the unstable functions from #117729 in more places in the compiler, follow up to #135494
2025-01-25Auto merge of #119286 - jyn514:linker-output, r=bjorn3bors-3/+3
show linker output even if the linker succeeds Show stderr and stderr by default, controlled by a new `linker_messages` lint. fixes https://github.com/rust-lang/rust/issues/83436. fixes https://github.com/rust-lang/rust/issues/38206. cc https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/uplift.20some.20-Zverbose.20calls.20and.20rename.20to.E2.80.A6.20compiler-team.23706/near/408986134 <!-- try-job: dist-x86_64-msvc --> try-job: aarch64-apple r? `@bjorn3`
2025-01-25fix terminator edges commentsRémy Rakic-2/+4
2025-01-25extract principal MIR dump functionRémy Rakic-21/+42
for cases where we want to dump the MIR to a given writer instead of a new file as the default does. this will be used when dumping the MIR to a buffer to process differently, e.g. post-process to escape for an HTML dump.
2025-01-25Auto merge of #128657 - clubby789:optimize-none, r=fee1-dead,WaffleLapkinbors-1/+1
Add `#[optimize(none)]` cc #54882 This extends the `optimize` attribute to add `none`, which corresponds to the LLVM `OptimizeNone` attribute. Not sure if an MCP is required for this, happy to file one if so.
2025-01-24Rename `OptimizeAttr::None` to `Default`clubby789-1/+1
2025-01-24Rollup merge of #135873 - Zalathar:be-prepared, r=oli-obkMatthias Krüger-16/+29
coverage: Prepare for upcoming changes to counter creation This is a collection of smaller changes to coverage instrumentation code that have been extracted from a larger PR that I'm still working on, in order to hopefully make review easier. Each individual change should hopefully be mostly self-explanatory. One of the big goals of the upcoming PR will be to defer certain parts of counter-creation until codegen, via the query system, so that ends up being a recurring theme in these changes. Several of the changes are follow-ups to #135481. There should be no observable change in compiler output.
2025-01-24use `fmt::from_fn` in more places, instead of using structs that impl ↵Yotam Ofek-94/+55
formatting traits
2025-01-24Add a workaround for parallel rustc crashing when there are delayed bugsbjorn3-15/+30
This doesn't fix the root cause of this crash, but at least stops it from happening for the time being.
2025-01-24Auto merge of #135272 - BoxyUwU:generic_arg_infer_reliability_2, ↵bors-13/+19
r=compiler-errors Forbid usage of `hir` `Infer` const/ty variants in ambiguous contexts The feature `generic_arg_infer` allows providing `_` as an argument to const generics in order to infer them. This introduces a syntactic ambiguity as to whether generic arguments are type or const arguments. In order to get around this we introduced a fourth `GenericArg` variant, `Infer` used to represent `_` as an argument to generic parameters when we don't know if its a type or a const argument. This made hir visitors that care about `TyKind::Infer` or `ConstArgKind::Infer` very error prone as checking for `TyKind::Infer`s in `visit_ty` would find *some* type infer arguments but not *all* of them as they would sometimes be lowered to `GenericArg::Infer` instead. Additionally the `visit_infer` method would previously only visit `GenericArg::Infer` not *all* infers (e.g. `TyKind::Infer`), this made it very easy to override `visit_infer` and expect it to visit all infers when in reality it would only visit *some* infers. --- This PR aims to fix those issues by making the `TyKind` and `ConstArgKind` types generic over whether the infer types/consts are represented by `Ty/ConstArgKind::Infer` or out of line (e.g. by a `GenericArg::Infer` or accessible by overiding `visit_infer`). We then make HIR Visitors convert all const args and types to the versions where infer vars are stored out of line and call `visit_infer` in cases where a `Ty`/`Const` would previously have had a `Ty/ConstArgKind::Infer` variant: API Summary ```rust enum AmbigArg {} enum Ty/ConstArgKind<Unambig = ()> { ... Infer(Unambig), } impl Ty/ConstArg { fn try_as_ambig_ty/ct(self) -> Option<Ty/ConstArg<AmbigArg>>; } impl Ty/ConstArg<AmbigArg> { fn as_unambig_ty/ct(self) -> Ty/ConstArg; } enum InferKind { Ty(Ty), Const(ConstArg), Ambig(InferArg), } trait Visitor { ... fn visit_ty/const_arg(&mut self, Ty/ConstArg<AmbigArg>) -> Self::Result; fn visit_infer(&mut self, id: HirId, sp: Span, kind: InferKind) -> Self::Result; } // blanket impl'd, not meant to be overriden trait VisitorExt { fn visit_ty/const_arg_unambig(&mut self, Ty/ConstArg) -> Self::Result; } fn walk_unambig_ty/const_arg(&mut V, Ty/ConstArg) -> Self::Result; fn walk_ty/const_arg(&mut V, Ty/ConstArg<AmbigArg>) -> Self::Result; ``` The end result is that `visit_infer` visits *all* infer args and is also the *only* way to visit an infer arg, `visit_ty` and `visit_const_arg` can now no longer encounter a `Ty/ConstArgKind::Infer`. Representing this in the type system means that it is now very difficult to mess things up, either accessing `TyKind::Infer` "just works" and you won't miss *some* type infers- or it doesn't work and you have to look at `visit_infer` or some `GenericArg::Infer` which forces you to think about the full complexity involved. Unfortunately there is no lint right now about explicitly matching on uninhabited variants, I can't find the context for why this is the case :woman_shrugging: I'm not convinced the framing of un/ambig ty/consts is necessarily the right one but I'm not sure what would be better. I somewhat like calling them full/partial types based on the fact that `Ty<Partial>`/`Ty<Full>` directly specifies how many of the type kinds are actually represented compared to `Ty<Ambig>` which which leaves that to the reader to figure out based on the logical consequences of it the type being in an ambiguous position. --- tool changes have been modified in their own commits for easier reviewing by anyone getting cc'd from subtree changes. I also attempted to split out "bug fixes arising from the refactoring" into their own commit so they arent lumped in with a big general refactor commit Fixes #112110
2025-01-24coverage: Make query `coverage_ids_info` return an OptionZalathar-1/+3
This reflects the fact that we can't compute meaningful info for a function that wasn't instrumented and therefore doesn't have `function_coverage_info`.
2025-01-24Exclude `mir::coverage` types from TypeFoldable/TypeVisitableZalathar-15/+26
These types are unlikely to ever contain type information in the foreseeable future, so excluding them from TypeFoldable/TypeVisitable avoids some unhelpful derive boilerplate.
2025-01-23`visit_x_unambig`Boxy-2/+2
2025-01-23Split hir `TyKind` and `ConstArgKind` in two and update `hir::Visitor`Boxy-8/+14
2025-01-23Make `hir::TyKind::TraitObject` use tagged ptrBoxy-7/+7
2025-01-23Allow `arena_cache` queries to return `Option<&'tcx T>`Zalathar-9/+64
2025-01-22Auto merge of #134478 - compiler-errors:attr-span, r=oli-obkbors-1/+4
Properly record metavar spans for other expansions other than TT This properly records metavar spans for nonterminals other than tokentree. This means that we operations like `span.to(other_span)` work correctly for macros. As you can see, other diagnostics involving metavars have improved as a result. Fixes #132908 Alternative to #133270 cc `@ehuss` cc `@petrochenkov`
2025-01-21Rollup merge of #135706 - compiler-errors:elaborate, r=lcnrMatthias Krüger-11/+6
Move `supertrait_def_ids` into the elaborate module like all other fns It's strange that this is the only elaborate-like fn on tcx. r? lcnr
2025-01-21Auto merge of #134299 - RalfJung:remove-start, r=compiler-errorsbors-3/+0
remove support for the (unstable) #[start] attribute As explained by `@Noratrieb:` `#[start]` should be deleted. It's nothing but an accidentally leaked implementation detail that's a not very useful mix between "portable" entrypoint logic and bad abstraction. I think the way the stable user-facing entrypoint should work (and works today on stable) is pretty simple: - `std`-using cross-platform programs should use `fn main()`. the compiler, together with `std`, will then ensure that code ends up at `main` (by having a platform-specific entrypoint that gets directed through `lang_start` in `std` to `main` - but that's just an implementation detail) - `no_std` platform-specific programs should use `#![no_main]` and define their own platform-specific entrypoint symbol with `#[no_mangle]`, like `main`, `_start`, `WinMain` or `my_embedded_platform_wants_to_start_here`. most of them only support a single platform anyways, and need cfg for the different platform's ways of passing arguments or other things *anyways* `#[start]` is in a super weird position of being neither of those two. It tries to pretend that it's cross-platform, but its signature is a total lie. Those arguments are just stubbed out to zero on ~~Windows~~ wasm, for example. It also only handles the platform-specific entrypoints for a few platforms that are supported by `std`, like Windows or Unix-likes. `my_embedded_platform_wants_to_start_here` can't use it, and neither could a libc-less Linux program. So we have an attribute that only works in some cases anyways, that has a signature that's a total lie (and a signature that, as I might want to add, has changed recently, and that I definitely would not be comfortable giving *any* stability guarantees on), and where there's a pretty easy way to get things working without it in the first place. Note that this feature has **not** been RFCed in the first place. *This comment was posted [in May](https://github.com/rust-lang/rust/issues/29633#issuecomment-2088596042) and so far nobody spoke up in that issue with a usecase that would require keeping the attribute.* Closes https://github.com/rust-lang/rust/issues/29633 try-job: x86_64-gnu-nopt try-job: x86_64-msvc-1 try-job: x86_64-msvc-2 try-job: test-various
2025-01-21Move supertrait_def_ids into the elaborate module like all other fnsMichael Goulet-11/+6
2025-01-21remove support for the #[start] attributeRalf Jung-3/+0
2025-01-21Also generate undef scalars and scalar pairsOli Scherer-1/+1
2025-01-20make it possible to silence linker warnings with a crate-level attributejyn-3/+3
this was slightly complicated because codegen_ssa doesn't have access to a tcx.
2025-01-20Get rid of mir::Const::from_ty_constMichael Goulet-15/+5
2025-01-19Manual cleanup of some `is_{or_none|some_and}` usagesYotam Ofek-2/+2
2025-01-19Run `clippy --fix` for `unnecessary_map_or` lintYotam Ofek-7/+7
2025-01-19Auto merge of #135709 - lqd:bring-back-len, r=compiler-errorsbors-3/+21
Temporarily bring back `Rvalue::Len` r? `@compiler-errors` as requested in https://github.com/rust-lang/rust/issues/135671#issuecomment-2599580364 > However, in the mean time, I'd rather we not crunch trying to find and more importantly validate the soundness of a solution 🤔 Agreed. To fix the IMO P-critical #135671 for which we somehow didn't have test coverage, this PR temporarily reverts: - https://github.com/rust-lang/rust/pull/133734 - its bugfix https://github.com/rust-lang/rust/pull/134371 - https://github.com/rust-lang/rust/pull/134330 cc `@scottmcm` I added the few samples from that issue as a test, but we can add more in the future, in particular it seems `@steffahn` [will work on that](https://github.com/rust-lang/rust/issues/135671#issuecomment-2599714354). Fixes #135671. And if we want to land this, it should also be nominated for beta backport.
2025-01-19Auto merge of #135715 - matthiaskrgr:rollup-9a18sxj, r=matthiaskrgrbors-2/+1
Rollup of 4 pull requests Successful merges: - #135641 ([rustdoc] Replace module list items `ul`/`li` with `dl`/`dd`/`dt` elements) - #135703 (Disallow `A { .. }` if `A` has no fields) - #135705 (Consolidate ad-hoc MIR lints into real pass-manager-based MIR lints) - #135708 (Some random compiler nits) Failed merges: - #135685 (Remove unused `item-row` CSS class) r? `@ghost` `@rustbot` modify labels: rollup
2025-01-19Rollup merge of #135697 - compiler-errors:poly-trait-ref, r=lqdMatthias Krüger-12/+1
Get rid of `ToPolyTraitRef` It's generally a footgun, since it throws away `PredicatePolarity`. This PR doesn't attempt to fix any related bugs having to do with binders or polarity; it just tries to pass through `TraitPredicate`s around instead of `TraitRef`s. There should be basically no functional changes.
2025-01-18Revert "Auto merge of #133734 - scottmcm:lower-indexing-to-ptrmetadata, ↵Rémy Rakic-3/+0
r=davidtwco,RalfJung" This reverts commit b57d93d8b9525fa261404b4cd9c0670eeb1264b8, reversing changes made to 0aeaa5eb22180fdf12a8489e63c4daa18da6f236.
2025-01-18Revert "Auto merge of #134330 - scottmcm:no-more-rvalue-len, r=matthewjasper"Rémy Rakic-0/+21
This reverts commit e108481f74ff123ad98a63bd107a18d13035b275, reversing changes made to 303e8bd768526a5812bb1776e798e829ddb7d3ca.
2025-01-18Fix commentMichael Goulet-2/+1
2025-01-18Get rid of `ToPolyTraitRef`Michael Goulet-12/+1
2025-01-18coverage: Remove `BcbCounter` and `BcbExpression`Zalathar-6/+2
Making these separate types from `CovTerm` and `Expression` was historically very helpful, but now that most of the counter-creation work is handled by `node_flow` they are no longer needed.
2025-01-17Auto merge of #135047 - Flakebi:amdgpu-kernel-cc, r=workingjubileebors-0/+1
Add gpu-kernel calling convention The amdgpu-kernel calling convention was reverted in commit f6b21e90d1ec01081bc2619efb68af6788a63d65 (#120495 and https://github.com/rust-lang/rust-analyzer/pull/16463) due to inactivity in the amdgpu target. Introduce a `gpu-kernel` calling convention that translates to `ptx_kernel` or `amdgpu_kernel`, depending on the target that rust compiles for. Tracking issue: #135467 amdgpu target tracking issue: #135024
2025-01-16Auto merge of #135592 - matthiaskrgr:rollup-4t69l7i, r=matthiaskrgrbors-1/+32
Rollup of 7 pull requests Successful merges: - #134754 (Implement `use` associated items of traits) - #135481 (coverage: Completely overhaul counter assignment, using node-flow graphs) - #135504 (Allow coercing safe-to-call target_feature functions to safe fn pointers) - #135561 (Update docs for `-Clink-dead-code` to discourage its use) - #135574 (ci: mirror ubuntu:22.04 to ghcr.io) - #135585 (resolve symlinks of LLVM tool binaries before copying them) - #135588 (Add license-metadata.json to rustc-src tarball.) r? `@ghost` `@rustbot` modify labels: rollup
2025-01-16Auto merge of #134504 - oli-obk:push-rltsvnyttwll, r=compiler-errorsbors-2/+37
Use trait definition cycle detection for trait alias definitions, too fixes #133901 In general doing this for `All` is not right, but this code path is specifically for traits and trait aliases, and there we only ever use `All` for trait aliases.
2025-01-16Rollup merge of #135504 - veluca93:target-feature-cast-to-fn-ptr, r=oli-obkMatthias Krüger-1/+32
Allow coercing safe-to-call target_feature functions to safe fn pointers r? oli-obk `@oli-obk:` this is based on your PR #134353 :-) See https://github.com/rust-lang/rust/pull/134090#issuecomment-2539422624 for the motivation behind this change.
2025-01-16Coerce safe-to-call target_feature functions to fn pointers.Luca Versari-1/+32
2025-01-16Add gpu-kernel calling conventionFlakebi-0/+1
The amdgpu-kernel calling convention was reverted in commit f6b21e90d1ec01081bc2619efb68af6788a63d65 due to inactivity in the amdgpu target. Introduce a `gpu-kernel` calling convention that translates to `ptx_kernel` or `amdgpu_kernel`, depending on the target that rust compiles for.