mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-13 15:33:53 +00:00
Improve formatting of some comments.
I.e. fixing comments lines that are too long or too short.
This commit is contained in:
parent
27dad009c6
commit
0293827e09
@ -1011,8 +1011,8 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||||||
ty::Const::new_infer(self.tcx, ty::InferConst::EffectVar(effect_vid)).into()
|
ty::Const::new_infer(self.tcx, ty::InferConst::EffectVar(effect_vid)).into()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Given a set of generics defined on a type or impl, returns the generic parameters mapping each
|
/// Given a set of generics defined on a type or impl, returns the generic parameters mapping
|
||||||
/// type/region parameter to a fresh inference variable.
|
/// each type/region parameter to a fresh inference variable.
|
||||||
pub fn fresh_args_for_item(&self, span: Span, def_id: DefId) -> GenericArgsRef<'tcx> {
|
pub fn fresh_args_for_item(&self, span: Span, def_id: DefId) -> GenericArgsRef<'tcx> {
|
||||||
GenericArgs::for_item(self.tcx, def_id, |param, _| self.var_for_def(span, param))
|
GenericArgs::for_item(self.tcx, def_id, |param, _| self.var_for_def(span, param))
|
||||||
}
|
}
|
||||||
@ -1390,10 +1390,10 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||||||
///
|
///
|
||||||
/// The constant can be located on a trait like `<A as B>::C`, in which case the given
|
/// The constant can be located on a trait like `<A as B>::C`, in which case the given
|
||||||
/// generic parameters and environment are used to resolve the constant. Alternatively if the
|
/// generic parameters and environment are used to resolve the constant. Alternatively if the
|
||||||
/// constant has generic parameters in scope the instantiations are used to evaluate the value of
|
/// constant has generic parameters in scope the instantiations are used to evaluate the value
|
||||||
/// the constant. For example in `fn foo<T>() { let _ = [0; bar::<T>()]; }` the repeat count
|
/// of the constant. For example in `fn foo<T>() { let _ = [0; bar::<T>()]; }` the repeat count
|
||||||
/// constant `bar::<T>()` requires a instantiation for `T`, if the instantiation for `T` is still
|
/// constant `bar::<T>()` requires a instantiation for `T`, if the instantiation for `T` is
|
||||||
/// too generic for the constant to be evaluated then `Err(ErrorHandled::TooGeneric)` is
|
/// still too generic for the constant to be evaluated then `Err(ErrorHandled::TooGeneric)` is
|
||||||
/// returned.
|
/// returned.
|
||||||
///
|
///
|
||||||
/// This handles inferences variables within both `param_env` and `args` by
|
/// This handles inferences variables within both `param_env` and `args` by
|
||||||
|
@ -148,11 +148,11 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let ty::Alias(ty::Opaque, ty::AliasTy { def_id: b_def_id, .. }) = *b.kind() {
|
if let ty::Alias(ty::Opaque, ty::AliasTy { def_id: b_def_id, .. }) = *b.kind() {
|
||||||
// We could accept this, but there are various ways to handle this situation, and we don't
|
// We could accept this, but there are various ways to handle this situation,
|
||||||
// want to make a decision on it right now. Likely this case is so super rare anyway, that
|
// and we don't want to make a decision on it right now. Likely this case is so
|
||||||
// no one encounters it in practice.
|
// super rare anyway, that no one encounters it in practice. It does occur
|
||||||
// It does occur however in `fn fut() -> impl Future<Output = i32> { async { 42 } }`,
|
// however in `fn fut() -> impl Future<Output = i32> { async { 42 } }`, where
|
||||||
// where it is of no concern, so we only check for TAITs.
|
// it is of no concern, so we only check for TAITs.
|
||||||
if self.can_define_opaque_ty(b_def_id)
|
if self.can_define_opaque_ty(b_def_id)
|
||||||
&& self.tcx.is_type_alias_impl_trait(b_def_id)
|
&& self.tcx.is_type_alias_impl_trait(b_def_id)
|
||||||
{
|
{
|
||||||
|
@ -396,11 +396,12 @@ where
|
|||||||
// 'a` in the environment but `trait Foo<'b> { type Item: 'b
|
// 'a` in the environment but `trait Foo<'b> { type Item: 'b
|
||||||
// }` in the trait definition.
|
// }` in the trait definition.
|
||||||
approx_env_bounds.retain(|bound_outlives| {
|
approx_env_bounds.retain(|bound_outlives| {
|
||||||
// OK to skip binder because we only manipulate and compare against other
|
// OK to skip binder because we only manipulate and compare against other values from
|
||||||
// values from the same binder. e.g. if we have (e.g.) `for<'a> <T as Trait<'a>>::Item: 'a`
|
// the same binder. e.g. if we have (e.g.) `for<'a> <T as Trait<'a>>::Item: 'a` in
|
||||||
// in `bound`, the `'a` will be a `^1` (bound, debruijn index == innermost) region.
|
// `bound`, the `'a` will be a `^1` (bound, debruijn index == innermost) region. If the
|
||||||
// If the declaration is `trait Trait<'b> { type Item: 'b; }`, then `projection_declared_bounds_from_trait`
|
// declaration is `trait Trait<'b> { type Item: 'b; }`, then
|
||||||
// will be invoked with `['b => ^1]` and so we will get `^1` returned.
|
// `projection_declared_bounds_from_trait` will be invoked with `['b => ^1]` and so we
|
||||||
|
// will get `^1` returned.
|
||||||
let bound = bound_outlives.skip_binder();
|
let bound = bound_outlives.skip_binder();
|
||||||
let ty::Alias(_, alias_ty) = bound.0.kind() else { bug!("expected AliasTy") };
|
let ty::Alias(_, alias_ty) = bound.0.kind() else { bug!("expected AliasTy") };
|
||||||
self.verify_bound.declared_bounds_from_definition(*alias_ty).all(|r| r != bound.1)
|
self.verify_bound.declared_bounds_from_definition(*alias_ty).all(|r| r != bound.1)
|
||||||
|
@ -55,8 +55,8 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> {
|
|||||||
/// * what placeholder they must outlive transitively
|
/// * what placeholder they must outlive transitively
|
||||||
/// * if they must also be equal to a placeholder, report an error because `P1: P2`
|
/// * if they must also be equal to a placeholder, report an error because `P1: P2`
|
||||||
/// * minimum universe U of all SCCs they must outlive
|
/// * minimum universe U of all SCCs they must outlive
|
||||||
/// * if they must also be equal to a placeholder P, and U cannot name P, report an error, as that
|
/// * if they must also be equal to a placeholder P, and U cannot name P, report an error, as
|
||||||
/// indicates `P: R` and `R` is in an incompatible universe
|
/// that indicates `P: R` and `R` is in an incompatible universe
|
||||||
///
|
///
|
||||||
/// To improve performance and for the old trait solver caching to be sound, this takes
|
/// To improve performance and for the old trait solver caching to be sound, this takes
|
||||||
/// an optional snapshot in which case we only look at region constraints added in that
|
/// an optional snapshot in which case we only look at region constraints added in that
|
||||||
@ -216,8 +216,8 @@ impl<'a, 'b, 'tcx> LeakCheck<'a, 'b, 'tcx> {
|
|||||||
// Walk over each `scc2` such that `scc1: scc2` and compute:
|
// Walk over each `scc2` such that `scc1: scc2` and compute:
|
||||||
//
|
//
|
||||||
// * `scc1_universe`: the minimum universe of `scc2` and the constituents of `scc1`
|
// * `scc1_universe`: the minimum universe of `scc2` and the constituents of `scc1`
|
||||||
// * `succ_bound`: placeholder `P` that the successors must outlive, if any (if there are multiple,
|
// * `succ_bound`: placeholder `P` that the successors must outlive, if any (if there
|
||||||
// we pick one arbitrarily)
|
// are multiple, we pick one arbitrarily)
|
||||||
let mut scc1_universe = self.scc_universes[scc1];
|
let mut scc1_universe = self.scc_universes[scc1];
|
||||||
let mut succ_bound = None;
|
let mut succ_bound = None;
|
||||||
for &scc2 in self.mini_graph.sccs.successors(scc1) {
|
for &scc2 in self.mini_graph.sccs.successors(scc1) {
|
||||||
@ -260,7 +260,8 @@ impl<'a, 'b, 'tcx> LeakCheck<'a, 'b, 'tcx> {
|
|||||||
self.scc_placeholders[scc1] = succ_bound;
|
self.scc_placeholders[scc1] = succ_bound;
|
||||||
}
|
}
|
||||||
|
|
||||||
// At this point, `scc_placeholder[scc1]` stores some placeholder that `scc1` must outlive (if any).
|
// At this point, `scc_placeholder[scc1]` stores some placeholder that `scc1` must
|
||||||
|
// outlive (if any).
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,8 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||||||
// Then the `generalized_ty` would be `&'?2 ?3`, where `'?2` and `?3` are fresh
|
// Then the `generalized_ty` would be `&'?2 ?3`, where `'?2` and `?3` are fresh
|
||||||
// region/type inference variables.
|
// region/type inference variables.
|
||||||
//
|
//
|
||||||
// We then relate `generalized_ty <: source_ty`,adding constraints like `'x: '?2` and `?1 <: ?3`.
|
// We then relate `generalized_ty <: source_ty`, adding constraints like `'x: '?2` and
|
||||||
|
// `?1 <: ?3`.
|
||||||
let Generalization { value_may_be_infer: generalized_ty, has_unconstrained_ty_var } = self
|
let Generalization { value_may_be_infer: generalized_ty, has_unconstrained_ty_var } = self
|
||||||
.generalize(
|
.generalize(
|
||||||
relation.span(),
|
relation.span(),
|
||||||
@ -104,7 +105,8 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||||||
&ty::Alias(ty::Projection, data) => {
|
&ty::Alias(ty::Projection, data) => {
|
||||||
// FIXME: This does not handle subtyping correctly, we could
|
// FIXME: This does not handle subtyping correctly, we could
|
||||||
// instead create a new inference variable `?normalized_source`, emitting
|
// instead create a new inference variable `?normalized_source`, emitting
|
||||||
// `Projection(normalized_source, ?ty_normalized)` and `?normalized_source <: generalized_ty`.
|
// `Projection(normalized_source, ?ty_normalized)` and
|
||||||
|
// `?normalized_source <: generalized_ty`.
|
||||||
relation.register_predicates([ty::ProjectionPredicate {
|
relation.register_predicates([ty::ProjectionPredicate {
|
||||||
projection_term: data.into(),
|
projection_term: data.into(),
|
||||||
term: generalized_ty.into(),
|
term: generalized_ty.into(),
|
||||||
|
@ -92,38 +92,31 @@ pub enum ProjectionCacheEntry<'tcx> {
|
|||||||
Error,
|
Error,
|
||||||
NormalizedTerm {
|
NormalizedTerm {
|
||||||
ty: NormalizedTerm<'tcx>,
|
ty: NormalizedTerm<'tcx>,
|
||||||
/// If we were able to successfully evaluate the
|
/// If we were able to successfully evaluate the corresponding cache
|
||||||
/// corresponding cache entry key during predicate
|
/// entry key during predicate evaluation, then this field stores the
|
||||||
/// evaluation, then this field stores the final
|
/// final result obtained from evaluating all of the projection
|
||||||
/// result obtained from evaluating all of the projection
|
/// sub-obligations. During evaluation, we will skip evaluating the
|
||||||
/// sub-obligations. During evaluation, we will skip
|
/// cached sub-obligations in `ty` if this field is set. Evaluation
|
||||||
/// evaluating the cached sub-obligations in `ty`
|
/// only cares about the final result, so we don't care about any
|
||||||
/// if this field is set. Evaluation only
|
/// region constraint side-effects produced by evaluating the
|
||||||
/// cares about the final result, so we don't
|
|
||||||
/// care about any region constraint side-effects
|
|
||||||
/// produced by evaluating the sub-obligations.
|
|
||||||
///
|
|
||||||
/// Additionally, we will clear out the sub-obligations
|
|
||||||
/// entirely if we ever evaluate the cache entry (along
|
|
||||||
/// with all its sub obligations) to `EvaluatedToOk`.
|
|
||||||
/// This affects all users of the cache, not just evaluation.
|
|
||||||
/// Since a result of `EvaluatedToOk` means that there were
|
|
||||||
/// no region obligations that need to be tracked, it's
|
|
||||||
/// fine to forget about the sub-obligations - they
|
|
||||||
/// don't provide any additional information. However,
|
|
||||||
/// we do *not* discard any obligations when we see
|
|
||||||
/// `EvaluatedToOkModuloRegions` - we don't know
|
|
||||||
/// which sub-obligations may introduce region constraints,
|
|
||||||
/// so we keep them all to be safe.
|
|
||||||
///
|
|
||||||
/// When we are not performing evaluation
|
|
||||||
/// (e.g. in `FulfillmentContext`), we ignore this field,
|
|
||||||
/// and always re-process the cached sub-obligations
|
|
||||||
/// (which may have been cleared out - see the above
|
|
||||||
/// paragraph).
|
|
||||||
/// This ensures that we do not lose any regions
|
|
||||||
/// constraints that arise from processing the
|
|
||||||
/// sub-obligations.
|
/// sub-obligations.
|
||||||
|
///
|
||||||
|
/// Additionally, we will clear out the sub-obligations entirely if we
|
||||||
|
/// ever evaluate the cache entry (along with all its sub obligations)
|
||||||
|
/// to `EvaluatedToOk`. This affects all users of the cache, not just
|
||||||
|
/// evaluation. Since a result of `EvaluatedToOk` means that there were
|
||||||
|
/// no region obligations that need to be tracked, it's fine to forget
|
||||||
|
/// about the sub-obligations - they don't provide any additional
|
||||||
|
/// information. However, we do *not* discard any obligations when we
|
||||||
|
/// see `EvaluatedToOkModuloRegions` - we don't know which
|
||||||
|
/// sub-obligations may introduce region constraints, so we keep them
|
||||||
|
/// all to be safe.
|
||||||
|
///
|
||||||
|
/// When we are not performing evaluation (e.g. in
|
||||||
|
/// `FulfillmentContext`), we ignore this field, and always re-process
|
||||||
|
/// the cached sub-obligations (which may have been cleared out - see
|
||||||
|
/// the above paragraph). This ensures that we do not lose any regions
|
||||||
|
/// constraints that arise from processing the sub-obligations.
|
||||||
complete: Option<EvaluationResult>,
|
complete: Option<EvaluationResult>,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user