the environment round here is awfully empty
capitalism
This commit is contained in:
parent
b86674e7cc
commit
7e368e57f2
4 changed files with 49 additions and 23 deletions
|
@ -72,17 +72,16 @@ pub fn is_const_evaluatable<'cx, 'tcx>(
|
|||
// We were unable to unify the abstract constant with
|
||||
// a constant found in the caller bounds, there are
|
||||
// now three possible cases here.
|
||||
//
|
||||
// - The substs are concrete enough that we can simply
|
||||
// try and evaluate the given constant.
|
||||
// - The abstract const still references an inference
|
||||
// variable, in this case we return `TooGeneric`.
|
||||
// - The abstract const references a generic parameter,
|
||||
// this means that we emit an error here.
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
|
||||
enum FailureKind {
|
||||
/// The abstract const still references an inference
|
||||
/// variable, in this case we return `TooGeneric`.
|
||||
MentionsInfer,
|
||||
/// The abstract const references a generic parameter,
|
||||
/// this means that we emit an error here.
|
||||
MentionsParam,
|
||||
/// The substs are concrete enough that we can simply
|
||||
/// try and evaluate the given constant.
|
||||
Concrete,
|
||||
}
|
||||
let mut failure_kind = FailureKind::Concrete;
|
||||
|
|
|
@ -200,22 +200,15 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
if let Some(def) = aty.ty_adt_def() {
|
||||
// We also want to be able to select the array's type's original
|
||||
// signature with no type arguments resolved
|
||||
flags.push((
|
||||
sym::_Self,
|
||||
Some(format!("[{}]", self.tcx.type_of(def.did).to_string())),
|
||||
));
|
||||
let tcx = self.tcx;
|
||||
if let Some(len) = len.try_eval_usize(tcx, ty::ParamEnv::empty()) {
|
||||
flags.push((
|
||||
sym::_Self,
|
||||
Some(format!("[{}; {}]", self.tcx.type_of(def.did).to_string(), len)),
|
||||
));
|
||||
} else {
|
||||
flags.push((
|
||||
sym::_Self,
|
||||
Some(format!("[{}; _]", self.tcx.type_of(def.did).to_string())),
|
||||
));
|
||||
}
|
||||
let type_string = self.tcx.type_of(def.did).to_string();
|
||||
flags.push((sym::_Self, Some(format!("[{}]", type_string))));
|
||||
|
||||
let len = len.val.try_to_value().and_then(|v| v.try_to_machine_usize(self.tcx));
|
||||
let string = match len {
|
||||
Some(n) => format!("[{}; {}]", type_string, n),
|
||||
None => format!("[{}; _]", type_string),
|
||||
};
|
||||
flags.push((sym::_Self, Some(string)));
|
||||
}
|
||||
}
|
||||
if let ty::Dynamic(traits, _) = self_ty.kind() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue