1682 Commits

Author SHA1 Message Date
Cameron Steffen
cf4d7938cf Limit defaultness to impl of trait 2025-07-25 08:49:31 -05:00
usamoi
e31876c143 generate elf symbol version in raw-dylib 2025-07-24 19:04:00 +08:00
Matthias Krüger
3a3a411980
Rollup merge of #144059 - LorrensP-2158466:remove-crate-loader, r=petrochenkov
Refactor `CrateLoader` into the `CStore`

Removes the `CrateLoader` and moves the code to `CStore`. Now, if you want to use the `CrateLoader`, you can just use `CStore`.

Should we rename `creader.rs` to `cstore.rs`?

r? ``@petrochenkov``
2025-07-18 19:14:46 +02:00
LorrensP-2158466
466d33cb5c inline CrateLoader inside of CStore 2025-07-18 13:16:09 +02:00
Deadbeef
69326878ee parse const trait Trait 2025-07-17 18:06:26 +08:00
Vadim Petrochenkov
babe2c0d0f resolve: Merge NameBindingKind::Module into NameBindingKind::Res 2025-07-16 08:28:17 +03:00
Jonathan Brouwer
a14baf1e56
Define datastructures for #[cfg] attribute, move StrippedCfgItem 2025-07-15 09:01:00 +02:00
Jakub Beránek
93c10272d0
Rollup merge of #143217 - Periodic1911:link-ordinal, r=jdonszelmann
Port #[link_ordinal] to the new attribute parsing infrastructure

Ports link_ordinal to the new attribute parsing infrastructure for https://github.com/rust-lang/rust/issues/131229#issuecomment-2971353197
2025-07-14 11:04:52 +02:00
Camille GILLOT
5bd3841668 Retire hir::ForeignItemRef. 2025-07-13 13:50:00 +00:00
Anne Stijns
75561c446a Port #[link_ordinal] to the new attribute parsing infrastructure. 2025-07-13 11:51:01 +02:00
Michael Goulet
736bfa12de Clean up implementation of RPITIT assoc item lowering 2025-07-12 19:31:15 +00:00
bohan
47e15d90e1 query RPITIT in a trait or impl 2025-07-13 02:52:13 +08:00
Camille GILLOT
17ce06a459 Add comment and move assertion. 2025-07-04 14:02:18 +00:00
Camille GILLOT
904bc2958f Lighten formatting. 2025-07-04 14:02:18 +00:00
Camille GILLOT
761d366415 Reuse metadata file from work products. 2025-07-04 14:02:17 +00:00
Camille GILLOT
c7ee3a5e3f Save metadata among work products. 2025-07-04 14:02:17 +00:00
Guillaume Gomez
62a7fb0fcb
Rollup merge of #143369 - bjorn3:cleanup_metadata_loading, r=lcnr
Various refactorings to the metadata loader
2025-07-03 19:45:31 +02:00
bjorn3
47caa0a927 Make most CrateLocator fields private
This ensures they don't get out of sync
2025-07-03 11:57:56 +00:00
bjorn3
57d6c1bab8 Have a separate code path for -Zdual-proc-macro
This makes it clearer when the locator and when crate_rejections is updated
2025-07-03 11:55:40 +00:00
bjorn3
87633054dc Pass CrateRejections separately from CrateLocator
This allows all CrateLocator methods to take &self.
2025-07-03 11:55:39 +00:00
bjorn3
121dac5cbb Deduplicate getting the path of a lib candidate 2025-07-03 11:52:19 +00:00
klensy
c76d032f01 setup CI and tidy to use typos for spellchecking and fix few typos 2025-07-03 10:51:06 +03:00
bors
076a0a26fd Auto merge of #143013 - bjorn3:split_exported_symbols, r=oli-obk
Split exported_symbols for generic and non-generic symbols

This reduces metadata decoder overhead during the monomorphization collector.
2025-07-01 11:53:02 +00:00
Nicholas Nethercote
478f8287c0 Introduce ByteSymbol.
It's like `Symbol` but for byte strings. The interner is now used for
both `Symbol` and `ByteSymbol`. E.g. if you intern `"dog"` and `b"dog"`
you'll get a `Symbol` and a `ByteSymbol` with the same index and the
characters will only be stored once.

The motivation for this is to eliminate the `Arc`s in `ast::LitKind`, to
make `ast::LitKind` impl `Copy`, and to avoid the need to arena-allocate
`ast::LitKind` in HIR. The latter change reduces peak memory by a
non-trivial amount on literal-heavy benchmarks such as `deep-vector` and
`tuple-stress`.

`Encoder`, `Decoder`, `SpanEncoder`, and `SpanDecoder` all get some
changes so that they can handle normal strings and byte strings.

This change does slow down compilation of programs that use
`include_bytes!` on large files, because the contents of those files are
now interned (hashed). This makes `include_bytes!` more similar to
`include_str!`, though `include_bytes!` contents still aren't escaped,
and hashing is still much cheaper than escaping.
2025-06-30 20:42:27 +10:00
Yotam Ofek
8429c9911b Remove unused feature gates 2025-06-28 23:36:46 +00:00
Matthias Krüger
9d15167921
Rollup merge of #140809 - bjorn3:panic_runtime_cleanup, r=petrochenkov
Reduce special casing for the panic runtime

