Skip to content

Commit

Permalink
Auto merge of rust-lang#35747 - jonathandturner:rollup, r=jonathandtu…
Browse files Browse the repository at this point in the history
  • Loading branch information
bors committed Aug 17, 2016
2 parents 76fa587 + c216617 commit 7ac11ca
Show file tree
Hide file tree
Showing 66 changed files with 511 additions and 376 deletions.
2 changes: 1 addition & 1 deletion mk/main.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
######################################################################

# The version number
CFG_RELEASE_NUM=1.12.0
CFG_RELEASE_NUM=1.13.0

# An optional number to put after the label, e.g. '.2' -> '-beta.2'
# NB Make sure it starts with a dot to conform to semver pre-release
Expand Down
2 changes: 1 addition & 1 deletion src/doc/book/associated-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ trait Graph {
Simple enough. Associated types use the `type` keyword, and go inside the body
of the trait, with the functions.

These `type` declarations can have all the same thing as functions do. For example,
These type declarations work the same way as those for functions. For example,
if we wanted our `N` type to implement `Display`, so we can print the nodes out,
we could do this:

Expand Down
6 changes: 3 additions & 3 deletions src/doc/book/closures.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ the result:

```rust
fn call_with_one<F>(some_closure: F) -> i32
where F : Fn(i32) -> i32 {
where F: Fn(i32) -> i32 {

some_closure(1)
}
Expand All @@ -279,7 +279,7 @@ Let’s examine the signature of `call_with_one` in more depth:

```rust
fn call_with_one<F>(some_closure: F) -> i32
# where F : Fn(i32) -> i32 {
# where F: Fn(i32) -> i32 {
# some_closure(1) }
```

Expand All @@ -288,7 +288,7 @@ isn’t interesting. The next part is:

```rust
# fn call_with_one<F>(some_closure: F) -> i32
where F : Fn(i32) -> i32 {
where F: Fn(i32) -> i32 {
# some_closure(1) }
```

Expand Down
8 changes: 4 additions & 4 deletions src/doc/book/lang-items.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ fn main(argc: isize, argv: *const *const u8) -> isize {
0
}
#[lang = "eh_personality"] extern fn eh_personality() {}
#[lang = "panic_fmt"] fn panic_fmt() -> ! { loop {} }
#[lang = "eh_personality"] extern fn rust_eh_personality() {}
#[lang = "panic_fmt"] extern fn rust_begin_panic() -> ! { loop {} }
# #[lang = "eh_unwind_resume"] extern fn rust_eh_unwind_resume() {}
# #[no_mangle] pub extern fn rust_eh_register_frames () {}
# #[no_mangle] pub extern fn rust_eh_unregister_frames () {}
Expand All @@ -73,8 +73,8 @@ Other features provided by lang items include:
`==`, `<`, dereferencing (`*`) and `+` (etc.) operators are all
marked with lang items; those specific four are `eq`, `ord`,
`deref`, and `add` respectively.
- stack unwinding and general failure; the `eh_personality`, `fail`
and `fail_bounds_checks` lang items.
- stack unwinding and general failure; the `eh_personality`,
`eh_unwind_resume`, `fail` and `fail_bounds_checks` lang items.
- the traits in `std::marker` used to indicate types of
various kinds; lang items `send`, `sync` and `copy`.
- the marker types and variance indicators found in
Expand Down
33 changes: 25 additions & 8 deletions src/doc/book/no-stdlib.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,13 @@ fn start(_argc: isize, _argv: *const *const u8) -> isize {
// provided by libstd.
#[lang = "eh_personality"]
#[no_mangle]
pub extern fn eh_personality() {
pub extern fn rust_eh_personality() {
}
// This function may be needed based on the compilation target.
#[lang = "eh_unwind_resume"]
#[no_mangle]
pub extern fn rust_eh_unwind_resume() {
}
#[lang = "panic_fmt"]
Expand Down Expand Up @@ -87,12 +93,18 @@ pub extern fn main(_argc: i32, _argv: *const *const u8) -> i32 {
0
}
// These functions and traits are used by the compiler, but not
// These functions are used by the compiler, but not
// for a bare-bones hello world. These are normally
// provided by libstd.
#[lang = "eh_personality"]
#[no_mangle]
pub extern fn eh_personality() {
pub extern fn rust_eh_personality() {
}
// This function may be needed based on the compilation target.
#[lang = "eh_unwind_resume"]
#[no_mangle]
pub extern fn rust_eh_unwind_resume() {
}
#[lang = "panic_fmt"]
Expand All @@ -104,23 +116,28 @@ pub extern fn rust_begin_panic(_msg: core::fmt::Arguments,
}
```

## More about the langauge items
## More about the language items

The compiler currently makes a few assumptions about symbols which are
available in the executable to call. Normally these functions are provided by
the standard library, but without it you must define your own. These symbols
are called "language items", and they each have an internal name, and then a
signature that an implementation must conform to.

The first of these two functions, `eh_personality`, is used by the failure
The first of these functions, `rust_eh_personality`, is used by the failure
mechanisms of the compiler. This is often mapped to GCC's personality function
(see the [libstd implementation][unwind] for more information), but crates
which do not trigger a panic can be assured that this function is never
called. Both the language item and the symbol name are `eh_personality`.
called. The language item's name is `eh_personality`.

[unwind]: https://github.com/rust-lang/rust/blob/master/src/libpanic_unwind/gcc.rs

The second function, `panic_fmt`, is also used by the failure mechanisms of the
The second function, `rust_begin_panic`, is also used by the failure mechanisms of the
compiler. When a panic happens, this controls the message that's displayed on
the screen. While the language item's name is `panic_fmt`, the symbol name is
`rust_begin_panic`.

A third function, `rust_eh_unwind_resume`, is also needed if the `custom_unwind_resume`
flag is set in the options of the compilation target. It allows customizing the
process of resuming unwind at the end of the landing pads. The language item's name
is `eh_unwind_resume`.
5 changes: 5 additions & 0 deletions src/doc/grammar.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ token : simple_token | ident | literal | symbol | whitespace token ;
Each of these keywords has special meaning in its grammar, and all of them are
excluded from the `ident` rule.

Not all of these keywords are used by the language. Some of them were used
before Rust 1.0, and were left reserved once their implementations were
removed. Some of them were reserved before 1.0 to make space for possible
future features.

### Literals

```antlr
Expand Down
9 changes: 9 additions & 0 deletions src/libcollections/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1715,6 +1715,15 @@ pub struct IntoIter<T> {
end: *const T,
}

#[stable(feature = "vec_intoiter_debug", since = "")]
impl<T: fmt::Debug> fmt::Debug for IntoIter<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("IntoIter")
.field(&self.as_slice())
.finish()
}
}

impl<T> IntoIter<T> {
/// Returns the remaining items of this iterator as a slice.
///
Expand Down
8 changes: 8 additions & 0 deletions src/libcollectionstest/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,14 @@ fn test_into_iter_as_mut_slice() {
assert_eq!(into_iter.as_slice(), &['y', 'c']);
}

#[test]
fn test_into_iter_debug() {
let vec = vec!['a', 'b', 'c'];
let into_iter = vec.into_iter();
let debug = format!("{:?}", into_iter);
assert_eq!(debug, "IntoIter(['a', 'b', 'c'])");
}

#[test]
fn test_into_iter_count() {
assert_eq!(vec![1, 2, 3].into_iter().count(), 3);
Expand Down
17 changes: 2 additions & 15 deletions src/libcore/iter/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,20 +295,8 @@ impl<A: Step> ops::Range<A> {
///
/// ```
/// #![feature(step_by)]
///
/// for i in (0..10).step_by(2) {
/// println!("{}", i);
/// }
/// ```
///
/// This prints:
///
/// ```text
/// 0
/// 2
/// 4
/// 6
/// 8
/// let result: Vec<_> = (0..10).step_by(2).collect();
/// assert_eq!(result, vec![0, 2, 4, 6, 8]);
/// ```
#[unstable(feature = "step_by", reason = "recent addition",
issue = "27741")]
Expand Down Expand Up @@ -650,4 +638,3 @@ impl<A: Step> DoubleEndedIterator for ops::RangeInclusive<A> where
n
}
}

