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 upSilent demotion of lifetime in analysis causes confusing message #21508
Comments
huonw
added
the
A-lifetimes
label
Jan 22, 2015
This comment has been minimized.
This comment has been minimized.
|
cc @nikomatsakis; this is the "subtyping" rule, right? |
This comment has been minimized.
This comment has been minimized.
|
Yes, this is the subtyping rule. I'm not sure whether changes are needed here, but if we were to change anything I would want to get stricter about the correspondence between the trait and impl. |
This comment has been minimized.
This comment has been minimized.
|
There are other places -- notably where-clauses -- where we absolutely cannot require a 1-to-1 correspondence. But in method signatures we likely could. It's a bit trickier than it might sound. |
nikomatsakis
added
the
I-nominated
label
Feb 4, 2015
This comment has been minimized.
This comment has been minimized.
|
Nominating. We have to decide what semantics we want here I guess. |
This comment has been minimized.
This comment has been minimized.
|
P-high, not required for 1.0. (But we would take a patch if we happen to get one before 1.0; otherwise the current semantics is stuck). |
pnkfelix
added
P-medium
and removed
I-nominated
labels
Feb 5, 2015
This comment has been minimized.
This comment has been minimized.
Well, a loooong time after 1.0, I guess this is stuck here, closing. |
dhardy commentedJan 22, 2015
See StackOverflow question.
Summary: the compiler accepts a trait impl function returning a
&'static strwhen the trait requires only&'a str,'abeing the life of the object, but then assumes the lifetime of the returned value is only&'a strdespite direct call (not via trait).Possible solutions I see:
&'staticwhen called via the object and lifetime&'awhen called via the trait). This is likely confusing, so (2) may be better.