File tree Expand file tree Collapse file tree 3 files changed +40
-0
lines changed 
tests/ui/consts/const-eval Expand file tree Collapse file tree 3 files changed +40
-0
lines changed Original file line number Diff line number Diff line change 1+ // This checks that function pointer signatures that are referenced mutably 
2+ // but contain a &mut T parameter still fail in a constant context: see issue #114994. 
3+ // 
4+ // check-fail 
5+ 
6+ const  fn  use_mut_const_fn ( _f :  & mut  fn ( & mut  String ) )  {  //~ ERROR mutable references are not allowed in constant functions 
7+     ( ) 
8+ } 
9+ 
10+ fn  main ( )  { } 
Original file line number Diff line number Diff line change 1+ error[E0658]: mutable references are not allowed in constant functions
2+   --> $DIR/issue-114994-fail.rs:6:27
3+    |
4+ LL | const fn use_mut_const_fn(_f: &mut fn(&mut String)) {
5+    |                           ^^
6+    |
7+    = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
8+    = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
9+ 
10+ error: aborting due to previous error
11+ 
12+ For more information about this error, try `rustc --explain E0658`.
Original file line number Diff line number Diff line change 1+ // This checks that function pointer signatures containing &mut T types 
2+ // work in a constant context: see issue #114994. 
3+ // 
4+ // check-pass 
5+ 
6+ const  fn  use_const_fn ( _f :  fn ( & mut  String ) )  { 
7+     ( ) 
8+ } 
9+ 
10+ const  fn  get_some_fn ( )  -> fn ( & mut  String )  { 
11+     String :: clear
12+ } 
13+ 
14+ const  fn  some_const_fn ( )  { 
15+     let  _f:  fn ( & mut  String )  = String :: clear; 
16+ } 
17+ 
18+ fn  main ( )  { } 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments