about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2025-03-10Share implementation of expr_u{16,32,size}.Mara Bos-21/+8
2025-03-10make precise capturing args in rustdoc Json typedmorine0122-10/+21
2025-03-10Limit formatting width and precision to 16 bits.Mara Bos-11/+23
2025-03-10Revert "Use workspace lints for crates in `compiler/` #138084"许杰友 Jieyou Xu (Joe)-229/+86
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-10Allow int literals for pattern types with int base typesOli Scherer-2/+20
2025-03-10Reject wrapping ranges of pattern typesOli Scherer-0/+28
2025-03-10Rollup merge of #138270 - StevenMia:master, r=compiler-errorsMatthias Krüger-4/+4
chore: Fix some comments Fix some comments
2025-03-10Rollup merge of #138238 - compiler-errors:dyn-suggestion-in-struct, ↵Matthias Krüger-33/+94
r=nnethercote Fix dyn -> param suggestion in struct ICEs Makes the logic from #138042 a bit less ICEy and more clean. Also fixes an incorrect suggestion when the struct already has generics. I'll point out the major changes and observations in the code. Fixes #138229 Fixes #138211 r? nnethercote since you reviewed the original pr, or re-roll if you don't want to review this
2025-03-10Rollup merge of #137279 - estebank:codegen-structured-errors, r=nnethercoteMatthias Krüger-84/+160
Make some invalid codegen attr errors structured/translatable
2025-03-10add tracking issue for unqualified_local_importsRalf Jung-1/+1
2025-03-10Remove AdtFlags::IS_ANONYMOUS and Copy/Clone condition for anonymous ADTMichael Goulet-18/+1
2025-03-10Fix pretty printing of parsed attrs in hir_prettyMichael Goulet-15/+22
2025-03-10Rename print_something to should_renderMichael Goulet-22/+28
2025-03-10Update rand to 0.9.0Chris Denton-7/+7
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-09Do not feed anon const a type that references generics that it does not haveMichael Goulet-8/+17
2025-03-09Do not write user type annotation for const param value pathMichael Goulet-0/+7
2025-03-09Explain weird quirk in user type annotation loweringMichael Goulet-3/+23
2025-03-09Auto merge of #138279 - matthiaskrgr:rollup-ndnoipr, r=matthiaskrgrbors-7/+6
Rollup of 7 pull requests Successful merges: - #122790 (Apply dllimport in ThinLTO) - #137650 (Move `fs` into `sys`) - #138228 (Use `disjoint_bitor` inside `borrowing_sub`) - #138233 (Windows: Don't link std (and run-make) against advapi32, except on win7) - #138253 (Continue to check attr if meet empty repr for adt) - #138263 (Fix `repr128-dwarf` test) - #138276 (Lazy load NtOpenFile for UWP) r? `@ghost` `@rustbot` modify labels: rollup
2025-03-09Rollup merge of #138253 - mu001999-contrib:fix-138241, r=jdonszelmannMatthias Krüger-1/+1
Continue to check attr if meet empty repr for adt Fixes #138241 Returning while checking ReprEmpty results in missing the check for the next repr
2025-03-09Rollup merge of #122790 - Zoxc:dllimp-rev, r=ChrisDentonMatthias Krüger-6/+5
Apply dllimport in ThinLTO This partially reverts https://github.com/rust-lang/rust/pull/103353 by properly applying `dllimport` if `-Z dylib-lto` is passed. That PR should probably fully be reverted as it looks quite sketchy. We don't know locally if the entire crate graph would be statically linked. This should hopefully be sufficient to make ThinLTO work for rustc on Windows. r? ``@wesleywiser`` --- Edit: This PR is changed to just generally revert https://github.com/rust-lang/rust/pull/103353.
2025-03-09Auto merge of #137655 - nnethercote:split-edges-iterator, r=nnethercotebors-93/+132
Split the `Edges` iterator. Some nice performance wins here, mostly on the `wg-grammar` benchmark. r? `@lcnr`
2025-03-09Auto merge of #138267 - matthiaskrgr:rollup-vt76bhs, r=matthiaskrgrbors-1030/+1153
Rollup of 12 pull requests Successful merges: - #136127 (Allow `*const W<dyn A> -> *const dyn A` ptr cast) - #136968 (Turn order dependent trait objects future incompat warning into a hard error) - #137319 (Stabilize `const_vec_string_slice`) - #137885 (tidy: add triagebot checks) - #138040 (compiler: Use `size_of` from the prelude instead of imported) - #138084 (Use workspace lints for crates in `compiler/`) - #138158 (Move more layouting logic to `rustc_abi`) - #138160 (depend more on attr_data_structures and move find_attr! there) - #138192 (crashes: couple more tests) - #138216 (bootstrap: Fix stack printing when a step cycle is detected) - #138232 (Reduce verbosity of GCC build log) - #138242 (Revert "Don't test new error messages with the stage 0 compiler") r? `@ghost` `@rustbot` modify labels: rollup
2025-03-09metadata: Ignore sysroot when doing the manual native lib search in rustcVadim Petrochenkov-47/+46
2025-03-09chore: Fix some commentsStevenMia-4/+4
Signed-off-by: StevenMia <flite@foxmail.com>
2025-03-09Rollup merge of #138160 - jdonszelmann:move-find-attr2, r=oli-obkMatthias Krüger-66/+69
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-626/+723
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-86/+229
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-74/+64
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-170/+8
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-09Rollup merge of #136127 - WaffleLapkin:dyn_ptr_unwrap_cast, r=compiler-errorsMatthias Krüger-8/+60
Allow `*const W<dyn A> -> *const dyn A` ptr cast Followup of https://github.com/rust-lang/rust/pull/120248#discussion_r1487936000. This PR allows casting pointers from something wrapping a trait object, to the trait object, i.e. `*const W<dyn A> -> *const dyn A` where `W` is `struct W<T: ?Sized>(T);`. r? compiler-errors Fixes https://github.com/rust-lang/rust/issues/128625
2025-03-09Auto merge of #137563 - FractalFir:dep_graph_cap, r=nnethercotebors-2/+1
Change TaskDeps to start preallocated with 128 capacity This is a tiny change that makes `TaskDeps::read_set` start preallocated with capacity for 128 elements. From local profiling, it looks like `TaskDeps::read_set` is one of the most-often resized hash-sets in `rustc`.
2025-03-09continue to check attr if meet empty repr for adtMu001999-1/+1
2025-03-09Do not register `Self: AutoTrait` when confirming auto traitMichael Goulet-15/+1
2025-03-09Auto merge of #137513 - scottmcm:identity-transmute, r=saethlinbors-0/+7
Don't re-`assume` in `transmute`s that don't change niches I noticed in nightly 2025-02-21 that `transmute` is emitting way more `assume`s than necessary for newtypes. For example, the three transmutes in <https://rust.godbolt.org/z/fW1KaTc4o> emits ```rust define noundef range(i32 1, 0) i32 `@repeatedly_transparent_transmute(i32` noundef range(i32 1, 0) %_1) unnamed_addr { start: %0 = sub i32 %_1, 1 %1 = icmp ule i32 %0, -2 call void `@llvm.assume(i1` %1) %2 = sub i32 %_1, 1 %3 = icmp ule i32 %2, -2 call void `@llvm.assume(i1` %3) %4 = sub i32 %_1, 1 %5 = icmp ule i32 %4, -2 call void `@llvm.assume(i1` %5) %6 = sub i32 %_1, 1 %7 = icmp ule i32 %6, -2 call void `@llvm.assume(i1` %7) %8 = sub i32 %_1, 1 %9 = icmp ule i32 %8, -2 call void `@llvm.assume(i1` %9) %10 = sub i32 %_1, 1 %11 = icmp ule i32 %10, -2 call void `@llvm.assume(i1` %11) ret i32 %_1 } ``` But those are all just newtypes that don't change size or niches, so none of it's needed. After this PR it's down to just ```rust define noundef range(i32 1, 0) i32 `@repeatedly_transparent_transmute(i32` noundef range(i32 1, 0) %_1) unnamed_addr { start: ret i32 %_1 } ``` because none of those `assume`s in the original actually did anything. (Transmuting to something with a difference niche, though, still has the assumes -- the other tests continue to pass checking that.)
2025-03-08Auto merge of #137502 - compiler-errors:global-asm-aint-mir-body, r=oli-obkbors-1/+6
Don't include global asm in `mir_keys`, fix error body synthesis r? oli-obk Fixes #137470 Fixes #137471 Fixes #137472 Fixes #137473 try-job: test-various try-job: x86_64-apple-2
2025-03-08Fix suggestion when there are generics, inline some thingsMichael Goulet-16/+30
2025-03-08Rework maybe_suggest_add_generic_impl_traitMichael Goulet-24/+71
2025-03-08Auto merge of #137500 - scottmcm:trunc-br, r=saethlinbors-0/+34
Use `trunc nuw`+`br` for 0/1 branches even in optimized builds Rather than needing to use `switch` for them to include the `unreachable` arm.
2025-03-08Move coroutine layout logic to `rustc_abi`Moulins-334/+373
2025-03-08check that `UnsizeCoerce` may hold before trying unsizing coercionWaffle Lapkin-8/+60
this prevents us from trying unsizing coercion in cases like `*const W<dyn T>` -> `*const dyn T`, where it would later cause a compilation error since `W<dyn T>: Sized` and `W<dyn T>: T` do not hold.
2025-03-08support XCOFF in `naked_asm!`Folkert de Vries-9/+41
2025-03-08Refactor coroutine layout logic to precompute all sublayoutsMoulins-117/+118
Also properly attaches spans on layouts of non-promoted coroutine locals, which slightly improves the error messages for some coroutine tests.
2025-03-08Move SIMD layout logic to `rustc_abi`Moulins-79/+117
2025-03-08Remove most manual LayoutData creations and move them to `rustc_abi`Moulins-189/+208
...either as: - methods on LayoutCalculator, for faillible operations; - constructors on LayoutData, for infaillible ones.
2025-03-08Rollup merge of #137757 - estebank:trim-spans, r=davidtwcoJacob Pratt-98/+160
On long spans, trim the middle of them to make them fit in the terminal width When encountering a single line span that is wider than the terminal, we keep context at the start and end of the span but otherwise remove the code from the middle. This is somewhat independent from whether the left and right margins of the output have been trimmed as well. ``` error[E0308]: mismatched types --> $DIR/long-span.rs:6:15 | LL | ... = [0, 0, 0, 0, ..., 0, 0]; | ^^^^^^^^^^^^^...^^^^^^^ expected `u8`, found `[{integer}; 1681]` ``` Address part of https://github.com/rust-lang/rust/issues/137680 (missing handling of the long suggestion). Fix https://github.com/rust-lang/rust/issues/125581. --- Change the way that underline positions are calculated by delaying using the "visual" column position until the last possible moment, instead using the "file"/byte position in the file, and then calculating visual positioning as late as possible. This should make the underlines more resilient to non-1-width unicode chars. Unfortunately, as part of this change (which fixes some visual bugs) comes with the loss of some eager tab codepoint handling, but the output remains legible despite some minor regression on the "margin trimming" logic. --- `-Zteach` is perma-unstable, barely used, the highlighting logic buggy and the flag being passed around is tech-debt. We should likely remove `-Zteach` in its entirely.
2025-03-08Rollup merge of #137685 - lqd:nostart-stop-gc, r=petrochenkovJacob Pratt-0/+29
self-contained linker: conservatively default to `-znostart-stop-gc` on x64 linux To help stabilization, this PR disables an LLD optimization on x64 linux with respect to `--gc-sections` and encapsulation symbols: it will reduce the number of crates needing to opt-out of lld due to this bfd / lld difference. For example, all the people using [linkme](https://github.com/dtolnay/linkme), which [doesn't work with lld](https://github.com/dtolnay/linkme/issues/63) or on nightly, need to disable lld. More information about all this, and the historical differences, can be found in: - https://maskray.me/blog/2021-01-31-metadata-sections-comdat-and-shf-link-order - https://lld.llvm.org/ELF/start-stop-gc This optimization has [no visible impact](https://github.com/rust-lang/rust/pull/137685#issuecomment-2686116312) on our benchmarks, so we can use it by default and have a safer/more conservative starting point to remove friction during migration. We can them emit an FCW for the cases where lld detects reliance on encapsulation symbols without `-znostart-stop-gc`, and then revert back to lld's default after a while. No one compiling on nightly relies on this difference, obviously, so doing an FCW is not necessary until after lld is used on stable. I've tested that this correctly links on `linkme` examples. I've also quickly tried to crate an rmake test but the setup with encapsulation symbols is annoying to reproduce: a few link section/name attributes is not enough, we also need to collect symbols between the encapsulation symbols, without referencing them in code, for `-znostart-stop-gc` to only impact this... It should of course be doable though, maybe ````@Kobzol```` will look into it if they have time. r? ````@petrochenkov````
2025-03-08Rollup merge of #136642 - bjorn3:separate_alloctest_crate, r=cuviperJacob Pratt-3/+3
Put the alloc unit tests in a separate alloctests package Same rationale as https://github.com/rust-lang/rust/pull/135937. This PR has some extra complexity though as a decent amount of tests are testing internal implementation details rather than the public api. As such I opted to include the modules containing the types under test using `#[path]` into the alloctests package. This means that those modules still need `#[cfg(test)]`, but the rest of liballoc no longer need it.
2025-03-08[AIX] Ignore linting on repr(C) structs with repr(packed) or repr(align(n))Amy Kwan-0/+6
This PR updates the lint added in 9b40bd7 to ignore repr(C) structs that also have repr(packed) or repr(align(n)). As these representations can be modifiers on repr(C), it is assumed that users that add these should know what they are doing, and thus the the lint should not warn on the respective structs. For example, for the time being, using repr(packed) and manually padding a repr(C) struct can be done to correctly align struct members on AIX.
2025-03-07Rollup merge of #138187 - matthiaskrgr:rmclone, r=cjgillotJacob Pratt-19/+10
remove clones