about summary refs log tree commit diff
path: root/tests/ui/cast
AgeCommit message (Collapse)AuthorLines
2025-08-29Rollup merge of #145676 - Oneirical:uncountable-integer-9, r=jieyouxuMatthias Krüger-0/+15
Rehome 30 `tests/ui/issues/` tests to other subdirectories under `tests/ui/` [#2 of Batch #2] Part of rust-lang/rust#133895 Methodology: 1. Refer to the previously written `tests/ui/SUMMARY.md` 2. Find an appropriate category for the test, using the original issue thread and the test contents. 3. Add the issue URL at the bottom (not at the top, as that would mess up stderr line numbers) 4. Rename the tests to make their purpose clearer Inspired by the methodology that `@Kivooeo` was using. r? `@jieyouxu`
2025-08-27Add test batch 2Oneirical-0/+15
2025-08-27Add test batch 1Oneirical-0/+20
2025-08-19bless tests with new lint messagesKarol Zwolak-3/+3
2025-08-10Rollup merge of #144553 - Oneirical:uncountable-integer-4, r=jieyouxuJacob Pratt-0/+6
Rehome 32 `tests/ui/issues/` tests to other subdirectories under `tests/ui/` rust-lang/rust#143902 divided into smaller, easier to review chunks. Part of rust-lang/rust#133895 Methodology: 1. Refer to the previously written `tests/ui/SUMMARY.md` 2. Find an appropriate category for the test, using the original issue thread and the test contents. 3. Add the issue URL at the bottom (not at the top, as that would mess up stderr line numbers) 4. Rename the tests to make their purpose clearer Inspired by the methodology that `@Kivooeo` was using. r? `@jieyouxu`
2025-08-10Rehome tests/ui/issues/ tests [4/?]Oneirical-0/+6
2025-08-05commentsKivooeo-0/+35
2025-08-05moved 35 tests to organized locationsKivooeo-0/+15
2025-08-02Rehome tests/ui/issues/ tests [2/?]Oneirical-0/+6
2025-07-24Rehome tests/ui/issues/ tests [1/?]Oneirical-0/+11
2025-07-17Rollup merge of #143678 - Kivooeo:char-overflow, r=SparrowLiiLeón Orell Valerian Liehr-11/+169
Added error for invalid char cast fixes rust-lang/rust#143597 not really sure if I did it right, but according to cast-char test -- it is right, also this code gave me false positive result ``` for _ in 0..(256 as u8) {} ``` so this is why I added this check `if lit_val <= 0xFF` Also I believe that error message could be improved, but I'm not sure how exactly cc ```@hkBst``` r? compiler
2025-07-13cleaned up some testsKivooeo-5/+21
Additionally, remove unused `tests/ui/auxiliary/svh-*` crates that are duplicates of `tests/ui/svh/auxiliary/svh-*`.
2025-07-13moved testsKivooeo-0/+130
2025-07-10added error for invalid char castKivooeo-11/+169
2025-07-01cleaned up some testsKivooeo-9/+23
2025-06-30moved testsKivooeo-0/+47
2025-06-24Make missing lifetime suggestion verboseMichael Goulet-9/+16
2025-06-06reword suggestion messageEsteban Küber-3/+3
2025-06-06Make cast suggestions verboseEsteban Küber-12/+24
``` error[E0604]: only `u8` can be cast as `char`, not `u32` --> $DIR/E0604.rs:2:5 | LL | 1u32 as char; | ^^^^^^^^^^^^ invalid cast | help: try `char::from_u32` instead | LL - 1u32 as char; LL + char::from_u32(1u32); | ``` ``` error[E0620]: cast to unsized type: `&[u8]` as `[char]` --> $DIR/cast-to-slice.rs:6:5 | LL | arr as [char]; | ^^^^^^^^^^^^^ | help: try casting to a reference instead | LL | arr as &[char]; | + ``` ``` error[E0620]: cast to unsized type: `Box<{integer}>` as `dyn Send` --> $DIR/cast-to-unsized-trait-object-suggestion.rs:3:5 | LL | Box::new(1) as dyn Send; | ^^^^^^^^^^^^^^^^^^^^^^^ | help: you can cast to a `Box` instead | LL | Box::new(1) as Box<dyn Send>; | ++++ + ```
2025-05-31Note ref expr being cast when encounter NonScalar cast errorxizheyin-0/+2
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-05-24Add ui test func-pointer-issue-140491xizheyin-0/+16
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-05-06Structurally resolve in check_ref_castMichael Goulet-0/+22
2025-04-30compiletest: Make diagnostic kind mandatory on line annotationsVadim Petrochenkov-12/+13
2025-04-13Rollup merge of #138962 - xizheyin:issue-138836, r=compiler-errorsJacob Pratt-0/+14
Expect an array when expected and acutal types are both arrays during cast Closes #138836
2025-04-10compiletest: Trim the value of `dont-require-annotations`Vadim Petrochenkov-1/+1
2025-04-10compiletest: Make `SUGGESTION` annotations viralVadim Petrochenkov-11/+13
2025-04-03compiletest: Require `//~` annotations even if `error-pattern` is specifiedVadim Petrochenkov-6/+4
2025-03-27Expect an array when expected and acutal types are both arrays during castxizheyin-7/+4
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-03-26Add ui test cast-array-issue-138836xizheyin-0/+17
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-03-24Revert "Rollup merge of #136127 - WaffleLapkin:dyn_ptr_unwrap_cast, ↵Michael Goulet-376/+0
r=compiler-errors" This reverts commit 84c2050bf63f734246572345aedca9edb2abe96e, reversing changes made to a96fa317d78c78a9de996afd317603c6970efc0d.
2025-03-16Rollup merge of #138484 - xizheyin:issue-138392, r=compiler-errors许杰友 Jieyou Xu (Joe)-0/+43
Use lit span when suggesting suffix lit cast Fixes #138392
2025-03-14Use lit span when suggesting suffix lit castxizheyin-0/+43
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-03-13Remove an outdated line from a test commentWaffle Lapkin-1/+0
They *used* to not work, however this was fixed in the PR that added the test. I forgot to remove this line or possibly lost its removal while rebasing.
2025-03-08bless testsWaffle Lapkin-235/+66
yay, I fixed the bug/missing feature :')
2025-03-08add a test for pointer casts involving un/re/wrapping trait objectsWaffle Lapkin-0/+546
the errors should not be there, this is a bug/missing feature.
2025-03-05Rollup merge of #137728 - Darksonn:no-tuple-unsize, r=oli-obk许杰友 Jieyou Xu (Joe)-17/+1
Remove unsizing coercions for tuples See https://github.com/rust-lang/rust/issues/42877#issuecomment-2686010847 and below comments for justification. Tracking issue: #42877 Fixes: #135217
2025-03-05Rollup merge of #136764 - ↵许杰友 Jieyou Xu (Joe)-39/+19
traviscross:TC/make-ptr_cast_add_auto_to_object-hard-error, r=oli-obk Make `ptr_cast_add_auto_to_object` lint into hard error In Rust 1.81, we added a FCW lint (including linting in dependencies) against pointer casts that add an auto trait to dyn bounds. This was part of work making casts of pointers involving trait objects stricter, and was part of the work needed to restabilize trait upcasting. We considered just making this a hard error, but opted against it at that time due to breakage found by crater. This breakage was mostly due to the `anymap` crate which has been a persistent problem for us. It's now a year later, and the fact that this is not yet a hard error is giving us pause about stabilizing arbitrary self types and `derive(CoercePointee)`. So let's see about making a hard error of this. r? ghost cc ```@adetaylor``` ```@Darksonn``` ```@BoxyUwU``` ```@RalfJung``` ```@compiler-errors``` ```@oli-obk``` ```@WaffleLapkin``` Related: - https://github.com/rust-lang/rust/pull/135881 - https://github.com/rust-lang/rust/issues/136702 - https://github.com/rust-lang/rust/pull/136776 Tracking: - https://github.com/rust-lang/rust/issues/127323 - https://github.com/rust-lang/rust/issues/44874 - https://github.com/rust-lang/rust/issues/123430
2025-02-27Delete tuple unsizingAlice Ryhl-17/+1
2025-02-22Make `ptr_cast_add_auto_to_object` lint into hard errorTravis Cross-39/+19
In Rust 1.81, we added a FCW lint (including linting in dependencies) against pointer casts that add an auto trait to dyn bounds. This was part of work making casts of pointers involving trait objects stricter which was needed to restabilize trait upcasting. We considered just making this a hard error at the time, but opted against it due to breakage found by crater. This breakage was mostly due to the `anymap` crate which has been a persistent problem for us. It's now a year later, and the fact that this is not yet a hard error is giving us pause about stabilizing arbitrary self types and `derive(CoercePointee)`. So let's now make a hard error of this.
2025-02-21More sophisticated span trimmingMichael Goulet-3/+2
2025-02-10Show diff suggestion format on verbose replacementEsteban Küber-22/+33
``` error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> $DIR/attempted-access-non-fatal.rs:7:15 | LL | let _ = 2.l; | ^ | help: if intended to be a floating point literal, consider adding a `0` after the period and a `f64` suffix | LL - let _ = 2.l; LL + let _ = 2.0f64; | ```
2025-01-06`best_blame_constraint`: prioritize blaming interesting-seeming constraintsdianne-5/+17
2025-01-06`best_blame_constraint`: don't filter constraints by sup SCCdianne-23/+19
The SCCs of the region graph are not a reliable heuristic to use for blaming an interesting constraint for diagnostics. For region errors, if the outlived region is `'static`, or the involved types are invariant in their lifetiems, there will be cycles in the constraint graph containing both the target region and the most interesting constraints to blame. To get better diagnostics in these cases, this commit removes that heuristic.
2024-10-29Remove detail from label/note that is already available in other noteEsteban Küber-1/+1
Remove the "which is required by `{root_obligation}`" post-script in "the trait `X` is not implemented for `Y`" explanation in E0277. This information is already conveyed in the notes explaining requirements, making it redundant while making the text (particularly in labels) harder to read. ``` error[E0277]: the trait bound `NotCopy: Copy` is not satisfied --> $DIR/wf-static-type.rs:10:13 | LL | static FOO: IsCopy<Option<NotCopy>> = IsCopy { t: None }; | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `NotCopy` | = note: required for `Option<NotCopy>` to implement `Copy` note: required by a bound in `IsCopy` --> $DIR/wf-static-type.rs:7:17 | LL | struct IsCopy<T:Copy> { t: T } | ^^^^ required by this bound in `IsCopy` ``` vs the prior ``` error[E0277]: the trait bound `NotCopy: Copy` is not satisfied --> $DIR/wf-static-type.rs:10:13 | LL | static FOO: IsCopy<Option<NotCopy>> = IsCopy { t: None }; | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `NotCopy`, which is required by `Option<NotCopy>: Copy` | = note: required for `Option<NotCopy>` to implement `Copy` note: required by a bound in `IsCopy` --> $DIR/wf-static-type.rs:7:17 | LL | struct IsCopy<T:Copy> { t: T } | ^^^^ required by this bound in `IsCopy` ```
2024-10-20elaborate why dropping principal in `*dyn` casts is non-trivialLukas Markeffsky-0/+32
2024-10-04Use wide pointers consistenly across the compilerUrgau-1/+1
2024-09-27borrowck: use subtyping instead of equality for ptr-to-ptr castsLukas Markeffsky-28/+1
2024-09-27add even more tests for ptr-to-ptr casts on trait objectsLukas Markeffsky-7/+92
2024-09-24improve errors for invalid pointer castsLukas Markeffsky-33/+20
2024-09-24replace "cast" with "coercion" where applicableLukas Markeffsky-1/+1
This changes the remaining span for the cast, because the new `Cast` category has a higher priority (lower `Ord`) than the old `Coercion` category, so we no longer report the region error for the "unsizing" coercion from `*const Trait` to itself.