-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Extract ImplOfTrait in AST/HIR #144386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Extract ImplOfTrait in AST/HIR #144386
Conversation
r? @SparrowLii rustbot has assigned @SparrowLii. Use |
Some changes occurred in src/tools/clippy cc @rust-lang/clippy Some changes occurred in src/tools/rustfmt cc @rust-lang/rustfmt HIR ty lowering was modified cc @fmease Some changes occurred in compiler/rustc_passes/src/check_attr.rs |
This comment has been minimized.
This comment has been minimized.
I don't think that's true fwiw. |
This comment has been minimized.
This comment has been minimized.
This means this PR change the code in |
@rustbot author |
Reminder, once the PR becomes ready for a review, use |
This comment has been minimized.
This comment has been minimized.
} | ||
|
||
#[derive(Clone, Encodable, Decodable, Debug)] | ||
pub struct ImplOfTrait { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find ImplOfTrait
(or TraitImpl
) to be very misleading since it doesn't represent a full trait impl.
First I thought maybe TraitImplHeader
(impl header is pre-existing jargon) but for that it lacks the self_ty
and the generics
.
I'm currently leaning towards ImplTraitRef
(impl trait ref is pre-existing jargon for the trait ref in an impl). It's not 100% technically correct since the "modifiers" belong to the impl not to the ref, so 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find
ImplOfTrait
(orTraitImpl
) to be very misleading since it doesn't represent a full trait impl.
Yeah I see your point, though I feel like this wont cause much confusion in practice.
The first thing I had was
enum ImplKind {
Inherent(/* self ty */ Ty)
Trait(ImplOfTrait)
}
...with self_ty
repeated in the two variants. But then I decided it's ultimately simpler to not duplicate anything, and then I decided that ImplKind
can just be an Option
.
Another option could be to have
enum ImplKind {
Inherent,
Trait { defaultness, constness, .... } // inline the things
}
...but a problem there is that I can't insert a box. I'm hoping that the box move is a perf win because I removed a box from ItemKind::Impl(noboxhere)
. Also I like the convenience of being able to bind the of_trait
object, but that's minor.
I don't think "trait ref" works because I think that term specifically means the part of the code that references a trait.
TraitImplHeader
seems alright to me. (Or maybe ImplTraitHeader
? But that kinda sounds like -> impl _
.)
I'll perf this due to the added indirection for impl "modifiers" + extra alloc + size changes. @bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Extract ImplOfTrait in AST/HIR
This comment has been minimized.
This comment has been minimized.
The job Click to see the possible cause of the failure (guessed by this bot)
|
I'll pause on fixing tests for now. |
☔ The latest upstream changes (presumably #144398) made this pull request unmergeable. Please resolve the merge conflicts. |
@bors try parent=last |
Extract ImplOfTrait in AST/HIR
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (e071e73): comparison URL. Overall result: ✅ improvements - no action neededBenchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf. @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary -0.6%, secondary 0.4%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary -3.4%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 468.258s -> 467.481s (-0.17%) |
@craterbot check |
👌 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
🚧 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
…only, r=compiler-errors Limit defaultness query to impl of trait I separated this out from rust-lang#144386.
🎉 Experiment
|
…ompiler-errors Limit defaultness query to impl of trait I separated this out from rust-lang/rust#144386.
Several fields of
Impl
are only applicable when it's a trait impl. This moves those fields into a new struct that is only present for trait impls.I also considered the name
ImplTrait
orTraitImpl
but I thought that might be more easily confused with-> impl _
. The variable nameof_trait
works nice since it is unique and you can infer what it means.