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 upCyclic traits allow arbitrary traits to be synthesized #29859
Comments
nikomatsakis
added
A-traits
I-unsound 💥
T-lang
T-compiler
labels
Nov 16, 2015
This comment has been minimized.
This comment has been minimized.
|
triage: P-high |
rust-highfive
added
the
P-high
label
Nov 16, 2015
nikomatsakis
self-assigned this
Nov 16, 2015
This comment has been minimized.
This comment has been minimized.
|
Update: unrelated, my mistake. This is #29861. |
This comment has been minimized.
This comment has been minimized.
|
cc @james-darkfox (who tripped on this and #29861 in his lense crate) |
eddyb
referenced this issue
Nov 16, 2015
Closed
Unconstrained lifetimes permitted in assoc. type as long as they are in a projection #29861
This comment has been minimized.
This comment has been minimized.
|
Another simple example as follows: Magic treats anything as trait Magic: Copy {}
impl<T: Magic> Magic for T {}
fn copy<T: Magic>(x: T) -> (T, T) { (x, x) }
#[derive(Debug)]
struct NoClone;
fn main() {
let (a, b) = copy(NoClone);
println!("{:?} {:?}", a, b);
} |
This comment has been minimized.
This comment has been minimized.
|
@nikomatsakis Earlier I decided to create a "safe" hexdump using this concept. :-) https://play.rust-lang.org/?gist=0832c0210daba58942c0&version=nightly |
This comment has been minimized.
This comment has been minimized.
jnicholls
commented
Nov 18, 2015
|
This is a big issue. I think a fix needs to be put out for 1.4.0+ as soon as possible. |
This comment has been minimized.
This comment has been minimized.
|
Related, what's our policy on nominating soundness fixes for backporting to beta? |
This comment has been minimized.
This comment has been minimized.
|
In my understanding of the system, the impl was supposed to cause a WF error (why do we think that |
This comment has been minimized.
This comment has been minimized.
|
The supertrait version looks more dangerous. |
This comment has been minimized.
This comment has been minimized.
|
Eh I got it - wfcheck checks |
This comment has been minimized.
This comment has been minimized.
|
As a fix, maybe not elaborate supertraits when checking WF? That would have an ugly annotation burden, but I am not sure how bad would it be. |
This comment has been minimized.
This comment has been minimized.
|
This seems like a great candidate for a stable version bug fix release. According to play, hexdump works in 1.4. Is it in any older versions? If so, should we backport a fix to them? |
This comment has been minimized.
This comment has been minimized.
|
The "supertrait" variant exists at least since multidispatch. The "associated type" variant is a problem with wf checking, but wf checking didn't really work before 1.5. |
This comment has been minimized.
This comment has been minimized.
|
@bstrie We mark with @erickt I suspect this goes all the way back to 1.0; it's not just an implementation issue, but may point to some deeper conceptual issues with how the trait system works. Before we talk about backporting in too much detail, we need to figure out how we want to address the problem (and see the code impact for doing so). |
This comment has been minimized.
This comment has been minimized.
|
Let's first decide on what we want the fix to be before we discuss whether @arielb1 I am not sure yet where I think the error should occur. My first
I don't particularly like this division though. But I think that just On Thu, Nov 19, 2015 at 10:22 AM, arielb1 notifications@github.com wrote:
|
This comment has been minimized.
This comment has been minimized.
|
I wrote this:
in response to @arielb1's comment here:
But I realize now I'm not 100% sure what he meant, so I potentially take it back. In any case, I'm stepping out the door just now (leaving on a trip for the next few days), but I'll definitely be pondering this. It may be that we can change something about how (*) A caveat, that example just happens to be one representative tab I have lying around open, it may have some small flaw that is orthogonal to this bug that's making it not work for all I know. But the main point is, it'd be interesting to try and pin down precisely why so many similar examples seem to not work, and make sure we have a fix that applies universally. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
triage: P-high I think the best fix for this in short term is to make non-structural-traits be inductive. I have a patch underway for this. But I'd like to think more about the longer term fix. |
This comment has been minimized.
This comment has been minimized.
|
I don't have serious objections to making non-structural-trait matching inductive, except that it would be a big scary breaking-change. |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
jnicholls
commented
Dec 7, 2015
|
lol. Such recursive trait impl. are an illogical paradox and should not be On Sunday, December 6, 2015, angelsl notifications@github.com wrote:
Sent from Gmail Mobile |
nikomatsakis
referenced this issue
Dec 23, 2015
Merged
Introduce "obligation forest" data structure into fulfillment to track backtraces #30533
nikomatsakis
added a commit
to nikomatsakis/rust
that referenced
this issue
Jan 16, 2016
This comment has been minimized.
This comment has been minimized.
|
@brson We've narrowed down this problem significantly but as far as I know not closed it completely. @arielb1 I recall at the dev sprint you proposed a set of rules concerning cycles that seemed reasonable -- I think it was to allow full coinductive reasoning for auto traits, but disallow an auto trait from supertraits or other similar side conditions? |
This comment has been minimized.
This comment has been minimized.
|
@brson but I'm not sure what you mean when you say "still P-high". I guess you mean "would this warrant dropping everything and fixing this second"... if that's the question, the answer is clearly no. I guess what I'm saying is that I still feel like we never rejiggered our triage system to my satisfaction so I'm not entirely sure what the set of labels are :) |
This comment has been minimized.
This comment has been minimized.
|
@nikomatsakis I am trying to steer |
This comment has been minimized.
This comment has been minimized.
|
@brson And |
This comment has been minimized.
This comment has been minimized.
|
@aturon That's the intent yeah. We should probably discuss more offline about our goals for process tracking though. |
This comment has been minimized.
This comment has been minimized.
|
@arielb1 says he is planning to discuss this with @nikomatsakis . I-unsound already expresses the unsoundness aspect of the bug. We're going to demote this to P-medium, but if ariel or niko plan to address this in this cycle, they can promote it back to P-high. |
This comment has been minimized.
This comment has been minimized.
|
triage: P-medium |
nikomatsakis commentedNov 16, 2015
•
edited
This issue is partially fixed through the introduction of the "obligation jungle" but we still want to impose a limitation that auto traits cannot have supertraits (for now, no supertraits at all seems easiest). This would close the remaining soundness hole described here.
This is, I believe, an unintended outcome of some caching I put in. The problem is that this test compiles fine -- I believe the expected outcome was an internal stack overflow. My preferred fix is to refactor the fulfillment context to track trees in more detail, which is something that we've started but the branch has since bitrotted. This makes me want to get back to that more urgently.