Skip to content

Commit 745de6e

Browse files
committed
Auto merge of #162456 - JonathanBrouwer:rollup-bpMVYlc, r=JonathanBrouwer
Rollup of 2 pull requests Successful merges: - #162433 (Forward CfgTrace attributes on EII items) - #162447 (Fix myself on .mailmap once and for all)
2 parents a3e94c2 + 46f0fdd commit 745de6e

5 files changed

Lines changed: 142 additions & 27 deletions

File tree

.mailmap

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,8 @@ bjorn3 <17426603+bjorn3@users.noreply.github.com> <bjorn3@users.noreply.github.c
9090
bjorn3 <17426603+bjorn3@users.noreply.github.com> <bjorn3_gh@protonmail.com>
9191
Björn Steinbrink <bsteinbr@gmail.com> <B.Steinbrink@gmx.de>
9292
blake2-ppc <ulrik.sverdrup@gmail.com> <blake2-ppc>
93-
Alejandra González <blyxyas@goose.love> blyxyas <blyxyas@gmail.com>
94-
Alejandra González <blyxyas@goose.love> blyxyas <blyxyas@goose.love>
95-
Alejandra González <blyxyas@goose.love> Alejandra González <blyxyas@gmail.com>
93+
Alejandra González <blyxyas@goose.love> <blyxyas@gmail.com>
94+
Alejandra González <blyxyas@goose.love> <blyxyas@goose.love>
9695
boolean_coercion <booleancoercion@gmail.com>
9796
Boris Egorov <jightuse@gmail.com> <egorov@linux.com>
9897
bors <bors@rust-lang.org> bors[bot] <26634292+bors[bot]@users.noreply.github.com>

