@@ -233,8 +233,8 @@ fn check_opaque(tcx: TyCtxt<'_>, def_id: LocalDefId) {
233
233
234
234
// HACK(jynelson): trying to infer the type of `impl trait` breaks documenting
235
235
// `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
238
238
if tcx. sess . opts . actually_rustdoc {
239
239
return ;
240
240
}
@@ -322,7 +322,8 @@ fn check_opaque_meets_bounds<'tcx>(
322
322
} ;
323
323
let param_env = tcx. param_env ( defining_use_anchor) ;
324
324
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.
326
327
let infcx = tcx. infer_ctxt ( ) . build ( if tcx. next_trait_solver_globally ( ) {
327
328
TypingMode :: post_borrowck_analysis ( tcx, defining_use_anchor)
328
329
} else {
@@ -401,9 +402,9 @@ fn check_opaque_meets_bounds<'tcx>(
401
402
}
402
403
}
403
404
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.
407
408
let predicate =
408
409
ty:: Binder :: dummy ( ty:: PredicateKind :: Clause ( ty:: ClauseKind :: WellFormed ( hidden_ty. into ( ) ) ) ) ;
409
410
ocx. register_obligation ( Obligation :: new ( tcx, misc_cause. clone ( ) , param_env, predicate) ) ;
@@ -434,7 +435,8 @@ fn check_opaque_meets_bounds<'tcx>(
434
435
let _ = infcx. take_opaque_types ( ) ;
435
436
Ok ( ( ) )
436
437
} 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.
438
440
for ( mut key, mut ty) in infcx. take_opaque_types ( ) {
439
441
ty. ty = infcx. resolve_vars_if_possible ( ty. ty ) ;
440
442
key = infcx. resolve_vars_if_possible ( key) ;
@@ -686,7 +688,8 @@ fn check_opaque_precise_captures<'tcx>(tcx: TyCtxt<'tcx>, opaque_def_id: LocalDe
686
688
ty:: GenericParamDefKind :: Lifetime => {
687
689
let use_span = tcx. def_span ( param. def_id ) ;
688
690
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.
690
693
if variances[ param. index as usize ] == ty:: Invariant {
691
694
if let DefKind :: OpaqueTy = tcx. def_kind ( tcx. parent ( param. def_id ) )
692
695
&& let Some ( def_id) = tcx
@@ -1519,15 +1522,17 @@ fn check_enum(tcx: TyCtxt<'_>, def_id: LocalDefId) {
1519
1522
check_unsafe_fields ( tcx, def_id) ;
1520
1523
}
1521
1524
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.
1523
1527
fn detect_discriminant_duplicate < ' tcx > ( tcx : TyCtxt < ' tcx > , adt : ty:: AdtDef < ' tcx > ) {
1524
1528
// Helper closure to reduce duplicate code. This gets called everytime we detect a duplicate.
1525
1529
// Here `idx` refers to the order of which the discriminant appears, and its index in `vs`
1526
1530
let report = |dis : Discr < ' tcx > , idx, err : & mut Diag < ' _ > | {
1527
1531
let var = adt. variant ( idx) ; // HIR for the duplicate discriminant
1528
1532
let ( span, display_discr) = match var. discr {
1529
1533
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.
1531
1536
if let hir:: Node :: AnonConst ( expr) =
1532
1537
tcx. hir_node_by_def_id ( discr_def_id. expect_local ( ) )
1533
1538
&& 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>)
1546
1551
// At this point we know this discriminant is a duplicate, and was not explicitly
1547
1552
// assigned by the user. Here we iterate backwards to fetch the HIR for the last
1548
1553
// 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.
1550
1555
if let Some ( explicit_idx) =
1551
1556
idx. as_u32 ( ) . checked_sub ( distance_to_explicit) . map ( VariantIdx :: from_u32)
1552
1557
{
@@ -1657,11 +1662,12 @@ fn check_type_alias_type_params_are_used<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalD
1657
1662
None
1658
1663
}
1659
1664
} )
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.
1665
1671
. collect :: < FxIndexMap < _ , _ > > ( )
1666
1672
} ) ;
1667
1673
0 commit comments