about summary refs log tree commit diff
path: root/compiler/rustc_middle/src
AgeCommit message (Collapse)AuthorLines
2025-03-10Convert `ShardedHashMap` to use `hashbrown::HashTable`Josh Stone-17/+7
The `hash_raw_entry` feature has finished fcp-close, so the compiler should stop using it to allow its removal. Several `Sharded` maps were using raw entries to avoid re-hashing between shard and map lookup, and we can do that with `hashbrown::HashTable` instead.
2025-03-10fix ICE in pretty-printing `global_asm!`Folkert de Vries-1/+4
2025-03-10make precise capturing args in rustdoc Json typedmorine0122-2/+4
2025-03-10Revert "Use workspace lints for crates in `compiler/` #138084"许杰友 Jieyou Xu (Joe)-0/+1
Revert <https://github.com/rust-lang/rust/pull/138084> to buy time to consider options that avoids breaking downstream usages of cargo on distributed `rustc-src` artifacts, where such cargo invocations fail due to inability to inherit `lints` from workspace root manifest's `workspace.lints` (this is only valid for the source rust-lang/rust workspace, but not really the distributed `rustc-src` artifacts). This breakage was reported in <https://github.com/rust-lang/rust/issues/138304>. This reverts commit 48caf81484b50dca5a5cebb614899a3df81ca898, reversing changes made to c6662879b27f5161e95f39395e3c9513a7b97028.
2025-03-10Remove AdtFlags::IS_ANONYMOUS and Copy/Clone condition for anonymous ADTMichael Goulet-9/+1
2025-03-09Auto merge of #137695 - nnethercote:always-inline-query_get_at, r=saethlinbors-1/+1
Always inline `query_get_at`. r? `@saethlin`
2025-03-09Rollup merge of #138160 - jdonszelmann:move-find-attr2, r=oli-obkMatthias Krüger-19/+20
depend more on attr_data_structures and move find_attr! there r? ``@oli-obk`` This should be an easy one. It just moves some imports around. This is necessary for other changes that I'm working on not to have import cycles. However, it's an easy one to just merge on its own.
2025-03-09Rollup merge of #138158 - moulins:move-layout-to-rustc_abi, r=workingjubileeMatthias Krüger-34/+13
Move more layouting logic to `rustc_abi` Move all `LayoutData`-constructing code to `rustc_abi`: - Infaillible operations get a new `LayoutData` constructor method; - Faillible ones get a new method on `LayoutCalculator`.
2025-03-09Rollup merge of #138084 - nnethercote:workspace-lints, r=jieyouxuMatthias Krüger-1/+0
Use workspace lints for crates in `compiler/` This is nicer and hopefully less error prone than specifying lints via bootstrap. r? ``@jieyouxu``
2025-03-09Rollup merge of #138040 - thaliaarchi:use-prelude-size-of.compiler, ↵Matthias Krüger-19/+18
r=compiler-errors compiler: Use `size_of` from the prelude instead of imported Use `std::mem::{size_of, size_of_val, align_of, align_of_val}` from the prelude instead of importing or qualifying them. Apply this change across the compiler. These functions were added to all preludes in Rust 1.80. r? ``@compiler-errors``
2025-03-09Rollup merge of #136968 - oli-obk:bye-bye, r=compiler-errorsMatthias Krüger-52/+1
Turn order dependent trait objects future incompat warning into a hard error fixes #56484 r? ``@ghost`` will FCP when we have a crater result
2025-03-08Move SIMD layout logic to `rustc_abi`Moulins-6/+1
2025-03-08Remove most manual LayoutData creations and move them to `rustc_abi`Moulins-28/+12
...either as: - methods on LayoutCalculator, for faillible operations; - constructors on LayoutData, for infaillible ones.
2025-03-08Remove `#![warn(unreachable_pub)]` from all `compiler/` crates.Nicholas Nethercote-1/+0
(Except for `rustc_codegen_cranelift`.) It's no longer necessary now that `unreachable_pub` is in the workspace lints.
2025-03-07compiler: Use size_of from the prelude instead of importedThalia Archibald-19/+18
Use `std::mem::{size_of, size_of_val, align_of, align_of_val}` from the prelude instead of importing or qualifying them. These functions were added to all preludes in Rust 1.80.
2025-03-07Rollup merge of #138150 - nnethercote:streamline-intravisit-visit_id, r=oli-obkMatthias Krüger-1/+1
Streamline HIR intravisit `visit_id` calls for items A small clean up.
2025-03-07Rollup merge of #137977 - nnethercote:less-kw-Empty-1, r=spastorinoMatthias Krüger-6/+8
Reduce `kw::Empty` usage, part 1 This PR fixes some confusing `kw::Empty` usage, fixing a crash test along the way. r? ```@spastorino```
2025-03-07Rollup merge of #134797 - spastorino:ergonomic-ref-counting-1, r=nikomatsakisMatthias Krüger-2/+33
Ergonomic ref counting This is an experimental first version of ergonomic ref counting. This first version implements most of the RFC but doesn't implement any of the optimizations. This was left for following iterations. RFC: https://github.com/rust-lang/rfcs/pull/3680 Tracking issue: https://github.com/rust-lang/rust/issues/132290 Project goal: https://github.com/rust-lang/rust-project-goals/issues/107 r? ```@nikomatsakis```
2025-03-07depend more on attr_data_structures and move find_attr! thereJana Dönszelmann-19/+20
2025-03-07Add helper methods checking for "#[non_exhaustive] that's active"Maja Kądziołka-2/+24
A check for `#[non_exhaustive]` is often done in combination with checking whether the type is local to the crate, in a variety of ways. Create a helper method and standardize on it as the way to check for this.
2025-03-07Make synthetic RPITIT assoc ty name handling more rigorous.Nicholas Nethercote-4/+6
Currently it relies on special treatment of `kw::Empty`, which is really easy to get wrong. This commit makes the special case clearer in the type system by using `Option`. It's a bit clumsy, but the synthetic name handling itself is a bit clumsy; better to make it explicit than sneak it in. Fixes #133426.
2025-03-07Pass `Option<Symbol>` to `def_path_data`/`create_def` methods.Nicholas Nethercote-2/+2
It's clearer than using `kw::Empty` to mean `None`.
2025-03-07Move `visit_id` calls.Nicholas Nethercote-1/+1
In `walk_item`, we call `visit_id` on every item kind. For most of them we do it directly in `walk_item`. But for `ItemKind::Mod`, `ItemKind::Enum`, and `ItemKind::Use` we instead do it in the `walk_*` function called (via the `visit_*` function) from `walk_item`. I can see no reason for this inconsistency, so this commit makes those three cases like all the other cases, moving the `visit_id` calls into `walk_item`. This also avoids the need for a few `HirId` arguments.
2025-03-07Increase recursion_limit in numerous crates.Nicholas Nethercote-0/+1
This is temporarily needed for `x doc compiler` to work. They can be removed once the `Nonterminal` is removed (#124141).
2025-03-07Auto merge of #138127 - compiler-errors:rollup-kcarqrz, r=compiler-errorsbors-0/+5
Rollup of 17 pull requests Successful merges: - #137827 (Add timestamp to unstable feature usage metrics) - #138041 (bootstrap and compiletest: Use `size_of_val` from the prelude instead of imported) - #138046 (trim channel value in `get_closest_merge_commit`) - #138053 (Increase the max. custom try jobs requested to `20`) - #138061 (triagebot: add a `compiler_leads` ad-hoc group) - #138064 (Remove - from xtensa targets cpu names) - #138075 (Use final path segment for diagnostic) - #138078 (Reduce the noise of bootstrap changelog warnings in --dry-run mode) - #138081 (Move `yield` expressions behind their own feature gate) - #138090 (`librustdoc`: flatten nested ifs) - #138092 (Re-add `DynSend` and `DynSync` impls for `TyCtxt`) - #138094 (a small borrowck cleanup) - #138098 (Stabilize feature `const_copy_from_slice`) - #138103 (Git ignore citool's target directory) - #138105 (Fix broken link to Miri intrinsics in documentation) - #138108 (Mention me (WaffleLapkin) when changes to `rustc_codegen_ssa` occur) - #138117 ([llvm/PassWrapper] use `size_t` when building arg strings) r? `@ghost` `@rustbot` modify labels: rollup
2025-03-06Account for UseCloned on expr_use_visitorSantiago Pastorino-0/+17
2025-03-06Generate the right MIR for by use closuresSantiago Pastorino-2/+5
2025-03-06Implement .use keyword as an alias of cloneSantiago Pastorino-0/+11
2025-03-06Rollup merge of #137920 - RalfJung:provenance-map-emptiness, r=oli-obkMichael Goulet-22/+22
interpret/provenance_map: consistently use range_is_empty https://github.com/rust-lang/rust/pull/137704 started using this for per-ptr provenance; let's be consistent and use it also for the per-byte provenance check. Also rename the methods to avoid having both "get" and "is_empty" in the name. r? ````@oli-obk````
2025-03-06Rollup merge of #137820 - meithecatte:instantiate-opt, r=BoxyUwUMichael Goulet-1/+9
Clarify why InhabitedPredicate::instantiate_opt exists At first glance, the extra casework seems pointless and needlessly error-prone. Clarify that there is a reason for it being there.
2025-03-06Rollup merge of #137764 - compiler-errors:always-applicable-negative-impl, ↵Michael Goulet-2/+2
r=lcnr Ensure that negative auto impls are always applicable r? lcnr (or reassign if you dont want to review) https://github.com/rust-lang/rust/issues/68318#issuecomment-2689265030
2025-03-06Rollup merge of #137744 - skius:master, r=NadrierilMichael Goulet-22/+25
Re-add `Clone`-derive on `Thir` This PR adds back `Clone` for `Thir`. If a tool wants to access a `thir_body` query result in the `Callbacks::after_analysis` hook, it can't do so (I think) without a `Clone` impl on `Thir`, because `check_unsafety` steals the value. With `Clone`, the `thir_body` query provider can be overriden to cache a clone of the `Thir`, circumventing that issue. Specifically, we need it for https://github.com/rust-corpus/qrates, [here](https://github.com/skius/qrates/blob/ca7a2301968a43862f2c04daffed71a9de8c333c/extractor/src/lib.rs#L205). Please let me know if there are issues with this PR/if there's another way to solve the problem at hand
2025-03-06expand comments of `TyCtxt` impl of `DynSync`/`DynSend`Rémy Rakic-1/+3
so that it doesn't get removed again
2025-03-06Hide the end of ranges in pretty printing if it's also the maximum of the typeOli Scherer-1/+23
2025-03-06Remove the `Option` part of range ends in the HIROli Scherer-18/+8
2025-03-06Avoid having to handle an `Option` in the type systemOli Scherer-29/+17
2025-03-06Prefer a two value enum over boolOli Scherer-5/+4
2025-03-06Revert "rustc_middle: parallel: TyCtxt: remove "unsafe impl DynSend/DynSync""Rémy Rakic-0/+3
This reverts commit 8eba29ac1015e989e6ba96ff17a75d548afde7ff.
2025-03-05Rollup merge of #137633 - ↵许杰友 Jieyou Xu (Joe)-11/+10
compiler-errors:no-implied-bounds-hack-unless-bevy, r=lcnr Only use implied bounds hack if bevy, and use deeply normalize in implied bounds hack Consolidates the implied bounds computation mode into a single function, which deeply normalizes, and if it's in **compat** mode (for bevy), it extracts outlives bounds from the infcx. Previously, we were using the implied bounds compat mode in two cases: 1. During WF, if it detects `ParamSet` 2. EVERYWHERE ELSE (lol) -- e.g. borrowck, predicate entailment, etc. While I think this is fine, and the net effect was just that we emitted fewer diagnostics, it makes me uncomfortable that all crates were using the supposed "compat" code. Fixes #137767
2025-03-05Rollup merge of #137298 - compiler-errors:mir-wf, r=lcnr许杰友 Jieyou Xu (Joe)-1/+1
Check signature WF when lowering MIR body Alternative to #137233. https://github.com/rust-lang/rust/pull/137233#issuecomment-2667879143 Fixes https://github.com/rust-lang/rust/issues/137186 We do this check in `mir_drops_elaborated_and_const_checked` and not during `mir_promoted` because that may result in borrowck cycles if WF requires looking into an opaque hidden type. This causes some TAIT tests to fail unnecessarily. r? lcnr try-job: test-various
2025-03-04Rollup merge of #137923 - scottmcm:fix-postorder-size-hint, r=tmiaskoJubilee-26/+11
Simplify `<Postorder as Iterator>::size_hint` The current version is sometimes malformed (cc #137919); let's see if we can get away with a loose but trivially-correct one.
2025-03-04Auto merge of #135186 - camelid:const-path-multi, r=BoxyUwUbors-1/+19
mgca: Lower all const paths as `ConstArgKind::Path` When `#![feature(min_generic_const_args)]` is enabled, we now lower all const paths in generic arg position to `hir::ConstArgKind::Path`. We then lower assoc const paths to `ty::ConstKind::Unevaluated` since we can no longer use the anon const expression lowering machinery. In the process of implementing this, I factored out `hir_ty_lowering` code that is now shared between lowering assoc types and assoc consts. This PR also introduces a `#[type_const]` attribute for trait assoc consts that are allowed as const args. However, we still need to implement code to check that assoc const definitions satisfy `#[type_const]` if present (basically is it a const path or a monomorphic anon const). r? `@BoxyUwU`
2025-03-04Only use implied bounds hack if bevy, and use deeply normalize in implied ↵Michael Goulet-11/+10
bounds hack
2025-03-04Ensure that negative auto impls are always applicableMichael Goulet-2/+2
2025-03-04mgca: Lower all const paths as `ConstArgKind::Path`Noah Lev-1/+19
When `#![feature(min_generic_const_args)]` is enabled, we now lower all const paths in generic arg position to `hir::ConstArgKind::Path`. We then lower assoc const paths to `ty::ConstKind::Unevaluated` since we can no longer use the anon const expression lowering machinery. In the process of implementing this, I factored out `hir_ty_lowering` code that is now shared between lowering assoc types and assoc consts. This PR also introduces a `#[type_const]` attribute for trait assoc consts that are allowed as const args. However, we still need to implement code to check that assoc const definitions satisfy `#[type_const]` if present (basically is it a const path or a monomorphic anon const).
2025-03-04InhabitedPredicate: avoid using a wildcard branchMaja Kądziołka-1/+4
This is error-prone. Explicitly write down which cases don't need anything substituted. Turn the `OpaqueType` case, which currently seems to be unreachable, into a `bug!`.
2025-03-04Clarify why InhabitedPredicate::instantiate_opt existsMaja Kądziołka-0/+5
At first glance, the extra casework seems pointless and needlessly error-prone. Clarify that there is a reason for it being there.
2025-03-03Also simplify `Preorder`'s `size_hint`Scott McMurray-15/+5
2025-03-03Tweak error code for sized checks of const/staticMichael Goulet-1/+1
2025-03-03Rollup merge of #137922 - Zalathar:sharded, r=SparrowLiiMatthias Krüger-1/+2
A few cleanups after the removal of `cfg(not(parallel))` I noticed a few small things that are no longer needed after the removal of `cfg(not(parallel))` in #132282. One of the later changes adjusts several imports, so viewing the changes individually is recommended. r? SparrowLii (or reroll)