Skip to content

Commit 0e84b61

Browse files
committed
use relevant span when unifying ConstVarValues
1 parent 3dbfdb0 commit 0e84b61

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
309309
);
310310
}
311311

312-
Some(origin.span).filter(|s| !s.is_dummy())
312+
debug_assert!(!origin.span.is_dummy());
313+
Some(origin.span)
313314
} else {
314315
bug!("unexpect const: {:?}", ct);
315316
};

compiler/rustc_middle/src/infer/unify_key.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use rustc_data_structures::unify::{
66
};
77
use rustc_span::def_id::DefId;
88
use rustc_span::symbol::Symbol;
9-
use rustc_span::{Span, DUMMY_SP};
9+
use rustc_span::Span;
1010

1111
use std::cmp;
1212
use std::marker::PhantomData;
@@ -176,17 +176,17 @@ impl<'tcx> UnifyValue for ConstVarValue<'tcx> {
176176
type Error = (&'tcx ty::Const<'tcx>, &'tcx ty::Const<'tcx>);
177177

178178
fn unify_values(value1: &Self, value2: &Self) -> Result<Self, Self::Error> {
179-
let val = match (value1.val, value2.val) {
179+
let (val, span) = match (value1.val, value2.val) {
180180
(ConstVariableValue::Known { .. }, ConstVariableValue::Known { .. }) => {
181181
bug!("equating two const variables, both of which have known values")
182182
}
183183

184184
// If one side is known, prefer that one.
185185
(ConstVariableValue::Known { .. }, ConstVariableValue::Unknown { .. }) => {
186-
Ok(value1.val)
186+
(value1.val, value1.origin.span)
187187
}
188188
(ConstVariableValue::Unknown { .. }, ConstVariableValue::Known { .. }) => {
189-
Ok(value2.val)
189+
(value2.val, value2.origin.span)
190190
}
191191

192192
// If both sides are *unknown*, it hardly matters, does it?
@@ -200,14 +200,14 @@ impl<'tcx> UnifyValue for ConstVarValue<'tcx> {
200200
// universe is the minimum of the two universes, because that is
201201
// the one which contains the fewest names in scope.
202202
let universe = cmp::min(universe1, universe2);
203-
Ok(ConstVariableValue::Unknown { universe })
203+
(ConstVariableValue::Unknown { universe }, value1.origin.span)
204204
}
205-
}?;
205+
};
206206

207207
Ok(ConstVarValue {
208208
origin: ConstVariableOrigin {
209209
kind: ConstVariableOriginKind::ConstInference,
210-
span: DUMMY_SP,
210+
span: span,
211211
},
212212
val,
213213
})

0 commit comments

Comments
 (0)