about summary refs log tree commit diff
path: root/src/librustc
diff options
context:
space:
mode:
authorYuki Okushi <huyuumi.dev@gmail.com>2019-10-21 03:10:57 +0900
committerGitHub <noreply@github.com>2019-10-21 03:10:57 +0900
commit3e8acaf68cefc8010c88bac7e6f8d6c313035801 (patch)
tree07af3e566442ce448a6f0c706f05a370d80dc58c /src/librustc
parentcc42adf3a21a4b1a359dfd8281693f3e892669d3 (diff)
parent9cefcd3051ac7f4ea3c924bd7542c70c59ac5dfd (diff)
downloadrust-3e8acaf68cefc8010c88bac7e6f8d6c313035801.tar.gz
rust-3e8acaf68cefc8010c88bac7e6f8d6c313035801.zip
Rollup merge of #65579 - skinny121:resolve_const_vars, r=varkor
Changed `resolve_type_vars_with_obligations` to also resolve const inference variables

Fixes #65380
r? @varkor
Diffstat (limited to 'src/librustc')
-rw-r--r--src/librustc/infer/resolve.rs6
-rw-r--r--src/librustc/ty/fold.rs3
2 files changed, 6 insertions, 3 deletions
diff --git a/src/librustc/infer/resolve.rs b/src/librustc/infer/resolve.rs
index 2db18674e2f..7c3a338366c 100644
--- a/src/librustc/infer/resolve.rs
+++ b/src/librustc/infer/resolve.rs
@@ -1,7 +1,7 @@
 use super::{InferCtxt, FixupError, FixupResult, Span};
 use super::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
 use crate::mir::interpret::ConstValue;
-use crate::ty::{self, Ty, Const, TyCtxt, TypeFoldable, InferConst, TypeFlags};
+use crate::ty::{self, Ty, Const, TyCtxt, TypeFoldable, InferConst};
 use crate::ty::fold::{TypeFolder, TypeVisitor};
 
 ///////////////////////////////////////////////////////////////////////////
@@ -29,7 +29,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for OpportunisticVarResolver<'a, 'tcx> {
     }
 
     fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
-        if !t.has_infer_types() {
+        if !t.has_infer_types() && !t.has_infer_consts() {
             t // micro-optimize -- if there is nothing in this type that this fold affects...
         } else {
             let t = self.infcx.shallow_resolve(t);
@@ -38,7 +38,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for OpportunisticVarResolver<'a, 'tcx> {
     }
 
     fn fold_const(&mut self, ct: &'tcx Const<'tcx>) -> &'tcx Const<'tcx> {
-        if !ct.has_type_flags(TypeFlags::HAS_CT_INFER) {
+        if !ct.has_infer_consts() {
             ct // micro-optimize -- if there is nothing in this const that this fold affects...
         } else {
             let ct = self.infcx.shallow_resolve(ct);
diff --git a/src/librustc/ty/fold.rs b/src/librustc/ty/fold.rs
index 5192075c26e..a95ed589c3e 100644
--- a/src/librustc/ty/fold.rs
+++ b/src/librustc/ty/fold.rs
@@ -88,6 +88,9 @@ pub trait TypeFoldable<'tcx>: fmt::Debug + Clone {
     fn has_infer_types(&self) -> bool {
         self.has_type_flags(TypeFlags::HAS_TY_INFER)
     }
+    fn has_infer_consts(&self) -> bool {
+        self.has_type_flags(TypeFlags::HAS_CT_INFER)
+    }
     fn has_local_value(&self) -> bool {
         self.has_type_flags(TypeFlags::KEEP_IN_LOCAL_TCX)
     }