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

&[Trait] should probably not be allowed #21748

Closed
Ms2ger opened this issue Jan 29, 2015 · 5 comments
Closed

&[Trait] should probably not be allowed #21748

Ms2ger opened this issue Jan 29, 2015 · 5 comments
Labels
A-DSTs Area: Dynamically-sized types (DSTs) A-type-system Area: Type system

Comments

@Ms2ger
Copy link
Contributor

Ms2ger commented Jan 29, 2015

This compiles:

trait Reader {}
fn perform(readers: &[Reader]) -> usize { 0 }

and this complains that there is no len():

trait Reader {}
fn perform(readers: &[Reader]) -> usize { readers.len() }

It seems to me like both should fail to compile with an error about sticking DSTs in a slice.

@steveklabnik
Copy link
Member

/cc @rust-lang/lang , what do you think?

@nrc
Copy link
Member

nrc commented Nov 4, 2015

Yeah, we should require that T: Sized for [T], I think.

@nikomatsakis
Copy link
Contributor

Note that you now get RFC 1214 warnings (i.e., this is largely fixed).

@nikomatsakis
Copy link
Contributor

See e.g. http://is.gd/idE0a4

@steveklabnik
Copy link
Member

Ahh yes, forgot about RFC 1214. Given that that will land, I think this is fine to close.

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

Successfully merging a pull request may close this issue.

5 participants