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.
Rollup merge of rust-lang#136314 - compiler-errors:const-deref-adj, r…
…=fee1-dead Use proper type when applying deref adjustment in const When applying a deref adjustment to some type `Wrap<T>` which derefs to `T`, we were checking that `T: ~const Deref`, not `Wrap<T>: ~const Deref` like we should have been. r? project-const-traits Fixes rust-lang#136273 Fixes rust-lang#135210 -- I just deleted the test since the regression test is uninteresting
- Loading branch information
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() {} |