forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use proper type when applying deref adjustment in const
- Loading branch information
1 parent
a6434ef
commit c64038a
Showing
3 changed files
with
33 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
//@ check-pass | ||
|
||
#![feature(const_deref)] | ||
#![feature(const_trait_impl)] | ||
|
||
use std::ops::Deref; | ||
|
||
struct Wrap<T>(T); | ||
struct Foo; | ||
|
||
impl Foo { | ||
const fn call(&self) {} | ||
} | ||
|
||
impl<T> const Deref for Wrap<T> { | ||
type Target = T; | ||
|
||
fn deref(&self) -> &Self::Target { | ||
&self.0 | ||
} | ||
} | ||
|
||
const fn foo() { | ||
let x = Wrap(Foo); | ||
x.call(); | ||
} | ||
|
||
fn main() {} |