Skip to content

Commit 0decf14

Browse files
committed
Do not store overlap_mode, just pass it down on insert
1 parent a9bfb5d commit 0decf14

File tree

3 files changed

+6
-16
lines changed

3 files changed

+6
-16
lines changed

compiler/rustc_middle/src/traits/specialization_graph.rs

+1-13
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,11 @@ pub struct Graph {
3232

3333
/// Whether an error was emitted while constructing the graph.
3434
pub has_errored: bool,
35-
36-
/// Overlap mode to be used
37-
pub overlap_mode: OverlapMode,
3835
}
3936

4037
impl Graph {
4138
pub fn new() -> Graph {
42-
Graph {
43-
parent: Default::default(),
44-
children: Default::default(),
45-
has_errored: false,
46-
overlap_mode: OverlapMode::Stable,
47-
}
48-
}
49-
50-
pub fn set_overlap_mode(&mut self, overlap_mode: OverlapMode) {
51-
self.overlap_mode = overlap_mode;
39+
Graph { parent: Default::default(), children: Default::default(), has_errored: false }
5240
}
5341

5442
/// The parent of a given impl, which is the `DefId` of the trait when the

compiler/rustc_trait_selection/src/traits/specialize/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ pub(super) fn specialization_graph_provider(
257257
trait_id: DefId,
258258
) -> specialization_graph::Graph {
259259
let mut sg = specialization_graph::Graph::new();
260-
sg.set_overlap_mode(specialization_graph::OverlapMode::get(tcx, trait_id));
260+
let overlap_mode = specialization_graph::OverlapMode::get(tcx, trait_id);
261261

262262
let mut trait_impls: Vec<_> = tcx.all_impls(trait_id).collect();
263263

@@ -271,7 +271,7 @@ pub(super) fn specialization_graph_provider(
271271
for impl_def_id in trait_impls {
272272
if let Some(impl_def_id) = impl_def_id.as_local() {
273273
// This is where impl overlap checking happens:
274-
let insert_result = sg.insert(tcx, impl_def_id.to_def_id());
274+
let insert_result = sg.insert(tcx, impl_def_id.to_def_id(), overlap_mode);
275275
// Report error if there was one.
276276
let (overlap, used_to_be_allowed) = match insert_result {
277277
Err(overlap) => (Some(overlap), None),

compiler/rustc_trait_selection/src/traits/specialize/specialization_graph.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ pub trait GraphExt {
277277
&mut self,
278278
tcx: TyCtxt<'_>,
279279
impl_def_id: DefId,
280+
overlap_mode: OverlapMode,
280281
) -> Result<Option<FutureCompatOverlapError>, OverlapError>;
281282

282283
/// Insert cached metadata mapping from a child impl back to its parent.
@@ -291,6 +292,7 @@ impl GraphExt for Graph {
291292
&mut self,
292293
tcx: TyCtxt<'_>,
293294
impl_def_id: DefId,
295+
overlap_mode: OverlapMode,
294296
) -> Result<Option<FutureCompatOverlapError>, OverlapError> {
295297
assert!(impl_def_id.is_local());
296298

@@ -335,7 +337,7 @@ impl GraphExt for Graph {
335337
tcx,
336338
impl_def_id,
337339
simplified,
338-
self.overlap_mode,
340+
overlap_mode,
339341
)?;
340342

341343
match insert_result {

0 commit comments

Comments
 (0)