Skip to content

Commit b8bcc6d

Browse files
committed
propagate default
1 parent a1facdc commit b8bcc6d

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
@@ -1882,11 +1882,11 @@ pub struct MacroDef {
18821882
/// `true` if macro was defined with `macro_rules`.
18831883
pub macro_rules: bool,
18841884

1885-
pub eii_macro_for: Option<EiiMacroFor>,
1885+
pub eii_macro_for: Option<EIIMacroFor>,
18861886
}
18871887

18881888
#[derive(Clone, Encodable, Decodable, Debug, HashStable_Generic)]
1889-
pub struct EiiMacroFor {
1889+
pub struct EIIMacroFor {
18901890
pub extern_item_path: Path,
18911891
pub impl_unsafe: bool,
18921892
}
@@ -3488,6 +3488,7 @@ pub struct EIIImpl {
34883488
pub impl_safety: Safety,
34893489
pub span: Span,
34903490
pub inner_span: Span,
3491+
pub is_default: bool,
34913492
}
34923493

34933494
#[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
@@ -747,7 +747,7 @@ fn walk_mac<T: MutVisitor>(vis: &mut T, mac: &mut MacCall) {
747747

748748
fn walk_macro_def<T: MutVisitor>(vis: &mut T, macro_def: &mut MacroDef) {
749749
let MacroDef { body, macro_rules: _, eii_macro_for } = macro_def;
750-
if let Some(EiiMacroFor { extern_item_path, impl_unsafe: _ }) = eii_macro_for {
750+
if let Some(EIIMacroFor { extern_item_path, impl_unsafe: _ }) = eii_macro_for {
751751
vis.visit_path(extern_item_path);
752752
}
753753
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
@@ -440,7 +440,7 @@ impl WalkItemKind for ItemKind {
440440
ItemKind::MacCall(mac) => try_visit!(visitor.visit_mac_call(mac)),
441441
ItemKind::MacroDef(ts) => {
442442
try_visit!(visitor.visit_mac_def(ts, id));
443-
if let Some(EiiMacroFor { extern_item_path, impl_unsafe: _ }) = &ts.eii_macro_for {
443+
if let Some(EIIMacroFor { extern_item_path, impl_unsafe: _ }) = &ts.eii_macro_for {
444444
try_visit!(visitor.visit_path(extern_item_path, id));
445445
}
446446
}

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,15 @@ impl<'hir> LoweringContext<'_, 'hir> {
163163
match i {
164164
ItemKind::Fn(box Fn { eii_impl, .. }) => {
165165
let mut eii_impls = ThinVec::new();
166-
for EIIImpl { node_id, eii_macro_path, impl_safety, span, inner_span } in eii_impl {
166+
for EIIImpl {
167+
node_id,
168+
eii_macro_path,
169+
impl_safety,
170+
span,
171+
inner_span,
172+
is_default,
173+
} in eii_impl
174+
{
167175
let did = self.lower_path_simple_eii(*node_id, eii_macro_path);
168176
eii_impls.push(rustc_attr_parsing::EIIImpl {
169177
eii_macro: did,
@@ -172,13 +180,14 @@ impl<'hir> LoweringContext<'_, 'hir> {
172180
impl_marked_unsafe: self
173181
.lower_safety(*impl_safety, hir::Safety::Safe)
174182
.is_unsafe(),
183+
is_default: *is_default,
175184
})
176185
}
177186

178187
vec![hir::Attribute::Parsed(AttributeKind::EiiImpl(eii_impls))]
179188
}
180189
ItemKind::MacroDef(MacroDef {
181-
eii_macro_for: Some(EiiMacroFor { extern_item_path, impl_unsafe }),
190+
eii_macro_for: Some(EIIMacroFor { extern_item_path, impl_unsafe }),
182191
..
183192
}) => {
184193
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
@@ -465,7 +465,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
465465
_target_span: Span,
466466
target: Target,
467467
) {
468-
for EIIImpl { span, inner_span, eii_macro, impl_marked_unsafe } in impls {
468+
for EIIImpl { span, inner_span, eii_macro, impl_marked_unsafe, is_default: _ } in impls {
469469
match target {
470470
Target::Fn => {}
471471
_ => {

compiler/rustc_resolve/src/late.rs

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

2829-
if let Some(EiiMacroFor { extern_item_path, impl_unsafe: _ }) =
2829+
if let Some(EIIMacroFor { extern_item_path, impl_unsafe: _ }) =
28302830
&macro_def.eii_macro_for
28312831
{
28322832
self.smart_resolve_path(

0 commit comments

Comments
 (0)