about summary refs log tree commit diff
path: root/tests/ui/traits/trait-upcasting
AgeCommit message (Collapse)AuthorLines
2025-09-30remove unnecessary test directiveslcnr-7/+0
2025-08-19bless tests with new lint messagesKarol Zwolak-2/+2
2025-07-13Retire hir::*ItemRef.Camille GILLOT-3/+3
2025-07-01Remove support for dyn*Michael Goulet-19/+0
2025-06-30Merge `lower_item` into `check_item_type`Oli Scherer-1/+1
2025-03-12Rollup merge of #138357 - lcnr:goodbye-TypeVerifier-rarw, r=compiler-errorsManish Goregaokar-2/+2
merge `TypeChecker` and `TypeVerifier` Stacked on top of #138354. Best reviewed commit by commit. r? `@compiler-errors`
2025-03-11change `TypeChecker` to a MIR visitorlcnr-2/+2
2025-03-11Implement `#[define_opaque]` attribute for functions.Oli Scherer-0/+2
2025-03-01Check dyn flavor before registering upcast goal on wide pointer cast in MIR ↵Michael Goulet-0/+19
typeck
2025-02-10Show diff suggestion format on verbose replacementEsteban Küber-10/+15
``` 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-02-06allow+update `deref_into_dyn_supertrait`Waffle Lapkin-62/+52
this commit makes `deref_into_dyn_supertrait` lint allow-by-default, removes future incompatibility (we finally live in a broken world), and changes the wording in the documentation. previously documentation erroneously said that it lints against *usage* of the deref impl, while it actually (since 104742) lints on the impl itself (oooops, my oversight, should have updated it 2+ years ago...)
2025-02-06remove `feature(trait_upcasting)` from tests and bless themWaffle Lapkin-220/+59
2025-01-31Ensure that we never try to monomorphize the upcasting of impossible dyn typesMichael Goulet-0/+26
2025-01-30More assertions, tests, and miri coverageMichael Goulet-5/+42
2025-01-30Normalize vtable entries before walking and deduplicating themMichael Goulet-2/+33
2025-01-30Do not treat vtable supertraits as distinct when bound with different bound varsMichael Goulet-2/+25
2025-01-30Rework rustc_dump_vtableMichael Goulet-0/+117
2025-01-27Remove all dead files inside tests/ui/León Orell Valerian Liehr-70/+0
2025-01-15Rollup merge of #135498 - compiler-errors:dyn-upcasting-completeness, r=lcnrGuillaume Gomez-0/+29
Prefer lower `TraitUpcasting` candidates in selection Fixes #135463. The underlying cause is this ambiguity, but it's more clear (and manifests as a coercion error, rather than a MIR validation error) when it's written the way I did in the UI test. Sorry this is cursed r? lcnr
2025-01-14Prefer lower TraitUpcasting candidatesMichael Goulet-0/+29
2025-01-14add note to testlcnr-1/+1
2025-01-14Leak check in impossible_predicates to avoid monomorphizing impossible instancesMichael Goulet-0/+79
2025-01-06`best_blame_constraint`: don't filter constraints by sup SCCdianne-4/+4
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-12-27Remove the `-test` suffix from normalize directivesZalathar-4/+4
2024-09-30Instantiate binders in supertrait_vtable_slotMichael Goulet-7/+8
2024-09-28Rollup merge of #130866 - compiler-errors:dyn-instantiate-binder, r=lcnrMatthias Krüger-44/+36
Allow instantiating object trait binder when upcasting This PR fixes two bugs (that probably need an FCP). ### We use equality rather than subtyping for upcasting dyn conversions This code should be valid: ```rust #![feature(trait_upcasting)] trait Foo: for<'h> Bar<'h> {} trait Bar<'a> {} fn foo(x: &dyn Foo) { let y: &dyn Bar<'static> = x; } ``` But instead: ``` error[E0308]: mismatched types --> src/lib.rs:7:32 | 7 | let y: &dyn Bar<'static> = x; | ^ one type is more general than the other | = note: expected existential trait ref `for<'h> Bar<'h>` found existential trait ref `Bar<'_>` ``` And so should this: ```rust #![feature(trait_upcasting)] fn foo(x: &dyn for<'h> Fn(&'h ())) { let y: &dyn FnOnce(&'static ()) = x; } ``` But instead: ``` error[E0308]: mismatched types --> src/lib.rs:4:39 | 4 | let y: &dyn FnOnce(&'static ()) = x; | ^ one type is more general than the other | = note: expected existential trait ref `for<'h> FnOnce<(&'h (),)>` found existential trait ref `FnOnce<(&(),)>` ``` Specifically, both of these fail because we use *equality* when comparing the supertrait to the *target* of the unsize goal. For the first example, since our supertrait is `for<'h> Bar<'h>` but our target is `Bar<'static>`, there's a higher-ranked type mismatch even though we *should* be able to instantiate that supertrait binder when upcasting. Similarly for the second example. ### New solver uses equality rather than subtyping for no-op (i.e. non-upcasting) dyn conversions This code should be valid in the new solver, like it is with the old solver: ```rust // -Znext-solver fn foo<'a>(x: &mut for<'h> dyn Fn(&'h ())) { let _: &mut dyn Fn(&'a ()) = x; } ``` But instead: ``` error: lifetime may not live long enough --> <source>:2:11 | 1 | fn foo<'a>(x: &mut dyn for<'h> Fn(&'h ())) { | -- lifetime `'a` defined here 2 | let _: &mut dyn Fn(&'a ()) = x; | ^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static` | = note: requirement occurs because of a mutable reference to `dyn Fn(&())` ``` Specifically, this fails because we try to coerce `&mut dyn for<'h> Fn(&'h ())` to `&mut dyn Fn(&'a ())`, which registers an `dyn for<'h> Fn(&'h ()): dyn Fn(&'a ())` goal. This fails because the new solver uses *equating* rather than *subtyping* in `Unsize` goals. This is *mostly* not a problem... You may wonder why the same code passes on the new solver for immutable references: ``` // -Znext-solver fn foo<'a>(x: &dyn Fn(&())) { let _: &dyn Fn(&'a ()) = x; // works } ``` That's because in this case, we first try to coerce via `Unsize`, but due to the leak check the goal fails. Then, later in coercion, we fall back to a simple subtyping operation, which *does* work. Since `&T` is covariant over `T`, but `&mut T` is invariant, that's where the discrepancy between these two examples crops up. --- r? lcnr or reassign :D
2024-09-27Rollup merge of #130826 - fmease:compiler-mv-obj-safe-dyn-compat, ↵Matthias Krüger-2/+2
r=compiler-errors Compiler: Rename "object safe" to "dyn compatible" Completed T-lang FCP: https://github.com/rust-lang/lang-team/issues/286#issuecomment-2338905118. Tracking issue: https://github.com/rust-lang/rust/issues/130852 Excludes `compiler/rustc_codegen_cranelift` (to be filed separately). Includes Stable MIR. Regarding https://github.com/rust-lang/rust/labels/relnotes, I guess I will manually open a https://github.com/rust-lang/rust/labels/relnotes-tracking-issue since this change affects everything (compiler, library, tools, docs, books, everyday language). r? ghost
2024-09-26Check allow instantiating object trait binder when upcasting and in new solverMichael Goulet-44/+36
2024-09-25Compiler: Rename "object safe" to "dyn compatible"León Orell Valerian Liehr-2/+2
2024-09-24use more accurate spans for user type ascriptionsLukas Markeffsky-8/+8
2024-07-11Always use a colon in `//@ normalize-*:` headersZalathar-4/+4
2024-05-23Support constraining opaque types while trait upcasting with bindersOli Scherer-10/+2
2024-05-23Allow defining opaque types during trait object upcasting.Oli Scherer-19/+2
No stable code is affected, as this requires the `trait_upcasting` feature gate.
2024-05-23Add more testsOli Scherer-6/+68
2024-05-06borrowck: more eagerly prepopulate opaqueslcnr-46/+27
2024-04-04Switch upcast projections to allowing opaque types and add a test showing it ↵Oli Scherer-0/+60
works. The old solver was already ICEing on this test before this change
2024-03-14add testslcnr-0/+128
2024-03-10Ignore tests w/ current/next revisions from compare-mode=next-solverMichael Goulet-8/+15
2024-03-07Merge collect_mod_item_types query into check_well_formedOli Scherer-2/+17
2024-02-22Deduplicate some logic and reword outputEsteban Küber-5/+5
2024-02-22Make confusable suggestions `verbose`Esteban Küber-5/+25
2024-02-16[AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives许杰友 Jieyou Xu (Joe)-26/+26
2024-02-15Consider principal trait ref's auto-trait super-traits in dyn upcastingMichael Goulet-0/+14
2024-02-07Update testsr0cky-4/+49
2024-01-22Revert "Auto merge of #118133 - Urgau:stabilize_trait_upcasting, r=WaffleLapkin"Oli Scherer-90/+196
This reverts commit 6d2b84b3ed7848fd91b8d6151d4451b3103ed816, reversing changes made to 73bc12199ea8c7651ed98b069c0dd6b0bb5fabcf.
2023-12-14update use of feature flagslcnr-6/+6
2023-11-24Show number in error message even for one errorNilstrieb-10/+10
Co-authored-by: Adrian <adrian.iosdev@gmail.com>
2023-11-22Rework supertrait lint once againMichael Goulet-3/+88
2023-11-22Stabilize RFC3324 dyn upcasting coercionUrgau-174/+77
Aka trait_upcasting feature. And also adjust the `deref_into_dyn_supertrait` lint.
2023-11-20Bump future release warning modeMichael Goulet-4/+4