Skip to content

Commit 74f3e04

Browse files
committed
auto merge of #12361 : sfackler/rust/rustdoc-test-extern, r=alexcrichton
2 parents cae5999 + 0658913 commit 74f3e04

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/libextra/json.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ the code for these traits: `#[deriving(Decodable, Encodable)]`
5959
To encode using Encodable :
6060
6161
```rust
62+
extern crate extra;
6263
extern crate serialize;
6364
use extra::json;
6465
use std::io;
@@ -98,6 +99,7 @@ A basic `ToJson` example using a TreeMap of attribute name / attribute value:
9899
99100
100101
```rust
102+
extern crate extra;
101103
extern crate collections;
102104
103105
use extra::json;
@@ -128,6 +130,7 @@ fn main() {
128130
To decode a JSON string using `Decodable` trait :
129131
130132
```rust
133+
extern crate extra;
131134
extern crate serialize;
132135
use serialize::Decodable;
133136
@@ -154,6 +157,7 @@ Create a struct called TestStruct1 and serialize and deserialize it to and from
154157
using the serialization API, using the derived serialization code.
155158
156159
```rust
160+
extern crate extra;
157161
extern crate serialize;
158162
use extra::json;
159163
use serialize::{Encodable, Decodable};
@@ -186,6 +190,7 @@ This example use the ToJson impl to deserialize the JSON string.
186190
Example of `ToJson` trait implementation for TestStruct1.
187191
188192
```rust
193+
extern crate extra;
189194
extern crate serialize;
190195
extern crate collections;
191196

src/librustdoc/test.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,13 @@ fn maketest(s: &str, cratename: &str) -> ~str {
144144
#[deny(warnings)];
145145
#[allow(unused_variable, dead_assignment, unused_mut, attribute_usage, dead_code)];
146146
";
147-
if s.contains("extra") {
148-
prog.push_str("extern crate extra;\n");
149-
}
150-
if s.contains(cratename) {
151-
prog.push_str(format!("extern crate {};\n", cratename));
147+
if !s.contains("extern crate") {
148+
if s.contains("extra") {
149+
prog.push_str("extern crate extra;\n");
150+
}
151+
if s.contains(cratename) {
152+
prog.push_str(format!("extern crate {};\n", cratename));
153+
}
152154
}
153155
if s.contains("fn main") {
154156
prog.push_str(s);

0 commit comments

Comments
 (0)