remove some ad-hoc has_infer_types checks that aren't needed anymore
This commit is contained in:
parent
75c172246c
commit
9bdfde0be4
2 changed files with 17 additions and 26 deletions
|
|
@ -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,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue