about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2021-07-04 11:43:22 -0400
committerNiko Matsakis <niko@alum.mit.edu>2021-07-04 11:55:09 -0400
commit9bdfde0be460c096e8aecfdfe6c6eeac2e173fe4 (patch)
tree8dc1b4bb8e19357f2f5bd9333f443407e4ee824c
parent75c172246c5c558fc1451554fb2798018a23e872 (diff)
downloadrust-9bdfde0be460c096e8aecfdfe6c6eeac2e173fe4.tar.gz
rust-9bdfde0be460c096e8aecfdfe6c6eeac2e173fe4.zip
remove some ad-hoc has_infer_types checks that aren't needed anymore
-rw-r--r--compiler/rustc_mir/src/borrow_check/diagnostics/conflict_errors.rs28
-rw-r--r--compiler/rustc_typeck/src/check/cast.rs15
2 files changed, 17 insertions, 26 deletions
diff --git a/compiler/rustc_mir/src/borrow_check/diagnostics/conflict_errors.rs b/compiler/rustc_mir/src/borrow_check/diagnostics/conflict_errors.rs
index c1c875eac55..4be4372c039 100644
--- a/compiler/rustc_mir/src/borrow_check/diagnostics/conflict_errors.rs
+++ b/compiler/rustc_mir/src/borrow_check/diagnostics/conflict_errors.rs
@@ -9,7 +9,7 @@ use rustc_middle::mir::{
     FakeReadCause, LocalDecl, LocalInfo, LocalKind, Location, Operand, Place, PlaceRef,
     ProjectionElem, Rvalue, Statement, StatementKind, Terminator, TerminatorKind, VarBindingForm,
 };
-use rustc_middle::ty::{self, suggest_constraining_type_param, Ty, TypeFoldable};
+use rustc_middle::ty::{self, suggest_constraining_type_param, Ty};
 use rustc_span::source_map::DesugaringKind;
 use rustc_span::symbol::sym;
 use rustc_span::{Span, DUMMY_SP};
@@ -1329,20 +1329,18 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
             let return_ty = tcx.erase_regions(return_ty);
 
             // to avoid panics
-            if !return_ty.has_infer_types() {
-                if let Some(iter_trait) = tcx.get_diagnostic_item(sym::Iterator) {
-                    if tcx
-                        .type_implements_trait((iter_trait, return_ty, ty_params, self.param_env))
-                        .must_apply_modulo_regions()
-                    {
-                        if let Ok(snippet) = tcx.sess.source_map().span_to_snippet(return_span) {
-                            err.span_suggestion_hidden(
-                                return_span,
-                                "use `.collect()` to allocate the iterator",
-                                format!("{}{}", snippet, ".collect::<Vec<_>>()"),
-                                Applicability::MaybeIncorrect,
-                            );
-                        }
+            if let Some(iter_trait) = tcx.get_diagnostic_item(sym::Iterator) {
+                if tcx
+                    .type_implements_trait((iter_trait, return_ty, ty_params, self.param_env))
+                    .must_apply_modulo_regions()
+                {
+                    if let Ok(snippet) = tcx.sess.source_map().span_to_snippet(return_span) {
+                        err.span_suggestion_hidden(
+                            return_span,
+                            "use `.collect()` to allocate the iterator",
+                            format!("{}{}", snippet, ".collect::<Vec<_>>()"),
+                            Applicability::MaybeIncorrect,
+                        );
                     }
                 }
             }
diff --git a/compiler/rustc_typeck/src/check/cast.rs b/compiler/rustc_typeck/src/check/cast.rs
index 7ff4a108dab..b0c25c86dd3 100644
--- a/compiler/rustc_typeck/src/check/cast.rs
+++ b/compiler/rustc_typeck/src/check/cast.rs
@@ -442,17 +442,10 @@ impl<'a, 'tcx> CastCheck<'tcx> {
                             let ty_params = fcx.tcx.mk_substs_trait(expr_ty, &[]);
                             // Check for infer types because cases like `Option<{integer}>` would
                             // panic otherwise.
-                            if !expr_ty.has_infer_types()
-                                && !ty.has_infer_types()
-                                && fcx
-                                    .tcx
-                                    .type_implements_trait((
-                                        from_trait,
-                                        ty,
-                                        ty_params,
-                                        fcx.param_env,
-                                    ))
-                                    .must_apply_modulo_regions()
+                            if fcx
+                                .tcx
+                                .type_implements_trait((from_trait, ty, ty_params, fcx.param_env))
+                                .must_apply_modulo_regions()
                             {
                                 label = false;
                                 err.span_suggestion(