use rustc_hir::lang_items::LangItem;
use rustc_hir::{ExprKind, Node, QPath};
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
-use rustc_middle::ty::fast_reject::{simplify_type, SimplifyParams, StripReferences};
+use rustc_middle::ty::fast_reject::{simplify_type, SimplifyParams};
use rustc_middle::ty::print::with_crate_prefix;
use rustc_middle::ty::{self, DefIdTree, ToPredicate, Ty, TyCtxt, TypeFoldable};
use rustc_span::lev_distance;
let mut bound_spans = vec![];
let mut collect_type_param_suggestions =
- |self_ty: Ty<'tcx>, parent_pred: &ty::Predicate<'tcx>, obligation: &str| {
+ |self_ty: Ty<'tcx>, parent_pred: ty::Predicate<'tcx>, obligation: &str| {
// We don't care about regions here, so it's fine to skip the binder here.
if let (ty::Param(_), ty::PredicateKind::Trait(p)) =
(self_ty.kind(), parent_pred.kind().skip_binder())
.filter(|(pred, _, _parent_pred)| !skip_list.contains(&pred))
.filter_map(|(pred, parent_pred, _cause)| {
format_pred(*pred).map(|(p, self_ty)| {
- collect_type_param_suggestions(self_ty, pred, &p);
+ collect_type_param_suggestions(self_ty, *pred, &p);
match parent_pred {
None => format!("`{}`", &p),
Some(parent_pred) => match format_pred(*parent_pred) {
Some((parent_p, _)) => {
collect_type_param_suggestions(
self_ty,
- parent_pred,
+ *parent_pred,
&p,
);
format!("`{}`\nwhich is required by `{}`", p, parent_p)
if let ty::Ref(region, t_type, mutability) = rcvr_ty.kind() {
if needs_mut {
let trait_type = self.tcx.mk_ref(
- region,
- ty::TypeAndMut { ty: t_type, mutbl: mutability.invert() },
+ *region,
+ ty::TypeAndMut { ty: *t_type, mutbl: mutability.invert() },
);
err.note(&format!("you need `{}` instead of `{}`", trait_type, rcvr_ty));
}
let additional_newline = if found_use { "" } else { "\n" };
format!(
"use {};\n{}",
- with_crate_prefix(|| self.tcx.def_path_str(*trait_did)),
+ with_crate_prefix!(self.tcx.def_path_str(*trait_did)),
additional_newline
)
});
let additional_newline = if found_use { "" } else { "\n" };
format!(
"use {}::*; // trait {}\n{}",
- with_crate_prefix(|| self.tcx.def_path_str(*parent_did)),
+ with_crate_prefix!(self.tcx.def_path_str(*parent_did)),
self.tcx.item_name(*trait_did),
additional_newline
)
msg.push_str(&format!(
"\ncandidate #{}: `use {};`",
i + 1,
- with_crate_prefix(|| self.tcx.def_path_str(*trait_did))
+ with_crate_prefix!(self.tcx.def_path_str(*trait_did))
));
} else {
msg.push_str(&format!(
"\n`use {};`",
- with_crate_prefix(|| self.tcx.def_path_str(*trait_did))
+ with_crate_prefix!(self.tcx.def_path_str(*trait_did))
));
}
}
msg.push_str(&format!(
"\ncandidate #{}: `use {}::*; // trait {}`",
candidates.len() + i + 1,
- with_crate_prefix(|| self.tcx.def_path_str(*parent_did)),
+ with_crate_prefix!(self.tcx.def_path_str(*parent_did)),
self.tcx.item_name(*trait_did),
));
} else {
msg.push_str(&format!(
"\n`use {}::*; // trait {}`",
- with_crate_prefix(|| self.tcx.def_path_str(*parent_did)),
+ with_crate_prefix!(self.tcx.def_path_str(*parent_did)),
self.tcx.item_name(*trait_did),
));
}
if let Some(did) = edition_fix {
err.note(&format!(
"'{}' is included in the prelude starting in Edition 2021",
- with_crate_prefix(|| self.tcx.def_path_str(did))
+ with_crate_prefix!(self.tcx.def_path_str(did))
));
}
// just this list.
for (rcvr_ty, post) in &[
(rcvr_ty, ""),
- (self.tcx.mk_mut_ref(&ty::ReErased, rcvr_ty), "&mut "),
- (self.tcx.mk_imm_ref(&ty::ReErased, rcvr_ty), "&"),
+ (self.tcx.mk_mut_ref(self.tcx.lifetimes.re_erased, rcvr_ty), "&mut "),
+ (self.tcx.mk_imm_ref(self.tcx.lifetimes.re_erased, rcvr_ty), "&"),
] {
if let Ok(pick) = self.lookup_probe(
span,
item_name,
- rcvr_ty,
+ *rcvr_ty,
rcvr,
crate::check::method::probe::ProbeScope::AllTraits,
) {
break;
}
for (rcvr_ty, pre) in &[
- (self.tcx.mk_lang_item(rcvr_ty, LangItem::OwnedBox), "Box::new"),
- (self.tcx.mk_lang_item(rcvr_ty, LangItem::Pin), "Pin::new"),
- (self.tcx.mk_diagnostic_item(rcvr_ty, sym::Arc), "Arc::new"),
- (self.tcx.mk_diagnostic_item(rcvr_ty, sym::Rc), "Rc::new"),
+ (self.tcx.mk_lang_item(*rcvr_ty, LangItem::OwnedBox), "Box::new"),
+ (self.tcx.mk_lang_item(*rcvr_ty, LangItem::Pin), "Pin::new"),
+ (self.tcx.mk_diagnostic_item(*rcvr_ty, sym::Arc), "Arc::new"),
+ (self.tcx.mk_diagnostic_item(*rcvr_ty, sym::Rc), "Rc::new"),
] {
if let Some(new_rcvr_t) = *rcvr_ty {
if let Ok(pick) = self.lookup_probe(
// FIXME: Even though negative bounds are not implemented, we could maybe handle
// cases where a positive bound implies a negative impl.
(candidates, Vec::new())
- } else if let Some(simp_rcvr_ty) =
- simplify_type(self.tcx, rcvr_ty, SimplifyParams::Yes, StripReferences::No)
+ } else if let Some(simp_rcvr_ty) = simplify_type(self.tcx, rcvr_ty, SimplifyParams::Yes)
{
let mut potential_candidates = Vec::new();
let mut explicitly_negative = Vec::new();
})
.any(|imp_did| {
let imp = self.tcx.impl_trait_ref(imp_did).unwrap();
- let imp_simp = simplify_type(
- self.tcx,
- imp.self_ty(),
- SimplifyParams::Yes,
- StripReferences::No,
- );
+ let imp_simp =
+ simplify_type(self.tcx, imp.self_ty(), SimplifyParams::Yes);
imp_simp.map_or(false, |s| s == simp_rcvr_ty)
})
{