Skip to content

Commit 89386d6

Browse files
authored
Auto merge of #37837 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 8 pull requests - Successful merges: #37752, #37757, #37759, #37766, #37772, #37799, #37806, #37821 - Failed merges: #37442
2 parents c57b826 + 850e355 commit 89386d6

File tree

11 files changed

+522
-37
lines changed

11 files changed

+522
-37
lines changed

src/doc/book/testing.md

+42
Original file line numberDiff line numberDiff line change
@@ -586,3 +586,45 @@ you add more examples.
586586

587587
We haven’t covered all of the details with writing documentation tests. For more,
588588
please see the [Documentation chapter](documentation.html).
589+
590+
# Testing and concurrency
591+
592+
One thing that is important to note when writing tests are run concurrently
593+
using threads. For this reason you should take care that your tests are written
594+
in such a way as to not depend on each-other, or on any shared state. "Shared
595+
state" can also include the environment, such as the current working directory,
596+
or environment variables.
597+
598+
If this is an issue it is possible to control this concurrency, either by
599+
setting the environment variable `RUST_TEST_THREADS`, or by passing the argument
600+
`--test-threads` to the tests:
601+
602+
```bash
603+
$ RUST_TEST_THREADS=1 cargo test # Run tests with no concurrency
604+
...
605+
$ cargo test -- --test-threads=1 # Same as above
606+
...
607+
```
608+
609+
# Test output
610+
611+
By default Rust's test library captures and discards output to standard
612+
out/error, e.g. output from `println!()`. This too can be controlled using the
613+
environment or a switch:
614+
615+
616+
```bash
617+
$ RUST_TEST_NOCAPTURE=1 cargo test # Preserve stdout/stderr
618+
...
619+
$ cargo test -- --nocapture # Same as above
620+
...
621+
```
622+
623+
However a better method avoiding capture is to use logging rather than raw
624+
output. Rust has a [standard logging API][log], which provides a frontend to
625+
multiple logging implementations. This can be used in conjunction with the
626+
default [env_logger] to output any debugging information in a manner that can be
627+
controlled at runtime.
628+
629+
[log]: https://crates.io/crates/log
630+
[env_logger]: https://crates.io/crates/env_logger

src/librustc_const_eval/diagnostics.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ Ensure the ordering of the match arm is correct and remove any superfluous
4040
arms.
4141
"##,
4242

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

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

103105
E0004: r##"
104106
This error indicates that the compiler cannot guarantee a matching pattern for

src/librustc_typeck/check/method/suggest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
308308

309309
let limit = if candidates.len() == 5 { 5 } else { 4 };
310310
for (i, trait_did) in candidates.iter().take(limit).enumerate() {
311-
err.help(&format!("candidate #{}: `use {}`",
311+
err.help(&format!("candidate #{}: `use {};`",
312312
i + 1,
313313
self.tcx.item_path_str(*trait_did)));
314314
}

src/librustc_typeck/coherence/overlap.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
1515
use hir::def_id::DefId;
1616
use rustc::traits::{self, Reveal};
17-
use rustc::ty::{self, TyCtxt};
17+
use rustc::ty::{self, TyCtxt, TypeFoldable};
1818
use syntax::ast;
1919
use rustc::dep_graph::DepNode;
2020
use rustc::hir;
@@ -134,6 +134,12 @@ impl<'cx, 'tcx, 'v> intravisit::Visitor<'v> for OverlapChecker<'cx, 'tcx> {
134134
let trait_ref = self.tcx.impl_trait_ref(impl_def_id).unwrap();
135135
let trait_def_id = trait_ref.def_id;
136136

137+
if trait_ref.references_error() {
138+
debug!("coherence: skipping impl {:?} with error {:?}",
139+
impl_def_id, trait_ref);
140+
return
141+
}
142+
137143
let _task =
138144
self.tcx.dep_graph.in_task(DepNode::CoherenceOverlapCheck(trait_def_id));
139145

src/librustdoc/html/render.rs

+17-17
Original file line numberDiff line numberDiff line change
@@ -874,12 +874,12 @@ fn extern_location(e: &clean::ExternalCrate, dst: &Path) -> ExternalLocation {
874874
impl<'a> DocFolder for SourceCollector<'a> {
875875
fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
876876
// If we're including source files, and we haven't seen this file yet,
877-
// then we need to render it out to the filesystem
877+
// then we need to render it out to the filesystem.
878878
if self.scx.include_sources
879879
// skip all invalid spans
880880
&& item.source.filename != ""
881-
// macros from other libraries get special filenames which we can
882-
// safely ignore
881+
// Macros from other libraries get special filenames which we can
882+
// safely ignore.
883883
&& !(item.source.filename.starts_with("<")
884884
&& item.source.filename.ends_with("macros>")) {
885885

@@ -974,13 +974,13 @@ impl DocFolder for Cache {
974974
};
975975

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

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

999-
// Index this method for searching later on
999+
// Index this method for searching later on.
10001000
if let Some(ref s) = item.name {
10011001
let (parent, is_inherent_impl_item) = match item.inner {
10021002
clean::StrippedItem(..) => ((None, None), false),
@@ -1097,8 +1097,8 @@ impl DocFolder for Cache {
10971097
(self.stack.clone(), item.type_()));
10981098
}
10991099
}
1100-
// link variants to their parent enum because pages aren't emitted
1101-
// for each variant
1100+
// Link variants to their parent enum because pages aren't emitted
1101+
// for each variant.
11021102
clean::VariantItem(..) if !self.stripped_mod => {
11031103
let mut stack = self.stack.clone();
11041104
stack.pop();
@@ -1144,8 +1144,8 @@ impl DocFolder for Cache {
11441144
_ => false
11451145
};
11461146

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

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

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

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

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

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

0 commit comments

Comments
 (0)