Skip to content

Commit 3888f76

Browse files
committed
Improve formatting of some comments.
I.e. fixing comments lines that are too long or too short.
1 parent 1cb183f commit 3888f76

File tree

6 files changed

+50
-53
lines changed

6 files changed

+50
-53
lines changed

compiler/rustc_infer/src/infer/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,8 +1012,8 @@ impl<'tcx> InferCtxt<'tcx> {
10121012
ty::Const::new_infer(self.tcx, ty::InferConst::EffectVar(effect_vid)).into()
10131013
}
10141014

1015-
/// Given a set of generics defined on a type or impl, returns the generic parameters mapping each
1016-
/// type/region parameter to a fresh inference variable.
1015+
/// Given a set of generics defined on a type or impl, returns the generic parameters mapping
1016+
/// each type/region parameter to a fresh inference variable.
10171017
pub fn fresh_args_for_item(&self, span: Span, def_id: DefId) -> GenericArgsRef<'tcx> {
10181018
GenericArgs::for_item(self.tcx, def_id, |param, _| self.var_for_def(span, param))
10191019
}
@@ -1391,10 +1391,10 @@ impl<'tcx> InferCtxt<'tcx> {
13911391
///
13921392
/// The constant can be located on a trait like `<A as B>::C`, in which case the given
13931393
/// generic parameters and environment are used to resolve the constant. Alternatively if the
1394-
/// constant has generic parameters in scope the instantiations are used to evaluate the value of
1395-
/// the constant. For example in `fn foo<T>() { let _ = [0; bar::<T>()]; }` the repeat count
1396-
/// constant `bar::<T>()` requires a instantiation for `T`, if the instantiation for `T` is still
1397-
/// too generic for the constant to be evaluated then `Err(ErrorHandled::TooGeneric)` is
1394+
/// constant has generic parameters in scope the instantiations are used to evaluate the value
1395+
/// of the constant. For example in `fn foo<T>() { let _ = [0; bar::<T>()]; }` the repeat count
1396+
/// constant `bar::<T>()` requires a instantiation for `T`, if the instantiation for `T` is
1397+
/// still too generic for the constant to be evaluated then `Err(ErrorHandled::TooGeneric)` is
13981398
/// returned.
13991399
///
14001400
/// This handles inferences variables within both `param_env` and `args` by

compiler/rustc_infer/src/infer/opaque_types/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,11 @@ impl<'tcx> InferCtxt<'tcx> {
148148
}
149149

150150
if let ty::Alias(ty::Opaque, ty::AliasTy { def_id: b_def_id, .. }) = *b.kind() {
151-
// We could accept this, but there are various ways to handle this situation, and we don't
152-
// want to make a decision on it right now. Likely this case is so super rare anyway, that
153-
// no one encounters it in practice.
154-
// It does occur however in `fn fut() -> impl Future<Output = i32> { async { 42 } }`,
155-
// where it is of no concern, so we only check for TAITs.
151+
// We could accept this, but there are various ways to handle this situation,
152+
// and we don't want to make a decision on it right now. Likely this case is so
153+
// super rare anyway, that no one encounters it in practice. It does occur
154+
// however in `fn fut() -> impl Future<Output = i32> { async { 42 } }`, where
155+
// it is of no concern, so we only check for TAITs.
156156
if self.can_define_opaque_ty(b_def_id)
157157
&& self.tcx.is_type_alias_impl_trait(b_def_id)
158158
{

compiler/rustc_infer/src/infer/outlives/obligations.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -396,11 +396,12 @@ where
396396
// 'a` in the environment but `trait Foo<'b> { type Item: 'b
397397
// }` in the trait definition.
398398
approx_env_bounds.retain(|bound_outlives| {
399-
// OK to skip binder because we only manipulate and compare against other
400-
// values from the same binder. e.g. if we have (e.g.) `for<'a> <T as Trait<'a>>::Item: 'a`
401-
// in `bound`, the `'a` will be a `^1` (bound, debruijn index == innermost) region.
402-
// If the declaration is `trait Trait<'b> { type Item: 'b; }`, then `projection_declared_bounds_from_trait`
403-
// will be invoked with `['b => ^1]` and so we will get `^1` returned.
399+
// OK to skip binder because we only manipulate and compare against other values from
400+
// the same binder. e.g. if we have (e.g.) `for<'a> <T as Trait<'a>>::Item: 'a` in
401+
// `bound`, the `'a` will be a `^1` (bound, debruijn index == innermost) region. If the
402+
// declaration is `trait Trait<'b> { type Item: 'b; }`, then
403+
// `projection_declared_bounds_from_trait` will be invoked with `['b => ^1]` and so we
404+
// will get `^1` returned.
404405
let bound = bound_outlives.skip_binder();
405406
let ty::Alias(_, alias_ty) = bound.0.kind() else { bug!("expected AliasTy") };
406407
self.verify_bound.declared_bounds_from_definition(*alias_ty).all(|r| r != bound.1)

compiler/rustc_infer/src/infer/region_constraints/leak_check.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> {
5555
/// * what placeholder they must outlive transitively
5656
/// * if they must also be equal to a placeholder, report an error because `P1: P2`
5757
/// * minimum universe U of all SCCs they must outlive
58-
/// * if they must also be equal to a placeholder P, and U cannot name P, report an error, as that
59-
/// indicates `P: R` and `R` is in an incompatible universe
58+
/// * if they must also be equal to a placeholder P, and U cannot name P, report an error, as
59+
/// that indicates `P: R` and `R` is in an incompatible universe
6060
///
6161
/// To improve performance and for the old trait solver caching to be sound, this takes
6262
/// 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> {
216216
// Walk over each `scc2` such that `scc1: scc2` and compute:
217217
//
218218
// * `scc1_universe`: the minimum universe of `scc2` and the constituents of `scc1`
219-
// * `succ_bound`: placeholder `P` that the successors must outlive, if any (if there are multiple,
220-
// we pick one arbitrarily)
219+
// * `succ_bound`: placeholder `P` that the successors must outlive, if any (if there
220+
// are multiple, we pick one arbitrarily)
221221
let mut scc1_universe = self.scc_universes[scc1];
222222
let mut succ_bound = None;
223223
for &scc2 in self.mini_graph.sccs.successors(scc1) {
@@ -260,7 +260,8 @@ impl<'a, 'b, 'tcx> LeakCheck<'a, 'b, 'tcx> {
260260
self.scc_placeholders[scc1] = succ_bound;
261261
}
262262

263-
// At this point, `scc_placeholder[scc1]` stores some placeholder that `scc1` must outlive (if any).
263+
// At this point, `scc_placeholder[scc1]` stores some placeholder that `scc1` must
264+
// outlive (if any).
264265
}
265266
Ok(())
266267
}

compiler/rustc_infer/src/infer/relate/generalize.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ impl<'tcx> InferCtxt<'tcx> {
5050
// Then the `generalized_ty` would be `&'?2 ?3`, where `'?2` and `?3` are fresh
5151
// region/type inference variables.
5252
//
53-
// We then relate `generalized_ty <: source_ty`,adding constraints like `'x: '?2` and `?1 <: ?3`.
53+
// We then relate `generalized_ty <: source_ty`, adding constraints like `'x: '?2` and
54+
// `?1 <: ?3`.
5455
let Generalization { value_may_be_infer: generalized_ty, has_unconstrained_ty_var } = self
5556
.generalize(
5657
relation.span(),
@@ -104,7 +105,8 @@ impl<'tcx> InferCtxt<'tcx> {
104105
&ty::Alias(ty::Projection, data) => {
105106
// FIXME: This does not handle subtyping correctly, we could
106107
// instead create a new inference variable `?normalized_source`, emitting
107-
// `Projection(normalized_source, ?ty_normalized)` and `?normalized_source <: generalized_ty`.
108+
// `Projection(normalized_source, ?ty_normalized)` and
109+
// `?normalized_source <: generalized_ty`.
108110
relation.register_predicates([ty::ProjectionPredicate {
109111
projection_term: data.into(),
110112
term: generalized_ty.into(),

compiler/rustc_infer/src/traits/project.rs

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -92,38 +92,31 @@ pub enum ProjectionCacheEntry<'tcx> {
9292
Error,
9393
NormalizedTerm {
9494
ty: NormalizedTerm<'tcx>,
95-
/// If we were able to successfully evaluate the
96-
/// corresponding cache entry key during predicate
97-
/// evaluation, then this field stores the final
98-
/// result obtained from evaluating all of the projection
99-
/// sub-obligations. During evaluation, we will skip
100-
/// evaluating the cached sub-obligations in `ty`
101-
/// if this field is set. Evaluation only
102-
/// cares about the final result, so we don't
103-
/// care about any region constraint side-effects
104-
/// produced by evaluating the sub-obligations.
95+
/// If we were able to successfully evaluate the corresponding cache
96+
/// entry key during predicate evaluation, then this field stores the
97+
/// final result obtained from evaluating all of the projection
98+
/// sub-obligations. During evaluation, we will skip evaluating the
99+
/// cached sub-obligations in `ty` if this field is set. Evaluation
100+
/// only cares about the final result, so we don't care about any
101+
/// region constraint side-effects produced by evaluating the
102+
/// sub-obligations.
105103
///
106-
/// Additionally, we will clear out the sub-obligations
107-
/// entirely if we ever evaluate the cache entry (along
108-
/// with all its sub obligations) to `EvaluatedToOk`.
109-
/// This affects all users of the cache, not just evaluation.
110-
/// Since a result of `EvaluatedToOk` means that there were
111-
/// no region obligations that need to be tracked, it's
112-
/// fine to forget about the sub-obligations - they
113-
/// don't provide any additional information. However,
114-
/// we do *not* discard any obligations when we see
115-
/// `EvaluatedToOkModuloRegions` - we don't know
116-
/// which sub-obligations may introduce region constraints,
117-
/// so we keep them all to be safe.
104+
/// Additionally, we will clear out the sub-obligations entirely if we
105+
/// ever evaluate the cache entry (along with all its sub obligations)
106+
/// to `EvaluatedToOk`. This affects all users of the cache, not just
107+
/// evaluation. Since a result of `EvaluatedToOk` means that there were
108+
/// no region obligations that need to be tracked, it's fine to forget
109+
/// about the sub-obligations - they don't provide any additional
110+
/// information. However, we do *not* discard any obligations when we
111+
/// see `EvaluatedToOkModuloRegions` - we don't know which
112+
/// sub-obligations may introduce region constraints, so we keep them
113+
/// all to be safe.
118114
///
119-
/// When we are not performing evaluation
120-
/// (e.g. in `FulfillmentContext`), we ignore this field,
121-
/// and always re-process the cached sub-obligations
122-
/// (which may have been cleared out - see the above
123-
/// paragraph).
124-
/// This ensures that we do not lose any regions
125-
/// constraints that arise from processing the
126-
/// sub-obligations.
115+
/// When we are not performing evaluation (e.g. in
116+
/// `FulfillmentContext`), we ignore this field, and always re-process
117+
/// the cached sub-obligations (which may have been cleared out - see
118+
/// the above paragraph). This ensures that we do not lose any regions
119+
/// constraints that arise from processing the sub-obligations.
127120
complete: Option<EvaluationResult>,
128121
},
129122
}

0 commit comments

Comments
 (0)