compiler/rustc_builtin_macros/src/eii.rs

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use rustc_ast::token::{Delimiter, TokenKind};
22
use rustc_ast::tokenstream::{DelimSpacing, DelimSpan, Spacing, TokenStream, TokenTree};
33
use rustc_ast::{
4-
Attribute, DUMMY_NODE_ID, EiiDecl, EiiImpl, ItemKind, MetaItem, Mutability, Path, StmtKind,
5-
Visibility, ast,
4+
AttrKind, Attribute, DUMMY_NODE_ID, EiiDecl, EiiImpl, ItemKind, MetaItem, Mutability, Path,
5+
StmtKind, SyntheticAttr, Visibility, ast,
66
};
77
use rustc_ast_pretty::pprust::path_to_string;
88
use rustc_expand::base::{Annotatable, ExtCtxt};
@@ -200,37 +200,47 @@ fn split_attrs(
200200
let mut foreign_item_attributes = ThinVec::new();
201201

202202
for attr in attrs {
203-
match attr.name() {
204-
// If an eii is marked a lang item, that's because we want to call its declaration, so
205-
// mark the foreign item as the lang item
206-
Some(sym::lang) => foreign_item_attributes.push(attr),
207-
// Deprecating an eii means deprecating the macro and the foreign item
208-
Some(sym::deprecated) => {
203+
match &attr.kind {
204+
// Forward synthetic CfgTrace and CfgAttrTrace, these are applicable to both foreign item and macro.
205+
AttrKind::Synthetic(SyntheticAttr::CfgTrace(_) | SyntheticAttr::CfgAttrTrace(_)) => {
209206
foreign_item_attributes.push(attr.clone());
210207
macro_attributes.push(attr);
211208
}
212-
// The stability of an EII affects the usage of the macro and calling the foreign item
213-
Some(sym::stable) | Some(sym::unstable) => {
214-
foreign_item_attributes.push(attr.clone());
215-
macro_attributes.push(attr);
216-
}
217-
// `#[track_caller]` goes on the foreign item only: it's the symbol callers link
218-
// against, so it must carry the flag for call sites to pass the caller location.
219-
// Implementations derive it during codegen (see `EiiImpls` in `codegen_attrs.rs`),
220-
// so it must not be routed onto the default impl here.
221-
Some(sym::track_caller) => {
222-
foreign_item_attributes.push(attr);
223-
}
224209
// Doc attributes should be forwarded to the macro and the foreign item, since those are
225210
// the two items you interact with as a user.
226211
// FIXME: idk yet how EIIs show up in docs, might want to customize
227-
_ if attr.is_doc_comment() => {
212+
AttrKind::DocComment(_, _) => {
228213
foreign_item_attributes.push(attr.clone());
229214
macro_attributes.push(attr);
230215
}
231-
Some(sym::eii) => unreachable!("should already be filtered out"),
232-
_ => {
233-
ecx.dcx().emit_err(EiiAttributeNotSupported { span, attr_span: attr.span() });
216+
AttrKind::Normal(normal) => {
217+
match normal.item.name() {
218+
// If an eii is marked a lang item, that's because we want to call its declaration, so
219+
// mark the foreign item as the lang item
220+
Some(sym::lang) => foreign_item_attributes.push(attr),
221+
// Deprecating an eii means deprecating the macro and the foreign item
222+
Some(sym::deprecated) => {
223+
foreign_item_attributes.push(attr.clone());
224+
macro_attributes.push(attr);
225+
}
226+
// The stability of an EII affects the usage of the macro and calling the foreign item
227+
Some(sym::stable) | Some(sym::unstable) => {
228+
foreign_item_attributes.push(attr.clone());
229+
macro_attributes.push(attr);
230+
}
231+
// `#[track_caller]` goes on the foreign item only: it's the symbol callers link
232+
// against, so it must carry the flag for call sites to pass the caller location.
233+
// Implementations derive it during codegen (see `EiiImpls` in `codegen_attrs.rs`),
234+
// so it must not be routed onto the default impl here.
235+
Some(sym::track_caller) => {
236+
foreign_item_attributes.push(attr);
237+
}
238+
Some(sym::eii) => unreachable!("should already be filtered out"),
239+
_ => {
240+
ecx.dcx()
241+
.emit_err(EiiAttributeNotSupported { span, attr_span: attr.span() });
242+
}
243+
}
234244
}
235245
}
236246
}

tests/ui/eii/cfg_on_eii.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//@ compile-flags: -Z unpretty=hir,typed
2+
3+
#![feature(extern_item_impls)]
4+
#![deny(deprecated)] //~ NOTE:
5+
6+
#[cfg(true)]
7+
#[eii]
8+
fn cfg_on_eii() {}
9+
10+
#[cfg_attr(true, eii)]
11+
fn conditional_eii() {}
12+
13+
#[cfg_attr(true, deprecated = "bar")]
14+
#[eii]
15+
fn cfg_attr_on_eii() {}
16+
17+
fn main() {
18+
cfg_attr_on_eii();
19+
//~^ ERROR use of deprecated function
20+
}

tests/ui/eii/cfg_on_eii.stderr

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error: use of deprecated function `cfg_attr_on_eii`: bar
2+
--> $DIR/cfg_on_eii.rs:18:5
3+
|
4+
LL | cfg_attr_on_eii();
5+
| ^^^^^^^^^^^^^^^
6+
|
7+
note: the lint level is defined here
8+
--> $DIR/cfg_on_eii.rs:4:9
9+
|
10+
LL | #![deny(deprecated)]
11+
| ^^^^^^^^^^
12+
13+
error: aborting due to 1 previous error
14+

tests/ui/eii/cfg_on_eii.stdout

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
//@ compile-flags: -Z unpretty=hir,typed
2+
3+
#![deny(deprecated)]
4+
#![attr = Feature([extern_item_impls#0])]
5+
extern crate std;
6+
#[attr = PreludeImport]
7+
use ::std::prelude::rust_2015::*;
8+
9+
const _: () =
10+
({
11+
#[attr = EiiImpl(EiiImpl {resolution: Known(DefId(0:7 ~ cfg_on_eii[fec6]::{extern#0}::cfg_on_eii)),
12+
is_default: true})]
13+
fn cfg_on_eii() ({ } as ())
14+
} as ());
15+
extern "Rust" {
16+
#[attr = CfgTrace([Bool(true, $DIR/cfg_on_eii.rs:6:7: 6:11 (#0))])]
17+
#[attr = RustcEiiForeignItem]
18+
fn cfg_on_eii();
19+
}
20+
#[attr = CfgTrace([Bool(true, $DIR/cfg_on_eii.rs:6:7: 6:11 (#0))])]
21+
#[attr = RustcMacroTransparency(SemiOpaque)]
22+
#[attr = RustcBuiltinMacro {builtin_name: "eii_shared_macro",
23+
helper_attrs: []}]
24+
#[attr = EiiDeclaration(EiiDecl {foreign_item: DefId(0:7 ~ cfg_on_eii[fec6]::{extern#0}::cfg_on_eii),
25+
impl_unsafe: false, name: cfg_on_eii#0})]
26+
macro cfg_on_eii { () => {} }
27+
28+
const _: () =
29+
({
30+
#[attr = EiiImpl(EiiImpl {resolution: Known(DefId(0:12 ~ cfg_on_eii[fec6]::{extern#1}::conditional_eii)),
31+
is_default: true})]
32+
fn conditional_eii() ({ } as ())
33+
} as ());
34+
extern "Rust" {
35+
#[attr = CfgAttrTrace([Bool(true, $DIR/cfg_on_eii.rs:10:12: 10:16 (#0))])]
36+
#[attr = RustcEiiForeignItem]
37+
fn conditional_eii();
38+
}
39+
#[attr = CfgAttrTrace([Bool(true, $DIR/cfg_on_eii.rs:10:12: 10:16 (#0))])]
40+
#[attr = RustcMacroTransparency(SemiOpaque)]
41+
#[attr = RustcBuiltinMacro {builtin_name: "eii_shared_macro",
42+
helper_attrs: []}]
43+
#[attr = EiiDeclaration(EiiDecl {foreign_item: DefId(0:12 ~ cfg_on_eii[fec6]::{extern#1}::conditional_eii),
44+
impl_unsafe: false, name: conditional_eii#0})]
45+
macro conditional_eii { () => {} }
46+
47+
const _: () =
48+
({
49+
#[attr = EiiImpl(EiiImpl {resolution: Known(DefId(0:17 ~ cfg_on_eii[fec6]::{extern#2}::cfg_attr_on_eii)),
50+
is_default: true})]
51+
fn cfg_attr_on_eii() ({ } as ())
52+
} as ());
53+
extern "Rust" {
54+
#[attr = CfgAttrTrace([Bool(true, $DIR/cfg_on_eii.rs:13:12: 13:16 (#0))])]
55+
#[attr = Deprecated {deprecation: Deprecation {since: Unspecified,
56+
note: bar#0}}]
57+
#[attr = RustcEiiForeignItem]
58+
fn cfg_attr_on_eii();
59+
}
60+
#[attr = CfgAttrTrace([Bool(true, $DIR/cfg_on_eii.rs:13:12: 13:16 (#0))])]
61+
#[attr = Deprecated {deprecation: Deprecation {since: Unspecified,
62+
note: bar#0}}]
63+
#[attr = RustcMacroTransparency(SemiOpaque)]
64+
#[attr = RustcBuiltinMacro {builtin_name: "eii_shared_macro",
65+
helper_attrs: []}]
66+
#[attr = EiiDeclaration(EiiDecl {foreign_item: DefId(0:17 ~ cfg_on_eii[fec6]::{extern#2}::cfg_attr_on_eii),
67+
impl_unsafe: false, name: cfg_attr_on_eii#0})]
68+
macro cfg_attr_on_eii { () => {} }
69+
70+
fn main() ({
71+
((cfg_attr_on_eii as fn() {cfg_attr_on_eii})() as ());
72+
} as ())

0 commit comments

Comments
 (0)