Add and use a simple extension trait derive macro in the compiler#121059
Merged
bors merged 4 commits intorust-lang:masterfrom Feb 17, 2024
Merged
Add and use a simple extension trait derive macro in the compiler#121059bors merged 4 commits intorust-lang:masterfrom
bors merged 4 commits intorust-lang:masterfrom
Conversation
Collaborator
|
r? @davidtwco rustbot has assigned @davidtwco. Use r? to explicitly pick a reviewer |
Collaborator
|
Some changes occurred in engine.rs, potentially modifying the public API of Some changes occurred to the core trait solver cc @rust-lang/initiative-trait-system-refactor |
Noratrieb
reviewed
Feb 14, 2024
f2f013a to
0939882
Compare
This comment was marked as resolved.
This comment was marked as resolved.
Noratrieb
reviewed
Feb 16, 2024
0939882 to
f624d55
Compare
davidtwco
approved these changes
Feb 16, 2024
Member
|
cool shit, errs |
Collaborator
Nadrieril
added a commit
to Nadrieril/rust
that referenced
this pull request
Feb 17, 2024
…twco,Nilstrieb
Add and use a simple extension trait derive macro in the compiler
Adds `#[extension]` to `rustc_macros` for implementing an extension trait. This expands an impl (with an optional visibility) into two parallel trait + impl definitions.
before:
```rust
pub trait Extension {
fn a();
}
impl Extension for () {
fn a() {}
}
```
to:
```rust
#[extension]
pub impl Extension for () {
fn a() {}
}
```
Opted to just implement it by hand because I couldn't figure if there was a "canonical" choice of extension trait macro in the ecosystem. It's really lightweight anyways, and can always be changed.
I'm interested in adding this because I'd like to later split up the large `TypeErrCtxtExt` traits into several different files. This should make it one step easier.
This was referenced Feb 17, 2024
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Feb 17, 2024
Rollup of 8 pull requests Successful merges: - rust-lang#119032 (Use a hardcoded constant instead of calling OpenProcessToken.) - rust-lang#120932 (const_mut_refs: allow mutable pointers to statics) - rust-lang#121059 (Add and use a simple extension trait derive macro in the compiler) - rust-lang#121135 (coverage: Discard spans that fill the entire function body) - rust-lang#121187 (Add examples to document the return type of quickselect functions) - rust-lang#121191 (Add myself to review rotation (and a rustbot ping)) - rust-lang#121192 (Give some intrinsics fallback bodies) - rust-lang#121197 (Ensure `./configure` works when `configure.py` path contains spaces) r? `@ghost` `@rustbot` modify labels: rollup
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Feb 17, 2024
Rollup merge of rust-lang#121059 - compiler-errors:extension, r=davidtwco,Nilstrieb Add and use a simple extension trait derive macro in the compiler Adds `#[extension]` to `rustc_macros` for implementing an extension trait. This expands an impl (with an optional visibility) into two parallel trait + impl definitions. before: ```rust pub trait Extension { fn a(); } impl Extension for () { fn a() {} } ``` to: ```rust #[extension] pub impl Extension for () { fn a() {} } ``` Opted to just implement it by hand because I couldn't figure if there was a "canonical" choice of extension trait macro in the ecosystem. It's really lightweight anyways, and can always be changed. I'm interested in adding this because I'd like to later split up the large `TypeErrCtxtExt` traits into several different files. This should make it one step easier.
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.
Adds
#[extension]torustc_macrosfor implementing an extension trait. This expands an impl (with an optional visibility) into two parallel trait + impl definitions.before:
to:
Opted to just implement it by hand because I couldn't figure if there was a "canonical" choice of extension trait macro in the ecosystem. It's really lightweight anyways, and can always be changed.
I'm interested in adding this because I'd like to later split up the large
TypeErrCtxtExttraits into several different files. This should make it one step easier.