mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-16 13:05:18 +03:00
Rollup merge of #140404 - lcnr:canonical-no-type-foldable, r=compiler-errors
rm `TypeVistable` impls for `Canonical` similar to `EarlyBinder`, you generally do not want to fold a canonical value directly without first instantiating it. In places where you do want to look into the `Canonical`, it's likely better to do so manually. r? ```@compiler-errors```
This commit is contained in:
@@ -1213,7 +1213,7 @@ fn pick_all_method<'b>(
|
||||
debug!("pick_all_method: step={:?}", step);
|
||||
// skip types that are from a type error or that would require dereferencing
|
||||
// a raw pointer
|
||||
!step.self_ty.references_error() && !step.from_unsafe_deref
|
||||
!step.self_ty.value.references_error() && !step.from_unsafe_deref
|
||||
})
|
||||
.find_map(|step| {
|
||||
let InferOk { value: self_ty, obligations: _ } = self
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
use rustc_hir::intravisit::{self, InferKind, Visitor};
|
||||
use rustc_hir::{self as hir, AmbigArg, HirId};
|
||||
use rustc_infer::traits::solve::Goal;
|
||||
use rustc_middle::span_bug;
|
||||
use rustc_middle::traits::ObligationCause;
|
||||
use rustc_middle::ty::adjustment::{Adjust, Adjustment, PointerCoercion};
|
||||
use rustc_middle::ty::{
|
||||
@@ -513,15 +512,6 @@ fn visit_user_provided_tys(&mut self) {
|
||||
self.typeck_results.user_provided_types_mut().extend(
|
||||
fcx_typeck_results.user_provided_types().items().map(|(local_id, c_ty)| {
|
||||
let hir_id = HirId { owner: common_hir_owner, local_id };
|
||||
|
||||
if cfg!(debug_assertions) && c_ty.has_infer() {
|
||||
span_bug!(
|
||||
hir_id.to_span(self.fcx.tcx),
|
||||
"writeback: `{:?}` has inference variables",
|
||||
c_ty
|
||||
);
|
||||
};
|
||||
|
||||
(hir_id, *c_ty)
|
||||
}),
|
||||
);
|
||||
@@ -532,17 +522,7 @@ fn visit_user_provided_sigs(&mut self) {
|
||||
assert_eq!(fcx_typeck_results.hir_owner, self.typeck_results.hir_owner);
|
||||
|
||||
self.typeck_results.user_provided_sigs.extend_unord(
|
||||
fcx_typeck_results.user_provided_sigs.items().map(|(&def_id, c_sig)| {
|
||||
if cfg!(debug_assertions) && c_sig.has_infer() {
|
||||
span_bug!(
|
||||
self.fcx.tcx.def_span(def_id),
|
||||
"writeback: `{:?}` has inference variables",
|
||||
c_sig
|
||||
);
|
||||
};
|
||||
|
||||
(def_id, *c_sig)
|
||||
}),
|
||||
fcx_typeck_results.user_provided_sigs.items().map(|(def_id, c_sig)| (*def_id, *c_sig)),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
|
||||
use super::print::PrettyPrinter;
|
||||
use super::{GenericArg, GenericArgKind, Pattern, Region};
|
||||
use crate::infer::canonical::CanonicalVarInfos;
|
||||
use crate::mir::PlaceElem;
|
||||
use crate::ty::print::{FmtPrinter, Printer, with_no_trimmed_paths};
|
||||
use crate::ty::{
|
||||
@@ -780,5 +779,4 @@ fn fold_with<F: TypeFolder<TyCtxt<'tcx>>>(
|
||||
&'tcx ty::List<ty::PolyExistentialPredicate<'tcx>> : mk_poly_existential_predicates,
|
||||
&'tcx ty::List<PlaceElem<'tcx>> : mk_place_elems,
|
||||
&'tcx ty::List<ty::Pattern<'tcx>> : mk_patterns,
|
||||
CanonicalVarInfos<'tcx> : mk_canonical_var_infos,
|
||||
}
|
||||
|
||||
@@ -716,6 +716,8 @@ pub struct UserTypeAnnotationIndex {
|
||||
|
||||
#[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable, TypeFoldable, TypeVisitable)]
|
||||
pub struct CanonicalUserTypeAnnotation<'tcx> {
|
||||
#[type_foldable(identity)]
|
||||
#[type_visitable(ignore)]
|
||||
pub user_ty: Box<CanonicalUserType<'tcx>>,
|
||||
pub span: Span,
|
||||
pub inferred_ty: Ty<'tcx>,
|
||||
|
||||
@@ -34,7 +34,6 @@ pub struct CanonicalQueryInput<I: Interner, V> {
|
||||
#[derive_where(Eq; I: Interner, V: Eq)]
|
||||
#[derive_where(Debug; I: Interner, V: fmt::Debug)]
|
||||
#[derive_where(Copy; I: Interner, V: Copy)]
|
||||
#[derive(TypeVisitable_Generic, TypeFoldable_Generic)]
|
||||
#[cfg_attr(
|
||||
feature = "nightly",
|
||||
derive(Encodable_NoContext, Decodable_NoContext, HashStable_NoContext)
|
||||
@@ -147,7 +146,6 @@ pub fn expect_placeholder_index(self) -> usize {
|
||||
/// in the type-theory sense of the term -- i.e., a "meta" type system
|
||||
/// that analyzes type-like values.
|
||||
#[derive_where(Clone, Copy, Hash, PartialEq, Eq, Debug; I: Interner)]
|
||||
#[derive(TypeVisitable_Generic, TypeFoldable_Generic)]
|
||||
#[cfg_attr(
|
||||
feature = "nightly",
|
||||
derive(Decodable_NoContext, Encodable_NoContext, HashStable_NoContext)
|
||||
|
||||
Reference in New Issue
Block a user