1
Fork 0
rust/compiler/rustc_middle/src
Guillaume Boisseau 5ff9022306
Rollup merge of #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.
2024-02-17 11:23:04 +01:00
..
dep_graph Reduce exposure of things. 2023-11-16 16:49:22 +11:00
hir Properly handle async blocks and fns in if exprs without else 2024-02-12 20:26:34 +00:00
hooks Rename hook. 2023-11-01 16:49:18 +00:00
infer Dejargnonize subst 2024-02-12 15:46:35 +09:00
middle Replace NonZero::<_>::new with NonZero::new. 2024-02-15 08:09:42 +01:00
mir Rollup merge of #121179 - RalfJung:zst-mutable-refs, r=oli-obk 2024-02-16 17:08:13 +01:00
query Auto merge of #120500 - oli-obk:intrinsics2.0, r=WaffleLapkin 2024-02-16 09:53:01 +00:00
thir Remove thir::Guard 2024-01-05 10:56:59 +00:00
traits Remove a suggestion that is redundant 2024-02-15 17:20:44 +00:00
ty Move trait into attr so it's greppable 2024-02-16 15:07:37 +00:00
util Tweak delayed bug mentions. 2024-02-12 18:39:20 +11:00
arena.rs Rollup merge of #119600 - aDotInTheVoid:comment-fix, r=compiler-errors 2024-02-05 06:37:14 +01:00
error.rs Use DiagnosticArgName in a few more places. 2024-02-03 09:02:50 +11:00
lib.rs Use generic NonZero internally. 2024-02-15 08:09:42 +01:00
lint.rs Do not point at #[allow(_)] as the reason for compat lint triggering 2024-02-13 20:27:43 +00:00
macros.rs Remove Session methods that duplicate DiagCtxt methods. 2023-12-24 08:05:28 +11:00
metadata.rs rustc_metadata: Remove Span from ModChild 2023-04-18 17:25:04 +03:00
tests.rs Remove outdated references to librustc_middle. 2024-01-05 16:34:52 +00:00
thir.rs Remove dead args from functions 2024-02-02 22:47:26 +00:00
values.rs Stop using String for error codes. 2024-01-29 07:41:41 +11:00