diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs
index c64cbb9a74e09..175e32125f272 100644
--- a/src/bootstrap/bin/rustc.rs
+++ b/src/bootstrap/bin/rustc.rs
@@ -38,13 +38,19 @@ fn main() {
// is passed (a bit janky...)
let target = args.windows(2).find(|w| &*w[0] == "--target")
.and_then(|w| w[1].to_str());
+ let version = args.iter().find(|w| &**w == "-vV");
// Build scripts always use the snapshot compiler which is guaranteed to be
// able to produce an executable, whereas intermediate compilers may not
// have the standard library built yet and may not be able to produce an
// executable. Otherwise we just use the standard compiler we're
// bootstrapping with.
- let (rustc, libdir) = if target.is_none() {
+ //
+ // Also note that cargo will detect the version of the compiler to trigger
+ // a rebuild when the compiler changes. If this happens, we want to make
+ // sure to use the actual compiler instead of the snapshot compiler becase
+ // that's the one that's actually changing.
+ let (rustc, libdir) = if target.is_none() && version.is_none() {
("RUSTC_SNAPSHOT", "RUSTC_SNAPSHOT_LIBDIR")
} else {
("RUSTC_REAL", "RUSTC_LIBDIR")
diff --git a/src/doc/book/borrow-and-asref.md b/src/doc/book/borrow-and-asref.md
index 1cfeb2620bd08..c30b2e68665f1 100644
--- a/src/doc/book/borrow-and-asref.md
+++ b/src/doc/book/borrow-and-asref.md
@@ -8,7 +8,7 @@ different. Here’s a quick refresher on what these two traits mean.
# Borrow
-The `Borrow` trait is used when you’re writing a datastructure, and you want to
+The `Borrow` trait is used when you’re writing a data structure, and you want to
use either an owned or borrowed type as synonymous for some purpose.
For example, [`HashMap`][hashmap] has a [`get` method][get] which uses `Borrow`:
@@ -86,7 +86,7 @@ We can see how they’re kind of the same: they both deal with owned and borrowe
versions of some type. However, they’re a bit different.
Choose `Borrow` when you want to abstract over different kinds of borrowing, or
-when you’re building a datastructure that treats owned and borrowed values in
+when you’re building a data structure that treats owned and borrowed values in
equivalent ways, such as hashing and comparison.
Choose `AsRef` when you want to convert something to a reference directly, and
diff --git a/src/doc/book/closures.md b/src/doc/book/closures.md
index d332cac7d8d16..3ed85c1a90b69 100644
--- a/src/doc/book/closures.md
+++ b/src/doc/book/closures.md
@@ -340,7 +340,7 @@ fn call_with_ref<'a, F>(some_closure:F) -> i32
where F: Fn(&'a i32) -> i32 {
```
-However this presents a problem with in our case. When you specify the explicit
+However this presents a problem in our case. When you specify the explicit
lifetime on a function it binds that lifetime to the *entire* scope of the function
instead of just the invocation scope of our closure. This means that the borrow checker
will see a mutable reference in the same lifetime as our immutable reference and fail
diff --git a/src/doc/book/error-handling.md b/src/doc/book/error-handling.md
index 6e13b464e4c25..a62e1b7dfa9c5 100644
--- a/src/doc/book/error-handling.md
+++ b/src/doc/book/error-handling.md
@@ -59,7 +59,7 @@ handling is reducing the amount of explicit case analysis the programmer has to
do while keeping code composable.
Keeping code composable is important, because without that requirement, we
-could [`panic`](../std/macro.panic!.html) whenever we
+could [`panic`](../std/macro.panic.html) whenever we
come across something unexpected. (`panic` causes the current task to unwind,
and in most cases, the entire program aborts.) Here's an example:
@@ -944,7 +944,7 @@ macro_rules! try {
}
```
-(The [real definition](../std/macro.try!.html) is a bit more
+(The [real definition](../std/macro.try.html) is a bit more
sophisticated. We will address that later.)
Using the `try!` macro makes it very easy to simplify our last example. Since
@@ -1271,7 +1271,7 @@ macro_rules! try {
```
This is not its real definition. Its real definition is
-[in the standard library](../std/macro.try!.html):
+[in the standard library](../std/macro.try.html):
@@ -2178,7 +2178,7 @@ heuristics!
[`From`](../std/convert/trait.From.html)
and
[`Error`](../std/error/trait.Error.html)
- impls to make the [`try!`](../std/macro.try!.html)
+ impls to make the [`try!`](../std/macro.try.html)
macro more ergonomic.
* If you're writing a library and your code can produce errors, define your own
error type and implement the
diff --git a/src/libcollections/fmt.rs b/src/libcollections/fmt.rs
index be0ef85d6b114..b7cbfb60ec4e9 100644
--- a/src/libcollections/fmt.rs
+++ b/src/libcollections/fmt.rs
@@ -530,7 +530,7 @@ use string;
/// assert_eq!(s, "Hello, world!");
/// ```
///
-/// [format!]: ../macro.format!.html
+/// [format!]: ../macro.format.html
#[stable(feature = "rust1", since = "1.0.0")]
pub fn format(args: Arguments) -> string::String {
let mut output = string::String::new();
diff --git a/src/libcore/iter/range.rs b/src/libcore/iter/range.rs
index 079dfe2a81f80..f8b3c84be5aa7 100644
--- a/src/libcore/iter/range.rs
+++ b/src/libcore/iter/range.rs
@@ -267,14 +267,11 @@ impl ops::RangeFrom {
/// # Examples
///
/// ```
- /// # #![feature(step_by)]
+ /// #![feature(step_by)]
///
- /// for i in (0u8..).step_by(2).take(10) {
- /// println!("{}", i);
- /// }
+ /// let result: Vec<_> = (0..).step_by(2).take(5).collect();
+ /// assert_eq!(result, vec![0, 2, 4, 6, 8]);
/// ```
- ///
- /// This prints the first ten even natural integers (0 to 18).
#[unstable(feature = "step_by", reason = "recent addition",
issue = "27741")]
pub fn step_by(self, by: A) -> StepBy {
@@ -319,20 +316,8 @@ impl ops::RangeInclusive {
/// ```
/// #![feature(step_by, inclusive_range_syntax)]
///
- /// for i in (0...10).step_by(2) {
- /// println!("{}", i);
- /// }
- /// ```
- ///
- /// This prints:
- ///
- /// ```text
- /// 0
- /// 2
- /// 4
- /// 6
- /// 8
- /// 10
+ /// let result: Vec<_> = (0...10).step_by(2).collect();
+ /// assert_eq!(result, vec![0, 2, 4, 6, 8, 10]);
/// ```
#[unstable(feature = "step_by", reason = "recent addition",
issue = "27741")]
diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs
index 4ac1b8394f450..5a1993e741c60 100644
--- a/src/libcore/ops.rs
+++ b/src/libcore/ops.rs
@@ -67,8 +67,7 @@
//! }
//! ```
//!
-//! See the documentation for each trait for a minimum implementation that
-//! prints something to the screen.
+//! See the documentation for each trait for an example implementation.
#![stable(feature = "rust1", since = "1.0.0")]
@@ -107,6 +106,13 @@ pub trait Drop {
///
/// After this function is over, the memory of `self` will be deallocated.
///
+ /// This function cannot be called explicitly. This is compiler error
+ /// [0040]. However, the [`std::mem::drop`] function in the prelude can be
+ /// used to call the argument's `Drop` implementation.
+ ///
+ /// [0040]: https://doc.rust-lang.org/error-index.html#E0040
+ /// [`std::mem::drop`]: https://doc.rust-lang.org/std/mem/fn.drop.html
+ ///
/// # Panics
///
/// Given that a `panic!` will call `drop()` as it unwinds, any `panic!` in
@@ -171,25 +177,38 @@ macro_rules! forward_ref_binop {
///
/// # Examples
///
-/// A trivial implementation of `Add`. When `Foo + Foo` happens, it ends up
-/// calling `add`, and therefore, `main` prints `Adding!`.
+/// This example creates a `Point` struct that implements the `Add` trait, and
+/// then demonstrates adding two `Point`s.
///
/// ```
/// use std::ops::Add;
///
-/// struct Foo;
+/// #[derive(Debug)]
+/// struct Point {
+/// x: i32,
+/// y: i32,
+/// }
///
-/// impl Add for Foo {
-/// type Output = Foo;
+/// impl Add for Point {
+/// type Output = Point;
///
-/// fn add(self, _rhs: Foo) -> Foo {
-/// println!("Adding!");
-/// self
+/// fn add(self, other: Point) -> Point {
+/// Point {
+/// x: self.x + other.x,
+/// y: self.y + other.y,
+/// }
+/// }
+/// }
+///
+/// impl PartialEq for Point {
+/// fn eq(&self, other: &Self) -> bool {
+/// self.x == other.x && self.y == other.y
/// }
/// }
///
/// fn main() {
-/// Foo + Foo;
+/// assert_eq!(Point { x: 1, y: 0 } + Point { x: 2, y: 3 },
+/// Point { x: 3, y: 3 });
/// }
/// ```
#[lang = "add"]
@@ -300,6 +319,37 @@ sub_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 }
/// Foo * Foo;
/// }
/// ```
+///
+/// Note that `RHS = Self` by default, but this is not mandatory. Here is an
+/// implementation which enables multiplication of vectors by scalars, as is
+/// done in linear algebra.
+///
+/// ```
+/// use std::ops::Mul;
+///
+/// struct Scalar {value: usize};
+///
+/// #[derive(Debug)]
+/// struct Vector {value: Vec};
+///
+/// impl Mul for Scalar {
+/// type Output = Vector;
+///
+/// fn mul(self, rhs: Vector) -> Vector {
+/// Vector {value: rhs.value.iter().map(|v| self.value * v).collect()}
+/// }
+/// }
+///
+/// impl PartialEq for Vector {
+/// fn eq(&self, other: &Self) -> bool {
+/// self.value == other.value
+/// }
+/// }
+///
+/// let scalar = Scalar{value: 3};
+/// let vector = Vector{value: vec![2, 4, 6]};
+/// assert_eq!(scalar * vector, Vector{value: vec![6, 12, 18]});
+/// ```
#[lang = "mul"]
#[stable(feature = "rust1", since = "1.0.0")]
pub trait Mul {
@@ -354,6 +404,37 @@ mul_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 }
/// Foo / Foo;
/// }
/// ```
+///
+/// Note that `RHS = Self` by default, but this is not mandatory. Here is an
+/// implementation which enables division of vectors by scalars, as is done in
+/// linear algebra.
+///
+/// ```
+/// use std::ops::Div;
+///
+/// struct Scalar {value: f32};
+///
+/// #[derive(Debug)]
+/// struct Vector {value: Vec};
+///
+/// impl Div for Vector {
+/// type Output = Vector;
+///
+/// fn div(self, rhs: Scalar) -> Vector {
+/// Vector {value: self.value.iter().map(|v| v / rhs.value).collect()}
+/// }
+/// }
+///
+/// impl PartialEq for Vector {
+/// fn eq(&self, other: &Self) -> bool {
+/// self.value == other.value
+/// }
+/// }
+///
+/// let scalar = Scalar{value: 2f32};
+/// let vector = Vector{value: vec![2f32, 4f32, 6f32]};
+/// assert_eq!(vector / scalar, Vector{value: vec![1f32, 2f32, 3f32]});
+/// ```
#[lang = "div"]
#[stable(feature = "rust1", since = "1.0.0")]
pub trait Div {
@@ -475,26 +556,37 @@ rem_impl_float! { f32 f64 }
///
/// # Examples
///
-/// A trivial implementation of `Neg`. When `-Foo` happens, it ends up calling
-/// `neg`, and therefore, `main` prints `Negating!`.
+/// An implementation of `Neg` for `Sign`, which allows the use of `-` to
+/// negate its value.
///
/// ```
/// use std::ops::Neg;
///
-/// struct Foo;
+/// #[derive(Debug, PartialEq)]
+/// enum Sign {
+/// Negative,
+/// Zero,
+/// Positive,
+/// }
///
-/// impl Neg for Foo {
-/// type Output = Foo;
+/// impl Neg for Sign {
+/// type Output = Sign;
///
-/// fn neg(self) -> Foo {
-/// println!("Negating!");
-/// self
+/// fn neg(self) -> Sign {
+/// match self {
+/// Sign::Negative => Sign::Positive,
+/// Sign::Zero => Sign::Zero,
+/// Sign::Positive => Sign::Negative,
+/// }
/// }
/// }
///
-/// fn main() {
-/// -Foo;
-/// }
+/// // a negative positive is a negative
+/// assert_eq!(-Sign::Positive, Sign::Negative);
+/// // a double negative is a positive
+/// assert_eq!(-Sign::Negative, Sign::Positive);
+/// // zero is its own negation
+/// assert_eq!(-Sign::Zero, Sign::Zero);
/// ```
#[lang = "neg"]
#[stable(feature = "rust1", since = "1.0.0")]
@@ -543,26 +635,31 @@ neg_impl_numeric! { isize i8 i16 i32 i64 f32 f64 }
///
/// # Examples
///
-/// A trivial implementation of `Not`. When `!Foo` happens, it ends up calling
-/// `not`, and therefore, `main` prints `Not-ing!`.
+/// An implementation of `Not` for `Answer`, which enables the use of `!` to
+/// invert its value.
///
/// ```
/// use std::ops::Not;
///
-/// struct Foo;
+/// #[derive(Debug, PartialEq)]
+/// enum Answer {
+/// Yes,
+/// No,
+/// }
///
-/// impl Not for Foo {
-/// type Output = Foo;
+/// impl Not for Answer {
+/// type Output = Answer;
///
-/// fn not(self) -> Foo {
-/// println!("Not-ing!");
-/// self
+/// fn not(self) -> Answer {
+/// match self {
+/// Answer::Yes => Answer::No,
+/// Answer::No => Answer::Yes
+/// }
/// }
/// }
///
-/// fn main() {
-/// !Foo;
-/// }
+/// assert_eq!(!Answer::Yes, Answer::No);
+/// assert_eq!(!Answer::No, Answer::Yes);
/// ```
#[lang = "not"]
#[stable(feature = "rust1", since = "1.0.0")]
@@ -899,25 +996,36 @@ shr_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize }
///
/// # Examples
///
-/// A trivial implementation of `AddAssign`. When `Foo += Foo` happens, it ends up
-/// calling `add_assign`, and therefore, `main` prints `Adding!`.
+/// This example creates a `Point` struct that implements the `AddAssign`
+/// trait, and then demonstrates add-assigning to a mutable `Point`.
///
/// ```
/// use std::ops::AddAssign;
///
-/// struct Foo;
+/// #[derive(Debug)]
+/// struct Point {
+/// x: i32,
+/// y: i32,
+/// }
///
-/// impl AddAssign for Foo {
-/// fn add_assign(&mut self, _rhs: Foo) {
-/// println!("Adding!");
+/// impl AddAssign for Point {
+/// fn add_assign(&mut self, other: Point) {
+/// *self = Point {
+/// x: self.x + other.x,
+/// y: self.y + other.y,
+/// };
/// }
/// }
///
-/// # #[allow(unused_assignments)]
-/// fn main() {
-/// let mut foo = Foo;
-/// foo += Foo;
+/// impl PartialEq for Point {
+/// fn eq(&self, other: &Self) -> bool {
+/// self.x == other.x && self.y == other.y
+/// }
/// }
+///
+/// let mut point = Point { x: 1, y: 0 };
+/// point += Point { x: 2, y: 3 };
+/// assert_eq!(point, Point { x: 3, y: 3 });
/// ```
#[lang = "add_assign"]
#[stable(feature = "op_assign_traits", since = "1.8.0")]
@@ -1467,17 +1575,30 @@ pub trait IndexMut: Index {
///
/// # Examples
///
+/// The `..` syntax is a `RangeFull`:
+///
+/// ```
+/// assert_eq!((..), std::ops::RangeFull);
/// ```
-/// fn main() {
-/// assert_eq!((..), std::ops::RangeFull);
///
-/// let arr = [0, 1, 2, 3];
-/// assert_eq!(arr[ .. ], [0,1,2,3]); // RangeFull
-/// assert_eq!(arr[ ..3], [0,1,2 ]);
-/// assert_eq!(arr[1.. ], [ 1,2,3]);
-/// assert_eq!(arr[1..3], [ 1,2 ]);
+/// It does not have an `IntoIterator` implementation, so you can't use it in a
+/// `for` loop directly. This won't compile:
+///
+/// ```ignore
+/// for i in .. {
+/// // ...
/// }
/// ```
+///
+/// Used as a slicing index, `RangeFull` produces the full array as a slice.
+///
+/// ```
+/// let arr = [0, 1, 2, 3];
+/// assert_eq!(arr[ .. ], [0,1,2,3]); // RangeFull
+/// assert_eq!(arr[ ..3], [0,1,2 ]);
+/// assert_eq!(arr[1.. ], [ 1,2,3]);
+/// assert_eq!(arr[1..3], [ 1,2 ]);
+/// ```
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct RangeFull;
diff --git a/src/librustc/middle/effect.rs b/src/librustc/middle/effect.rs
index 3ca6cf0399797..250ad80f5af6c 100644
--- a/src/librustc/middle/effect.rs
+++ b/src/librustc/middle/effect.rs
@@ -66,7 +66,7 @@ impl<'a, 'tcx> EffectCheckVisitor<'a, 'tcx> {
struct_span_err!(
self.tcx.sess, span, E0133,
"{} requires unsafe function or block", description)
- .span_label(span, &format!("unsafe call requires unsafe function or block"))
+ .span_label(span, &description)
.emit();
}
UnsafeBlock(block_id) => {
diff --git a/src/librustc_metadata/diagnostics.rs b/src/librustc_metadata/diagnostics.rs
index ae9f500c5de59..099ec62b38de7 100644
--- a/src/librustc_metadata/diagnostics.rs
+++ b/src/librustc_metadata/diagnostics.rs
@@ -14,7 +14,7 @@ register_long_diagnostics! {
E0454: r##"
A link name was given with an empty name. Erroneous code example:
-```
+```compile_fail,E0454
#[link(name = "")] extern {} // error: #[link(name = "")] given with empty name
```
@@ -32,7 +32,7 @@ as frameworks are specific to that operating system.
Erroneous code example:
-```compile_fail"
+```compile_fail,E0455
#[link(name = "FooCoreServices", kind = "framework")] extern {}
// OS used to compile is Linux for example
```
@@ -50,7 +50,7 @@ See more: https://doc.rust-lang.org/book/conditional-compilation.html
E0458: r##"
An unknown "kind" was specified for a link attribute. Erroneous code example:
-```
+```compile_fail,E0458
#[link(kind = "wonderful_unicorn")] extern {}
// error: unknown kind: `wonderful_unicorn`
```
@@ -64,7 +64,7 @@ Please specify a valid "kind" value, from one of the following:
E0459: r##"
A link was used without a name parameter. Erroneous code example:
-```
+```compile_fail,E0459
#[link(kind = "dylib")] extern {}
// error: #[link(...)] specified without `name = "foo"`
```
@@ -80,7 +80,7 @@ you want. Example:
E0463: r##"
A plugin/crate was declared but cannot be found. Erroneous code example:
-```
+```compile_fail,E0463
#![feature(plugin)]
#![plugin(cookie_monster)] // error: can't find crate for `cookie_monster`
extern crate cake_is_a_lie; // error: can't find crate for `cake_is_a_lie`
diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs
index 1de67922b1b3a..bcdc0d2ea3f9d 100644
--- a/src/librustc_mir/transform/qualify_consts.rs
+++ b/src/librustc_mir/transform/qualify_consts.rs
@@ -493,9 +493,13 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
if let ty::TyRawPtr(_) = base_ty.sty {
this.add(Qualif::NOT_CONST);
if this.mode != Mode::Fn {
- span_err!(this.tcx.sess, this.span, E0396,
- "raw pointers cannot be dereferenced in {}s",
- this.mode);
+ struct_span_err!(this.tcx.sess,
+ this.span, E0396,
+ "raw pointers cannot be dereferenced in {}s",
+ this.mode)
+ .span_label(this.span,
+ &format!("dereference of raw pointer in constant"))
+ .emit();
}
}
}
@@ -681,9 +685,14 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
self.add(Qualif::NOT_CONST);
if self.mode != Mode::Fn {
- span_err!(self.tcx.sess, self.span, E0395,
- "raw pointers cannot be compared in {}s",
- self.mode);
+ struct_span_err!(
+ self.tcx.sess, self.span, E0395,
+ "raw pointers cannot be compared in {}s",
+ self.mode)
+ .span_label(
+ self.span,
+ &format!("comparing raw pointers in static"))
+ .emit();
}
}
}
diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs
index ff0b86aa59540..7f27d3eb0a789 100644
--- a/src/librustc_typeck/check/mod.rs
+++ b/src/librustc_typeck/check/mod.rs
@@ -903,9 +903,12 @@ fn check_on_unimplemented<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
}
}
} else {
- span_err!(ccx.tcx.sess, attr.span, E0232,
- "this attribute must have a value, \
- eg `#[rustc_on_unimplemented = \"foo\"]`")
+ struct_span_err!(
+ ccx.tcx.sess, attr.span, E0232,
+ "this attribute must have a value")
+ .span_label(attr.span, &format!("attribute requires a value"))
+ .note(&format!("eg `#[rustc_on_unimplemented = \"foo\"]`"))
+ .emit();
}
}
}
@@ -1245,8 +1248,11 @@ pub fn check_enum_variants<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>,
let hint = *ccx.tcx.lookup_repr_hints(def_id).get(0).unwrap_or(&attr::ReprAny);
if hint != attr::ReprAny && vs.is_empty() {
- span_err!(ccx.tcx.sess, sp, E0084,
- "unsupported representation for zero-variant enum");
+ struct_span_err!(
+ ccx.tcx.sess, sp, E0084,
+ "unsupported representation for zero-variant enum")
+ .span_label(sp, &format!("unsupported enum representation"))
+ .emit();
}
let repr_type_ty = ccx.tcx.enum_repr_type(Some(&hint)).to_ty(ccx.tcx);
@@ -3192,14 +3198,30 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
!error_happened &&
!remaining_fields.is_empty()
{
- span_err!(tcx.sess, span, E0063,
- "missing field{} {} in initializer of `{}`",
- if remaining_fields.len() == 1 {""} else {"s"},
- remaining_fields.keys()
- .map(|n| format!("`{}`", n))
- .collect::>()
- .join(", "),
- adt_ty);
+ let len = remaining_fields.len();
+
+ let truncated_fields = if len <= 3 {
+ (remaining_fields.keys().take(len), "".to_string())
+ } else {
+ (remaining_fields.keys().take(3), format!(", and {} other field{}",
+ (len-3), if len-3 == 1 {""} else {"s"}))
+ };
+
+ let remaining_fields_names = truncated_fields.0
+ .map(|n| format!("`{}`", n))
+ .collect::>()
+ .join(", ");
+
+ struct_span_err!(tcx.sess, span, E0063,
+ "missing field{} {}{} in initializer of `{}`",
+ if remaining_fields.len() == 1 {""} else {"s"},
+ remaining_fields_names,
+ truncated_fields.1,
+ adt_ty)
+ .span_label(span, &format!("missing {}{}",
+ remaining_fields_names,
+ truncated_fields.1))
+ .emit();
}
}
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs
index 75d21399f05e6..39b1a04e98e69 100644
--- a/src/librustdoc/clean/mod.rs
+++ b/src/librustdoc/clean/mod.rs
@@ -2803,7 +2803,7 @@ pub struct Macro {
impl Clean- for doctree::Macro {
fn clean(&self, cx: &DocContext) -> Item {
- let name = format!("{}!", self.name.clean(cx));
+ let name = self.name.clean(cx);
Item {
name: Some(name.clone()),
attrs: self.attrs.clean(cx),
@@ -2814,8 +2814,10 @@ impl Clean
- for doctree::Macro {
def_id: cx.map.local_def_id(self.id),
inner: MacroItem(Macro {
source: format!("macro_rules! {} {{\n{}}}",
- name.trim_right_matches('!'), self.matchers.iter().map(|span|
- format!(" {} => {{ ... }};\n", span.to_src(cx))).collect::()),
+ name,
+ self.matchers.iter().map(|span| {
+ format!(" {} => {{ ... }};\n", span.to_src(cx))
+ }).collect::()),
imported_from: self.imported_from.clean(cx),
}),
}
diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs
index d654429146d83..e02cfb96dddf1 100644
--- a/src/librustdoc/html/render.rs
+++ b/src/librustdoc/html/render.rs
@@ -1426,6 +1426,16 @@ impl Context {
.open(&redir_dst) {
try_err!(layout::redirect(&mut redirect_out, file_name), &redir_dst);
}
+
+ // If the item is a macro, redirect from the old macro URL (with !)
+ // to the new one (without).
+ // FIXME(#35705) remove this redirect.
+ if item_type == ItemType::Macro {
+ let redir_name = format!("{}.{}!.html", item_type, name);
+ let redir_dst = self.dst.join(redir_name);
+ let mut redirect_out = try_err!(File::create(&redir_dst), &redir_dst);
+ try_err!(layout::redirect(&mut redirect_out, file_name), &redir_dst);
+ }
}
}
Ok(())
diff --git a/src/libstd/ffi/os_str.rs b/src/libstd/ffi/os_str.rs
index 0d29e62485abb..3d23a9a2383ff 100644
--- a/src/libstd/ffi/os_str.rs
+++ b/src/libstd/ffi/os_str.rs
@@ -251,6 +251,14 @@ impl Hash for OsString {
impl OsStr {
/// Coerces into an `OsStr` slice.
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// use std::ffi::OsStr;
+ ///
+ /// let os_str = OsStr::new("foo");
+ /// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn new + ?Sized>(s: &S) -> &OsStr {
s.as_ref()
@@ -283,6 +291,18 @@ impl OsStr {
}
/// Checks whether the `OsStr` is empty.
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// use std::ffi::OsStr;
+ ///
+ /// let os_str = OsStr::new("");
+ /// assert!(os_str.is_empty());
+ ///
+ /// let os_str = OsStr::new("foo");
+ /// assert!(!os_str.is_empty());
+ /// ```
#[stable(feature = "osstring_simple_functions", since = "1.9.0")]
pub fn is_empty(&self) -> bool {
self.inner.inner.is_empty()
@@ -296,6 +316,18 @@ impl OsStr {
/// other methods like `OsString::with_capacity` to avoid reallocations.
///
/// See `OsStr` introduction for more information about encoding.
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// use std::ffi::OsStr;
+ ///
+ /// let os_str = OsStr::new("");
+ /// assert_eq!(os_str.len(), 0);
+ ///
+ /// let os_str = OsStr::new("foo");
+ /// assert_eq!(os_str.len(), 3);
+ /// ```
#[stable(feature = "osstring_simple_functions", since = "1.9.0")]
pub fn len(&self) -> usize {
self.inner.inner.len()
diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs
index b78db24e44b70..ed821983b7087 100644
--- a/src/libstd/fs.rs
+++ b/src/libstd/fs.rs
@@ -1511,8 +1511,11 @@ pub fn remove_dir_all>(path: P) -> io::Result<()> {
/// Returns an iterator over the entries within a directory.
///
-/// The iterator will yield instances of `io::Result`. New errors may
-/// be encountered after an iterator is initially constructed.
+/// The iterator will yield instances of [`io::Result<`][`DirEntry`]`>`.
+/// New errors may be encountered after an iterator is initially constructed.
+///
+/// [`io::Result<`]: ../io/type.Result.html
+/// [`DirEntry`]: ../fs/struct.DirEntry.html
///
/// # Platform-specific behavior
///
diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs
index 88fd4186e0a2a..307d014fd68c6 100644
--- a/src/libstd/io/mod.rs
+++ b/src/libstd/io/mod.rs
@@ -236,7 +236,7 @@
//! to read the line and print it, so we use `()`.
//!
//! [result]: type.Result.html
-//! [try]: ../macro.try!.html
+//! [try]: ../macro.try.html
//!
//! ## Platform-specific behavior
//!
@@ -957,8 +957,8 @@ pub trait Write {
/// explicitly be called. The [`write!`][write] macro should be favored to
/// invoke this method instead.
///
- /// [formatargs]: ../macro.format_args!.html
- /// [write]: ../macro.write!.html
+ /// [formatargs]: ../macro.format_args.html
+ /// [write]: ../macro.write.html
///
/// This function internally uses the [`write_all`][writeall] method on
/// this trait and hence will continuously write data so long as no errors
diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs
index c05e0c3ca68df..ff3b9c6d04163 100644
--- a/src/libstd/lib.rs
+++ b/src/libstd/lib.rs
@@ -175,7 +175,7 @@
//! [`atomic`]: sync/atomic/index.html
//! [`collections`]: collections/index.html
//! [`for`]: ../book/loops.html#for
-//! [`format!`]: macro.format!.html
+//! [`format!`]: macro.format.html
//! [`fs`]: fs/index.html
//! [`io`]: io/index.html
//! [`iter`]: iter/index.html
diff --git a/src/libstd/path.rs b/src/libstd/path.rs
index 2d19561139b58..66efe017655fd 100644
--- a/src/libstd/path.rs
+++ b/src/libstd/path.rs
@@ -986,11 +986,16 @@ impl<'a> cmp::Ord for Components<'a> {
// Basic types and traits
////////////////////////////////////////////////////////////////////////////////
-/// An owned, mutable path (akin to `String`).
+/// An owned, mutable path (akin to [`String`]).
///
-/// This type provides methods like `push` and `set_extension` that mutate the
-/// path in place. It also implements `Deref` to `Path`, meaning that all
-/// methods on `Path` slices are available on `PathBuf` values as well.
+/// This type provides methods like [`push`] and [`set_extension`] that mutate
+/// the path in place. It also implements [`Deref`] to [`Path`], meaning that
+/// all methods on [`Path`] slices are available on `PathBuf` values as well.
+///
+/// [`String`]: ../string/struct.String.html
+/// [`Path`]: struct.Path.html
+/// [`push`]: struct.PathBuf.html#method.push
+/// [`set_extension`]: struct.PathBuf.html#method.set_extension
///
/// More details about the overall approach can be found in
/// the module documentation.
@@ -1017,12 +1022,31 @@ impl PathBuf {
}
/// Allocates an empty `PathBuf`.
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// use std::path::PathBuf;
+ ///
+ /// let path = PathBuf::new();
+ /// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn new() -> PathBuf {
PathBuf { inner: OsString::new() }
}
- /// Coerces to a `Path` slice.
+ /// Coerces to a [`Path`] slice.
+ ///
+ /// [`Path`]: struct.Path.html
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// use std::path::{Path, PathBuf};
+ ///
+ /// let p = PathBuf::from("/test");
+ /// assert_eq!(Path::new("/test"), p.as_path());
+ /// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn as_path(&self) -> &Path {
self
@@ -1087,10 +1111,26 @@ impl PathBuf {
self.inner.push(path);
}
- /// Truncate `self` to `self.parent()`.
+ /// Truncate `self` to [`self.parent()`].
///
- /// Returns false and does nothing if `self.file_name()` is `None`.
+ /// Returns false and does nothing if [`self.file_name()`] is `None`.
/// Otherwise, returns `true`.
+ ///
+ /// [`self.parent()`]: struct.PathBuf.html#method.parent
+ /// [`self.file_name()`]: struct.PathBuf.html#method.file_name
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// use std::path::{Path, PathBuf};
+ ///
+ /// let mut p = PathBuf::from("/test/test.rs");
+ ///
+ /// p.pop();
+ /// assert_eq!(Path::new("/test"), p.as_path());
+ /// p.pop();
+ /// assert_eq!(Path::new("/"), p.as_path());
+ /// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn pop(&mut self) -> bool {
match self.parent().map(|p| p.as_u8_slice().len()) {
@@ -1102,11 +1142,13 @@ impl PathBuf {
}
}
- /// Updates `self.file_name()` to `file_name`.
+ /// Updates [`self.file_name()`] to `file_name`.
///
/// If `self.file_name()` was `None`, this is equivalent to pushing
/// `file_name`.
///
+ /// [`self.file_name()`]: struct.PathBuf.html#method.file_name
+ ///
/// # Examples
///
/// ```
@@ -1133,12 +1175,29 @@ impl PathBuf {
self.push(file_name);
}
- /// Updates `self.extension()` to `extension`.
+ /// Updates [`self.extension()`] to `extension`.
+ ///
+ /// If [`self.file_name()`] is `None`, does nothing and returns `false`.
+ ///
+ /// Otherwise, returns `true`; if [`self.extension()`] is `None`, the
+ /// extension is added; otherwise it is replaced.
+ ///
+ /// [`self.file_name()`]: struct.PathBuf.html#method.file_name
+ /// [`self.extension()`]: struct.PathBuf.html#method.extension
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// use std::path::{Path, PathBuf};
///
- /// If `self.file_name()` is `None`, does nothing and returns `false`.
+ /// let mut p = PathBuf::from("/feel/the");
///
- /// Otherwise, returns `true`; if `self.extension()` is `None`, the extension
- /// is added; otherwise it is replaced.
+ /// p.set_extension("force");
+ /// assert_eq!(Path::new("/feel/the.force"), p.as_path());
+ ///
+ /// p.set_extension("dark_side");
+ /// assert_eq!(Path::new("/feel/the.dark_side"), p.as_path());
+ /// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn set_extension>(&mut self, extension: S) -> bool {
self._set_extension(extension.as_ref())
@@ -1163,7 +1222,18 @@ impl PathBuf {
true
}
- /// Consumes the `PathBuf`, yielding its internal `OsString` storage.
+ /// Consumes the `PathBuf`, yielding its internal [`OsString`] storage.
+ ///
+ /// [`OsString`]: ../ffi/struct.OsString.html
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// use std::path::PathBuf;
+ ///
+ /// let p = PathBuf::from("/the/head");
+ /// let os_str = p.into_os_string();
+ /// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn into_os_string(self) -> OsString {
self.inner
@@ -1301,7 +1371,7 @@ impl Into for PathBuf {
}
}
-/// A slice of a path (akin to `str`).
+/// A slice of a path (akin to [`str`]).
///
/// This type supports a number of operations for inspecting a path, including
/// breaking the path into its components (separated by `/` or `\`, depending on
@@ -1310,7 +1380,10 @@ impl Into for PathBuf {
/// the module documentation.
///
/// This is an *unsized* type, meaning that it must always be used behind a
-/// pointer like `&` or `Box`.
+/// pointer like `&` or [`Box`].
+///
+/// [`str`]: ../primitive.str.html
+/// [`Box`]: ../boxed/struct.Box.html
///
/// # Examples
///
@@ -1372,7 +1445,9 @@ impl Path {
unsafe { mem::transmute(s.as_ref()) }
}
- /// Yields the underlying `OsStr` slice.
+ /// Yields the underlying [`OsStr`] slice.
+ ///
+ /// [`OsStr`]: ../ffi/struct.OsStr.html
///
/// # Examples
///
@@ -1387,10 +1462,12 @@ impl Path {
&self.inner
}
- /// Yields a `&str` slice if the `Path` is valid unicode.
+ /// Yields a [`&str`] slice if the `Path` is valid unicode.
///
/// This conversion may entail doing a check for UTF-8 validity.
///
+ /// [`&str`]: ../primitive.str.html
+ ///
/// # Examples
///
/// ```
@@ -1404,10 +1481,12 @@ impl Path {
self.inner.to_str()
}
- /// Converts a `Path` to a `Cow`.
+ /// Converts a `Path` to a [`Cow`].
///
/// Any non-Unicode sequences are replaced with U+FFFD REPLACEMENT CHARACTER.
///
+ /// [`Cow`]: ../borrow/enum.Cow.html
+ ///
/// # Examples
///
/// ```
@@ -1421,7 +1500,9 @@ impl Path {
self.inner.to_string_lossy()
}
- /// Converts a `Path` to an owned `PathBuf`.
+ /// Converts a `Path` to an owned [`PathBuf`].
+ ///
+ /// [`PathBuf`]: struct.PathBuf.html
///
/// # Examples
///
@@ -1569,6 +1650,18 @@ impl Path {
///
/// If `base` is not a prefix of `self` (i.e. `starts_with`
/// returns `false`), returns `Err`.
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// use std::path::Path;
+ ///
+ /// let path = Path::new("/test/haha/foo.txt");
+ ///
+ /// assert_eq!(path.strip_prefix("/test"), Ok(Path::new("haha/foo.txt")));
+ /// assert_eq!(path.strip_prefix("test").is_ok(), false);
+ /// assert_eq!(path.strip_prefix("/haha").is_ok(), false);
+ /// ```
#[stable(since = "1.7.0", feature = "path_strip_prefix")]
pub fn strip_prefix<'a, P: ?Sized>(&'a self, base: &'a P)
-> Result<&'a Path, StripPrefixError>
@@ -1630,7 +1723,9 @@ impl Path {
iter_after(self.components().rev(), child.components().rev()).is_some()
}
- /// Extracts the stem (non-extension) portion of `self.file_name()`.
+ /// Extracts the stem (non-extension) portion of [`self.file_name()`].
+ ///
+ /// [`self.file_name()`]: struct.Path.html#method.file_name
///
/// The stem is:
///
@@ -1653,7 +1748,9 @@ impl Path {
self.file_name().map(split_file_at_dot).and_then(|(before, after)| before.or(after))
}
- /// Extracts the extension of `self.file_name()`, if possible.
+ /// Extracts the extension of [`self.file_name()`], if possible.
+ ///
+ /// [`self.file_name()`]: struct.Path.html#method.file_name
///
/// The extension is:
///
@@ -1676,9 +1773,12 @@ impl Path {
self.file_name().map(split_file_at_dot).and_then(|(before, after)| before.and(after))
}
- /// Creates an owned `PathBuf` with `path` adjoined to `self`.
+ /// Creates an owned [`PathBuf`] with `path` adjoined to `self`.
+ ///
+ /// See [`PathBuf::push`] for more details on what it means to adjoin a path.
///
- /// See `PathBuf::push` for more details on what it means to adjoin a path.
+ /// [`PathBuf`]: struct.PathBuf.html
+ /// [`PathBuf::push`]: struct.PathBuf.html#method.push
///
/// # Examples
///
@@ -1698,9 +1798,12 @@ impl Path {
buf
}
- /// Creates an owned `PathBuf` like `self` but with the given file name.
+ /// Creates an owned [`PathBuf`] like `self` but with the given file name.
///
- /// See `PathBuf::set_file_name` for more details.
+ /// See [`PathBuf::set_file_name`] for more details.
+ ///
+ /// [`PathBuf`]: struct.PathBuf.html
+ /// [`PathBuf::set_file_name`]: struct.PathBuf.html#method.set_file_name
///
/// # Examples
///
@@ -1721,9 +1824,12 @@ impl Path {
buf
}
- /// Creates an owned `PathBuf` like `self` but with the given extension.
+ /// Creates an owned [`PathBuf`] like `self` but with the given extension.
+ ///
+ /// See [`PathBuf::set_extension`] for more details.
///
- /// See `PathBuf::set_extension` for more details.
+ /// [`PathBuf`]: struct.PathBuf.html
+ /// [`PathBuf::set_extension`]: struct.PathBuf.html#method.set_extension
///
/// # Examples
///
@@ -1771,7 +1877,9 @@ impl Path {
}
}
- /// Produce an iterator over the path's components viewed as `OsStr` slices.
+ /// Produce an iterator over the path's components viewed as [`OsStr`] slices.
+ ///
+ /// [`OsStr`]: ffi/struct.OsStr.html
///
/// # Examples
///
@@ -1790,9 +1898,11 @@ impl Path {
Iter { inner: self.components() }
}
- /// Returns an object that implements `Display` for safely printing paths
+ /// Returns an object that implements [`Display`] for safely printing paths
/// that may contain non-Unicode data.
///
+ /// [`Display`]: fmt/trait.Display.html
+ ///
/// # Examples
///
/// ```
@@ -1854,11 +1964,13 @@ impl Path {
/// Returns an iterator over the entries within a directory.
///
- /// The iterator will yield instances of `io::Result`. New errors may
- /// be encountered after an iterator is initially constructed.
+ /// The iterator will yield instances of [`io::Result<`][`DirEntry`]`>`. New
+ /// errors may be encountered after an iterator is initially constructed.
///
/// This is an alias to [`fs::read_dir`].
///
+ /// [`io::Result<`]: ../io/type.Result.html
+ /// [`DirEntry`]: ../fs/struct.DirEntry.html
/// [`fs::read_dir`]: ../fs/fn.read_dir.html
#[stable(feature = "path_ext", since = "1.5.0")]
pub fn read_dir(&self) -> io::Result {
diff --git a/src/libstd/primitive_docs.rs b/src/libstd/primitive_docs.rs
index d31a593037622..2b92da6c684a4 100644
--- a/src/libstd/primitive_docs.rs
+++ b/src/libstd/primitive_docs.rs
@@ -27,7 +27,7 @@
/// assert!(!bool_val);
/// ```
///
-/// [`assert!`]: macro.assert!.html
+/// [`assert!`]: macro.assert.html
/// [`if`]: ../book/if.html
/// [`BitAnd`]: ops/trait.BitAnd.html
/// [`BitOr`]: ops/trait.BitOr.html
diff --git a/src/test/compile-fail/E0063.rs b/src/test/compile-fail/E0063.rs
index c94f807d807ca..c01cbccfc2bba 100644
--- a/src/test/compile-fail/E0063.rs
+++ b/src/test/compile-fail/E0063.rs
@@ -8,11 +8,47 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-struct Foo {
+// ignore-tidy-linelength
+
+struct SingleFoo {
+ x: i32
+}
+
+struct PluralFoo {
+ x: i32,
+ y: i32,
+ z: i32
+}
+
+struct TruncatedFoo {
+ a: i32,
+ b: i32,
x: i32,
- y: i32
+ y: i32,
+ z: i32
}
+struct TruncatedPluralFoo {
+ a: i32,
+ b: i32,
+ c: i32,
+ x: i32,
+ y: i32,
+ z: i32
+}
+
+
fn main() {
- let x = Foo { x: 0 }; //~ ERROR E0063
+ let w = SingleFoo { };
+ //~^ ERROR missing field `x` in initializer of `SingleFoo`
+ //~| NOTE missing `x`
+ let x = PluralFoo {x: 1};
+ //~^ ERROR missing fields `z`, `y` in initializer of `PluralFoo`
+ //~| NOTE missing `z`, `y`
+ let y = TruncatedFoo{x:1};
+ //~^ ERROR and 1 other field in initializer of `TruncatedFoo`
+ //~| NOTE and 1 other field
+ let z = TruncatedPluralFoo{x:1};
+ //~^ ERROR and 2 other fields in initializer of `TruncatedPluralFoo`
+ //~| NOTE and 2 other fields
}
diff --git a/src/test/compile-fail/E0084.rs b/src/test/compile-fail/E0084.rs
index c579101325f5d..c7c5662f1feda 100644
--- a/src/test/compile-fail/E0084.rs
+++ b/src/test/compile-fail/E0084.rs
@@ -9,7 +9,9 @@
// except according to those terms.
#[repr(i32)]
-enum Foo {} //~ ERROR E0084
+enum Foo {}
+//~^ ERROR E0084
+//~| unsupported enum representation
fn main() {
}
diff --git a/src/test/compile-fail/E0133.rs b/src/test/compile-fail/E0133.rs
index b8a4476fc5967..f60d9a5083f6f 100644
--- a/src/test/compile-fail/E0133.rs
+++ b/src/test/compile-fail/E0133.rs
@@ -13,5 +13,5 @@ unsafe fn f() { return; }
fn main() {
f();
//~^ ERROR E0133
- //~| NOTE unsafe call requires unsafe function or block
+ //~| NOTE call to unsafe function
}
diff --git a/src/test/compile-fail/E0232.rs b/src/test/compile-fail/E0232.rs
index efeb869d71fa5..ce4f4638dac59 100644
--- a/src/test/compile-fail/E0232.rs
+++ b/src/test/compile-fail/E0232.rs
@@ -10,7 +10,10 @@
#![feature(on_unimplemented)]
-#[rustc_on_unimplemented] //~ ERROR E0232
+#[rustc_on_unimplemented]
+//~^ ERROR E0232
+//~| NOTE attribute requires a value
+//~| NOTE eg `#[rustc_on_unimplemented = "foo"]`
trait Bar {}
fn main() {
diff --git a/src/test/compile-fail/E0395.rs b/src/test/compile-fail/E0395.rs
index 6ab66313a0472..98f08cd68c22d 100644
--- a/src/test/compile-fail/E0395.rs
+++ b/src/test/compile-fail/E0395.rs
@@ -12,6 +12,6 @@ static FOO: i32 = 42;
static BAR: i32 = 42;
static BAZ: bool = { (&FOO as *const i32) == (&BAR as *const i32) }; //~ ERROR E0395
-
+ //~| NOTE comparing raw pointers in static
fn main() {
}
diff --git a/src/test/compile-fail/E0396.rs b/src/test/compile-fail/E0396.rs
index 7f34acdfb9007..47080fb6e9ef7 100644
--- a/src/test/compile-fail/E0396.rs
+++ b/src/test/compile-fail/E0396.rs
@@ -11,6 +11,7 @@
const REG_ADDR: *const u8 = 0x5f3759df as *const u8;
const VALUE: u8 = unsafe { *REG_ADDR }; //~ ERROR E0396
+ //~| NOTE dereference of raw pointer in constant
fn main() {
}
diff --git a/src/test/compile-fail/E0441.rs b/src/test/compile-fail/E0441.rs
new file mode 100644
index 0000000000000..967ff64327235
--- /dev/null
+++ b/src/test/compile-fail/E0441.rs
@@ -0,0 +1,21 @@
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 or the MIT license
+// , at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(repr_simd)]
+#![feature(platform_intrinsics)]
+
+#[repr(simd)]
+struct i16x8(i16, i16, i16, i16, i16, i16, i16, i16);
+
+extern "platform-intrinsic" {
+ fn x86_mm_adds_ep16(x: i16x8, y: i16x8) -> i16x8; //~ ERROR E0441
+}
+
+fn main() {}
diff --git a/src/test/compile-fail/E0442.rs b/src/test/compile-fail/E0442.rs
new file mode 100644
index 0000000000000..ddd927054be1d
--- /dev/null
+++ b/src/test/compile-fail/E0442.rs
@@ -0,0 +1,29 @@
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 or the MIT license
+// , at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(repr_simd)]
+#![feature(platform_intrinsics)]
+
+#[repr(simd)]
+struct i8x16(i8, i8, i8, i8, i8, i8, i8, i8,
+ i8, i8, i8, i8, i8, i8, i8, i8);
+#[repr(simd)]
+struct i32x4(i32, i32, i32, i32);
+#[repr(simd)]
+struct i64x2(i64, i64);
+
+extern "platform-intrinsic" {
+ fn x86_mm_adds_epi16(x: i8x16, y: i32x4) -> i64x2;
+ //~^ ERROR E0442
+ //~| ERROR E0442
+ //~| ERROR E0442
+}
+
+fn main() {}
diff --git a/src/test/compile-fail/E0443.rs b/src/test/compile-fail/E0443.rs
new file mode 100644
index 0000000000000..24d1ee01dd46e
--- /dev/null
+++ b/src/test/compile-fail/E0443.rs
@@ -0,0 +1,23 @@
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 or the MIT license
+// , at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(repr_simd)]
+#![feature(platform_intrinsics)]
+
+#[repr(simd)]
+struct i16x8(i16, i16, i16, i16, i16, i16, i16, i16);
+#[repr(simd)]
+struct i64x8(i64, i64, i64, i64, i64, i64, i64, i64);
+
+extern "platform-intrinsic" {
+ fn x86_mm_adds_epi16(x: i16x8, y: i16x8) -> i64x8; //~ ERROR E0443
+}
+
+fn main() {}
diff --git a/src/test/compile-fail/E0444.rs b/src/test/compile-fail/E0444.rs
new file mode 100644
index 0000000000000..a424a3ca20ec0
--- /dev/null
+++ b/src/test/compile-fail/E0444.rs
@@ -0,0 +1,21 @@
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 or the MIT license
+// , at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(repr_simd)]
+#![feature(platform_intrinsics)]
+
+#[repr(simd)]
+struct f64x2(f64, f64);
+
+extern "platform-intrinsic" {
+ fn x86_mm_movemask_pd(x: f64x2, y: f64x2, z: f64x2) -> i32; //~ ERROR E0444
+}
+
+fn main() {}
diff --git a/src/test/compile-fail/E0445.rs b/src/test/compile-fail/E0445.rs
new file mode 100644
index 0000000000000..6b360c60a0f90
--- /dev/null
+++ b/src/test/compile-fail/E0445.rs
@@ -0,0 +1,19 @@
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 or the MIT license
+// , at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+trait Foo {
+ fn dummy(&self) { }
+}
+
+pub trait Bar : Foo {} //~ ERROR E0445
+pub struct Bar2(pub T); //~ ERROR E0445
+pub fn foo (t: T) {} //~ ERROR E0445
+
+fn main() {}
diff --git a/src/test/compile-fail/E0446.rs b/src/test/compile-fail/E0446.rs
new file mode 100644
index 0000000000000..c576661828471
--- /dev/null
+++ b/src/test/compile-fail/E0446.rs
@@ -0,0 +1,19 @@
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 or the MIT license
+// , at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+mod Foo {
+ struct Bar(u32);
+
+ pub fn bar() -> Bar { //~ ERROR E0446
+ Bar(0)
+ }
+}
+
+fn main() {}
diff --git a/src/test/compile-fail/E0449.rs b/src/test/compile-fail/E0449.rs
new file mode 100644
index 0000000000000..ac365db33e5cd
--- /dev/null
+++ b/src/test/compile-fail/E0449.rs
@@ -0,0 +1,24 @@
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 or the MIT license
+// , at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+struct Bar;
+
+trait Foo {
+ fn foo();
+}
+
+pub impl Bar {} //~ ERROR E0449
+
+pub impl Foo for Bar { //~ ERROR E0449
+ pub fn foo() {} //~ ERROR E0449
+}
+
+fn main() {
+}
diff --git a/src/test/compile-fail/E0450.rs b/src/test/compile-fail/E0450.rs
new file mode 100644
index 0000000000000..3d76cb9377316
--- /dev/null
+++ b/src/test/compile-fail/E0450.rs
@@ -0,0 +1,17 @@
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 or the MIT license
+// , at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+mod Bar {
+ pub struct Foo(isize);
+}
+
+fn main() {
+ let f = Bar::Foo(0); //~ ERROR E0450
+}
diff --git a/src/test/compile-fail/E0451.rs b/src/test/compile-fail/E0451.rs
new file mode 100644
index 0000000000000..9e4a8713a33e0
--- /dev/null
+++ b/src/test/compile-fail/E0451.rs
@@ -0,0 +1,20 @@
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 or the MIT license
+// , at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+mod Bar {
+ pub struct Foo {
+ pub a: isize,
+ b: isize,
+ }
+}
+
+fn main() {
+ let f = Bar::Foo{ a: 0, b: 0 }; //~ ERROR E0451
+}
diff --git a/src/test/compile-fail/E0452.rs b/src/test/compile-fail/E0452.rs
new file mode 100644
index 0000000000000..1665bbdd4c2c1
--- /dev/null
+++ b/src/test/compile-fail/E0452.rs
@@ -0,0 +1,14 @@
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 or the MIT license
+// , at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![allow(foo = "")] //~ ERROR E0452
+
+fn main() {
+}
diff --git a/src/test/compile-fail/E0453.rs b/src/test/compile-fail/E0453.rs
new file mode 100644
index 0000000000000..629b373cd7f12
--- /dev/null
+++ b/src/test/compile-fail/E0453.rs
@@ -0,0 +1,15 @@
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 or the MIT license
+// , at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![forbid(non_snake_case)]
+
+#[allow(non_snake_case)] //~ ERROR E0453
+fn main() {
+}
diff --git a/src/test/compile-fail/E0454.rs b/src/test/compile-fail/E0454.rs
new file mode 100644
index 0000000000000..1439c3133d9ca
--- /dev/null
+++ b/src/test/compile-fail/E0454.rs
@@ -0,0 +1,14 @@
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 or the MIT license
+// , at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#[link(name = "")] extern {} //~ ERROR E0454
+
+fn main() {
+}
diff --git a/src/test/compile-fail/E0455.rs b/src/test/compile-fail/E0455.rs
new file mode 100644
index 0000000000000..a90f97f89f490
--- /dev/null
+++ b/src/test/compile-fail/E0455.rs
@@ -0,0 +1,14 @@
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 or the MIT license
+// , at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#[link(name = "FooCoreServices", kind = "framework")] extern {} //~ ERROR E0455
+
+fn main() {
+}
diff --git a/src/test/compile-fail/E0458.rs b/src/test/compile-fail/E0458.rs
new file mode 100644
index 0000000000000..21bedc6b84c2b
--- /dev/null
+++ b/src/test/compile-fail/E0458.rs
@@ -0,0 +1,15 @@
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 or the MIT license
+// , at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#[link(kind = "wonderful_unicorn")] extern {} //~ ERROR E0458
+ //~^ ERROR E0459
+
+fn main() {
+}
diff --git a/src/test/compile-fail/E0459.rs b/src/test/compile-fail/E0459.rs
new file mode 100644
index 0000000000000..dc7ac714f2239
--- /dev/null
+++ b/src/test/compile-fail/E0459.rs
@@ -0,0 +1,14 @@
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 or the MIT license
+// , at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#[link(kind = "dylib")] extern {} //~ ERROR E0459
+
+fn main() {
+}
diff --git a/src/test/compile-fail/E0463.rs b/src/test/compile-fail/E0463.rs
new file mode 100644
index 0000000000000..3eff107365af1
--- /dev/null
+++ b/src/test/compile-fail/E0463.rs
@@ -0,0 +1,16 @@
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 or the MIT license
+// , at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(plugin)]
+#![plugin(cookie_monster)] //~ ERROR E0463
+extern crate cake_is_a_lie;
+
+fn main() {
+}
diff --git a/src/test/compile-fail/const-deref-ptr.rs b/src/test/compile-fail/const-deref-ptr.rs
index fa15f3e87c694..c626801d48c03 100644
--- a/src/test/compile-fail/const-deref-ptr.rs
+++ b/src/test/compile-fail/const-deref-ptr.rs
@@ -12,5 +12,6 @@
fn main() {
static C: u64 = unsafe {*(0xdeadbeef as *const u64)}; //~ ERROR E0396
+ //~| NOTE dereference of raw pointer in constant
println!("{}", C);
}
diff --git a/src/test/compile-fail/issue-25826.rs b/src/test/compile-fail/issue-25826.rs
index 00e1279d58a0e..468282fa7cca9 100644
--- a/src/test/compile-fail/issue-25826.rs
+++ b/src/test/compile-fail/issue-25826.rs
@@ -12,5 +12,6 @@ fn id(t: T) -> T { t }
fn main() {
const A: bool = id:: as *const () < id:: as *const ();
//~^ ERROR raw pointers cannot be compared in constants [E0395]
+ //~^^ NOTE comparing raw pointers in static
println!("{}", A);
}
diff --git a/src/test/compile-fail/issue-28776.rs b/src/test/compile-fail/issue-28776.rs
index 52b0eba96cbdf..4a36bc88fa7d9 100644
--- a/src/test/compile-fail/issue-28776.rs
+++ b/src/test/compile-fail/issue-28776.rs
@@ -13,5 +13,5 @@ use std::ptr;
fn main() {
(&ptr::write)(1 as *mut _, 42);
//~^ ERROR E0133
- //~| NOTE unsafe call requires unsafe function or block
+ //~| NOTE call to unsafe function
}
diff --git a/src/test/compile-fail/trait-safety-fn-body.rs b/src/test/compile-fail/trait-safety-fn-body.rs
index 0df7ee8cabed2..65732a8ff69e5 100644
--- a/src/test/compile-fail/trait-safety-fn-body.rs
+++ b/src/test/compile-fail/trait-safety-fn-body.rs
@@ -20,7 +20,7 @@ unsafe impl UnsafeTrait for *mut isize {
// Unsafe actions are not made legal by taking place in an unsafe trait:
*self += 1;
//~^ ERROR E0133
- //~| NOTE unsafe call requires unsafe function or block
+ //~| NOTE dereference of raw pointer
}
}
diff --git a/src/test/compile-fail/unsafe-const-fn.rs b/src/test/compile-fail/unsafe-const-fn.rs
index 174939b09009c..91e16592be472 100644
--- a/src/test/compile-fail/unsafe-const-fn.rs
+++ b/src/test/compile-fail/unsafe-const-fn.rs
@@ -18,7 +18,7 @@ const unsafe fn dummy(v: u32) -> u32 {
const VAL: u32 = dummy(0xFFFF);
//~^ ERROR E0133
-//~| NOTE unsafe call requires unsafe function or block
+//~| NOTE call to unsafe function
fn main() {
assert_eq!(VAL, 0xFFFF0000);
diff --git a/src/test/rustdoc/issue-26606.rs b/src/test/rustdoc/issue-26606.rs
index df40c01686dcc..12de76654512d 100644
--- a/src/test/rustdoc/issue-26606.rs
+++ b/src/test/rustdoc/issue-26606.rs
@@ -12,7 +12,7 @@
// ignore-cross-compile
// build-aux-docs
-// @has issue_26606_macro/macro.make_item!.html
+// @has issue_26606_macro/macro.make_item.html
#[macro_use]
extern crate issue_26606_macro;
diff --git a/src/test/rustdoc/macros.rs b/src/test/rustdoc/macros.rs
index b052ad2da2fa9..9aeeb71707c90 100644
--- a/src/test/rustdoc/macros.rs
+++ b/src/test/rustdoc/macros.rs
@@ -8,10 +8,12 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-// @has macros/macro.my_macro!.html //pre 'macro_rules! my_macro {'
+// @has macros/macro.my_macro.html //pre 'macro_rules! my_macro {'
// @has - //pre '() => { ... };'
// @has - //pre '($a:tt) => { ... };'
// @has - //pre '($e:expr) => { ... };'
+// @has macros/macro.my_macro!.html
+// @has - //a 'macro.my_macro.html'
#[macro_export]
macro_rules! my_macro {
() => [];
diff --git a/src/tools/linkchecker/Cargo.lock b/src/tools/linkchecker/Cargo.lock
index ed5fe081ffb2e..d71df6d3f83a8 100644
--- a/src/tools/linkchecker/Cargo.lock
+++ b/src/tools/linkchecker/Cargo.lock
@@ -42,3 +42,9 @@ dependencies = [
"matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
+[metadata]
+"checksum idna 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1053236e00ce4f668aeca4a769a09b3bf5a682d802abd6f3cb39374f6b162c11"
+"checksum matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "15305656809ce5a4805b1ff2946892810992197ce1270ff79baded852187942e"
+"checksum unicode-bidi 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c1f7ceb96afdfeedee42bade65a0d585a6a0106f681b6749c8ff4daa8df30b3f"
+"checksum unicode-normalization 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "26643a2f83bac55f1976fb716c10234485f9202dcd65cfbdf9da49867b271172"
+"checksum url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "afe9ec54bc4db14bc8744b7fed060d785ac756791450959b2248443319d5b119"