about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2025-01-15Auto merge of #135525 - jhpratt:rollup-4gu2wpm, r=jhprattbors-87/+102
Rollup of 7 pull requests Successful merges: - #132397 (Make missing_abi lint warn-by-default.) - #133807 (ci: Enable opt-dist for dist-aarch64-linux builds) - #134143 (Convert `struct FromBytesWithNulError` into enum) - #134338 (Use a C-safe return type for `__rust_[ui]128_*` overflowing intrinsics) - #134678 (Update `ReadDir::next` in `std::sys::pal::unix::fs` to use `&raw const (*p).field` instead of `p.byte_offset().cast()`) - #135424 (Detect unstable lint docs that dont enable their feature) - #135520 (Make sure we actually use the right trivial lifetime substs when eagerly monomorphizing drop for ADTs) r? `@ghost` `@rustbot` modify labels: rollup
2025-01-15Rollup merge of #135520 - ↵Jacob Pratt-5/+19
compiler-errors:mono-impossible-drop-with-lifetimes, r=BoxyUwU Make sure we actually use the right trivial lifetime substs when eagerly monomorphizing drop for ADTs Absolutely clueless mistake of mine. Whoops. When eagerly collecting mono items, when we encounter an ADT, we try to monomorphize its drop glue. In #135313, I made it so that this acts more like eagerly monomorphizing functions, where we allow (in this case) ADTs with lifetimes, since those can be erased by codegen. However, I did not account for the call to `instantiate_and_check_impossible_predicates`, which was still passing an empty set of args. This means that if the ADT in question had any predicates, we'd get an index out of bounds panic. This PR creates the correct set of args for the ADT. Fixes #135515. I assume that this manifests in that issue because of `-Clink-dead-code` or something.
2025-01-15Rollup merge of #134338 - tgross35:overflowing-c-safe-ret, r=bjorn3,antoyoJacob Pratt-76/+77
Use a C-safe return type for `__rust_[ui]128_*` overflowing intrinsics Combined with [1], this will change the overflowing multiplication operations to return an `extern "C"`-safe type. Link: https://github.com/rust-lang/compiler-builtins/pull/735 [1]
2025-01-15Rollup merge of #132397 - m-ou-se:warn-missing-abi, r=NadrierilJacob Pratt-6/+6
Make missing_abi lint warn-by-default. This makes the missing_abi lint warn-by-default, as suggested here: https://github.com/rust-lang/rfcs/pull/3722#issuecomment-2447719047 This needs a lang FCP.
2025-01-15Avoid notes that only make sense for unsafe functionsOli Scherer-4/+9
2025-01-15Try to render shorthand differentlyOli Scherer-3/+9
2025-01-15Render fn defs with target_features attrs with the attribute [second site]Oli Scherer-20/+40
2025-01-15Render fn defs with target_features attrs with the attributeOli Scherer-1/+8
2025-01-15Hide the internal unsafety of safe target_feature fn itemsOli Scherer-2/+14
2025-01-15Treat safe target_feature functions as unsafe by defaultOli Scherer-14/+68
2025-01-15avoid running the overlap check twicelcnr-22/+33
2025-01-15allowed_through_unstable_modules: support showing a deprecation message when ↵Ralf Jung-51/+125
the unstable module name is used
2025-01-15late_report_deprecation: move fast-path closer to the core logicRalf Jung-9/+12
2025-01-15Make sure we actually use the right trivial lifetime substs when eagerly ↵Michael Goulet-5/+19
monomorphizing drop for structs
2025-01-15Update compiler-builtins to 0.1.143Trevor Gross-2/+2
0.1.142 fixes an issue parsing optimization flags, and 0.1.143 changes `__rust_[ui]128_*` builtins to use a C-safe signature.
2025-01-14Rollup merge of #135425 - compiler-errors:not-conditionally-const, r=RalfJungJubilee-8/+18
Do not consider traits that have unsatisfied const conditions to be conditionally const This will improve error messages as we continue to constify traits, since we don't want to start calling things "conditionally const" if they aren't implemented with a const impl anyways. The only case that this affects today is `Deref` since that's one of the only constified traits in the standard library :) r? RalfJung
2025-01-14Rollup merge of #135423 - compiler-errors:enforce-const-trait-syntactical, ↵Jubilee-5/+121
r=oli-obk,RalfJung Enforce syntactical stability of const traits in HIR This PR enforces what I'm calling *syntactical* const stability of traits. In other words, it enforces the ability to name `~const`/`const` traits in trait bounds in various syntax positions in HIR (including in the trait of an impl header). This functionality is analogous to the *regular* item stability checker, which is concerned with making sure that you cannot refer to unstable items by name, and is implemented as an extension of that pass. This is separate from enforcing the *recursive* const stability of const trait methods, which is implemented in MIR and runs on MIR bodies. That will require adding a new `NonConstOp` to the const checker and probably adjusting some logic to deduplicate redundant errors. However, this check is separate and necessary for making sure that users don't add `~const`/`const` bounds to items when the trait is not const-stable in the first place. I chose to separate enforcing recursive const stability out of this PR to make it easier to review. I'll probably open a follow-up following this one, blocked on this PR. r? `@RalfJung` cc `@rust-lang/project-const-traits`
2025-01-14Rollup merge of #135380 - compiler-errors:mismatch-valtree, r=lcnrJubilee-2/+3
Make sure we can produce `ConstArgHasWrongType` errors for valtree consts I forgot about `ty::ConstKind::Value` in #134771. The error message here could use some work -- both in the new trait solver and the old trait solver. But unrelated to the issue here. Fixes https://github.com/rust-lang/rust/issues/135361 -- this was only ICEing in coherence because coherence uses the new trait solver, but I don't think the minimization is worth committing compared to the test I added. r? ```@lcnr``` or ```@BoxyUwU```
2025-01-14Rollup merge of #135264 - compiler-errors:layout-propagate-errors, r=oli-obkJubilee-12/+20
Consider more erroneous layouts as `LayoutError::ReferencesError` to suppress spurious errors Fixes #135208 r? oli-obk
2025-01-14Rollup merge of #135228 - compiler-errors:normalizes-ur-dispatch, r=BoxyUwUJubilee-9/+35
Improve `DispatchFromDyn` and `CoerceUnsized` impl validation * Disallow arbitrary 1-ZST fields in `DispatchFromDyn` -- only `PhantomData`, and 1-ZSTs that mention no params (which is needed to support, e.g., the `Global` alloctor in `Box<T, U = Global>`). * Don't allow coercing between non-ZSTs to ZSTs (since the previous check wasn't actually checking the field tys were the same before checking the layout...) * Normalize the field before checking it's `PhantomData`. Fixes #135215 Fixes #135214 Fixes #135220 r? ```@BoxyUwU``` or reassign
2025-01-14Rollup merge of #134940 - compiler-errors:scrape, r=lcnrJubilee-19/+48
Make sure to scrape region constraints from deeply normalizing type outlives assumptions in borrowck Otherwise we're just randomly registering these region relations into the infcx which isn't good r? lcnr
2025-01-15Use a C-safe return type for `__rust_[ui]128_*` overflowing intrinsicsTrevor Gross-74/+75
Combined with [1], this will change the overflowing multiplication operations to return an `extern "C"`-safe type. Link: https://github.com/rust-lang/compiler-builtins/pull/735 [1]
2025-01-15Rework trait expansion to happen once explicitlyMichael Goulet-291/+199
2025-01-14Auto merge of #135180 - tgross35:update-builtins, r=tgross35bors-2/+2
Update compiler-builtins to 0.1.141 0.1.141 syncs changes from `libm`. Most of the `libm` changes are testing- or configuration-related.
2025-01-14Auto merge of #135496 - matthiaskrgr:rollup-ps0cjzn, r=matthiaskrgrbors-47/+42
Rollup of 7 pull requests Successful merges: - #134216 (Enable "jump to def" feature on patterns) - #134880 (Made `Path::name` only have item name rather than full name) - #135466 (Leak check in `impossible_predicates` to avoid monomorphizing impossible instances) - #135476 (Remove remnant of asmjs) - #135479 (mir borrowck: cleanup late-bound region handling) - #135493 (Fix legacy symbol mangling of closures) - #135495 (Add missing closing backtick in commit hook message 🐸) r? `@ghost` `@rustbot` modify labels: rollup
2025-01-14Make sure to scrape region constraints from deeply normalizing type outlives ↵Michael Goulet-19/+48
assumptions in borrowck
2025-01-14Enforce syntactical stability of const traits in HIRMichael Goulet-5/+121
2025-01-14Consider more erroneous layouts as LayoutError::ReferencesError to suppress ↵Michael Goulet-12/+20
spurious errors
2025-01-14Do not consider traits that have unsatisfied const conditions to be ↵Michael Goulet-8/+18
conditionally const
2025-01-14Normalize field before checking PhantomData in coerce/dispatch impl validationMichael Goulet-3/+20
2025-01-14Make sure we can produce ConstArgHasWrongType errors for valtree constsMichael Goulet-2/+3
2025-01-14Update compiler-builtins to 0.1.141Trevor Gross-2/+2
0.1.141 syncs changes from `libm`. Most of the `libm` changes are testing- or configuration-related.
2025-01-14Rollup merge of #135493 - compiler-errors:legacy-mangle-closure, r=lqdMatthias Krüger-4/+4
Fix legacy symbol mangling of closures When this code was written, there was no `type_of` implementation for closures. That has long since been changed. In the UI test: ``` trait A where [(); (|| {}, 1).1]: Sized, { } ``` We tried to walk up the def path tree for the closure, from closure -> anon const -> trait. When we reached the trait, we tried to call `type_of` on it which obviously doesn't do the right thing and ICEs. Fixes #135418
2025-01-14Rollup merge of #135479 - lcnr:method-calls-on-opaques, r=compiler-errorsMatthias Krüger-40/+26
mir borrowck: cleanup late-bound region handling r? types
2025-01-14Rollup merge of #135466 - compiler-errors:leak-check-impossible, r=lcnrMatthias Krüger-3/+12
Leak check in `impossible_predicates` to avoid monomorphizing impossible instances Fixes #135462 r? lcnr
2025-01-14Prefer lower TraitUpcasting candidatesMichael Goulet-6/+25
2025-01-14Auto merge of #135313 - compiler-errors:needs-mono, r=BoxyUwUbors-2/+5
Eagerly mono drop for structs with lifetimes That is, use `!generics.requires_monomorphization()` rather than `generics.is_empty()` like the rest of the mono collector code.
2025-01-14Fix legacy symbol mangling of closuresMichael Goulet-4/+4
2025-01-14remove Rustc{En,De}codable from library and compilerRalf Jung-527/+10
2025-01-14Auto merge of #135278 - tgross35:ignore-std-dep-crates, r=SparrowLiibors-44/+105
Exclude dependencies of `std` for diagnostics Currently crates in the sysroot can show up in diagnostic suggestions, such as in https://github.com/rust-lang/rust/issues/135232. To prevent this, duplicate `all_traits` into `visible_traits` which only shows traits in non-private crates. Setting `#![feature(rustc_private)]` overrides this and makes items in private crates visible as well, since `rustc_private` enables use of `std`'s private dependencies. This may be reviewed per-commit. Fixes: https://github.com/rust-lang/rust/issues/135232
2025-01-14mir borrowck: cleanup late-bound region handlinglcnr-40/+26
2025-01-14Add `DenseBitSet::union_not`Zalathar-0/+56
This is similar to the existing `union`, except that bits in the RHS are negated before being incorporated into the LHS. Currently only `DenseBitSet` is supported. Supporting other bitset types is possible, but non-trivial, and currently isn't needed.
2025-01-14Add wrapper type `ReversedGraph` for swapping successors/predecessorsZalathar-0/+43
2025-01-14Auto merge of #135442 - antoyo:subtree-update_cg_gcc_2025_01_12, ↵bors-1529/+835
r=GuillaumeGomez Subtree update cg_gcc 2025/01/12 r? GuillaumeGomez
2025-01-14Add hir::HeaderSafety to make follow up commits simplerOli Scherer-25/+78
2025-01-14Mark dependencies of the standard library as private by defaultTrevor Gross-19/+47
In order to avoid diagnostics suggesting stdlib-private dependencies, make everything that is a direct dependency of any `std` crates private by default. Note that this will be overridden, if the same crate is public elsewhere in the crate graph then that overrides the private default. It may also be feasible to do this in the library crate, marking `std`'s dependencies private via Cargo. However, given that the feature is still rather unstable, doing this within the compiler seems more straightforward. Fixes: https://github.com/rust-lang/rust/issues/135232 [1]
2025-01-14Add `tcx.visible_traits()` and use it for producing diagnosticsTrevor Gross-4/+23
Add an alternative to `tcx.all_traits()` that only shows traits that the user might be able to use, for diagnostic purposes. With this available, make use of it for diagnostics including associated type errors, which is part of the problem with [1]. Includes a few comment updates for related API. [1]: https://github.com/rust-lang/rust/issues/135232
2025-01-14Make `#[rustc_private]` override dependency visibilityTrevor Gross-0/+5
Really this is always-visible override only needs to happen when the crate is a dependency of itself. However, this is a very internal feature, so it doesn't seem worth doing any additional filtering here.
2025-01-14rustc_metadata: Rename `root` to `dep_root`Trevor Gross-26/+35
Currently `root` or `crate_root` is used to refer to an instance of `CrateRoot` (representation of a crate's serialized metadata), but the name `root` sometimes also refers to a `CratePath` representing a "root" node in the dependency graph. In order to disambiguate, rename all instances of the latter to `dep_root`.
2025-01-14Rollup merge of #135464 - lukas-code:project-infinite-to-error, ↵Matthias Krüger-3/+4
r=FedericoBruzzone,oli-obk fix ICE with references to infinite structs in consts fixes https://github.com/rust-lang/rust/issues/114484 Normalizing `<Type as Pointee>::Metadata` may emit a (non-fatal) error during trait selection if finding the struct tail of `Type` hits the recursion limit. When this happens, prior this PR, we would treat the projection as rigid, i.e. don't normalize it further. This PR changes it so that we normalize to `ty::Error` instead. This is important, because to compute the layout of `&Type` we need to compute the layout of `<Type as Pointee>::Metadata` https://github.com/rust-lang/rust/blob/2ae9916816a448fcaab3b2da461de754eda0055a/compiler/rustc_ty_utils/src/layout.rs#L247-L273 and computing the layout of a rigid alias will (correctly) fail and needs to report an error to the user. For example: ```rust trait Project { type Assoc; } fn foo<T: Project>() { [(); { let _: Option<T::Assoc> = None; // ^^^^^^^^ this projection is rigid, so we can't know it's layout 0 }]; } ``` ``` error: constant expression depends on a generic parameter --> src/lib.rs:6:10 | 6 | [(); { | __________^ 7 | | let _: Option<T::Assoc> = None; 8 | | // ^^^^^^^^ this projection is rigid, so we can't know it's layout 9 | | 0 10 | | }]; | |_____^ | = note: this may fail depending on what value the parameter takes ``` For non-generic rigid projections we will currently ICE, because we incorrectly assume that `LayoutError::Unknown` means that a const must be generic (https://github.com/rust-lang/rust/issues/135138). This is being fixed and turned into a proper error in https://github.com/rust-lang/rust/pull/135158. ```rust #![feature(trivial_bounds)] trait Project { type Assoc; } fn foo() where u8: Project, { [(); { let _: Option<<u8 as Project>::Assoc> = None; // ICEs currently, but will be an error 0 }]; } ``` However, if we hit the recursion limit when normalizing `<Type as Pointee>::Metadata` we don't want to report a layout error, because we already emitted the recursion error. So by normalizing to `ty::Error` here, we get a `LayoutError::ReferencesError` instead of a `LayoutError::Unknown` and don't report the layout error to the user.