@@ -233,8 +233,8 @@ fn check_opaque(tcx: TyCtxt<'_>, def_id: LocalDefId) {
233233
234234 // HACK(jynelson): trying to infer the type of `impl trait` breaks documenting
235235 // `async-std` (and `pub async fn` in general).
236- // Since rustdoc doesn't care about the concrete type behind `impl Trait`, just don't look at it!
237- // See https://github.com/rust-lang/rust/issues/75100
236+ // Since rustdoc doesn't care about the concrete type behind `impl Trait`, just don't look at
237+ // it! See https://github.com/rust-lang/rust/issues/75100
238238 if tcx. sess . opts . actually_rustdoc {
239239 return ;
240240 }
@@ -322,7 +322,8 @@ fn check_opaque_meets_bounds<'tcx>(
322322 } ;
323323 let param_env = tcx. param_env ( defining_use_anchor) ;
324324
325- // FIXME(#132279): Once `PostBorrowckAnalysis` is supported in the old solver, this branch should be removed.
325+ // FIXME(#132279): Once `PostBorrowckAnalysis` is supported in the old solver, this branch
326+ // should be removed.
326327 let infcx = tcx. infer_ctxt ( ) . build ( if tcx. next_trait_solver_globally ( ) {
327328 TypingMode :: post_borrowck_analysis ( tcx, defining_use_anchor)
328329 } else {
@@ -401,9 +402,9 @@ fn check_opaque_meets_bounds<'tcx>(
401402 }
402403 }
403404
404- // Additionally require the hidden type to be well-formed with only the generics of the opaque type.
405- // Defining use functions may have more bounds than the opaque type, which is ok, as long as the
406- // hidden type is well formed even without those bounds.
405+ // Additionally require the hidden type to be well-formed with only the generics of the opaque
406+ // type. Defining use functions may have more bounds than the opaque type, which is ok, as long
407+ // as the hidden type is well formed even without those bounds.
407408 let predicate =
408409 ty:: Binder :: dummy ( ty:: PredicateKind :: Clause ( ty:: ClauseKind :: WellFormed ( hidden_ty. into ( ) ) ) ) ;
409410 ocx. register_obligation ( Obligation :: new ( tcx, misc_cause. clone ( ) , param_env, predicate) ) ;
@@ -434,7 +435,8 @@ fn check_opaque_meets_bounds<'tcx>(
434435 let _ = infcx. take_opaque_types ( ) ;
435436 Ok ( ( ) )
436437 } else {
437- // Check that any hidden types found during wf checking match the hidden types that `type_of` sees.
438+ // Check that any hidden types found during wf checking match the hidden types that
439+ // `type_of` sees.
438440 for ( mut key, mut ty) in infcx. take_opaque_types ( ) {
439441 ty. ty = infcx. resolve_vars_if_possible ( ty. ty ) ;
440442 key = infcx. resolve_vars_if_possible ( key) ;
@@ -686,7 +688,8 @@ fn check_opaque_precise_captures<'tcx>(tcx: TyCtxt<'tcx>, opaque_def_id: LocalDe
686688 ty:: GenericParamDefKind :: Lifetime => {
687689 let use_span = tcx. def_span ( param. def_id ) ;
688690 let opaque_span = tcx. def_span ( opaque_def_id) ;
689- // Check if the lifetime param was captured but isn't named in the precise captures list.
691+ // Check if the lifetime param was captured but isn't named in the precise
692+ // captures list.
690693 if variances[ param. index as usize ] == ty:: Invariant {
691694 if let DefKind :: OpaqueTy = tcx. def_kind ( tcx. parent ( param. def_id ) )
692695 && let Some ( def_id) = tcx
@@ -1519,15 +1522,17 @@ fn check_enum(tcx: TyCtxt<'_>, def_id: LocalDefId) {
15191522 check_unsafe_fields ( tcx, def_id) ;
15201523}
15211524
1522- /// Part of enum check. Given the discriminants of an enum, errors if two or more discriminants are equal
1525+ /// Part of enum check. Given the discriminants of an enum, errors if two or more discriminants are
1526+ /// equal.
15231527fn detect_discriminant_duplicate < ' tcx > ( tcx : TyCtxt < ' tcx > , adt : ty:: AdtDef < ' tcx > ) {
15241528 // Helper closure to reduce duplicate code. This gets called everytime we detect a duplicate.
15251529 // Here `idx` refers to the order of which the discriminant appears, and its index in `vs`
15261530 let report = |dis : Discr < ' tcx > , idx, err : & mut Diag < ' _ > | {
15271531 let var = adt. variant ( idx) ; // HIR for the duplicate discriminant
15281532 let ( span, display_discr) = match var. discr {
15291533 ty:: VariantDiscr :: Explicit ( discr_def_id) => {
1530- // In the case the discriminant is both a duplicate and overflowed, let the user know
1534+ // In the case the discriminant is both a duplicate and overflowed, let the user
1535+ // know.
15311536 if let hir:: Node :: AnonConst ( expr) =
15321537 tcx. hir_node_by_def_id ( discr_def_id. expect_local ( ) )
15331538 && let hir:: ExprKind :: Lit ( lit) = & tcx. hir ( ) . body ( expr. body ) . value . kind
@@ -1546,7 +1551,7 @@ fn detect_discriminant_duplicate<'tcx>(tcx: TyCtxt<'tcx>, adt: ty::AdtDef<'tcx>)
15461551 // At this point we know this discriminant is a duplicate, and was not explicitly
15471552 // assigned by the user. Here we iterate backwards to fetch the HIR for the last
15481553 // explicitly assigned discriminant, and letting the user know that this was the
1549- // increment startpoint, and how many steps from there leading to the duplicate
1554+ // increment startpoint, and how many steps from there leading to the duplicate.
15501555 if let Some ( explicit_idx) =
15511556 idx. as_u32 ( ) . checked_sub ( distance_to_explicit) . map ( VariantIdx :: from_u32)
15521557 {
@@ -1657,11 +1662,12 @@ fn check_type_alias_type_params_are_used<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalD
16571662 None
16581663 }
16591664 } )
1660- // FIXME: This assumes that elaborated `Sized` bounds come first (which does hold at the
1661- // time of writing). This is a bit fragile since we later use the span to detect elaborated
1662- // `Sized` bounds. If they came last for example, this would break `Trait + /*elab*/Sized`
1663- // since it would overwrite the span of the user-written bound. This could be fixed by
1664- // folding the spans with `Span::to` which requires a bit of effort I think.
1665+ // FIXME: This assumes that elaborated `Sized` bounds come first (which does hold at
1666+ // the time of writing). This is a bit fragile since we later use the span to detect
1667+ // elaborated `Sized` bounds. If they came last for example, this would break `Trait +
1668+ // /*elab*/Sized` since it would overwrite the span of the user-written bound. This
1669+ // could be fixed by folding the spans with `Span::to` which requires a bit of effort I
1670+ // think.
16651671 . collect :: < FxIndexMap < _ , _ > > ( )
16661672 } ) ;
16671673
0 commit comments