Skip to content

Commit 533a279

Browse files
committed
make import.vis is not mutable
1 parent 93ea767 commit 533a279

File tree

8 files changed

+140
-50
lines changed

8 files changed

+140
-50
lines changed

Diff for: compiler/rustc_resolve/src/build_reduced_graph.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
281281
&segments,
282282
None,
283283
parent_scope,
284+
None,
284285
finalize.then(|| Finalize::new(id, path.span)),
285286
None,
286287
) {
@@ -372,7 +373,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
372373
has_attributes: !item.attrs.is_empty(),
373374
root_span,
374375
root_id,
375-
vis: Cell::new(Some(vis)),
376+
vis: Some(vis),
376377
used: Default::default(),
377378
});
378379

@@ -888,7 +889,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
888889
root_span: item.span,
889890
span: item.span,
890891
module_path: Vec::new(),
891-
vis: Cell::new(Some(vis)),
892+
vis: Some(vis),
892893
used: Cell::new(used.then_some(Used::Other)),
893894
});
894895
self.r.potentially_unused_imports.push(import);
@@ -1089,7 +1090,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
10891090
root_span: span,
10901091
span,
10911092
module_path: Vec::new(),
1092-
vis: Cell::new(Some(ty::Visibility::Restricted(CRATE_DEF_ID))),
1093+
vis: Some(ty::Visibility::Restricted(CRATE_DEF_ID)),
10931094
used: Default::default(),
10941095
})
10951096
};
@@ -1125,6 +1126,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
11251126
ident,
11261127
MacroNS,
11271128
&self.parent_scope,
1129+
None,
11281130
);
11291131
if let Ok(binding) = result {
11301132
let import = macro_use_import(self, ident.span, false);
@@ -1253,7 +1255,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
12531255
root_span: span,
12541256
span,
12551257
module_path: Vec::new(),
1256-
vis: Cell::new(Some(vis)),
1258+
vis: Some(vis),
12571259
used: Cell::new(Some(Used::Other)),
12581260
});
12591261
let import_binding = self.r.import(binding, import);
@@ -1369,7 +1371,6 @@ impl<'a, 'b, 'tcx> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b, 'tcx> {
13691371
self.parent_scope.module = orig_current_module;
13701372
self.parent_scope.macro_rules = orig_current_macro_rules_scope;
13711373
}
1372-
13731374
fn visit_assoc_item(&mut self, item: &'b AssocItem, ctxt: AssocCtxt) {
13741375
if let AssocItemKind::MacCall(_) = item.kind {
13751376
match ctxt {

Diff for: compiler/rustc_resolve/src/diagnostics.rs

+13-5
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ use crate::{
4444
errors as errs, path_names_to_string, AmbiguityError, AmbiguityErrorMisc, AmbiguityKind,
4545
BindingError, BindingKey, Finalize, HasGenericParams, LexicalScopeBinding, MacroRulesScope,
4646
Module, ModuleKind, ModuleOrUniformRoot, NameBinding, NameBindingKind, ParentScope, PathResult,
47-
PrivacyError, ResolutionError, Resolver, Scope, ScopeSet, Segment, UseError, Used,
47+
PrivacyError, ResolutionError, Resolver, Scope, ScopeSet, Segment, UseError, Used, UsedImport,
4848
VisResolutionError,
4949
};
5050

@@ -1050,6 +1050,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
10501050
derive,
10511051
Some(MacroKind::Derive),
10521052
parent_scope,
1053+
None,
10531054
false,
10541055
false,
10551056
) {
@@ -1504,6 +1505,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
15041505
ScopeSet::All(ns),
15051506
parent_scope,
15061507
None,
1508+
None,
15071509
false,
15081510
None,
15091511
) {
@@ -1981,6 +1983,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
19811983
path: &[Segment],
19821984
opt_ns: Option<Namespace>, // `None` indicates a module path in import
19831985
parent_scope: &ParentScope<'a>,
1986+
used_import: UsedImport<'a>,
19841987
ribs: Option<&PerNS<Vec<Rib<'a>>>>,
19851988
ignore_binding: Option<NameBinding<'a>>,
19861989
module: Option<ModuleOrUniformRoot<'a>>,
@@ -2064,6 +2067,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
20642067
ident,
20652068
ns_to_try,
20662069
parent_scope,
2070+
used_import,
20672071
None,
20682072
ignore_binding,
20692073
)
@@ -2075,6 +2079,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
20752079
ident,
20762080
ns_to_try,
20772081
parent_scope,
2082+
used_import,
20782083
None,
20792084
&ribs[ns_to_try],
20802085
ignore_binding,
@@ -2088,6 +2093,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
20882093
ident,
20892094
ScopeSet::All(ns_to_try),
20902095
parent_scope,
2096+
used_import,
20912097
None,
20922098
false,
20932099
ignore_binding,
@@ -2136,6 +2142,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
21362142
ident,
21372143
ValueNS,
21382144
parent_scope,
2145+
used_import,
21392146
None,
21402147
&ribs[ValueNS],
21412148
ignore_binding,
@@ -2203,6 +2210,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
22032210
ident,
22042211
ScopeSet::All(ValueNS),
22052212
parent_scope,
2213+
used_import,
22062214
None,
22072215
false,
22082216
ignore_binding,
@@ -2259,7 +2267,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
22592267
) -> Option<(Vec<Segment>, Option<String>)> {
22602268
// Replace first ident with `self` and check if that is valid.
22612269
path[0].ident.name = kw::SelfLower;
2262-
let result = self.maybe_resolve_path(&path, None, parent_scope);
2270+
let result = self.maybe_resolve_path(&path, None, parent_scope, None);
22632271
debug!("make_missing_self_suggestion: path={:?} result={:?}", path, result);
22642272
if let PathResult::Module(..) = result { Some((path, None)) } else { None }
22652273
}
@@ -2278,7 +2286,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
22782286
) -> Option<(Vec<Segment>, Option<String>)> {
22792287
// Replace first ident with `crate` and check if that is valid.
22802288
path[0].ident.name = kw::Crate;
2281-
let result = self.maybe_resolve_path(&path, None, parent_scope);
2289+
let result = self.maybe_resolve_path(&path, None, parent_scope, None);
22822290
debug!("make_missing_crate_suggestion: path={:?} result={:?}", path, result);
22832291
if let PathResult::Module(..) = result {
22842292
Some((
@@ -2309,7 +2317,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
23092317
) -> Option<(Vec<Segment>, Option<String>)> {
23102318
// Replace first ident with `crate` and check if that is valid.
23112319
path[0].ident.name = kw::Super;
2312-
let result = self.maybe_resolve_path(&path, None, parent_scope);
2320+
let result = self.maybe_resolve_path(&path, None, parent_scope, None);
23132321
debug!("make_missing_super_suggestion: path={:?} result={:?}", path, result);
23142322
if let PathResult::Module(..) = result { Some((path, None)) } else { None }
23152323
}
@@ -2343,7 +2351,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
23432351
for name in extern_crate_names.into_iter() {
23442352
// Replace first ident with a crate name and check if that is valid.
23452353
path[0].ident.name = name;
2346-
let result = self.maybe_resolve_path(&path, None, parent_scope);
2354+
let result = self.maybe_resolve_path(&path, None, parent_scope, None);
23472355
debug!(
23482356
"make_external_crate_suggestion: name={:?} path={:?} result={:?}",
23492357
name, path, result

0 commit comments

Comments
 (0)