Skip to content

Commit dc7eb0e

Browse files
committed
Add test for impl Trait in argument position
1 parent 287b29b commit dc7eb0e

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

Diff for: src/test/rustdoc/universal-impl-trait.rs

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(universal_impl_trait)]
12+
#![crate_name = "foo"]
13+
14+
// @has foo/fn.foo.html
15+
// @has - //pre 'foo('
16+
// @matches - '_x: impl <a class="trait" href="[^"]+/trait\.Clone\.html"'
17+
// @matches - '_z: .+impl.+trait\.Copy\.html.+, impl.+trait\.Clone\.html'
18+
pub fn foo(_x: impl Clone, _y: i32, _z: (impl Copy, impl Clone)) {
19+
}
20+
21+
pub trait Trait {
22+
// @has foo/trait.Trait.html
23+
// @has - 'method</a>('
24+
// @matches - '_x: impl <a class="trait" href="[^"]+/trait\.Debug\.html"'
25+
fn method(&self, _x: impl std::fmt::Debug) {
26+
}
27+
}
28+
29+
pub struct S<T>(T);
30+
31+
impl<T> S<T> {
32+
// @has foo/struct.S.html
33+
// @has - 'bar</a>('
34+
// @matches - '_bar: impl <a class="trait" href="[^"]+/trait\.Copy\.html"'
35+
pub fn bar(_bar: impl Copy) {
36+
}
37+
38+
// @has - 'baz</a>('
39+
// @matches - '_baz:.+struct\.S\.html.+impl .+trait\.Clone\.html'
40+
pub fn baz(_baz: S<impl Clone>) {
41+
}
42+
}
43+
44+
// @has - 'method</a>('
45+
// @matches - '_x: impl <a class="trait" href="[^"]+/trait\.Debug\.html"'
46+
impl<T> Trait for S<T> {}

0 commit comments

Comments
 (0)