Skip to content

Commit c728fde

Browse files
committed
propagate default
1 parent 1142a72 commit c728fde

File tree

8 files changed

+27
-13
lines changed

8 files changed

+27
-13
lines changed

compiler/rustc_ast/src/ast.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1874,11 +1874,11 @@ pub struct MacroDef {
18741874
/// `true` if macro was defined with `macro_rules`.
18751875
pub macro_rules: bool,
18761876

1877-
pub eii_macro_for: Option<EiiMacroFor>,
1877+
pub eii_macro_for: Option<EIIMacroFor>,
18781878
}
18791879

18801880
#[derive(Clone, Encodable, Decodable, Debug, HashStable_Generic)]
1881-
pub struct EiiMacroFor {
1881+
pub struct EIIMacroFor {
18821882
pub extern_item_path: Path,
18831883
pub impl_unsafe: bool,
18841884
}
@@ -3518,6 +3518,7 @@ pub struct EIIImpl {
35183518
pub impl_safety: Safety,
35193519
pub span: Span,
35203520
pub inner_span: Span,
3521+
pub is_default: bool,
35213522
}
35223523

35233524
#[derive(Clone, Encodable, Decodable, Debug)]

compiler/rustc_ast/src/mut_visit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ fn walk_mac<T: MutVisitor>(vis: &mut T, mac: &mut MacCall) {
751751

752752
fn walk_macro_def<T: MutVisitor>(vis: &mut T, macro_def: &mut MacroDef) {
753753
let MacroDef { body, macro_rules: _, eii_macro_for } = macro_def;
754-
if let Some(EiiMacroFor { extern_item_path, impl_unsafe: _ }) = eii_macro_for {
754+
if let Some(EIIMacroFor { extern_item_path, impl_unsafe: _ }) = eii_macro_for {
755755
vis.visit_path(extern_item_path);
756756
}
757757
visit_delim_args(vis, body);

compiler/rustc_ast/src/visit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ impl WalkItemKind for ItemKind {
460460
ItemKind::MacCall(mac) => try_visit!(visitor.visit_mac_call(mac)),
461461
ItemKind::MacroDef(ts) => {
462462
try_visit!(visitor.visit_mac_def(ts, id));
463-
if let Some(EiiMacroFor { extern_item_path, impl_unsafe: _ }) = &ts.eii_macro_for {
463+
if let Some(EIIMacroFor { extern_item_path, impl_unsafe: _ }) = &ts.eii_macro_for {
464464
try_visit!(visitor.visit_path(extern_item_path, id));
465465
}
466466
}

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,15 @@ impl<'hir> LoweringContext<'_, 'hir> {
157157
match i {
158158
ItemKind::Fn(box Fn { eii_impl, .. }) => {
159159
let mut eii_impls = ThinVec::new();
160-
for EIIImpl { node_id, eii_macro_path, impl_safety, span, inner_span } in eii_impl {
160+
for EIIImpl {
161+
node_id,
162+
eii_macro_path,
163+
impl_safety,
164+
span,
165+
inner_span,
166+
is_default,
167+
} in eii_impl
168+
{
161169
let did = self.lower_path_simple_eii(*node_id, eii_macro_path);
162170
eii_impls.push(rustc_attr_parsing::EIIImpl {
163171
eii_macro: did,
@@ -166,13 +174,14 @@ impl<'hir> LoweringContext<'_, 'hir> {
166174
impl_marked_unsafe: self
167175
.lower_safety(*impl_safety, hir::Safety::Safe)
168176
.is_unsafe(),
177+
is_default: *is_default,
169178
})
170179
}
171180

172181
vec![hir::Attribute::Parsed(AttributeKind::EiiImpl(eii_impls))]
173182
}
174183
ItemKind::MacroDef(MacroDef {
175-
eii_macro_for: Some(EiiMacroFor { extern_item_path, impl_unsafe }),
184+
eii_macro_for: Some(EIIMacroFor { extern_item_path, impl_unsafe }),
176185
..
177186
}) => {
178187
vec![hir::Attribute::Parsed(AttributeKind::EiiMacroFor {

compiler/rustc_attr_data_structures/src/attributes.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ pub struct EIIImpl {
145145
pub impl_marked_unsafe: bool,
146146
pub span: Span,
147147
pub inner_span: Span,
148+
pub is_default: bool,
148149
}
149150

150151
/// Represent parsed, *built in*, inert attributes.

compiler/rustc_builtin_macros/src/eii.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
use rustc_ast::{DUMMY_NODE_ID, EIIImpl, EiiMacroFor, ItemKind, ast};
1+
use rustc_ast::{
2+
DUMMY_NODE_ID, DUMMY_NODE_ID, EIIImpl, EIIImpl, EIIMacroFor, EiiMacroFor, ItemKind, ItemKind,
3+
ast, ast,
4+
};
25
use rustc_ast_pretty::pprust::path_to_string;
36
use rustc_expand::base::{Annotatable, ExtCtxt};
4-
use rustc_span::{Span, kw};
7+
use rustc_span::{Span, Span, kw, kw};
58

69
use crate::errors::{
710
EIIMacroExpectedFunction, EIIMacroExpectedMaxOneArgument, EIIMacroForExpectedList,
@@ -50,7 +53,7 @@ pub(crate) fn eii_macro_for(
5053
false
5154
};
5255

53-
d.eii_macro_for = Some(EiiMacroFor { extern_item_path, impl_unsafe });
56+
d.eii_macro_for = Some(EIIMacroFor { extern_item_path, impl_unsafe });
5457

5558
// Return the original item and the new methods.
5659
vec![item]
@@ -94,8 +97,8 @@ pub(crate) fn eii_macro(
9497
eii_macro_path: meta_item.path.clone(),
9598
impl_safety: meta_item.unsafety,
9699
span,
97-
inner_span: meta_item.span,
98-
is_default: false,
100+
inner_span: meta_item.path.span,
101+
is_default,
99102
});
100103

101104
vec![item]

compiler/rustc_passes/src/check_attr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
467467
_target_span: Span,
468468
target: Target,
469469
) {
470-
for EIIImpl { span, inner_span, eii_macro, impl_marked_unsafe } in impls {
470+
for EIIImpl { span, inner_span, eii_macro, impl_marked_unsafe, is_default: _ } in impls {
471471
match target {
472472
Target::Fn => {}
473473
_ => {

compiler/rustc_resolve/src/late.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2843,7 +2843,7 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
28432843
self.parent_scope.macro_rules = self.r.macro_rules_scopes[&def_id];
28442844
}
28452845

2846-
if let Some(EiiMacroFor { extern_item_path, impl_unsafe: _ }) =
2846+
if let Some(EIIMacroFor { extern_item_path, impl_unsafe: _ }) =
28472847
&macro_def.eii_macro_for
28482848
{
28492849
self.smart_resolve_path(

0 commit comments

Comments
 (0)