Improve formatting of some comments.

I.e. fixing comments lines that are too long or too short.
This commit is contained in:
Nicholas Nethercote 2024-10-02 14:07:57 +10:00
parent 27dad009c6
commit 0293827e09
6 changed files with 51 additions and 54 deletions

View File

@ -1011,8 +1011,8 @@ pub fn var_for_effect(&self, param: &ty::GenericParamDef) -> GenericArg<'tcx> {
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
/// type/region parameter to a fresh inference variable.
/// Given a set of generics defined on a type or impl, returns the generic parameters mapping
/// each type/region parameter to a fresh inference variable.
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))
}
@ -1390,10 +1390,10 @@ pub fn try_const_eval_resolve(
///
/// 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
/// constant has generic parameters in scope the instantiations are used to evaluate the value 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
/// too generic for the constant to be evaluated then `Err(ErrorHandled::TooGeneric)` is
/// constant has generic parameters in scope the instantiations are used to evaluate the value
/// 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 too generic for the constant to be evaluated then `Err(ErrorHandled::TooGeneric)` is
/// returned.
///
/// This handles inferences variables within both `param_env` and `args` by

View File

@ -148,11 +148,11 @@ pub fn handle_opaque_type(
}
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
// want to make a decision on it right now. Likely this case is so super rare anyway, that
// no one encounters it in practice.
// It does occur however in `fn fut() -> impl Future<Output = i32> { async { 42 } }`,
// where it is of no concern, so we only check for TAITs.
// We could accept this, but there are various ways to handle this situation,
// and we don't want to make a decision on it right now. Likely this case is so
// super rare anyway, that no one encounters it in practice. It does occur
// however in `fn fut() -> impl Future<Output = i32> { async { 42 } }`, where
// it is of no concern, so we only check for TAITs.
if self.can_define_opaque_ty(b_def_id)
&& self.tcx.is_type_alias_impl_trait(b_def_id)
{

View File

@ -396,11 +396,12 @@ fn alias_ty_must_outlive(
// 'a` in the environment but `trait Foo<'b> { type Item: 'b
// }` in the trait definition.
approx_env_bounds.retain(|bound_outlives| {
// OK to skip binder because we only manipulate and compare against other
// values from the same binder. e.g. if we have (e.g.) `for<'a> <T as Trait<'a>>::Item: 'a`
// in `bound`, the `'a` will be a `^1` (bound, debruijn index == innermost) region.
// If the declaration is `trait Trait<'b> { type Item: 'b; }`, then `projection_declared_bounds_from_trait`
// will be invoked with `['b => ^1]` and so we will get `^1` returned.
// OK to skip binder because we only manipulate and compare against other values from
// the same binder. e.g. if we have (e.g.) `for<'a> <T as Trait<'a>>::Item: 'a` in
// `bound`, the `'a` will be a `^1` (bound, debruijn index == innermost) region. If the
// declaration is `trait Trait<'b> { type Item: 'b; }`, then
// `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 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)

View File

@ -55,8 +55,8 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> {
/// * what placeholder they must outlive transitively
/// * if they must also be equal to a placeholder, report an error because `P1: P2`
/// * 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
/// indicates `P: R` and `R` is in an incompatible universe
/// * if they must also be equal to a placeholder P, and U cannot name P, report an error, as
/// 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
/// an optional snapshot in which case we only look at region constraints added in that
@ -216,8 +216,8 @@ fn propagate_scc_value(&mut self) -> RelateResult<'tcx, ()> {
// Walk over each `scc2` such that `scc1: scc2` and compute:
//
// * `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,
// we pick one arbitrarily)
// * `succ_bound`: placeholder `P` that the successors must outlive, if any (if there
// are multiple, we pick one arbitrarily)
let mut scc1_universe = self.scc_universes[scc1];
let mut succ_bound = None;
for &scc2 in self.mini_graph.sccs.successors(scc1) {
@ -260,7 +260,8 @@ fn propagate_scc_value(&mut self) -> RelateResult<'tcx, ()> {
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(())
}

View File

@ -50,7 +50,8 @@ pub fn instantiate_ty_var<R: PredicateEmittingRelation<InferCtxt<'tcx>>>(
// Then the `generalized_ty` would be `&'?2 ?3`, where `'?2` and `?3` are fresh
// 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
.generalize(
relation.span(),
@ -104,7 +105,8 @@ pub fn instantiate_ty_var<R: PredicateEmittingRelation<InferCtxt<'tcx>>>(
&ty::Alias(ty::Projection, data) => {
// FIXME: This does not handle subtyping correctly, we could
// 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 {
projection_term: data.into(),
term: generalized_ty.into(),

View File

@ -92,38 +92,31 @@ pub enum ProjectionCacheEntry<'tcx> {
Error,
NormalizedTerm {
ty: NormalizedTerm<'tcx>,
/// If we were able to successfully evaluate the
/// corresponding cache entry key during predicate
/// evaluation, then this field stores the final
/// result obtained from evaluating all of the projection
/// sub-obligations. During evaluation, we will skip
/// evaluating the cached sub-obligations in `ty`
/// if this field is set. Evaluation only
/// 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
/// If we were able to successfully evaluate the corresponding cache
/// entry key during predicate evaluation, then this field stores the
/// final result obtained from evaluating all of the projection
/// sub-obligations. During evaluation, we will skip evaluating the
/// cached sub-obligations in `ty` if this field is set. Evaluation
/// only 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.
complete: Option<EvaluationResult>,
},
}