5 changes: 5 additions & 0 deletions src/libcore/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@
//! line. It is up to consumers of this core library to define this panic
//! function; it is only required to never return. This requires a `lang`
//! attribute named `panic_fmt`.
//!
//! * `rust_eh_personality` - is used by the failure mechanisms of the
//! compiler. This is often mapped to GCC's personality function, but crates
//! which do not trigger a panic can be assured that this function is never
//! called. The `lang` attribute is called `eh_personality`.

// Since libcore defines many fundamental lang items, all tests live in a
// separate crate, libcoretest, to avoid bizarre issues.
Expand Down
11 changes: 8 additions & 3 deletions src/libcore/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,16 @@

//! Overloadable operators.
//!
//! Implementing these traits allows you to get an effect similar to
//! overloading operators.
//! Implementing these traits allows you to overload certain operators.
//!
//! Some of these traits are imported by the prelude, so they are available in
//! every Rust program.
//! every Rust program. Only operators backed by traits can be overloaded. For
//! example, the addition operator (`+`) can be overloaded through the `Add`
//! trait, but since the assignment operator (`=`) has no backing trait, there
//! is no way of overloading its semantics. Additionally, this module does not
//! provide any mechanism to create new operators. If traitless overloading or
//! custom operators are required, you should look toward macros or compiler
//! plugins to extend Rust's syntax.
//!
//! Many of the operators take their operands by value. In non-generic
//! contexts involving built-in types, this is usually not a problem.
Expand Down
7 changes: 4 additions & 3 deletions src/librustc_const_eval/check_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1073,11 +1073,12 @@ fn check_irrefutable(cx: &MatchCheckCtxt, pat: &Pat, is_fn_arg: bool) {
};

