Skip to content

Commit 9bdfde0

Browse files
committed
remove some ad-hoc has_infer_types checks that aren't needed anymore
1 parent 75c1722 commit 9bdfde0

File tree

2 files changed

+17
-26
lines changed

2 files changed

+17
-26
lines changed

compiler/rustc_mir/src/borrow_check/diagnostics/conflict_errors.rs

+13-15
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_middle::mir::{
99
FakeReadCause, LocalDecl, LocalInfo, LocalKind, Location, Operand, Place, PlaceRef,
1010
ProjectionElem, Rvalue, Statement, StatementKind, Terminator, TerminatorKind, VarBindingForm,
1111
};
12-
use rustc_middle::ty::{self, suggest_constraining_type_param, Ty, TypeFoldable};
12+
use rustc_middle::ty::{self, suggest_constraining_type_param, Ty};
1313
use rustc_span::source_map::DesugaringKind;
1414
use rustc_span::symbol::sym;
1515
use rustc_span::{Span, DUMMY_SP};
@@ -1329,20 +1329,18 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
13291329
let return_ty = tcx.erase_regions(return_ty);
13301330

13311331
// to avoid panics
1332-
if !return_ty.has_infer_types() {
1333-
if let Some(iter_trait) = tcx.get_diagnostic_item(sym::Iterator) {
1334-
if tcx
1335-
.type_implements_trait((iter_trait, return_ty, ty_params, self.param_env))
1336-
.must_apply_modulo_regions()
1337-
{
1338-
if let Ok(snippet) = tcx.sess.source_map().span_to_snippet(return_span) {
1339-
err.span_suggestion_hidden(
1340-
return_span,
1341-
"use `.collect()` to allocate the iterator",
1342-
format!("{}{}", snippet, ".collect::<Vec<_>>()"),
1343-
Applicability::MaybeIncorrect,
1344-
);
1345-
}
1332+
if let Some(iter_trait) = tcx.get_diagnostic_item(sym::Iterator) {
1333+
if tcx
1334+
.type_implements_trait((iter_trait, return_ty, ty_params, self.param_env))
1335+
.must_apply_modulo_regions()
1336+
{
1337+
if let Ok(snippet) = tcx.sess.source_map().span_to_snippet(return_span) {
1338+
err.span_suggestion_hidden(
1339+
return_span,
1340+
"use `.collect()` to allocate the iterator",
1341+
format!("{}{}", snippet, ".collect::<Vec<_>>()"),
1342+
Applicability::MaybeIncorrect,
1343+
);
13461344
}
13471345
}
13481346
}

compiler/rustc_typeck/src/check/cast.rs

+4-11
Original file line numberDiff line numberDiff line change
@@ -442,17 +442,10 @@ impl<'a, 'tcx> CastCheck<'tcx> {
442442
let ty_params = fcx.tcx.mk_substs_trait(expr_ty, &[]);
443443
// Check for infer types because cases like `Option<{integer}>` would
444444
// panic otherwise.
445-
if !expr_ty.has_infer_types()
446-
&& !ty.has_infer_types()
447-
&& fcx
448-
.tcx
449-
.type_implements_trait((
450-
from_trait,
451-
ty,
452-
ty_params,
453-
fcx.param_env,
454-
))
455-
.must_apply_modulo_regions()
445+
if fcx
446+
.tcx
447+
.type_implements_trait((from_trait, ty, ty_params, fcx.param_env))
448+
.must_apply_modulo_regions()
456449
{
457450
label = false;
458451
err.span_suggestion(

0 commit comments

Comments
 (0)