about summary refs log tree commit diff
path: root/compiler/rustc_session/src
AgeCommit message (Collapse)AuthorLines
2025-02-22Greatly simplify lifetime captures in edition 2024Michael Goulet-7/+6
2025-02-22Auto merge of #137420 - matthiaskrgr:rollup-rr0q37f, r=matthiaskrgrbors-17/+17
Rollup of 9 pull requests Successful merges: - #136910 (Implement feature `isolate_most_least_significant_one` for integer types) - #137183 (Prune dead regionck code) - #137333 (Use `edition = "2024"` in the compiler (redux)) - #137356 (Ferris 🦀 Identifier naming conventions) - #137362 (Add build step log for `run-make-support`) - #137377 (Always allow reusing cratenum in CrateLoader::load) - #137388 (Fix(lib/fs/tests): Disable rename POSIX semantics FS tests under Windows 7) - #137410 (Use StableHasher + Hash64 for dep_tracking_hash) - #137413 (jubilee cleared out the review queue) r? `@ghost` `@rustbot` modify labels: rollup
2025-02-22Rollup merge of #137410 - saethlin:stable-dep-tracking-hash, r=workingjubileeMatthias Krüger-15/+16
Use StableHasher + Hash64 for dep_tracking_hash This is similar to https://github.com/rust-lang/rust/pull/137095. We currently have a +/- 1 byte jitter in the size of dep graphs reported on perf.rust-lang.org. I think this fixes that jitter. When I introduced `Hash64`, I wired it through most of the compiler by making it an output of `StableHasher::finalize` then fixing the compile errors. I missed this case because the `u64` hash in this function is being produced by `DefaultHasher` instead. That seems pretty sketchy because the code seems confident that the hash needs to be stable, and we have a mechanism for stable hashing that we weren't using here.
2025-02-21update autodiff flagsManuel Drehwald-38/+26
2025-02-21Use StableHasher + Hash64 for dep_tracking_hashBen Kimock-15/+16
2025-02-22Fix binding mode problemsMichael Goulet-2/+1
2025-02-17Auto merge of #137164 - matthiaskrgr:rollup-dj5826k, r=matthiaskrgrbors-2/+2
Rollup of 7 pull requests Successful merges: - #137095 (Replace some u64 hashes with Hash64) - #137100 (HIR analysis: Remove unnecessary abstraction over list of clauses) - #137105 (Restrict DerefPure for Cow<T> impl to T = impl Clone, [impl Clone], str.) - #137120 (Enable `relative-path-include-bytes-132203` rustdoc-ui test on Windows) - #137125 (Re-add missing empty lines in the releases notes) - #137145 (use add-core-stubs / minicore for a few more tests) - #137149 (Remove SSE ABI from i586-pc-windows-msvc) r? `@ghost` `@rustbot` modify labels: rollup
2025-02-17Rollup merge of #137095 - saethlin:use-hash64-for-hashes, r=workingjubileeMatthias Krüger-2/+2
Replace some u64 hashes with Hash64 I introduced the Hash64 and Hash128 types in https://github.com/rust-lang/rust/pull/110083, essentially as a mechanism to prevent hashes from landing in our leb128 encoding paths. If you just have a u64 or u128 field in a struct then derive Encodable/Decodable, that number gets leb128 encoding. So if you need to store a hash or some other value which behaves very close to a hash, don't store it as a u64. This reverts part of https://github.com/rust-lang/rust/pull/117603, which turned an encoded Hash64 into a u64. Based on https://github.com/rust-lang/rust/pull/110083, I don't expect this to be perf-sensitive on its own, though I expect that it may help stabilize some of the small rmeta size fluctuations we currently see in perf reports.
2025-02-17Rollup merge of #136671 - nnethercote:middle-limits, r=NadrierilMatthias Krüger-0/+7
Overhaul `rustc_middle::limits` In particular, to make `pattern_complexity` work more like other limits, which then enables some other simplifications. r? ``@Nadrieril``
2025-02-17Add `pattern_complexity_limit` to `Limits`.Nicholas Nethercote-0/+7
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-2/+2
with rust-analyzer
2025-02-16Rollup merge of #137072 - Urgau:check-cfg-load-builtins-at-once, r=NoratriebMatthias Krüger-6/+2
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-15Load all builtin targets at once instead of one by oneUrgau-6/+2
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-68/+3
2025-02-15Clean up rustc_session::output::{find,validate}_crate_nameLeón Orell Valerian Liehr-53/+56
2025-02-13Make `-O` mean `-C opt-level=3`clubby789-10/+16
2025-02-11Rollup merge of #135285 - tbu-:pr_fix_typo4, r=GuillaumeGomezMatthias Krüger-1/+1
it-self → itself, build-system → build system, type-alias → type alias
2025-02-10Stop using span hack for contracts feature gatingMichael Goulet-5/+0
2025-02-09Rollup merge of #136746 - wesleywiser:err_dwarf1, r=UrgauMatthias Krüger-1/+3
Emit an error if `-Zdwarf-version=1` is requested DWARF 1 is very different than DWARF 2+[^1] and LLVM does not really seem to support DWARF 1 as Clang does not offer a `-gdwarf-1` flag[^2] and `llc` will just generate DWARF 2 with the version set to 1[^3]. Since this isn't actually supported (and it's not clear it would be useful anyway), report that DWARF 1 is not supported if it is requested. Also add a help message to the error saying which versions are supported. cc #103057 [^1]: https://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html#index-gdwarf [^2]: https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-gdwarf [^3]: https://godbolt.org/z/s85d87n3a
2025-02-09Emit an error if `-Zdwarf-version=1` is requestedWesley Wiser-1/+3
DWARF 1 is very different than DWARF 2+ (see the commentary in https://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html#index-gdwarf) and LLVM does not really seem to support DWARF 1 as Clang does not offer a `-gdwarf-1` flag and `llc` will just generate DWARF 2 with the version set to 1: https://godbolt.org/z/s85d87n3a. Since this isn't actually supported (and it's not clear it would be useful anyway), report that DWARF 1 is not supported if it is requested. Also add a help message to the error saying which versions are supported.
2025-02-08Rustfmtbjorn3-28/+20
2025-02-06Rollup merge of #136636 - bjorn3:error_cleanup, r=compiler-errorsMatthias Krüger-12/+6
Couple of minor cleanups to the diagnostic infrastructure
2025-02-06Rollup merge of #136152 - Urgau:stabilize-map_many_mut, r=joshtriplettMatthias Krüger-2/+1
Stabilize `map_many_mut` feature This PR stabilize `HashMap::get_many_mut` as `HashMap::get_disjoint_mut` and `HashMap::get_many_unchecked_mut` as `HashMap::get_disjoint_unchecked_mut` per FCP. FCP at https://github.com/rust-lang/rust/issues/97601#issuecomment-2532710423 Fixes #97601 r? libs
2025-02-06Construct DiagCtxt a bit earlier in build_sessionbjorn3-12/+6
2025-02-06Auto merge of #136471 - safinaskar:parallel, r=SparrowLiibors-22/+21
tree-wide: parallel: Fully removed all `Lrc`, replaced with `Arc` tree-wide: parallel: Fully removed all `Lrc`, replaced with `Arc` This is continuation of https://github.com/rust-lang/rust/pull/132282 . I'm pretty sure I did everything right. In particular, I searched all occurrences of `Lrc` in submodules and made sure that they don't need replacement. There are other possibilities, through. We can define `enum Lrc<T> { Rc(Rc<T>), Arc(Arc<T>) }`. Or we can make `Lrc` a union and on every clone we can read from special thread-local variable. Or we can add a generic parameter to `Lrc` and, yes, this parameter will be everywhere across all codebase. So, if you think we should take some alternative approach, then don't merge this PR. But if it is decided to stick with `Arc`, then, please, merge. cc "Parallel Rustc Front-end" ( https://github.com/rust-lang/rust/issues/113349 ) r? SparrowLii `@rustbot` label WG-compiler-parallel
2025-02-03Separate contract feature gates for the internal machineryFelix S. Klock II-0/+5
The extended syntax for function signature that includes contract clauses should never be user exposed versus the interface we want to ship externally eventually.
2025-02-03Contracts core intrinsics.Felix S. Klock II-0/+13
These are hooks to: 1. control whether contract checks are run 2. allow 3rd party tools to intercept and reintepret the results of running contracts.
2025-02-03tree-wide: parallel: Fully removed all `Lrc`, replaced with `Arc`Askar Safin-22/+21
2025-02-03Auto merge of #133138 - azhogin:azhogin/target-modifiers, r=davidtwco,saethlinbors-15/+333
Target modifiers (special marked options) are recorded in metainfo Target modifiers (special marked options) are recorded in metainfo and compared to be equal in different linked crates. PR for this RFC: https://github.com/rust-lang/rfcs/pull/3716 Option may be marked as `TARGET_MODIFIER`, example: `regparm: Option<u32> = (None, parse_opt_number, [TRACKED TARGET_MODIFIER]`. If an TARGET_MODIFIER-marked option has non-default value, it will be recorded in crate metainfo as a `Vec<TargetModifier>`: ``` pub struct TargetModifier { pub opt: OptionsTargetModifiers, pub value_name: String, } ``` OptionsTargetModifiers is a macro-generated enum. Option value code (for comparison) is generated using `Debug` trait. Error example: ``` error: mixing `-Zregparm` will cause an ABI mismatch in crate `incompatible_regparm` --> $DIR/incompatible_regparm.rs:10:1 | LL | #![crate_type = "lib"] | ^ | = help: the `-Zregparm` flag modifies the ABI so Rust crates compiled with different values of this flag cannot be used together safely = note: `-Zregparm=1` in this crate is incompatible with `-Zregparm=2` in dependency `wrong_regparm` = help: set `-Zregparm=2` in this crate or `-Zregparm=1` in `wrong_regparm` = help: if you are sure this will not cause problems, use `-Cunsafe-allow-abi-mismatch=regparm` to silence this error error: aborting due to 1 previous error ``` `-Cunsafe-allow-abi-mismatch=regparm,reg-struct-return` to disable list of flags.
2025-02-02Replace ParseSess::set_dcx with DiagCtxt::set_emitterbjorn3-4/+0
Replacing the error emitter doesn't accidentally clear the error count.
2025-02-02Use fallback fluent bundle from inner emitter in SilentEmitterbjorn3-5/+2
2025-02-02Slightly simplify DiagCtxt::make_silentbjorn3-3/+2
2025-02-02Some cleanups around EarlyDiagCtxtbjorn3-13/+7
All callers of EarlyDiagCtxt::early_error now emit a fatal error.
2025-02-02Target modifiers (special marked options) are recorded in metainfo and ↵Andrew Zhogin-15/+333
compared to be equal in different crates
2025-01-31it-self → itself, build-system → build system, type-alias → type aliasTobias Bucher-1/+1
2025-01-31Auto merge of #136332 - jhpratt:rollup-aa69d0e, r=jhprattbors-1/+84
Rollup of 9 pull requests Successful merges: - #132156 (When encountering unexpected closure return type, point at return type/expression) - #133429 (Autodiff Upstreaming - rustc_codegen_ssa, rustc_middle) - #136281 (`rustc_hir_analysis` cleanups) - #136297 (Fix a typo in profile-guided-optimization.md) - #136300 (atomic: extend compare_and_swap migration docs) - #136310 (normalize `*.long-type.txt` paths for compare-mode tests) - #136312 (Disable `overflow_delimited_expr` in edition 2024) - #136313 (Filter out RPITITs when suggesting unconstrained assoc type on too many generics) - #136323 (Fix a typo in conventions.md) r? `@ghost` `@rustbot` modify labels: rollup
2025-01-31Rollup merge of #133429 - EnzymeAD:autodiff-middle, r=oli-obkJacob Pratt-1/+84
Autodiff Upstreaming - rustc_codegen_ssa, rustc_middle This PR should not be merged until the rustc_codegen_llvm part is merged. I will also alter it a little based on what get's shaved off from the cg_llvm PR, and address some of the feedback I received in the other PR (including cleanups). I am putting it already up to 1) Discuss with `@jieyouxu` if there is more work needed to add tests to this and 2) Pray that there is someone reviewing who can tell me why some of my autodiff invocations get lost. Re 1: My test require fat-lto. I also modify the compilation pipeline. So if there are any other llvm-ir tests in the same compilation unit then I will likely break them. Luckily there are two groups who currently have the same fat-lto requirement for their GPU code which I have for my autodiff code and both groups have some plans to enable support for thin-lto. Once either that work pans out, I'll copy it over for this feature. I will also work on not changing the optimization pipeline for functions not differentiated, but that will require some thoughts and engineering, so I think it would be good to be able to run the autodiff tests isolated from the rest for now. Can you guide me here please? For context, here are some of my tests in the samples folder: https://github.com/EnzymeAD/rustbook Re 2: This is a pretty serious issue, since it effectively prevents publishing libraries making use of autodiff: https://github.com/EnzymeAD/rust/issues/173. For some reason my dummy code persists till the end, so the code which calls autodiff, deletes the dummy, and inserts the code to compute the derivative never gets executed. To me it looks like the rustc_autodiff attribute just get's dropped, but I don't know WHY? Any help would be super appreciated, as rustc queries look a bit voodoo to me. Tracking: - https://github.com/rust-lang/rust/issues/124509 r? `@jieyouxu`
2025-01-31Auto merge of #135318 - compiler-errors:vtable-fixes, r=lcnrbors-61/+1
Fix deduplication mismatches in vtables leading to upcasting unsoundness We currently have two cases where subtleties in supertraits can trigger disagreements in the vtable layout, e.g. leading to a different vtable layout being accessed at a callsite compared to what was prepared during unsizing. Namely: ### #135315 In this example, we were not normalizing supertraits when preparing vtables. In the example, ``` trait Supertrait<T> { fn _print_numbers(&self, mem: &[usize; 100]) { println!("{mem:?}"); } } impl<T> Supertrait<T> for () {} trait Identity { type Selff; } impl<Selff> Identity for Selff { type Selff = Selff; } trait Middle<T>: Supertrait<()> + Supertrait<T> { fn say_hello(&self, _: &usize) { println!("Hello!"); } } impl<T> Middle<T> for () {} trait Trait: Middle<<() as Identity>::Selff> {} impl Trait for () {} fn main() { (&() as &dyn Trait as &dyn Middle<()>).say_hello(&0); } ``` When we prepare `dyn Trait`, we see a supertrait of `Middle<<() as Identity>::Selff>`, which itself has two supertraits `Supertrait<()>` and `Supertrait<<() as Identity>::Selff>`. These two supertraits are identical, but they are not duplicated because we were using structural equality and *not* considering normalization. This leads to a vtable layout with two trait pointers. When we upcast to `dyn Middle<()>`, those two supertraits are now the same, leading to a vtable layout with only one trait pointer. This leads to an offset error, and we call the wrong method. ### #135316 This one is a bit more interesting, and is the bulk of the changes in this PR. It's a bit similar, except it uses binder equality instead of normalization to make the compiler get confused about two vtable layouts. In the example, ``` trait Supertrait<T> { fn _print_numbers(&self, mem: &[usize; 100]) { println!("{mem:?}"); } } impl<T> Supertrait<T> for () {} trait Trait<T, U>: Supertrait<T> + Supertrait<U> { fn say_hello(&self, _: &usize) { println!("Hello!"); } } impl<T, U> Trait<T, U> for () {} fn main() { (&() as &'static dyn for<'a> Trait<&'static (), &'a ()> as &'static dyn Trait<&'static (), &'static ()>) .say_hello(&0); } ``` When we prepare the vtable for `dyn for<'a> Trait<&'static (), &'a ()>`, we currently consider the PolyTraitRef of the vtable as the key for a supertrait. This leads two two supertraits -- `Supertrait<&'static ()>` and `for<'a> Supertrait<&'a ()>`. However, we can upcast[^up] without offsetting the vtable from `dyn for<'a> Trait<&'static (), &'a ()>` to `dyn Trait<&'static (), &'static ()>`. This is just instantiating the principal trait ref for a specific `'a = 'static`. However, when considering those supertraits, we now have only one distinct supertrait -- `Supertrait<&'static ()>` (which is deduplicated since there are two supertraits with the same substitutions). This leads to similar offsetting issues, leading to the wrong method being called. [^up]: I say upcast but this is a cast that is allowed on stable, since it's not changing the vtable at all, just instantiating the binder of the principal trait ref for some lifetime. The solution here is to recognize that a vtable isn't really meaningfully higher ranked, and to just treat a vtable as corresponding to a `TraitRef` so we can do this deduplication more faithfully. That is to say, the vtable for `dyn for<'a> Tr<'a>` and `dyn Tr<'x>` are always identical, since they both would correspond to a set of free regions on an impl... Do note that `Tr<for<'a> fn(&'a ())>` and `Tr<fn(&'static ())>` are still distinct. ---- There's a bit more that can be cleaned up. In codegen, we can stop using `PolyExistentialTraitRef` basically everywhere. We can also fix SMIR to stop storing `PolyExistentialTraitRef` in its vtable allocations. As for testing, it's difficult to actually turn this into something that can be tested with `rustc_dump_vtable`, since having multiple supertraits that are identical is a recipe for ambiguity errors. Maybe someone else is more creative with getting that attr to work, since the tests I added being run-pass tests is a bit unsatisfying. Miri also doesn't help here, since it doesn't really generate vtables that are offset by an index in the same way as codegen. r? `@lcnr` for the vibe check? Or reassign, idk. Maybe let's talk about whether this makes sense. <sup>(I guess an alternative would also be to not do any deduplication of vtable supertraits (or only a really conservative subset) rather than trying to normalize and deduplicate more faithfully here. Not sure if that works and is sufficient tho.)</sup> cc `@steffahn` -- ty for the minimizations cc `@WaffleLapkin` -- since you're overseeing the feature stabilization :3 Fixes #135315 Fixes #135316
2025-01-30Remove print_vtable_sizesMichael Goulet-61/+1
2025-01-29Clean up uses of the unstable `dwarf_version` optionWesley Wiser-2/+7
- Consolidate calculation of the effective value. - Check the target `DebuginfoKind` instead of using `is_like_msvc`.
2025-01-29upstream rustc_codegen_ssa/rustc_middle changes for enzyme/autodiffManuel Drehwald-1/+84
2025-01-28Auto merge of #133929 - saethlin:remove-inline-in-all-cgus, r=nnethercotebors-2/+0
Remove -Zinline-in-all-cgus and clean up tests/codegen-units/ Implementation of https://github.com/rust-lang/compiler-team/issues/814 I've taken some liberties with cleaning up the CGU partitioning tests, because that's the only place this flag was used and also mattered. I've often fought a lot with the contents of `tests/codegen-units` and it has never been clear to me when a test failure indicates a problem with my changes as opposed to a test just needing to be manually blessed. Hopefully the combination of the new README, new comments, and using `-Zprint-mono-items=lazy` in the partitioning tests improves that. I've also deleted some of the `tests/run-make/sepcomp` tests. I think all the "sepcomp" tests have been obviated for years by better-designed (less flaky, clearer failures) test suites, but here I'm just deleting the ones I'm confident in.
2025-01-27Remove -Zinline-in-all-cgus and clean up CGU partitioning testsBen Kimock-2/+0
2025-01-27Adjust compiler for `HashMap::get_many_mut` stabilizationUrgau-2/+1
2025-01-25Auto merge of #119286 - jyn514:linker-output, r=bjorn3bors-3/+6
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-23Remove the need to manually call set_using_internal_featuresbjorn3-2/+2
2025-01-21Auto merge of #135487 - klensy:windows-0.59, r=Mark-Simulacrumbors-1/+1
bump compiler and tools to windows 0.59, bootstrap to 0.57 This bumps compiler and tools to windows 0.59 (temporary dupes version, as `sysinfo` still depend on <= 0.57). Bootstrap bumps only to 0.57 (the same sysinfo dep). This additionally resolves my comment https://github.com/rust-lang/rust/pull/130874#issuecomment-2393562071 Will work on it in follow up pr: There still some sus imports for `rustc_driver.dll` like ws2_32 or RoOriginateErrorW, but i will look at them later.
2025-01-21Auto merge of #134299 - RalfJung:remove-start, r=compiler-errorsbors-1/+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-21remove support for the #[start] attributeRalf Jung-1/+0
2025-01-21bumpt compiler and tools to windows 0.59klensy-1/+1