Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 950a966

Browse files
authored
Unrolled build for #148808
Rollup merge of #148808 - nnethercote:resolve-cleanups, r=chenyukang,petrochenkov Some resolve cleanups Minor improvements I found while looking over this code. r? ```````@petrochenkov```````
2 parents 6d41834 + b728064 commit 950a966

File tree

3 files changed

+23
-36
lines changed

3 files changed

+23
-36
lines changed

compiler/rustc_expand/src/base.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,6 +1099,9 @@ pub struct Indeterminate;
10991099
pub struct DeriveResolution {
11001100
pub path: ast::Path,
11011101
pub item: Annotatable,
1102+
// FIXME: currently this field is only used in `is_none`/`is_some` conditions. However, the
1103+
// `Arc<SyntaxExtension>` will be used if the FIXME in `MacroExpander::fully_expand_fragment`
1104+
// is completed.
11021105
pub exts: Option<Arc<SyntaxExtension>>,
11031106
pub is_const: bool,
11041107
}

compiler/rustc_resolve/src/ident.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -458,14 +458,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
458458
let mut result = Err(Determinacy::Determined);
459459
for derive in parent_scope.derives {
460460
let parent_scope = &ParentScope { derives: &[], ..*parent_scope };
461-
match this.reborrow().resolve_macro_path(
461+
match this.reborrow().resolve_derive_macro_path(
462462
derive,
463-
MacroKind::Derive,
464463
parent_scope,
465-
true,
466464
force,
467465
ignore_import,
468-
None,
469466
) {
470467
Ok((Some(ext), _)) => {
471468
if ext.helper_attrs.contains(&ident.name) {

compiler/rustc_resolve/src/macros.rs

Lines changed: 19 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -396,14 +396,11 @@ impl<'ra, 'tcx> ResolverExpand for Resolver<'ra, 'tcx> {
396396
for (i, resolution) in entry.resolutions.iter_mut().enumerate() {
397397
if resolution.exts.is_none() {
398398
resolution.exts = Some(
399-
match self.cm().resolve_macro_path(
399+
match self.cm().resolve_derive_macro_path(
400400
&resolution.path,
401-
MacroKind::Derive,
402401
&parent_scope,
403-
true,
404402
force,
405403
None,
406-
None,
407404
) {
408405
Ok((Some(ext), _)) => {
409406
if !ext.helper_attrs.is_empty() {
@@ -571,7 +568,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
571568
path,
572569
kind,
573570
parent_scope,
574-
true,
575571
force,
576572
deleg_impl,
577573
invoc_in_mod_inert_attr.map(|def_id| (def_id, node_id)),
@@ -713,26 +709,22 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
713709
Ok((ext, res))
714710
}
715711

716-
pub(crate) fn resolve_macro_path<'r>(
712+
pub(crate) fn resolve_derive_macro_path<'r>(
717713
self: CmResolver<'r, 'ra, 'tcx>,
718714
path: &ast::Path,
719-
kind: MacroKind,
720715
parent_scope: &ParentScope<'ra>,
721-
trace: bool,
722716
force: bool,
723717
ignore_import: Option<Import<'ra>>,
724-
suggestion_span: Option<Span>,
725718
) -> Result<(Option<Arc<SyntaxExtension>>, Res), Determinacy> {
726719
self.resolve_macro_or_delegation_path(
727720
path,
728-
kind,
721+
MacroKind::Derive,
729722
parent_scope,
730-
trace,
731723
force,
732724
None,
733725
None,
734726
ignore_import,
735-
suggestion_span,
727+
None,
736728
)
737729
}
738730

@@ -741,7 +733,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
741733
ast_path: &ast::Path,
742734
kind: MacroKind,
743735
parent_scope: &ParentScope<'ra>,
744-
trace: bool,
745736
force: bool,
746737
deleg_impl: Option<LocalDefId>,
747738
invoc_in_mod_inert_attr: Option<(LocalDefId, NodeId)>,
@@ -780,16 +771,14 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
780771
PathResult::Module(..) => unreachable!(),
781772
};
782773

783-
if trace {
784-
self.multi_segment_macro_resolutions.borrow_mut(&self).push((
785-
path,
786-
path_span,
787-
kind,
788-
*parent_scope,
789-
res.ok(),
790-
ns,
791-
));
792-
}
774+
self.multi_segment_macro_resolutions.borrow_mut(&self).push((
775+
path,
776+
path_span,
777+
kind,
778+
*parent_scope,
779+
res.ok(),
780+
ns,
781+
));
793782

794783
self.prohibit_imported_non_macro_attrs(None, res.ok(), path_span);
795784
res
@@ -807,15 +796,13 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
807796
return Err(Determinacy::Undetermined);
808797
}
809798

810-
if trace {
811-
self.single_segment_macro_resolutions.borrow_mut(&self).push((
812-
path[0].ident,
813-
kind,
814-
*parent_scope,
815-
binding.ok(),
816-
suggestion_span,
817-
));
818-
}
799+
self.single_segment_macro_resolutions.borrow_mut(&self).push((
800+
path[0].ident,
801+
kind,
802+
*parent_scope,
803+
binding.ok(),
804+
suggestion_span,
805+
));
819806

820807
let res = binding.map(|binding| binding.res());
821808
self.prohibit_imported_non_macro_attrs(binding.ok(), res.ok(), path_span);

0 commit comments

Comments
 (0)