rust/tests
Matthias Krüger 4cadb5d513
Rollup merge of #135464 - lukas-code:project-infinite-to-error, 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`

2ae9916816/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-14 07:56:24 +01:00
..
assembly llvm: Allow sized-word rather than ymmword in tests 2025-01-13 20:50:57 +00:00
auxiliary tests/assembly/asm: Remove uses of rustc_attrs and lang_items features by using minicore 2024-12-18 02:59:07 +09:00
codegen Auto merge of #135204 - RalfJung:win64-zst, r=SparrowLii 2025-01-13 13:05:53 +00:00
codegen-units Eagerly collect mono items for non-generic closures 2025-01-10 01:27:13 +00:00
coverage add comment to test 2025-01-09 13:55:50 +01:00
coverage-run-rustdoc coverage: Restrict empty-span expansion to only cover { and } 2024-11-08 20:43:08 +11:00
crashes fix ICE with references to infinite structs in consts 2025-01-14 01:22:04 +01:00
debuginfo Auto merge of #135192 - jdupak-ms:cdb-tests, r=wesleywiser 2025-01-13 18:13:53 +00:00
incremental Add more info on type/trait mismatches for different crate versions 2024-12-07 18:18:08 +00:00
mir-opt Rollup merge of #134498 - oli-obk:push-wmxynprsyxvr, r=compiler-errors 2025-01-13 20:43:44 -05:00
pretty Update tests to use new proc-macro header 2024-11-27 07:18:25 -08:00
run-make Replace the random substring of a linker argument with a placeholder and nullify the timestamp field of XCOFF files for file comparison. 2025-01-06 16:59:46 -05:00
rustdoc rustdoc: use import stability marker in display 2025-01-11 15:04:48 -07:00
rustdoc-gui Add GUI test for item info elements color 2024-12-28 20:54:00 +01:00
rustdoc-js Rollup merge of #134277 - notriddle:notriddle/inline-into, r=GuillaumeGomez 2024-12-16 20:00:20 +01:00
rustdoc-js-std rustdoc: treat allowed_through_unstable_modules as deprecation 2025-01-02 12:03:24 -07:00
rustdoc-json rustdoc-json: Include items in stripped modules in Crate::paths. 2025-01-10 23:51:45 +00:00
rustdoc-ui Remove some empty expected files to fix blessing 2025-01-12 12:49:24 +02:00
ui Rollup merge of #135464 - lukas-code:project-infinite-to-error, r=FedericoBruzzone,oli-obk 2025-01-14 07:56:24 +01:00
ui-fulldeps Rollup merge of #134834 - dtolnay:unnamedcall, r=compiler-errors 2024-12-27 18:43:05 -08:00
COMPILER_TESTS.md