File tree Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change 1+ // build-pass
2+
3+ #![ feature( adt_const_params) ]
4+ #![ allow( incomplete_features) ]
5+
6+ #[ derive( PartialEq , Eq ) ]
7+ struct Yikes ;
8+
9+ impl Yikes {
10+ fn mut_self ( & mut self ) { }
11+ }
12+
13+ fn foo < const YIKES : Yikes > ( ) {
14+ YIKES . mut_self ( )
15+ //~^ WARNING taking a mutable reference
16+ }
17+
18+ fn main ( ) {
19+ foo :: < { Yikes } > ( )
20+ }
Original file line number Diff line number Diff line change 1+ warning: taking a mutable reference to a `const` item
2+ --> $DIR/thir-constparam-temp.rs:14:5
3+ |
4+ LL | YIKES.mut_self()
5+ | ^^^^^^^^^^^^^^^^
6+ |
7+ = note: `#[warn(const_item_mutation)]` on by default
8+ = note: each usage of a `const` item creates a new temporary
9+ = note: the mutable reference will refer to this temporary, not the original `const` item
10+ note: mutable reference created due to call to this method
11+ --> $DIR/thir-constparam-temp.rs:10:5
12+ |
13+ LL | fn mut_self(&mut self) {}
14+ | ^^^^^^^^^^^^^^^^^^^^^^
15+ note: `const` item defined here
16+ --> $DIR/thir-constparam-temp.rs:13:14
17+ |
18+ LL | fn foo<const YIKES: Yikes>() {
19+ | ^^^^^
20+
21+ warning: 1 warning emitted
22+
You can’t perform that action at this time.
0 commit comments