about summary refs log tree commit diff
AgeCommit message (Collapse)AuthorLines
2024-09-27Rollup merge of #130880 - RalfJung:const-hack, r=scottmcmGuillaume Gomez-1/+1
add missing FIXME(const-hack) r? ```@scottmcm```
2024-09-27Rollup merge of #130879 - fmease:fix-diag-ice, r=compiler-errorsGuillaume Gomez-10/+55
Pass correct HirId to late_bound_vars in diagnostic code Fixes #130858. Fixes #125655. Fixes #130391. Fixes #130663. r? compiler-errors
2024-09-27Rollup merge of #130868 - taiki-e:s390x-fixme, r=jieyouxuGuillaume Gomez-6/+4
Update FIXME comment in s390x_unknown_linux_*.rs - Remove comment about "LLVM < 16" since the minimum external LLVM version is 16+ since https://github.com/rust-lang/rust/pull/117947 - Reflect rename of cabi_s390x.rs in https://github.com/rust-lang/rust/commit/030244cd4a76914af7dc2939ed1a16f394ceda48 (renamed to [abi/call/s390x.rs](https://github.com/rust-lang/rust/commit/030244cd4a76914af7dc2939ed1a16f394ceda48#diff-20136d4a18fa0ef9bd4fc2e6f92e88daad6be88bfb156e5702af39ee87ca4879), and it is currently [still in the same location](https://github.com/rust-lang/rust/blob/9e394f551c050ff03c6fc57f190e0761cf0be6e8/compiler/rustc_target/src/abi/call/s390x.rs)). r? ``````@cuviper`````` ``````@rustbot`````` label +O-SystemZ
2024-09-27Rollup merge of #130862 - zopsicle:patch-1, r=notriddle,GuillaumeGomezGuillaume Gomez-7/+12
rustdoc: do not animate :target when user prefers reduced motion This accessibility improvement gates #129284 behind an inverted [prefers-reduced-motion](https://developer.mozilla.org/en-US/docs/Web/CSS/`@media/prefers-reduced-motion)` media query.
2024-09-27Rollup merge of #130861 - cuviper:sun-path-offset, r=ibraheemdevGuillaume Gomez-12/+9
Use `mem::offset_of!` for `sockaddr_un.sun_path` We don't need manual pointer math here anymore! try-job: dist-i686-msvc
2024-09-27Rollup merge of #130850 - saveasguy:pass-mam-to-standrd-instrumentations, ↵Guillaume Gomez-5/+6
r=nikic Pass Module Analysis Manager to Standard Instrumentations This PR introduces changes related to llvm::PassInstrumentationCallbacks. Now, we pass Module Analysis Manager to StandardInstrumentations::registerCallbacks, so it can take advantage of such instrumentations as IR verifier or preserved CFG checker. So basically this is NFC PR.
2024-09-27Rollup merge of #130845 - RalfJung:utf8chunk, r=tgross35Guillaume Gomez-0/+4
Utf8Chunks: add link to Utf8Chunk It is currently surprisingly non-trivial to go from the `utf8_chunks` method to the docs of the `valid`/`invalid` methods used in the example. This should help.
2024-09-27Rollup merge of #130833 - makai410:master, r=compiler-errors,fee1-deadGuillaume Gomez-10/+10
Fix the misleading diagnostic for `let_underscore_drop` on type without `Drop` implementation Closes: #130430 r? rust-lang/diagnostics
2024-09-27Rollup merge of #130820 - 91khr:fix-coroutine-unit-arg, r=compiler-errorsGuillaume Gomez-37/+61
Fix diagnostics for coroutines with () as input. This may be a more real-life example to trigger the diagnostic: ```rust #![features(try_blocks, coroutine_trait, coroutines)] use std::ops::Coroutine; struct Request; struct Response; fn get_args() -> Result<String, String> { todo!() } fn build_request(_arg: String) -> Request { todo!() } fn work() -> impl Coroutine<Option<Response>, Yield = Request> { #[coroutine] |_| { let r: Result<(), String> = try { let req = get_args()?; yield build_request(req) }; if let Err(msg) = r { eprintln!("Error: {msg}"); } } } ```
2024-09-27Rollup merge of #130517 - bjorn3:update_ra_config, r=onur-ozkanGuillaume Gomez-0/+2
Add the library workspace to the suggested rust-analyzer config
2024-09-27Rollup merge of #130279 - theemathas:manually-drop-docs, r=thomcc,traviscrossGuillaume Gomez-12/+118
Document subtleties of `ManuallyDrop` After seeing #130140 and #130141, I figured that `ManuallyDrop` needs documentation explaining its subtleties, hence this PR. See also https://github.com/rust-lang/unsafe-code-guidelines/issues/245
2024-09-26rustdoc: consolidate prefers-reduced-motion-gated rulesetszopsicle-6/+4
2024-09-26Pass correct HirId to late_bound_vars in diagnostic codeLeón Orell Valerian Liehr-10/+55
2024-09-26Add `sun_path` to the fake doc `sockaddr_un`Josh Stone-1/+3
2024-09-26add missing FIXME(const-hack)Ralf Jung-1/+1
2024-09-26Auto merge of #129759 - dingxiangfei2009:stabilize-const-refs-to-static, ↵bors-442/+157
r=RalfJung Stabilize `const_refs_to_static` Meanwhile, I am cooking a sub-section in the language reference.
2024-09-26rustdoc: do not animate when user prefers reduced motionzopsicle-7/+14
This accessibility improvement gates the target flashing and tooltip fade-out behind an inverted prefers-reduced-motion media query.
2024-09-26Stabilize `const_refs_to_static`Ding Xiang Fei-442/+157
update tests fix bitwidth-sensitive stderr output use build-fail for asm tests
2024-09-26Auto merge of #130865 - cuviper:library-raw_ref_op, r=tgross35bors-185/+150
Use `&raw` in the standard library Since the stabilization in #127679 has reached stage0, 1.82-beta, we can start using `&raw` freely, and even the soft-deprecated `ptr::addr_of!` and `ptr::addr_of_mut!` can stop allowing the unstable feature. I intentionally did not change any documentation or tests, but the rest of those macro uses are all now using `&raw const` or `&raw mut` in the standard library.
2024-09-26Update FIXME comment in s390x_unknown_linux_*.rsTaiki Endo-6/+4
2024-09-26Auto merge of #130329 - khuey:reorder-constant-spills, r=davidtwcobors-18/+83
Reorder stack spills so that constants come later. Currently constants are "pulled forward" and have their stack spills emitted first. This confuses LLVM as to where to place breakpoints at function entry, and results in argument values being wrong in the debugger. It's straightforward to avoid emitting the stack spills for constants until arguments/etc have been introduced in debug_introduce_locals, so do that. Example LLVM IR (irrelevant IR elided): Before: ``` define internal void `@_ZN11rust_1289457binding17h2c78f956ba4bd2c3E(i64` %a, i64 %b, double %c) unnamed_addr #0 !dbg !178 { start: %c.dbg.spill = alloca [8 x i8], align 8 %b.dbg.spill = alloca [8 x i8], align 8 %a.dbg.spill = alloca [8 x i8], align 8 %x.dbg.spill = alloca [4 x i8], align 4 store i32 0, ptr %x.dbg.spill, align 4, !dbg !192 ; LLVM places breakpoint here. #dbg_declare(ptr %x.dbg.spill, !190, !DIExpression(), !192) store i64 %a, ptr %a.dbg.spill, align 8 #dbg_declare(ptr %a.dbg.spill, !187, !DIExpression(), !193) store i64 %b, ptr %b.dbg.spill, align 8 #dbg_declare(ptr %b.dbg.spill, !188, !DIExpression(), !194) store double %c, ptr %c.dbg.spill, align 8 #dbg_declare(ptr %c.dbg.spill, !189, !DIExpression(), !195) ret void, !dbg !196 } ``` After: ``` define internal void `@_ZN11rust_1289457binding17h2c78f956ba4bd2c3E(i64` %a, i64 %b, double %c) unnamed_addr #0 !dbg !178 { start: %x.dbg.spill = alloca [4 x i8], align 4 %c.dbg.spill = alloca [8 x i8], align 8 %b.dbg.spill = alloca [8 x i8], align 8 %a.dbg.spill = alloca [8 x i8], align 8 store i64 %a, ptr %a.dbg.spill, align 8 #dbg_declare(ptr %a.dbg.spill, !187, !DIExpression(), !192) store i64 %b, ptr %b.dbg.spill, align 8 #dbg_declare(ptr %b.dbg.spill, !188, !DIExpression(), !193) store double %c, ptr %c.dbg.spill, align 8 #dbg_declare(ptr %c.dbg.spill, !189, !DIExpression(), !194) store i32 0, ptr %x.dbg.spill, align 4, !dbg !195 ; LLVM places breakpoint here. #dbg_declare(ptr %x.dbg.spill, !190, !DIExpression(), !195) ret void, !dbg !196 } ``` Note in particular the position of the "LLVM places breakpoint here" comment relative to the stack spills for the function arguments. LLVM assumes that the first instruction with with a debug location is the end of the prologue. As LLVM does not currently offer front ends any direct control over the placement of the prologue end reordering the IR is the only mechanism available to fix argument values at function entry in the presence of MIR optimizations like SingleUseConsts. Fixes #128945 r? `@michaelwoerister`
2024-09-26Fix the misleading diagnostic for let_underscore_drop on type without Drop ↵makai410-10/+10
implementation
2024-09-25Use `&raw` in the standard libraryJosh Stone-185/+150
Since the stabilization in #127679 has reached stage0, 1.82-beta, we can start using `&raw` freely, and even the soft-deprecated `ptr::addr_of!` and `ptr::addr_of_mut!` can stop allowing the unstable feature. I intentionally did not change any documentation or tests, but the rest of those macro uses are all now using `&raw const` or `&raw mut` in the standard library.
2024-09-25Use `mem::offset_of!` for `sockaddr_un.sun_path`Josh Stone-11/+6
2024-09-25Auto merge of #120752 - compiler-errors:more-relevant-bounds, r=lcnrbors-10/+380
Collect relevant item bounds from trait clauses for nested rigid projections Rust currently considers trait where-clauses that bound the trait's *own* associated types to act like an item bound: ```rust trait Foo where Self::Assoc: Bar { type Assoc; } // acts as if: trait Foo { type Assoc: Bar; } ``` ### Background This behavior has existed since essentially forever (i.e. before Rust 1.0), since we originally started out by literally looking at the where clauses written on the trait when assembling `SelectionCandidate::ProjectionCandidate` for projections. However, looking at the predicates of the associated type themselves was not sound, since it was unclear which predicates were *assumed* and which predicates were *implied*, and therefore this was reworked in #72788 (which added a query for the predicates we consider for `ProjectionCandidate`s), and then finally item bounds and predicates were split in #73905. ### Problem 1: GATs don't uplift bounds correctly All the while, we've still had logic to uplift associated type bounds from a trait's where clauses. However, with the introduction of GATs, this logic was never really generalized correctly for them, since we were using simple equality to test if the self type of a trait where clause is a projection. This leads to shortcomings, such as: ```rust trait Foo where for<'a> Self::Gat<'a>: Debug, { type Gat<'a>; } fn test<T: Foo>(x: T::Gat<'static>) { //~^ ERROR `<T as Foo>::Gat<'a>` doesn't implement `Debug` println!("{:?}", x); } ``` ### Problem 2: Nested associated type bounds are not uplifted We also don't attempt to uplift bounds on nested associated types, something that we couldn't really support until #120584. This can be demonstrated best with an example: ```rust trait A where Self::Assoc: B, where <Self::Assoc as B>::Assoc2: C, { type Assoc; // <~ The compiler *should* treat this like it has an item bound `B<Assoc2: C>`. } trait B { type Assoc2; } trait C {} fn is_c<T: C>() {} fn test<T: A>() { is_c::<<Self::Assoc as B>::Assoc2>(); //~^ ERROR the trait bound `<<T as A>::Assoc as B>::Assoc2: C` is not satisfied } ``` Why does this matter? Well, generalizing this behavior bridges a gap between the associated type bounds (ATB) feature and trait where clauses. Currently, all bounds that can be stably written on associated types can also be expressed as where clauses on traits; however, with the stabilization of ATB, there are now bounds that can't be desugared in the same way. This fixes that. ## How does this PR fix things? First, when scraping item bounds from the trait's where clauses, given a trait predicate, we'll loop of the self type of the predicate as long as it's a projection. If we find a projection whose trait ref matches, we'll uplift the bound. This allows us to uplift, for example `<Self as Trait>::Assoc: Bound` (pre-existing), but also `<<Self as Trait>::Assoc as Iterator>::Item: Bound` (new). If that projection is a GAT, we will check if all of the GAT's *own* args are all unique late-bound vars. We then map the late-bound vars to early-bound vars from the GAT -- this allows us to uplift `for<'a, 'b> Self::Assoc<'a, 'b>: Trait` into an item bound, but we will leave `for<'a> Self::Assoc<'a, 'a>: Trait` and `Self::Assoc<'static, 'static>: Trait` alone. ### Okay, but does this *really* matter? I consider this to be an improvement of the status quo because it makes GATs a bit less magical, and makes rigid projections a bit more expressive.
2024-09-25Pass Module Analysis Manager to Standard InstrumentationsAleksei Romanov-5/+6
2024-09-25Auto merge of #130847 - matthiaskrgr:rollup-f0n80bw, r=matthiaskrgrbors-48/+145
Rollup of 6 pull requests Successful merges: - #130735 (Simple validation for unsize coercion in MIR validation) - #130781 (Fix up setting strip = true in Cargo.toml makes build scripts fail in…) - #130811 (add link from random() helper fn to extensive DefaultRandomSource docs) - #130819 (Add `must_use` attribute to `len_utf8` and `len_utf16`.) - #130832 (fix some cfg logic around optimize_for_size and 16-bit targets) - #130842 (Add tracking issue for io_error_inprogress) r? `@ghost` `@rustbot` modify labels: rollup
2024-09-25Rollup merge of #130842 - Noratrieb:tracking-issue-inprogress, r=jieyouxuMatthias Krüger-1/+1
Add tracking issue for io_error_inprogress I forgot to mention this in #130789
2024-09-25Rollup merge of #130832 - RalfJung:sort-cfg-mess, r=workingjubileeMatthias Krüger-11/+11
fix some cfg logic around optimize_for_size and 16-bit targets Fixes https://github.com/rust-lang/rust/issues/130818. Fixes https://github.com/rust-lang/rust/issues/129910. There are still some warnings when building on a 16bit target: ``` warning: struct `AlignedStorage` is never constructed --> /home/r/src/rust/rustc.2/library/core/src/slice/sort/stable/mod.rs:135:8 | 135 | struct AlignedStorage<T, const N: usize> { | ^^^^^^^^^^^^^^ | = note: `#[warn(dead_code)]` on by default warning: associated items `new` and `as_uninit_slice_mut` are never used --> /home/r/src/rust/rustc.2/library/core/src/slice/sort/stable/mod.rs:141:8 | 140 | impl<T, const N: usize> AlignedStorage<T, N> { | -------------------------------------------- associated items in this implementation 141 | fn new() -> Self { | ^^^ ... 145 | fn as_uninit_slice_mut(&mut self) -> &mut [MaybeUninit<T>] { | ^^^^^^^^^^^^^^^^^^^ warning: function `quicksort` is never used --> /home/r/src/rust/rustc.2/library/core/src/slice/sort/unstable/quicksort.rs:19:15 | 19 | pub(crate) fn quicksort<'a, T, F>( | ^^^^^^^^^ warning: `core` (lib) generated 3 warnings ``` However, the cfg stuff here is sufficiently messy that I didn't want to touch more of it. I think all `feature = "optimize_for_size"` should become `any(feature = "optimize_for_size", target_pointer_width = "16")` but I am not entirely certain. Warnings are fine, Miri will just ignore them. Cc `@Voultapher`
2024-09-25Rollup merge of #130819 - bjoernager:char-must-use-len-utf, r=NoratriebMatthias Krüger-0/+4
Add `must_use` attribute to `len_utf8` and `len_utf16`. The `len_utf8` and `len_utf16` methods in `char` should have the `must_use` attribute. The somewhat similar method `<[T]>::len` has had this attribute since #95274. Considering that these two methods would most likely be used to test the size of a buffer (before a call to `encode_utf8` or `encode_utf16`), *not* using their return values could indicate a bug. According to ["When to add `#[must_use]`](https://std-dev-guide.rust-lang.org/policy/must-use.html), this is **not** considered a breaking change (and could be reverted again at a later time).
2024-09-25Rollup merge of #130811 - RalfJung:random, r=joboetMatthias Krüger-1/+2
add link from random() helper fn to extensive DefaultRandomSource docs
2024-09-25Rollup merge of #130781 - monkeydbobo:mdb/fix_up_cross_compile_osx, r=davidtwcoMatthias Krüger-3/+4
Fix up setting strip = true in Cargo.toml makes build scripts fail in… Fix issue: https://github.com/rust-lang/rust/issues/110536 Strip binary is PATH dependent which breaks builds in MacOS. For example, on my Mac, the output of 'which strip' is '/opt/homebrew/opt/binutils/bin/strip', which leads to incorrect 'strip' results. Therefore, just like on other systems, it is also necessary to specify 'stripcmd' on macOS. However, it seems that there is a bug in binutils [bugzilla-Bug 31571](https://sourceware.org/bugzilla/show_bug.cgi?id=31571), which leads to the problem mentioned above.
2024-09-25Rollup merge of #130735 - compiler-errors:validate-unsize, r=spastorino,RalfJungMatthias Krüger-32/+123
Simple validation for unsize coercion in MIR validation This adds the most basic validity check to unsize coercions in MIR. The src and target of an unsize cast must *at least* implement `Src: CoerceUnsized<Target>` for this to be valid. This doesn't the second, more subtle validity check that is taken of advantage in codegen [here](https://github.com/rust-lang/rust/blob/914193c8f40528fe82696e1054828de8c399882e/compiler/rustc_codegen_ssa/src/base.rs#L126), but I did leave a beefy FIXME for that explaining what it is. As a consequence, this also fixes an ICE with GVN and invalid unsize coercions. This is somewhat coincidental, since MIR inlining will check that a body is valid before inlining it; so now that we determine it to be invalid, we don't inline it, and we don't encounter the GVN ICE. I'm not certain if the same GVN ICE is triggerable without the inliner, and perhaps instead with trivial where clauses or something. cc `@RalfJung`
2024-09-25Utf8Chunks: add link to Utf8ChunkRalf Jung-0/+4
2024-09-25Add a few more tests, commentsMichael Goulet-0/+81
2024-09-25Pull out into helper functionMichael Goulet-99/+112
2024-09-25Collect relevant item bounds from trait clauses for nested rigid ↵Michael Goulet-10/+286
projections, GATs
2024-09-25Add tracking issue for io_error_inprogressnora-1/+1
2024-09-25Add a debug assertion in codegen that unsize casts of the same principal ↵Michael Goulet-18/+38
trait def id are truly NOPs
2024-09-25Validate unsize coercion in MIR validationMichael Goulet-29/+100
2024-09-25Auto merge of #130812 - lnicola:sync-from-ra, r=lnicolabors-22630/+14369
Subtree update of `rust-analyzer` r? `@ghost`
2024-09-25fix some cfg logic around optimize_for_size and 16-bit targetsRalf Jung-11/+11
2024-09-25Auto merge of #130778 - flip1995:clippy-subtree-update, r=Manishearthbors-2606/+7437
Clippy subtree update r? `@Manishearth` Really delayed sync (2 1/2 weeks), because of a `debug_assertion` we hit, and I didn't have the time to investigate earlier. It would be nice to merge this PR with some priority, as it includes a lot of formatting changes due to the rustfmt bump. Include Cargo.lock update due to Clippy version bump and ui_test bump in Clippy.
2024-09-25Fixed diagnostics for coroutines with () as input.Virginia Senioria-37/+61
2024-09-25Auto merge of #130816 - matthiaskrgr:rollup-jy25phv, r=matthiaskrgrbors-175/+420
Rollup of 6 pull requests Successful merges: - #130549 (Add RISC-V vxworks targets) - #130595 (Initial std library support for NuttX) - #130734 (Fix: ices on virtual-function-elimination about principal trait) - #130787 (Ban combination of GCE and new solver) - #130809 (Update llvm triple for OpenHarmony targets) - #130810 (Don't trap into the debugger on panics under Linux) r? `@ghost` `@rustbot` modify labels: rollup
2024-09-25Add 'must_use' attribute to 'char::len_utf8' and 'char::len_utf16';Gabriel Bjørnager Jensen-0/+4
2024-09-25Rollup merge of #130810 - kromych:master, r=workingjubileeMatthias Krüger-78/+1
Don't trap into the debugger on panics under Linux This breaks `rr`, see https://github.com/rust-lang/rust/pull/129019#issuecomment-2369361278 for the discussion CC `@khuey` `@workingjubilee`
2024-09-25Rollup merge of #130809 - heiher:update-triple-ohos, r=jieyouxuMatthias Krüger-8/+4
Update llvm triple for OpenHarmony targets The `ohos` triple has been supported since LLVM 17, so it's time to update them.
2024-09-25Rollup merge of #130787 - compiler-errors:next-solver-gce, r=BoxyUwUMatthias Krüger-11/+63
Ban combination of GCE and new solver These do not work together. I don't want anyone to have the impression that they do. I reused the conflicting features diagnostic but I guess I could make it more tailored to the new solver? OTOH I don't really about the presentation of diagnostics here; these are nightly features after all. r? `@BoxyUwU` thoughts on this?
2024-09-25Rollup merge of #130734 - Luv-Ray:fix_vfe, r=lcnrMatthias Krüger-51/+61
Fix: ices on virtual-function-elimination about principal trait Extract `load_vtable` function to ensure the `virtual_function_elimination` option is always checked. It's okay not to use `llvm.type.checked.load` to load the vtable if there is no principal trait. Fixes #123955 Fixes #124092