about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJack Huey <31162821+jackh726@users.noreply.github.com>2022-07-10 15:25:33 -0400
committerJack Huey <31162821+jackh726@users.noreply.github.com>2022-07-10 15:25:33 -0400
commit2d15f1ca42c39bb6982ebde8a84b4cda3c8f8874 (patch)
treee70d056764a342adc0b8283f9dbd844c01a781f7
parentc4693bc946729393c087fb120af566395915d19d (diff)
downloadrust-2d15f1ca42c39bb6982ebde8a84b4cda3c8f8874.tar.gz
rust-2d15f1ca42c39bb6982ebde8a84b4cda3c8f8874.zip
Don't try to resolve inference variables in WF computation, just register
-rw-r--r--compiler/rustc_trait_selection/src/traits/wf.rs52
-rw-r--r--src/test/ui/issues/issue-98299.stderr11
2 files changed, 25 insertions, 38 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/wf.rs b/compiler/rustc_trait_selection/src/traits/wf.rs
index 7b5e1498f26..75330fdf91a 100644
--- a/compiler/rustc_trait_selection/src/traits/wf.rs
+++ b/compiler/rustc_trait_selection/src/traits/wf.rs
@@ -452,26 +452,16 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
                                 predicate,
                             ));
                         }
-                        ty::ConstKind::Infer(infer) => {
-                            let resolved = self.infcx.shallow_resolve(infer);
-                            // the `InferConst` changed, meaning that we made progress.
-                            if resolved != infer {
-                                let cause = self.cause(traits::WellFormed(None));
-
-                                let resolved_constant = self.infcx.tcx.mk_const(ty::ConstS {
-                                    kind: ty::ConstKind::Infer(resolved),
-                                    ty: constant.ty(),
-                                });
-                                self.out.push(traits::Obligation::with_depth(
-                                    cause,
-                                    self.recursion_depth,
-                                    self.param_env,
-                                    ty::Binder::dummy(ty::PredicateKind::WellFormed(
-                                        resolved_constant.into(),
-                                    ))
+                        ty::ConstKind::Infer(_) => {
+                            let cause = self.cause(traits::WellFormed(None));
+
+                            self.out.push(traits::Obligation::with_depth(
+                                cause,
+                                self.recursion_depth,
+                                self.param_env,
+                                ty::Binder::dummy(ty::PredicateKind::WellFormed(constant.into()))
                                     .to_predicate(self.tcx()),
-                                ));
-                            }
+                            ));
                         }
                         ty::ConstKind::Error(_)
                         | ty::ConstKind::Param(_)
@@ -675,22 +665,14 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
                 // See also the comment on `fn obligations`, describing "livelock"
                 // prevention, which happens before this can be reached.
                 ty::Infer(_) => {
-                    let ty = self.infcx.shallow_resolve(ty);
-                    if let ty::Infer(ty::TyVar(_)) = ty.kind() {
-                        // Not yet resolved, but we've made progress.
-                        let cause = self.cause(traits::WellFormed(None));
-                        self.out.push(traits::Obligation::with_depth(
-                            cause,
-                            self.recursion_depth,
-                            param_env,
-                            ty::Binder::dummy(ty::PredicateKind::WellFormed(ty.into()))
-                                .to_predicate(self.tcx()),
-                        ));
-                    } else {
-                        // Yes, resolved, proceed with the result.
-                        // FIXME(eddyb) add the type to `walker` instead of recursing.
-                        self.compute(ty.into());
-                    }
+                    let cause = self.cause(traits::WellFormed(None));
+                    self.out.push(traits::Obligation::with_depth(
+                        cause,
+                        self.recursion_depth,
+                        param_env,
+                        ty::Binder::dummy(ty::PredicateKind::WellFormed(ty.into()))
+                            .to_predicate(self.tcx()),
+                    ));
                 }
             }
         }
diff --git a/src/test/ui/issues/issue-98299.stderr b/src/test/ui/issues/issue-98299.stderr
index a61bffa91e7..fd905392a21 100644
--- a/src/test/ui/issues/issue-98299.stderr
+++ b/src/test/ui/issues/issue-98299.stderr
@@ -1,8 +1,13 @@
-error[E0282]: type annotations needed
-  --> $DIR/issue-98299.rs:4:5
+error[E0282]: type annotations needed for `SmallCString<N>`
+  --> $DIR/issue-98299.rs:4:36
    |
 LL |     SmallCString::try_from(p).map(|cstr| cstr);
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for enum `Result<SmallCString<{_: usize}>, ()>`
+   |                                    ^^^^
+   |
+help: consider giving this closure parameter an explicit type, where the the value of const parameter `N` is specified
+   |
+LL |     SmallCString::try_from(p).map(|cstr: SmallCString<N>| cstr);
+   |                                        +++++++++++++++++
 
 error: aborting due to previous error