Auto merge of #89230 - workingjubilee:rollup-1swktdq, r=workingjubilee
Rollup of 8 pull requests Successful merges: - #88893 (Add 1.56.0 release notes) - #89001 (Be explicit about using Binder::dummy) - #89072 (Avoid a couple of Symbol::as_str calls in cg_llvm ) - #89104 (Simplify scoped_thread) - #89208 ([rfc 2229] Drop fully captured upvars in the same order as the regular drop code) - #89210 (Add missing time complexities to linked_list.rs) - #89217 (Enable "generate-link-to-definition" option on rust tools docs as well) - #89221 (Give better error for `macro_rules! name!`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
6867dd2c01
52 changed files with 863 additions and 153 deletions
|
@ -524,13 +524,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
for o in obligations {
|
||||
match o.predicate.kind().skip_binder() {
|
||||
ty::PredicateKind::Trait(t) => {
|
||||
let pred = ty::PredicateKind::Trait(ty::TraitPredicate {
|
||||
trait_ref: ty::TraitRef {
|
||||
def_id: t.def_id(),
|
||||
substs: self.infcx.tcx.mk_substs_trait(outer_ty, &[]),
|
||||
},
|
||||
constness: t.constness,
|
||||
});
|
||||
let pred =
|
||||
ty::Binder::dummy(ty::PredicateKind::Trait(ty::TraitPredicate {
|
||||
trait_ref: ty::TraitRef {
|
||||
def_id: t.def_id(),
|
||||
substs: self.infcx.tcx.mk_substs_trait(outer_ty, &[]),
|
||||
},
|
||||
constness: t.constness,
|
||||
}));
|
||||
let obl = Obligation::new(
|
||||
o.cause.clone(),
|
||||
self.param_env,
|
||||
|
|
|
@ -256,10 +256,10 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
|
|||
obligations.push(Obligation::new(
|
||||
self.cause.clone(),
|
||||
self.param_env,
|
||||
ty::PredicateKind::Coerce(ty::CoercePredicate {
|
||||
ty::Binder::dummy(ty::PredicateKind::Coerce(ty::CoercePredicate {
|
||||
a: source_ty,
|
||||
b: target_ty,
|
||||
})
|
||||
}))
|
||||
.to_predicate(self.tcx()),
|
||||
));
|
||||
}
|
||||
|
|
|
@ -585,7 +585,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
self.register_predicate(traits::Obligation::new(
|
||||
cause,
|
||||
self.param_env,
|
||||
ty::PredicateKind::WellFormed(arg).to_predicate(self.tcx),
|
||||
ty::Binder::dummy(ty::PredicateKind::WellFormed(arg)).to_predicate(self.tcx),
|
||||
));
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ use rustc_infer::infer::{self, InferOk};
|
|||
use rustc_middle::ty::subst::Subst;
|
||||
use rustc_middle::ty::subst::{InternalSubsts, SubstsRef};
|
||||
use rustc_middle::ty::GenericParamDefKind;
|
||||
use rustc_middle::ty::{self, ToPolyTraitRef, ToPredicate, Ty, TypeFoldable, WithConstness};
|
||||
use rustc_middle::ty::{self, ToPredicate, Ty, TypeFoldable, WithConstness};
|
||||
use rustc_span::symbol::Ident;
|
||||
use rustc_span::Span;
|
||||
use rustc_trait_selection::traits;
|
||||
|
@ -331,7 +331,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
let trait_ref = ty::TraitRef::new(trait_def_id, substs);
|
||||
|
||||
// Construct an obligation
|
||||
let poly_trait_ref = trait_ref.to_poly_trait_ref();
|
||||
let poly_trait_ref = ty::Binder::dummy(trait_ref);
|
||||
let obligation = traits::Obligation::misc(
|
||||
span,
|
||||
self.body_id,
|
||||
|
@ -413,7 +413,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
obligations.push(traits::Obligation::new(
|
||||
cause,
|
||||
self.param_env,
|
||||
ty::PredicateKind::WellFormed(method_ty.into()).to_predicate(tcx),
|
||||
ty::Binder::dummy(ty::PredicateKind::WellFormed(method_ty.into())).to_predicate(tcx),
|
||||
));
|
||||
|
||||
let callee = MethodCallee { def_id, substs: trait_ref.substs, sig: fn_sig };
|
||||
|
|
|
@ -21,9 +21,7 @@ use rustc_infer::infer::{self, InferOk, TyCtxtInferExt};
|
|||
use rustc_middle::middle::stability;
|
||||
use rustc_middle::ty::subst::{InternalSubsts, Subst, SubstsRef};
|
||||
use rustc_middle::ty::GenericParamDefKind;
|
||||
use rustc_middle::ty::{
|
||||
self, ParamEnvAnd, ToPolyTraitRef, ToPredicate, Ty, TyCtxt, TypeFoldable, WithConstness,
|
||||
};
|
||||
use rustc_middle::ty::{self, ParamEnvAnd, ToPredicate, Ty, TyCtxt, TypeFoldable, WithConstness};
|
||||
use rustc_session::lint;
|
||||
use rustc_span::def_id::LocalDefId;
|
||||
use rustc_span::lev_distance::{find_best_match_for_name, lev_distance};
|
||||
|
@ -967,7 +965,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
|
|||
|
||||
if self.tcx.is_trait_alias(trait_def_id) {
|
||||
// For trait aliases, assume all super-traits are relevant.
|
||||
let bounds = iter::once(trait_ref.to_poly_trait_ref());
|
||||
let bounds = iter::once(ty::Binder::dummy(trait_ref));
|
||||
self.elaborate_bounds(bounds, |this, new_trait_ref, item| {
|
||||
let new_trait_ref = this.erase_late_bound_regions(new_trait_ref);
|
||||
|
||||
|
@ -1372,7 +1370,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
|
|||
trait_ref: ty::TraitRef<'tcx>,
|
||||
) -> traits::SelectionResult<'tcx, traits::Selection<'tcx>> {
|
||||
let cause = traits::ObligationCause::misc(self.span, self.body_id);
|
||||
let predicate = trait_ref.to_poly_trait_ref().to_poly_trait_predicate();
|
||||
let predicate = ty::Binder::dummy(trait_ref).to_poly_trait_predicate();
|
||||
let obligation = traits::Obligation::new(cause, self.param_env, predicate);
|
||||
traits::SelectionContext::new(self).select(&obligation)
|
||||
}
|
||||
|
@ -1470,7 +1468,8 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
}
|
||||
let predicate = trait_ref.without_const().to_predicate(self.tcx);
|
||||
let predicate =
|
||||
ty::Binder::dummy(trait_ref).without_const().to_predicate(self.tcx);
|
||||
let obligation = traits::Obligation::new(cause, self.param_env, predicate);
|
||||
if !self.predicate_may_hold(&obligation) {
|
||||
result = ProbeResult::NoMatch;
|
||||
|
|
|
@ -12,9 +12,7 @@ use rustc_hir::{ExprKind, Node, QPath};
|
|||
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
||||
use rustc_middle::ty::fast_reject::simplify_type;
|
||||
use rustc_middle::ty::print::with_crate_prefix;
|
||||
use rustc_middle::ty::{
|
||||
self, ToPolyTraitRef, ToPredicate, Ty, TyCtxt, TypeFoldable, WithConstness,
|
||||
};
|
||||
use rustc_middle::ty::{self, ToPredicate, Ty, TyCtxt, TypeFoldable, WithConstness};
|
||||
use rustc_span::lev_distance;
|
||||
use rustc_span::symbol::{kw, sym, Ident};
|
||||
use rustc_span::{source_map, FileName, Span};
|
||||
|
@ -53,7 +51,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
.into()],
|
||||
);
|
||||
let trait_ref = ty::TraitRef::new(fn_once, fn_once_substs);
|
||||
let poly_trait_ref = trait_ref.to_poly_trait_ref();
|
||||
let poly_trait_ref = ty::Binder::dummy(trait_ref);
|
||||
let obligation = Obligation::misc(
|
||||
span,
|
||||
self.body_id,
|
||||
|
|
|
@ -602,7 +602,78 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
debug!("For closure={:?}, min_captures={:#?}", closure_def_id, root_var_min_capture_list);
|
||||
debug!(
|
||||
"For closure={:?}, min_captures before sorting={:?}",
|
||||
closure_def_id, root_var_min_capture_list
|
||||
);
|
||||
|
||||
// Now that we have the minimized list of captures, sort the captures by field id.
|
||||
// This causes the closure to capture the upvars in the same order as the fields are
|
||||
// declared which is also the drop order. Thus, in situations where we capture all the
|
||||
// fields of some type, the obserable drop order will remain the same as it previously
|
||||
// was even though we're dropping each capture individually.
|
||||
// See https://github.com/rust-lang/project-rfc-2229/issues/42 and
|
||||
// `src/test/ui/closures/2229_closure_analysis/preserve_field_drop_order.rs`.
|
||||
for (_, captures) in &mut root_var_min_capture_list {
|
||||
captures.sort_by(|capture1, capture2| {
|
||||
for (p1, p2) in capture1.place.projections.iter().zip(&capture2.place.projections) {
|
||||
// We do not need to look at the `Projection.ty` fields here because at each
|
||||
// step of the iteration, the projections will either be the same and therefore
|
||||
// the types must be as well or the current projection will be different and
|
||||
// we will return the result of comparing the field indexes.
|
||||
match (p1.kind, p2.kind) {
|
||||
// Paths are the same, continue to next loop.
|
||||
(ProjectionKind::Deref, ProjectionKind::Deref) => {}
|
||||
(ProjectionKind::Field(i1, _), ProjectionKind::Field(i2, _))
|
||||
if i1 == i2 => {}
|
||||
|
||||
// Fields are different, compare them.
|
||||
(ProjectionKind::Field(i1, _), ProjectionKind::Field(i2, _)) => {
|
||||
return i1.cmp(&i2);
|
||||
}
|
||||
|
||||
// We should have either a pair of `Deref`s or a pair of `Field`s.
|
||||
// Anything else is a bug.
|
||||
(
|
||||
l @ (ProjectionKind::Deref | ProjectionKind::Field(..)),
|
||||
r @ (ProjectionKind::Deref | ProjectionKind::Field(..)),
|
||||
) => bug!(
|
||||
"ProjectionKinds Deref and Field were mismatched: ({:?}, {:?})",
|
||||
l,
|
||||
r
|
||||
),
|
||||
(
|
||||
l
|
||||
@
|
||||
(ProjectionKind::Index
|
||||
| ProjectionKind::Subslice
|
||||
| ProjectionKind::Deref
|
||||
| ProjectionKind::Field(..)),
|
||||
r
|
||||
@
|
||||
(ProjectionKind::Index
|
||||
| ProjectionKind::Subslice
|
||||
| ProjectionKind::Deref
|
||||
| ProjectionKind::Field(..)),
|
||||
) => bug!(
|
||||
"ProjectionKinds Index or Subslice were unexpected: ({:?}, {:?})",
|
||||
l,
|
||||
r
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
unreachable!(
|
||||
"we captured two identical projections: capture1 = {:?}, capture2 = {:?}",
|
||||
capture1, capture2
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
debug!(
|
||||
"For closure={:?}, min_captures after sorting={:#?}",
|
||||
closure_def_id, root_var_min_capture_list
|
||||
);
|
||||
typeck_results.closure_min_captures.insert(closure_def_id, root_var_min_capture_list);
|
||||
}
|
||||
|
||||
|
|
|
@ -593,10 +593,10 @@ fn check_type_defn<'tcx, F>(
|
|||
fcx.register_predicate(traits::Obligation::new(
|
||||
cause,
|
||||
fcx.param_env,
|
||||
ty::PredicateKind::ConstEvaluatable(ty::Unevaluated::new(
|
||||
ty::Binder::dummy(ty::PredicateKind::ConstEvaluatable(ty::Unevaluated::new(
|
||||
ty::WithOptConstParam::unknown(discr_def_id.to_def_id()),
|
||||
discr_substs,
|
||||
))
|
||||
)))
|
||||
.to_predicate(tcx),
|
||||
));
|
||||
}
|
||||
|
@ -1204,10 +1204,10 @@ fn receiver_is_implemented(
|
|||
cause: ObligationCause<'tcx>,
|
||||
receiver_ty: Ty<'tcx>,
|
||||
) -> bool {
|
||||
let trait_ref = ty::TraitRef {
|
||||
let trait_ref = ty::Binder::dummy(ty::TraitRef {
|
||||
def_id: receiver_trait_def_id,
|
||||
substs: fcx.tcx.mk_substs_trait(receiver_ty, &[]),
|
||||
};
|
||||
});
|
||||
|
||||
let obligation = traits::Obligation::new(
|
||||
cause,
|
||||
|
|
|
@ -40,7 +40,7 @@ use rustc_middle::ty::query::Providers;
|
|||
use rustc_middle::ty::subst::InternalSubsts;
|
||||
use rustc_middle::ty::util::Discr;
|
||||
use rustc_middle::ty::util::IntTypeExt;
|
||||
use rustc_middle::ty::{self, AdtKind, Const, DefIdTree, ToPolyTraitRef, Ty, TyCtxt};
|
||||
use rustc_middle::ty::{self, AdtKind, Const, DefIdTree, Ty, TyCtxt};
|
||||
use rustc_middle::ty::{ReprOptions, ToPredicate, WithConstness};
|
||||
use rustc_session::lint;
|
||||
use rustc_session::parse::feature_err;
|
||||
|
@ -2042,7 +2042,9 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP
|
|||
match item.kind {
|
||||
ItemKind::Impl(ref impl_) => {
|
||||
if impl_.defaultness.is_default() {
|
||||
is_default_impl_trait = tcx.impl_trait_ref(def_id);
|
||||
is_default_impl_trait = tcx
|
||||
.impl_trait_ref(def_id)
|
||||
.map(|trait_ref| ty::Binder::dummy(trait_ref));
|
||||
}
|
||||
&impl_.generics
|
||||
}
|
||||
|
@ -2122,10 +2124,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP
|
|||
// (see below). Recall that a default impl is not itself an impl, but rather a
|
||||
// set of defaults that can be incorporated into another impl.
|
||||
if let Some(trait_ref) = is_default_impl_trait {
|
||||
predicates.insert((
|
||||
trait_ref.to_poly_trait_ref().without_const().to_predicate(tcx),
|
||||
tcx.def_span(def_id),
|
||||
));
|
||||
predicates.insert((trait_ref.without_const().to_predicate(tcx), tcx.def_span(def_id)));
|
||||
}
|
||||
|
||||
// Collect the region predicates that were declared inline as
|
||||
|
@ -2238,8 +2237,10 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP
|
|||
}
|
||||
_ => bug!(),
|
||||
};
|
||||
let pred = ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(r1, r2))
|
||||
.to_predicate(icx.tcx);
|
||||
let pred = ty::Binder::dummy(ty::PredicateKind::RegionOutlives(
|
||||
ty::OutlivesPredicate(r1, r2),
|
||||
))
|
||||
.to_predicate(icx.tcx);
|
||||
|
||||
(pred, span)
|
||||
}))
|
||||
|
@ -2304,7 +2305,8 @@ fn const_evaluatable_predicates_of<'tcx>(
|
|||
assert_eq!(uv.promoted, None);
|
||||
let span = self.tcx.hir().span(c.hir_id);
|
||||
self.preds.insert((
|
||||
ty::PredicateKind::ConstEvaluatable(uv.shrink()).to_predicate(self.tcx),
|
||||
ty::Binder::dummy(ty::PredicateKind::ConstEvaluatable(uv.shrink()))
|
||||
.to_predicate(self.tcx),
|
||||
span,
|
||||
));
|
||||
}
|
||||
|
|
|
@ -83,7 +83,8 @@ fn diagnostic_hir_wf_check<'tcx>(
|
|||
traits::Obligation::new(
|
||||
cause,
|
||||
self.param_env,
|
||||
ty::PredicateKind::WellFormed(tcx_ty.into()).to_predicate(self.tcx),
|
||||
ty::Binder::dummy(ty::PredicateKind::WellFormed(tcx_ty.into()))
|
||||
.to_predicate(self.tcx),
|
||||
),
|
||||
);
|
||||
|
||||
|
|
|
@ -104,13 +104,15 @@ fn inferred_outlives_crate(tcx: TyCtxt<'_>, (): ()) -> CratePredicatesMap<'_> {
|
|||
|(ty::OutlivesPredicate(kind1, region2), &span)| {
|
||||
match kind1.unpack() {
|
||||
GenericArgKind::Type(ty1) => Some((
|
||||
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(ty1, region2))
|
||||
.to_predicate(tcx),
|
||||
ty::Binder::dummy(ty::PredicateKind::TypeOutlives(
|
||||
ty::OutlivesPredicate(ty1, region2),
|
||||
))
|
||||
.to_predicate(tcx),
|
||||
span,
|
||||
)),
|
||||
GenericArgKind::Lifetime(region1) => Some((
|
||||
ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(
|
||||
region1, region2,
|
||||
ty::Binder::dummy(ty::PredicateKind::RegionOutlives(
|
||||
ty::OutlivesPredicate(region1, region2),
|
||||
))
|
||||
.to_predicate(tcx),
|
||||
span,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue