Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
And refactor duplicated code.
- Loading branch information
Showing
4 changed files
with
218 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,3 +34,4 @@ fn issue_36540() { | |
} | ||
|
||
trait Trait<T> {} | ||
impl Trait<i32> for i32 {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright 2017 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. | ||
// compile-flags: --error-format=human | ||
|
||
use std::iter::FromIterator; | ||
use std::vec::IntoIter; | ||
use std::ops::Add; | ||
|
||
struct Foo<T, U: FromIterator<T>>(T, U); | ||
struct WellFormed<Z = Foo<i32, i32>>(Z); | ||
|
||
struct WellFormedProjection<A, T=<A as Iterator>::Item>(A, T); | ||
|
||
struct Bounds<T:Copy=String>(T); | ||
|
||
struct WhereClause<T=String>(T) where T: Copy; | ||
|
||
trait TraitBound<T:Copy=String> {} | ||
|
||
trait SelfBound<T:Copy=Self> {} | ||
|
||
trait FooTrait<T:Iterator = IntoIter<i32>> where T::Item : Add<u8> {} | ||
|
||
fn main() { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
error[E0277]: the trait bound `i32: std::iter::FromIterator<i32>` is not satisfied | ||
--> $DIR/type-check-defaults.rs:17:1 | ||
| | ||
17 | struct WellFormed<Z = Foo<i32, i32>>(Z); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ a collection of type `i32` cannot be built from an iterator over elements of type `i32` | ||
| | ||
= help: the trait `std::iter::FromIterator<i32>` is not implemented for `i32` | ||
= note: required by `Foo` | ||
|
||
error[E0277]: the trait bound `A: std::iter::Iterator` is not satisfied | ||
--> $DIR/type-check-defaults.rs:19:1 | ||
| | ||
19 | struct WellFormedProjection<A, T=<A as Iterator>::Item>(A, T); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `A` is not an iterator; maybe try calling `.iter()` or a similar method | ||
| | ||
= help: the trait `std::iter::Iterator` is not implemented for `A` | ||
= help: consider adding a `where A: std::iter::Iterator` bound | ||
|
||
error[E0277]: the trait bound `std::string::String: std::marker::Copy` is not satisfied | ||
--> $DIR/type-check-defaults.rs:21:1 | ||
| | ||
21 | struct Bounds<T:Copy=String>(T); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::string::String` | ||
| | ||
= note: required by `std::marker::Copy` | ||
|
||
error[E0277]: the trait bound `std::string::String: std::marker::Copy` is not satisfied | ||
--> $DIR/type-check-defaults.rs:23:1 | ||
| | ||
23 | struct WhereClause<T=String>(T) where T: Copy; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::string::String` | ||
| | ||
= note: required by `std::marker::Copy` | ||
|
||
error[E0277]: the trait bound `std::string::String: std::marker::Copy` is not satisfied | ||
--> $DIR/type-check-defaults.rs:25:1 | ||
| | ||
25 | trait TraitBound<T:Copy=String> {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::string::String` | ||
| | ||
= note: required by `std::marker::Copy` | ||
|
||
error[E0277]: the trait bound `Self: std::marker::Copy` is not satisfied | ||
--> $DIR/type-check-defaults.rs:27:1 | ||
| | ||
27 | trait SelfBound<T:Copy=Self> {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `Self` | ||
| | ||
= help: consider adding a `where Self: std::marker::Copy` bound | ||
= note: required by `std::marker::Copy` | ||
|
||
error[E0277]: the trait bound `i32: std::ops::Add<u8>` is not satisfied | ||
--> $DIR/type-check-defaults.rs:29:1 | ||
| | ||
29 | trait FooTrait<T:Iterator = IntoIter<i32>> where T::Item : Add<u8> {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `i32 + u8` | ||
| | ||
= help: the trait `std::ops::Add<u8>` is not implemented for `i32` | ||
= note: required by `std::ops::Add` | ||
|
||
error: aborting due to 7 previous errors | ||
|