about summary refs log tree commit diff
path: root/tests/ui/layout
AgeCommit message (Collapse)AuthorLines
2025-01-27Add `TooGeneric` variant to `LayoutError` and emit `Unknown` oneFedericoBruzzone-8/+127
- `check-pass` test for a MRE of #135020 - fail test for #135138 - switch to `TooGeneric` for checking CMSE fn signatures - switch to `TooGeneric` for compute `SizeSkeleton` (for transmute) - fix broken tests
2025-01-23Rollup merge of #135552 - ↵Matthias Krüger-0/+264
amy-kwan:amy-kwan/reprc-struct-diagnostic-power-alignment, r=workingjubilee [AIX] Lint on structs that have a different alignment in AIX's C ABI This PR adds a linting diagnostic on AIX for repr(C) structs that are required to follow the power alignment rule. A repr(C) struct needs to follow the power alignment rule if the struct: - Has a floating-point data type (greater than 4-bytes) as its first member, or - The first member of the struct is an aggregate, whose recursively first member is a floating-point data type (greater than 4-bytes). The power alignment rule for eligible structs is currently unimplemented, so a linting diagnostic is produced when such a struct is encountered.
2025-01-22[AIX] Lint on structs that have a different alignment in AIX's C ABIAmy Kwan-0/+264
2025-01-16Properly note when query stack is being cut offMichael Goulet-1/+1
2025-01-14Consider more erroneous layouts as LayoutError::ReferencesError to suppress ↵Michael Goulet-14/+3
spurious errors
2025-01-10test that coercions still work under randomizationThe 8472-8/+40
2025-01-10exclude unsizable tail from randomization seed calculationThe 8472-3/+4
2025-01-10adjust UI testsThe 8472-40/+120
2025-01-10Foo<T> != Foo<U> under layout randomizationThe 8472-0/+29
previously field ordering was using the same seed for all instances of Foo, now we pass seed values through the layout tree so that not only the struct itself affects layout but also its fields
2025-01-01Try to write the panic message with a single `write_all` callJohn Kåre Alsaker-0/+1
2024-12-27Remove the `-test` suffix from normalize directivesZalathar-12/+12
2024-12-13Stabilize async closuresMichael Goulet-4/+2
2024-12-10Rollup merge of #134010 - RalfJung:promoted-type-error-ice, r=oli-obkLeón Orell Valerian Liehr-6/+0
fix ICE on type error in promoted Fixes https://github.com/rust-lang/rust/issues/133968 Ensure that when we turn a type error into a "this promoted failed to evaluate" error, we do record this as something that may happen even in "infallible" promoteds.
2024-12-09fix ICE on type error in promotedRalf Jung-6/+0
2024-12-07Mention type parameter in more cases and don't suggest ~const bound already ↵Esteban Küber-5/+5
there
2024-12-07Use trait name instead of full constraint in suggestion messageEsteban Küber-5/+5
``` help: consider restricting type parameter `T` with traits `Copy` and `Trait` | LL | fn duplicate_custom<T: Copy + Trait>(t: S<T>) -> (S<T>, S<T>) { | ++++++++++++++ ``` ``` help: consider restricting type parameter `V` with trait `Copy` | LL | fn index<'a, K, V: std::marker::Copy>(map: &'a HashMap<K, V>, k: K) -> &'a V { | +++++++++++++++++++ ```
2024-12-07reword trait bound suggestion message to include the boundsEsteban Küber-5/+5
2024-12-07Don't suggest restricting bound with unstable traits on stableEsteban Küber-5/+5
On nightly, we mention the trait is unstable ``` error[E0277]: the trait bound `T: Unstable` is not satisfied --> $DIR/unstable-trait-suggestion.rs:13:9 | LL | foo(t) | --- ^ the trait `Unstable` is not implemented for `T` | | | required by a bound introduced by this call | note: required by a bound in `foo` --> $DIR/unstable-trait-suggestion.rs:9:11 | LL | fn foo<T: Unstable>(_: T) {} | ^^^^^^^^ required by this bound in `foo` help: consider restricting type parameter `T` but it is an `unstable` trait | LL | pub fn demo<T: Unstable>(t: T) { | ++++++++++ ``` On stable, we don't suggest the trait at all ``` error[E0277]: the trait bound `T: Unstable` is not satisfied --> $DIR/unstable-trait-suggestion.rs:13:9 | LL | foo(t) | --- ^ the trait `Unstable` is not implemented for `T` | | | required by a bound introduced by this call | note: required by a bound in `foo` --> $DIR/unstable-trait-suggestion.rs:9:11 | LL | fn foo<T: Unstable>(_: T) {} | ^^^^^^^^ required by this bound in `foo` ```
2024-12-05Stabilize noop_wakerEric Holk-1/+1
Co-authored-by: zachs18 <8355914+zachs18@users.noreply.github.com>
2024-12-01fix ICE when promoted has layout size overflowRalf Jung-0/+6
2024-11-23Rollup merge of #133355 - chorman0773:spec-layout-tests, r=jieyouxu许杰友 Jieyou Xu (Joe)-0/+265
Add language tests for aggregate types This adds some tests for struct and union types, ensuring that they satisfy the rules for all structs and unions - namely that fields of structs do not overlap, fields are well-aligned, and the size of the entire. The reference annotations used are from https://github.com/rust-lang/reference/pull/1654, though the rules tested here were FCPed in <https://github.com/rust-lang/reference/pull/1152>.
2024-11-22Remove `#[cfg(test)]` related stubsConnor Horman-57/+10
2024-11-22Add language tests for aggregate typesConnor Horman-0/+312
2024-11-21Stop being so bail-y in candidate assemblyMichael Goulet-3/+16
2024-11-10Auto merge of #132173 - veluca93:abi_checks, r=RalfJung,compiler-errorsbors-12/+10
Emit warning when calling/declaring functions with unavailable vectors. On some architectures, vector types may have a different ABI depending on whether the relevant target features are enabled. (The ABI when the feature is disabled is often not specified, but LLVM implements some de-facto ABI.) As discussed in rust-lang/lang-team#235, this turns out to very easily lead to unsound code. This commit makes it a post-monomorphization future-incompat warning to declare or call functions using those vector types in a context in which the corresponding target features are disabled, if using an ABI for which the difference is relevant. This ensures that these functions are always called with a consistent ABI. See the [nomination comment](https://github.com/rust-lang/rust/pull/127731#issuecomment-2288558187) for more discussion. Part of #116558 r? RalfJung
2024-11-04Rollup merge of #132583 - mejrs:tuples, r=compiler-errorsMatthias Krüger-0/+4
Suggest creating unary tuples when types don't match a trait When you want to have a variadic function, a common workaround to implement this is to create a trait and then implement that trait for various tuples. For example in `pyo3` there exists ```rust /// Calls the object with only positional arguments. pub fn call1(&self, args: impl IntoPy<Py<PyTuple>>) -> PyResult<&PyAny> { ... } ``` with various impls like ```rust impl<A: IntoPy<PyObject> IntoPy<Py<PyAny>> for (A,) impl<A: IntoPy<PyObject, B: IntoPy<PyObject> IntoPy<Py<PyAny>> for (A, B) ... etc ``` This means that if you want to call the method with a single item you have to create a unary tuple, like `(x,)`, rather than just `x`. This PR implements a suggestion to do that, if applicable.
2024-11-04Suggest creating unary tuplesmejrs-0/+4
2024-11-03use backticks instead of single quotes when reporting "use of unstable ↵dianne-6/+6
library feature" This is consistent with all other diagnostics I could find containing features and enables the use of `DiagSymbolList` for generalizing diagnostics for unstable library features to multiple features.
2024-11-01Emit warning when calling/declaring functions with unavailable vectors.Luca Versari-12/+10
On some architectures, vector types may have a different ABI depending on whether the relevant target features are enabled. (The ABI when the feature is disabled is often not specified, but LLVM implements some de-facto ABI.) As discussed in rust-lang/lang-team#235, this turns out to very easily lead to unsound code. This commit makes it a post-monomorphization future-incompat warning to declare or call functions using those vector types in a context in which the corresponding target features are disabled, if using an ABI for which the difference is relevant. This ensures that these functions are always called with a consistent ABI. See the [nomination comment](https://github.com/rust-lang/rust/pull/127731#issuecomment-2288558187) for more discussion. Part of #116558
2024-10-30tests: Bless `rustc_abi::Abi::Aggregate` => `::Memory`Jubilee Young-47/+47
2024-10-25Revert "Emit error when calling/declaring functions with unavailable vectors."Rémy Rakic-10/+12
This reverts commit 5af56cac38fa48e4228e5e123d060e85eb1acbf7.
2024-10-25Auto merge of #127731 - veluca93:abi_checks, r=RalfJungbors-12/+10
Emit future-incompatibility lint when calling/declaring functions with vectors that require missing target feature On some architectures, vector types may have a different ABI depending on whether the relevant target features are enabled. (The ABI when the feature is disabled is often not specified, but LLVM implements some de-facto ABI.) As discussed in https://github.com/rust-lang/lang-team/issues/235, this turns out to very easily lead to unsound code. This commit makes it a post-monomorphization error to declare or call functions using those vector types in a context in which the corresponding target features are disabled, if using an ABI for which the difference is relevant. This ensures that these functions are always called with a consistent ABI. See the [nomination comment](https://github.com/rust-lang/rust/pull/127731#issuecomment-2288558187) for more discussion. r? RalfJung Part of https://github.com/rust-lang/rust/issues/116558
2024-10-25Emit error when calling/declaring functions with unavailable vectors.Luca Versari-12/+10
On some architectures, vector types may have a different ABI when relevant target features are enabled. As discussed in https://github.com/rust-lang/lang-team/issues/235, this turns out to very easily lead to unsound code. This commit makes it an error to declare or call functions using those vector types in a context in which the corresponding target features are disabled, if using an ABI for which the difference is relevant.
2024-10-20compiler: Reject impossible reprs during enum layoutJubilee Young-4/+107
2024-10-20compiler: pre-move code for fixing enum layout ICEsJubilee Young-0/+47
2024-10-08Dont ICE when encountering post-mono layout cycle errorMichael Goulet-0/+123
2024-09-20TL note: current means targetJubilee Young-4/+4
2024-09-17get rid of an old hackLukas Markeffsky-0/+65
For structs that cannot be unsized, the layout algorithm sometimes moves unsized fields to the end of the struct, which circumvented the error for unexpected unsized fields and returned an unsized layout anyway. This commit makes it so that the unexpected unsized error is always returned for structs that cannot be unsized, allowing us to remove an old hack and fixing some old ICE.
2024-09-16layout computation: eagerly error for unexpected unsized fieldsLukas Markeffsky-1/+141
2024-09-09Ban non-array SIMDScott McMurray-1/+1
2024-07-24Rollup merge of #126152 - RalfJung:size_of_val_raw, r=saethlinMatthias Krüger-0/+22
size_of_val_raw: for length 0 this is safe to call For motivation, see https://github.com/rust-lang/unsafe-code-guidelines/issues/465, specifically around [here](https://github.com/rust-lang/unsafe-code-guidelines/issues/465#issuecomment-2136401114). Cc `@rust-lang/opsem`
2024-07-11Always use a colon in `//@ normalize-*:` headersZalathar-11/+11
2024-07-10size_of_val_raw: for length 0 this is safe to callRalf Jung-0/+22
2024-06-25Auto merge of #125740 - RalfJung:transmute-size-check, r=oli-obkbors-1/+1
transmute size check: properly account for alignment Fixes another place where ZST alignment was ignored when checking whether something is a newtype. I wonder how many more of these there are... Fixes https://github.com/rust-lang/rust/issues/101084
2024-05-30transmute size check: properly account for alignmentRalf Jung-1/+1
2024-05-28Allow type_of to return partially non-error types if the type was already ↵Oli Scherer-4/+35
tainted
2024-04-23Rollup merge of #124057 - gurry:124031-ice-layout-errored, r=compiler-errorsMatthias Krüger-0/+32
Fix ICE when ADT tail has type error Fixes #124031
2024-04-22Stabilize generic `NonZero`.Markus Reiter-6/+4
2024-04-22Fix ICE when ADT tail has type errorGurinder Singh-0/+32
2024-04-06add test for ICE: Unexpected unsized type tail: &ReStatic [u8] #122488Matthias Krüger-0/+37
Fixes https://github.com/rust-lang/rust/issues/122488