Skip to content

Commit 1948140

Browse files
committed
Added a test for coherence when a generic type param has a default value from an associated type
1 parent 97c9437 commit 1948140

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

src/test/run-pass/coherence/auxiliary/re_rebalance_coherence_lib.rs

+9
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,12 @@ pub struct BatchInsert<'a, T: 'a, Tab> {
2020
impl<'a, T:'a, Tab, DB> QueryFragment<DB> for BatchInsert<'a, T, Tab>
2121
where DB: SupportsDefaultKeyword + Backend,
2222
{}
23+
24+
pub trait LibToOwned {
25+
type Owned;
26+
}
27+
28+
pub struct LibCow<T: LibToOwned, Owned = <T as LibToOwned>::Owned> {
29+
pub t: T,
30+
pub o: Owned,
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// run-pass
2+
// aux-build:re_rebalance_coherence_lib.rs
3+
4+
#![allow(dead_code)]
5+
#![feature(re_rebalance_coherence)]
6+
// check that a generic type with a default value from an associated type can be used without
7+
// specifying the value, and without invoking coherence errors.
8+
9+
extern crate re_rebalance_coherence_lib as lib;
10+
use lib::*;
11+
12+
struct MyString {}
13+
14+
impl LibToOwned for MyString {
15+
type Owned = String;
16+
}
17+
18+
impl PartialEq<MyString> for LibCow<MyString> {
19+
fn eq(&self, _other: &MyString) -> bool {
20+
// Test that the default type is used.
21+
let _s: &String = &self.o;
22+
23+
false
24+
}
25+
}
26+
27+
fn main() {}

0 commit comments

Comments
 (0)