Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coherence test when a generic type param has a default value from an associated type #61535

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,12 @@ pub struct BatchInsert<'a, T: 'a, Tab> {
impl<'a, T:'a, Tab, DB> QueryFragment<DB> for BatchInsert<'a, T, Tab>
where DB: SupportsDefaultKeyword + Backend,
{}

pub trait LibToOwned {
type Owned;
}

pub struct LibCow<T: LibToOwned, Owned = <T as LibToOwned>::Owned> {
pub t: T,
pub o: Owned,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// run-pass
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we leave a comment elaborating what this test is trying to test?

// aux-build:re_rebalance_coherence_lib.rs

#![allow(dead_code)]
#![feature(re_rebalance_coherence)]
// check that a generic type with a default value from an associated type can be used without
// specifying the value, and without invoking coherence errors.

extern crate re_rebalance_coherence_lib as lib;
use lib::*;

struct MyString {}

impl LibToOwned for MyString {
type Owned = String;
}

impl PartialEq<MyString> for LibCow<MyString> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test doesn't really check what the default works out to be, right? Should we do that?

fn eq(&self, _other: &MyString) -> bool {
// Test that the default type is used.
let _s: &String = &self.o;

false
}
}

fn main() {}