Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check types in method signatures #25388

Closed
arielb1 opened this issue May 13, 2015 · 3 comments
Closed

Check types in method signatures #25388

arielb1 opened this issue May 13, 2015 · 3 comments
Labels
A-type-system Area: Type system

Comments

@arielb1
Copy link
Contributor

arielb1 commented May 13, 2015

We don't check that types in method signatures are well-formed, or even when they are Sized. I mean, this compiles:

pub struct U<T: Send+Sync+Copy+::std::fmt::Display>(*const T);

pub trait Trait { }

pub trait OtherTrait {
    fn f(self, u: U<Trait>);
    fn g(self, u: [u8]);
}

impl OtherTrait for () {
    fn f(self, u: U<Trait>) { }
    fn g(self, ref u: [u8]) {}
}

fn main () {}
@arielb1
Copy link
Contributor Author

arielb1 commented May 13, 2015

Fixing this seems 1) important but 2) kind-of backward-compatibility breaking

@apasel422
Copy link
Contributor

Related to #19182.

@nikomatsakis
Copy link
Contributor

We intentionally chose not to check that argument types are Sized in trait definitions. We do check it when the method is implemented, and the full type is known, and we check that values we actually pass as arguments are sized. (Moreover, at least for now, if two types are related by subtyping, then either both are sized or neither is.) So I don't think that's a big problem. But I agree we need to cleanup some corner cases of WF.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-type-system Area: Type system
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants