2015-12-28 17:40:11 -06:00
|
|
|
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2017-11-29 15:47:36 -06:00
|
|
|
// aux-build:cross_crates_defaults.rs
|
2015-12-28 17:40:11 -06:00
|
|
|
|
|
|
|
#![feature(specialization)]
|
|
|
|
|
2017-11-29 15:47:36 -06:00
|
|
|
extern crate cross_crates_defaults;
|
2015-12-28 17:40:11 -06:00
|
|
|
|
2017-11-29 15:47:36 -06:00
|
|
|
use cross_crates_defaults::*;
|
2015-12-28 17:40:11 -06:00
|
|
|
|
2016-03-11 14:15:28 -06:00
|
|
|
struct LocalDefault;
|
|
|
|
struct LocalOverride;
|
|
|
|
|
|
|
|
impl Foo for LocalDefault {}
|
|
|
|
|
|
|
|
impl Foo for LocalOverride {
|
|
|
|
fn foo(&self) -> bool { true }
|
|
|
|
}
|
|
|
|
|
2015-12-28 17:40:11 -06:00
|
|
|
fn test_foo() {
|
2016-04-05 23:24:19 -05:00
|
|
|
assert!(!0i8.foo());
|
|
|
|
assert!(!0i32.foo());
|
|
|
|
assert!(0i64.foo());
|
2016-03-11 14:15:28 -06:00
|
|
|
|
2016-04-05 23:24:19 -05:00
|
|
|
assert!(!LocalDefault.foo());
|
|
|
|
assert!(LocalOverride.foo());
|
2015-12-28 17:40:11 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fn test_bar() {
|
|
|
|
assert!(0u8.bar() == 0);
|
|
|
|
assert!(0i32.bar() == 1);
|
|
|
|
assert!("hello".bar() == 0);
|
|
|
|
assert!(vec![()].bar() == 2);
|
|
|
|
assert!(vec![0i32].bar() == 2);
|
|
|
|
assert!(vec![0i64].bar() == 3);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
test_foo();
|
|
|
|
test_bar();
|
|
|
|
}
|