Skip to content

Commit 5b9007b

Browse files
committed
Auto merge of #147054 - matthiaskrgr:rollup-660g92w, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #146283 (Resolve: (Ref)Cell wrappers to deny mutation during spec resolution.) - #146453 (Add general arm-linux.md platform doc.) - #146991 (const_caller_location to use real Span instead of `DUMMY_SP`) - #146994 (Add `clippy::unconditional_recursion` to `./x clippy ci`) - #147038 (Rename verbosity functions in bootstrap) - #147047 (rustdoc: put the toolbar on the all item index) - #147049 (std: fix warning in VEXos stdio module) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 40ace17 + 87b8eca commit 5b9007b

File tree

31 files changed

+445
-107
lines changed

31 files changed

+445
-107
lines changed

compiler/rustc_const_eval/src/util/caller_location.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pub(crate) fn const_caller_location_provider(
6161
trace!("const_caller_location: {}:{}:{}", file, line, col);
6262
let mut ecx = mk_eval_cx_to_read_const_val(
6363
tcx,
64-
rustc_span::DUMMY_SP, // FIXME: use a proper span here?
64+
rustc_span::DUMMY_SP, // This interpreter cannot fail, so the span is irrelevant.
6565
ty::TypingEnv::fully_monomorphized(),
6666
CanAccessMutGlobal::No,
6767
);

compiler/rustc_resolve/src/build_reduced_graph.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
//! unexpanded macros in the fragment are visited and registered.
66
//! Imports are also considered items and placed into modules here, but not resolved yet.
77
8-
use std::cell::Cell;
98
use std::sync::Arc;
109

1110
use rustc_ast::visit::{self, AssocCtxt, Visitor, WalkItemKind};
@@ -35,6 +34,7 @@ use crate::Namespace::{MacroNS, TypeNS, ValueNS};
3534
use crate::def_collector::collect_definitions;
3635
use crate::imports::{ImportData, ImportKind};
3736
use crate::macros::{MacroRulesBinding, MacroRulesScope, MacroRulesScopeRef};
37+
use crate::ref_mut::CmCell;
3838
use crate::{
3939
BindingKey, ExternPreludeEntry, Finalize, MacroData, Module, ModuleKind, ModuleOrUniformRoot,
4040
NameBinding, ParentScope, PathResult, ResolutionError, Resolver, Segment, Used,
@@ -87,7 +87,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
8787
// because they can be fetched by glob imports from those modules, and bring traits
8888
// into scope both directly and through glob imports.
8989
let key = BindingKey::new_disambiguated(ident, ns, || {
90-
parent.underscore_disambiguator.update(|d| d + 1);
90+
// FIXME(batched): Will be fixed in batched resolution.
91+
parent.underscore_disambiguator.update_unchecked(|d| d + 1);
9192
parent.underscore_disambiguator.get()
9293
});
9394
if self
@@ -477,7 +478,7 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
477478
kind,
478479
parent_scope: self.parent_scope,
479480
module_path,
480-
imported_module: Cell::new(None),
481+
imported_module: CmCell::new(None),
481482
span,
482483
use_span: item.span,
483484
use_span_with_attributes: item.span_with_attributes(),
@@ -505,7 +506,7 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
505506
});
506507
}
507508
}
508-
ImportKind::Glob { .. } => current_module.globs.borrow_mut().push(import),
509+
ImportKind::Glob { .. } => current_module.globs.borrow_mut(self.r).push(import),
509510
_ => unreachable!(),
510511
}
511512
}
@@ -668,7 +669,7 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
668669
}
669670
ast::UseTreeKind::Glob => {
670671
if !ast::attr::contains_name(&item.attrs, sym::prelude_import) {
671-
let kind = ImportKind::Glob { max_vis: Cell::new(None), id };
672+
let kind = ImportKind::Glob { max_vis: CmCell::new(None), id };
672673
self.add_import(prefix, kind, use_tree.span, item, root_span, item.id, vis);
673674
} else {
674675
// Resolve the prelude import early.
@@ -971,7 +972,7 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
971972
kind: ImportKind::ExternCrate { source: orig_name, target: ident, id: item.id },
972973
root_id: item.id,
973974
parent_scope: self.parent_scope,
974-
imported_module: Cell::new(module),
975+
imported_module: CmCell::new(module),
975976
has_attributes: !item.attrs.is_empty(),
976977
use_span_with_attributes: item.span_with_attributes(),
977978
use_span: item.span,
@@ -1103,7 +1104,7 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
11031104
kind: ImportKind::MacroUse { warn_private },
11041105
root_id: item.id,
11051106
parent_scope: this.parent_scope,
1106-
imported_module: Cell::new(Some(ModuleOrUniformRoot::Module(module))),
1107+
imported_module: CmCell::new(Some(ModuleOrUniformRoot::Module(module))),
11071108
use_span_with_attributes: item.span_with_attributes(),
11081109
has_attributes: !item.attrs.is_empty(),
11091110
use_span: item.span,
@@ -1196,7 +1197,7 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
11961197
/// directly into its parent scope's module.
11971198
fn visit_invoc_in_module(&mut self, id: NodeId) -> MacroRulesScopeRef<'ra> {
11981199
let invoc_id = self.visit_invoc(id);
1199-
self.parent_scope.module.unexpanded_invocations.borrow_mut().insert(invoc_id);
1200+
self.parent_scope.module.unexpanded_invocations.borrow_mut(self.r).insert(invoc_id);
12001201
self.r.arenas.alloc_macro_rules_scope(MacroRulesScope::Invocation(invoc_id))
12011202
}
12021203

@@ -1274,7 +1275,7 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
12741275
kind: ImportKind::MacroExport,
12751276
root_id: item.id,
12761277
parent_scope: self.parent_scope,
1277-
imported_module: Cell::new(None),
1278+
imported_module: CmCell::new(None),
12781279
has_attributes: false,
12791280
use_span_with_attributes: span,
12801281
use_span: span,

compiler/rustc_resolve/src/imports.rs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//! A bunch of methods and structures more or less related to resolving imports.
22
3-
use std::cell::Cell;
43
use std::mem;
54

65
use rustc_ast::NodeId;
@@ -32,6 +31,7 @@ use crate::errors::{
3231
CannotBeReexportedPrivateNS, CannotDetermineImportResolution, CannotGlobImportAllCrates,
3332
ConsiderAddingMacroExport, ConsiderMarkingAsPub, ConsiderMarkingAsPubCrate,
3433
};
34+
use crate::ref_mut::CmCell;
3535
use crate::{
3636
AmbiguityError, AmbiguityKind, BindingKey, CmResolver, Determinacy, Finalize, ImportSuggestion,
3737
Module, ModuleOrUniformRoot, NameBinding, NameBindingData, NameBindingKind, ParentScope,
@@ -68,7 +68,7 @@ pub(crate) enum ImportKind<'ra> {
6868
/// It will directly use `source` when the format is `use prefix::source`.
6969
target: Ident,
7070
/// Bindings introduced by the import.
71-
bindings: PerNS<Cell<PendingBinding<'ra>>>,
71+
bindings: PerNS<CmCell<PendingBinding<'ra>>>,
7272
/// `true` for `...::{self [as target]}` imports, `false` otherwise.
7373
type_ns_only: bool,
7474
/// Did this import result from a nested import? ie. `use foo::{bar, baz};`
@@ -89,7 +89,7 @@ pub(crate) enum ImportKind<'ra> {
8989
Glob {
9090
// The visibility of the greatest re-export.
9191
// n.b. `max_vis` is only used in `finalize_import` to check for re-export errors.
92-
max_vis: Cell<Option<Visibility>>,
92+
max_vis: CmCell<Option<Visibility>>,
9393
id: NodeId,
9494
},
9595
ExternCrate {
@@ -182,7 +182,7 @@ pub(crate) struct ImportData<'ra> {
182182
/// |`use ::foo` | `ModuleOrUniformRoot::ExternPrelude` | 2018+ editions |
183183
/// |`use ::foo` | `ModuleOrUniformRoot::ModuleAndExternPrelude` | a special case in 2015 edition |
184184
/// |`use foo` | `ModuleOrUniformRoot::CurrentScope` | - |
185-
pub imported_module: Cell<Option<ModuleOrUniformRoot<'ra>>>,
185+
pub imported_module: CmCell<Option<ModuleOrUniformRoot<'ra>>>,
186186
pub vis: Visibility,
187187

188188
/// Span of the visibility.
@@ -320,7 +320,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
320320
&& (vis == import_vis
321321
|| max_vis.get().is_none_or(|max_vis| vis.is_at_least(max_vis, self.tcx)))
322322
{
323-
max_vis.set(Some(vis.expect_local()))
323+
// FIXME(batched): Will be fixed in batched import resolution.
324+
max_vis.set_unchecked(Some(vis.expect_local()))
324325
}
325326

326327
self.arenas.alloc_name_binding(NameBindingData {
@@ -349,7 +350,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
349350
// because they can be fetched by glob imports from those modules, and bring traits
350351
// into scope both directly and through glob imports.
351352
let key = BindingKey::new_disambiguated(ident, ns, || {
352-
module.underscore_disambiguator.update(|d| d + 1);
353+
// FIXME(batched): Will be fixed in batched resolution.
354+
module.underscore_disambiguator.update_unchecked(|d| d + 1);
353355
module.underscore_disambiguator.get()
354356
});
355357
self.update_local_resolution(module, key, warn_ambiguity, |this, resolution| {
@@ -482,7 +484,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
482484
}
483485
};
484486

485-
let Ok(glob_importers) = module.glob_importers.try_borrow_mut() else {
487+
let Ok(glob_importers) = module.glob_importers.try_borrow_mut_unchecked() else {
486488
return t;
487489
};
488490

@@ -862,7 +864,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
862864
}
863865
};
864866

865-
import.imported_module.set(Some(module));
867+
// FIXME(batched): Will be fixed in batched import resolution.
868+
import.imported_module.set_unchecked(Some(module));
866869
let (source, target, bindings, type_ns_only) = match import.kind {
867870
ImportKind::Single { source, target, ref bindings, type_ns_only, .. } => {
868871
(source, target, bindings, type_ns_only)
@@ -937,7 +940,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
937940
PendingBinding::Pending
938941
}
939942
};
940-
bindings[ns].set(binding);
943+
// FIXME(batched): Will be fixed in batched import resolution.
944+
bindings[ns].set_unchecked(binding);
941945
}
942946
});
943947

@@ -1508,7 +1512,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
15081512
}
15091513

15101514
// Add to module's glob_importers
1511-
module.glob_importers.borrow_mut().push(import);
1515+
module.glob_importers.borrow_mut_unchecked().push(import);
15121516

15131517
// Ensure that `resolutions` isn't borrowed during `try_define`,
15141518
// since it might get updated via a glob cycle.
@@ -1550,7 +1554,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
15501554
// reporting conflicts, and reporting unresolved imports.
15511555
fn finalize_resolutions_in(&mut self, module: Module<'ra>) {
15521556
// Since import resolution is finished, globs will not define any more names.
1553-
*module.globs.borrow_mut() = Vec::new();
1557+
*module.globs.borrow_mut(self) = Vec::new();
15541558

15551559
let Some(def_id) = module.opt_def_id() else { return };
15561560

0 commit comments

Comments
 (0)