File tree Expand file tree Collapse file tree 3 files changed +11
-4
lines changed Expand file tree Collapse file tree 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> {
15021502}
15031503
15041504#[ 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 > {
15061507 type Target = T ;
15071508
15081509 #[ inline]
Original file line number Diff line number Diff line change @@ -494,22 +494,27 @@ fn const_refcell() {
494494 {
495495 assert ! ( a. try_borrow( ) . is_ok( ) ) ;
496496 assert ! ( a. try_borrow_mut( ) . is_ok( ) ) ;
497- let _a = a. borrow ( ) ;
497+ let a_ref = a. borrow ( ) ;
498+ assert ! ( * a_ref == 0 ) ;
498499 assert ! ( a. try_borrow( ) . is_ok( ) ) ;
499500 assert ! ( a. try_borrow_mut( ) . is_err( ) ) ;
500501 }
501502 a
502503 } ;
503504 // Check that `borrow_mut` is usable at compile-time
504505 const BORROW_MUT_TEST : RefCell < u32 > = {
505- let a = RefCell :: new ( 0 ) ;
506+ let mut a = RefCell :: new ( 0 ) ;
506507 {
507508 assert ! ( a. try_borrow( ) . is_ok( ) ) ;
508509 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 ) ;
510514 assert ! ( a. try_borrow( ) . is_err( ) ) ;
511515 assert ! ( a. try_borrow_mut( ) . is_err( ) ) ;
512516 }
517+ assert ! ( * a. get_mut( ) == 10 ) ;
513518 a
514519 } ;
515520
Original file line number Diff line number Diff line change 1515#![ feature( cell_update) ]
1616#![ feature( char_max_len) ]
1717#![ feature( clone_to_uninit) ]
18+ #![ feature( const_deref) ]
1819#![ feature( const_destruct) ]
1920#![ feature( const_eval_select) ]
2021#![ feature( const_ref_cell) ]
You can’t perform that action at this time.
0 commit comments