handle ConstEquate in rustdoc
This commit is contained in:
parent
1454bbd4fd
commit
2a16bb085e
@ -802,6 +802,38 @@ impl AutoTraitFinder<'tcx> {
|
||||
_ => {}
|
||||
};
|
||||
}
|
||||
ty::PredicateAtom::ConstEquate(c1, c2) => {
|
||||
let evaluate = |c: &'tcx ty::Const<'tcx>| {
|
||||
if let ty::ConstKind::Unevaluated(def, substs, promoted) = c.val {
|
||||
match select.infcx().const_eval_resolve(
|
||||
obligation.param_env,
|
||||
def,
|
||||
substs,
|
||||
promoted,
|
||||
Some(obligation.cause.span),
|
||||
) {
|
||||
Ok(val) => Ok(ty::Const::from_value(select.tcx(), val, c.ty)),
|
||||
Err(err) => Err(err),
|
||||
}
|
||||
} else {
|
||||
Ok(c)
|
||||
}
|
||||
};
|
||||
|
||||
match (evaluate(c1), evaluate(c2)) {
|
||||
(Ok(c1), Ok(c2)) => {
|
||||
match select
|
||||
.infcx()
|
||||
.at(&obligation.cause, obligation.param_env)
|
||||
.eq(c1, c2)
|
||||
{
|
||||
Ok(_) => (),
|
||||
Err(_) => return false,
|
||||
}
|
||||
}
|
||||
_ => return false,
|
||||
}
|
||||
}
|
||||
_ => panic!("Unexpected predicate {:?} {:?}", ty, predicate),
|
||||
};
|
||||
}
|
||||
|
@ -0,0 +1,18 @@
|
||||
#![crate_name = "foo"]
|
||||
#![feature(lazy_normalization_consts)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
// Checking if `Send` is implemented for `Hasher` requires us to evaluate a `ConstEquate` predicate,
|
||||
// which previously caused an ICE.
|
||||
|
||||
pub struct Hasher<T> {
|
||||
cv_stack: T,
|
||||
}
|
||||
|
||||
unsafe impl<T: Default> Send for Hasher<T> {}
|
||||
|
||||
// @has foo/struct.Foo.html
|
||||
// @has - '//code' 'impl Send for Foo'
|
||||
pub struct Foo {
|
||||
hasher: Hasher<[u8; 3]>,
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user