@@ -477,8 +477,14 @@ const S_CH: PhantomData<Box<dyn Halfie<'static, 'static> + 'static>> = CH;
477
477
const S_CD : PhantomData <Box <dyn Double <'static , 'static > + 'static >> = CD ;
478
478
```
479
479
480
- In a context where non-` 'static ` lifetimes can be named, those lifetimes
481
- act like early-bound lifetimes in function signatures.
480
+ However, from Rust 1.64 forward, associated ` const ` s were allowed to use general
481
+ elided lifetimes and the wildcard lifetime (as opposed to only elided
482
+ trait object lifetimes). [ This was an accidental stabilization which
483
+ will probably be removed or modified.] ( https://github.com/rust-lang/rust/issues/115010 )
484
+
485
+ In the meanwhile, elided lifetimes act like independent lifetime
486
+ variables on the ` impl ` block. Those in turn act like early-bound
487
+ lifetimes in function signatures.
482
488
``` rust
483
489
#use core :: marker :: PhantomData ;
484
490
#trait Single <'a >: 'a + Send + Sync {}
@@ -491,7 +497,8 @@ impl<'a, 'b> L<'a, 'b> {
491
497
const S_CS : PhantomData <Box <dyn Single <'a > + 'a >> = Self :: CS ;
492
498
}
493
499
```
494
- Elided lifetimes are still inferred to be ` 'static ` ...
500
+
501
+ Elided lifetimes can be inferred to be ` 'static ` elsewhere...
495
502
``` rust
496
503
#use core :: marker :: PhantomData ;
497
504
#trait Single <'a >: 'a + Send + Sync {}
@@ -504,9 +511,9 @@ impl<'a, 'b> L<'a, 'b> {
504
511
const S_SCS : PhantomData <Box <dyn Single <'static > + 'static >> = Self :: SCS ;
505
512
}
506
513
```
507
- * ...however, * this inference only seems to take effect after the
508
- definition itself for elided trait object lifetimes, as demonstrated
509
- by cases such as this being ambiguous:
514
+
515
+ * ...however, * it's really a free variable. Therefore, cases such
516
+ as this are considered ambiguous:
510
517
``` rust
511
518
#use core :: marker :: PhantomData ;
512
519
#trait Double <'a , 'b >: 'a + 'b + Send + Sync {}
@@ -515,9 +522,9 @@ impl<'a, 'b> L<'a, 'b> {
515
522
const EBCD : PhantomData <Box <dyn Double <'a , '_ >>> = PhantomData ;
516
523
}
517
524
```
518
- ...and cases such this saying that the reference lifetime is longer
519
- than the trait object, even when they have the same anonymous
520
- lifetime:
525
+ ...and cases such this are considered to be a borrow check violation,
526
+ as there are no outlives relationships between the anonymously
527
+ introduced lifetime parameters :
521
528
``` rust
522
529
#use core :: marker :: PhantomData ;
523
530
#trait Single <'a >: 'a + Send + Sync {}
@@ -527,6 +534,8 @@ impl<'a, 'b, 'r> R<'a, 'b, 'r> where 'a: 'r, 'b: 'r {
527
534
const RECS : PhantomData <& 'r dyn Single <'_ >> = PhantomData ;
528
535
}
529
536
```
537
+ (There is no implicit bound due to nesting the lifetimes because
538
+ the nesting occurs in the body of the ` impl ` block and not the header.)
530
539
531
540
### ` impl ` headers
532
541
0 commit comments