Skip to content

Commit c5f8788

Browse files
SNCPlay42fee1-dead
authored andcommitted
add regression test for rust-lang#91489
1 parent 5166f68 commit c5f8788

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

src/test/ui/issues/issue-91489.rs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// check-pass
2+
3+
// regression test for #91489
4+
5+
use std::borrow::Borrow;
6+
use std::borrow::Cow;
7+
8+
pub struct VariantType {}
9+
pub struct VariantTy {}
10+
11+
impl Borrow<VariantTy> for VariantType {
12+
fn borrow(&self) -> &VariantTy {
13+
unimplemented!()
14+
}
15+
}
16+
17+
impl ToOwned for VariantTy {
18+
type Owned = VariantType;
19+
fn to_owned(&self) -> VariantType {
20+
unimplemented!()
21+
}
22+
}
23+
24+
impl VariantTy {
25+
pub fn as_str(&self) -> () {}
26+
}
27+
28+
// the presence of this was causing all attempts to call `as_str` on
29+
// `Cow<'_, VariantTy>, including in itself, to not find the method
30+
static _TYP: () = {
31+
let _ = || {
32+
// should be found
33+
Cow::Borrowed(&VariantTy {}).as_str();
34+
};
35+
};
36+
37+
fn main() {
38+
// should be found
39+
Cow::Borrowed(&VariantTy {}).as_str()
40+
}

0 commit comments

Comments
 (0)