Skip to content

Commit

Permalink
Auto merge of #37837 - GuillaumeGomez:rollup, r=GuillaumeGomez
Browse files Browse the repository at this point in the history
Rollup of 8 pull requests

- Successful merges: #37752, #37757, #37759, #37766, #37772, #37799, #37806, #37821
- Failed merges: #37442
  • Loading branch information
bors authored Nov 17, 2016
2 parents c57b826 + 850e355 commit 89386d6
Show file tree
Hide file tree
Showing 11 changed files with 522 additions and 37 deletions.
42 changes: 42 additions & 0 deletions src/doc/book/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -586,3 +586,45 @@ you add more examples.

We haven’t covered all of the details with writing documentation tests. For more,
please see the [Documentation chapter](documentation.html).

# Testing and concurrency

One thing that is important to note when writing tests are run concurrently
using threads. For this reason you should take care that your tests are written
in such a way as to not depend on each-other, or on any shared state. "Shared
state" can also include the environment, such as the current working directory,
or environment variables.

If this is an issue it is possible to control this concurrency, either by
setting the environment variable `RUST_TEST_THREADS`, or by passing the argument
`--test-threads` to the tests:

```bash
$ RUST_TEST_THREADS=1 cargo test # Run tests with no concurrency
...
$ cargo test -- --test-threads=1 # Same as above
...
```

# Test output

By default Rust's test library captures and discards output to standard
out/error, e.g. output from `println!()`. This too can be controlled using the
environment or a switch:


```bash
$ RUST_TEST_NOCAPTURE=1 cargo test # Preserve stdout/stderr
...
$ cargo test -- --nocapture # Same as above
...
```

However a better method avoiding capture is to use logging rather than raw
output. Rust has a [standard logging API][log], which provides a frontend to
multiple logging implementations. This can be used in conjunction with the
default [env_logger] to output any debugging information in a manner that can be
controlled at runtime.

[log]: https://crates.io/crates/log
[env_logger]: https://crates.io/crates/env_logger
10 changes: 6 additions & 4 deletions src/librustc_const_eval/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ Ensure the ordering of the match arm is correct and remove any superfluous
arms.
"##,

/*E0002: r##"
E0002: r##"
## Note: this error code is no longer emitted by the compiler.
This error indicates that an empty match expression is invalid because the type
it is matching on is non-empty (there exist values of this type). In safe code
it is impossible to create an instance of an empty type, so empty match
Expand Down Expand Up @@ -68,10 +70,11 @@ fn foo(x: Option<String>) {
}
}
```
"##,*/
"##,

E0003: r##"
## Note: this error code is no longer emitted by the compiler.
/*E0003: r##"
Not-a-Number (NaN) values cannot be compared for equality and hence can never
match the input to a match expression. So, the following will not compile:
Expand All @@ -98,7 +101,6 @@ match number {
}
```
"##,
*/

