Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upobject-safe traits can have associated types with unchecked bounds #27675
Comments
This comment has been minimized.
This comment has been minimized.
|
Related: use std::fmt;
trait Foo {
type Assoc: 'static;
}
fn foo<T: Foo+?Sized>(t: T::Assoc) -> Box<fmt::Display+'static>
where T::Assoc: fmt::Display {
Box::new(t)
}
fn wat() -> Box<fmt::Display+'static> {
let x = 42;
foo::<Foo<Assoc=&u32>>(&x)
}
fn main() {
println!("{}", wat());
} |
This comment has been minimized.
This comment has been minimized.
|
Interesting. I agree that it should be illegal and we should amend WF relations for object types to check that the bindings cover the requirements of the trait -- the RFC was incomplete on this topic. |
steveklabnik
added
A-typesystem
A-traits
labels
Aug 13, 2015
arielb1
referenced this issue
Aug 14, 2015
Closed
Incorrect object-safety with `where Option<Self>: Sized` #25204
arielb1
referenced this issue
Aug 31, 2015
Closed
ICE: creating trait object with function that has stricter bounds on associated type. #27954
nikomatsakis
referenced this issue
Jan 20, 2016
Open
Projections, lifetimes, and WF tracking issue (RFC 1214) #27579
This comment has been minimized.
This comment has been minimized.
|
The example from the first comment (#27675 (comment)) is actually scarier than the original bug description; at least, I usually can think "oh, an ICE, well that might just be something that won't actually ever compile"; but the first comment is showing code that is indeed a case of "wat"! |
arielb1
added
the
I-unsound 💥
label
Jan 21, 2016
arielb1
changed the title
object-safe traits can have associated types with Self-containing bounds
object-safe traits can have associated types with unchecked bounds
Jan 21, 2016
arielb1
referenced this issue
Apr 11, 2016
Closed
Unsound projection when late-bound-region appears only in return type #32330
This comment has been minimized.
This comment has been minimized.
|
triage: P-medium |
rust-highfive
added
the
P-medium
label
Jul 7, 2016
Mark-Simulacrum
added
the
C-bug
label
Jul 22, 2017
arielb1
referenced this issue
Sep 10, 2017
Open
unsoundness relating to WF requirements on trait object types #44454
bstrie
referenced this issue
Sep 17, 2017
Open
borrowed referent of a `&T` sometimes incorrectly allowed #38899
arielb1
referenced this issue
Dec 3, 2018
Closed
problems with trait objects with a trait projection value that contains Self #56288
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
arielb1 commentedAug 11, 2015
STR
Result
I guess this should be banned.
cc @nikomatsakis