Skip to content

Commit 4571fea

Browse files
authored
Rollup merge of #89412 - lqd:zvariant-repro, r=Aaron1011
Add regression test for issues #88969 and #89119 This adds a regression test to complete #89125, and thus for issues #88969 and #89119, which needed a test. Used with multiple crates, [this](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=f665e7e882059157e0f86cfb09c47187) minimized from `zvariant-2.8.0` reproduces the error on `nightly-2021-09-19`. The test in this PR fails on master if the commit 6dbb9d4 from #89125 is reverted, and passes otherwise since it's now fixed. r? `@Aaron1011`
2 parents e834b9d + bec19a7 commit 4571fea

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// This is the auxiliary crate for the regression test for issue #89119, minimized
2+
// from `zvariant-2.8.0`.
3+
4+
use std::convert::TryFrom;
5+
use std::borrow::Cow;
6+
7+
pub struct Str<'a>(Cow<'a, str>);
8+
impl<'a> Str<'a> {
9+
pub fn to_owned(&self) -> Str<'static> {
10+
todo!()
11+
}
12+
}
13+
14+
pub enum Value<'a> {
15+
Str(Str<'a>),
16+
Value(Box<Value<'a>>),
17+
}
18+
impl<'a> Value<'a> {
19+
pub fn to_owned(&self) -> Value<'static> {
20+
match self {
21+
Value::Str(v) => Value::Str(v.to_owned()),
22+
Value::Value(v) => {
23+
let o = OwnedValue::from(&**v);
24+
Value::Value(Box::new(o.into_inner()))
25+
}
26+
}
27+
}
28+
}
29+
30+
struct OwnedValue(Value<'static>);
31+
impl OwnedValue {
32+
pub(crate) fn into_inner(self) -> Value<'static> {
33+
todo!()
34+
}
35+
}
36+
impl<'a, T> TryFrom<OwnedValue> for Vec<T>
37+
where
38+
T: TryFrom<Value<'a>, Error = ()>,
39+
{
40+
type Error = ();
41+
fn try_from(_: OwnedValue) -> Result<Self, Self::Error> {
42+
todo!()
43+
}
44+
}
45+
impl TryFrom<OwnedValue> for Vec<OwnedValue> {
46+
type Error = ();
47+
fn try_from(_: OwnedValue) -> Result<Self, Self::Error> {
48+
todo!()
49+
}
50+
}
51+
impl<'a> From<Value<'a>> for OwnedValue {
52+
fn from(_: Value<'a>) -> Self {
53+
todo!()
54+
}
55+
}
56+
impl<'a> From<&Value<'a>> for OwnedValue {
57+
fn from(_: &Value<'a>) -> Self {
58+
todo!()
59+
}
60+
}

src/test/ui/traits/issue-89119.rs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// This is a regression test for issue #89119: an issue in intercrate mode caching.
2+
//
3+
// It requires multiple crates, of course, but the bug is triggered by the code in the dependency,
4+
// not the main crate. This is why this file is empty.
5+
//
6+
// The auxiliary crate used in the test contains the code minimized from `zvariant-2.8.0`.
7+
8+
// check-pass
9+
// aux-build: issue_89119_intercrate_caching.rs
10+
11+
fn main() {}

0 commit comments

Comments
 (0)