about summary refs log tree commit diff
path: root/tests
AgeCommit message (Collapse)AuthorLines
2025-01-16Coerce safe-to-call target_feature functions to fn pointers.Luca Versari-2/+53
2025-01-15Auto merge of #134353 - oli-obk:safe-target-feature-unsafe-by-default, ↵bors-40/+62
r=wesleywiser Treat safe target_feature functions as unsafe by default [less invasive variant] This unblocks * #134090 As I stated in https://github.com/rust-lang/rust/pull/134090#issuecomment-2541332415 I think the previous impl was too easy to get wrong, as by default it treated safe target feature functions as safe and had to add additional checks for when they weren't. Now the logic is inverted. By default they are unsafe and you have to explicitly handle safe target feature functions. This is the less (imo) invasive variant of #134317, as it doesn't require changing the Safety enum, so it only affects FnDefs and nothing else, as it should.
2025-01-15Auto merge of #135525 - jhpratt:rollup-4gu2wpm, r=jhprattbors-125/+190
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-0/+13
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 #132397 - m-ou-se:warn-missing-abi, r=NadrierilJacob Pratt-125/+177
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-13/+0
2025-01-15Try to render shorthand differentlyOli Scherer-6/+3
2025-01-15Render fn defs with target_features attrs with the attribute [second site]Oli Scherer-24/+24
2025-01-15Render fn defs with target_features attrs with the attributeOli Scherer-14/+15
2025-01-15Hide the internal unsafety of safe target_feature fn itemsOli Scherer-1/+1
2025-01-15Treat safe target_feature functions as unsafe by defaultOli Scherer-40/+77
2025-01-15Make sure we actually use the right trivial lifetime substs when eagerly ↵Michael Goulet-0/+13
monomorphizing drop for structs
2025-01-14Rollup merge of #135425 - compiler-errors:not-conditionally-const, r=RalfJungJubilee-18/+16
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-32/+151
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-0/+107
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 #135353 - lolbinarycat:rustdoc-disable-minification, r=notriddleJubilee-1/+2
re-add --disable-minification to rustdoc this also makes the rust.docs-minification option work as advertised in config.toml nothing fancy this time, this is intended to be perma-unstable. it's only really here for the benefit of rustdoc devs. mitegates https://github.com/rust-lang/rust/issues/135345 It was removed in https://github.com/rust-lang/rust/commit/f9e1f6ffdf03ec33cb29e20c88fc7bcc938c7f42.
2025-01-14Rollup merge of #135302 - lolbinarycat:rustdoc-search-return-sort-134935, ↵Jubilee-0/+30
r=notriddle for purely return-type based searches, deprioritize clone-like functions closes https://github.com/rust-lang/rust/issues/134935
2025-01-14Rollup merge of #135264 - compiler-errors:layout-propagate-errors, r=oli-obkJubilee-14/+91
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-2/+118
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-0/+13
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-14Auto merge of #135496 - matthiaskrgr:rollup-ps0cjzn, r=matthiaskrgrbors-9/+146
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-0/+13
assumptions in borrowck
2025-01-14Enforce syntactical stability of const traits in HIRMichael Goulet-32/+151
2025-01-14Consider more erroneous layouts as LayoutError::ReferencesError to suppress ↵Michael Goulet-14/+91
spurious errors
2025-01-14Do not consider traits that have unsatisfied const conditions to be ↵Michael Goulet-18/+16
conditionally const
2025-01-14Normalize field before checking PhantomData in coerce/dispatch impl validationMichael Goulet-0/+25
2025-01-14Make sure we can produce ConstArgHasWrongType errors for valtree constsMichael Goulet-0/+107
2025-01-14Rollup merge of #135493 - compiler-errors:legacy-mangle-closure, r=lqdMatthias Krüger-0/+6
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-8/+8
mir borrowck: cleanup late-bound region handling r? types
2025-01-14Rollup merge of #135466 - compiler-errors:leak-check-impossible, r=lcnrMatthias Krüger-0/+79
Leak check in `impossible_predicates` to avoid monomorphizing impossible instances Fixes #135462 r? lcnr
2025-01-14Rollup merge of #134880 - as1100k-forks:fix-rustdoc-json-path-name, ↵Matthias Krüger-1/+1
r=aDotInTheVoid Made `Path::name` only have item name rather than full name Closes #134853 This PR makes `Path::name` to only have item name rather than full name, i.e. with the following code ```rust pub mod foo { pub struct Bar; } pub fn get_bar() -> foo::Bar { foo::Bar } ``` and running `./rustdoc ./demo.rs -wjson -Zunstable-options` gives: ```json { "41": { "id": 41, "name": "get_bar", "inner": { "function": { "sig": { "inputs": [], "output": { "resolved_path": { "name": "Bar", "id": 0, "args": { "angle_bracketed": { "args": [], "constraints": [] } } } } } } } } } ``` _Information which isn't useful here was trimmed_ r? aDotInTheVoid
2025-01-14Rollup merge of #134216 - GuillaumeGomez:jump-to-def-pats, r=fmeaseMatthias Krüger-0/+52
Enable "jump to def" feature on patterns Part of https://github.com/rust-lang/rust/issues/89095. Pattern (as in "patterns in pattern matching") were not handled by the feature, it's now added. It all started when I realized that prelude values like `Some` or `Err` were not getting a link generated either (added support for it in the first commit). r? ``@fmease``
2025-01-14Auto merge of #135313 - compiler-errors:needs-mono, r=BoxyUwUbors-0/+43
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-0/+6
2025-01-14fix typo and unit testbinarycat-1/+2
2025-01-14Auto merge of #135278 - tgross35:ignore-std-dep-crates, r=SparrowLiibors-0/+120
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-8/+8
2025-01-14add note to testlcnr-1/+1
2025-01-14Mark dependencies of the standard library as private by defaultTrevor Gross-2/+2
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 a UI test for stdlib-private dependenciesTrevor Gross-0/+120
Introduce a test that shows stdlib-private dependencies leaking into diagnostics. This is resolved by a later commit.
2025-01-14Rollup merge of #135464 - lukas-code:project-infinite-to-error, ↵Matthias Krüger-3/+107
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.
2025-01-14Made `Path::name` only have item name rather than full nameAditya Kumar-1/+1
2025-01-14Auto merge of #135465 - jhpratt:rollup-7p93bct, r=jhprattbors-20/+230
Rollup of 10 pull requests Successful merges: - #134498 (Fix cycle error only occurring with -Zdump-mir) - #134977 (Detect `mut arg: &Ty` meant to be `arg: &mut Ty` and provide structured suggestion) - #135390 (Re-added regression test for #122638) - #135393 (uefi: helpers: Introduce OwnedDevicePath) - #135440 (rm unnecessary `OpaqueTypeDecl` wrapper) - #135441 (Make sure to mark `IMPL_TRAIT_REDUNDANT_CAPTURES` as `Allow` in edition 2024) - #135444 (Update books) - #135450 (Fix emscripten-wasm-eh with unwind=abort) - #135452 (bootstrap: fix outdated feature name in comment) - #135454 (llvm: Allow sized-word rather than ymmword in tests) r? `@ghost` `@rustbot` modify labels: rollup
2025-01-14Leak check in impossible_predicates to avoid monomorphizing impossible instancesMichael Goulet-0/+79
2025-01-13Rollup merge of #135454 - maurer:sized-word-ymmword, r=jieyouxuJacob Pratt-2/+2
llvm: Allow sized-word rather than ymmword in tests llvm/llvm-project#122530 changes LLVM to use sized-word rather than ymmword for scatter gather pointers. While this will not always be qword, it is for these two tests. `@rustbot` label: +llvm-main
2025-01-13Rollup merge of #135441 - compiler-errors:redundant-captures-lint, r=lqdJacob Pratt-11/+15
Make sure to mark `IMPL_TRAIT_REDUNDANT_CAPTURES` as `Allow` in edition 2024 I never got sign-off on #127672 for this lint being warn by default in edition 2024, so let's turn downgrade this lint to allow for now. Should be backported so it ships with the edition. ```@rustbot``` label: +beta-nominated
2025-01-13Rollup merge of #135390 - ranger-ross:readd-test-122638, r=BoxyUwUJacob Pratt-0/+78
Re-added regression test for #122638 Re-adds the test for #122638 :smile: fixes #122638 r? `@BoxyUwU` (please let me know if this can be improved. I am still fairly new to using compiletest)
2025-01-13Rollup merge of #134977 - estebank:issue-112357, r=BoxyUwUJacob Pratt-0/+113
Detect `mut arg: &Ty` meant to be `arg: &mut Ty` and provide structured suggestion When a newcomer attempts to use an "out parameter" using borrows, they sometimes get confused and instead of mutating the borrow they try to mutate the function-local binding instead. This leads to either type errors (due to assigning an owned value to a mutable binding of reference type) or a multitude of lifetime errors and unused binding warnings. This change adds a suggestion to the type error ``` error[E0308]: mismatched types --> $DIR/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.rs:6:14 | LL | fn change_object(mut object: &Object) { | ------- expected due to this parameter type LL | let object2 = Object; LL | object = object2; | ^^^^^^^ expected `&Object`, found `Object` | help: you might have meant to mutate the pointed at value being passed in, instead of changing the reference in the local binding | LL ~ fn change_object(object: &mut Object) { LL | let object2 = Object; LL ~ *object = object2; | ``` and to the unused assignment lint ``` error: value assigned to `object` is never read --> $DIR/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.rs:11:5 | LL | object = &object2; | ^^^^^^ | note: the lint level is defined here --> $DIR/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.rs:1:9 | LL | #![deny(unused_assignments, unused_variables)] | ^^^^^^^^^^^^^^^^^^ help: you might have meant to mutate the pointed at value being passed in, instead of changing the reference in the local binding | LL ~ fn change_object2(object: &mut Object) { LL | let object2 = Object; LL ~ *object = object2; | ``` Fix #112357.
2025-01-13Rollup merge of #134498 - oli-obk:push-wmxynprsyxvr, r=compiler-errorsJacob Pratt-7/+22
Fix cycle error only occurring with -Zdump-mir fixes #134205 During mir dumping, we evaluate static items to render their allocations. If a static item refers to itself, its own MIR will have a reference to itself, so during mir dumping we end up evaluating the static again, causing us to try to build MIR again (mir dumping happens during MIR building). Thus I disabled evaluation of statics during MIR dumps in case the MIR body isn't far enough along yet to be able to be guaranteed cycle free.
2025-01-14Auto merge of #135438 - matthiaskrgr:rollup-rt2zrbz, r=matthiaskrgrbors-2/+3
Rollup of 4 pull requests Successful merges: - #133752 (replace copypasted ModuleLlvm::parse) - #135245 (rustc_feature: Avoid unsafe `std::env::set_var()` in `UnstableFeatures` tests) - #135405 (path: Move is_absolute check to sys::path) - #135426 (Assert that `Instance::try_resolve` is only used on body-like things) r? `@ghost` `@rustbot` modify labels: rollup try-job: x86_64-mingw-1