See the individual commits for more info.
2025-06-27 22:13:01 +02:00
bjorn3
753c73a349 Split exported_symbols for generic and non-generic symbols
This reduces metadata decoder overhead during the monomorphization collector.
2025-06-27 09:34:20 +00:00
bors
bc4376fa73 Auto merge of #143026 - jdonszelmann:rollup-z7mkuyt, r=jdonszelmann
Rollup of 7 pull requests

Successful merges:

 - rust-lang/rust#142146 (Withdraw the claim `extern "C-cmse-nonsecure-*"` always matches `extern "C"`)
 - rust-lang/rust#142200 (`tests/ui`: A New Order [8/N])
 - rust-lang/rust#142724 (Add runtime check to avoid overwrite arg in `Diag`)
 - rust-lang/rust#142809 (Add PrintTAFn flag for targeted type analysis printing)
 - rust-lang/rust#142976 (Check CoerceUnsized impl validity before coercing)
 - rust-lang/rust#142992 (Convert some ABI tests to use `extern "rust-invalid"`)
 - rust-lang/rust#143000 (Make `Sub`, `Mul`, `Div` and `Rem`  `const_traits`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-06-25 23:33:23 +00:00
Jana Dönszelmann
63c5a84b74
Rollup merge of #142724 - xizheyin:avoid_overwrite_args, r=oli-obk
Add runtime check to avoid overwrite arg in `Diag`

## Origin PR description
At first, I set up a `debug_assert` check for the arg method to make sure that `args` in `Diag` aren't easily overwritten, and I added the `remove_arg()` method, so that if you do need to overwrite an arg, then you can explicitly call `remove_arg()` to remove it first, then call `arg()` to overwrite it.

For the code before the rust-lang/rust#142015 change, it won't compile because it will report an error
```
arg `instance`already exists.
```

This PR also modifies all diagnostics that fail the check to pass the check. There are two cases of check failure:

1. ~~Between *the parent diagnostic and the subdiagnostic*, or *between the subdiagnostics* have the same field between them. In this case, I renamed the conflicting fields.~~
2. ~~For subdiagnostics stored in `Vec`, the rendering may iteratively write the same arg over and over again. In this case, I changed the auto-generation with `derive(SubDiagnostic)` to manually implementing `SubDiagnostic` and manually rendered it with `eagerly_translate()`, similar to https://github.com/rust-lang/rust/issues/142031#issuecomment-2984812090, and after rendering it I manually deleted useless arg with the newly added `remove_arg` method.~~

## Final Decision

After trying and discussing, we made a final decision.

For `#[derive(Subdiagnostic)]`, This PR made two changes:

1. After the subdiagnostic is rendered, remove all args of this subdiagnostic, which allows for usage like `Vec<Subdiag>`.
2. Store `diag.args` before setting arguments, so that you can restore the contents of the main diagnostic after deleting the arguments after subdiagnostic is rendered, to avoid deleting the main diagnostic's arg when they have the same name args.
2025-06-25 22:14:55 +02:00
Jana Dönszelmann
64a1a98f47
encode_cross_crate for hir attributes 2025-06-25 22:10:40 +02:00
xizheyin
d2d17c60bd
Add runtime check to avoid overwrite arg easily in diag and store and restore snapshot when set subdiag arg
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-06-25 21:07:16 +08:00
bors
3de5b08ef6 Auto merge of #142979 - matthiaskrgr:rollup-szqah4e, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#142645 (Also emit suggestions for usages in the `non_upper_case_globals` lint)
 - rust-lang/rust#142657 (mbe: Clean up code with non-optional `NonterminalKind`)
 - rust-lang/rust#142799 (rustc_session: Add a structure for keeping both explicit and default sysroots)
 - rust-lang/rust#142805 (Emit a single error when importing a path with `_`)
 - rust-lang/rust#142882 (Lazy init diagnostics-only local_names in borrowck)
 - rust-lang/rust#142883 (Add impl_trait_in_bindings tests from rust-lang/rust#61773)
 - rust-lang/rust#142943 (Don't include current rustc version string in feature removed help)
 - rust-lang/rust#142965 ([RTE-497] Ignore `c-link-to-rust-va-list-fn` test on SGX platform)
 - rust-lang/rust#142972 (Add a missing mailmap entry)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-06-24 21:58:31 +00:00
bjorn3
c44a23c16c Make comment on activate_injected_dep a doc comment 2025-06-24 19:44:35 +00:00
bjorn3
5dfe72c1fd Stop handling explicit dependencies on the panic runtime
You shouldn't ever need to explicitly depend on it. And we weren't
checking that the panic runtime used the correct panic strategy either.
2025-06-24 19:44:35 +00:00
bjorn3
5f63b57589 Remove dependency injection for the panic runtime
This used to be necessary for a correct linker order, but ever since the
introduction of symbols.o adding the symbols in question to symbols.o
would work just as well. We do still add dependencies on the panic runtime
to the local crate, but not for #![needs_panic_runtime] crates.

This also removes the runtime-depends-on-needs-runtime test.
inject_dependency_if used to emit this error, but with symbols.o it is
no longer important that there is no dependency and in fact it may be
nice to have panic_abort and panic_unwind directly depend on libstd in
the future for calling std::process::abort().
2025-06-24 19:44:35 +00:00
Vadim Petrochenkov
0be37cab97 rustc_session: Add a structure for keeping both explicit and default sysroots
Also avoid creating and cloning sysroot unnecessarily.
2025-06-24 16:00:04 +03:00
Nicholas Nethercote
b2a57e6b42 Tweak -Zinput-stats and -Zmeta-stats output.
To make it match `-Zmacro-stats`, and work better if you have enabled it
for multiple crates.
- Print each crate's name.
- Print a `===` banner at the start and end for separation.
2025-06-24 13:07:14 +10:00
Nicholas Nethercote
1e7e1732ca Reverse order of -Zinput-stats and -Zmeta-stats output.
Currently they have the largest items at the end. I believe the
rationale is that it saves you scrolling up through terminal output
because the important stuff is at the bottom. But it's also surprising
and a bit confusing, and I think the obvious order (big things at the
top) is better.
2025-06-24 13:05:53 +10:00
Nicholas Nethercote
8b1abd6578 Make stats code nicer.
Taking inspiration from `-Zmacro-stats`:
- Use "{prefix}" consistently.
- Use names for column widths.
- Write output in a single `eprint!` call, in an attempt to minimize
  interleaving of output from different rustc processes.
- Use `repeat` for the long `---` banners.
2025-06-24 13:05:51 +10:00
Michael Goulet
48060c97c8 Use gen blocks in the compiler instead of from_coroutine 2025-06-20 18:57:52 +00:00
bors
044514eb26 Auto merge of #142689 - Urgau:rollup-4ho6835, r=Urgau
Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#135656 (Add `-Z hint-mostly-unused` to tell rustc that most of a crate will go unused)
 - rust-lang/rust#138237 (Get rid of `EscapeDebugInner`.)
 - rust-lang/rust#141614 (lint direct use of rustc_type_ir )
 - rust-lang/rust#142123 (Implement initial support for timing sections (`--json=timings`))
 - rust-lang/rust#142377 (Try unremapping compiler sources)
 - rust-lang/rust#142674 (remove duplicate crash test)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-06-18 21:19:39 +00:00
Urgau
bf38e5dee3
Rollup merge of #142377 - Urgau:unremap-rustc-dev, r=jieyouxu
Try unremapping compiler sources

See [#t-compiler/help > Span pointing to wrong file location (`rustc-dev` component)](https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/Span.20pointing.20to.20wrong.20file.20location.20.28.60rustc-dev.60.20component.29/with/521087083).

This PR is a follow-up to rust-lang/rust#141751 regarding the compiler side.

Specifically we now take into account the `CFG_VIRTUAL_RUSTC_DEV_SOURCE_BASE_DIR` env from rust-lang/rust#141751 when trying to unremap sources from `$sysroot/lib/rustlib/rustc-src/rust` (the `rustc-dev` component install directory).

Best reviewed commit by commit.

cc ``@samueltardieu``
r? ``@jieyouxu``
2025-06-18 19:40:32 +02:00
klensy
8c83935cdf apply clippy::or_fun_call 2025-06-17 13:59:53 +03:00
León Orell Valerian Liehr
0b249d3f85
Rollup merge of #141769 - bjorn3:codegen_metadata_module_rework, r=workingjubilee,saethlin
Move metadata object generation for dylibs to the linker code

This deduplicates some code between codegen backends and may in the future allow adding extra metadata that is only known at link time.

Prerequisite of https://github.com/rust-lang/rust/issues/96708.
2025-06-15 23:51:54 +02:00
Urgau
268fbfed47 Un-remap rustc-dev component paths 2025-06-15 17:20:08 +02:00
Urgau
810d99e7b5 Prepare rustc-dev component un-remapping in the compiler 2025-06-14 15:24:28 +02:00
Matthias Krüger
9639a7c522
Rollup merge of #142069 - nnethercote:Zmacro-stats, r=petrochenkov
Introduce `-Zmacro-stats`

Introduce `-Zmacro-stats`.

It collects data about macro expansions and prints them in a table after expansion finishes. It's very useful for detecting macro bloat, especially for proc macros.

r? `@petrochenkov`
2025-06-13 05:16:56 +02:00
Nicholas Nethercote
bdfe1b9fb0 Overhaul the thousands module.
It currently only inserts separators into `usize`s, because that's all
that has been needed so far. `-Zmacro-stats` will need `isize` and `f64`
handling, so this commit adds that.
2025-06-12 15:26:06 +10:00
Urgau
208f2e461c Remove useless and wrong std crates special casing when un-remap sysroot 2025-06-11 07:42:58 +02:00
Ralf Jung
b616e11974 raw dylib: ensure that we have applied standard ABI checks
also unify error messages that do not seem to have a good reason to be different
2025-06-08 07:34:41 +02:00