diff options
| author | b-naber <bn263@gmx.de> | 2022-02-16 10:56:01 +0100 |
|---|---|---|
| committer | b-naber <bn263@gmx.de> | 2022-06-14 16:07:11 +0200 |
| commit | 705d818bd52a6324d5e7693cc4306457395eebc8 (patch) | |
| tree | f5363e1a8b0426bc961970028c23670869e344fb /compiler/rustc_trait_selection/src/traits/auto_trait.rs | |
| parent | edab34ab2abbafc16a78daedf71dbacd2eb0b7bf (diff) | |
| download | rust-705d818bd52a6324d5e7693cc4306457395eebc8.tar.gz rust-705d818bd52a6324d5e7693cc4306457395eebc8.zip | |
implement valtrees as the type-system representation for constant values
Diffstat (limited to 'compiler/rustc_trait_selection/src/traits/auto_trait.rs')
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/auto_trait.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/auto_trait.rs b/compiler/rustc_trait_selection/src/traits/auto_trait.rs index c95d43b71cf..a63790b594d 100644 --- a/compiler/rustc_trait_selection/src/traits/auto_trait.rs +++ b/compiler/rustc_trait_selection/src/traits/auto_trait.rs @@ -6,6 +6,7 @@ use super::*; use crate::infer::region_constraints::{Constraint, RegionConstraintData}; use crate::infer::InferCtxt; use crate::traits::project::ProjectAndUnifyResult; +use rustc_middle::mir::interpret::ErrorHandled; use rustc_middle::ty::fold::{TypeFolder, TypeSuperFoldable}; use rustc_middle::ty::{Region, RegionVid, Term}; @@ -834,7 +835,16 @@ impl<'tcx> AutoTraitFinder<'tcx> { unevaluated, Some(obligation.cause.span), ) { - Ok(val) => Ok(ty::Const::from_value(select.tcx(), val, c.ty())), + Ok(Some(valtree)) => { + Ok(ty::Const::from_value(select.tcx(), valtree, c.ty())) + } + Ok(None) => { + let tcx = self.tcx; + let def_id = unevaluated.def.did; + let reported = tcx.sess.struct_span_err(tcx.def_span(def_id), &format!("unable to construct a constant value for the unevaluated constant {:?}", unevaluated)).emit(); + + Err(ErrorHandled::Reported(reported)) + } Err(err) => Err(err), } } else { |