E0004: r##"
This error indicates that the compiler cannot guarantee a matching pattern for
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/check/method/suggest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {

let limit = if candidates.len() == 5 { 5 } else { 4 };
for (i, trait_did) in candidates.iter().take(limit).enumerate() {
err.help(&format!("candidate #{}: `use {}`",
err.help(&format!("candidate #{}: `use {};`",
i + 1,
self.tcx.item_path_str(*trait_did)));
}
Expand Down
8 changes: 7 additions & 1 deletion src/librustc_typeck/coherence/overlap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

use hir::def_id::DefId;
use rustc::traits::{self, Reveal};
use rustc::ty::{self, TyCtxt};
use rustc::ty::{self, TyCtxt, TypeFoldable};
use syntax::ast;
use rustc::dep_graph::DepNode;
use rustc::hir;
Expand Down Expand Up @@ -134,6 +134,12 @@ impl<'cx, 'tcx, 'v> intravisit::Visitor<'v> for OverlapChecker<'cx, 'tcx> {
let trait_ref = self.tcx.impl_trait_ref(impl_def_id).unwrap();
let trait_def_id = trait_ref.def_id;

if trait_ref.references_error() {
debug!("coherence: skipping impl {:?} with error {:?}",
impl_def_id, trait_ref);
return
}

let _task =
self.tcx.dep_graph.in_task(DepNode::CoherenceOverlapCheck(trait_def_id));

Expand Down
34 changes: 17 additions & 17 deletions src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -874,12 +874,12 @@ fn extern_location(e: &clean::ExternalCrate, dst: &Path) -> ExternalLocation {
impl<'a> DocFolder for SourceCollector<'a> {
fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
// If we're including source files, and we haven't seen this file yet,
// then we need to render it out to the filesystem
// then we need to render it out to the filesystem.
if self.scx.include_sources
// skip all invalid spans
&& item.source.filename != ""
// macros from other libraries get special filenames which we can
// safely ignore
// Macros from other libraries get special filenames which we can
// safely ignore.
&& !(item.source.filename.starts_with("<")
&& item.source.filename.ends_with("macros>")) {

Expand Down Expand Up @@ -974,13 +974,13 @@ impl DocFolder for Cache {
};

// Register any generics to their corresponding string. This is used
// when pretty-printing types
// when pretty-printing types.
if let Some(generics) = item.inner.generics() {
self.generics(generics);
}

// Propagate a trait methods' documentation to all implementors of the
// trait
// Propagate a trait method's documentation to all implementors of the
// trait.
if let clean::TraitItem(ref t) = item.inner {
self.traits.entry(item.def_id).or_insert_with(|| t.clone());
}
Expand All @@ -996,7 +996,7 @@ impl DocFolder for Cache {
}
}

// Index this method for searching later on
// Index this method for searching later on.
if let Some(ref s) = item.name {
let (parent, is_inherent_impl_item) = match item.inner {
clean::StrippedItem(..) => ((None, None), false),
Expand Down Expand Up @@ -1097,8 +1097,8 @@ impl DocFolder for Cache {
(self.stack.clone(), item.type_()));
}
}
// link variants to their parent enum because pages aren't emitted
// for each variant
// Link variants to their parent enum because pages aren't emitted
// for each variant.
clean::VariantItem(..) if !self.stripped_mod => {
let mut stack = self.stack.clone();
stack.pop();
Expand Down Expand Up @@ -1144,8 +1144,8 @@ impl DocFolder for Cache {
_ => false
};

// Once we've recursively found all the generics, then hoard off all the
// implementations elsewhere
// Once we've recursively found all the generics, hoard off all the
// implementations elsewhere.
let ret = self.fold_item_recur(item).and_then(|item| {
if let clean::Item { inner: clean::ImplItem(_), .. } = item {
// Figure out the id of this impl. This may map to a
Expand Down Expand Up @@ -1206,7 +1206,7 @@ impl Context {
}

/// Recurse in the directory structure and change the "root path" to make
/// sure it always points to the top (relatively)
/// sure it always points to the top (relatively).
fn recurse<T, F>(&mut self, s: String, f: F) -> T where
F: FnOnce(&mut Context) -> T,
{
Expand Down Expand Up @@ -1237,11 +1237,11 @@ impl Context {
fn krate(self, mut krate: clean::Crate) -> Result<(), Error> {
let mut item = match krate.module.take() {
Some(i) => i,
None => return Ok(())
None => return Ok(()),
};
item.name = Some(krate.name);

// render the crate documentation
// Render the crate documentation
let mut work = vec![(self, item)];

while let Some((mut cx, item)) = work.pop() {
Expand Down Expand Up @@ -2987,7 +2987,7 @@ impl<'a> fmt::Display for Sidebar<'a> {
let it = self.item;
let parentlen = cx.current.len() - if it.is_mod() {1} else {0};

// the sidebar is designed to display sibling functions, modules and
// The sidebar is designed to display sibling functions, modules and
// other miscellaneous information. since there are lots of sibling
// items (and that causes quadratic growth in large modules),
// we refactor common parts into a shared JavaScript file per module.
Expand All @@ -3006,7 +3006,7 @@ impl<'a> fmt::Display for Sidebar<'a> {
}
write!(fmt, "</p>")?;

// sidebar refers to the enclosing module, not this module
// Sidebar refers to the enclosing module, not this module.
let relpath = if it.is_mod() { "../" } else { "" };
write!(fmt,
"<script>window.sidebarCurrent = {{\
Expand All @@ -3018,7 +3018,7 @@ impl<'a> fmt::Display for Sidebar<'a> {
ty = it.type_().css_class(),
path = relpath)?;
if parentlen == 0 {
// there is no sidebar-items.js beyond the crate root path
// There is no sidebar-items.js beyond the crate root path
// FIXME maybe dynamic crate loading can be merged here
} else {
write!(fmt, "<script defer src=\"{path}sidebar-items.js\"></script>",
Expand Down
Loading

0 comments on commit 89386d6

Please sign in to comment.