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

Box::from(&str) -> Box<Error> regression #30634

Closed
diwic opened this Issue Dec 30, 2015 · 13 comments

Comments

Projects
None yet
4 participants
@diwic
Copy link
Contributor

diwic commented Dec 30, 2015

The following code compiles fine on the stable channel but fails on the beta and nigthly channels:

fn test() -> Box<std::error::Error> { Box::from("test") }
fn main() { test(); }

The error message is:

error: the trait `std::error::Error` is not implemented for the type `&str`
@bluss

This comment has been minimized.

Copy link
Contributor

bluss commented Dec 30, 2015

cc @brson

If the result type is Box<Error + Send + Sync> instead, it continues to compile. I'm not immediately sure why.

@bluss

This comment has been minimized.

Copy link
Contributor

bluss commented Dec 30, 2015

Is #29580 related?

@diwic

This comment has been minimized.

Copy link
Contributor Author

diwic commented Dec 31, 2015

Side note - I discovered this when running cargo test on my dbus crate, as now one of the examples fails to build. If the crater is run on all crates on crates.io and it includes a cargo test, this would have been discovered by crater as a root regression?

@brson

This comment has been minimized.

Copy link
Contributor

brson commented Jan 6, 2016

This has bit me. Crater had to be modified to not try to box strings as errors.

@aturon

This comment has been minimized.

Copy link
Member

aturon commented Jan 6, 2016

@bluss That suggests that there's some bad interplay between the coercion that would throw away the extra constraints and the dispatch for From (which is indeed tied to Box<Error + Send + Sync + 'a>). Not sure why it was working before, honestly.

@brson brson self-assigned this Jan 6, 2016

@brson

This comment has been minimized.

Copy link
Contributor

brson commented Jan 6, 2016

I'll try to bisect.

@brson

This comment has been minimized.

Copy link
Contributor

brson commented Jan 8, 2016

If the crater is run on all crates on crates.io and it includes a cargo test, this would have been discovered by crater as a root regression?

Yes.

@brson

This comment has been minimized.

Copy link
Contributor

brson commented Jan 8, 2016

So this is working as intended, right? @bluss why doesn't one need to write the type with the lifetime in Box<Error + Send + Sync + 'static>? Is 'static the default?

@bluss

This comment has been minimized.

Copy link
Contributor

bluss commented Jan 8, 2016

Yep, 'static is the default with Box. For &'a Trait it's &'a (Trait + 'a) instead.

@brson

This comment has been minimized.

Copy link
Contributor

brson commented Jan 11, 2016

I started bisecting last week to find the patch that made this change, but it's slow going.

@diwic

This comment has been minimized.

Copy link
Contributor Author

diwic commented Jan 19, 2016

Might be solved by #30509 ?

@bluss

This comment has been minimized.

Copy link
Contributor

bluss commented Jan 19, 2016

Yes, it compiles on nightly now. The regression to beta still remains.

@brson

This comment has been minimized.

Copy link
Contributor

brson commented Feb 11, 2016

This has been ported to beta. Closing.

@brson brson closed this Feb 11, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.