Skip to content

Commit 1867078

Browse files
committed
Auto merge of #27383 - Manishearth:rollup, r=Manishearth
- Successful merges: #26778, #27232, #27352, #27369, #27373 - Failed merges:
2 parents 823f4fc + b904b45 commit 1867078

File tree

11 files changed

+97
-70
lines changed

11 files changed

+97
-70
lines changed

src/doc/trpl/glossary.md

+42-16
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,12 @@
33
Not every Rustacean has a background in systems programming, nor in computer
44
science, so we've added explanations of terms that might be unfamiliar.
55

6-
### Arity
7-
8-
Arity refers to the number of arguments a function or operation takes.
9-
10-
```rust
11-
let x = (2, 3);
12-
let y = (4, 6);
13-
let z = (8, 2, 6);
14-
```
15-
16-
In the example above `x` and `y` have arity 2. `z` has arity 3.
17-
186
### Abstract Syntax Tree
197

20-
When a compiler is compiling your program, it does a number of different
21-
things. One of the things that it does is turn the text of your program into an
22-
‘abstract syntax tree’, or ‘AST’. This tree is a representation of the
23-
structure of your program. For example, `2 + 3` can be turned into a tree:
8+
When a compiler is compiling your program, it does a number of different things.
9+
One of the things that it does is turn the text of your program into an
10+
‘abstract syntax tree’, or ‘AST’. This tree is a representation of the structure
11+
of your program. For example, `2 + 3` can be turned into a tree:
2412

2513
```text
2614
+
@@ -37,3 +25,41 @@ And `2 + (3 * 4)` would look like this:
3725
/ \
3826
3 4
3927
```
28+
29+
### Arity
30+
31+
Arity refers to the number of arguments a function or operation takes.
32+
33+
```rust
34+
let x = (2, 3);
35+
let y = (4, 6);
36+
let z = (8, 2, 6);
37+
```
38+
39+
In the example above `x` and `y` have arity 2. `z` has arity 3.
40+
41+
### Expression
42+
43+
In computer programming, an expression is a combination of values, constants,
44+
variables, operators and functions that evaluate to a single value. For example,
45+
`2 + (3 * 4)` is an expression that returns the value 14. It is worth noting
46+
that expressions can have side-effects. For example, a function included in an
47+
expression might perform actions other than simply returning a value.
48+
49+
### Expression-Oriented Language
50+
51+
In early programming languages, [expressions][expression] and
52+
[statements][statement] were two separate syntactic categories: expressions had
53+
a value and statements did things. However, later languages blurred this
54+
distinction, allowing expressions to do things and statements to have a value.
55+
In an expression-oriented language, (nearly) every statement is an expression
56+
and therefore returns a value. Consequently, these expression statements can
57+
themselves form part of larger expressions.
58+
59+
[expression]: glossary.html#expression
60+
[statement]: glossary.html#statement
61+
62+
### Statement
63+
64+
In computer programming, a statement is the smallest standalone element of a
65+
programming language that commands a computer to perform an action.

src/doc/trpl/hello-world.md

+7-4
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,13 @@ string to the screen. Easy enough!
111111

112112
[allocation]: the-stack-and-the-heap.html
113113

114-
Finally, the line ends with a semicolon (`;`). Rust is an ‘expression oriented’
115-
language, which means that most things are expressions, rather than statements.
116-
The `;` is used to indicate that this expression is over, and the next one is
117-
ready to begin. Most lines of Rust code end with a `;`.
114+
Finally, the line ends with a semicolon (`;`). Rust is an [‘expression oriented’
115+
language][expression-oriented language], which means that most things are
116+
expressions, rather than statements. The `;` is used to indicate that this
117+
expression is over, and the next one is ready to begin. Most lines of Rust code
118+
end with a `;`.
119+
120+
[expression-oriented language]: glossary.html#expression-oriented-language
118121

119122
Finally, actually compiling and running our program. We can compile with our
120123
compiler, `rustc`, by passing it the name of our source file:

src/libcollections/fmt.rs

+11-9
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@
8585
//! format!("{a} {c} {b}", a="a", b='b', c=3); // => "a 3 b"
8686
//! ```
8787
//!
88-
//! It is illegal to put positional parameters (those without names) after
89-
//! arguments which have names. Like with positional parameters, it is illegal
90-
//! to provide named parameters that are unused by the format string.
88+
//! It is not valid to put positional parameters (those without names) after
89+
//! arguments which have names. Like with positional parameters, it is not
90+
//! valid to provide named parameters that are unused by the format string.
9191
//!
9292
//! ## Argument types
9393
//!
@@ -103,19 +103,21 @@
103103
//! hexadecimal as well as an
104104
//! octal.
105105
//!
106-
//! There are various parameters which do require a particular type, however. Namely, the `{:.*}`
107-
//! syntax, which sets the number of numbers after the decimal in floating-point types:
106+
//! There are various parameters which do require a particular type, however.
107+
//! Namely, the `{:.*}` syntax, which sets the number of numbers after the
108+
//! decimal in floating-point types:
108109
//!
109110
//! ```
110111
//! let formatted_number = format!("{:.*}", 2, 1.234567);
111112
//!
112113
//! assert_eq!("1.23", formatted_number)
113114
//! ```
114115
//!
115-
//! If this syntax is used, then the number of characters to print precedes the actual object being
116-
//! formatted, and the number of characters must have the type `usize`. Although a `usize` can be
117-
//! printed with `{}`, it is illegal to reference an argument as such. For example this is another
118-
//! invalid format string:
116+
//! If this syntax is used, then the number of characters to print precedes the
117+
//! actual object being formatted, and the number of characters must have the
118+
//! type `usize`. Although a `usize` can be printed with `{}`, it is invalid to
119+
//! reference an argument as such. For example this is another invalid format
120+
//! string:
119121
//!
120122
//! ```text
121123
//! {:.*} {0}

