forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add regression test for rust-lang#91489
- Loading branch information
Showing
1 changed file
with
40 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// check-pass | ||
|
||
// regression test for #91489 | ||
|
||
use std::borrow::Borrow; | ||
use std::borrow::Cow; | ||
|
||
pub struct VariantType {} | ||
pub struct VariantTy {} | ||
|
||
impl Borrow<VariantTy> for VariantType { | ||
fn borrow(&self) -> &VariantTy { | ||
unimplemented!() | ||
} | ||
} | ||
|
||
impl ToOwned for VariantTy { | ||
type Owned = VariantType; | ||
fn to_owned(&self) -> VariantType { | ||
unimplemented!() | ||
} | ||
} | ||
|
||
impl VariantTy { | ||
pub fn as_str(&self) -> () {} | ||
} | ||
|
||
// the presence of this was causing all attempts to call `as_str` on | ||
// `Cow<'_, VariantTy>, including in itself, to not find the method | ||
static _TYP: () = { | ||
let _ = || { | ||
// should be found | ||
Cow::Borrowed(&VariantTy {}).as_str(); | ||
}; | ||
}; | ||
|
||
fn main() { | ||
// should be found | ||
Cow::Borrowed(&VariantTy {}).as_str() | ||
} |