about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBastian Kauschke <bastian_kauschke@hotmail.de>2020-09-23 11:00:44 +0200
committerBastian Kauschke <bastian_kauschke@hotmail.de>2020-09-23 11:00:44 +0200
commit0e84b6105376742072e85ae2b85a6a1fd9a9045d (patch)
tree3b61515f401485d5d62cdfe06b3d59279e6fa204
parent3dbfdb0182c7b8bbace4b5d8d4445aac4291351a (diff)
downloadrust-0e84b6105376742072e85ae2b85a6a1fd9a9045d.tar.gz
rust-0e84b6105376742072e85ae2b85a6a1fd9a9045d.zip
use relevant span when unifying `ConstVarValue`s
-rw-r--r--compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs3
-rw-r--r--compiler/rustc_middle/src/infer/unify_key.rs14
2 files changed, 9 insertions, 8 deletions
diff --git a/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs b/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs
index b7debba68b5..b00adec822e 100644
--- a/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs
+++ b/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs
@@ -309,7 +309,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
                         );
                     }
 
-                    Some(origin.span).filter(|s| !s.is_dummy())
+                    debug_assert!(!origin.span.is_dummy());
+                    Some(origin.span)
                 } else {
                     bug!("unexpect const: {:?}", ct);
                 };
diff --git a/compiler/rustc_middle/src/infer/unify_key.rs b/compiler/rustc_middle/src/infer/unify_key.rs
index 499f92b4041..4d884dde393 100644
--- a/compiler/rustc_middle/src/infer/unify_key.rs
+++ b/compiler/rustc_middle/src/infer/unify_key.rs
@@ -6,7 +6,7 @@ use rustc_data_structures::unify::{
 };
 use rustc_span::def_id::DefId;
 use rustc_span::symbol::Symbol;
-use rustc_span::{Span, DUMMY_SP};
+use rustc_span::Span;
 
 use std::cmp;
 use std::marker::PhantomData;
@@ -176,17 +176,17 @@ impl<'tcx> UnifyValue for ConstVarValue<'tcx> {
     type Error = (&'tcx ty::Const<'tcx>, &'tcx ty::Const<'tcx>);
 
     fn unify_values(value1: &Self, value2: &Self) -> Result<Self, Self::Error> {
-        let val = match (value1.val, value2.val) {
+        let (val, span) = match (value1.val, value2.val) {
             (ConstVariableValue::Known { .. }, ConstVariableValue::Known { .. }) => {
                 bug!("equating two const variables, both of which have known values")
             }
 
             // If one side is known, prefer that one.
             (ConstVariableValue::Known { .. }, ConstVariableValue::Unknown { .. }) => {
-                Ok(value1.val)
+                (value1.val, value1.origin.span)
             }
             (ConstVariableValue::Unknown { .. }, ConstVariableValue::Known { .. }) => {
-                Ok(value2.val)
+                (value2.val, value2.origin.span)
             }
 
             // If both sides are *unknown*, it hardly matters, does it?
@@ -200,14 +200,14 @@ impl<'tcx> UnifyValue for ConstVarValue<'tcx> {
                 // universe is the minimum of the two universes, because that is
                 // the one which contains the fewest names in scope.
                 let universe = cmp::min(universe1, universe2);
-                Ok(ConstVariableValue::Unknown { universe })
+                (ConstVariableValue::Unknown { universe }, value1.origin.span)
             }
-        }?;
+        };
 
         Ok(ConstVarValue {
             origin: ConstVariableOrigin {
                 kind: ConstVariableOriginKind::ConstInference,
-                span: DUMMY_SP,
+                span: span,
             },
             val,
         })