about summary refs log tree commit diff
path: root/tests/ui/layout
AgeCommit message (Collapse)AuthorLines
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
2024-04-06add test for ICE: !base.layout().is_sized() #123078Matthias Krüger-0/+48
Fixes https://github.com/rust-lang/rust/issues/123078
2024-04-04Error out of layout calculation if a non-last struct field is unsizedGurinder Singh-0/+185
Fixes an ICE that occurs when a struct with an unsized field at a non-last position is const evaluated.
2024-03-25add test for ICE: failed to get layout for [type error] #92979Matthias Krüger-0/+94
Fixes https://github.com/rust-lang/rust/issues/92979
2024-03-25add test for Compiler panic using fn_traits #81974Matthias Krüger-0/+137
Fixes https://github.com/rust-lang/rust/issues/81974
2024-03-13Auto merge of #121668 - erikdesjardins:commonprim, r=scottmcm,oli-obkbors-1/+51
Represent `Result<usize, Box<T>>` as ScalarPair(i64, ptr) This allows types like `Result<usize, std::io::Error>` (and integers of differing sign, e.g. `Result<u64, i64>`) to be passed in a pair of registers instead of through memory, like `Result<u64, u64>` or `Result<Box<T>, Box<U>>` are today. Fixes #97540. r? `@ghost`
2024-03-06Check that return type is WF in typeckGurinder Singh-1/+12
Without it non-WF types could pass typeck and then later fail in MIR/const eval
2024-02-28fix test failure due to differing u64 alignment on different targetsErik Desjardins-3/+3
2024-02-27allow using scalarpair with a common prim of ptr/ptr-sized-intErik Desjardins-1/+51
2024-02-25Use generic `NonZero` in tests.Markus Reiter-20/+23
2024-02-16[AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives许杰友 Jieyou Xu (Joe)-29/+29
2024-02-14Continue compilation after check_mod_type_wf errorsOli Scherer-4/+13
2024-01-27Update tests.Markus Reiter-1/+1
2024-01-19Remove feature(offset_of) from testsGeorge Bateman-1/+0