Commit Graph

2014 Commits

Author SHA1 Message Date
Jacob Pratt
29b5c303bb Rollup merge of #160984 - bit-aloo:2026-08-12-mgca-const-infer-args, r=khyperia
Fix ICE on { _ } const args in bodies by tracking const-only infer args

closes: rust-lang/rust#160798

r? @khyperia

PS: Here, I am following what Boxy suggested as solution 5, here: [#project-const-generics > Should { _ } be kind ambiguous?](https://rust-lang.zulipchat.com/#narrow/channel/260443-project-const-generics/topic/Should.20.7B.20_.20.7D.20be.20kind.20ambiguous.3F/with/616005728)
2026-08-13 18:16:08 -04:00
bjorn3
5b3e2771b1 Remove target argument from get_proc_macros
Currently it will always load proc-macros for the host. In the future it
may also start loading wasm proc-macros. This way rust-analyzer doesn't
have to pick between both options itself.
2026-08-12 15:08:50 +02:00
bit-aloo
4147cde2e6 Handle anon const defs attached to Node::Infer under mGCA 2026-08-12 12:31:58 +00:00
mejrs
b588ef3b37 Move rustc_session cstore module to its own crate 2026-08-11 17:12:12 +02:00
Zalán Bálint Lévai
d577cbc2de Fix visible_parent_map fallback map merging perf regression 2026-08-10 16:02:24 +01:00
mejrs
196dd2a174 Fix up lang_items import paths 2026-08-09 15:20:29 +02:00
Jonathan Brouwer
c5549dd7bc Rollup merge of #160464 - zalanlevai:fix-visible-parent-map-fallback-entry-check, r=oli-obk
fix: Check the fallback map before queueing child in `visible_parent_map` breadth-first search

The fix in rust-lang/rust#159881 extended the `visible_parent_map` breadth-first search (BFS) to include items nested within "fallback" items, such as `#[doc(hidden)]` modules and re-exports. However, the fix resulted in fallback entries not being checked before enqueueing new items into the BFS, resulting in fallback items being explored in the BFS multiple times, once for each fallback parent, up until a non-fallback visible parent is found instead, if any.

This PR adds a check before new fallback items are recorded and the BFS queue is extended that ensures that the item has not already been searched through a fallback parent item.

Fixes the `libc` performance regression described in rust-lang/rust#160439. (Fixes rust-lang/rust#160439.)

Unfortunately, I could not think of a way to write a test case that covers the regression that this PR fixes, as it would require a massive crate with a very large number of "fallback" parents, and the test would be performance-based.
2026-08-06 12:41:02 +02:00
Jonathan Brouwer
6a6901467a Rollup merge of #159029 - erickt:lto-module-summaries, r=cuviper
rustc_llvm: Emit module summaries when using -Clto=fat

Currently, module summaries are only emitted with thin lto. If we would link full/fat lto'd rust code against lto'd c++ code built with CFI (or WPD), those passes would fail during the link step because the participating rust modules are missing module summaries. Rust code does not know at compile-time if it would be participating in some special link which may require module summaries, so this PR ensures module summaries are unconditionally emitted for full/fat lto, just like with thin lto.

The WriteBitcodeToFile function just invokes the normal BitcodeWriterPass under the hood, but doesn't provide a way to set the argument for emitting module summaries. So this patch just adds the pass directly and sets that argument.

This is a rebase of @PiJoules's https://github.com/rust-lang/rust/pull/158099, which also should fix up the tests with the gcc tools.
2026-08-05 21:55:42 +02:00
Zalán Bálint Lévai
640032da52 fix: Check the fallback map before queueing child in visible_parent_map BFS 2026-08-05 17:42:10 +01:00
Jonathan Brouwer
900f0bcb32 Rollup merge of #159225 - bjorn3:split_incr_comp_session, r=oli-obk
Split IncrCompSession out of Session

This will allow introducing a separate incr comp session dir for the post LTO artifacts in the future. In addition it statically encodes the lifetime of the incr comp session rather than requiring an enum behind a mutex stored in the Session.

Based on https://github.com/rust-lang/rust/pull/159000
Part of https://github.com/rust-lang/compiler-team/issues/908
2026-08-05 13:36:11 +02:00
Jonathan Brouwer
adf7af816f Rollup merge of #159763 - nikic:resolve-crate-opt, r=bjorn3
Optimize crate resolution for large workspace

By keeping a map from hash to crate number.
2026-08-04 14:41:23 +02:00
Jakub Beránek
3ee6e30969 Rollup merge of #160449 - Kobzol:filesearch-lookup-fix, r=petrochenkov
Fix lookup of object files

I broke this in https://github.com/rust-lang/rust/pull/158823. I wanted to optimize the potentially O(n^2) object file lookup, but didn't realize that we have to search all search paths here, not only files that we already prefiltered for the lib prefixes.

r? @petrochenkov

Fixes: https://github.com/rust-lang/rust/issues/160446
2026-08-04 11:10:32 +02:00
Jakub Beránek
07e1398046 Fix lookup of object files 2026-08-03 18:45:53 +02:00
bjorn3
1a3d919258 Deny multiple EII impls on a single item
This allows implementing EIIs that don't have a default impl without the
involvement of symbol aliases by simply changing the mangled symbol name
of the implementation, which would make them trivially compatible with
all backends and targets. This change will be left to a followup PR.
2026-08-03 11:04:23 +02:00
Jonathan Brouwer
d982e2ec06 Rollup merge of #159881 - zalanlevai:fix-incomplete-visible-parent-map, r=fee1-dead
fix: Do not stop `visible_parent_map` breadth-first search reaching children of `#[doc(hidden)]` modules

The `visible_parent_map` query misses putting the child items of `#[doc(hidden)]` modules into the queue, resulting in the breadth-first search missing them entirely. This results in inconsistent path printing behavior affecting diagnostics: namely that re-exports nested deeply within `#[doc(hidden)]` modules are not considered as a possible fallback path. See the linked issue (rust-lang/rust#159880) for more details and an example of how this manifests in diagnostics.

This PR makes sure that `#[doc(hidden)]` parents in the fallback map are still searched as part of the breadth-first search.

Fixes rust-lang/rust#159880.

The two tests for this change are based on the inconsistent diagnostics shown in the issue:
* `tests/ui/suggestions/suggest-path-through-direct-dep-crate/hidden-reexport-of-transitive-dep-item.rs` captures the current, expected behavior in the already working base case where the hidden module is still recorded in the fallback map;
* `tests/ui/suggestions/suggest-path-through-direct-dep-crate/hidden-reexport-of-nested-transitive-dep-item.rs` is a regression test for the breadth-first search covering nested children of `#[doc(hidden)]` modules to populate the fallback map by testing whether the diagnostic prefers the hidden but accessible path through the direct dependency crate.

Related PRs/issues:
* rust-lang/rust#87349
* rust-lang/rust#153477
2026-08-02 16:19:31 +02:00
Zalán Bálint Lévai
e5b636479b fix: Do not stop visible_parent_map breadth-first search reaching children of #[doc(hidden)] modules 2026-08-01 19:57:11 +01:00
CoCo-Japan-pan
f31f2531ad Lower mut restriction to ty::FieldDef 2026-08-01 16:48:54 +09:00
bors
6c04025a8a Auto merge of #158823 - Kobzol:flatten-search-paths, r=petrochenkov
Flatten all -L search paths into a single list of files



This is an optimization that mostly targets the new [Cargo build dir layout](https://rust-lang.github.io/rust-project-goals/2025h2/cargo-build-dir-layout.html).

Before, Cargo usually used to pass rustc a single `-L` path to a directory containing potentially a large number of `.rlib` or other dependency paths. Rustc is optimized for this, and does a preprocessing step, where it preloads all files from this directory into a sorted vector, in which it then performs binary search to look for files having a given prefix and postfix.

With the new build dir layout, this changes, and Cargo will pass potentially many (even hundreds, if your crate has many dependencies) `-L` directories, where each directory will usually have only 1-2 files. This is not ideal for the current rustc search implementation, because the old preprocessing isn't really worth it when the `-L` directory typically only has a single file, and because rustc will do a lot of work per each `-L` directory in the lookup phase, including some quadratic (O(n^2)) work.

With the `large-workspace` stress test from rustc-perf, where the final binary has ~1000 total and ~500 direct dependencies:
- With the old build dir layout, rustc does 4274 calls to `FilesIndex::query`
- With the new build dir layout, it does `1938314` calls to `FilesIndex::query`. Not ideal :)

This PR modifies the logic so that instead of going through all `-L` directories one by one when we are looking for a specific dependency, we pre-gather all files from all passed `-L` directories at the start, and sort them all together. Then, in the lookup phase, instead of performing <number of -L dirs> * 4 (.rmeta, .rlib, etc.) searched, we only perform the 4 searches across all files. This gets rid of the O(n^2) behavior.

Further improvements could be made, e.g. sort the files just once and then filter it for for both host and target filesearchs. I alsothought about pre-filtering the files further, e.g. based on their `kind`,  but that is not worth it in usual situations, where ~all of the deps will be `.rlib`s or `.rmeta`s anyway. What might work is pre-filtering based on their actual names (we strip known prefixes from them and then search based on the names alone, in a hashmap or something?), but that can be a follow-up.

Diff vs parent. of https://github.com/rust-lang/rust/pull/159857: https://perf.rust-lang.org/compare.html?start=1a833e16546c2eb012758ddd499964fd8afee29e&end=6514e2707b7e90fecbc570eeaa36f3780a9b02b4&stat=instructions%3Au
2026-07-31 22:09:50 +00:00
Jonathan Brouwer
a06a96e280 Rollup merge of #160272 - petrochenkov:metamove, r=nnethercote
rustc_metadata: Move native library search code to `rustc_codegen_ssa`

https://github.com/rust-lang/rust/issues/138243 was partially implemented, so we can do this now.
2026-07-31 16:02:27 +02:00
Jakub Beránek
55500ae2e7 Preprocess and sort files from all search paths into one large list 2026-07-31 13:43:49 +02:00
Vadim Petrochenkov
15d80dc813 rustc_metadata: Move native library search code to rustc_codegen_ssa 2026-07-31 12:46:23 +03:00
Vadim Petrochenkov
2b4375dadc rustc: Support --jobs options for limiting parallelism in various parts of the compiler 2026-07-29 15:22:16 +03:00
Jonathan Brouwer
0a1a25a0b6 Rollup merge of #159990 - nnethercote:predicate-to-clause, r=oli-obk
Many "predicate"-to-"clause" renamings

Lots of names weren't changed to account for the introduction of the `Clause` type as a specialized form of `Predicate`, presumably because it was tedious. This commit converts as many of them as I could find. It's mostly very tedious renamings of types, functions, variables, and queries. The more interesting ones are a couple of files (`predicates_of.rs`, `impossible_predicates.rs`) and a MIR pass (`ImpossiblePredicates`).

r? @oli-obk
2026-07-28 21:07:39 +02:00
Jacob Pratt
6da5b2fcca Rollup merge of #160022 - mejrs:hir_too_globby, r=folkertdev
Refactor rustc_hir re-exports

Probably best reviewed commit by commit.

I've been trying to split up rustc_hir and attributes.. This PR prepares for part of that, by cleaning up import paths and moving around some stuff. (See also https://github.com/rust-lang/rust/pull/159602 https://github.com/rust-lang/rust/pull/159659 and https://github.com/rust-lang/rust/pull/159893 for some previous work)
2026-07-28 01:38:36 -04:00
Jacob Pratt
f8ee207a51 Rollup merge of #153563 - Urgau:lint-panics-when-n-is-zero, r=fee1-dead,ShoyuVanilla
Lint against iterator functions that panic when `N` is zero

This PR extends the deny-by-default `unconditional_panic` lint, by linting on iterator functions that panics when `N` (chunks/windows size) is zero[^attr].

Those methods are [documented](https://doc.rust-lang.org/std/primitive.slice.html#panics-11) to panic if `N` is zero.

```
error: this operation will panic at runtime
  --> $DIR/const-n-is-zero.rs:11:13
   |
LL |     let _ = s.array_windows::<0>();
   |             ^^^^^^^^^^^^^^^^^^^^^^ const parameter `N` is zero
   |
   = note: `#[deny(unconditional_panic)]` on by default
```

cc @rust-lang/libs-api

[^attr]: this is done by introducing a new internal attribute on the const parameter: `#[rustc_panics_when_zero]`
2026-07-28 01:38:30 -04:00
Nicholas Nethercote
ff161b18b5 Many "predicate"-to-"clause" renamings
Lots of names weren't changed to account for the introduction of the
`Clause` type as a specialized form of `Predicate`, presumably because
it was tedious. This commit converts as many of them as I could find.
It's mostly very tedious renamings of types, functions, variables, and
queries. The more interesting ones are a couple of files
(`predicates_of.rs`, `impossible_predicates.rs`) and a MIR pass
(`ImpossiblePredicates`).
2026-07-28 11:48:45 +10:00
Urgau
54130660c9 Encode const params attributes in rmeta 2026-07-27 22:44:12 +02:00
Leonard Chan
a4bc26a608 rustc_llvm: Emit module summaries when using -Clto=fat
Currently, module summaries are only emitted with thin lto. If we would
link full/fat lto'd rust code against lto'd c++ code built with CFI (or
WPD), those passes would fail during the link step because the
participating rust modules are missing module summaries. Rust code does
not know at compile-time if it would be participating in some special
link which may require module summaries, so this PR ensures module
summaries are unconditionally emitted for full/fat lto, just like with
thin lto.

The WriteBitcodeToFile function just invokes the normal
BitcodeWriterPass under the hood, but doesn't provide a way to set the
argument for emitting module summaries. So this patch just adds the pass
directly and sets that argument.

Finally, now that we're generating module summaries for `-Clto=fat`
without using ThinLTO, we need to update `rustc-metadata` to keep
around a temporary directory that contains the `.rmeta` for a little
longer before we deserialize it.
2026-07-27 18:31:29 +00:00
mejrs
3301eeabb4 Move canonical symbols into attributes 2026-07-27 19:17:55 +02:00
Jonathan Brouwer
8bf37cecf6 Fix decoding attributes of SyntheticCoroutineBody 2026-07-26 13:10:05 +02:00
Nikita Popov
54ff9a2290 Optimize crate resolution
By keeping a map from hash to crate number.
2026-07-23 16:17:22 +02:00
bjorn3
f9679fa4df Split IncrCompSession out of Session
This will allow introducing a separate incr comp session dir for the
post LTO artifacts in the future. In addition it statically encodes the
lifetime of the incr comp session rather than requiring an enum behind a
mutex stored in the Session.
2026-07-23 12:14:56 +02:00
Oli Scherer
e9ad00c5af Remove 'static requirement on try_as_dyn 2026-07-23 10:59:01 +02:00
James Barford-Evans
03a157afc0 Move Region to rustc_type_ir 2026-07-21 12:04:58 +01:00
bors
87e5904f5e Auto merge of #159610 - JonathanBrouwer:rollup-Wil0K5d, r=JonathanBrouwer
Rollup of 18 pull requests

Successful merges:

 - rust-lang/rust#159600 (`rust-analyzer` subtree update)
 - rust-lang/rust#158046 (proc_macro: preserve file module spans for inner attrs)
 - rust-lang/rust#159000 (Small cleanups to the incr comp session code)
 - rust-lang/rust#159189 (Account for type alias projections in E0308 "expected/found" shortening logic)
 - rust-lang/rust#159449 (Enable single Location to issue multiple borrows)
 - rust-lang/rust#159544 (Suggest valid command-line crate names)
 - rust-lang/rust#159587 (Improve `AttrItem::span`)
 - rust-lang/rust#159594 (feat(rustc_hir_typeck): suggest `impl Fn` return for capturing closures)
 - rust-lang/rust#159597 (std: use `arc4random_buf` from libc)
 - rust-lang/rust#159599 (Resolver: Record at least 1 ambiguous trait if main decl is not a trait.)
 - rust-lang/rust#158061 (Make `pin!()` more foolproof.)
 - rust-lang/rust#159460 (Do not mark unnormalized const aliases as rigid when normalizing param env)
 - rust-lang/rust#159529 (Add regression test for nested replacement ranges in `collect_tokens`)
 - rust-lang/rust#159571 (Remove unused bundled library lookup for the local crate)
 - rust-lang/rust#159585 (Minor `TokenStream` improvements)
 - rust-lang/rust#159586 (Separate `InterpCx` usage by `ConstAnalysis` phases)
 - rust-lang/rust#159602 (Remove `ItemLike`)
 - rust-lang/rust#159603 (Clarify `push_stream`/`push_tree`)

Failed merges:

 - rust-lang/rust#159590 (Remove some dead code)
2026-07-20 19:20:00 +00:00
Jonathan Brouwer
066fd4c62d Rollup merge of #159571 - mehdiakiki:rmeta-link/drop-dead-local-search, r=petrochenkov
Remove unused bundled library lookup for the local crate

After rust-lang/rust#156735 the local crate's branch in `add_native_libs_from_crate` computes a list of bundled library filenames that nothing ever reads. And the only place that runs this is located in other crates not the current local one. The local crate always links its native libraries by name.

This removes that unused branch. This is a cleanup only with no change in behavior.
2026-07-20 18:06:12 +02:00
bors
d527bc9bfa Auto merge of #159344 - Urgau:canonical-symbols, r=mejrs
Replace weak only lang items with a custom attribute



When I added the `invalid_runtime_symbol_definitions` and `suspicious_runtime_symbol_definitions` lints in rust-lang/rust#155521 I added the concept of "weak only" lang item.

It's a `LangItem` that has no implementation, this is useful because the `core` symbols where not directly called, they were inserted by the compiler.

This mechanism work well, but T-lang [approved](https://github.com/rust-lang/rust/pull/158522#issuecomment-4856902233) the extension to "all extern functions referenced by the standard library", which makes the lang item approach impractical as we needs to update 5 files just to declare them. I'm not sure we can ask library contributor to do the dance for each `extern "C"` functions.

But the most problematic thing is that many extern functions in `std` come from `libc` not `std`, and adding lang items there is just no feasible I think.

Instead this PR proposed that we introduce a proper mechanism for them by adding a attribute `#[rustc_canonical_symbol = "..."]`, which is encoded and decoded in `rmeta` like lang items and diagnostics items.

This simplifies the declaration as we only need to put the attribute to be effective `#[rustc_canonical_symbol = "open"]`. It also opens up many possibilities (none implemented here) like putting them on `use` statements (so we don't need to modify `libc`) or having the attribute be placed on a module. The table may also be useful on it's own if we want someday to do it for all crates, not just the standard library.

Follow up to rust-lang/rust#155521 and rust-lang/rust#158522
2026-07-20 16:05:44 +00:00
Jonathan Brouwer
8e9fb78173 Rollup merge of #150732 - kulst:cpu_is_target_modifier, r=bjorn3
Convert `-Ctarget-cpu` into a target-modifier for AVR, AMDGCN and NVPTX

Crates built for AVR, AMDGCN and NVPTX that specify different values for `-Ctarget-cpu` cannot be soundly linked together.
This PR attempts to make `rustc` ensure that no crates with disagreeing values for `-Ctarget-cpu` are linked together. This is achieved by converting `-Ctarget-cpu` into a target-modifier depending on `--target`.
To do this, the consistency check for `-Ctarget-cpu` considers mismatching values as inconsistent only for targets for which the new flag `requires_consistent_cpu` is set in their target spec.

**Why should `-Ctarget-cpu` be a target-modifier for `nvptx`?**
<details><summary>PTX is a single-module contract</summary>
<p>
PTX requires a binary to start with .version (`ptx$$`) then .target (`sm_$$`). If the ptx contains instructions that are not supported by either .version or .target, the binary is ill-formed and will be rejected by ptxas. The concept of features that can be mixed and matched in a binary does not exist for nvptx and is therefore not supported by LLVM.
</p>
</details>

<details><summary>It prevents the production of bitcode that cannot be codegen'd after linking</summary>
<p>
A target modifier should prevent configurations that are not composable across crates when those crates are linked together. The most prominent example is when enabling a target feature changes the ABI, making cross-crate calls inherently unsound.

In the case of nvptx, ABI mismatch is (at least for now) not the core problem motivating target modifiers. NVIDIA’s documented PTX calling convention has [remained stable since ptx20](https://docs.nvidia.com/cuda/ptx-writers-guide-to-interoperability/index.html#function-calling-sequence).

However, in the current state it is possible to produce bitcode that cannot be codegen'd after linking, because some operations are only lowerable for sufficiently new SM/PTX levels. In the best case this results in an LLVM error during the final llc step, but this is not something we should rely on for correctness.

nvptx has a special compilation pipeline where instead of linking the final PTX object, instead LLVM bitcode is linked. The resulting artifact is then compiled in one invocation.
Now consider crate A which is independently compiled into bitcode with the following rustc arguments:

```Rust
//@ compile-flags: --target nvptx64-nvidia-cuda -C target-cpu=sm_70 --crate-type=rlib
#[cfg(target_feature = "sm_70")]
fn foo() {
    // cannot be lowered to ptx before "sm_70: so currently produces an LLVM error
}
#[cfg(not(target_feature = "sm_70"))]
fn foo() {
    // can be lowered to ptx before "sm_70"
}
pub fn bar() {
    foo()
}
```
Crate A is a dependency of crate B. In the *rustc* invocation of crate B
1. crate B is compiled into bitcode, too
2. both bitcode artifacts are bitcode-linked by *llvm-link*
3. the resulting bitcode artifact is compiled by *llc -mcpu=sm_60*

This should now ideally create an LLVM error, because the linked bitcode contains code paths that were selected under `sm_70` assumptions but the final NVPTX codegen is targeting `sm_60`, where those operations are not lowerable. An LLVM error here is better than silent miscompilation, but it’s not a promise we should rely on.

A real example where this could happen is the lowering of atomic loads and stores with non-relaxed orderings, which is known to depend on the selected SM level.
</p>
</details>

**Why should `-Ctarget-cpu` be a target-modifier for `amdgcn` and `avr`?**
- In case of AVR the target-cpu defines the ISA, which is encoded in the ELF header flags, amdgcn also encodes the cpu directly into those flags
- To not rely on *lld* which currently prevents it for both by looking at those flags [AVR](597ffbe09d/lld/test/ELF/avr-flags.s) and [amdgcn](597ffbe09d/lld/test/ELF/amdgpu-elf-flags-err.s)

Previous discussions about the topic can be found [here](https://github.com/rust-lang/rust/issues/131799#issuecomment-3390563329) and [here](https://github.com/rust-lang/rust/issues/141468).

I also created a [Zulip discussion](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Making.20-Ctarget-cpu.20a.20target-modifier.20on.20NVPTX/with/566622679).

I am unsure if a MCP is needed before proceeding. If you think so please let me know.

Creating *target-modifiers* for NVPTX *target-features* is to be done in a follow-up.

cc @kjetilkjeka as target maintainer for NVPTX
cc @flakebi as target maintainer for amdgcn
cc @Patryk27 as target maintainer for AVR
cc @RalfJung you were very involved in the discussions so far

Target modifier tracking issue: https://github.com/rust-lang/rust/issues/136966
2026-07-19 23:26:25 +02:00
mehdiakiki
a29216c046 drop the dead bundled-library search for the local crate 2026-07-19 17:35:35 +01:00
Urgau
8e6bd6e388 Query-fy and encode canonical symbols 2026-07-19 17:38:56 +02:00
kulst
76d5107658 Treat -Ctarget-cpu as a target-modifier when targeting AVR, AMDGCN and NVPTX
For AVR, AMDGCN, and NVPTX, crates built with different target CPU values are
not generally link-compatible.

Add a `requires_consistent_cpu` flag to the target spec and enable it for these
targets. When the flag is set, treat `-Ctarget-cpu` as a target modifier and
require all linked crates to agree on its value.

Reject `-Ctarget-cpu=native` before codegen for targets that set
`requires_consistent_cpu` to true. Also do not include `native` in the printed
`target-cpus` list for such targets.

Add tests covering:
- which built-in targets set `requires-consistent-cpu`
- cross-crate behavior with and without `requires-consistent-cpu`
- that an omitted `-Ctarget-cpu` compares equal to an explicitly specified
  default CPU
- rejection and printing behavior for `native`
- precedence of repeated `-Ctarget-cpu` flags in metadata comparison and LLVM IR
2026-07-17 15:46:00 +02:00
Jonathan Brouwer
d55ab96dac Rollup merge of #158758 - josetorrs:rename-lazy-type-alias, r=lcnr
Rename `lazy_type_alias` feature gate to `checked_type_aliases`

there's not an open issue for it, though happy to create one if desired, but [this](https://rust-lang.zulipchat.com/#narrow/channel/144729-t-types/topic/ask.20for.20help.3A.20rename.20.60lazy_type_alias.60.20feature/near/608089932) is the zulip thread. basically just did a cmd+shift+F on VSCode

r? @lcnr

cc: @BoxyUwU
2026-07-16 21:01:48 +02:00
Jose Torres
526787dbbc rename from lazy_type_alias to checked_type_aliases
Co-authored-by: lcnr <rust@lcnr.de>
2026-07-15 11:50:42 -04:00
kulst
d2b2602137 Improve error messages for disagreeing *target-modifiers*
- Boolean target modifiers are now mentioned without a trailing `=` in the
messages.
- Wording improved for unset target modifiers.
2026-07-15 16:24:44 +02:00
Jonathan Brouwer
8fdc29c9ea Rollup merge of #159197 - camsteffen:more-modid, r=petrochenkov
Rename ModDefId to ModId and use more

Addresses some FIXMEs.

The `ModDefId` was used pretty sparingly, and honestly I wondered if it should exist at all. After making these changes, I think the type is worth it. Most notably it is now used in `Visibility::Restricted`.

I first renamed `ModDefId` to `ModId` since I think the former is over-specific, and also this is more in line with `BodyId` or `OwnerId`.

I'll wait for initial feedback before fixing rustdoc/clippy.
2026-07-15 16:17:07 +02:00
Jonathan Brouwer
9f5052b9ab Rollup merge of #158235 - cezarbbb:eii-metadata-opt, r=bjorn3
Store `DefId` instead of `EiiDecl` in `EiiImplResolution::Known`

Fixes the `FIXME(eii)` about removing the extern target from the encoded decl.

`Known(EiiDecl)` serialized the same `EiiDecl` N+1 times per entry (once as the declaration, once per Known impl). Changing to `Known(DefId)` eliminates that redundancy — the `EiiDecl` is recoverable via `tcx.externally_implementable_items()` or a local lookup map, consistent with how Rust metadata uses `DefId` as a reference elsewhere.

I believe there are benefits in both performance and size(full `EiiDecl` to single `DefId`, and O(N) to O(1) lookup).

Also fixes a soundness gap(I think?) in `check_attr.rs` where the `Known` branch skipped `impl_unsafe` checking, and replaces an `.expect()` in `codegen_attrs.rs` with `a let Some` pattern.

tracking issues: rust-lang/rust#125418

r? @jdonszelmann
2026-07-14 16:48:59 +02:00
Cameron Steffen
3c0923a48d Use ModId more 2026-07-14 08:23:57 -05:00
cezarbbb
48a980d9a3 Store DefId instead of EiiDecl in EiiImplResolution::Known 2026-07-14 20:17:40 +08:00
Mark Rousskov
268e708b93 Step cfg(bootstrap) 2026-07-13 18:04:39 -04:00
Jacob Pratt
c907a05576 Rollup merge of #158767 - khyperia:merge-inlineconst, r=BoxyUwU
merge DefKind::InlineConst into AnonConst

This is a closely related followup to https://github.com/rust-lang/rust/pull/158375 (a condition of merging that PR was doing this as a followup)

This merge conflicts with https://github.com/rust-lang/rust/pull/158617 ; prefer merging that one first please~

This PR is within the general goal of const generics / `generic_const_args` and perhaps specifically https://github.com/rust-lang/project-const-generics/issues/108 but is mostly a code cleanup rather than implementing any particular feature

---

Anon consts (the `1 + 2` in `let x: [u8; 1 + 2];`) are closely related to inline consts (the `const {}` in `let x = const { 1 + 2 };`). They are especially related now that both can be used in the type system (by the above PR) and should be treated identically in that scenario. In general, they should be treated the same, as evidenced by the number of matches touched in this PR that just match on both. This PR merges the two DefKinds into one, mostly arbitrarily and bikesheddily choosing to use the name `AnonConst` for the merged concept (e.g. both `DefKind::InlineConst` and `DefKind::AnonConst` used `ast::AnonConst`, so `ast::AnonConst` should probably be named whatever the merged `DefKind` concept is named).

When you absolute must distinguish between the two, `tcx.anon_const_kind` allows you to do so - however, anon consts/inline consts in the type system intentionally appear identically under `anon_const_kind`. Indeed, the places where we distinguish between the two raised my eyebrows a few times when doing this PR, and being a little more explicit and loud about it is helpful for code clarity, IMO.

r? @BoxyUwU
2026-07-10 21:53:56 -04:00