Skip to content

Commit 9a2772a

Browse files
committed
Implement ToTrace for ty::Const
1 parent 5fc0395 commit 9a2772a

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

src/librustc/infer/at.rs

+15
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
2828
use super::*;
2929

30+
use crate::ty::Const;
3031
use crate::ty::relate::{Relate, TypeRelation};
3132

3233
pub struct At<'a, 'gcx: 'tcx, 'tcx: 'a> {
@@ -308,6 +309,20 @@ impl<'tcx> ToTrace<'tcx> for ty::Region<'tcx> {
308309
}
309310
}
310311

312+
impl<'tcx> ToTrace<'tcx> for &'tcx Const<'tcx> {
313+
fn to_trace(cause: &ObligationCause<'tcx>,
314+
a_is_expected: bool,
315+
a: Self,
316+
b: Self)
317+
-> TypeTrace<'tcx>
318+
{
319+
TypeTrace {
320+
cause: cause.clone(),
321+
values: Consts(ExpectedFound::new(a_is_expected, a, b))
322+
}
323+
}
324+
}
325+
311326
impl<'tcx> ToTrace<'tcx> for ty::TraitRef<'tcx> {
312327
fn to_trace(cause: &ObligationCause<'tcx>,
313328
a_is_expected: bool,

src/librustc/infer/error_reporting/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1260,6 +1260,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
12601260
match *values {
12611261
infer::Types(ref exp_found) => self.expected_found_str_ty(exp_found),
12621262
infer::Regions(ref exp_found) => self.expected_found_str(exp_found),
1263+
infer::Consts(ref exp_found) => self.expected_found_str(exp_found),
12631264
infer::TraitRefs(ref exp_found) => self.expected_found_str(exp_found),
12641265
infer::PolyTraitRefs(ref exp_found) => self.expected_found_str(exp_found),
12651266
}

src/librustc/infer/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ pub type PlaceholderMap<'tcx> = BTreeMap<ty::BoundRegion, ty::Region<'tcx>>;
232232
pub enum ValuePairs<'tcx> {
233233
Types(ExpectedFound<Ty<'tcx>>),
234234
Regions(ExpectedFound<ty::Region<'tcx>>),
235+
Consts(ExpectedFound<&'tcx ty::Const<'tcx>>),
235236
TraitRefs(ExpectedFound<ty::TraitRef<'tcx>>),
236237
PolyTraitRefs(ExpectedFound<ty::PolyTraitRef<'tcx>>),
237238
}
@@ -1730,6 +1731,7 @@ EnumTypeFoldableImpl! {
17301731
impl<'tcx> TypeFoldable<'tcx> for ValuePairs<'tcx> {
17311732
(ValuePairs::Types)(a),
17321733
(ValuePairs::Regions)(a),
1734+
(ValuePairs::Consts)(a),
17331735
(ValuePairs::TraitRefs)(a),
17341736
(ValuePairs::PolyTraitRefs)(a),
17351737
}

0 commit comments

Comments
 (0)