File tree 3 files changed +11
-4
lines changed
3 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -1502,7 +1502,8 @@ pub struct Ref<'b, T: ?Sized + 'b> {
1502
1502
}
1503
1503
1504
1504
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1505
- impl < T : ?Sized > Deref for Ref < ' _ , T > {
1505
+ #[ rustc_const_unstable( feature = "const_deref" , issue = "88955" ) ]
1506
+ impl < T : ?Sized > const Deref for Ref < ' _ , T > {
1506
1507
type Target = T ;
1507
1508
1508
1509
#[ inline]
Original file line number Diff line number Diff line change @@ -494,22 +494,27 @@ fn const_refcell() {
494
494
{
495
495
assert ! ( a. try_borrow( ) . is_ok( ) ) ;
496
496
assert ! ( a. try_borrow_mut( ) . is_ok( ) ) ;
497
- let _a = a. borrow ( ) ;
497
+ let a_ref = a. borrow ( ) ;
498
+ assert ! ( * a_ref == 0 ) ;
498
499
assert ! ( a. try_borrow( ) . is_ok( ) ) ;
499
500
assert ! ( a. try_borrow_mut( ) . is_err( ) ) ;
500
501
}
501
502
a
502
503
} ;
503
504
// Check that `borrow_mut` is usable at compile-time
504
505
const BORROW_MUT_TEST : RefCell < u32 > = {
505
- let a = RefCell :: new ( 0 ) ;
506
+ let mut a = RefCell :: new ( 0 ) ;
506
507
{
507
508
assert ! ( a. try_borrow( ) . is_ok( ) ) ;
508
509
assert ! ( a. try_borrow_mut( ) . is_ok( ) ) ;
509
- let _a = a. borrow_mut ( ) ;
510
+ let mut a_ref = a. borrow_mut ( ) ;
511
+ assert ! ( * a_ref == 0 ) ;
512
+ * a_ref = 10 ;
513
+ assert ! ( * a_ref == 10 ) ;
510
514
assert ! ( a. try_borrow( ) . is_err( ) ) ;
511
515
assert ! ( a. try_borrow_mut( ) . is_err( ) ) ;
512
516
}
517
+ assert ! ( * a. get_mut( ) == 10 ) ;
513
518
a
514
519
} ;
515
520
Original file line number Diff line number Diff line change 15
15
#![ feature( cell_update) ]
16
16
#![ feature( char_max_len) ]
17
17
#![ feature( clone_to_uninit) ]
18
+ #![ feature( const_deref) ]
18
19
#![ feature( const_destruct) ]
19
20
#![ feature( const_eval_select) ]
20
21
#![ feature( const_ref_cell) ]
You can’t perform that action at this time.
0 commit comments