Skip to content

Rollup of 8 pull requests #37830

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
b8fc512
coherence: skip impls with an erroneous trait ref
arielb1 Nov 13, 2016
e4a9d83
Uncomment some long error explanation
GuillaumeGomez Nov 13, 2016
f3a71d3
Add semicolon to "perhaps add a `use` for one of them" help
robinst Nov 14, 2016
67df9b9
Add sections about concurrency and stdout/err capture to the Testing …
Nov 14, 2016
b9e17fa
Typo in new section
Nov 14, 2016
5a76fe4
Remove thread-per-CPU bit as it may not be accurate.
Nov 14, 2016
8e70a50
add test for #37765
durka Nov 14, 2016
8e4097f
ICH: Add test case for type alias definitions
michaelwoerister Nov 16, 2016
27acb5c
Add missing urls and improve internal doc representation
GuillaumeGomez Nov 16, 2016
976bfc0
Add examples for Ipv4Addr
GuillaumeGomez Nov 16, 2016
963ef08
Remove incorrect statement about the reference.
steveklabnik Nov 17, 2016
95bec31
Rollup merge of #37752 - arielb1:incoherent-error, r=nikomatsakis
GuillaumeGomez Nov 17, 2016
5d438a6
Rollup merge of #37757 - rust-lang:E0002-precision, r=brson
GuillaumeGomez Nov 17, 2016
03b8a9f
Rollup merge of #37759 - robinst:trait-use-message-add-semicolon, r=e…
GuillaumeGomez Nov 17, 2016
e439603
Rollup merge of #37766 - tarka:book-testing-concurrency-capture, r=st…
GuillaumeGomez Nov 17, 2016
856131d
Rollup merge of #37772 - durka:patch-32, r=petrochenkov
GuillaumeGomez Nov 17, 2016
9b51322
Rollup merge of #37799 - michaelwoerister:ich-type-def-tests, r=nikom…
GuillaumeGomez Nov 17, 2016
6bdb9d1
Rollup merge of #37806 - GuillaumeGomez:net_examples, r=frewsxcv
GuillaumeGomez Nov 17, 2016
75941eb
Rollup merge of #37820 - steveklabnik:remove-incorrect-reference-comm…
GuillaumeGomez Nov 17, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion src/doc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ the language.

[**The Rust Reference**][ref]. While Rust does not have a
specification, the reference tries to describe its working in
detail. It tends to be out of date.
detail.

[**Standard Library API Reference**][api]. Documentation for the
standard library.
Expand Down
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
Loading