librustc: Disallow trait bounds in types, enumerations, and structure definitions#4660
Closed
pcwalton wants to merge 2 commits intorust-lang:incomingfrom
Closed
librustc: Disallow trait bounds in types, enumerations, and structure definitions#4660pcwalton wants to merge 2 commits intorust-lang:incomingfrom
pcwalton wants to merge 2 commits intorust-lang:incomingfrom
Conversation
…ules. "Dual impls" are impls that are both type implementations and trait implementations. They can lead to ambiguity and so this patch removes them from the language. This also enforces coherence rules. Without this patch, records can implement traits not defined in the current crate. This patch fixes this, and updates all of rustc to adhere to the new enforcement. Most of this patch is fixing rustc to obey the coherence rules, which involves converting a bunch of records to structs.
Contributor
|
Doesn't have to be in the same pull request, but we need to document why you're not allowed to have trait bounds in these locations, and what to do instead. (In fact, I don't completely get the gist of it: I assume the issue is that writing |
Contributor
|
r+ -- making it a parse error instead of a type error would be nice, but isn't necessary. |
makai410
pushed a commit
to makai410/rust
that referenced
this pull request
Nov 4, 2025
Automatic Rustup
makai410
pushed a commit
to makai410/rust
that referenced
this pull request
Nov 8, 2025
Automatic Rustup
makai410
pushed a commit
to makai410/rust
that referenced
this pull request
Nov 10, 2025
Automatic Rustup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
r? @catamorphism
I had to take an alarmingly large hatchet to most of the trait bounds in pipes. There is some bug in the interactions between the pipes compiler, the code generated by the pipes compiler, and the kind checker. However, I believe the code to still be safe; it should still not be possible to send a garbage-collected value over a channel.