Skip to content

librustc: Disallow trait bounds in types, enumerations, and structure definitions - #4660

Closed
pcwalton wants to merge 2 commits into
rust-lang:incomingfrom
pcwalton:unenforced-bounds
Closed

librustc: Disallow trait bounds in types, enumerations, and structure definitions#4660
pcwalton wants to merge 2 commits into
rust-lang:incomingfrom
pcwalton:unenforced-bounds

Conversation

@pcwalton

Copy link
Copy Markdown
Contributor

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.

…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.
@catamorphism

Copy link
Copy Markdown
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 struct Bucket<K: Eq> is pointless because instead, you want to write fn foo<K: Eq>(...Bucket<K>...), putting all the constraints on the signature of functions that use Buckets?)

@catamorphism

Copy link
Copy Markdown
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
makai410 pushed a commit to makai410/rust that referenced this pull request Nov 8, 2025
makai410 pushed a commit to makai410/rust that referenced this pull request Nov 10, 2025
U007D pushed a commit to U007D/rust-mos that referenced this pull request Aug 21, 2026
4660: Enable hover and autocomplete docs on macro generated items r=aloucks a=aloucks
Enable hover and autocomplete docs on macro generated items. This de-sugars doc comments into `doc` attributes in some cases, but not all. Comments and `doc` attributes are then merged together. This PR is essentially a partial implementation of what's being suggested rust-lang#3182, but it's not all the way there yet. ~I still need to add unit tests~, but I wanted to first get feedback on whether or not this was an acceptable path forward.
Fixesrust-lang#4564Fixesrust-lang#3984Fixesrust-lang#3180
Related rust-lang#3182
![macro_item_docs](https://user-images.githubusercontent.com/221559/83336760-15012200-a284-11ea-8d0d-b6a615850044.gif)
Co-authored-by: Aaron Loucks <aloucks@cofront.net>
Sign up for freeto 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

@pcwalton@catamorphism@nikomatsakis