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

core: rustc: improve compile message for unsized types #26617

Closed
wants to merge 1 commit into from

Conversation

liigo
Copy link
Contributor

@liigo liigo commented Jun 27, 2015

Currently, the compiler only tell us there is unsized type, but it's not clear how to fix the error, especially for a newbie.

t.rs:5:17: 5:18 error: the trait `core::marker::Sized` is not implemented for the type `MyTrait` [E0277]
t.rs:5 fn do_something(t: MyTrait) {
                       ^
t.rs:5:17: 5:18 note: `MyTrait` does not have a constant size known at compile-time
t.rs:5 fn do_something(t: MyTrait) {
                       ^
error: aborting due to previous error

@rust-highfive
Copy link
Collaborator

r? @aturon

(rust_highfive has picked a reviewer for you, use r? to override)

@aturon
Copy link
Member

aturon commented Aug 4, 2015

Hi @liigo, sorry this fell through my inbox!

This looks like a good change, but I'm not sure about the last clause about generic types. I suspect in most cases this comes up you've got roughly the right type in mind, but need to put it behind a pointer -- so maybe just stick with the first two suggestions?

Otherwise LGTM.

@liigo
Copy link
Contributor Author

liigo commented Aug 6, 2015

Sure! I'm sorry for replying this too late. I'm on holiday and will be at
work in about one or two days.
On Aug 4, 2015 22:50, "Aaron Turon" notifications@github.com wrote:

Hi @liigo https://github.com/liigo, sorry this fell through my inbox!

This looks like a good change, but I'm not sure about the last clause
about generic types. I suspect in most cases this comes up you've got
roughly the right type in mind, but need to put it behind a pointer -- so
maybe just stick with the first two suggestions?

Otherwise LGTM.


Reply to this email directly or view it on GitHub
#26617 (comment).

@liigo liigo force-pushed the unsized-type-tips branch from becad03 to 58be3c7 Compare August 9, 2015 08:36
@liigo
Copy link
Contributor Author

liigo commented Aug 9, 2015

@aturon r? I've addressed your comment, and rebased.

@arielb1
Copy link
Contributor

arielb1 commented Aug 9, 2015

This will make #23286 even worse, and even if we print the cause:

test.rs:3:6: 3:7 error: the trait `core::marker::Sized` is not implemented for the type `[u8]` [E0277]
test.rs:3 fn f(p: Path) {}
               ^
test.rs:3:6: 3:7 help: run `rustc --explain E0277` to see a detailed explanation
test.rs:3:6: 3:7 note: `[u8]` does not have a constant size known at compile-time. Try to use `&[u8]` or `Box<[u8]>`?
test.rs:3 fn f(p: Path) {}
               ^
test.rs:3:6: 3:7 note: required because it appears within the type `std::sys::os_str::Slice`
test.rs:3 fn f(p: Path) {}
               ^
test.rs:3:6: 3:7 note: required because it appears within the type `std::ffi::os_str::OsStr`
test.rs:3 fn f(p: Path) {}
               ^
test.rs:3:6: 3:7 note: required because it appears within the type `std::path::Path`
test.rs:3 fn f(p: Path) {}
               ^
test.rs:3:6: 3:7 note: all local variables must have a statically known size
test.rs:3 fn f(p: Path) {}
               ^

Maybe have #[rustc_on_unimplemented_help="maybe put it behind a pointer?"] (bikeshed) that appears after the note?

@liigo
Copy link
Contributor Author

liigo commented Oct 18, 2015

Ok, I'm closing this.

@liigo liigo closed this Oct 18, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants