about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSantiago Pastorino <spastorino@gmail.com>2022-01-31 11:51:34 -0300
committerSantiago Pastorino <spastorino@gmail.com>2022-01-31 11:51:34 -0300
commit0decf14ef1e63e7e7b70805cdf3d03b42d2f457c (patch)
tree92203b1a5bbcece59fcf96f6af70b82d43f1a39a
parenta9bfb5d83754710a8cb7da2f7d17f62ec3cafdcc (diff)
downloadrust-0decf14ef1e63e7e7b70805cdf3d03b42d2f457c.tar.gz
rust-0decf14ef1e63e7e7b70805cdf3d03b42d2f457c.zip
Do not store overlap_mode, just pass it down on insert
-rw-r--r--compiler/rustc_middle/src/traits/specialization_graph.rs14
-rw-r--r--compiler/rustc_trait_selection/src/traits/specialize/mod.rs4
-rw-r--r--compiler/rustc_trait_selection/src/traits/specialize/specialization_graph.rs4
3 files changed, 6 insertions, 16 deletions
diff --git a/compiler/rustc_middle/src/traits/specialization_graph.rs b/compiler/rustc_middle/src/traits/specialization_graph.rs
index 36025ea637f..03a6daaf8aa 100644
--- a/compiler/rustc_middle/src/traits/specialization_graph.rs
+++ b/compiler/rustc_middle/src/traits/specialization_graph.rs
@@ -32,23 +32,11 @@ pub struct Graph {
 
     /// Whether an error was emitted while constructing the graph.
     pub has_errored: bool,
-
-    /// Overlap mode to be used
-    pub overlap_mode: OverlapMode,
 }
 
 impl Graph {
     pub fn new() -> Graph {
-        Graph {
-            parent: Default::default(),
-            children: Default::default(),
-            has_errored: false,
-            overlap_mode: OverlapMode::Stable,
-        }
-    }
-
-    pub fn set_overlap_mode(&mut self, overlap_mode: OverlapMode) {
-        self.overlap_mode = overlap_mode;
+        Graph { parent: Default::default(), children: Default::default(), has_errored: false }
     }
 
     /// The parent of a given impl, which is the `DefId` of the trait when the
diff --git a/compiler/rustc_trait_selection/src/traits/specialize/mod.rs b/compiler/rustc_trait_selection/src/traits/specialize/mod.rs
index 15276e69db8..b098e8590da 100644
--- a/compiler/rustc_trait_selection/src/traits/specialize/mod.rs
+++ b/compiler/rustc_trait_selection/src/traits/specialize/mod.rs
@@ -257,7 +257,7 @@ pub(super) fn specialization_graph_provider(
     trait_id: DefId,
 ) -> specialization_graph::Graph {
     let mut sg = specialization_graph::Graph::new();
-    sg.set_overlap_mode(specialization_graph::OverlapMode::get(tcx, trait_id));
+    let overlap_mode = specialization_graph::OverlapMode::get(tcx, trait_id);
 
     let mut trait_impls: Vec<_> = tcx.all_impls(trait_id).collect();
 
@@ -271,7 +271,7 @@ pub(super) fn specialization_graph_provider(
     for impl_def_id in trait_impls {
         if let Some(impl_def_id) = impl_def_id.as_local() {
             // This is where impl overlap checking happens:
-            let insert_result = sg.insert(tcx, impl_def_id.to_def_id());
+            let insert_result = sg.insert(tcx, impl_def_id.to_def_id(), overlap_mode);
             // Report error if there was one.
             let (overlap, used_to_be_allowed) = match insert_result {
                 Err(overlap) => (Some(overlap), None),
diff --git a/compiler/rustc_trait_selection/src/traits/specialize/specialization_graph.rs b/compiler/rustc_trait_selection/src/traits/specialize/specialization_graph.rs
index c1a271b9e5a..5ee8b45e66b 100644
--- a/compiler/rustc_trait_selection/src/traits/specialize/specialization_graph.rs
+++ b/compiler/rustc_trait_selection/src/traits/specialize/specialization_graph.rs
@@ -277,6 +277,7 @@ pub trait GraphExt {
         &mut self,
         tcx: TyCtxt<'_>,
         impl_def_id: DefId,
+        overlap_mode: OverlapMode,
     ) -> Result<Option<FutureCompatOverlapError>, OverlapError>;
 
     /// Insert cached metadata mapping from a child impl back to its parent.
@@ -291,6 +292,7 @@ impl GraphExt for Graph {
         &mut self,
         tcx: TyCtxt<'_>,
         impl_def_id: DefId,
+        overlap_mode: OverlapMode,
     ) -> Result<Option<FutureCompatOverlapError>, OverlapError> {
         assert!(impl_def_id.is_local());
 
@@ -335,7 +337,7 @@ impl GraphExt for Graph {
                 tcx,
                 impl_def_id,
                 simplified,
-                self.overlap_mode,
+                overlap_mode,
             )?;
 
             match insert_result {