[Pre-pre RFC] Allow exclusion of trait methods for (certain) unsatisfiable where bounds
Related:
- Refinement tracking issue, so you could write a method without the bounds when they aren't met, and actually make use of it
- Trivial bounds tracking issue, so you could write a method with the trivially unmet bounds present without a compiler error
steffahn:
For some reason,
rustcdoesn’t care so much anymore about “impossible” bounds if you add some higher-ranked lifetime to it.
That has an issue, but is also a workaround for the lack of stable trivial bounds. (As is writing a method without bounds, but you can't currently call it.)
steffahn:
This seems like deliberate design, so it’s probably possible to find prior discussion somewhere
github.com/rust-lang/rust
Don't require method impls for methods with Self:Sized bounds for impls for unsized types (#135480)
master ← oli-obk:sized-method-on-unsized-impl
opened 11:39AM - 14 Jan 25 UTC
oli-obk
+106 -20
Similarly to how #112319 doesn't require specifying associated types with Self:… Sized bounds on dyn Trait, we now don't require assoc items with Self: Sized bounds to be in impls of for unsized types. Additionally we lint assoc items with Self: Sized bounds that are in such impls: rust trait Foo { fn foo() where Self: Sized; } impl Foo for () { fn foo() {} } impl Foo for i32 {} //~^ ERROR: not all trait items implemented, missing: `foo` impl Foo for dyn std::fmt::Debug {} #[deny(dead_code)] impl Foo for dyn std::fmt::Display { fn foo() {} //~^ ERROR this item cannot be used as its where bounds are not satisfied } Note that this works with the same Self: Sized specific logic we already have for dyn Trait, so no new capabilities like avoiding assoc items with Self: Copy bounds on impls for String or such are added here. Specifying where ConcreteType: Sized in a trait and implementing the trait for ConcreteType also does not work, it must be exactly Self: Sized.
Discussion in the ATmosphere