Skip to content

librustc: Have coherence check Copy kind bounds when determining whether parameter substitutions could possibly unify - #4139

Closed
pcwalton wants to merge 2 commits into
rust-lang:incomingfrom
pcwalton:coherence-copy-kind
Closed

librustc: Have coherence check Copy kind bounds when determining whether parameter substitutions could possibly unify#4139
pcwalton wants to merge 2 commits into
rust-lang:incomingfrom
pcwalton:coherence-copy-kind

Conversation

@pcwalton

@pcwalton pcwalton commented Dec 8, 2012

Copy link
Copy Markdown
Contributor

@nikomatsakis

Copy link
Copy Markdown
Contributor

r+ to coherence check special-casing Copy bounds

@brson

brson commented Dec 8, 2012

Copy link
Copy Markdown
Contributor

Why is this special-cased for Copy? When we discussed it yesterday I understood that it was a general problem.

@nikomatsakis

Copy link
Copy Markdown
Contributor

So, there is a larger issue here. In general I am nervous about "negative logic" in type rules. That is, saying something like "this is ok because type X does NOT have this property" (in this case, copy-ness) vs "this is ok because type X DOES have this property". This is because it leads to non-monotonicity which tends to create complications when things are combined.

All that said, I think in the abstract it's ok for coherence to consider a type variable T:U and some type X that does not implement U as disjoint. This is because of coherence itself, basically, which ensures that since both X and U are defined in crates that we know about, if there was any impl of U for X, we'd be able to see it. So we can't screw up crate linking this way

But that said, supporting this sort of reasoning in coherence is complicated. It requires nested checks. We need to be very careful to ensure termination in these kinds of scenarios (but we probably have to anyhow, long story). Perhaps just supporting this reasoning for the built-in kinds is an acceptable compromise.

@pcwalton pcwalton closed this Dec 14, 2012
RalfJung added a commit to RalfJung/rust that referenced this pull request Jan 19, 2025
U007D pushed a commit to U007D/rust-mos that referenced this pull request Aug 21, 2026
4139: Add check for rules that no repetition which could match an empty token r=matklad a=edwin0cheng

Fix rust-lang#4103

for `/ui/issues/issue-57597.rs`

This is `ParseError` of the macro rules , because it is how rustc handle it : 

https://github.com/rust-lang/rust/blob/a58b1ed44f5e06976de2bdc4d7dc81c36a96934f/src/librustc_expand/mbe/macro_rules.rs#L558


Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
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.

3 participants