is_refutable(cx, pat, |uncovered_pat| {
span_err!(cx.tcx.sess, pat.span, E0005,
let pattern_string = pat_to_string(uncovered_pat);
struct_span_err!(cx.tcx.sess, pat.span, E0005,
"refutable pattern in {}: `{}` not covered",
origin,
pat_to_string(uncovered_pat),
);
pattern_string,
).span_label(pat.span, &format!("pattern `{}` not covered", pattern_string)).emit();
});
}

Expand Down
5 changes: 4 additions & 1 deletion src/librustc_mir/transform/qualify_consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,10 @@ impl<'a, 'tcx> Qualifier<'a, 'tcx, 'tcx> {
} else {
"cannot refer to statics by value, use a constant instead"
};
span_err!(self.tcx.sess, self.span, E0394, "{}", msg);
struct_span_err!(self.tcx.sess, self.span, E0394, "{}", msg)
.span_label(self.span, &format!("referring to another static by value"))
.note(&format!("use the address-of operator or a constant instead"))
.emit();

// Replace STATIC with NOT_CONST to avoid further errors.
self.qualif = self.qualif - Qualif::STATIC;
Expand Down
8 changes: 4 additions & 4 deletions src/librustc_passes/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,10 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> {
Ok(Ordering::Less) |
Ok(Ordering::Equal) => {}
Ok(Ordering::Greater) => {
span_err!(self.tcx.sess,
start.span,
E0030,
"lower range bound must be less than or equal to upper");
struct_span_err!(self.tcx.sess, start.span, E0030,
"lower range bound must be less than or equal to upper")
.span_label(start.span, &format!("lower bound larger than upper bound"))
.emit();
}
Err(ErrorReported) => {}
}
Expand Down
25 changes: 17 additions & 8 deletions src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ enum ResolutionError<'a> {
/// error E0408: variable `{}` from pattern #{} is not bound in pattern #{}
VariableNotBoundInPattern(Name, usize, usize),
/// error E0409: variable is bound with different mode in pattern #{} than in pattern #1
VariableBoundWithDifferentMode(Name, usize),
VariableBoundWithDifferentMode(Name, usize, Span),
/// error E0411: use of `Self` outside of an impl or trait
SelfUsedOutsideImplOrTrait,
/// error E0412: use of undeclared
Expand Down Expand Up @@ -269,14 +269,19 @@ fn resolve_struct_error<'b, 'a: 'b, 'c>(resolver: &'b Resolver<'a>,
from,
to)
}
ResolutionError::VariableBoundWithDifferentMode(variable_name, pattern_number) => {
struct_span_err!(resolver.session,
ResolutionError::VariableBoundWithDifferentMode(variable_name,
pattern_number,
first_binding_span) => {
let mut err = struct_span_err!(resolver.session,
span,
E0409,
"variable `{}` is bound with different mode in pattern #{} than in \
pattern #1",
variable_name,
pattern_number)
pattern_number);
err.span_label(span, &format!("bound in different ways"));
err.span_label(first_binding_span, &format!("first binding"));
err
}
ResolutionError::SelfUsedOutsideImplOrTrait => {
let mut err = struct_span_err!(resolver.session,
Expand Down Expand Up @@ -316,11 +321,13 @@ fn resolve_struct_error<'b, 'a: 'b, 'c>(resolver: &'b Resolver<'a>,
err
}
ResolutionError::DoesNotNameAStruct(name) => {
struct_span_err!(resolver.session,
let mut err = struct_span_err!(resolver.session,
span,
E0422,
"`{}` does not name a structure",
name)
name);
err.span_label(span, &format!("not a structure"));
err
}
ResolutionError::StructVariantUsedAsFunction(path_name) => {
struct_span_err!(resolver.session,
Expand Down Expand Up @@ -2028,8 +2035,10 @@ impl<'a> Resolver<'a> {
if binding_0.binding_mode != binding_i.binding_mode {
resolve_error(self,
binding_i.span,
ResolutionError::VariableBoundWithDifferentMode(key.name,
i + 1));
ResolutionError::VariableBoundWithDifferentMode(
key.name,
i + 1,
binding_0.span));
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/librustc_resolve/resolve_imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -584,12 +584,12 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
source);
self.session.add_lint(PRIVATE_IN_PUBLIC, directive.id, directive.span, msg);
} else {
let msg = format!("`{}` is private, and cannot be reexported", source);
let note_msg =
format!("consider declaring type or module `{}` with `pub`", source);
struct_span_err!(self.session, directive.span, E0365, "{}", &msg)
.span_note(directive.span, &note_msg)
.emit();
let mut err = struct_span_err!(self.session, directive.span, E0365,
"`{}` is private, and cannot be reexported",
source);
err.span_label(directive.span, &format!("reexport of private `{}`", source));
err.note(&format!("consider declaring type or module `{}` with `pub`", source));
err.emit();
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/librustc_typeck/check/wfcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -624,8 +624,10 @@ fn error_380(ccx: &CrateCtxt, span: Span) {

fn error_392<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, span: Span, param_name: ast::Name)
-> DiagnosticBuilder<'tcx> {
struct_span_err!(ccx.tcx.sess, span, E0392,
"parameter `{}` is never used", param_name)
let mut err = struct_span_err!(ccx.tcx.sess, span, E0392,
"parameter `{}` is never used", param_name);
err.span_label(span, &format!("unused type parameter"));
err
}

fn error_194(tcx: TyCtxt, span: Span, name: ast::Name) {
Expand Down
Loading

0 comments on commit 7ac11ca

Please sign in to comment.