src/libcore/marker.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ pub trait Copy : Clone {
205205
/// Any types with interior mutability must also use the `std::cell::UnsafeCell`
206206
/// wrapper around the value(s) which can be mutated when behind a `&`
207207
/// reference; not doing this is undefined behaviour (for example,
208-
/// `transmute`-ing from `&T` to `&mut T` is illegal).
208+
/// `transmute`-ing from `&T` to `&mut T` is invalid).
209209
#[stable(feature = "rust1", since = "1.0.0")]
210210
#[lang = "sync"]
211211
#[rustc_on_unimplemented = "`{Self}` cannot be shared between threads safely"]

src/libcore/num/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -479,8 +479,8 @@ macro_rules! int_impl {
479479
/// wrapping around at the boundary of the type.
480480
///
481481
/// Such wrap-around never actually occurs mathematically;
482-
/// implementation artifacts make `x % y` illegal for `MIN /
483-
/// -1` on a signed type illegal (where `MIN` is the negative
482+
/// implementation artifacts make `x % y` invalid for `MIN /
483+
/// -1` on a signed type (where `MIN` is the negative
484484
/// minimal value). In such a case, this function returns `0`.
485485
#[stable(feature = "num_wrapping", since = "1.2.0")]
486486
#[inline(always)]
@@ -1051,8 +1051,8 @@ macro_rules! uint_impl {
10511051
/// wrapping around at the boundary of the type.
10521052
///
10531053
/// Such wrap-around never actually occurs mathematically;
1054-
/// implementation artifacts make `x % y` illegal for `MIN /
1055-
/// -1` on a signed type illegal (where `MIN` is the negative
1054+
/// implementation artifacts make `x % y` invalid for `MIN /
1055+
/// -1` on a signed type (where `MIN` is the negative
10561056
/// minimal value). In such a case, this function returns `0`.
10571057
#[stable(feature = "num_wrapping", since = "1.2.0")]
10581058
#[inline(always)]

src/librustc/diagnostics.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ arms.
4141
"##,
4242

4343
E0002: r##"
44-
This error indicates that an empty match expression is illegal because the type
44+
This error indicates that an empty match expression is invalid because the type
4545
it is matching on is non-empty (there exist values of this type). In safe code
4646
it is impossible to create an instance of an empty type, so empty match
4747
expressions are almost never desired. This error is typically fixed by adding
@@ -1055,7 +1055,7 @@ because the `'static` lifetime is a special built-in lifetime name denoting
10551055
the lifetime of the entire program, this is an error:
10561056
10571057
```
1058-
// error, illegal lifetime parameter name `'static`
1058+
// error, invalid lifetime parameter name `'static`
10591059
fn foo<'static>(x: &'static str) { }
10601060
```
10611061
"##,
@@ -1805,7 +1805,7 @@ For more information about `const fn`'s, see [RFC 911].
18051805
E0394: r##"
18061806
From [RFC 246]:
18071807
1808-
> It is illegal for a static to reference another static by value. It is
1808+
> It is invalid for a static to reference another static by value. It is
18091809
> required that all references be borrowed.
18101810
18111811
[RFC 246]: https://github.com/rust-lang/rfcs/pull/246

src/librustc/middle/ty.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ use metadata::csearch;
4444
use middle;
4545
use middle::cast;
4646
use middle::check_const;
47-
use middle::const_eval::{self, ConstVal};
47+
use middle::const_eval::{self, ConstVal, ErrKind};
4848
use middle::const_eval::EvalHint::UncheckedExprHint;
4949
use middle::def::{self, DefMap, ExportMap};
5050
use middle::dependency_format;
@@ -6107,20 +6107,20 @@ impl<'tcx> ctxt<'tcx> {
61076107
found);
61086108
}
61096109
Err(err) => {
6110-
let err_description = err.description();
6111-
let found = match count_expr.node {
6110+
let err_msg = match count_expr.node {
61126111
ast::ExprPath(None, ast::Path {
61136112
global: false,
61146113
ref segments,
61156114
..
61166115
}) if segments.len() == 1 =>
6117-
format!("{}", "found variable"),
6118-
_ =>
6119-
format!("but {}", err_description),
6116+
format!("found variable"),
6117+
_ => match err.kind {
6118+
ErrKind::MiscCatchAll => format!("but found {}", err.description()),
6119+
_ => format!("but {}", err.description())
6120+
}
61206121
};
61216122
span_err!(self.sess, count_expr.span, E0307,
6122-
"expected constant integer for repeat count, {}",
6123-
found);
6123+
"expected constant integer for repeat count, {}", err_msg);
61246124
}
61256125
}
61266126
0

src/librustc_resolve/diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ mod foo {
106106
use foo::MyTrait::do_something;
107107
```
108108
109-
It's illegal to directly import methods belonging to a trait or concrete type.
109+
It's invalid to directly import methods belonging to a trait or concrete type.
110110
"##,
111111

112112
E0255: r##"

src/librustc_typeck/diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ extern "C" {
584584
```
585585
586586
Using this declaration, it must be called with at least one argument, so
587-
simply calling `printf()` is illegal. But the following uses are allowed:
587+
simply calling `printf()` is invalid. But the following uses are allowed:
588588
589589
```
590590
unsafe {

src/libstd/lib.rs

+5-10
Original file line numberDiff line numberDiff line change
@@ -281,36 +281,31 @@ extern crate libc;
281281

282282
#[macro_use] #[no_link] extern crate rustc_bitflags;
283283

284-
// Make std testable by not duplicating lang items. See #2912
284+
// Make std testable by not duplicating lang items and other globals. See #2912
285285
#[cfg(test)] extern crate std as realstd;
286-
#[cfg(test)] pub use realstd::marker;
287-
#[cfg(test)] pub use realstd::ops;
288-
#[cfg(test)] pub use realstd::cmp;
289-
#[cfg(test)] pub use realstd::boxed;
290-
291286

292287
// NB: These reexports are in the order they should be listed in rustdoc
293288

294289
pub use core::any;
295290
pub use core::cell;
296291
pub use core::clone;
297-
#[cfg(not(test))] pub use core::cmp;
292+
pub use core::cmp;
298293
pub use core::convert;
299294
pub use core::default;
300295
pub use core::hash;
301296
pub use core::intrinsics;
302297
pub use core::iter;
303-
#[cfg(not(test))] pub use core::marker;
298+
pub use core::marker;
304299
pub use core::mem;
305-
#[cfg(not(test))] pub use core::ops;
300+
pub use core::ops;
306301
pub use core::ptr;
307302
pub use core::raw;
308303
pub use core::simd;
309304
pub use core::result;
310305
pub use core::option;
311306
pub mod error;
312307

313-
#[cfg(not(test))] pub use alloc::boxed;
308+
pub use alloc::boxed;
314309
pub use alloc::rc;
315310

316311
pub use core_collections::borrow;

src/libstd/sys/unix/condvar.rs

+14-13
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,22 @@ impl Condvar {
6060
let r = ffi::gettimeofday(&mut sys_now, ptr::null_mut());
6161
debug_assert_eq!(r, 0);
6262

63+
let nsec = dur.extra_nanos() as libc::c_long +
64+
(sys_now.tv_usec * 1000) as libc::c_long;
65+
let extra = (nsec / 1_000_000_000) as libc::time_t;
66+
let nsec = nsec % 1_000_000_000;
6367
let seconds = dur.secs() as libc::time_t;
64-
let timeout = match sys_now.tv_sec.checked_add(seconds) {
65-
Some(sec) => {
66-
libc::timespec {
67-
tv_sec: sec,
68-
tv_nsec: dur.extra_nanos() as libc::c_long,
69-
}
70-
}
71-
None => {
72-
libc::timespec {
73-
tv_sec: <libc::time_t>::max_value(),
74-
tv_nsec: 1_000_000_000 - 1,
75-
}
68+
69+
let timeout = sys_now.tv_sec.checked_add(extra).and_then(|s| {
70+
s.checked_add(seconds)
71+
}).map(|s| {
72+
libc::timespec { tv_sec: s, tv_nsec: nsec }
73+
}).unwrap_or_else(|| {
74+
libc::timespec {
75+
tv_sec: <libc::time_t>::max_value(),
76+
tv_nsec: 1_000_000_000 - 1,
7677
}
77-
};
78+
});
7879

7980
// And wait!
8081
let r = ffi::pthread_cond_timedwait(self.inner.get(), mutex::raw(mutex),

0 commit comments

Comments
 (0)