Skip to content

Commit 7e70fee

Browse files
add more tests for traits-in-non-module-scope
1 parent e79780f commit 7e70fee

File tree

6 files changed

+63
-5
lines changed

6 files changed

+63
-5
lines changed

src/librustdoc/passes/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ impl<'a> fold::DocFolder for ImplStripper<'a> {
320320
if let Some(did) = typaram.def_id() {
321321
if did.is_local() && !self.retained.contains(&did) {
322322
debug!("ImplStripper: stripped item in trait's generics; \
323-
removing impl");
323+
removing impl");
324324
return None;
325325
}
326326
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
#![crate_name = "inner"]
12+
13+
pub struct SomeStruct;
14+
15+
fn asdf() {
16+
const _FOO: () = {
17+
impl Clone for SomeStruct {
18+
fn clone(&self) -> Self {
19+
SomeStruct
20+
}
21+
}
22+
};
23+
}
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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+
// aux-build:trait-vis.rs
12+
13+
extern crate inner;
14+
15+
// @has trait_vis/struct.SomeStruct.html
16+
// @has - '//code' 'impl Clone for SomeStruct'
17+
pub use inner::SomeStruct;

src/test/rustdoc/inline_local/trait-vis.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//

src/test/rustdoc/primitive-generic-impl.rs

-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010

1111
#![crate_name = "foo"]
1212

13-
// we need to reexport something from libstd so that `all_trait_implementations` is called.
14-
pub use std::string::String;
15-
1613
include!("primitive/primitive-generic-impl.rs");
1714

1815
// @has foo/primitive.i32.html '//h3[@id="impl-ToString"]//code' 'impl<T> ToString for T'

src/test/rustdoc/traits-in-bodies.rs

+21
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,24 @@ const _FOO: () = {
3939
impl Copy for Point {}
4040
()
4141
};
42+
43+
// @has traits_in_bodies/struct.Inception.html
44+
// @has - '//code' 'impl Clone for Inception'
45+
pub struct Inception;
46+
47+
static _BAR: usize = {
48+
trait HiddenTrait {
49+
fn hidden_fn(&self) {
50+
for _ in 0..5 {
51+
impl Clone for Inception {
52+
fn clone(&self) -> Self {
53+
// we need to go deeper
54+
Inception
55+
}
56+
}
57+
}
58+
}
59+
}
60+
61+
5
62+
};

0 commit comments

Comments
 (0)