Auto merge of #47209 - eddyb:ccx, r=nikomatsakis
rustc_trans: reorganize CrateContext and rename context types.
Firstly, the `{Shared,Local}CrateContext` hasn't been meaningful for a while now, and this PR resolves it by moving all their fields to `CrateContext` and removing redundant accessor methods.
Secondly, this PR contains the following mass-renames:
* `ccx: CrateContext` -> `cx: CodegenCx`
* `mircx: MirContext` -> `fx: FunctionCx`
* `bcx: Builder` -> `bx: Builder`
r? @nikomatsakis
diff --git a/.gitmodules b/.gitmodules
index 373ca90..ffa7b32 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -48,3 +48,6 @@
[submodule "src/binaryen"]
path = src/binaryen
url = https://github.com/alexcrichton/binaryen.git
+[submodule "src/doc/rust-by-example"]
+ path = src/doc/rust-by-example
+ url = https://github.com/rust-lang/rust-by-example
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs
index a660b5c..8e35ecc 100644
--- a/src/bootstrap/builder.rs
+++ b/src/bootstrap/builder.rs
@@ -258,7 +258,7 @@
Kind::Bench => describe!(check::Crate, check::CrateLibrustc),
Kind::Doc => describe!(doc::UnstableBook, doc::UnstableBookGen, doc::TheBook,
doc::Standalone, doc::Std, doc::Test, doc::Rustc, doc::ErrorIndex, doc::Nomicon,
- doc::Reference, doc::Rustdoc, doc::CargoBook),
+ doc::Reference, doc::Rustdoc, doc::RustByExample, doc::CargoBook),
Kind::Dist => describe!(dist::Docs, dist::Mingw, dist::Rustc, dist::DebuggerScripts,
dist::Std, dist::Analysis, dist::Src, dist::PlainSourceTarball, dist::Cargo,
dist::Rls, dist::Rustfmt, dist::Extended, dist::HashSign,
diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs
index 178d60d..d66c01e 100644
--- a/src/bootstrap/doc.rs
+++ b/src/bootstrap/doc.rs
@@ -12,7 +12,7 @@
//!
//! This module implements generation for all bits and pieces of documentation
//! for the Rust project. This notably includes suites like the rust book, the
-//! nomicon, standalone documentation, etc.
+//! nomicon, rust by example, standalone documentation, etc.
//!
//! Everything here is basically just a shim around calling either `rustbook` or
//! `rustdoc`.
@@ -69,6 +69,7 @@
Nomicon, "src/doc/nomicon", "nomicon";
Reference, "src/doc/reference", "reference";
Rustdoc, "src/doc/rustdoc", "rustdoc";
+ RustByExample, "src/doc/rust-by-example", "rust-by-example";
);
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
diff --git a/src/doc/rust-by-example b/src/doc/rust-by-example
new file mode 160000
index 0000000..4ebb816
--- /dev/null
+++ b/src/doc/rust-by-example
@@ -0,0 +1 @@
+Subproject commit 4ebb8169dfe569b3dcbeab560607800bb717978a
diff --git a/src/doc/unstable-book/src/language-features/crate_in_paths.md b/src/doc/unstable-book/src/language-features/crate-in-paths.md
similarity index 100%
rename from src/doc/unstable-book/src/language-features/crate_in_paths.md
rename to src/doc/unstable-book/src/language-features/crate-in-paths.md
diff --git a/src/doc/unstable-book/src/language-features/extern_absolute_paths.md b/src/doc/unstable-book/src/language-features/extern-absolute-paths.md
similarity index 100%
rename from src/doc/unstable-book/src/language-features/extern_absolute_paths.md
rename to src/doc/unstable-book/src/language-features/extern-absolute-paths.md
diff --git a/src/doc/unstable-book/src/language-features/extern_in_paths.md b/src/doc/unstable-book/src/language-features/extern-in-paths.md
similarity index 100%
rename from src/doc/unstable-book/src/language-features/extern_in_paths.md
rename to src/doc/unstable-book/src/language-features/extern-in-paths.md
diff --git a/src/doc/unstable-book/src/language-features/match_default_bindings.md b/src/doc/unstable-book/src/language-features/match-default-bindings.md
similarity index 100%
rename from src/doc/unstable-book/src/language-features/match_default_bindings.md
rename to src/doc/unstable-book/src/language-features/match-default-bindings.md
diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs
index 3cc3ea4..d8ce286 100644
--- a/src/liballoc/lib.rs
+++ b/src/liballoc/lib.rs
@@ -124,6 +124,7 @@
#![feature(unsize)]
#![feature(allocator_internals)]
#![feature(on_unimplemented)]
+#![feature(exact_chunks)]
#![cfg_attr(not(test), feature(fused, fn_traits, placement_new_protocol, swap_with_slice, i128))]
#![cfg_attr(test, feature(test, box_heap))]
diff --git a/src/liballoc/slice.rs b/src/liballoc/slice.rs
index 2c7bdc4..861f72b 100644
--- a/src/liballoc/slice.rs
+++ b/src/liballoc/slice.rs
@@ -123,6 +123,8 @@
pub use core::slice::{from_ref, from_ref_mut};
#[unstable(feature = "slice_get_slice", issue = "35729")]
pub use core::slice::SliceIndex;
+#[unstable(feature = "exact_chunks", issue = "47115")]
+pub use core::slice::{ExactChunks, ExactChunksMut};
////////////////////////////////////////////////////////////////////////////////
// Basic slice extension methods
@@ -611,6 +613,9 @@
/// not divide the length of the slice, then the last chunk will
/// not have length `chunk_size`.
///
+ /// See [`exact_chunks`] for a variant of this iterator that returns chunks
+ /// of always exactly `chunk_size` elements.
+ ///
/// # Panics
///
/// Panics if `chunk_size` is 0.
@@ -631,11 +636,44 @@
core_slice::SliceExt::chunks(self, chunk_size)
}
+ /// Returns an iterator over `chunk_size` elements of the slice at a
+ /// time. The chunks are slices and do not overlap. If `chunk_size` does
+ /// not divide the length of the slice, then the last up to `chunk_size-1`
+ /// elements will be omitted.
+ ///
+ /// Due to each chunk having exactly `chunk_size` elements, the compiler
+ /// can often optimize the resulting code better than in the case of
+ /// [`chunks`].
+ ///
+ /// # Panics
+ ///
+ /// Panics if `chunk_size` is 0.
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// #![feature(exact_chunks)]
+ ///
+ /// let slice = ['l', 'o', 'r', 'e', 'm'];
+ /// let mut iter = slice.exact_chunks(2);
+ /// assert_eq!(iter.next().unwrap(), &['l', 'o']);
+ /// assert_eq!(iter.next().unwrap(), &['r', 'e']);
+ /// assert!(iter.next().is_none());
+ /// ```
+ #[unstable(feature = "exact_chunks", issue = "47115")]
+ #[inline]
+ pub fn exact_chunks(&self, chunk_size: usize) -> ExactChunks<T> {
+ core_slice::SliceExt::exact_chunks(self, chunk_size)
+ }
+
/// Returns an iterator over `chunk_size` elements of the slice at a time.
/// The chunks are mutable slices, and do not overlap. If `chunk_size` does
/// not divide the length of the slice, then the last chunk will not
/// have length `chunk_size`.
///
+ /// See [`exact_chunks_mut`] for a variant of this iterator that returns chunks
+ /// of always exactly `chunk_size` elements.
+ ///
/// # Panics
///
/// Panics if `chunk_size` is 0.
@@ -660,6 +698,42 @@
core_slice::SliceExt::chunks_mut(self, chunk_size)
}
+ /// Returns an iterator over `chunk_size` elements of the slice at a time.
+ /// The chunks are mutable slices, and do not overlap. If `chunk_size` does
+ /// not divide the length of the slice, then the last up to `chunk_size-1`
+ /// elements will be omitted.
+ ///
+ ///
+ /// Due to each chunk having exactly `chunk_size` elements, the compiler
+ /// can often optimize the resulting code better than in the case of
+ /// [`chunks_mut`].
+ ///
+ /// # Panics
+ ///
+ /// Panics if `chunk_size` is 0.
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// #![feature(exact_chunks)]
+ ///
+ /// let v = &mut [0, 0, 0, 0, 0];
+ /// let mut count = 1;
+ ///
+ /// for chunk in v.exact_chunks_mut(2) {
+ /// for elem in chunk.iter_mut() {
+ /// *elem += count;
+ /// }
+ /// count += 1;
+ /// }
+ /// assert_eq!(v, &[1, 1, 2, 2, 0]);
+ /// ```
+ #[unstable(feature = "exact_chunks", issue = "47115")]
+ #[inline]
+ pub fn exact_chunks_mut(&mut self, chunk_size: usize) -> ExactChunksMut<T> {
+ core_slice::SliceExt::exact_chunks_mut(self, chunk_size)
+ }
+
/// Divides one slice into two at an index.
///
/// The first will contain all indices from `[0, mid)` (excluding
diff --git a/src/liballoc/tests/lib.rs b/src/liballoc/tests/lib.rs
index f1e9588..eee229b 100644
--- a/src/liballoc/tests/lib.rs
+++ b/src/liballoc/tests/lib.rs
@@ -30,6 +30,7 @@
#![feature(string_retain)]
#![feature(unboxed_closures)]
#![feature(unicode)]
+#![feature(exact_chunks)]
extern crate alloc_system;
extern crate std_unicode;
diff --git a/src/liballoc/tests/slice.rs b/src/liballoc/tests/slice.rs
index 49bdc9e..1a9d26f 100644
--- a/src/liballoc/tests/slice.rs
+++ b/src/liballoc/tests/slice.rs
@@ -946,6 +946,30 @@
}
#[test]
+fn test_exact_chunksator() {
+ let v = &[1, 2, 3, 4, 5];
+
+ assert_eq!(v.exact_chunks(2).len(), 2);
+
+ let chunks: &[&[_]] = &[&[1, 2], &[3, 4]];
+ assert_eq!(v.exact_chunks(2).collect::<Vec<_>>(), chunks);
+ let chunks: &[&[_]] = &[&[1, 2, 3]];
+ assert_eq!(v.exact_chunks(3).collect::<Vec<_>>(), chunks);
+ let chunks: &[&[_]] = &[];
+ assert_eq!(v.exact_chunks(6).collect::<Vec<_>>(), chunks);
+
+ let chunks: &[&[_]] = &[&[3, 4], &[1, 2]];
+ assert_eq!(v.exact_chunks(2).rev().collect::<Vec<_>>(), chunks);
+}
+
+#[test]
+#[should_panic]
+fn test_exact_chunksator_0() {
+ let v = &[1, 2, 3, 4];
+ let _it = v.exact_chunks(0);
+}
+
+#[test]
fn test_reverse_part() {
let mut values = [1, 2, 3, 4, 5];
values[1..4].reverse();
@@ -1159,7 +1183,7 @@
}
}
let result = [0, 0, 0, 1, 1, 1, 2];
- assert!(v == result);
+ assert_eq!(v, result);
}
#[test]
@@ -1171,7 +1195,7 @@
}
}
let result = [2, 2, 2, 1, 1, 1, 0];
- assert!(v == result);
+ assert_eq!(v, result);
}
#[test]
@@ -1182,6 +1206,38 @@
}
#[test]
+fn test_mut_exact_chunks() {
+ let mut v = [0, 1, 2, 3, 4, 5, 6];
+ assert_eq!(v.exact_chunks_mut(2).len(), 3);
+ for (i, chunk) in v.exact_chunks_mut(3).enumerate() {
+ for x in chunk {
+ *x = i as u8;
+ }
+ }
+ let result = [0, 0, 0, 1, 1, 1, 6];
+ assert_eq!(v, result);
+}
+
+#[test]
+fn test_mut_exact_chunks_rev() {
+ let mut v = [0, 1, 2, 3, 4, 5, 6];
+ for (i, chunk) in v.exact_chunks_mut(3).rev().enumerate() {
+ for x in chunk {
+ *x = i as u8;
+ }
+ }
+ let result = [1, 1, 1, 0, 0, 0, 6];
+ assert_eq!(v, result);
+}
+
+#[test]
+#[should_panic]
+fn test_mut_exact_chunks_0() {
+ let mut v = [1, 2, 3, 4];
+ let _it = v.exact_chunks_mut(0);
+}
+
+#[test]
fn test_mut_last() {
let mut x = [1, 2, 3, 4, 5];
let h = x.last_mut();
diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs
index e6b7931..48e8266 100644
--- a/src/libcore/slice/mod.rs
+++ b/src/libcore/slice/mod.rs
@@ -104,6 +104,9 @@
#[stable(feature = "core", since = "1.6.0")]
fn chunks(&self, size: usize) -> Chunks<Self::Item>;
+ #[unstable(feature = "exact_chunks", issue = "47115")]
+ fn exact_chunks(&self, size: usize) -> ExactChunks<Self::Item>;
+
#[stable(feature = "core", since = "1.6.0")]
fn get<I>(&self, index: I) -> Option<&I::Output>
where I: SliceIndex<Self>;
@@ -181,6 +184,9 @@
#[stable(feature = "core", since = "1.6.0")]
fn chunks_mut(&mut self, chunk_size: usize) -> ChunksMut<Self::Item>;
+ #[unstable(feature = "exact_chunks", issue = "47115")]
+ fn exact_chunks_mut(&mut self, size: usize) -> ExactChunksMut<Self::Item>;
+
#[stable(feature = "core", since = "1.6.0")]
fn swap(&mut self, a: usize, b: usize);
@@ -357,6 +363,14 @@
}
#[inline]
+ fn exact_chunks(&self, chunk_size: usize) -> ExactChunks<T> {
+ assert!(chunk_size != 0);
+ let rem = self.len() % chunk_size;
+ let len = self.len() - rem;
+ ExactChunks { v: &self[..len], chunk_size: chunk_size}
+ }
+
+ #[inline]
fn get<I>(&self, index: I) -> Option<&I::Output>
where I: SliceIndex<[T]>
{
@@ -540,6 +554,14 @@
}
#[inline]
+ fn exact_chunks_mut(&mut self, chunk_size: usize) -> ExactChunksMut<T> {
+ assert!(chunk_size != 0);
+ let rem = self.len() % chunk_size;
+ let len = self.len() - rem;
+ ExactChunksMut { v: &mut self[..len], chunk_size: chunk_size}
+ }
+
+ #[inline]
fn swap(&mut self, a: usize, b: usize) {
unsafe {
// Can't take two mutable loans from one vector, so instead just cast
@@ -2378,6 +2400,209 @@
fn may_have_side_effect() -> bool { false }
}
+/// An iterator over a slice in (non-overlapping) chunks (`chunk_size` elements at a
+/// time).
+///
+/// When the slice len is not evenly divided by the chunk size, the last
+/// up to `chunk_size-1` elements will be omitted.
+///
+/// This struct is created by the [`exact_chunks`] method on [slices].
+///
+/// [`exact_chunks`]: ../../std/primitive.slice.html#method.exact_chunks
+/// [slices]: ../../std/primitive.slice.html
+#[derive(Debug)]
+#[unstable(feature = "exact_chunks", issue = "47115")]
+pub struct ExactChunks<'a, T:'a> {
+ v: &'a [T],
+ chunk_size: usize
+}
+
+// FIXME(#26925) Remove in favor of `#[derive(Clone)]`
+#[unstable(feature = "exact_chunks", issue = "47115")]
+impl<'a, T> Clone for ExactChunks<'a, T> {
+ fn clone(&self) -> ExactChunks<'a, T> {
+ ExactChunks {
+ v: self.v,
+ chunk_size: self.chunk_size,
+ }
+ }
+}
+
+#[unstable(feature = "exact_chunks", issue = "47115")]
+impl<'a, T> Iterator for ExactChunks<'a, T> {
+ type Item = &'a [T];
+
+ #[inline]
+ fn next(&mut self) -> Option<&'a [T]> {
+ if self.v.len() < self.chunk_size {
+ None
+ } else {
+ let (fst, snd) = self.v.split_at(self.chunk_size);
+ self.v = snd;
+ Some(fst)
+ }
+ }
+
+ #[inline]
+ fn size_hint(&self) -> (usize, Option<usize>) {
+ let n = self.v.len() / self.chunk_size;
+ (n, Some(n))
+ }
+
+ #[inline]
+ fn count(self) -> usize {
+ self.len()
+ }
+
+ #[inline]
+ fn nth(&mut self, n: usize) -> Option<Self::Item> {
+ let (start, overflow) = n.overflowing_mul(self.chunk_size);
+ if start >= self.v.len() || overflow {
+ self.v = &[];
+ None
+ } else {
+ let (_, snd) = self.v.split_at(start);
+ self.v = snd;
+ self.next()
+ }
+ }
+
+ #[inline]
+ fn last(mut self) -> Option<Self::Item> {
+ self.next_back()
+ }
+}
+
+#[unstable(feature = "exact_chunks", issue = "47115")]
+impl<'a, T> DoubleEndedIterator for ExactChunks<'a, T> {
+ #[inline]
+ fn next_back(&mut self) -> Option<&'a [T]> {
+ if self.v.len() < self.chunk_size {
+ None
+ } else {
+ let (fst, snd) = self.v.split_at(self.v.len() - self.chunk_size);
+ self.v = fst;
+ Some(snd)
+ }
+ }
+}
+
+#[unstable(feature = "exact_chunks", issue = "47115")]
+impl<'a, T> ExactSizeIterator for ExactChunks<'a, T> {
+ fn is_empty(&self) -> bool {
+ self.v.is_empty()
+ }
+}
+
+#[unstable(feature = "fused", issue = "35602")]
+impl<'a, T> FusedIterator for ExactChunks<'a, T> {}
+
+#[doc(hidden)]
+unsafe impl<'a, T> TrustedRandomAccess for ExactChunks<'a, T> {
+ unsafe fn get_unchecked(&mut self, i: usize) -> &'a [T] {
+ let start = i * self.chunk_size;
+ from_raw_parts(self.v.as_ptr().offset(start as isize), self.chunk_size)
+ }
+ fn may_have_side_effect() -> bool { false }
+}
+
+/// An iterator over a slice in (non-overlapping) mutable chunks (`chunk_size`
+/// elements at a time). When the slice len is not evenly divided by the chunk
+/// size, the last up to `chunk_size-1` elements will be omitted.
+///
+/// This struct is created by the [`exact_chunks_mut`] method on [slices].
+///
+/// [`exact_chunks_mut`]: ../../std/primitive.slice.html#method.exact_chunks_mut
+/// [slices]: ../../std/primitive.slice.html
+#[derive(Debug)]
+#[unstable(feature = "exact_chunks", issue = "47115")]
+pub struct ExactChunksMut<'a, T:'a> {
+ v: &'a mut [T],
+ chunk_size: usize
+}
+
+#[unstable(feature = "exact_chunks", issue = "47115")]
+impl<'a, T> Iterator for ExactChunksMut<'a, T> {
+ type Item = &'a mut [T];
+
+ #[inline]
+ fn next(&mut self) -> Option<&'a mut [T]> {
+ if self.v.len() < self.chunk_size {
+ None
+ } else {
+ let tmp = mem::replace(&mut self.v, &mut []);
+ let (head, tail) = tmp.split_at_mut(self.chunk_size);
+ self.v = tail;
+ Some(head)
+ }
+ }
+
+ #[inline]
+ fn size_hint(&self) -> (usize, Option<usize>) {
+ let n = self.v.len() / self.chunk_size;
+ (n, Some(n))
+ }
+
+ #[inline]
+ fn count(self) -> usize {
+ self.len()
+ }
+
+ #[inline]
+ fn nth(&mut self, n: usize) -> Option<&'a mut [T]> {
+ let (start, overflow) = n.overflowing_mul(self.chunk_size);
+ if start >= self.v.len() || overflow {
+ self.v = &mut [];
+ None
+ } else {
+ let tmp = mem::replace(&mut self.v, &mut []);
+ let (_, snd) = tmp.split_at_mut(start);
+ self.v = snd;
+ self.next()
+ }
+ }
+
+ #[inline]
+ fn last(mut self) -> Option<Self::Item> {
+ self.next_back()
+ }
+}
+
+#[unstable(feature = "exact_chunks", issue = "47115")]
+impl<'a, T> DoubleEndedIterator for ExactChunksMut<'a, T> {
+ #[inline]
+ fn next_back(&mut self) -> Option<&'a mut [T]> {
+ if self.v.len() < self.chunk_size {
+ None
+ } else {
+ let tmp = mem::replace(&mut self.v, &mut []);
+ let tmp_len = tmp.len();
+ let (head, tail) = tmp.split_at_mut(tmp_len - self.chunk_size);
+ self.v = head;
+ Some(tail)
+ }
+ }
+}
+
+#[unstable(feature = "exact_chunks", issue = "47115")]
+impl<'a, T> ExactSizeIterator for ExactChunksMut<'a, T> {
+ fn is_empty(&self) -> bool {
+ self.v.is_empty()
+ }
+}
+
+#[unstable(feature = "fused", issue = "35602")]
+impl<'a, T> FusedIterator for ExactChunksMut<'a, T> {}
+
+#[doc(hidden)]
+unsafe impl<'a, T> TrustedRandomAccess for ExactChunksMut<'a, T> {
+ unsafe fn get_unchecked(&mut self, i: usize) -> &'a mut [T] {
+ let start = i * self.chunk_size;
+ from_raw_parts_mut(self.v.as_mut_ptr().offset(start as isize), self.chunk_size)
+ }
+ fn may_have_side_effect() -> bool { false }
+}
+
//
// Free functions
//
diff --git a/src/libcore/tests/lib.rs b/src/libcore/tests/lib.rs
index c4b85b8..2c00095 100644
--- a/src/libcore/tests/lib.rs
+++ b/src/libcore/tests/lib.rs
@@ -42,6 +42,7 @@
#![feature(try_from)]
#![feature(try_trait)]
#![feature(unique)]
+#![feature(exact_chunks)]
extern crate core;
extern crate test;
diff --git a/src/libcore/tests/slice.rs b/src/libcore/tests/slice.rs
index 40e5fe5..f7a4a71 100644
--- a/src/libcore/tests/slice.rs
+++ b/src/libcore/tests/slice.rs
@@ -117,12 +117,12 @@
fn test_chunks_nth() {
let v: &[i32] = &[0, 1, 2, 3, 4, 5];
let mut c = v.chunks(2);
- assert_eq!(c.nth(1).unwrap()[1], 3);
- assert_eq!(c.next().unwrap()[0], 4);
+ assert_eq!(c.nth(1).unwrap(), &[2, 3]);
+ assert_eq!(c.next().unwrap(), &[4, 5]);
let v2: &[i32] = &[0, 1, 2, 3, 4];
let mut c2 = v2.chunks(3);
- assert_eq!(c2.nth(1).unwrap()[1], 4);
+ assert_eq!(c2.nth(1).unwrap(), &[3, 4]);
assert_eq!(c2.next(), None);
}
@@ -168,12 +168,12 @@
fn test_chunks_mut_nth() {
let v: &mut [i32] = &mut [0, 1, 2, 3, 4, 5];
let mut c = v.chunks_mut(2);
- assert_eq!(c.nth(1).unwrap()[1], 3);
- assert_eq!(c.next().unwrap()[0], 4);
+ assert_eq!(c.nth(1).unwrap(), &[2, 3]);
+ assert_eq!(c.next().unwrap(), &[4, 5]);
let v2: &mut [i32] = &mut [0, 1, 2, 3, 4];
let mut c2 = v2.chunks_mut(3);
- assert_eq!(c2.nth(1).unwrap()[1], 4);
+ assert_eq!(c2.nth(1).unwrap(), &[3, 4]);
assert_eq!(c2.next(), None);
}
@@ -181,11 +181,11 @@
fn test_chunks_mut_last() {
let v: &mut [i32] = &mut [0, 1, 2, 3, 4, 5];
let c = v.chunks_mut(2);
- assert_eq!(c.last().unwrap()[1], 5);
+ assert_eq!(c.last().unwrap(), &[4, 5]);
let v2: &mut [i32] = &mut [0, 1, 2, 3, 4];
let c2 = v2.chunks_mut(2);
- assert_eq!(c2.last().unwrap()[0], 4);
+ assert_eq!(c2.last().unwrap(), &[4]);
}
#[test]
@@ -203,6 +203,110 @@
}
#[test]
+fn test_exact_chunks_count() {
+ let v: &[i32] = &[0, 1, 2, 3, 4, 5];
+ let c = v.exact_chunks(3);
+ assert_eq!(c.count(), 2);
+
+ let v2: &[i32] = &[0, 1, 2, 3, 4];
+ let c2 = v2.exact_chunks(2);
+ assert_eq!(c2.count(), 2);
+
+ let v3: &[i32] = &[];
+ let c3 = v3.exact_chunks(2);
+ assert_eq!(c3.count(), 0);
+}
+
+#[test]
+fn test_exact_chunks_nth() {
+ let v: &[i32] = &[0, 1, 2, 3, 4, 5];
+ let mut c = v.exact_chunks(2);
+ assert_eq!(c.nth(1).unwrap(), &[2, 3]);
+ assert_eq!(c.next().unwrap(), &[4, 5]);
+
+ let v2: &[i32] = &[0, 1, 2, 3, 4, 5, 6];
+ let mut c2 = v2.exact_chunks(3);
+ assert_eq!(c2.nth(1).unwrap(), &[3, 4, 5]);
+ assert_eq!(c2.next(), None);
+}
+
+#[test]
+fn test_exact_chunks_last() {
+ let v: &[i32] = &[0, 1, 2, 3, 4, 5];
+ let c = v.exact_chunks(2);
+ assert_eq!(c.last().unwrap(), &[4, 5]);
+
+ let v2: &[i32] = &[0, 1, 2, 3, 4];
+ let c2 = v2.exact_chunks(2);
+ assert_eq!(c2.last().unwrap(), &[2, 3]);
+}
+
+#[test]
+fn test_exact_chunks_zip() {
+ let v1: &[i32] = &[0, 1, 2, 3, 4];
+ let v2: &[i32] = &[6, 7, 8, 9, 10];
+
+ let res = v1.exact_chunks(2)
+ .zip(v2.exact_chunks(2))
+ .map(|(a, b)| a.iter().sum::<i32>() + b.iter().sum::<i32>())
+ .collect::<Vec<_>>();
+ assert_eq!(res, vec![14, 22]);
+}
+
+#[test]
+fn test_exact_chunks_mut_count() {
+ let v: &mut [i32] = &mut [0, 1, 2, 3, 4, 5];
+ let c = v.exact_chunks_mut(3);
+ assert_eq!(c.count(), 2);
+
+ let v2: &mut [i32] = &mut [0, 1, 2, 3, 4];
+ let c2 = v2.exact_chunks_mut(2);
+ assert_eq!(c2.count(), 2);
+
+ let v3: &mut [i32] = &mut [];
+ let c3 = v3.exact_chunks_mut(2);
+ assert_eq!(c3.count(), 0);
+}
+
+#[test]
+fn test_exact_chunks_mut_nth() {
+ let v: &mut [i32] = &mut [0, 1, 2, 3, 4, 5];
+ let mut c = v.exact_chunks_mut(2);
+ assert_eq!(c.nth(1).unwrap(), &[2, 3]);
+ assert_eq!(c.next().unwrap(), &[4, 5]);
+
+ let v2: &mut [i32] = &mut [0, 1, 2, 3, 4, 5, 6];
+ let mut c2 = v2.exact_chunks_mut(3);
+ assert_eq!(c2.nth(1).unwrap(), &[3, 4, 5]);
+ assert_eq!(c2.next(), None);
+}
+
+#[test]
+fn test_exact_chunks_mut_last() {
+ let v: &mut [i32] = &mut [0, 1, 2, 3, 4, 5];
+ let c = v.exact_chunks_mut(2);
+ assert_eq!(c.last().unwrap(), &[4, 5]);
+
+ let v2: &mut [i32] = &mut [0, 1, 2, 3, 4];
+ let c2 = v2.exact_chunks_mut(2);
+ assert_eq!(c2.last().unwrap(), &[2, 3]);
+}
+
+#[test]
+fn test_exact_chunks_mut_zip() {
+ let v1: &mut [i32] = &mut [0, 1, 2, 3, 4];
+ let v2: &[i32] = &[6, 7, 8, 9, 10];
+
+ for (a, b) in v1.exact_chunks_mut(2).zip(v2.exact_chunks(2)) {
+ let sum = b.iter().sum::<i32>();
+ for v in a {
+ *v += sum;
+ }
+ }
+ assert_eq!(v1, [13, 14, 19, 20, 4]);
+}
+
+#[test]
fn test_windows_count() {
let v: &[i32] = &[0, 1, 2, 3, 4, 5];
let c = v.windows(3);
diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs
index 84d4590..1af7bd4 100644
--- a/src/librustc/hir/lowering.rs
+++ b/src/librustc/hir/lowering.rs
@@ -1502,8 +1502,8 @@
fn_def_id: Option<DefId>,
impl_trait_return_allow: bool)
-> P<hir::FnDecl> {
- // NOTE: The two last paramters here have to do with impl Trait. If fn_def_id is Some,
- // then impl Trait arguments are lowered into generic paramters on the given
+ // NOTE: The two last parameters here have to do with impl Trait. If fn_def_id is Some,
+ // then impl Trait arguments are lowered into generic parameters on the given
// fn_def_id, otherwise impl Trait is disallowed. (for now)
//
// Furthermore, if impl_trait_return_allow is true, then impl Trait may be used in
diff --git a/src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs b/src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs
index 9d0ddfd..5617c77 100644
--- a/src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs
+++ b/src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs
@@ -118,4 +118,17 @@
.emit();
return Some(ErrorReported);
}
+
+ // This method returns whether the given Region is Named
+ pub(super) fn is_named_region(&self, region: ty::Region<'tcx>) -> bool {
+ match *region {
+ ty::ReStatic => true,
+ ty::ReFree(ref free_region) => match free_region.bound_region {
+ ty::BrNamed(..) => true,
+ _ => false,
+ },
+ ty::ReEarlyBound(_) => true,
+ _ => false,
+ }
+ }
}
diff --git a/src/librustc/infer/error_reporting/nice_region_error/util.rs b/src/librustc/infer/error_reporting/nice_region_error/util.rs
index f8b6f7d..8aadec6 100644
--- a/src/librustc/infer/error_reporting/nice_region_error/util.rs
+++ b/src/librustc/infer/error_reporting/nice_region_error/util.rs
@@ -198,16 +198,4 @@
}
false
}
-
- // This method returns whether the given Region is Named
- pub(super) fn is_named_region(&self, region: Region<'tcx>) -> bool {
- match *region {
- ty::ReFree(ref free_region) => match free_region.bound_region {
- ty::BrNamed(..) => true,
- _ => false,
- },
- ty::ReEarlyBound(_) => true,
- _ => false,
- }
- }
}
diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs
index 5811265..4529e4b 100644
--- a/src/librustc_borrowck/borrowck/mod.rs
+++ b/src/librustc_borrowck/borrowck/mod.rs
@@ -772,11 +772,12 @@
&move_data::Assignment) {
let mut err = self.cannot_reassign_immutable(span,
&self.loan_path_to_string(lp),
+ false,
Origin::Ast);
err.span_label(span, "cannot assign twice to immutable variable");
if span != assign.span {
err.span_label(assign.span, format!("first assignment to `{}`",
- self.loan_path_to_string(lp)));
+ self.loan_path_to_string(lp)));
}
err.emit();
}
diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs
index 73c1b69..33234ff 100644
--- a/src/librustc_driver/driver.rs
+++ b/src/librustc_driver/driver.rs
@@ -37,7 +37,7 @@
use rustc_privacy;
use rustc_plugin::registry::Registry;
use rustc_plugin as plugin;
-use rustc_passes::{self, ast_validation, no_asm, loops, consts, static_recursion, hir_stats};
+use rustc_passes::{self, ast_validation, loops, consts, static_recursion, hir_stats};
use rustc_const_eval::{self, check_match};
use super::Compilation;
use ::DefaultTransCrate;
@@ -853,10 +853,6 @@
}
time(time_passes,
- "checking for inline asm in case the target doesn't support it",
- || no_asm::check_crate(sess, &krate));
-
- time(time_passes,
"AST validation",
|| ast_validation::check_crate(sess, &krate));
diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs
index af556c5..1c3d4af 100644
--- a/src/librustc_errors/emitter.rs
+++ b/src/librustc_errors/emitter.rs
@@ -990,7 +990,7 @@
buffer.append(buffer_msg_line_offset,
&format!("{}:{}:{}",
loc.file.name,
- loc.line,
+ cm.doctest_offset_line(loc.line),
loc.col.0 + 1),
Style::LineAndColumn);
for _ in 0..max_line_num_len {
@@ -1000,7 +1000,7 @@
buffer.prepend(0,
&format!("{}:{}:{} - ",
loc.file.name,
- loc.line,
+ cm.doctest_offset_line(loc.line),
loc.col.0 + 1),
Style::LineAndColumn);
}
diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs
index c48f176..1fb6738 100644
--- a/src/librustc_errors/lib.rs
+++ b/src/librustc_errors/lib.rs
@@ -103,6 +103,7 @@
fn merge_spans(&self, sp_lhs: Span, sp_rhs: Span) -> Option<Span>;
fn call_span_if_macro(&self, sp: Span) -> Span;
fn ensure_filemap_source_present(&self, file_map: Rc<FileMap>) -> bool;
+ fn doctest_offset_line(&self, line: usize) -> usize;
}
impl CodeSuggestion {
diff --git a/src/librustc_metadata/native_libs.rs b/src/librustc_metadata/native_libs.rs
index cc332ac..c0ce32c 100644
--- a/src/librustc_metadata/native_libs.rs
+++ b/src/librustc_metadata/native_libs.rs
@@ -92,9 +92,19 @@
let cfg = items.iter().find(|k| {
k.check_name("cfg")
}).and_then(|a| a.meta_item_list());
- let cfg = cfg.map(|list| {
- list[0].meta_item().unwrap().clone()
- });
+ let cfg = if let Some(list) = cfg {
+ if list.is_empty() {
+ self.tcx.sess.span_err(m.span(), "`cfg()` must have an argument");
+ return;
+ } else if let cfg @ Some(..) = list[0].meta_item() {
+ cfg.cloned()
+ } else {
+ self.tcx.sess.span_err(list[0].span(), "invalid argument for `cfg(..)`");
+ return;
+ }
+ } else {
+ None
+ };
let foreign_items = fm.items.iter()
.map(|it| self.tcx.hir.local_def_id(it.id))
.collect();
diff --git a/src/librustc_mir/borrow_check/error_reporting.rs b/src/librustc_mir/borrow_check/error_reporting.rs
index b65452f..520febc 100644
--- a/src/librustc_mir/borrow_check/error_reporting.rs
+++ b/src/librustc_mir/borrow_check/error_reporting.rs
@@ -10,7 +10,7 @@
use syntax_pos::Span;
use rustc::middle::region::ScopeTree;
-use rustc::mir::{BorrowKind, Field, Local, Location, Operand};
+use rustc::mir::{BorrowKind, Field, Local, LocalKind, Location, Operand};
use rustc::mir::{Place, ProjectionElem, Rvalue, Statement, StatementKind};
use rustc::ty::{self, RegionKind};
use rustc_data_structures::indexed_vec::Idx;
@@ -568,19 +568,39 @@
(place, span): (&Place<'tcx>, Span),
assigned_span: Span,
) {
+ let is_arg = if let Place::Local(local) = place {
+ if let LocalKind::Arg = self.mir.local_kind(*local) {
+ true
+ } else {
+ false
+ }
+ } else {
+ false
+ };
+
let mut err = self.tcx.cannot_reassign_immutable(
span,
&self.describe_place(place).unwrap_or("_".to_owned()),
+ is_arg,
Origin::Mir,
);
- err.span_label(span, "cannot assign twice to immutable variable");
+ let msg = if is_arg {
+ "cannot assign to immutable argument"
+ } else {
+ "cannot assign twice to immutable variable"
+ };
if span != assigned_span {
- let value_msg = match self.describe_place(place) {
- Some(name) => format!("`{}`", name),
- None => "value".to_owned(),
- };
- err.span_label(assigned_span, format!("first assignment to {}", value_msg));
+ if is_arg {
+ err.span_label(assigned_span, "argument not declared as `mut`");
+ } else {
+ let value_msg = match self.describe_place(place) {
+ Some(name) => format!("`{}`", name),
+ None => "value".to_owned(),
+ };
+ err.span_label(assigned_span, format!("first assignment to {}", value_msg));
+ }
}
+ err.span_label(span, msg);
err.emit();
}
}
diff --git a/src/librustc_mir/borrow_check/nll/type_check/liveness.rs b/src/librustc_mir/borrow_check/nll/type_check/liveness.rs
index 50b38f9..8a0578a 100644
--- a/src/librustc_mir/borrow_check/nll/type_check/liveness.rs
+++ b/src/librustc_mir/borrow_check/nll/type_check/liveness.rs
@@ -214,6 +214,7 @@
// associated types here and possibly recursively process.
for ty in dtorck_types {
let ty = self.cx.normalize(&ty, location);
+ let ty = self.cx.infcx.resolve_type_and_region_vars_if_possible(&ty);
match ty.sty {
ty::TyParam(..) | ty::TyProjection(..) | ty::TyAnon(..) => {
let cause = Cause::DropVar(dropped_local, location);
diff --git a/src/librustc_mir/util/borrowck_errors.rs b/src/librustc_mir/util/borrowck_errors.rs
index 38227bd..4a7ee39 100644
--- a/src/librustc_mir/util/borrowck_errors.rs
+++ b/src/librustc_mir/util/borrowck_errors.rs
@@ -269,12 +269,17 @@
self.cancel_if_wrong_origin(err, o)
}
- fn cannot_reassign_immutable(&self, span: Span, desc: &str, o: Origin)
+ fn cannot_reassign_immutable(&self, span: Span, desc: &str, is_arg: bool, o: Origin)
-> DiagnosticBuilder
{
+ let msg = if is_arg {
+ "to immutable argument"
+ } else {
+ "twice to immutable variable"
+ };
let err = struct_span_err!(self, span, E0384,
- "cannot assign twice to immutable variable `{}`{OGN}",
- desc, OGN=o);
+ "cannot assign {} `{}`{OGN}",
+ msg, desc, OGN=o);
self.cancel_if_wrong_origin(err, o)
}
diff --git a/src/librustc_passes/ast_validation.rs b/src/librustc_passes/ast_validation.rs
index c41591b..3f49128 100644
--- a/src/librustc_passes/ast_validation.rs
+++ b/src/librustc_passes/ast_validation.rs
@@ -149,6 +149,9 @@
ExprKind::Continue(Some(ident)) => {
self.check_label(ident.node, ident.span);
}
+ ExprKind::InlineAsm(..) if !self.session.target.target.options.allow_asm => {
+ span_err!(self.session, expr.span, E0472, "asm! is unsupported on this target");
+ }
_ => {}
}
@@ -215,13 +218,16 @@
fn visit_item(&mut self, item: &'a Item) {
match item.node {
- ItemKind::Impl(.., Some(..), ref ty, ref impl_items) => {
+ ItemKind::Impl(unsafety, polarity, _, _, Some(..), ref ty, ref impl_items) => {
self.invalid_visibility(&item.vis, item.span, None);
if ty.node == TyKind::Err {
self.err_handler()
.struct_span_err(item.span, "`impl Trait for .. {}` is an obsolete syntax")
.help("use `auto trait Trait {}` instead").emit();
}
+ if unsafety == Unsafety::Unsafe && polarity == ImplPolarity::Negative {
+ span_err!(self.session, item.span, E0198, "negative impls cannot be unsafe");
+ }
for impl_item in impl_items {
self.invalid_visibility(&impl_item.vis, impl_item.span, None);
if let ImplItemKind::Method(ref sig, _) = impl_item.node {
@@ -229,10 +235,19 @@
}
}
}
- ItemKind::Impl(.., None, _, _) => {
+ ItemKind::Impl(unsafety, polarity, defaultness, _, None, _, _) => {
self.invalid_visibility(&item.vis,
item.span,
Some("place qualifiers on individual impl items instead"));
+ if unsafety == Unsafety::Unsafe {
+ span_err!(self.session, item.span, E0197, "inherent impls cannot be unsafe");
+ }
+ if polarity == ImplPolarity::Negative {
+ self.err_handler().span_err(item.span, "inherent impls cannot be negative");
+ }
+ if defaultness == Defaultness::Default {
+ self.err_handler().span_err(item.span, "inherent impls cannot be default");
+ }
}
ItemKind::ForeignMod(..) => {
self.invalid_visibility(&item.vis,
diff --git a/src/librustc_passes/diagnostics.rs b/src/librustc_passes/diagnostics.rs
index cbfdace..743f7b7 100644
--- a/src/librustc_passes/diagnostics.rs
+++ b/src/librustc_passes/diagnostics.rs
@@ -82,6 +82,52 @@
```
"##,
+E0197: r##"
+Inherent implementations (one that do not implement a trait but provide
+methods associated with a type) are always safe because they are not
+implementing an unsafe trait. Removing the `unsafe` keyword from the inherent
+implementation will resolve this error.
+
+```compile_fail,E0197
+struct Foo;
+
+// this will cause this error
+unsafe impl Foo { }
+// converting it to this will fix it
+impl Foo { }
+```
+"##,
+
+E0198: r##"
+A negative implementation is one that excludes a type from implementing a
+particular trait. Not being able to use a trait is always a safe operation,
+so negative implementations are always safe and never need to be marked as
+unsafe.
+
+```compile_fail
+#![feature(optin_builtin_traits)]
+
+struct Foo;
+
+// unsafe is unnecessary
+unsafe impl !Clone for Foo { }
+```
+
+This will compile:
+
+```ignore (ignore auto_trait future compatibility warning)
+#![feature(optin_builtin_traits)]
+
+struct Foo;
+
+auto trait Enterprise {}
+
+impl !Enterprise for Foo { }
+```
+
+Please note that negative impls are only allowed for auto traits.
+"##,
+
E0265: r##"
This error indicates that a static or constant references itself.
All statics and constants need to resolve to a value in an acyclic manner.
diff --git a/src/librustc_passes/lib.rs b/src/librustc_passes/lib.rs
index 754c3bb..73c71ec 100644
--- a/src/librustc_passes/lib.rs
+++ b/src/librustc_passes/lib.rs
@@ -42,7 +42,6 @@
pub mod hir_stats;
pub mod loops;
mod mir_stats;
-pub mod no_asm;
pub mod static_recursion;
#[cfg(not(stage0))] // remove after the next snapshot
diff --git a/src/librustc_passes/no_asm.rs b/src/librustc_passes/no_asm.rs
deleted file mode 100644
index 4dbf57a..0000000
--- a/src/librustc_passes/no_asm.rs
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright 2015 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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-/// Run over the whole crate and check for ExprInlineAsm.
-/// Inline asm isn't allowed on virtual ISA based targets, so we reject it
-/// here.
-
-use rustc::session::Session;
-
-use syntax::ast;
-use syntax::visit::Visitor;
-use syntax::visit;
-
-pub fn check_crate(sess: &Session, krate: &ast::Crate) {
- if sess.target.target.options.allow_asm {
- return;
- }
-
- visit::walk_crate(&mut CheckNoAsm { sess: sess }, krate);
-}
-
-#[derive(Copy, Clone)]
-struct CheckNoAsm<'a> {
- sess: &'a Session,
-}
-
-impl<'a> Visitor<'a> for CheckNoAsm<'a> {
- fn visit_expr(&mut self, e: &'a ast::Expr) {
- match e.node {
- ast::ExprKind::InlineAsm(_) => {
- span_err!(self.sess,
- e.span,
- E0472,
- "asm! is unsupported on this target")
- }
- _ => {}
- }
- visit::walk_expr(self, e)
- }
-}
diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs
index 60d28fb..3668fc4 100644
--- a/src/librustc_typeck/check/wfcheck.rs
+++ b/src/librustc_typeck/check/wfcheck.rs
@@ -107,16 +107,21 @@
//
// won't be allowed unless there's an *explicit* implementation of `Send`
// for `T`
- hir::ItemImpl(_, hir::ImplPolarity::Positive, _, _,
- ref trait_ref, ref self_ty, _) => {
- self.check_impl(item, self_ty, trait_ref);
- }
- hir::ItemImpl(_, hir::ImplPolarity::Negative, _, _, Some(_), ..) => {
- // FIXME(#27579) what amount of WF checking do we need for neg impls?
-
- let trait_ref = tcx.impl_trait_ref(tcx.hir.local_def_id(item.id)).unwrap();
- if !tcx.trait_is_auto(trait_ref.def_id) {
- error_192(tcx, item.span);
+ hir::ItemImpl(_, polarity, defaultness, _, ref trait_ref, ref self_ty, _) => {
+ let is_auto = tcx.impl_trait_ref(tcx.hir.local_def_id(item.id))
+ .map_or(false, |trait_ref| tcx.trait_is_auto(trait_ref.def_id));
+ if let (hir::Defaultness::Default { .. }, true) = (defaultness, is_auto) {
+ tcx.sess.span_err(item.span, "impls of auto traits cannot be default");
+ }
+ if polarity == hir::ImplPolarity::Positive {
+ self.check_impl(item, self_ty, trait_ref);
+ } else {
+ // FIXME(#27579) what amount of WF checking do we need for neg impls?
+ if trait_ref.is_some() && !is_auto {
+ span_err!(tcx.sess, item.span, E0192,
+ "negative impls are only allowed for \
+ auto traits (e.g., `Send` and `Sync`)")
+ }
}
}
hir::ItemFn(..) => {
@@ -661,12 +666,6 @@
}
}
-fn error_192(tcx: TyCtxt, span: Span) {
- span_err!(tcx.sess, span, E0192,
- "negative impls are only allowed for traits with \
- default impls (e.g., `Send` and `Sync`)")
-}
-
fn error_392<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, span: Span, param_name: ast::Name)
-> DiagnosticBuilder<'tcx> {
let mut err = struct_span_err!(tcx.sess, span, E0392,
diff --git a/src/librustc_typeck/coherence/inherent_impls.rs b/src/librustc_typeck/coherence/inherent_impls.rs
index 4256a1f..2b81c82 100644
--- a/src/librustc_typeck/coherence/inherent_impls.rs
+++ b/src/librustc_typeck/coherence/inherent_impls.rs
@@ -93,23 +93,11 @@
impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentCollect<'a, 'tcx> {
fn visit_item(&mut self, item: &hir::Item) {
- let (unsafety, ty) = match item.node {
- hir::ItemImpl(unsafety, .., None, ref ty, _) => (unsafety, ty),
+ let ty = match item.node {
+ hir::ItemImpl(.., None, ref ty, _) => ty,
_ => return
};
- match unsafety {
- hir::Unsafety::Normal => {
- // OK
- }
- hir::Unsafety::Unsafe => {
- span_err!(self.tcx.sess,
- item.span,
- E0197,
- "inherent impls cannot be declared as unsafe");
- }
- }
-
let def_id = self.tcx.hir.local_def_id(item.id);
let self_ty = self.tcx.type_of(def_id);
let lang_items = self.tcx.lang_items();
diff --git a/src/librustc_typeck/coherence/orphan.rs b/src/librustc_typeck/coherence/orphan.rs
index ab19a86..c2dfd79 100644
--- a/src/librustc_typeck/coherence/orphan.rs
+++ b/src/librustc_typeck/coherence/orphan.rs
@@ -67,16 +67,15 @@
}
}
- // In addition to the above rules, we restrict impls of defaulted traits
+ // In addition to the above rules, we restrict impls of auto traits
// so that they can only be implemented on nominal types, such as structs,
// enums or foreign types. To see why this restriction exists, consider the
- // following example (#22978). Imagine that crate A defines a defaulted trait
+ // following example (#22978). Imagine that crate A defines an auto trait
// `Foo` and a fn that operates on pairs of types:
//
// ```
// // Crate A
- // trait Foo { }
- // impl Foo for .. { }
+ // auto trait Foo { }
// fn two_foos<A:Foo,B:Foo>(..) {
// one_foo::<(A,B)>(..)
// }
diff --git a/src/librustc_typeck/coherence/unsafety.rs b/src/librustc_typeck/coherence/unsafety.rs
index c924a33..4aa876e 100644
--- a/src/librustc_typeck/coherence/unsafety.rs
+++ b/src/librustc_typeck/coherence/unsafety.rs
@@ -37,14 +37,7 @@
let trait_def = self.tcx.trait_def(trait_ref.def_id);
let unsafe_attr = impl_generics.and_then(|g| g.carries_unsafe_attr());
match (trait_def.unsafety, unsafe_attr, unsafety, polarity) {
- (_, _, Unsafety::Unsafe, hir::ImplPolarity::Negative) => {
- span_err!(self.tcx.sess,
- item.span,
- E0198,
- "negative implementations are not unsafe");
- }
-
- (Unsafety::Normal, None, Unsafety::Unsafe, _) => {
+ (Unsafety::Normal, None, Unsafety::Unsafe, hir::ImplPolarity::Positive) => {
span_err!(self.tcx.sess,
item.span,
E0199,
@@ -69,6 +62,10 @@
g.attr_name());
}
+ (_, _, Unsafety::Unsafe, hir::ImplPolarity::Negative) => {
+ // Reported in AST validation
+ self.tcx.sess.delay_span_bug(item.span, "unsafe negative impl");
+ }
(_, _, Unsafety::Normal, hir::ImplPolarity::Negative) |
(Unsafety::Unsafe, _, Unsafety::Unsafe, hir::ImplPolarity::Positive) |
(Unsafety::Normal, Some(_), Unsafety::Unsafe, hir::ImplPolarity::Positive) |
diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs
index 11b983f..1913b94 100644
--- a/src/librustc_typeck/diagnostics.rs
+++ b/src/librustc_typeck/diagnostics.rs
@@ -1715,7 +1715,7 @@
"##,
E0192: r##"
-Negative impls are only allowed for traits with default impls. For more
+Negative impls are only allowed for auto traits. For more
information see the [opt-in builtin traits RFC][RFC 19].
[RFC 19]: https://github.com/rust-lang/rfcs/blob/master/text/0019-opt-in-builtin-traits.md
@@ -1821,52 +1821,6 @@
```
"##,
-E0197: r##"
-Inherent implementations (one that do not implement a trait but provide
-methods associated with a type) are always safe because they are not
-implementing an unsafe trait. Removing the `unsafe` keyword from the inherent
-implementation will resolve this error.
-
-```compile_fail,E0197
-struct Foo;
-
-// this will cause this error
-unsafe impl Foo { }
-// converting it to this will fix it
-impl Foo { }
-```
-"##,
-
-E0198: r##"
-A negative implementation is one that excludes a type from implementing a
-particular trait. Not being able to use a trait is always a safe operation,
-so negative implementations are always safe and never need to be marked as
-unsafe.
-
-```compile_fail
-#![feature(optin_builtin_traits)]
-
-struct Foo;
-
-// unsafe is unnecessary
-unsafe impl !Clone for Foo { }
-```
-
-This will compile:
-
-```
-#![feature(optin_builtin_traits)]
-
-struct Foo;
-
-auto trait Enterprise {}
-
-impl !Enterprise for Foo { }
-```
-
-Please note that negative impls are only allowed for traits with default impls.
-"##,
-
E0199: r##"
Safe traits should not have unsafe implementations, therefore marking an
implementation for a safe trait unsafe will cause a compiler error. Removing
diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs
index f7a67b1..e66add2 100644
--- a/src/librustdoc/html/markdown.rs
+++ b/src/librustdoc/html/markdown.rs
@@ -196,7 +196,7 @@
.map(|l| map_line(l).for_code())
.collect::<Vec<&str>>().join("\n");
let krate = krate.as_ref().map(|s| &**s);
- let test = test::make_test(&test, krate, false,
+ let (test, _) = test::make_test(&test, krate, false,
&Default::default());
let channel = if test.contains("#![feature(") {
"&version=nightly"
@@ -607,7 +607,7 @@
.map(|l| map_line(l).for_code())
.collect::<Vec<&str>>().join("\n");
let krate = krate.as_ref().map(|s| &**s);
- let test = test::make_test(&test, krate, false,
+ let (test, _) = test::make_test(&test, krate, false,
&Default::default());
let channel = if test.contains("#![feature(") {
"&version=nightly"
diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs
index 8e861f1..5432f5c 100644
--- a/src/librustdoc/test.rs
+++ b/src/librustdoc/test.rs
@@ -176,7 +176,8 @@
opts
}
-fn run_test(test: &str, cratename: &str, filename: &FileName, cfgs: Vec<String>, libs: SearchPaths,
+fn run_test(test: &str, cratename: &str, filename: &FileName, line: usize,
+ cfgs: Vec<String>, libs: SearchPaths,
externs: Externs,
should_panic: bool, no_run: bool, as_test_harness: bool,
compile_fail: bool, mut error_codes: Vec<String>, opts: &TestOptions,
@@ -184,7 +185,7 @@
linker: Option<PathBuf>) {
// the test harness wants its own `main` & top level functions, so
// never wrap the test in `fn main() { ... }`
- let test = make_test(test, Some(cratename), as_test_harness, opts);
+ let (test, line_offset) = make_test(test, Some(cratename), as_test_harness, opts);
// FIXME(#44940): if doctests ever support path remapping, then this filename
// needs to be the result of CodeMap::span_to_unmapped_path
let input = config::Input::Str {
@@ -234,7 +235,9 @@
}
}
let data = Arc::new(Mutex::new(Vec::new()));
- let codemap = Rc::new(CodeMap::new(sessopts.file_path_mapping()));
+ let codemap = Rc::new(CodeMap::new_doctest(
+ sessopts.file_path_mapping(), filename.clone(), line as isize - line_offset as isize
+ ));
let emitter = errors::emitter::EmitterWriter::new(box Sink(data.clone()),
Some(codemap.clone()),
false);
@@ -326,13 +329,14 @@
}
}
+/// Makes the test file. Also returns the number of lines before the code begins
pub fn make_test(s: &str,
cratename: Option<&str>,
dont_insert_main: bool,
opts: &TestOptions)
- -> String {
+ -> (String, usize) {
let (crate_attrs, everything_else) = partition_source(s);
-
+ let mut line_offset = 0;
let mut prog = String::new();
if opts.attrs.is_empty() {
@@ -341,11 +345,13 @@
// commonly used to make tests fail in case they trigger warnings, so having this there in
// that case may cause some tests to pass when they shouldn't have.
prog.push_str("#![allow(unused)]\n");
+ line_offset += 1;
}
// Next, any attributes that came from the crate root via #![doc(test(attr(...)))].
for attr in &opts.attrs {
prog.push_str(&format!("#![{}]\n", attr));
+ line_offset += 1;
}
// Now push any outer attributes from the example, assuming they
@@ -358,6 +364,7 @@
if let Some(cratename) = cratename {
if s.contains(cratename) {
prog.push_str(&format!("extern crate {};\n", cratename));
+ line_offset += 1;
}
}
}
@@ -379,6 +386,7 @@
prog.push_str(&everything_else);
} else {
prog.push_str("fn main() {\n");
+ line_offset += 1;
prog.push_str(&everything_else);
prog = prog.trim().into();
prog.push_str("\n}");
@@ -386,7 +394,7 @@
info!("final test program: {}", prog);
- prog
+ (prog, line_offset)
}
// FIXME(aburka): use a real parser to deal with multiline attributes
@@ -543,6 +551,7 @@
run_test(&test,
&cratename,
&filename,
+ line,
cfgs,
libs,
externs,
diff --git a/src/libstd/env.rs b/src/libstd/env.rs
index ed34c12..27bf326 100644
--- a/src/libstd/env.rs
+++ b/src/libstd/env.rs
@@ -956,8 +956,7 @@
mod tests {
use super::*;
- use ffi::OsStr;
- use path::{Path, PathBuf};
+ use path::Path;
#[test]
#[cfg_attr(target_os = "emscripten", ignore)]
@@ -980,6 +979,8 @@
#[test]
#[cfg(windows)]
fn split_paths_windows() {
+ use path::PathBuf;
+
fn check_parse(unparsed: &str, parsed: &[&str]) -> bool {
split_paths(unparsed).collect::<Vec<_>>() ==
parsed.iter().map(|s| PathBuf::from(*s)).collect::<Vec<_>>()
@@ -1000,6 +1001,8 @@
#[test]
#[cfg(unix)]
fn split_paths_unix() {
+ use path::PathBuf;
+
fn check_parse(unparsed: &str, parsed: &[&str]) -> bool {
split_paths(unparsed).collect::<Vec<_>>() ==
parsed.iter().map(|s| PathBuf::from(*s)).collect::<Vec<_>>()
@@ -1015,6 +1018,8 @@
#[test]
#[cfg(unix)]
fn join_paths_unix() {
+ use ffi::OsStr;
+
fn test_eq(input: &[&str], output: &str) -> bool {
&*join_paths(input.iter().cloned()).unwrap() ==
OsStr::new(output)
@@ -1031,6 +1036,8 @@
#[test]
#[cfg(windows)]
fn join_paths_windows() {
+ use ffi::OsStr;
+
fn test_eq(input: &[&str], output: &str) -> bool {
&*join_paths(input.iter().cloned()).unwrap() ==
OsStr::new(output)
diff --git a/src/libstd/f32.rs b/src/libstd/f32.rs
index 6d76c7e..5e5695f 100644
--- a/src/libstd/f32.rs
+++ b/src/libstd/f32.rs
@@ -472,20 +472,19 @@
/// Returns the logarithm of the number with respect to an arbitrary base.
///
+ /// The result may not be correctly rounded owing to implementation details;
+ /// `self.log2()` can produce more accurate results for base 2, and
+ /// `self.log10()` can produce more accurate results for base 10.
+ ///
/// ```
/// use std::f32;
///
- /// let ten = 10.0f32;
- /// let two = 2.0f32;
+ /// let five = 5.0f32;
///
- /// // log10(10) - 1 == 0
- /// let abs_difference_10 = (ten.log(10.0) - 1.0).abs();
+ /// // log5(5) - 1 == 0
+ /// let abs_difference = (five.log(5.0) - 1.0).abs();
///
- /// // log2(2) - 1 == 0
- /// let abs_difference_2 = (two.log(2.0) - 1.0).abs();
- ///
- /// assert!(abs_difference_10 <= f32::EPSILON);
- /// assert!(abs_difference_2 <= f32::EPSILON);
+ /// assert!(abs_difference <= f32::EPSILON);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
diff --git a/src/libstd/f64.rs b/src/libstd/f64.rs
index dee9566..e4eea74 100644
--- a/src/libstd/f64.rs
+++ b/src/libstd/f64.rs
@@ -432,18 +432,17 @@
/// Returns the logarithm of the number with respect to an arbitrary base.
///
+ /// The result may not be correctly rounded owing to implementation details;
+ /// `self.log2()` can produce more accurate results for base 2, and
+ /// `self.log10()` can produce more accurate results for base 10.
+ ///
/// ```
- /// let ten = 10.0_f64;
- /// let two = 2.0_f64;
+ /// let five = 5.0_f64;
///
- /// // log10(10) - 1 == 0
- /// let abs_difference_10 = (ten.log(10.0) - 1.0).abs();
+ /// // log5(5) - 1 == 0
+ /// let abs_difference = (five.log(5.0) - 1.0).abs();
///
- /// // log2(2) - 1 == 0
- /// let abs_difference_2 = (two.log(2.0) - 1.0).abs();
- ///
- /// assert!(abs_difference_10 < 1e-10);
- /// assert!(abs_difference_2 < 1e-10);
+ /// assert!(abs_difference < 1e-10);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs
index 51cb960..4e0ff45 100644
--- a/src/libstd/fs.rs
+++ b/src/libstd/fs.rs
@@ -1989,7 +1989,7 @@
}
}
-#[cfg(all(test, not(target_os = "emscripten")))]
+#[cfg(all(test, not(any(target_os = "cloudabi", target_os = "emscripten"))))]
mod tests {
use io::prelude::*;
diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs
index 16fbf0c..4e7db5f 100644
--- a/src/libstd/io/buffered.rs
+++ b/src/libstd/io/buffered.rs
@@ -345,8 +345,8 @@
///
/// let mut stream = TcpStream::connect("127.0.0.1:34254").unwrap();
///
-/// for i in 1..10 {
-/// stream.write(&[i]).unwrap();
+/// for i in 0..10 {
+/// stream.write(&[i+1]).unwrap();
/// }
/// ```
///
@@ -361,8 +361,8 @@
///
/// let mut stream = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap());
///
-/// for i in 1..10 {
-/// stream.write(&[i]).unwrap();
+/// for i in 0..10 {
+/// stream.write(&[i+1]).unwrap();
/// }
/// ```
///
diff --git a/src/libstd/io/error.rs b/src/libstd/io/error.rs
index bb9383d..f0b41f3 100644
--- a/src/libstd/io/error.rs
+++ b/src/libstd/io/error.rs
@@ -62,12 +62,18 @@
/// [`Write`]: ../io/trait.Write.html
/// [`Seek`]: ../io/trait.Seek.html
/// [`ErrorKind`]: enum.ErrorKind.html
-#[derive(Debug)]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Error {
repr: Repr,
}
+#[stable(feature = "rust1", since = "1.0.0")]
+impl fmt::Debug for Error {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fmt::Debug::fmt(&self.repr, f)
+ }
+}
+
enum Repr {
Os(i32),
Simple(ErrorKind),
@@ -511,10 +517,12 @@
impl fmt::Debug for Repr {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
match *self {
- Repr::Os(ref code) =>
- fmt.debug_struct("Os").field("code", code)
- .field("message", &sys::os::error_string(*code)).finish(),
- Repr::Custom(ref c) => fmt.debug_tuple("Custom").field(c).finish(),
+ Repr::Os(code) =>
+ fmt.debug_struct("Os")
+ .field("code", &code)
+ .field("kind", &sys::decode_error_kind(code))
+ .field("message", &sys::os::error_string(code)).finish(),
+ Repr::Custom(ref c) => fmt::Debug::fmt(&c, fmt),
Repr::Simple(kind) => fmt.debug_tuple("Kind").field(&kind).finish(),
}
}
@@ -559,17 +567,36 @@
#[cfg(test)]
mod test {
- use super::{Error, ErrorKind};
+ use super::{Error, ErrorKind, Repr, Custom};
use error;
use fmt;
use sys::os::error_string;
+ use sys::decode_error_kind;
#[test]
fn test_debug_error() {
let code = 6;
let msg = error_string(code);
- let err = Error { repr: super::Repr::Os(code) };
- let expected = format!("Error {{ repr: Os {{ code: {:?}, message: {:?} }} }}", code, msg);
+ let kind = decode_error_kind(code);
+ let err = Error {
+ repr: Repr::Custom(box Custom {
+ kind: ErrorKind::InvalidInput,
+ error: box Error {
+ repr: super::Repr::Os(code)
+ },
+ })
+ };
+ let expected = format!(
+ "Custom {{ \
+ kind: InvalidInput, \
+ error: Os {{ \
+ code: {:?}, \
+ kind: {:?}, \
+ message: {:?} \
+ }} \
+ }}",
+ code, kind, msg
+ );
assert_eq!(format!("{:?}", err), expected);
}
diff --git a/src/libstd/net/tcp.rs b/src/libstd/net/tcp.rs
index 539ff1d..78235ea 100644
--- a/src/libstd/net/tcp.rs
+++ b/src/libstd/net/tcp.rs
@@ -885,7 +885,7 @@
}
}
-#[cfg(all(test, not(target_os = "emscripten")))]
+#[cfg(all(test, not(any(target_os = "cloudabi", target_os = "emscripten"))))]
mod tests {
use io::ErrorKind;
use io::prelude::*;
diff --git a/src/libstd/net/udp.rs b/src/libstd/net/udp.rs
index 84ceaa6..fc7f920 100644
--- a/src/libstd/net/udp.rs
+++ b/src/libstd/net/udp.rs
@@ -786,7 +786,7 @@
}
}
-#[cfg(all(test, not(target_os = "emscripten")))]
+#[cfg(all(test, not(any(target_os = "cloudabi", target_os = "emscripten"))))]
mod tests {
use io::ErrorKind;
use net::*;
diff --git a/src/libstd/process.rs b/src/libstd/process.rs
index 33e8a87..5c66ac6 100644
--- a/src/libstd/process.rs
+++ b/src/libstd/process.rs
@@ -1392,7 +1392,7 @@
::sys::os::getpid()
}
-#[cfg(all(test, not(target_os = "emscripten")))]
+#[cfg(all(test, not(any(target_os = "cloudabi", target_os = "emscripten"))))]
mod tests {
use io::prelude::*;
diff --git a/src/libstd/rand/reader.rs b/src/libstd/rand/reader.rs
deleted file mode 100644
index 08bc809..0000000
--- a/src/libstd/rand/reader.rs
+++ /dev/null
@@ -1,108 +0,0 @@
-// Copyright 2013 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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! A wrapper around any Read to treat it as an RNG.
-
-#![allow(dead_code)]
-
-use io::prelude::*;
-use rand::Rng;
-
-/// An RNG that reads random bytes straight from a `Read`. This will
-/// work best with an infinite reader, but this is not required.
-///
-/// # Panics
-///
-/// It will panic if it there is insufficient data to fulfill a request.
-pub struct ReaderRng<R> {
- reader: R
-}
-
-impl<R: Read> ReaderRng<R> {
- /// Create a new `ReaderRng` from a `Read`.
- pub fn new(r: R) -> ReaderRng<R> {
- ReaderRng {
- reader: r
- }
- }
-}
-
-impl<R: Read> Rng for ReaderRng<R> {
- fn next_u32(&mut self) -> u32 {
- // This is designed for speed: reading a LE integer on a LE
- // platform just involves blitting the bytes into the memory
- // of the u32, similarly for BE on BE; avoiding byteswapping.
- let mut bytes = [0; 4];
- self.fill_bytes(&mut bytes);
- unsafe { *(bytes.as_ptr() as *const u32) }
- }
- fn next_u64(&mut self) -> u64 {
- // see above for explanation.
- let mut bytes = [0; 8];
- self.fill_bytes(&mut bytes);
- unsafe { *(bytes.as_ptr() as *const u64) }
- }
- fn fill_bytes(&mut self, mut v: &mut [u8]) {
- while !v.is_empty() {
- let t = v;
- match self.reader.read(t) {
- Ok(0) => panic!("ReaderRng.fill_bytes: EOF reached"),
- Ok(n) => v = t.split_at_mut(n).1,
- Err(e) => panic!("ReaderRng.fill_bytes: {}", e),
- }
- }
- }
-}
-
-#[cfg(test)]
-mod tests {
- use super::ReaderRng;
- use rand::Rng;
-
- #[test]
- fn test_reader_rng_u64() {
- // transmute from the target to avoid endianness concerns.
- let v = &[0, 0, 0, 0, 0, 0, 0, 1,
- 0, 0, 0, 0, 0, 0, 0, 2,
- 0, 0, 0, 0, 0, 0, 0, 3][..];
- let mut rng = ReaderRng::new(v);
-
- assert_eq!(rng.next_u64(), 1u64.to_be());
- assert_eq!(rng.next_u64(), 2u64.to_be());
- assert_eq!(rng.next_u64(), 3u64.to_be());
- }
- #[test]
- fn test_reader_rng_u32() {
- let v = &[0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 3][..];
- let mut rng = ReaderRng::new(v);
-
- assert_eq!(rng.next_u32(), 1u32.to_be());
- assert_eq!(rng.next_u32(), 2u32.to_be());
- assert_eq!(rng.next_u32(), 3u32.to_be());
- }
- #[test]
- fn test_reader_rng_fill_bytes() {
- let v = [1, 2, 3, 4, 5, 6, 7, 8];
- let mut w = [0; 8];
-
- let mut rng = ReaderRng::new(&v[..]);
- rng.fill_bytes(&mut w);
-
- assert!(v == w);
- }
-
- #[test]
- #[should_panic]
- fn test_reader_rng_insufficient_bytes() {
- let mut rng = ReaderRng::new(&[][..]);
- let mut v = [0; 3];
- rng.fill_bytes(&mut v);
- }
-}
diff --git a/src/libstd/sys/cloudabi/abi/bitflags.rs b/src/libstd/sys/cloudabi/abi/bitflags.rs
new file mode 100644
index 0000000..f764cc1
--- /dev/null
+++ b/src/libstd/sys/cloudabi/abi/bitflags.rs
@@ -0,0 +1,51 @@
+// Copyright (c) 2018 Nuxi (https://nuxi.nl/) and contributors.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// 1. Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE.
+
+// Appease Rust's tidy.
+// ignore-license
+
+#[cfg(feature = "bitflags")]
+#[macro_use]
+extern crate bitflags;
+
+// Minimal implementation of bitflags! in case we can't depend on the bitflags
+// crate. Only implements `bits()` and a `from_bits_truncate()` that doesn't
+// actually truncate.
+#[cfg(not(feature = "bitflags"))]
+macro_rules! bitflags {
+ (
+ $(#[$attr:meta])*
+ pub struct $name:ident: $type:ty {
+ $($(#[$const_attr:meta])* const $const:ident = $val:expr;)*
+ }
+ ) => {
+ $(#[$attr])*
+ #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
+ pub struct $name { bits: $type }
+ impl $name {
+ $($(#[$const_attr])* pub const $const: $name = $name{ bits: $val };)*
+ pub fn bits(&self) -> $type { self.bits }
+ pub fn from_bits_truncate(bits: $type) -> Self { $name{ bits } }
+ }
+ }
+}
diff --git a/src/libstd/sys/cloudabi/abi/cloudabi.rs b/src/libstd/sys/cloudabi/abi/cloudabi.rs
new file mode 100644
index 0000000..2909db5
--- /dev/null
+++ b/src/libstd/sys/cloudabi/abi/cloudabi.rs
@@ -0,0 +1,2847 @@
+// Copyright (c) 2016-2017 Nuxi (https://nuxi.nl/) and contributors.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// 1. Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE.
+//
+// This file is automatically generated. Do not edit.
+//
+// Source: https://github.com/NuxiNL/cloudabi
+
+// Appease Rust's tidy.
+// ignore-license
+// ignore-tidy-linelength
+
+//! **PLEASE NOTE: This entire crate including this
+//! documentation is automatically generated from
+//! [`cloudabi.txt`](https://github.com/NuxiNL/cloudabi/blob/master/cloudabi.txt)**
+//!
+//! # Nuxi CloudABI
+//!
+//! CloudABI is what you get if you take POSIX, add capability-based
+//! security, and remove everything that's incompatible with that. The
+//! result is a minimal ABI consisting of only 49 syscalls.
+//!
+//! CloudABI doesn't have its own kernel, but instead is implemented in existing
+//! kernels: FreeBSD has CloudABI support for x86-64 and arm64, and [a patch-set
+//! for NetBSD](https://github.com/NuxiNL/netbsd) and [a patch-set for
+//! Linux](https://github.com/NuxiNL/linux) are available as well. This means that
+//! CloudABI binaries can be executed on different operating systems, without any
+//! modification.
+//!
+//! ## Capability-Based Security
+//!
+//! Capability-based security means that processes can only perform
+//! actions that have no global impact. Processes cannot open files by
+//! their absolute path, cannot open network connections, and cannot
+//! observe global system state such as the process table.
+//!
+//! The capabilities of a process are fully determined by its set of open
+//! file descriptors (fds). For example, files can only be opened if the
+//! process already has a file descriptor to a directory the file is in.
+//!
+//! Unlike in POSIX, where processes are normally started with file
+//! descriptors 0, 1, and 2 reserved for standard input, output, and
+//! error, CloudABI does not reserve any file descriptor numbers for
+//! specific purposes.
+//!
+//! In CloudABI, a process depends on its parent process to launch it with
+//! the right set of resources, since the process will not be able to open
+//! any new resources. For example, a simple static web server would need
+//! to be started with a file descriptor to a [TCP
+//! listener](https://github.com/NuxiNL/flower), and a file descriptor to
+//! the directory for which to serve files. The web server will then be
+//! unable to do anything other than reading files in that directory, and
+//! process incoming network connections.
+//!
+//! So, unknown CloudABI binaries can safely be executed without the need
+//! for containers, virtual machines, or other sandboxing technologies.
+//!
+//! Watch [Ed Schouten's Talk at
+//! 32C3](https://www.youtube.com/watch?v=3N29vrPoDv8) for more
+//! information about what capability-based security for UNIX means.
+//!
+//! ## Cloudlibc
+//!
+//! [Cloudlibc](https://github.com/NuxiNL/cloudlibc) is an implementation
+//! of the C standard library, without all CloudABI-incompatible
+//! functions. For example, Cloudlibc does not have `printf`, but does
+//! have `fprintf`. It does not have `open`, but does have `openat`.
+//!
+//! ## CloudABI-Ports
+//!
+//! [CloudABI-Ports](https://github.com/NuxiNL/cloudabi-ports) is a
+//! collection of ports of commonly used libraries and applications to
+//! CloudABI. It contains software such as `zlib`, `libpng`, `boost`,
+//! `memcached`, and much more. The software is patched to not depend on
+//! any global state, such as files in `/etc` or `/dev`, using `open()`,
+//! etc.
+//!
+//! ## Using CloudABI
+//!
+//! Instructions for using CloudABI (including kernel modules/patches,
+//! toolchain, and ports) are available for several operating systems:
+//!
+//! - [Arch Linux](https://nuxi.nl/cloudabi/archlinux/)
+//! - [Debian, Ubuntu, and other Debian derivatives](https://nuxi.nl/cloudabi/debian/)
+//! - [FreeBSD, PC-BSD and DragonFly BSD](https://nuxi.nl/cloudabi/freebsd/)
+//! - [Mac OS X](https://nuxi.nl/cloudabi/mac/)
+//! - [NetBSD](https://nuxi.nl/cloudabi/netbsd/)
+//!
+//! ## Specification of the ABI
+//!
+//! The entire ABI is specified in a a file called
+//! [`cloudabi.txt`](https://github.com/NuxiNL/cloudabi/blob/master/cloudabi.txt),
+//! from which all
+//! [headers](https://github.com/NuxiNL/cloudabi/tree/master/headers)
+//! and documentation (including the one you're reading now) is generated.
+
+#![no_std]
+#![allow(non_camel_case_types)]
+
+include!("bitflags.rs");
+
+/// File or memory access pattern advisory information.
+#[repr(u8)]
+#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
+pub enum advice {
+ /// The application expects that it will not access the
+ /// specified data in the near future.
+ DONTNEED = 1,
+ /// The application expects to access the specified data
+ /// once and then not reuse it thereafter.
+ NOREUSE = 2,
+ /// The application has no advice to give on its behavior
+ /// with respect to the specified data.
+ NORMAL = 3,
+ /// The application expects to access the specified data
+ /// in a random order.
+ RANDOM = 4,
+ /// The application expects to access the specified data
+ /// sequentially from lower offsets to higher offsets.
+ SEQUENTIAL = 5,
+ /// The application expects to access the specified data
+ /// in the near future.
+ WILLNEED = 6,
+ #[doc(hidden)] _NonExhaustive = -1 as isize as u8,
+}
+
+/// Enumeration describing the kind of value stored in [`auxv`](struct.auxv.html).
+#[repr(u32)]
+#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
+pub enum auxtype {
+ /// Base address of the binary argument data provided to
+ /// [`proc_exec()`](fn.proc_exec.html).
+ ARGDATA = 256,
+ /// Length of the binary argument data provided to
+ /// [`proc_exec()`](fn.proc_exec.html).
+ ARGDATALEN = 257,
+ /// Base address at which the executable is placed in
+ /// memory.
+ BASE = 7,
+ /// Base address of a buffer of random data that may be
+ /// used for non-cryptographic purposes, for example as a
+ /// canary for stack smashing protection.
+ CANARY = 258,
+ /// Length of a buffer of random data that may be used
+ /// for non-cryptographic purposes, for example as a
+ /// canary for stack smashing protection.
+ CANARYLEN = 259,
+ /// Number of CPUs that the system this process is running
+ /// on has.
+ NCPUS = 260,
+ /// Terminator of the auxiliary vector.
+ NULL = 0,
+ /// Smallest memory object size for which individual
+ /// memory protection controls can be configured.
+ PAGESZ = 6,
+ /// Address of the first ELF program header of the
+ /// executable.
+ PHDR = 3,
+ /// Number of ELF program headers of the executable.
+ PHNUM = 4,
+ /// Identifier of the process.
+ ///
+ /// This environment does not provide any simple numerical
+ /// process identifiers, for the reason that these are not
+ /// useful in distributed contexts. Instead, processes are
+ /// identified by a UUID.
+ ///
+ /// This record should point to sixteen bytes of binary
+ /// data, containing a version 4 UUID (fully random).
+ PID = 263,
+ /// Address of the ELF header of the vDSO.
+ ///
+ /// The vDSO is a shared library that is mapped in the
+ /// address space of the process. It provides entry points
+ /// for every system call supported by the environment,
+ /// all having a corresponding symbol that is prefixed
+ /// with `cloudabi_sys_`. System calls should be invoked
+ /// through these entry points.
+ ///
+ /// The first advantage of letting processes call into a
+ /// vDSO to perform system calls instead of raising
+ /// hardware traps is that it allows for easy emulation of
+ /// executables on top of existing operating systems. The
+ /// second advantage is that in cases where an operating
+ /// system provides native support for CloudABI executables,
+ /// it may still implement partial userspace
+ /// implementations of these system calls to improve
+ /// performance (e.g., [`clock_time_get()`](fn.clock_time_get.html)). It also provides
+ /// a more dynamic way of adding, removing or replacing
+ /// system calls.
+ SYSINFO_EHDR = 262,
+ /// Thread ID of the initial thread of the process.
+ TID = 261,
+ #[doc(hidden)] _NonExhaustive = -1 as isize as u32,
+}
+
+/// Identifiers for clocks.
+#[repr(u32)]
+#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
+pub enum clockid {
+ /// The system-wide monotonic clock, which is defined as a
+ /// clock measuring real time, whose value cannot be
+ /// adjusted and which cannot have negative clock jumps.
+ ///
+ /// The epoch of this clock is undefined. The absolute
+ /// time value of this clock therefore has no meaning.
+ MONOTONIC = 1,
+ /// The CPU-time clock associated with the current
+ /// process.
+ PROCESS_CPUTIME_ID = 2,
+ /// The system-wide clock measuring real time. Time value
+ /// zero corresponds with 1970-01-01T00:00:00Z.
+ REALTIME = 3,
+ /// The CPU-time clock associated with the current thread.
+ THREAD_CPUTIME_ID = 4,
+ #[doc(hidden)] _NonExhaustive = -1 as isize as u32,
+}
+
+/// A userspace condition variable.
+#[repr(C)]
+#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
+pub struct condvar(pub u32);
+/// The condition variable is in its initial state. There
+/// are no threads waiting to be woken up. If the
+/// condition variable has any other value, the kernel
+/// must be called to wake up any sleeping threads.
+pub const CONDVAR_HAS_NO_WAITERS: condvar = condvar(0);
+
+/// Identifier for a device containing a file system. Can be used
+/// in combination with [`inode`](struct.inode.html) to uniquely identify a file on the
+/// local system.
+#[repr(C)]
+#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
+pub struct device(pub u64);
+
+/// A reference to the offset of a directory entry.
+#[repr(C)]
+#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
+pub struct dircookie(pub u64);
+/// Permanent reference to the first directory entry
+/// within a directory.
+pub const DIRCOOKIE_START: dircookie = dircookie(0);
+
+/// Error codes returned by system calls.
+///
+/// Not all of these error codes are returned by the system calls
+/// provided by this environment, but are either used in userspace
+/// exclusively or merely provided for alignment with POSIX.
+#[repr(u16)]
+#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
+pub enum errno {
+ /// No error occurred. System call completed successfully.
+ SUCCESS = 0,
+ /// Argument list too long.
+ TOOBIG = 1,
+ /// Permission denied.
+ ACCES = 2,
+ /// Address in use.
+ ADDRINUSE = 3,
+ /// Address not available.
+ ADDRNOTAVAIL = 4,
+ /// Address family not supported.
+ AFNOSUPPORT = 5,
+ /// Resource unavailable, or operation would block.
+ AGAIN = 6,
+ /// Connection already in progress.
+ ALREADY = 7,
+ /// Bad file descriptor.
+ BADF = 8,
+ /// Bad message.
+ BADMSG = 9,
+ /// Device or resource busy.
+ BUSY = 10,
+ /// Operation canceled.
+ CANCELED = 11,
+ /// No child processes.
+ CHILD = 12,
+ /// Connection aborted.
+ CONNABORTED = 13,
+ /// Connection refused.
+ CONNREFUSED = 14,
+ /// Connection reset.
+ CONNRESET = 15,
+ /// Resource deadlock would occur.
+ DEADLK = 16,
+ /// Destination address required.
+ DESTADDRREQ = 17,
+ /// Mathematics argument out of domain of function.
+ DOM = 18,
+ /// Reserved.
+ DQUOT = 19,
+ /// File exists.
+ EXIST = 20,
+ /// Bad address.
+ FAULT = 21,
+ /// File too large.
+ FBIG = 22,
+ /// Host is unreachable.
+ HOSTUNREACH = 23,
+ /// Identifier removed.
+ IDRM = 24,
+ /// Illegal byte sequence.
+ ILSEQ = 25,
+ /// Operation in progress.
+ INPROGRESS = 26,
+ /// Interrupted function.
+ INTR = 27,
+ /// Invalid argument.
+ INVAL = 28,
+ /// I/O error.
+ IO = 29,
+ /// Socket is connected.
+ ISCONN = 30,
+ /// Is a directory.
+ ISDIR = 31,
+ /// Too many levels of symbolic links.
+ LOOP = 32,
+ /// File descriptor value too large.
+ MFILE = 33,
+ /// Too many links.
+ MLINK = 34,
+ /// Message too large.
+ MSGSIZE = 35,
+ /// Reserved.
+ MULTIHOP = 36,
+ /// Filename too long.
+ NAMETOOLONG = 37,
+ /// Network is down.
+ NETDOWN = 38,
+ /// Connection aborted by network.
+ NETRESET = 39,
+ /// Network unreachable.
+ NETUNREACH = 40,
+ /// Too many files open in system.
+ NFILE = 41,
+ /// No buffer space available.
+ NOBUFS = 42,
+ /// No such device.
+ NODEV = 43,
+ /// No such file or directory.
+ NOENT = 44,
+ /// Executable file format error.
+ NOEXEC = 45,
+ /// No locks available.
+ NOLCK = 46,
+ /// Reserved.
+ NOLINK = 47,
+ /// Not enough space.
+ NOMEM = 48,
+ /// No message of the desired type.
+ NOMSG = 49,
+ /// Protocol not available.
+ NOPROTOOPT = 50,
+ /// No space left on device.
+ NOSPC = 51,
+ /// Function not supported.
+ NOSYS = 52,
+ /// The socket is not connected.
+ NOTCONN = 53,
+ /// Not a directory or a symbolic link to a directory.
+ NOTDIR = 54,
+ /// Directory not empty.
+ NOTEMPTY = 55,
+ /// State not recoverable.
+ NOTRECOVERABLE = 56,
+ /// Not a socket.
+ NOTSOCK = 57,
+ /// Not supported, or operation not supported on socket.
+ NOTSUP = 58,
+ /// Inappropriate I/O control operation.
+ NOTTY = 59,
+ /// No such device or address.
+ NXIO = 60,
+ /// Value too large to be stored in data type.
+ OVERFLOW = 61,
+ /// Previous owner died.
+ OWNERDEAD = 62,
+ /// Operation not permitted.
+ PERM = 63,
+ /// Broken pipe.
+ PIPE = 64,
+ /// Protocol error.
+ PROTO = 65,
+ /// Protocol not supported.
+ PROTONOSUPPORT = 66,
+ /// Protocol wrong type for socket.
+ PROTOTYPE = 67,
+ /// Result too large.
+ RANGE = 68,
+ /// Read-only file system.
+ ROFS = 69,
+ /// Invalid seek.
+ SPIPE = 70,
+ /// No such process.
+ SRCH = 71,
+ /// Reserved.
+ STALE = 72,
+ /// Connection timed out.
+ TIMEDOUT = 73,
+ /// Text file busy.
+ TXTBSY = 74,
+ /// Cross-device link.
+ XDEV = 75,
+ /// Extension: Capabilities insufficient.
+ NOTCAPABLE = 76,
+ #[doc(hidden)] _NonExhaustive = -1 as isize as u16,
+}
+
+bitflags! {
+ /// The state of the file descriptor subscribed to with
+ /// [`FD_READ`](enum.eventtype.html#variant.FD_READ) or [`FD_WRITE`](enum.eventtype.html#variant.FD_WRITE).
+ #[repr(C)]
+ pub struct eventrwflags: u16 {
+ /// The peer of this socket has closed or disconnected.
+ const HANGUP = 0x0001;
+ }
+}
+
+/// Type of a subscription to an event or its occurrence.
+#[repr(u8)]
+#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
+pub enum eventtype {
+ /// The time value of clock [`subscription.union.clock.clock_id`](struct.subscription_clock.html#structfield.clock_id)
+ /// has reached timestamp [`subscription.union.clock.timeout`](struct.subscription_clock.html#structfield.timeout).
+ CLOCK = 1,
+ /// Condition variable [`subscription.union.condvar.condvar`](struct.subscription_condvar.html#structfield.condvar) has
+ /// been woken up and [`subscription.union.condvar.lock`](struct.subscription_condvar.html#structfield.lock) has been
+ /// acquired for writing.
+ CONDVAR = 2,
+ /// File descriptor [`subscription.union.fd_readwrite.fd`](struct.subscription_fd_readwrite.html#structfield.fd) has
+ /// data available for reading. This event always triggers
+ /// for regular files.
+ FD_READ = 3,
+ /// File descriptor [`subscription.union.fd_readwrite.fd`](struct.subscription_fd_readwrite.html#structfield.fd) has
+ /// capacity available for writing. This event always
+ /// triggers for regular files.
+ FD_WRITE = 4,
+ /// Lock [`subscription.union.lock.lock`](struct.subscription_lock.html#structfield.lock) has been acquired for
+ /// reading.
+ LOCK_RDLOCK = 5,
+ /// Lock [`subscription.union.lock.lock`](struct.subscription_lock.html#structfield.lock) has been acquired for
+ /// writing.
+ LOCK_WRLOCK = 6,
+ /// The process associated with process descriptor
+ /// [`subscription.union.proc_terminate.fd`](struct.subscription_proc_terminate.html#structfield.fd) has terminated.
+ PROC_TERMINATE = 7,
+ #[doc(hidden)] _NonExhaustive = -1 as isize as u8,
+}
+
+/// Exit code generated by a process when exiting.
+pub type exitcode = u32;
+
+/// A file descriptor number.
+///
+/// Unlike on POSIX-compliant systems, none of the file descriptor
+/// numbers are reserved for a purpose (e.g., stdin, stdout,
+/// stderr). Operating systems are not required to allocate new
+/// file descriptors in ascending order.
+#[repr(C)]
+#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
+pub struct fd(pub u32);
+/// Returned to the child process by [`proc_fork()`](fn.proc_fork.html).
+pub const PROCESS_CHILD: fd = fd(0xffffffff);
+/// Passed to [`mem_map()`](fn.mem_map.html) when creating a mapping to
+/// anonymous memory.
+pub const MAP_ANON_FD : fd = fd(0xffffffff);
+
+bitflags! {
+ /// File descriptor flags.
+ #[repr(C)]
+ pub struct fdflags: u16 {
+ /// Append mode: Data written to the file is always
+ /// appended to the file's end.
+ const APPEND = 0x0001;
+ /// Write according to synchronized I/O data integrity
+ /// completion. Only the data stored in the file is
+ /// synchronized.
+ const DSYNC = 0x0002;
+ /// Non-blocking mode.
+ const NONBLOCK = 0x0004;
+ /// Synchronized read I/O operations.
+ const RSYNC = 0x0008;
+ /// Write according to synchronized I/O file integrity
+ /// completion. In addition to synchronizing the data
+ /// stored in the file, the system may also synchronously
+ /// update the file's metadata.
+ const SYNC = 0x0010;
+ }
+}
+
+bitflags! {
+ /// Which file descriptor attributes to adjust.
+ #[repr(C)]
+ pub struct fdsflags: u16 {
+ /// Adjust the file descriptor flags stored in
+ /// [`fdstat.fs_flags`](struct.fdstat.html#structfield.fs_flags).
+ const FLAGS = 0x0001;
+ /// Restrict the rights of the file descriptor to the
+ /// rights stored in [`fdstat.fs_rights_base`](struct.fdstat.html#structfield.fs_rights_base) and
+ /// [`fdstat.fs_rights_inheriting`](struct.fdstat.html#structfield.fs_rights_inheriting).
+ const RIGHTS = 0x0002;
+ }
+}
+
+/// Relative offset within a file.
+pub type filedelta = i64;
+
+/// Non-negative file size or length of a region within a file.
+pub type filesize = u64;
+
+/// The type of a file descriptor or file.
+#[repr(u8)]
+#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
+pub enum filetype {
+ /// The type of the file descriptor or file is unknown or
+ /// is different from any of the other types specified.
+ UNKNOWN = 0,
+ /// The file descriptor or file refers to a block device
+ /// inode.
+ BLOCK_DEVICE = 16,
+ /// The file descriptor or file refers to a character
+ /// device inode.
+ CHARACTER_DEVICE = 17,
+ /// The file descriptor or file refers to a directory
+ /// inode.
+ DIRECTORY = 32,
+ /// The file descriptor refers to a process handle.
+ PROCESS = 80,
+ /// The file descriptor or file refers to a regular file
+ /// inode.
+ REGULAR_FILE = 96,
+ /// The file descriptor refers to a shared memory object.
+ SHARED_MEMORY = 112,
+ /// The file descriptor or file refers to a datagram
+ /// socket.
+ SOCKET_DGRAM = 128,
+ /// The file descriptor or file refers to a byte-stream
+ /// socket.
+ SOCKET_STREAM = 130,
+ /// The file refers to a symbolic link inode.
+ SYMBOLIC_LINK = 144,
+ #[doc(hidden)] _NonExhaustive = -1 as isize as u8,
+}
+
+bitflags! {
+ /// Which file attributes to adjust.
+ #[repr(C)]
+ pub struct fsflags: u16 {
+ /// Adjust the last data access timestamp to the value
+ /// stored in [`filestat.st_atim`](struct.filestat.html#structfield.st_atim).
+ const ATIM = 0x0001;
+ /// Adjust the last data access timestamp to the time
+ /// of clock [`REALTIME`](enum.clockid.html#variant.REALTIME).
+ const ATIM_NOW = 0x0002;
+ /// Adjust the last data modification timestamp to the
+ /// value stored in [`filestat.st_mtim`](struct.filestat.html#structfield.st_mtim).
+ const MTIM = 0x0004;
+ /// Adjust the last data modification timestamp to the
+ /// time of clock [`REALTIME`](enum.clockid.html#variant.REALTIME).
+ const MTIM_NOW = 0x0008;
+ /// Truncate or extend the file to the size stored in
+ /// [`filestat.st_size`](struct.filestat.html#structfield.st_size).
+ const SIZE = 0x0010;
+ }
+}
+
+/// File serial number that is unique within its file system.
+#[repr(C)]
+#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
+pub struct inode(pub u64);
+
+/// Number of hard links to an inode.
+pub type linkcount = u32;
+
+/// A userspace read-recursive readers-writer lock, similar to a
+/// Linux futex or a FreeBSD umtx.
+#[repr(C)]
+#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
+pub struct lock(pub u32);
+/// Value indicating that the lock is in its initial
+/// unlocked state.
+pub const LOCK_UNLOCKED : lock = lock(0x00000000);
+/// Bitmask indicating that the lock is write-locked. If
+/// set, the lower 30 bits of the lock contain the
+/// identifier of the thread that owns the write lock.
+/// Otherwise, the lower 30 bits of the lock contain the
+/// number of acquired read locks.
+pub const LOCK_WRLOCKED : lock = lock(0x40000000);
+/// Bitmask indicating that the lock is either read locked
+/// or write locked, and that one or more threads have
+/// their execution suspended, waiting to acquire the
+/// lock. The last owner of the lock must call the
+/// kernel to unlock.
+///
+/// When the lock is acquired for reading and this bit is
+/// set, it means that one or more threads are attempting
+/// to acquire this lock for writing. In that case, other
+/// threads should only acquire additional read locks if
+/// suspending execution would cause a deadlock. It is
+/// preferred to suspend execution, as this prevents
+/// starvation of writers.
+pub const LOCK_KERNEL_MANAGED: lock = lock(0x80000000);
+/// Value indicating that the lock is in an incorrect
+/// state. A lock cannot be in its initial unlocked state,
+/// while also managed by the kernel.
+pub const LOCK_BOGUS : lock = lock(0x80000000);
+
+bitflags! {
+ /// Flags determining the method of how paths are resolved.
+ #[repr(C)]
+ pub struct lookupflags: u32 {
+ /// As long as the resolved path corresponds to a symbolic
+ /// link, it is expanded.
+ const SYMLINK_FOLLOW = 0x00000001;
+ }
+}
+
+bitflags! {
+ /// Memory mapping flags.
+ #[repr(C)]
+ pub struct mflags: u8 {
+ /// Instead of mapping the contents of the file provided,
+ /// create a mapping to anonymous memory. The file
+ /// descriptor argument must be set to [`MAP_ANON_FD`](constant.MAP_ANON_FD.html),
+ /// and the offset must be set to zero.
+ const ANON = 0x01;
+ /// Require that the mapping is performed at the base
+ /// address provided.
+ const FIXED = 0x02;
+ /// Changes are private.
+ const PRIVATE = 0x04;
+ /// Changes are shared.
+ const SHARED = 0x08;
+ }
+}
+
+bitflags! {
+ /// Memory page protection options.
+ ///
+ /// This implementation enforces the `W^X` property: Pages cannot be
+ /// mapped for execution while also mapped for writing.
+ #[repr(C)]
+ pub struct mprot: u8 {
+ /// Page can be executed.
+ const EXEC = 0x01;
+ /// Page can be written.
+ const WRITE = 0x02;
+ /// Page can be read.
+ const READ = 0x04;
+ }
+}
+
+bitflags! {
+ /// Methods of synchronizing memory with physical storage.
+ #[repr(C)]
+ pub struct msflags: u8 {
+ /// Perform asynchronous writes.
+ const ASYNC = 0x01;
+ /// Invalidate cached data.
+ const INVALIDATE = 0x02;
+ /// Perform synchronous writes.
+ const SYNC = 0x04;
+ }
+}
+
+/// Specifies the number of threads sleeping on a condition
+/// variable that should be woken up.
+pub type nthreads = u32;
+
+bitflags! {
+ /// Open flags used by [`file_open()`](fn.file_open.html).
+ #[repr(C)]
+ pub struct oflags: u16 {
+ /// Create file if it does not exist.
+ const CREAT = 0x0001;
+ /// Fail if not a directory.
+ const DIRECTORY = 0x0002;
+ /// Fail if file already exists.
+ const EXCL = 0x0004;
+ /// Truncate file to size 0.
+ const TRUNC = 0x0008;
+ }
+}
+
+bitflags! {
+ /// Flags provided to [`sock_recv()`](fn.sock_recv.html).
+ #[repr(C)]
+ pub struct riflags: u16 {
+ /// Returns the message without removing it from the
+ /// socket's receive queue.
+ const PEEK = 0x0004;
+ /// On byte-stream sockets, block until the full amount
+ /// of data can be returned.
+ const WAITALL = 0x0010;
+ }
+}
+
+bitflags! {
+ /// File descriptor rights, determining which actions may be
+ /// performed.
+ #[repr(C)]
+ pub struct rights: u64 {
+ /// The right to invoke [`fd_datasync()`](fn.fd_datasync.html).
+ ///
+ /// If [`FILE_OPEN`](struct.rights.html#associatedconstant.FILE_OPEN) is set, includes the right to
+ /// invoke [`file_open()`](fn.file_open.html) with [`DSYNC`](struct.fdflags.html#associatedconstant.DSYNC).
+ const FD_DATASYNC = 0x0000000000000001;
+ /// The right to invoke [`fd_read()`](fn.fd_read.html) and [`sock_recv()`](fn.sock_recv.html).
+ ///
+ /// If [`MEM_MAP`](struct.rights.html#associatedconstant.MEM_MAP) is set, includes the right to
+ /// invoke [`mem_map()`](fn.mem_map.html) with memory protection option
+ /// [`READ`](struct.mprot.html#associatedconstant.READ).
+ ///
+ /// If [`FD_SEEK`](struct.rights.html#associatedconstant.FD_SEEK) is set, includes the right to invoke
+ /// [`fd_pread()`](fn.fd_pread.html).
+ const FD_READ = 0x0000000000000002;
+ /// The right to invoke [`fd_seek()`](fn.fd_seek.html). This flag implies
+ /// [`FD_TELL`](struct.rights.html#associatedconstant.FD_TELL).
+ const FD_SEEK = 0x0000000000000004;
+ /// The right to invoke [`fd_stat_put()`](fn.fd_stat_put.html) with
+ /// [`FLAGS`](struct.fdsflags.html#associatedconstant.FLAGS).
+ const FD_STAT_PUT_FLAGS = 0x0000000000000008;
+ /// The right to invoke [`fd_sync()`](fn.fd_sync.html).
+ ///
+ /// If [`FILE_OPEN`](struct.rights.html#associatedconstant.FILE_OPEN) is set, includes the right to
+ /// invoke [`file_open()`](fn.file_open.html) with [`RSYNC`](struct.fdflags.html#associatedconstant.RSYNC) and
+ /// [`DSYNC`](struct.fdflags.html#associatedconstant.DSYNC).
+ const FD_SYNC = 0x0000000000000010;
+ /// The right to invoke [`fd_seek()`](fn.fd_seek.html) in such a way that the
+ /// file offset remains unaltered (i.e., [`CUR`](enum.whence.html#variant.CUR) with
+ /// offset zero).
+ const FD_TELL = 0x0000000000000020;
+ /// The right to invoke [`fd_write()`](fn.fd_write.html) and [`sock_send()`](fn.sock_send.html).
+ ///
+ /// If [`MEM_MAP`](struct.rights.html#associatedconstant.MEM_MAP) is set, includes the right to
+ /// invoke [`mem_map()`](fn.mem_map.html) with memory protection option
+ /// [`WRITE`](struct.mprot.html#associatedconstant.WRITE).
+ ///
+ /// If [`FD_SEEK`](struct.rights.html#associatedconstant.FD_SEEK) is set, includes the right to
+ /// invoke [`fd_pwrite()`](fn.fd_pwrite.html).
+ const FD_WRITE = 0x0000000000000040;
+ /// The right to invoke [`file_advise()`](fn.file_advise.html).
+ const FILE_ADVISE = 0x0000000000000080;
+ /// The right to invoke [`file_allocate()`](fn.file_allocate.html).
+ const FILE_ALLOCATE = 0x0000000000000100;
+ /// The right to invoke [`file_create()`](fn.file_create.html) with
+ /// [`DIRECTORY`](enum.filetype.html#variant.DIRECTORY).
+ const FILE_CREATE_DIRECTORY = 0x0000000000000200;
+ /// If [`FILE_OPEN`](struct.rights.html#associatedconstant.FILE_OPEN) is set, the right to invoke
+ /// [`file_open()`](fn.file_open.html) with [`CREAT`](struct.oflags.html#associatedconstant.CREAT).
+ const FILE_CREATE_FILE = 0x0000000000000400;
+ /// The right to invoke [`file_link()`](fn.file_link.html) with the file
+ /// descriptor as the source directory.
+ const FILE_LINK_SOURCE = 0x0000000000001000;
+ /// The right to invoke [`file_link()`](fn.file_link.html) with the file
+ /// descriptor as the target directory.
+ const FILE_LINK_TARGET = 0x0000000000002000;
+ /// The right to invoke [`file_open()`](fn.file_open.html).
+ const FILE_OPEN = 0x0000000000004000;
+ /// The right to invoke [`file_readdir()`](fn.file_readdir.html).
+ const FILE_READDIR = 0x0000000000008000;
+ /// The right to invoke [`file_readlink()`](fn.file_readlink.html).
+ const FILE_READLINK = 0x0000000000010000;
+ /// The right to invoke [`file_rename()`](fn.file_rename.html) with the file
+ /// descriptor as the source directory.
+ const FILE_RENAME_SOURCE = 0x0000000000020000;
+ /// The right to invoke [`file_rename()`](fn.file_rename.html) with the file
+ /// descriptor as the target directory.
+ const FILE_RENAME_TARGET = 0x0000000000040000;
+ /// The right to invoke [`file_stat_fget()`](fn.file_stat_fget.html).
+ const FILE_STAT_FGET = 0x0000000000080000;
+ /// The right to invoke [`file_stat_fput()`](fn.file_stat_fput.html) with
+ /// [`SIZE`](struct.fsflags.html#associatedconstant.SIZE).
+ ///
+ /// If [`FILE_OPEN`](struct.rights.html#associatedconstant.FILE_OPEN) is set, includes the right to
+ /// invoke [`file_open()`](fn.file_open.html) with [`TRUNC`](struct.oflags.html#associatedconstant.TRUNC).
+ const FILE_STAT_FPUT_SIZE = 0x0000000000100000;
+ /// The right to invoke [`file_stat_fput()`](fn.file_stat_fput.html) with
+ /// [`ATIM`](struct.fsflags.html#associatedconstant.ATIM), [`ATIM_NOW`](struct.fsflags.html#associatedconstant.ATIM_NOW), [`MTIM`](struct.fsflags.html#associatedconstant.MTIM),
+ /// and [`MTIM_NOW`](struct.fsflags.html#associatedconstant.MTIM_NOW).
+ const FILE_STAT_FPUT_TIMES = 0x0000000000200000;
+ /// The right to invoke [`file_stat_get()`](fn.file_stat_get.html).
+ const FILE_STAT_GET = 0x0000000000400000;
+ /// The right to invoke [`file_stat_put()`](fn.file_stat_put.html) with
+ /// [`ATIM`](struct.fsflags.html#associatedconstant.ATIM), [`ATIM_NOW`](struct.fsflags.html#associatedconstant.ATIM_NOW), [`MTIM`](struct.fsflags.html#associatedconstant.MTIM),
+ /// and [`MTIM_NOW`](struct.fsflags.html#associatedconstant.MTIM_NOW).
+ const FILE_STAT_PUT_TIMES = 0x0000000000800000;
+ /// The right to invoke [`file_symlink()`](fn.file_symlink.html).
+ const FILE_SYMLINK = 0x0000000001000000;
+ /// The right to invoke [`file_unlink()`](fn.file_unlink.html).
+ const FILE_UNLINK = 0x0000000002000000;
+ /// The right to invoke [`mem_map()`](fn.mem_map.html) with [`mprot`](struct.mprot.html) set to
+ /// zero.
+ const MEM_MAP = 0x0000000004000000;
+ /// If [`MEM_MAP`](struct.rights.html#associatedconstant.MEM_MAP) is set, the right to invoke
+ /// [`mem_map()`](fn.mem_map.html) with [`EXEC`](struct.mprot.html#associatedconstant.EXEC).
+ const MEM_MAP_EXEC = 0x0000000008000000;
+ /// If [`FD_READ`](struct.rights.html#associatedconstant.FD_READ) is set, includes the right to
+ /// invoke [`poll()`](fn.poll.html) to subscribe to [`FD_READ`](enum.eventtype.html#variant.FD_READ).
+ ///
+ /// If [`FD_WRITE`](struct.rights.html#associatedconstant.FD_WRITE) is set, includes the right to
+ /// invoke [`poll()`](fn.poll.html) to subscribe to [`FD_WRITE`](enum.eventtype.html#variant.FD_WRITE).
+ const POLL_FD_READWRITE = 0x0000000010000000;
+ /// The right to invoke [`poll()`](fn.poll.html) to subscribe to
+ /// [`PROC_TERMINATE`](enum.eventtype.html#variant.PROC_TERMINATE).
+ const POLL_PROC_TERMINATE = 0x0000000040000000;
+ /// The right to invoke [`proc_exec()`](fn.proc_exec.html).
+ const PROC_EXEC = 0x0000000100000000;
+ /// The right to invoke [`sock_shutdown()`](fn.sock_shutdown.html).
+ const SOCK_SHUTDOWN = 0x0000008000000000;
+ }
+}
+
+bitflags! {
+ /// Flags returned by [`sock_recv()`](fn.sock_recv.html).
+ #[repr(C)]
+ pub struct roflags: u16 {
+ /// Returned by [`sock_recv()`](fn.sock_recv.html): List of file descriptors
+ /// has been truncated.
+ const FDS_TRUNCATED = 0x0001;
+ /// Returned by [`sock_recv()`](fn.sock_recv.html): Message data has been
+ /// truncated.
+ const DATA_TRUNCATED = 0x0008;
+ }
+}
+
+/// Indicates whether an object is stored in private or shared
+/// memory.
+#[repr(u8)]
+#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
+pub enum scope {
+ /// The object is stored in private memory.
+ PRIVATE = 4,
+ /// The object is stored in shared memory.
+ SHARED = 8,
+ #[doc(hidden)] _NonExhaustive = -1 as isize as u8,
+}
+
+bitflags! {
+ /// Which channels on a socket need to be shut down.
+ #[repr(C)]
+ pub struct sdflags: u8 {
+ /// Disables further receive operations.
+ const RD = 0x01;
+ /// Disables further send operations.
+ const WR = 0x02;
+ }
+}
+
+bitflags! {
+ /// Flags provided to [`sock_send()`](fn.sock_send.html). As there are currently no flags
+ /// defined, it must be set to zero.
+ #[repr(C)]
+ pub struct siflags: u16 {
+ const DEFAULT = 0;
+ }
+}
+
+/// Signal condition.
+#[repr(u8)]
+#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
+pub enum signal {
+ /// Process abort signal.
+ ///
+ /// Action: Terminates the process.
+ ABRT = 1,
+ /// Alarm clock.
+ ///
+ /// Action: Terminates the process.
+ ALRM = 2,
+ /// Access to an undefined portion of a memory object.
+ ///
+ /// Action: Terminates the process.
+ BUS = 3,
+ /// Child process terminated, stopped, or continued.
+ ///
+ /// Action: Ignored.
+ CHLD = 4,
+ /// Continue executing, if stopped.
+ ///
+ /// Action: Continues executing, if stopped.
+ CONT = 5,
+ /// Erroneous arithmetic operation.
+ ///
+ /// Action: Terminates the process.
+ FPE = 6,
+ /// Hangup.
+ ///
+ /// Action: Terminates the process.
+ HUP = 7,
+ /// Illegal instruction.
+ ///
+ /// Action: Terminates the process.
+ ILL = 8,
+ /// Terminate interrupt signal.
+ ///
+ /// Action: Terminates the process.
+ INT = 9,
+ /// Kill.
+ ///
+ /// Action: Terminates the process.
+ KILL = 10,
+ /// Write on a pipe with no one to read it.
+ ///
+ /// Action: Ignored.
+ PIPE = 11,
+ /// Terminal quit signal.
+ ///
+ /// Action: Terminates the process.
+ QUIT = 12,
+ /// Invalid memory reference.
+ ///
+ /// Action: Terminates the process.
+ SEGV = 13,
+ /// Stop executing.
+ ///
+ /// Action: Stops executing.
+ STOP = 14,
+ /// Bad system call.
+ ///
+ /// Action: Terminates the process.
+ SYS = 15,
+ /// Termination signal.
+ ///
+ /// Action: Terminates the process.
+ TERM = 16,
+ /// Trace/breakpoint trap.
+ ///
+ /// Action: Terminates the process.
+ TRAP = 17,
+ /// Terminal stop signal.
+ ///
+ /// Action: Stops executing.
+ TSTP = 18,
+ /// Background process attempting read.
+ ///
+ /// Action: Stops executing.
+ TTIN = 19,
+ /// Background process attempting write.
+ ///
+ /// Action: Stops executing.
+ TTOU = 20,
+ /// High bandwidth data is available at a socket.
+ ///
+ /// Action: Ignored.
+ URG = 21,
+ /// User-defined signal 1.
+ ///
+ /// Action: Terminates the process.
+ USR1 = 22,
+ /// User-defined signal 2.
+ ///
+ /// Action: Terminates the process.
+ USR2 = 23,
+ /// Virtual timer expired.
+ ///
+ /// Action: Terminates the process.
+ VTALRM = 24,
+ /// CPU time limit exceeded.
+ ///
+ /// Action: Terminates the process.
+ XCPU = 25,
+ /// File size limit exceeded.
+ ///
+ /// Action: Terminates the process.
+ XFSZ = 26,
+ #[doc(hidden)] _NonExhaustive = -1 as isize as u8,
+}
+
+bitflags! {
+ /// Flags determining how the timestamp provided in
+ /// [`subscription.union.clock.timeout`](struct.subscription_clock.html#structfield.timeout) should be interpreted.
+ #[repr(C)]
+ pub struct subclockflags: u16 {
+ /// If set, treat the timestamp provided in
+ /// [`subscription.union.clock.timeout`](struct.subscription_clock.html#structfield.timeout) as an absolute timestamp
+ /// of clock [`subscription.union.clock.clock_id`](struct.subscription_clock.html#structfield.clock_id).
+ ///
+ /// If clear, treat the timestamp provided in
+ /// [`subscription.union.clock.timeout`](struct.subscription_clock.html#structfield.timeout) relative to the current
+ /// time value of clock [`subscription.union.clock.clock_id`](struct.subscription_clock.html#structfield.clock_id).
+ const ABSTIME = 0x0001;
+ }
+}
+
+bitflags! {
+ /// Flags influencing the method of polling for read or writing on
+ /// a file descriptor.
+ #[repr(C)]
+ pub struct subrwflags: u16 {
+ /// Deprecated. Must be set by callers and ignored by
+ /// implementations.
+ const POLL = 0x0001;
+ }
+}
+
+/// Unique system-local identifier of a thread. This identifier is
+/// only valid during the lifetime of the thread.
+///
+/// Threads must be aware of their thread identifier, as it is
+/// written it into locks when acquiring them for writing. It is
+/// not advised to use these identifiers for any other purpose.
+///
+/// As the thread identifier is also stored in [`lock`](struct.lock.html) when
+/// [`LOCK_WRLOCKED`](constant.LOCK_WRLOCKED.html) is set, the top two bits of the thread
+/// must always be set to zero.
+#[repr(C)]
+#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
+pub struct tid(pub u32);
+
+/// Timestamp in nanoseconds.
+pub type timestamp = u64;
+
+bitflags! {
+ /// Specifies whether files are unlinked or directories are
+ /// removed.
+ #[repr(C)]
+ pub struct ulflags: u8 {
+ /// If set, removes a directory. Otherwise, unlinks any
+ /// non-directory file.
+ const REMOVEDIR = 0x01;
+ }
+}
+
+/// User-provided value that can be attached to objects that is
+/// retained when extracted from the kernel.
+pub type userdata = u64;
+
+/// Relative to which position the offset of the file descriptor
+/// should be set.
+#[repr(u8)]
+#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
+pub enum whence {
+ /// Seek relative to current position.
+ CUR = 1,
+ /// Seek relative to end-of-file.
+ END = 2,
+ /// Seek relative to start-of-file.
+ SET = 3,
+ #[doc(hidden)] _NonExhaustive = -1 as isize as u8,
+}
+
+/// Auxiliary vector entry.
+///
+/// The auxiliary vector is a list of key-value pairs that is
+/// provided to the process on startup. Unlike structures, it is
+/// extensible, as it is possible to add new records later on.
+/// The auxiliary vector is always terminated by an entry having
+/// type [`NULL`](enum.auxtype.html#variant.NULL).
+///
+/// The auxiliary vector is part of the x86-64 ABI, but is used by
+/// this environment on all architectures.
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct auxv {
+ /// The type of the auxiliary vector entry.
+ pub a_type: auxtype,
+ pub union: auxv_union
+}
+/// A union inside `auxv`.
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub union auxv_union {
+ /// Used when `a_type` is [`ARGDATALEN`](enum.auxtype.html#variant.ARGDATALEN), [`CANARYLEN`](enum.auxtype.html#variant.CANARYLEN), [`NCPUS`](enum.auxtype.html#variant.NCPUS), [`PAGESZ`](enum.auxtype.html#variant.PAGESZ), [`PHNUM`](enum.auxtype.html#variant.PHNUM), or [`TID`](enum.auxtype.html#variant.TID).
+/// A numerical value.
+ pub a_val: usize,
+ /// Used when `a_type` is [`ARGDATA`](enum.auxtype.html#variant.ARGDATA), [`BASE`](enum.auxtype.html#variant.BASE), [`CANARY`](enum.auxtype.html#variant.CANARY), [`PHDR`](enum.auxtype.html#variant.PHDR), [`PID`](enum.auxtype.html#variant.PID), or [`SYSINFO_EHDR`](enum.auxtype.html#variant.SYSINFO_EHDR).
+/// A pointer value.
+ pub a_ptr: *mut (),
+}
+#[test]
+#[cfg(target_pointer_width = "32")]
+fn auxv_layout_test_32() {
+ assert_eq!(::core::mem::size_of::<auxv>(), 8);
+ assert_eq!(::core::mem::align_of::<auxv>(), 4);
+ unsafe {
+ let obj: auxv = ::core::mem::uninitialized();
+ let base = &obj as *const _ as usize;
+ assert_eq!(&obj.a_type as *const _ as usize - base, 0);
+ assert_eq!(&obj.union.a_val as *const _ as usize - base, 4);
+ assert_eq!(&obj.union.a_ptr as *const _ as usize - base, 4);
+ }
+}
+#[test]
+#[cfg(target_pointer_width = "64")]
+fn auxv_layout_test_64() {
+ assert_eq!(::core::mem::size_of::<auxv>(), 16);
+ assert_eq!(::core::mem::align_of::<auxv>(), 8);
+ unsafe {
+ let obj: auxv = ::core::mem::uninitialized();
+ let base = &obj as *const _ as usize;
+ assert_eq!(&obj.a_type as *const _ as usize - base, 0);
+ assert_eq!(&obj.union.a_val as *const _ as usize - base, 8);
+ assert_eq!(&obj.union.a_ptr as *const _ as usize - base, 8);
+ }
+}
+
+/// A region of memory for scatter/gather writes.
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct ciovec {
+ /// The address and length of the buffer to be written.
+ pub buf: (*const (), usize),
+}
+#[test]
+#[cfg(target_pointer_width = "32")]
+fn ciovec_layout_test_32() {
+ assert_eq!(::core::mem::size_of::<ciovec>(), 8);
+ assert_eq!(::core::mem::align_of::<ciovec>(), 4);
+ unsafe {
+ let obj: ciovec = ::core::mem::uninitialized();
+ let base = &obj as *const _ as usize;
+ assert_eq!(&obj.buf.0 as *const _ as usize - base, 0);
+ assert_eq!(&obj.buf.1 as *const _ as usize - base, 4);
+ }
+}
+#[test]
+#[cfg(target_pointer_width = "64")]
+fn ciovec_layout_test_64() {
+ assert_eq!(::core::mem::size_of::<ciovec>(), 16);
+ assert_eq!(::core::mem::align_of::<ciovec>(), 8);
+ unsafe {
+ let obj: ciovec = ::core::mem::uninitialized();
+ let base = &obj as *const _ as usize;
+ assert_eq!(&obj.buf.0 as *const _ as usize - base, 0);
+ assert_eq!(&obj.buf.1 as *const _ as usize - base, 8);
+ }
+}
+
+/// A directory entry.
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct dirent {
+ /// The offset of the next directory entry stored in this
+ /// directory.
+ pub d_next: dircookie,
+ /// The serial number of the file referred to by this
+ /// directory entry.
+ pub d_ino: inode,
+ /// The length of the name of the directory entry.
+ pub d_namlen: u32,
+ /// The type of the file referred to by this directory
+ /// entry.
+ pub d_type: filetype,
+}
+#[test]
+fn dirent_layout_test() {
+ assert_eq!(::core::mem::size_of::<dirent>(), 24);
+ assert_eq!(::core::mem::align_of::<dirent>(), 8);
+ unsafe {
+ let obj: dirent = ::core::mem::uninitialized();
+ let base = &obj as *const _ as usize;
+ assert_eq!(&obj.d_next as *const _ as usize - base, 0);
+ assert_eq!(&obj.d_ino as *const _ as usize - base, 8);
+ assert_eq!(&obj.d_namlen as *const _ as usize - base, 16);
+ assert_eq!(&obj.d_type as *const _ as usize - base, 20);
+ }
+}
+
+/// An event that occurred.
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct event {
+ /// User-provided value that got attached to
+ /// [`subscription.userdata`](struct.subscription.html#structfield.userdata).
+ pub userdata: userdata,
+ /// If non-zero, an error that occurred while processing
+ /// the subscription request.
+ pub error: errno,
+ /// The type of the event that occurred.
+ pub type_: eventtype,
+ pub union: event_union
+}
+/// A union inside `event`.
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub union event_union {
+ /// Used when `type_` is [`FD_READ`](enum.eventtype.html#variant.FD_READ) or [`FD_WRITE`](enum.eventtype.html#variant.FD_WRITE).
+ pub fd_readwrite: event_fd_readwrite,
+ /// Used when `type_` is [`PROC_TERMINATE`](enum.eventtype.html#variant.PROC_TERMINATE).
+ pub proc_terminate: event_proc_terminate,
+}
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct event_fd_readwrite {
+ /// The number of bytes available
+ /// for reading or writing.
+ pub nbytes: filesize,
+ /// Obsolete.
+ pub unused: [u8; 4],
+ /// The state of the file
+ /// descriptor.
+ pub flags: eventrwflags,
+}
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct event_proc_terminate {
+ /// Obsolete.
+ pub unused: [u8; 4],
+ /// If zero, the process has
+ /// exited.
+ /// Otherwise, the signal
+ /// condition causing it to
+ /// terminated.
+ pub signal: signal,
+ /// If exited, the exit code of
+ /// the process.
+ pub exitcode: exitcode,
+}
+#[test]
+fn event_layout_test() {
+ assert_eq!(::core::mem::size_of::<event>(), 32);
+ assert_eq!(::core::mem::align_of::<event>(), 8);
+ unsafe {
+ let obj: event = ::core::mem::uninitialized();
+ let base = &obj as *const _ as usize;
+ assert_eq!(&obj.userdata as *const _ as usize - base, 0);
+ assert_eq!(&obj.error as *const _ as usize - base, 8);
+ assert_eq!(&obj.type_ as *const _ as usize - base, 10);
+ assert_eq!(&obj.union.fd_readwrite.nbytes as *const _ as usize - base, 16);
+ assert_eq!(&obj.union.fd_readwrite.unused as *const _ as usize - base, 24);
+ assert_eq!(&obj.union.fd_readwrite.flags as *const _ as usize - base, 28);
+ assert_eq!(&obj.union.proc_terminate.unused as *const _ as usize - base, 16);
+ assert_eq!(&obj.union.proc_terminate.signal as *const _ as usize - base, 20);
+ assert_eq!(&obj.union.proc_terminate.exitcode as *const _ as usize - base, 24);
+ }
+}
+
+/// File descriptor attributes.
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct fdstat {
+ /// File type.
+ pub fs_filetype: filetype,
+ /// File descriptor flags.
+ pub fs_flags: fdflags,
+ /// Rights that apply to this file descriptor.
+ pub fs_rights_base: rights,
+ /// Maximum set of rights that can be installed on new
+ /// file descriptors that are created through this file
+ /// descriptor, e.g., through [`file_open()`](fn.file_open.html).
+ pub fs_rights_inheriting: rights,
+}
+#[test]
+fn fdstat_layout_test() {
+ assert_eq!(::core::mem::size_of::<fdstat>(), 24);
+ assert_eq!(::core::mem::align_of::<fdstat>(), 8);
+ unsafe {
+ let obj: fdstat = ::core::mem::uninitialized();
+ let base = &obj as *const _ as usize;
+ assert_eq!(&obj.fs_filetype as *const _ as usize - base, 0);
+ assert_eq!(&obj.fs_flags as *const _ as usize - base, 2);
+ assert_eq!(&obj.fs_rights_base as *const _ as usize - base, 8);
+ assert_eq!(&obj.fs_rights_inheriting as *const _ as usize - base, 16);
+ }
+}
+
+/// File attributes.
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct filestat {
+ /// Device ID of device containing the file.
+ pub st_dev: device,
+ /// File serial number.
+ pub st_ino: inode,
+ /// File type.
+ pub st_filetype: filetype,
+ /// Number of hard links to the file.
+ pub st_nlink: linkcount,
+ /// For regular files, the file size in bytes. For
+ /// symbolic links, the length in bytes of the pathname
+ /// contained in the symbolic link.
+ pub st_size: filesize,
+ /// Last data access timestamp.
+ pub st_atim: timestamp,
+ /// Last data modification timestamp.
+ pub st_mtim: timestamp,
+ /// Last file status change timestamp.
+ pub st_ctim: timestamp,
+}
+#[test]
+fn filestat_layout_test() {
+ assert_eq!(::core::mem::size_of::<filestat>(), 56);
+ assert_eq!(::core::mem::align_of::<filestat>(), 8);
+ unsafe {
+ let obj: filestat = ::core::mem::uninitialized();
+ let base = &obj as *const _ as usize;
+ assert_eq!(&obj.st_dev as *const _ as usize - base, 0);
+ assert_eq!(&obj.st_ino as *const _ as usize - base, 8);
+ assert_eq!(&obj.st_filetype as *const _ as usize - base, 16);
+ assert_eq!(&obj.st_nlink as *const _ as usize - base, 20);
+ assert_eq!(&obj.st_size as *const _ as usize - base, 24);
+ assert_eq!(&obj.st_atim as *const _ as usize - base, 32);
+ assert_eq!(&obj.st_mtim as *const _ as usize - base, 40);
+ assert_eq!(&obj.st_ctim as *const _ as usize - base, 48);
+ }
+}
+
+/// A region of memory for scatter/gather reads.
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct iovec {
+ /// The address and length of the buffer to be filled.
+ pub buf: (*mut (), usize),
+}
+#[test]
+#[cfg(target_pointer_width = "32")]
+fn iovec_layout_test_32() {
+ assert_eq!(::core::mem::size_of::<iovec>(), 8);
+ assert_eq!(::core::mem::align_of::<iovec>(), 4);
+ unsafe {
+ let obj: iovec = ::core::mem::uninitialized();
+ let base = &obj as *const _ as usize;
+ assert_eq!(&obj.buf.0 as *const _ as usize - base, 0);
+ assert_eq!(&obj.buf.1 as *const _ as usize - base, 4);
+ }
+}
+#[test]
+#[cfg(target_pointer_width = "64")]
+fn iovec_layout_test_64() {
+ assert_eq!(::core::mem::size_of::<iovec>(), 16);
+ assert_eq!(::core::mem::align_of::<iovec>(), 8);
+ unsafe {
+ let obj: iovec = ::core::mem::uninitialized();
+ let base = &obj as *const _ as usize;
+ assert_eq!(&obj.buf.0 as *const _ as usize - base, 0);
+ assert_eq!(&obj.buf.1 as *const _ as usize - base, 8);
+ }
+}
+
+/// Path lookup properties.
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct lookup {
+ /// The working directory at which the resolution of the
+ /// path starts.
+ pub fd: fd,
+ /// Flags determining the method of how the path is
+ /// resolved.
+ pub flags: lookupflags,
+}
+#[test]
+fn lookup_layout_test() {
+ assert_eq!(::core::mem::size_of::<lookup>(), 8);
+ assert_eq!(::core::mem::align_of::<lookup>(), 4);
+ unsafe {
+ let obj: lookup = ::core::mem::uninitialized();
+ let base = &obj as *const _ as usize;
+ assert_eq!(&obj.fd as *const _ as usize - base, 0);
+ assert_eq!(&obj.flags as *const _ as usize - base, 4);
+ }
+}
+
+/// Entry point for a process (`_start`).
+///
+/// **auxv**:
+/// The auxiliary vector. See [`auxv`](struct.auxv.html).
+pub type processentry = unsafe extern "C" fn(
+ auxv: *const auxv,
+) -> ();
+
+/// Arguments of [`sock_recv()`](fn.sock_recv.html).
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct recv_in {
+ /// List of scatter/gather vectors where message data
+ /// should be stored.
+ pub ri_data: (*const iovec, usize),
+ /// Buffer where numbers of incoming file descriptors
+ /// should be stored.
+ pub ri_fds: (*mut fd, usize),
+ /// Message flags.
+ pub ri_flags: riflags,
+}
+#[test]
+#[cfg(target_pointer_width = "32")]
+fn recv_in_layout_test_32() {
+ assert_eq!(::core::mem::size_of::<recv_in>(), 20);
+ assert_eq!(::core::mem::align_of::<recv_in>(), 4);
+ unsafe {
+ let obj: recv_in = ::core::mem::uninitialized();
+ let base = &obj as *const _ as usize;
+ assert_eq!(&obj.ri_data.0 as *const _ as usize - base, 0);
+ assert_eq!(&obj.ri_data.1 as *const _ as usize - base, 4);
+ assert_eq!(&obj.ri_fds.0 as *const _ as usize - base, 8);
+ assert_eq!(&obj.ri_fds.1 as *const _ as usize - base, 12);
+ assert_eq!(&obj.ri_flags as *const _ as usize - base, 16);
+ }
+}
+#[test]
+#[cfg(target_pointer_width = "64")]
+fn recv_in_layout_test_64() {
+ assert_eq!(::core::mem::size_of::<recv_in>(), 40);
+ assert_eq!(::core::mem::align_of::<recv_in>(), 8);
+ unsafe {
+ let obj: recv_in = ::core::mem::uninitialized();
+ let base = &obj as *const _ as usize;
+ assert_eq!(&obj.ri_data.0 as *const _ as usize - base, 0);
+ assert_eq!(&obj.ri_data.1 as *const _ as usize - base, 8);
+ assert_eq!(&obj.ri_fds.0 as *const _ as usize - base, 16);
+ assert_eq!(&obj.ri_fds.1 as *const _ as usize - base, 24);
+ assert_eq!(&obj.ri_flags as *const _ as usize - base, 32);
+ }
+}
+
+/// Results of [`sock_recv()`](fn.sock_recv.html).
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct recv_out {
+ /// Number of bytes stored in [`recv_in.ri_data`](struct.recv_in.html#structfield.ri_data).
+ pub ro_datalen: usize,
+ /// Number of file descriptors stored in [`recv_in.ri_fds`](struct.recv_in.html#structfield.ri_fds).
+ pub ro_fdslen: usize,
+ /// Fields that were used by previous implementations.
+ pub ro_unused: [u8; 40],
+ /// Message flags.
+ pub ro_flags: roflags,
+}
+#[test]
+#[cfg(target_pointer_width = "32")]
+fn recv_out_layout_test_32() {
+ assert_eq!(::core::mem::size_of::<recv_out>(), 52);
+ assert_eq!(::core::mem::align_of::<recv_out>(), 4);
+ unsafe {
+ let obj: recv_out = ::core::mem::uninitialized();
+ let base = &obj as *const _ as usize;
+ assert_eq!(&obj.ro_datalen as *const _ as usize - base, 0);
+ assert_eq!(&obj.ro_fdslen as *const _ as usize - base, 4);
+ assert_eq!(&obj.ro_unused as *const _ as usize - base, 8);
+ assert_eq!(&obj.ro_flags as *const _ as usize - base, 48);
+ }
+}
+#[test]
+#[cfg(target_pointer_width = "64")]
+fn recv_out_layout_test_64() {
+ assert_eq!(::core::mem::size_of::<recv_out>(), 64);
+ assert_eq!(::core::mem::align_of::<recv_out>(), 8);
+ unsafe {
+ let obj: recv_out = ::core::mem::uninitialized();
+ let base = &obj as *const _ as usize;
+ assert_eq!(&obj.ro_datalen as *const _ as usize - base, 0);
+ assert_eq!(&obj.ro_fdslen as *const _ as usize - base, 8);
+ assert_eq!(&obj.ro_unused as *const _ as usize - base, 16);
+ assert_eq!(&obj.ro_flags as *const _ as usize - base, 56);
+ }
+}
+
+/// Arguments of [`sock_send()`](fn.sock_send.html).
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct send_in {
+ /// List of scatter/gather vectors where message data
+ /// should be retrieved.
+ pub si_data: (*const ciovec, usize),
+ /// File descriptors that need to be attached to the
+ /// message.
+ pub si_fds: (*const fd, usize),
+ /// Message flags.
+ pub si_flags: siflags,
+}
+#[test]
+#[cfg(target_pointer_width = "32")]
+fn send_in_layout_test_32() {
+ assert_eq!(::core::mem::size_of::<send_in>(), 20);
+ assert_eq!(::core::mem::align_of::<send_in>(), 4);
+ unsafe {
+ let obj: send_in = ::core::mem::uninitialized();
+ let base = &obj as *const _ as usize;
+ assert_eq!(&obj.si_data.0 as *const _ as usize - base, 0);
+ assert_eq!(&obj.si_data.1 as *const _ as usize - base, 4);
+ assert_eq!(&obj.si_fds.0 as *const _ as usize - base, 8);
+ assert_eq!(&obj.si_fds.1 as *const _ as usize - base, 12);
+ assert_eq!(&obj.si_flags as *const _ as usize - base, 16);
+ }
+}
+#[test]
+#[cfg(target_pointer_width = "64")]
+fn send_in_layout_test_64() {
+ assert_eq!(::core::mem::size_of::<send_in>(), 40);
+ assert_eq!(::core::mem::align_of::<send_in>(), 8);
+ unsafe {
+ let obj: send_in = ::core::mem::uninitialized();
+ let base = &obj as *const _ as usize;
+ assert_eq!(&obj.si_data.0 as *const _ as usize - base, 0);
+ assert_eq!(&obj.si_data.1 as *const _ as usize - base, 8);
+ assert_eq!(&obj.si_fds.0 as *const _ as usize - base, 16);
+ assert_eq!(&obj.si_fds.1 as *const _ as usize - base, 24);
+ assert_eq!(&obj.si_flags as *const _ as usize - base, 32);
+ }
+}
+
+/// Results of [`sock_send()`](fn.sock_send.html).
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct send_out {
+ /// Number of bytes transmitted.
+ pub so_datalen: usize,
+}
+#[test]
+#[cfg(target_pointer_width = "32")]
+fn send_out_layout_test_32() {
+ assert_eq!(::core::mem::size_of::<send_out>(), 4);
+ assert_eq!(::core::mem::align_of::<send_out>(), 4);
+ unsafe {
+ let obj: send_out = ::core::mem::uninitialized();
+ let base = &obj as *const _ as usize;
+ assert_eq!(&obj.so_datalen as *const _ as usize - base, 0);
+ }
+}
+#[test]
+#[cfg(target_pointer_width = "64")]
+fn send_out_layout_test_64() {
+ assert_eq!(::core::mem::size_of::<send_out>(), 8);
+ assert_eq!(::core::mem::align_of::<send_out>(), 8);
+ unsafe {
+ let obj: send_out = ::core::mem::uninitialized();
+ let base = &obj as *const _ as usize;
+ assert_eq!(&obj.so_datalen as *const _ as usize - base, 0);
+ }
+}
+
+/// Subscription to an event.
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct subscription {
+ /// User-provided value that is attached to the
+ /// subscription in the kernel and returned through
+ /// [`event.userdata`](struct.event.html#structfield.userdata).
+ pub userdata: userdata,
+ /// Used by previous implementations. Ignored.
+ pub unused: u16,
+ /// The type of the event to which to subscribe.
+ ///
+ /// Currently, [`CONDVAR`](enum.eventtype.html#variant.CONDVAR),
+ /// [`LOCK_RDLOCK`](enum.eventtype.html#variant.LOCK_RDLOCK), and [`LOCK_WRLOCK`](enum.eventtype.html#variant.LOCK_WRLOCK)
+ /// must be provided as the first subscription and may
+ /// only be followed by up to one other subscription,
+ /// having type [`CLOCK`](enum.eventtype.html#variant.CLOCK).
+ pub type_: eventtype,
+ pub union: subscription_union
+}
+/// A union inside `subscription`.
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub union subscription_union {
+ /// Used when `type_` is [`CLOCK`](enum.eventtype.html#variant.CLOCK).
+ pub clock: subscription_clock,
+ /// Used when `type_` is [`CONDVAR`](enum.eventtype.html#variant.CONDVAR).
+ pub condvar: subscription_condvar,
+ /// Used when `type_` is [`FD_READ`](enum.eventtype.html#variant.FD_READ) or [`FD_WRITE`](enum.eventtype.html#variant.FD_WRITE).
+ pub fd_readwrite: subscription_fd_readwrite,
+ /// Used when `type_` is [`LOCK_RDLOCK`](enum.eventtype.html#variant.LOCK_RDLOCK) or [`LOCK_WRLOCK`](enum.eventtype.html#variant.LOCK_WRLOCK).
+ pub lock: subscription_lock,
+ /// Used when `type_` is [`PROC_TERMINATE`](enum.eventtype.html#variant.PROC_TERMINATE).
+ pub proc_terminate: subscription_proc_terminate,
+}
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct subscription_clock {
+ /// The user-defined unique
+ /// identifier of the clock.
+ pub identifier: userdata,
+ /// The clock against which the
+ /// timestamp should be compared.
+ pub clock_id: clockid,
+ /// The absolute or relative
+ /// timestamp.
+ pub timeout: timestamp,
+ /// The amount of time that the
+ /// kernel may wait additionally
+ /// to coalesce with other events.
+ pub precision: timestamp,
+ /// Flags specifying whether the
+ /// timeout is absolute or
+ /// relative.
+ pub flags: subclockflags,
+}
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct subscription_condvar {
+ /// The condition variable on
+ /// which to wait to be woken up.
+ pub condvar: *mut condvar,
+ /// The lock that will be
+ /// released while waiting.
+ ///
+ /// The lock will be reacquired
+ /// for writing when the condition
+ /// variable triggers.
+ pub lock: *mut lock,
+ /// Whether the condition variable
+ /// is stored in private or shared
+ /// memory.
+ pub condvar_scope: scope,
+ /// Whether the lock is stored in
+ /// private or shared memory.
+ pub lock_scope: scope,
+}
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct subscription_fd_readwrite {
+ /// The file descriptor on which
+ /// to wait for it to become ready
+ /// for reading or writing.
+ pub fd: fd,
+ /// Under which conditions to
+ /// trigger.
+ pub flags: subrwflags,
+}
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct subscription_lock {
+ /// The lock that will be acquired
+ /// for reading or writing.
+ pub lock: *mut lock,
+ /// Whether the lock is stored in
+ /// private or shared memory.
+ pub lock_scope: scope,
+}
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct subscription_proc_terminate {
+ /// The process descriptor on
+ /// which to wait for process
+ /// termination.
+ pub fd: fd,
+}
+#[test]
+#[cfg(target_pointer_width = "32")]
+fn subscription_layout_test_32() {
+ assert_eq!(::core::mem::size_of::<subscription>(), 56);
+ assert_eq!(::core::mem::align_of::<subscription>(), 8);
+ unsafe {
+ let obj: subscription = ::core::mem::uninitialized();
+ let base = &obj as *const _ as usize;
+ assert_eq!(&obj.userdata as *const _ as usize - base, 0);
+ assert_eq!(&obj.unused as *const _ as usize - base, 8);
+ assert_eq!(&obj.type_ as *const _ as usize - base, 10);
+ assert_eq!(&obj.union.clock.identifier as *const _ as usize - base, 16);
+ assert_eq!(&obj.union.clock.clock_id as *const _ as usize - base, 24);
+ assert_eq!(&obj.union.clock.timeout as *const _ as usize - base, 32);
+ assert_eq!(&obj.union.clock.precision as *const _ as usize - base, 40);
+ assert_eq!(&obj.union.clock.flags as *const _ as usize - base, 48);
+ assert_eq!(&obj.union.condvar.condvar as *const _ as usize - base, 16);
+ assert_eq!(&obj.union.condvar.lock as *const _ as usize - base, 20);
+ assert_eq!(&obj.union.condvar.condvar_scope as *const _ as usize - base, 24);
+ assert_eq!(&obj.union.condvar.lock_scope as *const _ as usize - base, 25);
+ assert_eq!(&obj.union.fd_readwrite.fd as *const _ as usize - base, 16);
+ assert_eq!(&obj.union.fd_readwrite.flags as *const _ as usize - base, 20);
+ assert_eq!(&obj.union.lock.lock as *const _ as usize - base, 16);
+ assert_eq!(&obj.union.lock.lock_scope as *const _ as usize - base, 20);
+ assert_eq!(&obj.union.proc_terminate.fd as *const _ as usize - base, 16);
+ }
+}
+#[test]
+#[cfg(target_pointer_width = "64")]
+fn subscription_layout_test_64() {
+ assert_eq!(::core::mem::size_of::<subscription>(), 56);
+ assert_eq!(::core::mem::align_of::<subscription>(), 8);
+ unsafe {
+ let obj: subscription = ::core::mem::uninitialized();
+ let base = &obj as *const _ as usize;
+ assert_eq!(&obj.userdata as *const _ as usize - base, 0);
+ assert_eq!(&obj.unused as *const _ as usize - base, 8);
+ assert_eq!(&obj.type_ as *const _ as usize - base, 10);
+ assert_eq!(&obj.union.clock.identifier as *const _ as usize - base, 16);
+ assert_eq!(&obj.union.clock.clock_id as *const _ as usize - base, 24);
+ assert_eq!(&obj.union.clock.timeout as *const _ as usize - base, 32);
+ assert_eq!(&obj.union.clock.precision as *const _ as usize - base, 40);
+ assert_eq!(&obj.union.clock.flags as *const _ as usize - base, 48);
+ assert_eq!(&obj.union.condvar.condvar as *const _ as usize - base, 16);
+ assert_eq!(&obj.union.condvar.lock as *const _ as usize - base, 24);
+ assert_eq!(&obj.union.condvar.condvar_scope as *const _ as usize - base, 32);
+ assert_eq!(&obj.union.condvar.lock_scope as *const _ as usize - base, 33);
+ assert_eq!(&obj.union.fd_readwrite.fd as *const _ as usize - base, 16);
+ assert_eq!(&obj.union.fd_readwrite.flags as *const _ as usize - base, 20);
+ assert_eq!(&obj.union.lock.lock as *const _ as usize - base, 16);
+ assert_eq!(&obj.union.lock.lock_scope as *const _ as usize - base, 24);
+ assert_eq!(&obj.union.proc_terminate.fd as *const _ as usize - base, 16);
+ }
+}
+
+/// The Thread Control Block (TCB).
+///
+/// After a thread begins execution (at program startup or when
+/// created through [`thread_create()`](fn.thread_create.html)), the CPU's registers
+/// controlling Thread-Local Storage (TLS) will already be
+/// initialized. They will point to an area only containing the
+/// TCB.
+///
+/// If the thread needs space for storing thread-specific
+/// variables, the thread may allocate a larger area and adjust
+/// the CPU's registers to point to that area instead. However, it
+/// does need to make sure that the TCB is copied over to the new
+/// TLS area.
+///
+/// The purpose of the TCB is that it allows light-weight
+/// emulators to store information related to individual threads.
+/// For example, it may be used to store a copy of the CPU
+/// registers prior emulation, so that TLS for the host system
+/// can be restored if needed.
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct tcb {
+ /// Pointer that may be freely assigned by the system. Its
+ /// value cannot be interpreted by the application.
+ pub parent: *mut (),
+}
+#[test]
+#[cfg(target_pointer_width = "32")]
+fn tcb_layout_test_32() {
+ assert_eq!(::core::mem::size_of::<tcb>(), 4);
+ assert_eq!(::core::mem::align_of::<tcb>(), 4);
+ unsafe {
+ let obj: tcb = ::core::mem::uninitialized();
+ let base = &obj as *const _ as usize;
+ assert_eq!(&obj.parent as *const _ as usize - base, 0);
+ }
+}
+#[test]
+#[cfg(target_pointer_width = "64")]
+fn tcb_layout_test_64() {
+ assert_eq!(::core::mem::size_of::<tcb>(), 8);
+ assert_eq!(::core::mem::align_of::<tcb>(), 8);
+ unsafe {
+ let obj: tcb = ::core::mem::uninitialized();
+ let base = &obj as *const _ as usize;
+ assert_eq!(&obj.parent as *const _ as usize - base, 0);
+ }
+}
+
+/// Entry point for additionally created threads.
+///
+/// **tid**:
+/// Thread ID of the current thread.
+///
+/// **aux**:
+/// Copy of the value stored in
+/// [`threadattr.argument`](struct.threadattr.html#structfield.argument).
+pub type threadentry = unsafe extern "C" fn(
+ tid: tid,
+ aux: *mut (),
+) -> ();
+
+/// Attributes for thread creation.
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct threadattr {
+ /// Initial program counter value.
+ pub entry_point: threadentry,
+ /// Region allocated to serve as stack space.
+ pub stack: (*mut (), usize),
+ /// Argument to be forwarded to the entry point function.
+ pub argument: *mut (),
+}
+#[test]
+#[cfg(target_pointer_width = "32")]
+fn threadattr_layout_test_32() {
+ assert_eq!(::core::mem::size_of::<threadattr>(), 16);
+ assert_eq!(::core::mem::align_of::<threadattr>(), 4);
+ unsafe {
+ let obj: threadattr = ::core::mem::uninitialized();
+ let base = &obj as *const _ as usize;
+ assert_eq!(&obj.entry_point as *const _ as usize - base, 0);
+ assert_eq!(&obj.stack.0 as *const _ as usize - base, 4);
+ assert_eq!(&obj.stack.1 as *const _ as usize - base, 8);
+ assert_eq!(&obj.argument as *const _ as usize - base, 12);
+ }
+}
+#[test]
+#[cfg(target_pointer_width = "64")]
+fn threadattr_layout_test_64() {
+ assert_eq!(::core::mem::size_of::<threadattr>(), 32);
+ assert_eq!(::core::mem::align_of::<threadattr>(), 8);
+ unsafe {
+ let obj: threadattr = ::core::mem::uninitialized();
+ let base = &obj as *const _ as usize;
+ assert_eq!(&obj.entry_point as *const _ as usize - base, 0);
+ assert_eq!(&obj.stack.0 as *const _ as usize - base, 8);
+ assert_eq!(&obj.stack.1 as *const _ as usize - base, 16);
+ assert_eq!(&obj.argument as *const _ as usize - base, 24);
+ }
+}
+
+/// The table with pointers to all syscall implementations.
+#[allow(improper_ctypes)]
+extern "C" {
+ fn cloudabi_sys_clock_res_get(_: clockid, _: *mut timestamp) -> errno;
+ fn cloudabi_sys_clock_time_get(_: clockid, _: timestamp, _: *mut timestamp) -> errno;
+ fn cloudabi_sys_condvar_signal(_: *mut condvar, _: scope, _: nthreads) -> errno;
+ fn cloudabi_sys_fd_close(_: fd) -> errno;
+ fn cloudabi_sys_fd_create1(_: filetype, _: *mut fd) -> errno;
+ fn cloudabi_sys_fd_create2(_: filetype, _: *mut fd, _: *mut fd) -> errno;
+ fn cloudabi_sys_fd_datasync(_: fd) -> errno;
+ fn cloudabi_sys_fd_dup(_: fd, _: *mut fd) -> errno;
+ fn cloudabi_sys_fd_pread(_: fd, _: *const iovec, _: usize, _: filesize, _: *mut usize) -> errno;
+ fn cloudabi_sys_fd_pwrite(_: fd, _: *const ciovec, _: usize, _: filesize, _: *mut usize) -> errno;
+ fn cloudabi_sys_fd_read(_: fd, _: *const iovec, _: usize, _: *mut usize) -> errno;
+ fn cloudabi_sys_fd_replace(_: fd, _: fd) -> errno;
+ fn cloudabi_sys_fd_seek(_: fd, _: filedelta, _: whence, _: *mut filesize) -> errno;
+ fn cloudabi_sys_fd_stat_get(_: fd, _: *mut fdstat) -> errno;
+ fn cloudabi_sys_fd_stat_put(_: fd, _: *const fdstat, _: fdsflags) -> errno;
+ fn cloudabi_sys_fd_sync(_: fd) -> errno;
+ fn cloudabi_sys_fd_write(_: fd, _: *const ciovec, _: usize, _: *mut usize) -> errno;
+ fn cloudabi_sys_file_advise(_: fd, _: filesize, _: filesize, _: advice) -> errno;
+ fn cloudabi_sys_file_allocate(_: fd, _: filesize, _: filesize) -> errno;
+ fn cloudabi_sys_file_create(_: fd, _: *const u8, _: usize, _: filetype) -> errno;
+ fn cloudabi_sys_file_link(_: lookup, _: *const u8, _: usize, _: fd, _: *const u8, _: usize) -> errno;
+ fn cloudabi_sys_file_open(_: lookup, _: *const u8, _: usize, _: oflags, _: *const fdstat, _: *mut fd) -> errno;
+ fn cloudabi_sys_file_readdir(_: fd, _: *mut (), _: usize, _: dircookie, _: *mut usize) -> errno;
+ fn cloudabi_sys_file_readlink(_: fd, _: *const u8, _: usize, _: *mut u8, _: usize, _: *mut usize) -> errno;
+ fn cloudabi_sys_file_rename(_: fd, _: *const u8, _: usize, _: fd, _: *const u8, _: usize) -> errno;
+ fn cloudabi_sys_file_stat_fget(_: fd, _: *mut filestat) -> errno;
+ fn cloudabi_sys_file_stat_fput(_: fd, _: *const filestat, _: fsflags) -> errno;
+ fn cloudabi_sys_file_stat_get(_: lookup, _: *const u8, _: usize, _: *mut filestat) -> errno;
+ fn cloudabi_sys_file_stat_put(_: lookup, _: *const u8, _: usize, _: *const filestat, _: fsflags) -> errno;
+ fn cloudabi_sys_file_symlink(_: *const u8, _: usize, _: fd, _: *const u8, _: usize) -> errno;
+ fn cloudabi_sys_file_unlink(_: fd, _: *const u8, _: usize, _: ulflags) -> errno;
+ fn cloudabi_sys_lock_unlock(_: *mut lock, _: scope) -> errno;
+ fn cloudabi_sys_mem_advise(_: *mut (), _: usize, _: advice) -> errno;
+ fn cloudabi_sys_mem_map(_: *mut (), _: usize, _: mprot, _: mflags, _: fd, _: filesize, _: *mut *mut ()) -> errno;
+ fn cloudabi_sys_mem_protect(_: *mut (), _: usize, _: mprot) -> errno;
+ fn cloudabi_sys_mem_sync(_: *mut (), _: usize, _: msflags) -> errno;
+ fn cloudabi_sys_mem_unmap(_: *mut (), _: usize) -> errno;
+ fn cloudabi_sys_poll(_: *const subscription, _: *mut event, _: usize, _: *mut usize) -> errno;
+ fn cloudabi_sys_proc_exec(_: fd, _: *const (), _: usize, _: *const fd, _: usize) -> errno;
+ fn cloudabi_sys_proc_exit(_: exitcode) -> !;
+ fn cloudabi_sys_proc_fork(_: *mut fd, _: *mut tid) -> errno;
+ fn cloudabi_sys_proc_raise(_: signal) -> errno;
+ fn cloudabi_sys_random_get(_: *mut (), _: usize) -> errno;
+ fn cloudabi_sys_sock_recv(_: fd, _: *const recv_in, _: *mut recv_out) -> errno;
+ fn cloudabi_sys_sock_send(_: fd, _: *const send_in, _: *mut send_out) -> errno;
+ fn cloudabi_sys_sock_shutdown(_: fd, _: sdflags) -> errno;
+ fn cloudabi_sys_thread_create(_: *mut threadattr, _: *mut tid) -> errno;
+ fn cloudabi_sys_thread_exit(_: *mut lock, _: scope) -> !;
+ fn cloudabi_sys_thread_yield() -> errno;
+}
+
+/// Obtains the resolution of a clock.
+///
+/// ## Parameters
+///
+/// **clock_id**:
+/// The clock for which the resolution needs to be
+/// returned.
+///
+/// **resolution**:
+/// The resolution of the clock.
+#[inline]
+pub unsafe fn clock_res_get(clock_id_: clockid, resolution_: &mut timestamp) -> errno {
+ cloudabi_sys_clock_res_get(clock_id_, resolution_)
+}
+
+/// Obtains the time value of a clock.
+///
+/// ## Parameters
+///
+/// **clock_id**:
+/// The clock for which the time needs to be
+/// returned.
+///
+/// **precision**:
+/// The maximum lag (exclusive) that the returned
+/// time value may have, compared to its actual
+/// value.
+///
+/// **time**:
+/// The time value of the clock.
+#[inline]
+pub unsafe fn clock_time_get(clock_id_: clockid, precision_: timestamp, time_: &mut timestamp) -> errno {
+ cloudabi_sys_clock_time_get(clock_id_, precision_, time_)
+}
+
+/// Wakes up threads waiting on a userspace condition variable.
+///
+/// If an invocation of this system call causes all waiting
+/// threads to be woken up, the value of the condition variable
+/// is set to [`CONDVAR_HAS_NO_WAITERS`](constant.CONDVAR_HAS_NO_WAITERS.html). As long as the condition
+/// variable is set to this value, it is not needed to invoke this
+/// system call.
+///
+/// ## Parameters
+///
+/// **condvar**:
+/// The userspace condition variable that has
+/// waiting threads.
+///
+/// **scope**:
+/// Whether the condition variable is stored in
+/// private or shared memory.
+///
+/// **nwaiters**:
+/// The number of threads that need to be woken
+/// up. If it exceeds the number of waiting
+/// threads, all threads are woken up.
+#[inline]
+pub unsafe fn condvar_signal(condvar_: *mut condvar, scope_: scope, nwaiters_: nthreads) -> errno {
+ cloudabi_sys_condvar_signal(condvar_, scope_, nwaiters_)
+}
+
+/// Closes a file descriptor.
+///
+/// ## Parameters
+///
+/// **fd**:
+/// The file descriptor that needs to be closed.
+#[inline]
+pub unsafe fn fd_close(fd_: fd) -> errno {
+ cloudabi_sys_fd_close(fd_)
+}
+
+/// Creates a file descriptor.
+///
+/// ## Parameters
+///
+/// **type**:
+/// Possible values:
+///
+/// - [`SHARED_MEMORY`](enum.filetype.html#variant.SHARED_MEMORY):
+/// Creates an anonymous shared memory
+/// object.
+///
+/// **fd**:
+/// The file descriptor that has been created.
+#[inline]
+pub unsafe fn fd_create1(type_: filetype, fd_: &mut fd) -> errno {
+ cloudabi_sys_fd_create1(type_, fd_)
+}
+
+/// Creates a pair of file descriptors.
+///
+/// ## Parameters
+///
+/// **type**:
+/// Possible values:
+///
+/// - [`SOCKET_DGRAM`](enum.filetype.html#variant.SOCKET_DGRAM):
+/// Creates a UNIX datagram socket pair.
+/// - [`SOCKET_STREAM`](enum.filetype.html#variant.SOCKET_STREAM):
+/// Creates a UNIX byte-stream socket
+/// pair.
+///
+/// **fd1**:
+/// The first file descriptor of the pair.
+///
+/// **fd2**:
+/// The second file descriptor of the pair.
+#[inline]
+pub unsafe fn fd_create2(type_: filetype, fd1_: &mut fd, fd2_: &mut fd) -> errno {
+ cloudabi_sys_fd_create2(type_, fd1_, fd2_)
+}
+
+/// Synchronizes the data of a file to disk.
+///
+/// ## Parameters
+///
+/// **fd**:
+/// The file descriptor of the file whose data
+/// needs to be synchronized to disk.
+#[inline]
+pub unsafe fn fd_datasync(fd_: fd) -> errno {
+ cloudabi_sys_fd_datasync(fd_)
+}
+
+/// Duplicates a file descriptor.
+///
+/// ## Parameters
+///
+/// **from**:
+/// The file descriptor that needs to be
+/// duplicated.
+///
+/// **fd**:
+/// The new file descriptor.
+#[inline]
+pub unsafe fn fd_dup(from_: fd, fd_: &mut fd) -> errno {
+ cloudabi_sys_fd_dup(from_, fd_)
+}
+
+/// Reads from a file descriptor, without using and updating the
+/// file descriptor's offset.
+///
+/// ## Parameters
+///
+/// **fd**:
+/// The file descriptor from which data should be
+/// read.
+///
+/// **iovs**:
+/// List of scatter/gather vectors where data
+/// should be stored.
+///
+/// **offset**:
+/// The offset within the file at which reading
+/// should start.
+///
+/// **nread**:
+/// The number of bytes read.
+#[inline]
+pub unsafe fn fd_pread(fd_: fd, iovs_: &[iovec], offset_: filesize, nread_: &mut usize) -> errno {
+ cloudabi_sys_fd_pread(fd_, iovs_.as_ptr(), iovs_.len(), offset_, nread_)
+}
+
+/// Writes to a file descriptor, without using and updating the
+/// file descriptor's offset.
+///
+/// ## Parameters
+///
+/// **fd**:
+/// The file descriptor to which data should be
+/// written.
+///
+/// **iovs**:
+/// List of scatter/gather vectors where data
+/// should be retrieved.
+///
+/// **offset**:
+/// The offset within the file at which writing
+/// should start.
+///
+/// **nwritten**:
+/// The number of bytes written.
+#[inline]
+pub unsafe fn fd_pwrite(fd_: fd, iovs_: &[ciovec], offset_: filesize, nwritten_: &mut usize) -> errno {
+ cloudabi_sys_fd_pwrite(fd_, iovs_.as_ptr(), iovs_.len(), offset_, nwritten_)
+}
+
+/// Reads from a file descriptor.
+///
+/// ## Parameters
+///
+/// **fd**:
+/// The file descriptor from which data should be
+/// read.
+///
+/// **iovs**:
+/// List of scatter/gather vectors where data
+/// should be stored.
+///
+/// **nread**:
+/// The number of bytes read.
+#[inline]
+pub unsafe fn fd_read(fd_: fd, iovs_: &[iovec], nread_: &mut usize) -> errno {
+ cloudabi_sys_fd_read(fd_, iovs_.as_ptr(), iovs_.len(), nread_)
+}
+
+/// Atomically replaces a file descriptor by a copy of another
+/// file descriptor.
+///
+/// Due to the strong focus on thread safety, this environment
+/// does not provide a mechanism to duplicate a file descriptor to
+/// an arbitrary number, like dup2(). This would be prone to race
+/// conditions, as an actual file descriptor with the same number
+/// could be allocated by a different thread at the same time.
+///
+/// This system call provides a way to atomically replace file
+/// descriptors, which would disappear if dup2() were to be
+/// removed entirely.
+///
+/// ## Parameters
+///
+/// **from**:
+/// The file descriptor that needs to be copied.
+///
+/// **to**:
+/// The file descriptor that needs to be
+/// overwritten.
+#[inline]
+pub unsafe fn fd_replace(from_: fd, to_: fd) -> errno {
+ cloudabi_sys_fd_replace(from_, to_)
+}
+
+/// Moves the offset of the file descriptor.
+///
+/// ## Parameters
+///
+/// **fd**:
+/// The file descriptor whose offset has to be
+/// moved.
+///
+/// **offset**:
+/// The number of bytes to move.
+///
+/// **whence**:
+/// Relative to which position the move should
+/// take place.
+///
+/// **newoffset**:
+/// The new offset of the file descriptor,
+/// relative to the start of the file.
+#[inline]
+pub unsafe fn fd_seek(fd_: fd, offset_: filedelta, whence_: whence, newoffset_: &mut filesize) -> errno {
+ cloudabi_sys_fd_seek(fd_, offset_, whence_, newoffset_)
+}
+
+/// Gets attributes of a file descriptor.
+///
+/// ## Parameters
+///
+/// **fd**:
+/// The file descriptor whose attributes have to
+/// be obtained.
+///
+/// **buf**:
+/// The buffer where the file descriptor's
+/// attributes are stored.
+#[inline]
+pub unsafe fn fd_stat_get(fd_: fd, buf_: *mut fdstat) -> errno {
+ cloudabi_sys_fd_stat_get(fd_, buf_)
+}
+
+/// Adjusts attributes of a file descriptor.
+///
+/// ## Parameters
+///
+/// **fd**:
+/// The file descriptor whose attributes have to
+/// be adjusted.
+///
+/// **buf**:
+/// The desired values of the file descriptor
+/// attributes that are adjusted.
+///
+/// **flags**:
+/// A bitmask indicating which attributes have to
+/// be adjusted.
+#[inline]
+pub unsafe fn fd_stat_put(fd_: fd, buf_: *const fdstat, flags_: fdsflags) -> errno {
+ cloudabi_sys_fd_stat_put(fd_, buf_, flags_)
+}
+
+/// Synchronizes the data and metadata of a file to disk.
+///
+/// ## Parameters
+///
+/// **fd**:
+/// The file descriptor of the file whose data
+/// and metadata needs to be synchronized to disk.
+#[inline]
+pub unsafe fn fd_sync(fd_: fd) -> errno {
+ cloudabi_sys_fd_sync(fd_)
+}
+
+/// Writes to a file descriptor.
+///
+/// ## Parameters
+///
+/// **fd**:
+/// The file descriptor to which data should be
+/// written.
+///
+/// **iovs**:
+/// List of scatter/gather vectors where data
+/// should be retrieved.
+///
+/// **nwritten**:
+/// The number of bytes written.
+#[inline]
+pub unsafe fn fd_write(fd_: fd, iovs_: &[ciovec], nwritten_: &mut usize) -> errno {
+ cloudabi_sys_fd_write(fd_, iovs_.as_ptr(), iovs_.len(), nwritten_)
+}
+
+/// Provides file advisory information on a file descriptor.
+///
+/// ## Parameters
+///
+/// **fd**:
+/// The file descriptor for which to provide file
+/// advisory information.
+///
+/// **offset**:
+/// The offset within the file to which the
+/// advisory applies.
+///
+/// **len**:
+/// The length of the region to which the advisory
+/// applies.
+///
+/// **advice**:
+/// The advice.
+#[inline]
+pub unsafe fn file_advise(fd_: fd, offset_: filesize, len_: filesize, advice_: advice) -> errno {
+ cloudabi_sys_file_advise(fd_, offset_, len_, advice_)
+}
+
+/// Forces the allocation of space in a file.
+///
+/// ## Parameters
+///
+/// **fd**:
+/// The file in which the space should be
+/// allocated.
+///
+/// **offset**:
+/// The offset at which the allocation should
+/// start.
+///
+/// **len**:
+/// The length of the area that is allocated.
+#[inline]
+pub unsafe fn file_allocate(fd_: fd, offset_: filesize, len_: filesize) -> errno {
+ cloudabi_sys_file_allocate(fd_, offset_, len_)
+}
+
+/// Creates a file of a specified type.
+///
+/// ## Parameters
+///
+/// **fd**:
+/// The working directory at which the resolution
+/// of the file to be created starts.
+///
+/// **path**:
+/// The path at which the file should be created.
+///
+/// **type**:
+/// Possible values:
+///
+/// - [`DIRECTORY`](enum.filetype.html#variant.DIRECTORY):
+/// Creates a directory.
+#[inline]
+pub unsafe fn file_create(fd_: fd, path_: &[u8], type_: filetype) -> errno {
+ cloudabi_sys_file_create(fd_, path_.as_ptr(), path_.len(), type_)
+}
+
+/// Creates a hard link.
+///
+/// ## Parameters
+///
+/// **fd1**:
+/// The working directory at which the resolution
+/// of the source path starts.
+///
+/// **path1**:
+/// The source path of the file that should be
+/// hard linked.
+///
+/// **fd2**:
+/// The working directory at which the resolution
+/// of the destination path starts.
+///
+/// **path2**:
+/// The destination path at which the hard link
+/// should be created.
+#[inline]
+pub unsafe fn file_link(fd1_: lookup, path1_: &[u8], fd2_: fd, path2_: &[u8]) -> errno {
+ cloudabi_sys_file_link(fd1_, path1_.as_ptr(), path1_.len(), fd2_, path2_.as_ptr(), path2_.len())
+}
+
+/// Opens a file.
+///
+/// ## Parameters
+///
+/// **dirfd**:
+/// The working directory at which the resolution
+/// of the file to be opened starts.
+///
+/// **path**:
+/// The path of the file that should be opened.
+///
+/// **oflags**:
+/// The method at which the file should be opened.
+///
+/// **fds**:
+/// [`fdstat.fs_rights_base`](struct.fdstat.html#structfield.fs_rights_base) and
+/// [`fdstat.fs_rights_inheriting`](struct.fdstat.html#structfield.fs_rights_inheriting) specify the
+/// initial rights of the newly created file
+/// descriptor. The operating system is allowed to
+/// return a file descriptor with fewer rights
+/// than specified, if and only if those rights do
+/// not apply to the type of file being opened.
+///
+/// [`fdstat.fs_flags`](struct.fdstat.html#structfield.fs_flags) specifies the initial flags
+/// of the file descriptor.
+///
+/// [`fdstat.fs_filetype`](struct.fdstat.html#structfield.fs_filetype) is ignored.
+///
+/// **fd**:
+/// The file descriptor of the file that has been
+/// opened.
+#[inline]
+pub unsafe fn file_open(dirfd_: lookup, path_: &[u8], oflags_: oflags, fds_: *const fdstat, fd_: &mut fd) -> errno {
+ cloudabi_sys_file_open(dirfd_, path_.as_ptr(), path_.len(), oflags_, fds_, fd_)
+}
+
+/// Reads directory entries from a directory.
+///
+/// When successful, the contents of the output buffer consist of
+/// a sequence of directory entries. Each directory entry consists
+/// of a [`dirent`](struct.dirent.html) object, followed by [`dirent.d_namlen`](struct.dirent.html#structfield.d_namlen) bytes
+/// holding the name of the directory entry.
+///
+/// This system call fills the output buffer as much as possible,
+/// potentially truncating the last directory entry. This allows
+/// the caller to grow its read buffer size in case it's too small
+/// to fit a single large directory entry, or skip the oversized
+/// directory entry.
+///
+/// ## Parameters
+///
+/// **fd**:
+/// The directory from which to read the directory
+/// entries.
+///
+/// **buf**:
+/// The buffer where directory entries are stored.
+///
+/// **cookie**:
+/// The location within the directory to start
+/// reading.
+///
+/// **bufused**:
+/// The number of bytes stored in the read buffer.
+/// If less than the size of the read buffer, the
+/// end of the directory has been reached.
+#[inline]
+pub unsafe fn file_readdir(fd_: fd, buf_: &mut [u8], cookie_: dircookie, bufused_: &mut usize) -> errno {
+ cloudabi_sys_file_readdir(fd_, buf_.as_mut_ptr() as *mut (), buf_.len(), cookie_, bufused_)
+}
+
+/// Reads the contents of a symbolic link.
+///
+/// ## Parameters
+///
+/// **fd**:
+/// The working directory at which the resolution
+/// of the path of the symbolic starts.
+///
+/// **path**:
+/// The path of the symbolic link whose contents
+/// should be read.
+///
+/// **buf**:
+/// The buffer where the contents of the symbolic
+/// link should be stored.
+///
+/// **bufused**:
+/// The number of bytes placed in the buffer.
+#[inline]
+pub unsafe fn file_readlink(fd_: fd, path_: &[u8], buf_: &mut [u8], bufused_: &mut usize) -> errno {
+ cloudabi_sys_file_readlink(fd_, path_.as_ptr(), path_.len(), buf_.as_mut_ptr(), buf_.len(), bufused_)
+}
+
+/// Renames a file.
+///
+/// ## Parameters
+///
+/// **fd1**:
+/// The working directory at which the resolution
+/// of the source path starts.
+///
+/// **path1**:
+/// The source path of the file that should be
+/// renamed.
+///
+/// **fd2**:
+/// The working directory at which the resolution
+/// of the destination path starts.
+///
+/// **path2**:
+/// The destination path to which the file should
+/// be renamed.
+#[inline]
+pub unsafe fn file_rename(fd1_: fd, path1_: &[u8], fd2_: fd, path2_: &[u8]) -> errno {
+ cloudabi_sys_file_rename(fd1_, path1_.as_ptr(), path1_.len(), fd2_, path2_.as_ptr(), path2_.len())
+}
+
+/// Gets attributes of a file by file descriptor.
+///
+/// ## Parameters
+///
+/// **fd**:
+/// The file descriptor whose attributes have to
+/// be obtained.
+///
+/// **buf**:
+/// The buffer where the file's attributes are
+/// stored.
+#[inline]
+pub unsafe fn file_stat_fget(fd_: fd, buf_: *mut filestat) -> errno {
+ cloudabi_sys_file_stat_fget(fd_, buf_)
+}
+
+/// Adjusts attributes of a file by file descriptor.
+///
+/// ## Parameters
+///
+/// **fd**:
+/// The file descriptor whose attributes have to
+/// be adjusted.
+///
+/// **buf**:
+/// The desired values of the file attributes that
+/// are adjusted.
+///
+/// **flags**:
+/// A bitmask indicating which attributes have to
+/// be adjusted.
+#[inline]
+pub unsafe fn file_stat_fput(fd_: fd, buf_: *const filestat, flags_: fsflags) -> errno {
+ cloudabi_sys_file_stat_fput(fd_, buf_, flags_)
+}
+
+/// Gets attributes of a file by path.
+///
+/// ## Parameters
+///
+/// **fd**:
+/// The working directory at which the resolution
+/// of the path whose attributes have to be
+/// obtained starts.
+///
+/// **path**:
+/// The path of the file whose attributes have to
+/// be obtained.
+///
+/// **buf**:
+/// The buffer where the file's attributes are
+/// stored.
+#[inline]
+pub unsafe fn file_stat_get(fd_: lookup, path_: &[u8], buf_: *mut filestat) -> errno {
+ cloudabi_sys_file_stat_get(fd_, path_.as_ptr(), path_.len(), buf_)
+}
+
+/// Adjusts attributes of a file by path.
+///
+/// ## Parameters
+///
+/// **fd**:
+/// The working directory at which the resolution
+/// of the path whose attributes have to be
+/// adjusted starts.
+///
+/// **path**:
+/// The path of the file whose attributes have to
+/// be adjusted.
+///
+/// **buf**:
+/// The desired values of the file attributes that
+/// are adjusted.
+///
+/// **flags**:
+/// A bitmask indicating which attributes have to
+/// be adjusted.
+#[inline]
+pub unsafe fn file_stat_put(fd_: lookup, path_: &[u8], buf_: *const filestat, flags_: fsflags) -> errno {
+ cloudabi_sys_file_stat_put(fd_, path_.as_ptr(), path_.len(), buf_, flags_)
+}
+
+/// Creates a symbolic link.
+///
+/// ## Parameters
+///
+/// **path1**:
+/// The contents of the symbolic link.
+///
+/// **fd**:
+/// The working directory at which the resolution
+/// of the destination path starts.
+///
+/// **path2**:
+/// The destination path at which the symbolic
+/// link should be created.
+#[inline]
+pub unsafe fn file_symlink(path1_: &[u8], fd_: fd, path2_: &[u8]) -> errno {
+ cloudabi_sys_file_symlink(path1_.as_ptr(), path1_.len(), fd_, path2_.as_ptr(), path2_.len())
+}
+
+/// Unlinks a file, or removes a directory.
+///
+/// ## Parameters
+///
+/// **fd**:
+/// The working directory at which the resolution
+/// of the path starts.
+///
+/// **path**:
+/// The path that needs to be unlinked or removed.
+///
+/// **flags**:
+/// Possible values:
+///
+/// - [`REMOVEDIR`](struct.ulflags.html#associatedconstant.REMOVEDIR):
+/// If set, attempt to remove a directory.
+/// Otherwise, unlink a file.
+#[inline]
+pub unsafe fn file_unlink(fd_: fd, path_: &[u8], flags_: ulflags) -> errno {
+ cloudabi_sys_file_unlink(fd_, path_.as_ptr(), path_.len(), flags_)
+}
+
+/// Unlocks a write-locked userspace lock.
+///
+/// If a userspace lock is unlocked while having its
+/// [`LOCK_KERNEL_MANAGED`](constant.LOCK_KERNEL_MANAGED.html) flag set, the lock cannot be unlocked in
+/// userspace directly. This system call needs to be performed
+/// instead, so that any waiting threads can be woken up.
+///
+/// To prevent spurious invocations of this system call, the lock
+/// must be locked for writing. This prevents other threads from
+/// acquiring additional read locks while the system call is in
+/// progress. If the lock is acquired for reading, it must first
+/// be upgraded to a write lock.
+///
+/// ## Parameters
+///
+/// **lock**:
+/// The userspace lock that is locked for writing
+/// by the calling thread.
+///
+/// **scope**:
+/// Whether the lock is stored in private or
+/// shared memory.
+#[inline]
+pub unsafe fn lock_unlock(lock_: *mut lock, scope_: scope) -> errno {
+ cloudabi_sys_lock_unlock(lock_, scope_)
+}
+
+/// Provides memory advisory information on a region of memory.
+///
+/// ## Parameters
+///
+/// **mapping**:
+/// The pages for which to provide memory advisory
+/// information.
+///
+/// **advice**:
+/// The advice.
+#[inline]
+pub unsafe fn mem_advise(mapping_: &mut [u8], advice_: advice) -> errno {
+ cloudabi_sys_mem_advise(mapping_.as_mut_ptr() as *mut (), mapping_.len(), advice_)
+}
+
+/// Creates a memory mapping, making the contents of a file
+/// accessible through memory.
+///
+/// ## Parameters
+///
+/// **addr**:
+/// If [`FIXED`](struct.mflags.html#associatedconstant.FIXED) is set, specifies to which
+/// address the file region is mapped. Otherwise,
+/// the mapping is performed at an unused
+/// location.
+///
+/// **len**:
+/// The length of the memory mapping to be
+/// created.
+///
+/// **prot**:
+/// Initial memory protection options for the
+/// memory mapping.
+///
+/// **flags**:
+/// Memory mapping flags.
+///
+/// **fd**:
+/// If [`ANON`](struct.mflags.html#associatedconstant.ANON) is set, this argument must be
+/// [`MAP_ANON_FD`](constant.MAP_ANON_FD.html). Otherwise, this argument
+/// specifies the file whose contents need to be
+/// mapped.
+///
+/// **off**:
+/// If [`ANON`](struct.mflags.html#associatedconstant.ANON) is set, this argument must be
+/// zero. Otherwise, this argument specifies the
+/// offset within the file at which the mapping
+/// starts.
+///
+/// **mem**:
+/// The starting address of the memory mapping.
+#[inline]
+pub unsafe fn mem_map(addr_: *mut (), len_: usize, prot_: mprot, flags_: mflags, fd_: fd, off_: filesize, mem_: &mut *mut ()) -> errno {
+ cloudabi_sys_mem_map(addr_, len_, prot_, flags_, fd_, off_, mem_)
+}
+
+/// Change the protection of a memory mapping.
+///
+/// ## Parameters
+///
+/// **mapping**:
+/// The pages that need their protection changed.
+///
+/// **prot**:
+/// New protection options.
+#[inline]
+pub unsafe fn mem_protect(mapping_: &mut [u8], prot_: mprot) -> errno {
+ cloudabi_sys_mem_protect(mapping_.as_mut_ptr() as *mut (), mapping_.len(), prot_)
+}
+
+/// Synchronize a region of memory with its physical storage.
+///
+/// ## Parameters
+///
+/// **mapping**:
+/// The pages that need to be synchronized.
+///
+/// **flags**:
+/// The method of synchronization.
+#[inline]
+pub unsafe fn mem_sync(mapping_: &mut [u8], flags_: msflags) -> errno {
+ cloudabi_sys_mem_sync(mapping_.as_mut_ptr() as *mut (), mapping_.len(), flags_)
+}
+
+/// Unmaps a region of memory.
+///
+/// ## Parameters
+///
+/// **mapping**:
+/// The pages that needs to be unmapped.
+#[inline]
+pub unsafe fn mem_unmap(mapping_: &mut [u8]) -> errno {
+ cloudabi_sys_mem_unmap(mapping_.as_mut_ptr() as *mut (), mapping_.len())
+}
+
+/// Concurrently polls for the occurrence of a set of events.
+///
+/// ## Parameters
+///
+/// **in**:
+/// The events to which to subscribe.
+///
+/// **out**:
+/// The events that have occurred.
+///
+/// **nsubscriptions**:
+/// Both the number of subscriptions and events.
+///
+/// **nevents**:
+/// The number of events stored.
+#[inline]
+pub unsafe fn poll(in_: *const subscription, out_: *mut event, nsubscriptions_: usize, nevents_: &mut usize) -> errno {
+ cloudabi_sys_poll(in_, out_, nsubscriptions_, nevents_)
+}
+
+/// Replaces the process by a new executable.
+///
+/// Process execution in CloudABI differs from POSIX in two ways:
+/// handling of arguments and inheritance of file descriptors.
+///
+/// CloudABI does not use string command line arguments. Instead,
+/// a buffer with binary data is copied into the address space of
+/// the new executable. The kernel does not enforce any specific
+/// structure to this data, although CloudABI's C library uses it
+/// to store a tree structure that is semantically identical to
+/// YAML.
+///
+/// Due to the strong focus on thread safety, file descriptors
+/// aren't inherited through close-on-exec flags. An explicit
+/// list of file descriptors that need to be retained needs to be
+/// provided. After execution, file descriptors are placed in the
+/// order in which they are stored in the array. This not only
+/// makes the execution process deterministic. It also prevents
+/// potential information disclosures about the layout of the
+/// original process.
+///
+/// ## Parameters
+///
+/// **fd**:
+/// A file descriptor of the new executable.
+///
+/// **data**:
+/// Binary argument data that is passed on to the
+/// new executable.
+///
+/// **fds**:
+/// The layout of the file descriptor table after
+/// execution.
+#[inline]
+pub unsafe fn proc_exec(fd_: fd, data_: &[u8], fds_: &[fd]) -> errno {
+ cloudabi_sys_proc_exec(fd_, data_.as_ptr() as *const (), data_.len(), fds_.as_ptr(), fds_.len())
+}
+
+/// Terminates the process normally.
+///
+/// ## Parameters
+///
+/// **rval**:
+/// The exit code returned by the process. The
+/// exit code can be obtained by other processes
+/// through [`event.union.proc_terminate.exitcode`](struct.event_proc_terminate.html#structfield.exitcode).
+#[inline]
+pub unsafe fn proc_exit(rval_: exitcode) -> ! {
+ cloudabi_sys_proc_exit(rval_)
+}
+
+/// Forks the process of the calling thread.
+///
+/// After forking, a new process shall be created, having only a
+/// copy of the calling thread. The parent process will obtain a
+/// process descriptor. When closed, the child process is
+/// automatically signaled with [`KILL`](enum.signal.html#variant.KILL).
+///
+/// ## Parameters
+///
+/// **fd**:
+/// In the parent process: the file descriptor
+/// number of the process descriptor.
+///
+/// In the child process: [`PROCESS_CHILD`](constant.PROCESS_CHILD.html).
+///
+/// **tid**:
+/// In the parent process: undefined.
+///
+/// In the child process: the thread ID of the
+/// initial thread of the child process.
+#[inline]
+pub unsafe fn proc_fork(fd_: &mut fd, tid_: &mut tid) -> errno {
+ cloudabi_sys_proc_fork(fd_, tid_)
+}
+
+/// Sends a signal to the process of the calling thread.
+///
+/// ## Parameters
+///
+/// **sig**:
+/// The signal condition that should be triggered.
+/// If the signal causes the process to terminate,
+/// its condition can be obtained by other
+/// processes through
+/// [`event.union.proc_terminate.signal`](struct.event_proc_terminate.html#structfield.signal).
+#[inline]
+pub unsafe fn proc_raise(sig_: signal) -> errno {
+ cloudabi_sys_proc_raise(sig_)
+}
+
+/// Obtains random data from the kernel random number generator.
+///
+/// As this interface is not guaranteed to be fast, it is advised
+/// that the random data obtained through this system call is used
+/// as the seed for a userspace pseudo-random number generator.
+///
+/// ## Parameters
+///
+/// **buf**:
+/// The buffer that needs to be filled with random
+/// data.
+#[inline]
+pub unsafe fn random_get(buf_: &mut [u8]) -> errno {
+ cloudabi_sys_random_get(buf_.as_mut_ptr() as *mut (), buf_.len())
+}
+
+/// Receives a message on a socket.
+///
+/// ## Parameters
+///
+/// **sock**:
+/// The socket on which a message should be
+/// received.
+///
+/// **in**:
+/// Input parameters.
+///
+/// **out**:
+/// Output parameters.
+#[inline]
+pub unsafe fn sock_recv(sock_: fd, in_: *const recv_in, out_: *mut recv_out) -> errno {
+ cloudabi_sys_sock_recv(sock_, in_, out_)
+}
+
+/// Sends a message on a socket.
+///
+/// ## Parameters
+///
+/// **sock**:
+/// The socket on which a message should be sent.
+///
+/// **in**:
+/// Input parameters.
+///
+/// **out**:
+/// Output parameters.
+#[inline]
+pub unsafe fn sock_send(sock_: fd, in_: *const send_in, out_: *mut send_out) -> errno {
+ cloudabi_sys_sock_send(sock_, in_, out_)
+}
+
+/// Shuts down socket send and receive channels.
+///
+/// ## Parameters
+///
+/// **sock**:
+/// The socket that needs its channels shut down.
+///
+/// **how**:
+/// Which channels on the socket need to be shut
+/// down.
+#[inline]
+pub unsafe fn sock_shutdown(sock_: fd, how_: sdflags) -> errno {
+ cloudabi_sys_sock_shutdown(sock_, how_)
+}
+
+/// Creates a new thread within the current process.
+///
+/// ## Parameters
+///
+/// **attr**:
+/// The desired attributes of the new thread.
+///
+/// **tid**:
+/// The thread ID of the new thread.
+#[inline]
+pub unsafe fn thread_create(attr_: *mut threadattr, tid_: &mut tid) -> errno {
+ cloudabi_sys_thread_create(attr_, tid_)
+}
+
+/// Terminates the calling thread.
+///
+/// This system call can also unlock a single userspace lock
+/// after termination, which can be used to implement thread
+/// joining.
+///
+/// ## Parameters
+///
+/// **lock**:
+/// Userspace lock that is locked for writing by
+/// the calling thread.
+///
+/// **scope**:
+/// Whether the lock is stored in private or
+/// shared memory.
+#[inline]
+pub unsafe fn thread_exit(lock_: *mut lock, scope_: scope) -> ! {
+ cloudabi_sys_thread_exit(lock_, scope_)
+}
+
+/// Temporarily yields execution of the calling thread.
+#[inline]
+pub unsafe fn thread_yield() -> errno {
+ cloudabi_sys_thread_yield()
+}
diff --git a/src/libstd/sys/cloudabi/abi/mod.rs b/src/libstd/sys/cloudabi/abi/mod.rs
new file mode 100644
index 0000000..81a4d29
--- /dev/null
+++ b/src/libstd/sys/cloudabi/abi/mod.rs
@@ -0,0 +1,13 @@
+// Copyright 2018 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#[allow(warnings)]
+mod cloudabi;
+pub use self::cloudabi::*;
diff --git a/src/libstd/sys/cloudabi/args.rs b/src/libstd/sys/cloudabi/args.rs
new file mode 100644
index 0000000..7b62cc6
--- /dev/null
+++ b/src/libstd/sys/cloudabi/args.rs
@@ -0,0 +1,17 @@
+// Copyright 2018 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+pub use sys::cloudabi::shims::args::*;
+
+#[allow(dead_code)]
+pub fn init(_: isize, _: *const *const u8) {}
+
+#[allow(dead_code)]
+pub fn cleanup() {}
diff --git a/src/libstd/sys/cloudabi/backtrace.rs b/src/libstd/sys/cloudabi/backtrace.rs
new file mode 100644
index 0000000..33d9317
--- /dev/null
+++ b/src/libstd/sys/cloudabi/backtrace.rs
@@ -0,0 +1,121 @@
+// Copyright 2014-2018 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use error::Error;
+use ffi::CStr;
+use intrinsics;
+use io;
+use libc;
+use sys_common::backtrace::Frame;
+use unwind as uw;
+
+pub struct BacktraceContext;
+
+struct Context<'a> {
+ idx: usize,
+ frames: &'a mut [Frame],
+}
+
+#[derive(Debug)]
+struct UnwindError(uw::_Unwind_Reason_Code);
+
+impl Error for UnwindError {
+ fn description(&self) -> &'static str {
+ "unexpected return value while unwinding"
+ }
+}
+
+impl ::fmt::Display for UnwindError {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ write!(f, "{}: {:?}", self.description(), self.0)
+ }
+}
+
+#[inline(never)] // if we know this is a function call, we can skip it when
+ // tracing
+pub fn unwind_backtrace(frames: &mut [Frame]) -> io::Result<(usize, BacktraceContext)> {
+ let mut cx = Context { idx: 0, frames };
+ let result_unwind =
+ unsafe { uw::_Unwind_Backtrace(trace_fn, &mut cx as *mut Context as *mut libc::c_void) };
+ // See libunwind:src/unwind/Backtrace.c for the return values.
+ // No, there is no doc.
+ match result_unwind {
+ // These return codes seem to be benign and need to be ignored for backtraces
+ // to show up properly on all tested platforms.
+ uw::_URC_END_OF_STACK | uw::_URC_FATAL_PHASE1_ERROR | uw::_URC_FAILURE => {
+ Ok((cx.idx, BacktraceContext))
+ }
+ _ => Err(io::Error::new(
+ io::ErrorKind::Other,
+ UnwindError(result_unwind),
+ )),
+ }
+}
+
+extern "C" fn trace_fn(
+ ctx: *mut uw::_Unwind_Context,
+ arg: *mut libc::c_void,
+) -> uw::_Unwind_Reason_Code {
+ let cx = unsafe { &mut *(arg as *mut Context) };
+ let mut ip_before_insn = 0;
+ let mut ip = unsafe { uw::_Unwind_GetIPInfo(ctx, &mut ip_before_insn) as *mut libc::c_void };
+ if !ip.is_null() && ip_before_insn == 0 {
+ // this is a non-signaling frame, so `ip` refers to the address
+ // after the calling instruction. account for that.
+ ip = (ip as usize - 1) as *mut _;
+ }
+
+ let symaddr = unsafe { uw::_Unwind_FindEnclosingFunction(ip) };
+ if cx.idx < cx.frames.len() {
+ cx.frames[cx.idx] = Frame {
+ symbol_addr: symaddr as *mut u8,
+ exact_position: ip as *mut u8,
+ };
+ cx.idx += 1;
+ }
+
+ uw::_URC_NO_REASON
+}
+
+pub fn foreach_symbol_fileline<F>(_: Frame, _: F, _: &BacktraceContext) -> io::Result<bool>
+where
+ F: FnMut(&[u8], u32) -> io::Result<()>,
+{
+ // No way to obtain this information on CloudABI.
+ Ok(false)
+}
+
+pub fn resolve_symname<F>(frame: Frame, callback: F, _: &BacktraceContext) -> io::Result<()>
+where
+ F: FnOnce(Option<&str>) -> io::Result<()>,
+{
+ unsafe {
+ let mut info: Dl_info = intrinsics::init();
+ let symname =
+ if dladdr(frame.exact_position as *mut _, &mut info) == 0 || info.dli_sname.is_null() {
+ None
+ } else {
+ CStr::from_ptr(info.dli_sname).to_str().ok()
+ };
+ callback(symname)
+ }
+}
+
+#[repr(C)]
+struct Dl_info {
+ dli_fname: *const libc::c_char,
+ dli_fbase: *mut libc::c_void,
+ dli_sname: *const libc::c_char,
+ dli_saddr: *mut libc::c_void,
+}
+
+extern "C" {
+ fn dladdr(addr: *const libc::c_void, info: *mut Dl_info) -> libc::c_int;
+}
diff --git a/src/libstd/sys/cloudabi/condvar.rs b/src/libstd/sys/cloudabi/condvar.rs
new file mode 100644
index 0000000..c05c837
--- /dev/null
+++ b/src/libstd/sys/cloudabi/condvar.rs
@@ -0,0 +1,169 @@
+// Copyright 2018 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use cell::UnsafeCell;
+use mem;
+use sync::atomic::{AtomicU32, Ordering};
+use sys::cloudabi::abi;
+use sys::mutex::{self, Mutex};
+use sys::time::dur2intervals;
+use time::Duration;
+
+extern "C" {
+ #[thread_local]
+ static __pthread_thread_id: abi::tid;
+}
+
+pub struct Condvar {
+ condvar: UnsafeCell<AtomicU32>,
+}
+
+unsafe impl Send for Condvar {}
+unsafe impl Sync for Condvar {}
+
+impl Condvar {
+ pub const fn new() -> Condvar {
+ Condvar {
+ condvar: UnsafeCell::new(AtomicU32::new(abi::CONDVAR_HAS_NO_WAITERS.0)),
+ }
+ }
+
+ pub unsafe fn init(&mut self) {}
+
+ pub unsafe fn notify_one(&self) {
+ let condvar = self.condvar.get();
+ if (*condvar).load(Ordering::Relaxed) != abi::CONDVAR_HAS_NO_WAITERS.0 {
+ let ret = abi::condvar_signal(condvar as *mut abi::condvar, abi::scope::PRIVATE, 1);
+ assert_eq!(
+ ret,
+ abi::errno::SUCCESS,
+ "Failed to signal on condition variable"
+ );
+ }
+ }
+
+ pub unsafe fn notify_all(&self) {
+ let condvar = self.condvar.get();
+ if (*condvar).load(Ordering::Relaxed) != abi::CONDVAR_HAS_NO_WAITERS.0 {
+ let ret = abi::condvar_signal(
+ condvar as *mut abi::condvar,
+ abi::scope::PRIVATE,
+ abi::nthreads::max_value(),
+ );
+ assert_eq!(
+ ret,
+ abi::errno::SUCCESS,
+ "Failed to broadcast on condition variable"
+ );
+ }
+ }
+
+ pub unsafe fn wait(&self, mutex: &Mutex) {
+ let mutex = mutex::raw(mutex);
+ assert_eq!(
+ (*mutex).load(Ordering::Relaxed) & !abi::LOCK_KERNEL_MANAGED.0,
+ __pthread_thread_id.0 | abi::LOCK_WRLOCKED.0,
+ "This lock is not write-locked by this thread"
+ );
+
+ // Call into the kernel to wait on the condition variable.
+ let condvar = self.condvar.get();
+ let subscription = abi::subscription {
+ type_: abi::eventtype::CONDVAR,
+ union: abi::subscription_union {
+ condvar: abi::subscription_condvar {
+ condvar: condvar as *mut abi::condvar,
+ condvar_scope: abi::scope::PRIVATE,
+ lock: mutex as *mut abi::lock,
+ lock_scope: abi::scope::PRIVATE,
+ },
+ },
+ ..mem::zeroed()
+ };
+ let mut event: abi::event = mem::uninitialized();
+ let mut nevents: usize = mem::uninitialized();
+ let ret = abi::poll(&subscription, &mut event, 1, &mut nevents);
+ assert_eq!(
+ ret,
+ abi::errno::SUCCESS,
+ "Failed to wait on condition variable"
+ );
+ assert_eq!(
+ event.error,
+ abi::errno::SUCCESS,
+ "Failed to wait on condition variable"
+ );
+ }
+
+ pub unsafe fn wait_timeout(&self, mutex: &Mutex, dur: Duration) -> bool {
+ let mutex = mutex::raw(mutex);
+ assert_eq!(
+ (*mutex).load(Ordering::Relaxed) & !abi::LOCK_KERNEL_MANAGED.0,
+ __pthread_thread_id.0 | abi::LOCK_WRLOCKED.0,
+ "This lock is not write-locked by this thread"
+ );
+
+ // Call into the kernel to wait on the condition variable.
+ let condvar = self.condvar.get();
+ let subscriptions = [
+ abi::subscription {
+ type_: abi::eventtype::CONDVAR,
+ union: abi::subscription_union {
+ condvar: abi::subscription_condvar {
+ condvar: condvar as *mut abi::condvar,
+ condvar_scope: abi::scope::PRIVATE,
+ lock: mutex as *mut abi::lock,
+ lock_scope: abi::scope::PRIVATE,
+ },
+ },
+ ..mem::zeroed()
+ },
+ abi::subscription {
+ type_: abi::eventtype::CLOCK,
+ union: abi::subscription_union {
+ clock: abi::subscription_clock {
+ clock_id: abi::clockid::MONOTONIC,
+ timeout: dur2intervals(&dur),
+ ..mem::zeroed()
+ },
+ },
+ ..mem::zeroed()
+ },
+ ];
+ let mut events: [abi::event; 2] = mem::uninitialized();
+ let mut nevents: usize = mem::uninitialized();
+ let ret = abi::poll(subscriptions.as_ptr(), events.as_mut_ptr(), 2, &mut nevents);
+ assert_eq!(
+ ret,
+ abi::errno::SUCCESS,
+ "Failed to wait on condition variable"
+ );
+ for i in 0..nevents {
+ assert_eq!(
+ events[i].error,
+ abi::errno::SUCCESS,
+ "Failed to wait on condition variable"
+ );
+ if events[i].type_ == abi::eventtype::CONDVAR {
+ return true;
+ }
+ }
+ false
+ }
+
+ pub unsafe fn destroy(&self) {
+ let condvar = self.condvar.get();
+ assert_eq!(
+ (*condvar).load(Ordering::Relaxed),
+ abi::CONDVAR_HAS_NO_WAITERS.0,
+ "Attempted to destroy a condition variable with blocked threads"
+ );
+ }
+}
diff --git a/src/libstd/sys/cloudabi/mod.rs b/src/libstd/sys/cloudabi/mod.rs
new file mode 100644
index 0000000..9e943c1
--- /dev/null
+++ b/src/libstd/sys/cloudabi/mod.rs
@@ -0,0 +1,76 @@
+// Copyright 2018 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use io;
+use libc;
+use mem;
+
+pub mod args;
+#[cfg(feature = "backtrace")]
+pub mod backtrace;
+#[path = "../unix/cmath.rs"]
+pub mod cmath;
+pub mod condvar;
+#[path = "../unix/memchr.rs"]
+pub mod memchr;
+pub mod mutex;
+pub mod os;
+#[path = "../unix/os_str.rs"]
+pub mod os_str;
+pub mod rwlock;
+pub mod stack_overflow;
+pub mod stdio;
+pub mod thread;
+#[path = "../unix/thread_local.rs"]
+pub mod thread_local;
+pub mod time;
+
+mod abi;
+
+mod shims;
+pub use self::shims::*;
+
+#[allow(dead_code)]
+pub fn init() {}
+
+pub fn decode_error_kind(errno: i32) -> io::ErrorKind {
+ match errno {
+ x if x == abi::errno::ACCES as i32 => io::ErrorKind::PermissionDenied,
+ x if x == abi::errno::ADDRINUSE as i32 => io::ErrorKind::AddrInUse,
+ x if x == abi::errno::ADDRNOTAVAIL as i32 => io::ErrorKind::AddrNotAvailable,
+ x if x == abi::errno::AGAIN as i32 => io::ErrorKind::WouldBlock,
+ x if x == abi::errno::CONNABORTED as i32 => io::ErrorKind::ConnectionAborted,
+ x if x == abi::errno::CONNREFUSED as i32 => io::ErrorKind::ConnectionRefused,
+ x if x == abi::errno::CONNRESET as i32 => io::ErrorKind::ConnectionReset,
+ x if x == abi::errno::EXIST as i32 => io::ErrorKind::AlreadyExists,
+ x if x == abi::errno::INTR as i32 => io::ErrorKind::Interrupted,
+ x if x == abi::errno::INVAL as i32 => io::ErrorKind::InvalidInput,
+ x if x == abi::errno::NOENT as i32 => io::ErrorKind::NotFound,
+ x if x == abi::errno::NOTCONN as i32 => io::ErrorKind::NotConnected,
+ x if x == abi::errno::PERM as i32 => io::ErrorKind::PermissionDenied,
+ x if x == abi::errno::PIPE as i32 => io::ErrorKind::BrokenPipe,
+ x if x == abi::errno::TIMEDOUT as i32 => io::ErrorKind::TimedOut,
+ _ => io::ErrorKind::Other,
+ }
+}
+
+pub unsafe fn abort_internal() -> ! {
+ ::core::intrinsics::abort();
+}
+
+pub use libc::strlen;
+
+pub fn hashmap_random_keys() -> (u64, u64) {
+ unsafe {
+ let mut v = mem::uninitialized();
+ libc::arc4random_buf(&mut v as *mut _ as *mut libc::c_void, mem::size_of_val(&v));
+ v
+ }
+}
diff --git a/src/libstd/sys/cloudabi/mutex.rs b/src/libstd/sys/cloudabi/mutex.rs
new file mode 100644
index 0000000..d4ba6bc
--- /dev/null
+++ b/src/libstd/sys/cloudabi/mutex.rs
@@ -0,0 +1,158 @@
+// Copyright 2018 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use cell::UnsafeCell;
+use mem;
+use sync::atomic::{AtomicU32, Ordering};
+use sys::cloudabi::abi;
+use sys::rwlock::{self, RWLock};
+
+extern "C" {
+ #[thread_local]
+ static __pthread_thread_id: abi::tid;
+}
+
+// Implement Mutex using an RWLock. This doesn't introduce any
+// performance overhead in this environment, as the operations would be
+// implemented identically.
+pub struct Mutex(RWLock);
+
+pub unsafe fn raw(m: &Mutex) -> *mut AtomicU32 {
+ rwlock::raw(&m.0)
+}
+
+impl Mutex {
+ pub const fn new() -> Mutex {
+ Mutex(RWLock::new())
+ }
+
+ pub unsafe fn init(&mut self) {
+ // This function should normally reinitialize the mutex after
+ // moving it to a different memory address. This implementation
+ // does not require adjustments after moving.
+ }
+
+ pub unsafe fn try_lock(&self) -> bool {
+ self.0.try_write()
+ }
+
+ pub unsafe fn lock(&self) {
+ self.0.write()
+ }
+
+ pub unsafe fn unlock(&self) {
+ self.0.write_unlock()
+ }
+
+ pub unsafe fn destroy(&self) {
+ self.0.destroy()
+ }
+}
+
+pub struct ReentrantMutex {
+ lock: UnsafeCell<AtomicU32>,
+ recursion: UnsafeCell<u32>,
+}
+
+impl ReentrantMutex {
+ pub unsafe fn uninitialized() -> ReentrantMutex {
+ mem::uninitialized()
+ }
+
+ pub unsafe fn init(&mut self) {
+ self.lock = UnsafeCell::new(AtomicU32::new(abi::LOCK_UNLOCKED.0));
+ self.recursion = UnsafeCell::new(0);
+ }
+
+ pub unsafe fn try_lock(&self) -> bool {
+ // Attempt to acquire the lock.
+ let lock = self.lock.get();
+ let recursion = self.recursion.get();
+ if let Err(old) = (*lock).compare_exchange(
+ abi::LOCK_UNLOCKED.0,
+ __pthread_thread_id.0 | abi::LOCK_WRLOCKED.0,
+ Ordering::Acquire,
+ Ordering::Relaxed,
+ ) {
+ // If we fail to acquire the lock, it may be the case
+ // that we've already acquired it and may need to recurse.
+ if old & !abi::LOCK_KERNEL_MANAGED.0 == __pthread_thread_id.0 | abi::LOCK_WRLOCKED.0 {
+ *recursion += 1;
+ true
+ } else {
+ false
+ }
+ } else {
+ // Success.
+ assert_eq!(*recursion, 0, "Mutex has invalid recursion count");
+ true
+ }
+ }
+
+ pub unsafe fn lock(&self) {
+ if !self.try_lock() {
+ // Call into the kernel to acquire a write lock.
+ let lock = self.lock.get();
+ let subscription = abi::subscription {
+ type_: abi::eventtype::LOCK_WRLOCK,
+ union: abi::subscription_union {
+ lock: abi::subscription_lock {
+ lock: lock as *mut abi::lock,
+ lock_scope: abi::scope::PRIVATE,
+ },
+ },
+ ..mem::zeroed()
+ };
+ let mut event: abi::event = mem::uninitialized();
+ let mut nevents: usize = mem::uninitialized();
+ let ret = abi::poll(&subscription, &mut event, 1, &mut nevents);
+ assert_eq!(ret, abi::errno::SUCCESS, "Failed to acquire mutex");
+ assert_eq!(event.error, abi::errno::SUCCESS, "Failed to acquire mutex");
+ }
+ }
+
+ pub unsafe fn unlock(&self) {
+ let lock = self.lock.get();
+ let recursion = self.recursion.get();
+ assert_eq!(
+ (*lock).load(Ordering::Relaxed) & !abi::LOCK_KERNEL_MANAGED.0,
+ __pthread_thread_id.0 | abi::LOCK_WRLOCKED.0,
+ "This mutex is locked by a different thread"
+ );
+
+ if *recursion > 0 {
+ *recursion -= 1;
+ } else if !(*lock)
+ .compare_exchange(
+ __pthread_thread_id.0 | abi::LOCK_WRLOCKED.0,
+ abi::LOCK_UNLOCKED.0,
+ Ordering::Release,
+ Ordering::Relaxed,
+ )
+ .is_ok()
+ {
+ // Lock is managed by kernelspace. Call into the kernel
+ // to unblock waiting threads.
+ let ret = abi::lock_unlock(lock as *mut abi::lock, abi::scope::PRIVATE);
+ assert_eq!(ret, abi::errno::SUCCESS, "Failed to unlock a mutex");
+ }
+ }
+
+ pub unsafe fn destroy(&self) {
+ let lock = self.lock.get();
+ let recursion = self.recursion.get();
+ assert_eq!(
+ (*lock).load(Ordering::Relaxed),
+ abi::LOCK_UNLOCKED.0,
+ "Attempted to destroy locked mutex"
+ );
+ assert_eq!(*recursion, 0, "Recursion counter invalid");
+ }
+}
diff --git a/src/libstd/sys/cloudabi/os.rs b/src/libstd/sys/cloudabi/os.rs
new file mode 100644
index 0000000..7e506b8
--- /dev/null
+++ b/src/libstd/sys/cloudabi/os.rs
@@ -0,0 +1,37 @@
+// Copyright 2018 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use ffi::CStr;
+use libc::{self, c_int};
+use str;
+
+pub use sys::cloudabi::shims::os::*;
+
+pub fn errno() -> i32 {
+ extern "C" {
+ #[thread_local]
+ static errno: c_int;
+ }
+
+ unsafe { errno as i32 }
+}
+
+/// Gets a detailed string description for the given error number.
+pub fn error_string(errno: i32) -> String {
+ // cloudlibc's strerror() is guaranteed to be thread-safe. There is
+ // thus no need to use strerror_r().
+ str::from_utf8(unsafe { CStr::from_ptr(libc::strerror(errno)) }.to_bytes())
+ .unwrap()
+ .to_owned()
+}
+
+pub fn exit(code: i32) -> ! {
+ unsafe { libc::exit(code as c_int) }
+}
diff --git a/src/libstd/sys/cloudabi/rwlock.rs b/src/libstd/sys/cloudabi/rwlock.rs
new file mode 100644
index 0000000..8539aec
--- /dev/null
+++ b/src/libstd/sys/cloudabi/rwlock.rs
@@ -0,0 +1,237 @@
+// Copyright 2018 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use cell::UnsafeCell;
+use mem;
+use sync::atomic::{AtomicU32, Ordering};
+use sys::cloudabi::abi;
+
+extern "C" {
+ #[thread_local]
+ static __pthread_thread_id: abi::tid;
+}
+
+#[thread_local]
+static mut RDLOCKS_ACQUIRED: u32 = 0;
+
+pub struct RWLock {
+ lock: UnsafeCell<AtomicU32>,
+}
+
+pub unsafe fn raw(r: &RWLock) -> *mut AtomicU32 {
+ r.lock.get()
+}
+
+unsafe impl Send for RWLock {}
+unsafe impl Sync for RWLock {}
+
+impl RWLock {
+ pub const fn new() -> RWLock {
+ RWLock {
+ lock: UnsafeCell::new(AtomicU32::new(abi::LOCK_UNLOCKED.0)),
+ }
+ }
+
+ pub unsafe fn try_read(&self) -> bool {
+ let lock = self.lock.get();
+ let mut old = abi::LOCK_UNLOCKED.0;
+ while let Err(cur) =
+ (*lock).compare_exchange_weak(old, old + 1, Ordering::Acquire, Ordering::Relaxed)
+ {
+ if (cur & abi::LOCK_WRLOCKED.0) != 0 {
+ // Another thread already has a write lock.
+ assert_ne!(
+ old & !abi::LOCK_KERNEL_MANAGED.0,
+ __pthread_thread_id.0 | abi::LOCK_WRLOCKED.0,
+ "Attempted to acquire a read lock while holding a write lock"
+ );
+ return false;
+ } else if (old & abi::LOCK_KERNEL_MANAGED.0) != 0 && RDLOCKS_ACQUIRED == 0 {
+ // Lock has threads waiting for the lock. Only acquire
+ // the lock if we have already acquired read locks. In
+ // that case, it is justified to acquire this lock to
+ // prevent a deadlock.
+ return false;
+ }
+ old = cur;
+ }
+
+ RDLOCKS_ACQUIRED += 1;
+ true
+ }
+
+ pub unsafe fn read(&self) {
+ if !self.try_read() {
+ // Call into the kernel to acquire a read lock.
+ let lock = self.lock.get();
+ let subscription = abi::subscription {
+ type_: abi::eventtype::LOCK_RDLOCK,
+ union: abi::subscription_union {
+ lock: abi::subscription_lock {
+ lock: lock as *mut abi::lock,
+ lock_scope: abi::scope::PRIVATE,
+ },
+ },
+ ..mem::zeroed()
+ };
+ let mut event: abi::event = mem::uninitialized();
+ let mut nevents: usize = mem::uninitialized();
+ let ret = abi::poll(&subscription, &mut event, 1, &mut nevents);
+ assert_eq!(ret, abi::errno::SUCCESS, "Failed to acquire read lock");
+ assert_eq!(
+ event.error,
+ abi::errno::SUCCESS,
+ "Failed to acquire read lock"
+ );
+
+ RDLOCKS_ACQUIRED += 1;
+ }
+ }
+
+ pub unsafe fn read_unlock(&self) {
+ // Perform a read unlock. We can do this in userspace, except when
+ // other threads are blocked and we are performing the last unlock.
+ // In that case, call into the kernel.
+ //
+ // Other threads may attempt to increment the read lock count,
+ // meaning that the call into the kernel could be spurious. To
+ // prevent this from happening, upgrade to a write lock first. This
+ // allows us to call into the kernel, having the guarantee that the
+ // lock value will not change in the meantime.
+ assert!(RDLOCKS_ACQUIRED > 0, "Bad lock count");
+ let mut old = 1;
+ loop {
+ let lock = self.lock.get();
+ if old == 1 | abi::LOCK_KERNEL_MANAGED.0 {
+ // Last read lock while threads are waiting. Attempt to upgrade
+ // to a write lock before calling into the kernel to unlock.
+ if let Err(cur) = (*lock).compare_exchange_weak(
+ old,
+ __pthread_thread_id.0 | abi::LOCK_WRLOCKED.0 | abi::LOCK_KERNEL_MANAGED.0,
+ Ordering::Acquire,
+ Ordering::Relaxed,
+ ) {
+ old = cur;
+ } else {
+ // Call into the kernel to unlock.
+ let ret = abi::lock_unlock(lock as *mut abi::lock, abi::scope::PRIVATE);
+ assert_eq!(ret, abi::errno::SUCCESS, "Failed to write unlock a rwlock");
+ break;
+ }
+ } else {
+ // No threads waiting or not the last read lock. Just decrement
+ // the read lock count.
+ assert_ne!(
+ old & !abi::LOCK_KERNEL_MANAGED.0,
+ 0,
+ "This rwlock is not locked"
+ );
+ assert_eq!(
+ old & abi::LOCK_WRLOCKED.0,
+ 0,
+ "Attempted to read-unlock a write-locked rwlock"
+ );
+ if let Err(cur) = (*lock).compare_exchange_weak(
+ old,
+ old - 1,
+ Ordering::Acquire,
+ Ordering::Relaxed,
+ ) {
+ old = cur;
+ } else {
+ break;
+ }
+ }
+ }
+
+ RDLOCKS_ACQUIRED -= 1;
+ }
+
+ pub unsafe fn try_write(&self) -> bool {
+ // Attempt to acquire the lock.
+ let lock = self.lock.get();
+ if let Err(old) = (*lock).compare_exchange(
+ abi::LOCK_UNLOCKED.0,
+ __pthread_thread_id.0 | abi::LOCK_WRLOCKED.0,
+ Ordering::Acquire,
+ Ordering::Relaxed,
+ ) {
+ // Failure. Crash upon recursive acquisition.
+ assert_ne!(
+ old & !abi::LOCK_KERNEL_MANAGED.0,
+ __pthread_thread_id.0 | abi::LOCK_WRLOCKED.0,
+ "Attempted to recursive write-lock a rwlock",
+ );
+ false
+ } else {
+ // Success.
+ true
+ }
+ }
+
+ pub unsafe fn write(&self) {
+ if !self.try_write() {
+ // Call into the kernel to acquire a write lock.
+ let lock = self.lock.get();
+ let subscription = abi::subscription {
+ type_: abi::eventtype::LOCK_WRLOCK,
+ union: abi::subscription_union {
+ lock: abi::subscription_lock {
+ lock: lock as *mut abi::lock,
+ lock_scope: abi::scope::PRIVATE,
+ },
+ },
+ ..mem::zeroed()
+ };
+ let mut event: abi::event = mem::uninitialized();
+ let mut nevents: usize = mem::uninitialized();
+ let ret = abi::poll(&subscription, &mut event, 1, &mut nevents);
+ assert_eq!(ret, abi::errno::SUCCESS, "Failed to acquire write lock");
+ assert_eq!(
+ event.error,
+ abi::errno::SUCCESS,
+ "Failed to acquire write lock"
+ );
+ }
+ }
+
+ pub unsafe fn write_unlock(&self) {
+ let lock = self.lock.get();
+ assert_eq!(
+ (*lock).load(Ordering::Relaxed) & !abi::LOCK_KERNEL_MANAGED.0,
+ __pthread_thread_id.0 | abi::LOCK_WRLOCKED.0,
+ "This rwlock is not write-locked by this thread"
+ );
+
+ if !(*lock)
+ .compare_exchange(
+ __pthread_thread_id.0 | abi::LOCK_WRLOCKED.0,
+ abi::LOCK_UNLOCKED.0,
+ Ordering::Release,
+ Ordering::Relaxed,
+ )
+ .is_ok()
+ {
+ // Lock is managed by kernelspace. Call into the kernel
+ // to unblock waiting threads.
+ let ret = abi::lock_unlock(lock as *mut abi::lock, abi::scope::PRIVATE);
+ assert_eq!(ret, abi::errno::SUCCESS, "Failed to write unlock a rwlock");
+ }
+ }
+
+ pub unsafe fn destroy(&self) {
+ let lock = self.lock.get();
+ assert_eq!(
+ (*lock).load(Ordering::Relaxed),
+ abi::LOCK_UNLOCKED.0,
+ "Attempted to destroy locked rwlock"
+ );
+ }
+}
diff --git a/src/libstd/sys/cloudabi/shims/args.rs b/src/libstd/sys/cloudabi/shims/args.rs
new file mode 100644
index 0000000..1b5785a
--- /dev/null
+++ b/src/libstd/sys/cloudabi/shims/args.rs
@@ -0,0 +1,45 @@
+// Copyright 2018 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use ffi::OsString;
+
+pub struct Args(());
+
+impl Args {
+ pub fn inner_debug(&self) -> &[OsString] {
+ &[]
+ }
+}
+
+impl Iterator for Args {
+ type Item = OsString;
+ fn next(&mut self) -> Option<OsString> {
+ None
+ }
+ fn size_hint(&self) -> (usize, Option<usize>) {
+ (0, Some(0))
+ }
+}
+
+impl ExactSizeIterator for Args {
+ fn len(&self) -> usize {
+ 0
+ }
+}
+
+impl DoubleEndedIterator for Args {
+ fn next_back(&mut self) -> Option<OsString> {
+ None
+ }
+}
+
+pub fn args() -> Args {
+ Args(())
+}
diff --git a/src/libstd/sys/cloudabi/shims/env.rs b/src/libstd/sys/cloudabi/shims/env.rs
new file mode 100644
index 0000000..31777aa
--- /dev/null
+++ b/src/libstd/sys/cloudabi/shims/env.rs
@@ -0,0 +1,19 @@
+// Copyright 2018 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+pub mod os {
+ pub const FAMILY: &'static str = "cloudabi";
+ pub const OS: &'static str = "cloudabi";
+ pub const DLL_PREFIX: &'static str = "lib";
+ pub const DLL_SUFFIX: &'static str = ".so";
+ pub const DLL_EXTENSION: &'static str = "so";
+ pub const EXE_SUFFIX: &'static str = "";
+ pub const EXE_EXTENSION: &'static str = "";
+}
diff --git a/src/libstd/sys/cloudabi/shims/fs.rs b/src/libstd/sys/cloudabi/shims/fs.rs
new file mode 100644
index 0000000..d3da0fb
--- /dev/null
+++ b/src/libstd/sys/cloudabi/shims/fs.rs
@@ -0,0 +1,302 @@
+// Copyright 2017 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use ffi::OsString;
+use fmt;
+use hash::{Hash, Hasher};
+use io::{self, SeekFrom};
+use path::{Path, PathBuf};
+use sys::time::SystemTime;
+use sys::{unsupported, Void};
+
+pub struct File(Void);
+
+pub struct FileAttr(Void);
+
+pub struct ReadDir(Void);
+
+pub struct DirEntry(Void);
+
+#[derive(Clone, Debug)]
+pub struct OpenOptions {}
+
+pub struct FilePermissions(Void);
+
+pub struct FileType(Void);
+
+#[derive(Debug)]
+pub struct DirBuilder {}
+
+impl FileAttr {
+ pub fn size(&self) -> u64 {
+ match self.0 {}
+ }
+
+ pub fn perm(&self) -> FilePermissions {
+ match self.0 {}
+ }
+
+ pub fn file_type(&self) -> FileType {
+ match self.0 {}
+ }
+
+ pub fn modified(&self) -> io::Result<SystemTime> {
+ match self.0 {}
+ }
+
+ pub fn accessed(&self) -> io::Result<SystemTime> {
+ match self.0 {}
+ }
+
+ pub fn created(&self) -> io::Result<SystemTime> {
+ match self.0 {}
+ }
+}
+
+impl Clone for FileAttr {
+ fn clone(&self) -> FileAttr {
+ match self.0 {}
+ }
+}
+
+impl FilePermissions {
+ pub fn readonly(&self) -> bool {
+ match self.0 {}
+ }
+
+ pub fn set_readonly(&mut self, _readonly: bool) {
+ match self.0 {}
+ }
+}
+
+impl Clone for FilePermissions {
+ fn clone(&self) -> FilePermissions {
+ match self.0 {}
+ }
+}
+
+impl PartialEq for FilePermissions {
+ fn eq(&self, _other: &FilePermissions) -> bool {
+ match self.0 {}
+ }
+}
+
+impl Eq for FilePermissions {}
+
+impl fmt::Debug for FilePermissions {
+ fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result {
+ match self.0 {}
+ }
+}
+
+impl FileType {
+ pub fn is_dir(&self) -> bool {
+ match self.0 {}
+ }
+
+ pub fn is_file(&self) -> bool {
+ match self.0 {}
+ }
+
+ pub fn is_symlink(&self) -> bool {
+ match self.0 {}
+ }
+}
+
+impl Clone for FileType {
+ fn clone(&self) -> FileType {
+ match self.0 {}
+ }
+}
+
+impl Copy for FileType {}
+
+impl PartialEq for FileType {
+ fn eq(&self, _other: &FileType) -> bool {
+ match self.0 {}
+ }
+}
+
+impl Eq for FileType {}
+
+impl Hash for FileType {
+ fn hash<H: Hasher>(&self, _h: &mut H) {
+ match self.0 {}
+ }
+}
+
+impl fmt::Debug for FileType {
+ fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result {
+ match self.0 {}
+ }
+}
+
+impl fmt::Debug for ReadDir {
+ fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result {
+ match self.0 {}
+ }
+}
+
+impl Iterator for ReadDir {
+ type Item = io::Result<DirEntry>;
+
+ fn next(&mut self) -> Option<io::Result<DirEntry>> {
+ match self.0 {}
+ }
+}
+
+impl DirEntry {
+ pub fn path(&self) -> PathBuf {
+ match self.0 {}
+ }
+
+ pub fn file_name(&self) -> OsString {
+ match self.0 {}
+ }
+
+ pub fn metadata(&self) -> io::Result<FileAttr> {
+ match self.0 {}
+ }
+
+ pub fn file_type(&self) -> io::Result<FileType> {
+ match self.0 {}
+ }
+}
+
+impl OpenOptions {
+ pub fn new() -> OpenOptions {
+ OpenOptions {}
+ }
+
+ pub fn read(&mut self, _read: bool) {}
+ pub fn write(&mut self, _write: bool) {}
+ pub fn append(&mut self, _append: bool) {}
+ pub fn truncate(&mut self, _truncate: bool) {}
+ pub fn create(&mut self, _create: bool) {}
+ pub fn create_new(&mut self, _create_new: bool) {}
+}
+
+impl File {
+ pub fn open(_path: &Path, _opts: &OpenOptions) -> io::Result<File> {
+ unsupported()
+ }
+
+ pub fn file_attr(&self) -> io::Result<FileAttr> {
+ match self.0 {}
+ }
+
+ pub fn fsync(&self) -> io::Result<()> {
+ match self.0 {}
+ }
+
+ pub fn datasync(&self) -> io::Result<()> {
+ match self.0 {}
+ }
+
+ pub fn truncate(&self, _size: u64) -> io::Result<()> {
+ match self.0 {}
+ }
+
+ pub fn read(&self, _buf: &mut [u8]) -> io::Result<usize> {
+ match self.0 {}
+ }
+
+ pub fn write(&self, _buf: &[u8]) -> io::Result<usize> {
+ match self.0 {}
+ }
+
+ pub fn flush(&self) -> io::Result<()> {
+ match self.0 {}
+ }
+
+ pub fn seek(&self, _pos: SeekFrom) -> io::Result<u64> {
+ match self.0 {}
+ }
+
+ pub fn duplicate(&self) -> io::Result<File> {
+ match self.0 {}
+ }
+
+ pub fn set_permissions(&self, _perm: FilePermissions) -> io::Result<()> {
+ match self.0 {}
+ }
+
+ pub fn diverge(&self) -> ! {
+ match self.0 {}
+ }
+}
+
+impl DirBuilder {
+ pub fn new() -> DirBuilder {
+ DirBuilder {}
+ }
+
+ pub fn mkdir(&self, _p: &Path) -> io::Result<()> {
+ unsupported()
+ }
+}
+
+impl fmt::Debug for File {
+ fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result {
+ match self.0 {}
+ }
+}
+
+pub fn readdir(_p: &Path) -> io::Result<ReadDir> {
+ unsupported()
+}
+
+pub fn unlink(_p: &Path) -> io::Result<()> {
+ unsupported()
+}
+
+pub fn rename(_old: &Path, _new: &Path) -> io::Result<()> {
+ unsupported()
+}
+
+pub fn set_perm(_p: &Path, perm: FilePermissions) -> io::Result<()> {
+ match perm.0 {}
+}
+
+pub fn rmdir(_p: &Path) -> io::Result<()> {
+ unsupported()
+}
+
+pub fn remove_dir_all(_path: &Path) -> io::Result<()> {
+ unsupported()
+}
+
+pub fn readlink(_p: &Path) -> io::Result<PathBuf> {
+ unsupported()
+}
+
+pub fn symlink(_src: &Path, _dst: &Path) -> io::Result<()> {
+ unsupported()
+}
+
+pub fn link(_src: &Path, _dst: &Path) -> io::Result<()> {
+ unsupported()
+}
+
+pub fn stat(_p: &Path) -> io::Result<FileAttr> {
+ unsupported()
+}
+
+pub fn lstat(_p: &Path) -> io::Result<FileAttr> {
+ unsupported()
+}
+
+pub fn canonicalize(_p: &Path) -> io::Result<PathBuf> {
+ unsupported()
+}
+
+pub fn copy(_from: &Path, _to: &Path) -> io::Result<u64> {
+ unsupported()
+}
diff --git a/src/libstd/sys/cloudabi/shims/mod.rs b/src/libstd/sys/cloudabi/shims/mod.rs
new file mode 100644
index 0000000..407c2b9
--- /dev/null
+++ b/src/libstd/sys/cloudabi/shims/mod.rs
@@ -0,0 +1,32 @@
+// Copyright 2018 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use io;
+
+pub mod args;
+pub mod env;
+pub mod fs;
+pub mod net;
+#[path = "../../unix/path.rs"]
+pub mod path;
+pub mod pipe;
+pub mod process;
+pub mod os;
+
+// This enum is used as the storage for a bunch of types which can't actually exist.
+#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
+pub enum Void {}
+
+pub fn unsupported<T>() -> io::Result<T> {
+ Err(io::Error::new(
+ io::ErrorKind::Other,
+ "This function is not available on CloudABI.",
+ ))
+}
diff --git a/src/libstd/sys/cloudabi/shims/net.rs b/src/libstd/sys/cloudabi/shims/net.rs
new file mode 100644
index 0000000..93eaf6a
--- /dev/null
+++ b/src/libstd/sys/cloudabi/shims/net.rs
@@ -0,0 +1,296 @@
+// Copyright 2017 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use fmt;
+use io;
+use net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr};
+use time::Duration;
+use sys::{unsupported, Void};
+
+pub extern crate libc as netc;
+
+pub struct TcpStream(Void);
+
+impl TcpStream {
+ pub fn connect(_: &SocketAddr) -> io::Result<TcpStream> {
+ unsupported()
+ }
+
+ pub fn connect_timeout(_: &SocketAddr, _: Duration) -> io::Result<TcpStream> {
+ unsupported()
+ }
+
+ pub fn set_read_timeout(&self, _: Option<Duration>) -> io::Result<()> {
+ match self.0 {}
+ }
+
+ pub fn set_write_timeout(&self, _: Option<Duration>) -> io::Result<()> {
+ match self.0 {}
+ }
+
+ pub fn read_timeout(&self) -> io::Result<Option<Duration>> {
+ match self.0 {}
+ }
+
+ pub fn write_timeout(&self) -> io::Result<Option<Duration>> {
+ match self.0 {}
+ }
+
+ pub fn peek(&self, _: &mut [u8]) -> io::Result<usize> {
+ match self.0 {}
+ }
+
+ pub fn read(&self, _: &mut [u8]) -> io::Result<usize> {
+ match self.0 {}
+ }
+
+ pub fn write(&self, _: &[u8]) -> io::Result<usize> {
+ match self.0 {}
+ }
+
+ pub fn peer_addr(&self) -> io::Result<SocketAddr> {
+ match self.0 {}
+ }
+
+ pub fn socket_addr(&self) -> io::Result<SocketAddr> {
+ match self.0 {}
+ }
+
+ pub fn shutdown(&self, _: Shutdown) -> io::Result<()> {
+ match self.0 {}
+ }
+
+ pub fn duplicate(&self) -> io::Result<TcpStream> {
+ match self.0 {}
+ }
+
+ pub fn set_nodelay(&self, _: bool) -> io::Result<()> {
+ match self.0 {}
+ }
+
+ pub fn nodelay(&self) -> io::Result<bool> {
+ match self.0 {}
+ }
+
+ pub fn set_ttl(&self, _: u32) -> io::Result<()> {
+ match self.0 {}
+ }
+
+ pub fn ttl(&self) -> io::Result<u32> {
+ match self.0 {}
+ }
+
+ pub fn take_error(&self) -> io::Result<Option<io::Error>> {
+ match self.0 {}
+ }
+
+ pub fn set_nonblocking(&self, _: bool) -> io::Result<()> {
+ match self.0 {}
+ }
+}
+
+impl fmt::Debug for TcpStream {
+ fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result {
+ match self.0 {}
+ }
+}
+
+pub struct TcpListener(Void);
+
+impl TcpListener {
+ pub fn bind(_: &SocketAddr) -> io::Result<TcpListener> {
+ unsupported()
+ }
+
+ pub fn socket_addr(&self) -> io::Result<SocketAddr> {
+ match self.0 {}
+ }
+
+ pub fn accept(&self) -> io::Result<(TcpStream, SocketAddr)> {
+ match self.0 {}
+ }
+
+ pub fn duplicate(&self) -> io::Result<TcpListener> {
+ match self.0 {}
+ }
+
+ pub fn set_ttl(&self, _: u32) -> io::Result<()> {
+ match self.0 {}
+ }
+
+ pub fn ttl(&self) -> io::Result<u32> {
+ match self.0 {}
+ }
+
+ pub fn set_only_v6(&self, _: bool) -> io::Result<()> {
+ match self.0 {}
+ }
+
+ pub fn only_v6(&self) -> io::Result<bool> {
+ match self.0 {}
+ }
+
+ pub fn take_error(&self) -> io::Result<Option<io::Error>> {
+ match self.0 {}
+ }
+
+ pub fn set_nonblocking(&self, _: bool) -> io::Result<()> {
+ match self.0 {}
+ }
+}
+
+impl fmt::Debug for TcpListener {
+ fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result {
+ match self.0 {}
+ }
+}
+
+pub struct UdpSocket(Void);
+
+impl UdpSocket {
+ pub fn bind(_: &SocketAddr) -> io::Result<UdpSocket> {
+ unsupported()
+ }
+
+ pub fn socket_addr(&self) -> io::Result<SocketAddr> {
+ match self.0 {}
+ }
+
+ pub fn recv_from(&self, _: &mut [u8]) -> io::Result<(usize, SocketAddr)> {
+ match self.0 {}
+ }
+
+ pub fn peek_from(&self, _: &mut [u8]) -> io::Result<(usize, SocketAddr)> {
+ match self.0 {}
+ }
+
+ pub fn send_to(&self, _: &[u8], _: &SocketAddr) -> io::Result<usize> {
+ match self.0 {}
+ }
+
+ pub fn duplicate(&self) -> io::Result<UdpSocket> {
+ match self.0 {}
+ }
+
+ pub fn set_read_timeout(&self, _: Option<Duration>) -> io::Result<()> {
+ match self.0 {}
+ }
+
+ pub fn set_write_timeout(&self, _: Option<Duration>) -> io::Result<()> {
+ match self.0 {}
+ }
+
+ pub fn read_timeout(&self) -> io::Result<Option<Duration>> {
+ match self.0 {}
+ }
+
+ pub fn write_timeout(&self) -> io::Result<Option<Duration>> {
+ match self.0 {}
+ }
+
+ pub fn set_broadcast(&self, _: bool) -> io::Result<()> {
+ match self.0 {}
+ }
+
+ pub fn broadcast(&self) -> io::Result<bool> {
+ match self.0 {}
+ }
+
+ pub fn set_multicast_loop_v4(&self, _: bool) -> io::Result<()> {
+ match self.0 {}
+ }
+
+ pub fn multicast_loop_v4(&self) -> io::Result<bool> {
+ match self.0 {}
+ }
+
+ pub fn set_multicast_ttl_v4(&self, _: u32) -> io::Result<()> {
+ match self.0 {}
+ }
+
+ pub fn multicast_ttl_v4(&self) -> io::Result<u32> {
+ match self.0 {}
+ }
+
+ pub fn set_multicast_loop_v6(&self, _: bool) -> io::Result<()> {
+ match self.0 {}
+ }
+
+ pub fn multicast_loop_v6(&self) -> io::Result<bool> {
+ match self.0 {}
+ }
+
+ pub fn join_multicast_v4(&self, _: &Ipv4Addr, _: &Ipv4Addr) -> io::Result<()> {
+ match self.0 {}
+ }
+
+ pub fn join_multicast_v6(&self, _: &Ipv6Addr, _: u32) -> io::Result<()> {
+ match self.0 {}
+ }
+
+ pub fn leave_multicast_v4(&self, _: &Ipv4Addr, _: &Ipv4Addr) -> io::Result<()> {
+ match self.0 {}
+ }
+
+ pub fn leave_multicast_v6(&self, _: &Ipv6Addr, _: u32) -> io::Result<()> {
+ match self.0 {}
+ }
+
+ pub fn set_ttl(&self, _: u32) -> io::Result<()> {
+ match self.0 {}
+ }
+
+ pub fn ttl(&self) -> io::Result<u32> {
+ match self.0 {}
+ }
+
+ pub fn take_error(&self) -> io::Result<Option<io::Error>> {
+ match self.0 {}
+ }
+
+ pub fn set_nonblocking(&self, _: bool) -> io::Result<()> {
+ match self.0 {}
+ }
+
+ pub fn recv(&self, _: &mut [u8]) -> io::Result<usize> {
+ match self.0 {}
+ }
+
+ pub fn peek(&self, _: &mut [u8]) -> io::Result<usize> {
+ match self.0 {}
+ }
+
+ pub fn send(&self, _: &[u8]) -> io::Result<usize> {
+ match self.0 {}
+ }
+
+ pub fn connect(&self, _: &SocketAddr) -> io::Result<()> {
+ match self.0 {}
+ }
+}
+
+impl fmt::Debug for UdpSocket {
+ fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result {
+ match self.0 {}
+ }
+}
+
+pub struct LookupHost(Void);
+
+impl Iterator for LookupHost {
+ type Item = SocketAddr;
+ fn next(&mut self) -> Option<SocketAddr> {
+ match self.0 {}
+ }
+}
+
+pub fn lookup_host(_: &str) -> io::Result<LookupHost> {
+ unsupported()
+}
diff --git a/src/libstd/sys/cloudabi/shims/os.rs b/src/libstd/sys/cloudabi/shims/os.rs
new file mode 100644
index 0000000..1e355d9
--- /dev/null
+++ b/src/libstd/sys/cloudabi/shims/os.rs
@@ -0,0 +1,95 @@
+// Copyright 2018 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use error::Error as StdError;
+use ffi::{OsStr, OsString};
+use fmt;
+use io;
+use iter;
+use path::{self, PathBuf};
+use sys::{unsupported, Void};
+
+pub fn getcwd() -> io::Result<PathBuf> {
+ unsupported()
+}
+
+pub fn chdir(_: &path::Path) -> io::Result<()> {
+ unsupported()
+}
+
+pub type Env = iter::Empty<(OsString, OsString)>;
+
+pub fn env() -> Env {
+ iter::empty()
+}
+
+pub fn getenv(_: &OsStr) -> io::Result<Option<OsString>> {
+ Ok(None)
+}
+
+pub fn setenv(_: &OsStr, _: &OsStr) -> io::Result<()> {
+ unsupported()
+}
+
+pub fn unsetenv(_: &OsStr) -> io::Result<()> {
+ unsupported()
+}
+
+pub struct SplitPaths<'a>(&'a Void);
+
+pub fn split_paths(_unparsed: &OsStr) -> SplitPaths {
+ panic!("unsupported")
+}
+
+impl<'a> Iterator for SplitPaths<'a> {
+ type Item = PathBuf;
+ fn next(&mut self) -> Option<PathBuf> {
+ match *self.0 {}
+ }
+}
+
+#[derive(Debug)]
+pub struct JoinPathsError;
+
+pub fn join_paths<I, T>(_paths: I) -> Result<OsString, JoinPathsError>
+where
+ I: Iterator<Item = T>,
+ T: AsRef<OsStr>,
+{
+ Err(JoinPathsError)
+}
+
+impl fmt::Display for JoinPathsError {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ "not supported on CloudABI yet".fmt(f)
+ }
+}
+
+impl StdError for JoinPathsError {
+ fn description(&self) -> &str {
+ "not supported on CloudABI yet"
+ }
+}
+
+pub fn home_dir() -> Option<PathBuf> {
+ None
+}
+
+pub fn temp_dir() -> PathBuf {
+ PathBuf::from("/tmp")
+}
+
+pub fn current_exe() -> io::Result<PathBuf> {
+ unsupported()
+}
+
+pub fn getpid() -> u32 {
+ 1
+}
diff --git a/src/libstd/sys/cloudabi/shims/pipe.rs b/src/libstd/sys/cloudabi/shims/pipe.rs
new file mode 100644
index 0000000..77a9cd6
--- /dev/null
+++ b/src/libstd/sys/cloudabi/shims/pipe.rs
@@ -0,0 +1,32 @@
+// Copyright 2017 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use io;
+use sys::Void;
+
+pub struct AnonPipe(Void);
+
+impl AnonPipe {
+ pub fn read(&self, _buf: &mut [u8]) -> io::Result<usize> {
+ match self.0 {}
+ }
+
+ pub fn write(&self, _buf: &[u8]) -> io::Result<usize> {
+ match self.0 {}
+ }
+
+ pub fn diverge(&self) -> ! {
+ match self.0 {}
+ }
+}
+
+pub fn read2(p1: AnonPipe, _v1: &mut Vec<u8>, _p2: AnonPipe, _v2: &mut Vec<u8>) -> io::Result<()> {
+ match p1.0 {}
+}
diff --git a/src/libstd/sys/cloudabi/shims/process.rs b/src/libstd/sys/cloudabi/shims/process.rs
new file mode 100644
index 0000000..52e8c82
--- /dev/null
+++ b/src/libstd/sys/cloudabi/shims/process.rs
@@ -0,0 +1,147 @@
+// Copyright 2017 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use ffi::OsStr;
+use fmt;
+use io;
+use sys::fs::File;
+use sys::pipe::AnonPipe;
+use sys::{unsupported, Void};
+use sys_common::process::{CommandEnv, DefaultEnvKey};
+
+////////////////////////////////////////////////////////////////////////////////
+// Command
+////////////////////////////////////////////////////////////////////////////////
+
+pub struct Command {
+ env: CommandEnv<DefaultEnvKey>,
+}
+
+// passed back to std::process with the pipes connected to the child, if any
+// were requested
+pub struct StdioPipes {
+ pub stdin: Option<AnonPipe>,
+ pub stdout: Option<AnonPipe>,
+ pub stderr: Option<AnonPipe>,
+}
+
+pub enum Stdio {
+ Inherit,
+ Null,
+ MakePipe,
+}
+
+impl Command {
+ pub fn new(_program: &OsStr) -> Command {
+ Command {
+ env: Default::default(),
+ }
+ }
+
+ pub fn arg(&mut self, _arg: &OsStr) {}
+
+ pub fn env_mut(&mut self) -> &mut CommandEnv<DefaultEnvKey> {
+ &mut self.env
+ }
+
+ pub fn cwd(&mut self, _dir: &OsStr) {}
+
+ pub fn stdin(&mut self, _stdin: Stdio) {}
+
+ pub fn stdout(&mut self, _stdout: Stdio) {}
+
+ pub fn stderr(&mut self, _stderr: Stdio) {}
+
+ pub fn spawn(
+ &mut self,
+ _default: Stdio,
+ _needs_stdin: bool,
+ ) -> io::Result<(Process, StdioPipes)> {
+ unsupported()
+ }
+}
+
+impl From<AnonPipe> for Stdio {
+ fn from(pipe: AnonPipe) -> Stdio {
+ pipe.diverge()
+ }
+}
+
+impl From<File> for Stdio {
+ fn from(file: File) -> Stdio {
+ file.diverge()
+ }
+}
+
+impl fmt::Debug for Command {
+ fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result {
+ Ok(())
+ }
+}
+
+pub struct ExitStatus(Void);
+
+impl ExitStatus {
+ pub fn success(&self) -> bool {
+ match self.0 {}
+ }
+
+ pub fn code(&self) -> Option<i32> {
+ match self.0 {}
+ }
+}
+
+impl Clone for ExitStatus {
+ fn clone(&self) -> ExitStatus {
+ match self.0 {}
+ }
+}
+
+impl Copy for ExitStatus {}
+
+impl PartialEq for ExitStatus {
+ fn eq(&self, _other: &ExitStatus) -> bool {
+ match self.0 {}
+ }
+}
+
+impl Eq for ExitStatus {}
+
+impl fmt::Debug for ExitStatus {
+ fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result {
+ match self.0 {}
+ }
+}
+
+impl fmt::Display for ExitStatus {
+ fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result {
+ match self.0 {}
+ }
+}
+
+pub struct Process(Void);
+
+impl Process {
+ pub fn id(&self) -> u32 {
+ match self.0 {}
+ }
+
+ pub fn kill(&mut self) -> io::Result<()> {
+ match self.0 {}
+ }
+
+ pub fn wait(&mut self) -> io::Result<ExitStatus> {
+ match self.0 {}
+ }
+
+ pub fn try_wait(&mut self) -> io::Result<Option<ExitStatus>> {
+ match self.0 {}
+ }
+}
diff --git a/src/libstd/sys/cloudabi/stack_overflow.rs b/src/libstd/sys/cloudabi/stack_overflow.rs
new file mode 100644
index 0000000..5c0b1e5
--- /dev/null
+++ b/src/libstd/sys/cloudabi/stack_overflow.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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![cfg_attr(test, allow(dead_code))]
+
+pub struct Handler;
+
+impl Handler {
+ pub unsafe fn new() -> Handler {
+ Handler
+ }
+}
+
+pub unsafe fn init() {}
+
+pub unsafe fn cleanup() {}
diff --git a/src/libstd/sys/cloudabi/stdio.rs b/src/libstd/sys/cloudabi/stdio.rs
new file mode 100644
index 0000000..9519a92
--- /dev/null
+++ b/src/libstd/sys/cloudabi/stdio.rs
@@ -0,0 +1,79 @@
+// Copyright 2018 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use io;
+use sys::cloudabi::abi;
+
+pub struct Stdin(());
+pub struct Stdout(());
+pub struct Stderr(());
+
+impl Stdin {
+ pub fn new() -> io::Result<Stdin> {
+ Ok(Stdin(()))
+ }
+
+ pub fn read(&self, _: &mut [u8]) -> io::Result<usize> {
+ Ok(0)
+ }
+}
+
+impl Stdout {
+ pub fn new() -> io::Result<Stdout> {
+ Ok(Stdout(()))
+ }
+
+ pub fn write(&self, _: &[u8]) -> io::Result<usize> {
+ Err(io::Error::new(
+ io::ErrorKind::BrokenPipe,
+ "Stdout is not connected to any output in this environment",
+ ))
+ }
+
+ pub fn flush(&self) -> io::Result<()> {
+ Ok(())
+ }
+}
+
+impl Stderr {
+ pub fn new() -> io::Result<Stderr> {
+ Ok(Stderr(()))
+ }
+
+ pub fn write(&self, _: &[u8]) -> io::Result<usize> {
+ Err(io::Error::new(
+ io::ErrorKind::BrokenPipe,
+ "Stderr is not connected to any output in this environment",
+ ))
+ }
+
+ pub fn flush(&self) -> io::Result<()> {
+ Ok(())
+ }
+}
+
+// FIXME: right now this raw stderr handle is used in a few places because
+// std::io::stderr_raw isn't exposed, but once that's exposed this impl
+// should go away
+impl io::Write for Stderr {
+ fn write(&mut self, data: &[u8]) -> io::Result<usize> {
+ Stderr::write(self, data)
+ }
+
+ fn flush(&mut self) -> io::Result<()> {
+ Stderr::flush(self)
+ }
+}
+
+pub fn is_ebadf(err: &io::Error) -> bool {
+ err.raw_os_error() == Some(abi::errno::BADF as i32)
+}
+
+pub const STDIN_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE;
diff --git a/src/libstd/sys/cloudabi/thread.rs b/src/libstd/sys/cloudabi/thread.rs
new file mode 100644
index 0000000..c980ae7
--- /dev/null
+++ b/src/libstd/sys/cloudabi/thread.rs
@@ -0,0 +1,124 @@
+// Copyright 2014-2018 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use alloc::boxed::FnBox;
+use cmp;
+use ffi::CStr;
+use io;
+use libc;
+use mem;
+use ptr;
+use sys::cloudabi::abi;
+use sys::time::dur2intervals;
+use sys_common::thread::*;
+use time::Duration;
+
+pub const DEFAULT_MIN_STACK_SIZE: usize = 2 * 1024 * 1024;
+
+pub struct Thread {
+ id: libc::pthread_t,
+}
+
+// CloudABI has pthread_t as a pointer in which case we still want
+// a thread to be Send/Sync
+unsafe impl Send for Thread {}
+unsafe impl Sync for Thread {}
+
+impl Thread {
+ pub unsafe fn new<'a>(stack: usize, p: Box<FnBox() + 'a>) -> io::Result<Thread> {
+ let p = box p;
+ let mut native: libc::pthread_t = mem::zeroed();
+ let mut attr: libc::pthread_attr_t = mem::zeroed();
+ assert_eq!(libc::pthread_attr_init(&mut attr), 0);
+
+ let stack_size = cmp::max(stack, min_stack_size(&attr));
+ assert_eq!(libc::pthread_attr_setstacksize(&mut attr, stack_size), 0);
+
+ let ret = libc::pthread_create(&mut native, &attr, thread_start, &*p as *const _ as *mut _);
+ assert_eq!(libc::pthread_attr_destroy(&mut attr), 0);
+
+ return if ret != 0 {
+ Err(io::Error::from_raw_os_error(ret))
+ } else {
+ mem::forget(p); // ownership passed to pthread_create
+ Ok(Thread { id: native })
+ };
+
+ extern "C" fn thread_start(main: *mut libc::c_void) -> *mut libc::c_void {
+ unsafe {
+ start_thread(main as *mut u8);
+ }
+ ptr::null_mut()
+ }
+ }
+
+ pub fn yield_now() {
+ let ret = unsafe { abi::thread_yield() };
+ debug_assert_eq!(ret, abi::errno::SUCCESS);
+ }
+
+ pub fn set_name(_name: &CStr) {
+ // CloudABI has no way to set a thread name.
+ }
+
+ pub fn sleep(dur: Duration) {
+ unsafe {
+ let subscription = abi::subscription {
+ type_: abi::eventtype::CLOCK,
+ union: abi::subscription_union {
+ clock: abi::subscription_clock {
+ clock_id: abi::clockid::MONOTONIC,
+ timeout: dur2intervals(&dur),
+ ..mem::zeroed()
+ },
+ },
+ ..mem::zeroed()
+ };
+ let mut event: abi::event = mem::uninitialized();
+ let mut nevents: usize = mem::uninitialized();
+ let ret = abi::poll(&subscription, &mut event, 1, &mut nevents);
+ assert_eq!(ret, abi::errno::SUCCESS);
+ assert_eq!(event.error, abi::errno::SUCCESS);
+ }
+ }
+
+ pub fn join(self) {
+ unsafe {
+ let ret = libc::pthread_join(self.id, ptr::null_mut());
+ mem::forget(self);
+ assert!(
+ ret == 0,
+ "failed to join thread: {}",
+ io::Error::from_raw_os_error(ret)
+ );
+ }
+ }
+}
+
+impl Drop for Thread {
+ fn drop(&mut self) {
+ let ret = unsafe { libc::pthread_detach(self.id) };
+ debug_assert_eq!(ret, 0);
+ }
+}
+
+#[cfg_attr(test, allow(dead_code))]
+pub mod guard {
+ pub unsafe fn current() -> Option<usize> {
+ None
+ }
+ pub unsafe fn init() -> Option<usize> {
+ None
+ }
+}
+
+fn min_stack_size(_: *const libc::pthread_attr_t) -> usize {
+ libc::PTHREAD_STACK_MIN
+}
diff --git a/src/libstd/sys/cloudabi/time.rs b/src/libstd/sys/cloudabi/time.rs
new file mode 100644
index 0000000..ee12731
--- /dev/null
+++ b/src/libstd/sys/cloudabi/time.rs
@@ -0,0 +1,111 @@
+// Copyright 2018 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use mem;
+use sys::cloudabi::abi;
+use time::Duration;
+
+const NSEC_PER_SEC: abi::timestamp = 1_000_000_000;
+
+#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
+pub struct Instant {
+ t: abi::timestamp,
+}
+
+pub fn dur2intervals(dur: &Duration) -> abi::timestamp {
+ dur.as_secs()
+ .checked_mul(NSEC_PER_SEC)
+ .and_then(|nanos| nanos.checked_add(dur.subsec_nanos() as abi::timestamp))
+ .expect("overflow converting duration to nanoseconds")
+}
+
+impl Instant {
+ pub fn now() -> Instant {
+ unsafe {
+ let mut t = mem::uninitialized();
+ let ret = abi::clock_time_get(abi::clockid::MONOTONIC, 0, &mut t);
+ assert_eq!(ret, abi::errno::SUCCESS);
+ Instant { t: t }
+ }
+ }
+
+ pub fn sub_instant(&self, other: &Instant) -> Duration {
+ let diff = self.t
+ .checked_sub(other.t)
+ .expect("second instant is later than self");
+ Duration::new(diff / NSEC_PER_SEC, (diff % NSEC_PER_SEC) as u32)
+ }
+
+ pub fn add_duration(&self, other: &Duration) -> Instant {
+ Instant {
+ t: self.t
+ .checked_add(dur2intervals(other))
+ .expect("overflow when adding duration to instant"),
+ }
+ }
+
+ pub fn sub_duration(&self, other: &Duration) -> Instant {
+ Instant {
+ t: self.t
+ .checked_sub(dur2intervals(other))
+ .expect("overflow when subtracting duration from instant"),
+ }
+ }
+}
+
+#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
+pub struct SystemTime {
+ t: abi::timestamp,
+}
+
+impl SystemTime {
+ pub fn now() -> SystemTime {
+ unsafe {
+ let mut t = mem::uninitialized();
+ let ret = abi::clock_time_get(abi::clockid::REALTIME, 0, &mut t);
+ assert_eq!(ret, abi::errno::SUCCESS);
+ SystemTime { t: t }
+ }
+ }
+
+ pub fn sub_time(&self, other: &SystemTime) -> Result<Duration, Duration> {
+ if self.t >= other.t {
+ let diff = self.t - other.t;
+ Ok(Duration::new(
+ diff / NSEC_PER_SEC,
+ (diff % NSEC_PER_SEC) as u32,
+ ))
+ } else {
+ let diff = other.t - self.t;
+ Err(Duration::new(
+ diff / NSEC_PER_SEC,
+ (diff % NSEC_PER_SEC) as u32,
+ ))
+ }
+ }
+
+ pub fn add_duration(&self, other: &Duration) -> SystemTime {
+ SystemTime {
+ t: self.t
+ .checked_add(dur2intervals(other))
+ .expect("overflow when adding duration to instant"),
+ }
+ }
+
+ pub fn sub_duration(&self, other: &Duration) -> SystemTime {
+ SystemTime {
+ t: self.t
+ .checked_sub(dur2intervals(other))
+ .expect("overflow when subtracting duration from instant"),
+ }
+ }
+}
+
+pub const UNIX_EPOCH: SystemTime = SystemTime { t: 0 };
diff --git a/src/libstd/sys/mod.rs b/src/libstd/sys/mod.rs
index be8cb88..1231898 100644
--- a/src/libstd/sys/mod.rs
+++ b/src/libstd/sys/mod.rs
@@ -39,6 +39,9 @@
} else if #[cfg(windows)] {
mod windows;
pub use self::windows::*;
+ } else if #[cfg(target_os = "cloudabi")] {
+ mod cloudabi;
+ pub use self::cloudabi::*;
} else if #[cfg(target_os = "redox")] {
mod redox;
pub use self::redox::*;
@@ -59,9 +62,10 @@
if #[cfg(any(unix, target_os = "redox"))] {
// On unix we'll document what's already available
pub use self::ext as unix_ext;
- } else if #[cfg(target_arch = "wasm32")] {
- // On wasm right now the module below doesn't compile (missing things
- // in `libc` which is empty) so just omit everything with an empty module
+ } else if #[cfg(any(target_os = "cloudabi", target_arch = "wasm32"))] {
+ // On CloudABI and wasm right now the module below doesn't compile
+ // (missing things in `libc` which is empty) so just omit everything
+ // with an empty module
#[unstable(issue = "0", feature = "std_internals")]
pub mod unix_ext {}
} else {
@@ -77,8 +81,9 @@
if #[cfg(windows)] {
// On windows we'll just be documenting what's already available
pub use self::ext as windows_ext;
- } else if #[cfg(target_arch = "wasm32")] {
- // On wasm right now the shim below doesn't compile, so just omit it
+ } else if #[cfg(any(target_os = "cloudabi", target_arch = "wasm32"))] {
+ // On CloudABI and wasm right now the shim below doesn't compile, so
+ // just omit it
#[unstable(issue = "0", feature = "std_internals")]
pub mod windows_ext {}
} else {
diff --git a/src/libstd/sys_common/mod.rs b/src/libstd/sys_common/mod.rs
index 938e865..27504d3 100644
--- a/src/libstd/sys_common/mod.rs
+++ b/src/libstd/sys_common/mod.rs
@@ -46,7 +46,7 @@
pub mod process;
cfg_if! {
- if #[cfg(any(target_os = "redox", target_os = "l4re"))] {
+ if #[cfg(any(target_os = "cloudabi", target_os = "l4re", target_os = "redox"))] {
pub use sys::net;
} else if #[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))] {
pub use sys::net;
diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs
index 129defd..a58a61c3 100644
--- a/src/libsyntax/codemap.rs
+++ b/src/libsyntax/codemap.rs
@@ -131,6 +131,9 @@
// -Zremap-path-prefix to all FileMaps allocated within this CodeMap.
path_mapping: FilePathMapping,
stable_id_to_filemap: RefCell<FxHashMap<StableFilemapId, Rc<FileMap>>>,
+ /// In case we are in a doctest, replace all file names with the PathBuf,
+ /// and add the given offsets to the line info
+ doctest_offset: Option<(FileName, isize)>,
}
impl CodeMap {
@@ -140,9 +143,19 @@
file_loader: Box::new(RealFileLoader),
path_mapping,
stable_id_to_filemap: RefCell::new(FxHashMap()),
+ doctest_offset: None,
}
}
+ pub fn new_doctest(path_mapping: FilePathMapping,
+ file: FileName, line: isize) -> CodeMap {
+ CodeMap {
+ doctest_offset: Some((file, line)),
+ ..CodeMap::new(path_mapping)
+ }
+
+ }
+
pub fn with_file_loader(file_loader: Box<FileLoader>,
path_mapping: FilePathMapping)
-> CodeMap {
@@ -151,6 +164,7 @@
file_loader,
path_mapping,
stable_id_to_filemap: RefCell::new(FxHashMap()),
+ doctest_offset: None,
}
}
@@ -164,7 +178,12 @@
pub fn load_file(&self, path: &Path) -> io::Result<Rc<FileMap>> {
let src = self.file_loader.read_file(path)?;
- Ok(self.new_filemap(path.to_owned().into(), src))
+ let filename = if let Some((ref name, _)) = self.doctest_offset {
+ name.clone()
+ } else {
+ path.to_owned().into()
+ };
+ Ok(self.new_filemap(filename, src))
}
pub fn files(&self) -> Ref<Vec<Rc<FileMap>>> {
@@ -303,6 +322,18 @@
pos.col.to_usize() + 1)).to_string()
}
+ // If there is a doctest_offset, apply it to the line
+ pub fn doctest_offset_line(&self, mut orig: usize) -> usize {
+ if let Some((_, line)) = self.doctest_offset {
+ if line >= 0 {
+ orig = orig + line as usize;
+ } else {
+ orig = orig - (-line) as usize;
+ }
+ }
+ orig
+ }
+
/// Lookup source information about a BytePos
pub fn lookup_char_pos(&self, pos: BytePos) -> Loc {
let chpos = self.bytepos_to_file_charpos(pos);
@@ -681,6 +712,9 @@
}
)
}
+ fn doctest_offset_line(&self, line: usize) -> usize {
+ self.doctest_offset_line(line)
+ }
}
#[derive(Clone)]
diff --git a/src/libsyntax/diagnostic_list.rs b/src/libsyntax/diagnostic_list.rs
index c3cf474..d841281 100644
--- a/src/libsyntax/diagnostic_list.rs
+++ b/src/libsyntax/diagnostic_list.rs
@@ -317,6 +317,31 @@
```
"##,
+E0658: r##"
+An unstable feature was used.
+
+Erroneous code example:
+
+```compile_fail,E658
+let x = ::std::u128::MAX; // error: use of unstable library feature 'i128'
+```
+
+If you're using a stable or a beta version of rustc, you won't be able to use
+any unstable features. In order to do so, please switch to a nightly version of
+rustc (by using rustup).
+
+If you're using a nightly version of rustc, just add the corresponding feature
+to be able to use it:
+
+```
+#![feature(i128)]
+
+fn main() {
+ let x = ::std::u128::MAX; // ok!
+}
+```
+"##,
+
}
register_diagnostics! {
diff --git a/src/libsyntax/diagnostics/macros.rs b/src/libsyntax/diagnostics/macros.rs
index c01836b..61f3e70 100644
--- a/src/libsyntax/diagnostics/macros.rs
+++ b/src/libsyntax/diagnostics/macros.rs
@@ -106,6 +106,14 @@
}
#[macro_export]
+macro_rules! stringify_error_code {
+ ($code:ident) => ({
+ __diagnostic_used!($code);
+ $crate::errors::DiagnosticId::Error(stringify!($code).to_owned())
+ })
+}
+
+#[macro_export]
macro_rules! type_error_struct {
($session:expr, $span:expr, $typ:expr, $code:ident, $($message:tt)*) => ({
if $typ.references_error() {
diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs
index c3bf5db..196fadc 100644
--- a/src/libsyntax/feature_gate.rs
+++ b/src/libsyntax/feature_gate.rs
@@ -1179,7 +1179,9 @@
};
let mut err = match level {
- GateStrength::Hard => diag.struct_span_err(span, &explanation),
+ GateStrength::Hard => {
+ diag.struct_span_err_with_code(span, &explanation, stringify_error_code!(E0658))
+ }
GateStrength::Soft => diag.struct_span_warn(span, &explanation),
};
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index ad9c802..e7565d3 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -71,7 +71,7 @@
}
}
-type ItemInfo = (Ident, ItemKind, Option<Vec<Attribute> >);
+type ItemInfo = (Ident, ItemKind, Option<Vec<Attribute>>);
/// How to parse a path.
#[derive(Copy, Clone, PartialEq)]
@@ -151,10 +151,9 @@
};
}
-fn maybe_append(mut lhs: Vec<Attribute>, rhs: Option<Vec<Attribute>>)
- -> Vec<Attribute> {
- if let Some(ref attrs) = rhs {
- lhs.extend(attrs.iter().cloned())
+fn maybe_append(mut lhs: Vec<Attribute>, mut rhs: Option<Vec<Attribute>>) -> Vec<Attribute> {
+ if let Some(ref mut rhs) = rhs {
+ lhs.append(rhs);
}
lhs
}
@@ -1347,7 +1346,7 @@
Function Style
*/
- let unsafety = self.parse_unsafety()?;
+ let unsafety = self.parse_unsafety();
let abi = if self.eat_keyword(keywords::Extern) {
self.parse_opt_abi()?.unwrap_or(Abi::C)
} else {
@@ -1370,11 +1369,12 @@
})))
}
- pub fn parse_unsafety(&mut self) -> PResult<'a, Unsafety> {
+ /// Parse unsafety: `unsafe` or nothing.
+ fn parse_unsafety(&mut self) -> Unsafety {
if self.eat_keyword(keywords::Unsafe) {
- return Ok(Unsafety::Unsafe);
+ Unsafety::Unsafe
} else {
- return Ok(Unsafety::Normal);
+ Unsafety::Normal
}
}
@@ -4094,28 +4094,6 @@
self.look_ahead(2, |t| t.is_keyword(keywords::Trait)))
}
- fn is_defaultness(&self) -> bool {
- // `pub` is included for better error messages
- self.token.is_keyword(keywords::Default) &&
- self.look_ahead(1, |t| t.is_keyword(keywords::Impl) ||
- t.is_keyword(keywords::Const) ||
- t.is_keyword(keywords::Fn) ||
- t.is_keyword(keywords::Unsafe) ||
- t.is_keyword(keywords::Extern) ||
- t.is_keyword(keywords::Type) ||
- t.is_keyword(keywords::Pub))
- }
-
- fn eat_defaultness(&mut self) -> bool {
- let is_defaultness = self.is_defaultness();
- if is_defaultness {
- self.bump()
- } else {
- self.expected_tokens.push(TokenType::Keyword(keywords::Default));
- }
- is_defaultness
- }
-
fn eat_macro_def(&mut self, attrs: &[Attribute], vis: &Visibility, lo: Span)
-> PResult<'a, Option<P<Item>>> {
let token_lo = self.span;
@@ -4794,21 +4772,13 @@
}
let lo = self.prev_span;
- // This is a temporary future proofing.
- //
// We are considering adding generics to the `where` keyword as an alternative higher-rank
// parameter syntax (as in `where<'a>` or `where<T>`. To avoid that being a breaking
- // change, for now we refuse to parse `where < (ident | lifetime) (> | , | :)`.
- if token::Lt == self.token {
- let ident_or_lifetime = self.look_ahead(1, |t| t.is_ident() || t.is_lifetime());
- if ident_or_lifetime {
- let gt_comma_or_colon = self.look_ahead(2, |t| {
- *t == token::Gt || *t == token::Comma || *t == token::Colon
- });
- if gt_comma_or_colon {
- self.span_err(self.span, "syntax `where<T>` is reserved for future use");
- }
- }
+ // change we parse those generics now, but report an error.
+ if self.choose_generics_over_qpath() {
+ let generics = self.parse_generics()?;
+ self.span_err(generics.span,
+ "generic parameters on `where` clauses are reserved for future use");
}
loop {
@@ -5126,7 +5096,7 @@
fn parse_item_fn(&mut self,
unsafety: Unsafety,
constness: Spanned<Constness>,
- abi: abi::Abi)
+ abi: Abi)
-> PResult<'a, ItemInfo> {
let (ident, mut generics) = self.parse_fn_header()?;
let decl = self.parse_fn_decl(false)?;
@@ -5150,13 +5120,10 @@
/// - `const unsafe fn`
/// - `extern fn`
/// - etc
- pub fn parse_fn_front_matter(&mut self)
- -> PResult<'a, (Spanned<ast::Constness>,
- ast::Unsafety,
- abi::Abi)> {
+ pub fn parse_fn_front_matter(&mut self) -> PResult<'a, (Spanned<Constness>, Unsafety, Abi)> {
let is_const_fn = self.eat_keyword(keywords::Const);
let const_span = self.prev_span;
- let unsafety = self.parse_unsafety()?;
+ let unsafety = self.parse_unsafety();
let (constness, unsafety, abi) = if is_const_fn {
(respan(const_span, Constness::Const), unsafety, Abi::Rust)
} else {
@@ -5191,7 +5158,7 @@
mut attrs: Vec<Attribute>) -> PResult<'a, ImplItem> {
let lo = self.span;
let vis = self.parse_visibility(false)?;
- let defaultness = self.parse_defaultness()?;
+ let defaultness = self.parse_defaultness();
let (name, node, generics) = if self.eat_keyword(keywords::Type) {
// This parses the grammar:
// ImplItemAssocTy = Ident ["<"...">"] ["where" ...] "=" Ty ";"
@@ -5284,7 +5251,7 @@
/// Parse a method or a macro invocation in a trait impl.
fn parse_impl_method(&mut self, vis: &Visibility, at_end: &mut bool)
- -> PResult<'a, (Ident, Vec<ast::Attribute>, ast::Generics,
+ -> PResult<'a, (Ident, Vec<Attribute>, ast::Generics,
ast::ImplItemKind)> {
// code copied from parse_macro_use_or_failure... abstraction!
if self.token.is_path_start() && !self.is_extern_non_path() {
@@ -5373,83 +5340,123 @@
}
}
- /// Parses items implementations variants
- /// impl<T> Foo { ... }
- /// impl<T> ToString for &'static T { ... }
- fn parse_item_impl(&mut self,
- unsafety: ast::Unsafety,
- defaultness: Defaultness) -> PResult<'a, ItemInfo> {
+ fn choose_generics_over_qpath(&self) -> bool {
+ // There's an ambiguity between generic parameters and qualified paths in impls.
+ // If we see `<` it may start both, so we have to inspect some following tokens.
+ // The following combinations can only start generics,
+ // but not qualified paths (with one exception):
+ // `<` `>` - empty generic parameters
+ // `<` `#` - generic parameters with attributes
+ // `<` (LIFETIME|IDENT) `>` - single generic parameter
+ // `<` (LIFETIME|IDENT) `,` - first generic parameter in a list
+ // `<` (LIFETIME|IDENT) `:` - generic parameter with bounds
+ // `<` (LIFETIME|IDENT) `=` - generic parameter with a default
+ // The only truly ambiguous case is
+ // `<` IDENT `>` `::` IDENT ...
+ // we disambiguate it in favor of generics (`impl<T> ::absolute::Path<T> { ... }`)
+ // because this is what almost always expected in practice, qualified paths in impls
+ // (`impl <Type>::AssocTy { ... }`) aren't even allowed by type checker at the moment.
+ self.token == token::Lt &&
+ (self.look_ahead(1, |t| t == &token::Pound || t == &token::Gt) ||
+ self.look_ahead(1, |t| t.is_lifetime() || t.is_ident()) &&
+ self.look_ahead(2, |t| t == &token::Gt || t == &token::Comma ||
+ t == &token::Colon || t == &token::Eq))
+ }
- // First, parse type parameters if necessary.
- let mut generics = self.parse_generics()?;
-
- // Special case: if the next identifier that follows is '(', don't
- // allow this to be parsed as a trait.
- let could_be_trait = self.token != token::OpenDelim(token::Paren);
-
- let neg_span = self.span;
- let polarity = if self.eat(&token::Not) {
- ast::ImplPolarity::Negative
- } else {
- ast::ImplPolarity::Positive
- };
-
- // Parse the trait.
- let mut ty = self.parse_ty()?;
-
- // Parse traits, if necessary.
- let opt_trait = if could_be_trait && self.eat_keyword(keywords::For) {
- // New-style trait. Reinterpret the type as a trait.
- match ty.node {
- TyKind::Path(None, ref path) => {
- Some(TraitRef {
- path: (*path).clone(),
- ref_id: ty.id,
- })
- }
- _ => {
- self.span_err(ty.span, "not a trait");
- None
- }
- }
- } else {
- if polarity == ast::ImplPolarity::Negative {
- // This is a negated type implementation
- // `impl !MyType {}`, which is not allowed.
- self.span_err(neg_span, "inherent implementation can't be negated");
- }
- None
- };
-
- if opt_trait.is_some() {
- ty = if self.eat(&token::DotDot) {
- P(Ty { node: TyKind::Err, span: self.prev_span, id: ast::DUMMY_NODE_ID })
- } else {
- self.parse_ty()?
- }
- }
- generics.where_clause = self.parse_where_clause()?;
-
+ fn parse_impl_body(&mut self) -> PResult<'a, (Vec<ImplItem>, Vec<Attribute>)> {
self.expect(&token::OpenDelim(token::Brace))?;
let attrs = self.parse_inner_attributes()?;
- let mut impl_items = vec![];
+ let mut impl_items = Vec::new();
while !self.eat(&token::CloseDelim(token::Brace)) {
let mut at_end = false;
match self.parse_impl_item(&mut at_end) {
- Ok(item) => impl_items.push(item),
- Err(mut e) => {
- e.emit();
+ Ok(impl_item) => impl_items.push(impl_item),
+ Err(mut err) => {
+ err.emit();
if !at_end {
self.recover_stmt_(SemiColonMode::Break, BlockMode::Break);
}
}
}
}
+ Ok((impl_items, attrs))
+ }
- Ok((keywords::Invalid.ident(),
- ItemKind::Impl(unsafety, polarity, defaultness, generics, opt_trait, ty, impl_items),
- Some(attrs)))
+ /// Parses an implementation item, `impl` keyword is already parsed.
+ /// impl<'a, T> TYPE { /* impl items */ }
+ /// impl<'a, T> TRAIT for TYPE { /* impl items */ }
+ /// impl<'a, T> !TRAIT for TYPE { /* impl items */ }
+ /// We actually parse slightly more relaxed grammar for better error reporting and recovery.
+ /// `impl` GENERICS `!`? TYPE `for`? (TYPE | `..`) (`where` PREDICATES)? `{` BODY `}`
+ /// `impl` GENERICS `!`? TYPE (`where` PREDICATES)? `{` BODY `}`
+ fn parse_item_impl(&mut self, unsafety: Unsafety, defaultness: Defaultness)
+ -> PResult<'a, ItemInfo> {
+ // First, parse generic parameters if necessary.
+ let mut generics = if self.choose_generics_over_qpath() {
+ self.parse_generics()?
+ } else {
+ ast::Generics::default()
+ };
+
+ // Disambiguate `impl !Trait for Type { ... }` and `impl ! { ... }` for the never type.
+ let polarity = if self.check(&token::Not) && self.look_ahead(1, |t| t.can_begin_type()) {
+ self.bump(); // `!`
+ ast::ImplPolarity::Negative
+ } else {
+ ast::ImplPolarity::Positive
+ };
+
+ // Parse both types and traits as a type, then reinterpret if necessary.
+ let ty_first = self.parse_ty()?;
+
+ // If `for` is missing we try to recover.
+ let has_for = self.eat_keyword(keywords::For);
+ let missing_for_span = self.prev_span.between(self.span);
+
+ let ty_second = if self.token == token::DotDot {
+ // We need to report this error after `cfg` expansion for compatibility reasons
+ self.bump(); // `..`, do not add it to expected tokens
+ Some(P(Ty { node: TyKind::Err, span: self.prev_span, id: ast::DUMMY_NODE_ID }))
+ } else if has_for || self.token.can_begin_type() {
+ Some(self.parse_ty()?)
+ } else {
+ None
+ };
+
+ generics.where_clause = self.parse_where_clause()?;
+
+ let (impl_items, attrs) = self.parse_impl_body()?;
+
+ let item_kind = match ty_second {
+ Some(ty_second) => {
+ // impl Trait for Type
+ if !has_for {
+ self.span_err(missing_for_span, "missing `for` in a trait impl");
+ }
+
+ let ty_first = ty_first.into_inner();
+ let path = match ty_first.node {
+ // This notably includes paths passed through `ty` macro fragments (#46438).
+ TyKind::Path(None, path) => path,
+ _ => {
+ self.span_err(ty_first.span, "expected a trait, found type");
+ ast::Path::from_ident(ty_first.span, keywords::Invalid.ident())
+ }
+ };
+ let trait_ref = TraitRef { path, ref_id: ty_first.id };
+
+ ItemKind::Impl(unsafety, polarity, defaultness,
+ generics, Some(trait_ref), ty_second, impl_items)
+ }
+ None => {
+ // impl Type
+ ItemKind::Impl(unsafety, polarity, defaultness,
+ generics, None, ty_first, impl_items)
+ }
+ };
+
+ Ok((keywords::Invalid.ident(), item_kind, Some(attrs)))
}
fn parse_late_bound_lifetime_defs(&mut self) -> PResult<'a, Vec<GenericParam>> {
@@ -5722,12 +5729,21 @@
Ok(Visibility::Public)
}
- /// Parse defaultness: DEFAULT or nothing
- fn parse_defaultness(&mut self) -> PResult<'a, Defaultness> {
- if self.eat_defaultness() {
- Ok(Defaultness::Default)
+ /// Parse defaultness: `default` or nothing.
+ fn parse_defaultness(&mut self) -> Defaultness {
+ // `pub` is included for better error messages
+ if self.check_keyword(keywords::Default) &&
+ self.look_ahead(1, |t| t.is_keyword(keywords::Impl) ||
+ t.is_keyword(keywords::Const) ||
+ t.is_keyword(keywords::Fn) ||
+ t.is_keyword(keywords::Unsafe) ||
+ t.is_keyword(keywords::Extern) ||
+ t.is_keyword(keywords::Type) ||
+ t.is_keyword(keywords::Pub)) {
+ self.bump(); // `default`
+ Defaultness::Default
} else {
- Ok(Defaultness::Final)
+ Defaultness::Final
}
}
@@ -5797,7 +5813,7 @@
let (module, mut attrs) =
self.eval_src_mod(path, directory_ownership, id.to_string(), id_span)?;
if warn {
- let attr = ast::Attribute {
+ let attr = Attribute {
id: attr::mk_attr_id(),
style: ast::AttrStyle::Outer,
path: ast::Path::from_ident(syntax_pos::DUMMY_SP,
@@ -5837,7 +5853,7 @@
}
}
- pub fn submod_path_from_attr(attrs: &[ast::Attribute], dir_path: &Path) -> Option<PathBuf> {
+ pub fn submod_path_from_attr(attrs: &[Attribute], dir_path: &Path) -> Option<PathBuf> {
attr::first_attr_value_str_by_name(attrs, "path").map(|d| dir_path.join(&d.as_str()))
}
@@ -5906,7 +5922,7 @@
fn submod_path(&mut self,
id: ast::Ident,
- outer_attrs: &[ast::Attribute],
+ outer_attrs: &[Attribute],
id_sp: Span)
-> PResult<'a, ModulePathSuccess> {
if let Some(path) = Parser::submod_path_from_attr(outer_attrs, &self.directory.path) {
@@ -5999,7 +6015,7 @@
directory_ownership: DirectoryOwnership,
name: String,
id_sp: Span)
- -> PResult<'a, (ast::ItemKind, Vec<ast::Attribute> )> {
+ -> PResult<'a, (ast::ItemKind, Vec<Attribute> )> {
let mut included_mod_stack = self.sess.included_mod_stack.borrow_mut();
if let Some(i) = included_mod_stack.iter().position(|p| *p == path) {
let mut err = String::from("circular modules: ");
@@ -6122,7 +6138,7 @@
/// extern {}
fn parse_item_foreign_mod(&mut self,
lo: Span,
- opt_abi: Option<abi::Abi>,
+ opt_abi: Option<Abi>,
visibility: Visibility,
mut attrs: Vec<Attribute>)
-> PResult<'a, P<Item>> {
@@ -6225,7 +6241,7 @@
/// Parses a string as an ABI spec on an extern type or module. Consumes
/// the `extern` keyword, if one is found.
- fn parse_opt_abi(&mut self) -> PResult<'a, Option<abi::Abi>> {
+ fn parse_opt_abi(&mut self) -> PResult<'a, Option<Abi>> {
match self.token {
token::Literal(token::Str_(s), suf) | token::Literal(token::StrRaw(s, _), suf) => {
let sp = self.span;
@@ -6330,11 +6346,7 @@
|| (self.check_keyword(keywords::Unsafe)
&& self.look_ahead(1, |t| t.is_keyword(keywords::Fn))) {
// CONST FUNCTION ITEM
- let unsafety = if self.eat_keyword(keywords::Unsafe) {
- Unsafety::Unsafe
- } else {
- Unsafety::Normal
- };
+ let unsafety = self.parse_unsafety();
self.bump();
let (ident, item_, extra_attrs) =
self.parse_item_fn(unsafety,
@@ -6370,7 +6382,7 @@
self.look_ahead(1, |t| t.is_keyword(keywords::Auto)))
{
// UNSAFE TRAIT ITEM
- self.expect_keyword(keywords::Unsafe)?;
+ self.bump(); // `unsafe`
let is_auto = if self.eat_keyword(keywords::Trait) {
IsAuto::No
} else {
@@ -6379,7 +6391,7 @@
IsAuto::Yes
};
let (ident, item_, extra_attrs) =
- self.parse_item_trait(is_auto, ast::Unsafety::Unsafe)?;
+ self.parse_item_trait(is_auto, Unsafety::Unsafe)?;
let prev_span = self.prev_span;
let item = self.mk_item(lo.to(prev_span),
ident,
@@ -6388,26 +6400,21 @@
maybe_append(attrs, extra_attrs));
return Ok(Some(item));
}
- if (self.check_keyword(keywords::Unsafe) &&
- self.look_ahead(1, |t| t.is_keyword(keywords::Impl))) ||
- (self.check_keyword(keywords::Default) &&
- self.look_ahead(1, |t| t.is_keyword(keywords::Unsafe)) &&
- self.look_ahead(2, |t| t.is_keyword(keywords::Impl)))
- {
+ if self.check_keyword(keywords::Impl) ||
+ self.check_keyword(keywords::Unsafe) &&
+ self.look_ahead(1, |t| t.is_keyword(keywords::Impl)) ||
+ self.check_keyword(keywords::Default) &&
+ self.look_ahead(1, |t| t.is_keyword(keywords::Impl)) ||
+ self.check_keyword(keywords::Default) &&
+ self.look_ahead(1, |t| t.is_keyword(keywords::Unsafe)) {
// IMPL ITEM
- let defaultness = self.parse_defaultness()?;
- self.expect_keyword(keywords::Unsafe)?;
+ let defaultness = self.parse_defaultness();
+ let unsafety = self.parse_unsafety();
self.expect_keyword(keywords::Impl)?;
- let (ident,
- item_,
- extra_attrs) = self.parse_item_impl(ast::Unsafety::Unsafe, defaultness)?;
- let prev_span = self.prev_span;
- let item = self.mk_item(lo.to(prev_span),
- ident,
- item_,
- visibility,
- maybe_append(attrs, extra_attrs));
- return Ok(Some(item));
+ let (ident, item, extra_attrs) = self.parse_item_impl(unsafety, defaultness)?;
+ let span = lo.to(self.prev_span);
+ return Ok(Some(self.mk_item(span, ident, item, visibility,
+ maybe_append(attrs, extra_attrs))));
}
if self.check_keyword(keywords::Fn) {
// FUNCTION ITEM
@@ -6428,7 +6435,7 @@
if self.check_keyword(keywords::Unsafe)
&& self.look_ahead(1, |t| *t != token::OpenDelim(token::Brace)) {
// UNSAFE FUNCTION ITEM
- self.bump();
+ self.bump(); // `unsafe`
let abi = if self.eat_keyword(keywords::Extern) {
self.parse_opt_abi()?.unwrap_or(Abi::C)
} else {
@@ -6495,25 +6502,7 @@
};
// TRAIT ITEM
let (ident, item_, extra_attrs) =
- self.parse_item_trait(is_auto, ast::Unsafety::Normal)?;
- let prev_span = self.prev_span;
- let item = self.mk_item(lo.to(prev_span),
- ident,
- item_,
- visibility,
- maybe_append(attrs, extra_attrs));
- return Ok(Some(item));
- }
- if (self.check_keyword(keywords::Impl)) ||
- (self.check_keyword(keywords::Default) &&
- self.look_ahead(1, |t| t.is_keyword(keywords::Impl)))
- {
- // IMPL ITEM
- let defaultness = self.parse_defaultness()?;
- self.expect_keyword(keywords::Impl)?;
- let (ident,
- item_,
- extra_attrs) = self.parse_item_impl(ast::Unsafety::Normal, defaultness)?;
+ self.parse_item_trait(is_auto, Unsafety::Normal)?;
let prev_span = self.prev_span;
let item = self.mk_item(lo.to(prev_span),
ident,
diff --git a/src/test/compile-fail/E0198.rs b/src/test/compile-fail/E0198.rs
index 892989c..1a779a4 100644
--- a/src/test/compile-fail/E0198.rs
+++ b/src/test/compile-fail/E0198.rs
@@ -12,7 +12,7 @@
struct Foo;
-unsafe impl !Clone for Foo { } //~ ERROR negative implementations are not unsafe [E0198]
+unsafe impl !Send for Foo { } //~ ERROR E0198
fn main() {
}
diff --git a/src/test/compile-fail/E0658.rs b/src/test/compile-fail/E0658.rs
new file mode 100644
index 0000000..d30068e
--- /dev/null
+++ b/src/test/compile-fail/E0658.rs
@@ -0,0 +1,13 @@
+// Copyright 2018 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+fn main() {
+ let _ = ::std::u128::MAX; //~ ERROR E0658
+}
diff --git a/src/test/compile-fail/closure-bounds-static-cant-capture-borrowed.rs b/src/test/compile-fail/closure-bounds-static-cant-capture-borrowed.rs
index 513a17e..1ffba68 100644
--- a/src/test/compile-fail/closure-bounds-static-cant-capture-borrowed.rs
+++ b/src/test/compile-fail/closure-bounds-static-cant-capture-borrowed.rs
@@ -13,7 +13,7 @@
fn foo(x: &()) {
bar(|| {
- //~^ ERROR does not fulfill
+ //~^ ERROR explicit lifetime required in the type of `x` [E0621]
let _ = x;
})
}
diff --git a/src/test/compile-fail/coherence-negative-impls-safe.rs b/src/test/compile-fail/coherence-negative-impls-safe.rs
index 3b335d5..1ae07b6 100644
--- a/src/test/compile-fail/coherence-negative-impls-safe.rs
+++ b/src/test/compile-fail/coherence-negative-impls-safe.rs
@@ -15,6 +15,6 @@
struct TestType;
unsafe impl !Send for TestType {}
-//~^ ERROR negative implementations are not unsafe
+//~^ ERROR negative impls cannot be unsafe
fn main() {}
diff --git a/src/test/compile-fail/impl-trait/must_outlive_least_region_or_bound.rs b/src/test/compile-fail/impl-trait/must_outlive_least_region_or_bound.rs
index 837160b..0eb99ca 100644
--- a/src/test/compile-fail/impl-trait/must_outlive_least_region_or_bound.rs
+++ b/src/test/compile-fail/impl-trait/must_outlive_least_region_or_bound.rs
@@ -13,7 +13,7 @@
use std::fmt::Debug;
fn elided(x: &i32) -> impl Copy { x }
-//~^ ERROR cannot infer an appropriate lifetime
+//~^ ERROR explicit lifetime required in the type of `x` [E0621]
fn explicit<'a>(x: &'a i32) -> impl Copy { x }
//~^ ERROR cannot infer an appropriate lifetime
diff --git a/src/test/compile-fail/issue-16922.rs b/src/test/compile-fail/issue-16922.rs
index b525d5f..1768c83 100644
--- a/src/test/compile-fail/issue-16922.rs
+++ b/src/test/compile-fail/issue-16922.rs
@@ -12,7 +12,7 @@
fn foo<T: Any>(value: &T) -> Box<Any> {
Box::new(value) as Box<Any>
- //~^ ERROR: cannot infer an appropriate lifetime
+ //~^ ERROR explicit lifetime required in the type of `value` [E0621]
}
fn main() {
diff --git a/src/test/compile-fail/issue-43925.rs b/src/test/compile-fail/issue-43925.rs
new file mode 100644
index 0000000..8ad5764
--- /dev/null
+++ b/src/test/compile-fail/issue-43925.rs
@@ -0,0 +1,16 @@
+// Copyright 2018 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(attr_literals)]
+
+#[link(name="foo", cfg("rlib"))] //~ ERROR invalid argument for `cfg(..)`
+extern {}
+
+fn main() {}
diff --git a/src/test/compile-fail/issue-43926.rs b/src/test/compile-fail/issue-43926.rs
new file mode 100644
index 0000000..5d510b6
--- /dev/null
+++ b/src/test/compile-fail/issue-43926.rs
@@ -0,0 +1,14 @@
+// Copyright 2018 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#[link(name="foo", cfg())] //~ ERROR `cfg()` must have an argument
+extern {}
+
+fn main() {}
diff --git a/src/test/compile-fail/issue-45199.rs b/src/test/compile-fail/issue-45199.rs
index af8f7dc..ecddb4c 100644
--- a/src/test/compile-fail/issue-45199.rs
+++ b/src/test/compile-fail/issue-45199.rs
@@ -31,11 +31,11 @@
}
fn test_args(b: Box<i32>) { //[ast]~ NOTE first assignment
- //[mir]~^ NOTE first assignment
+ //[mir]~^ NOTE argument not declared as `mut`
b = Box::new(2); //[ast]~ ERROR cannot assign twice to immutable variable
- //[mir]~^ ERROR cannot assign twice to immutable variable `b`
+ //[mir]~^ ERROR cannot assign to immutable argument `b`
//[ast]~| NOTE cannot assign twice to immutable
- //[mir]~| NOTE cannot assign twice to immutable
+ //[mir]~| NOTE cannot assign to immutable argument
}
fn main() {}
diff --git a/src/test/compile-fail/issue-46438.rs b/src/test/compile-fail/issue-46438.rs
new file mode 100644
index 0000000..d84b581
--- /dev/null
+++ b/src/test/compile-fail/issue-46438.rs
@@ -0,0 +1,23 @@
+// Copyright 2017 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+macro_rules! m {
+ ($my_type: ty) => {
+ impl $my_type for u8 {}
+ }
+}
+
+trait Trait {}
+
+m!(Tr);
+
+m!(&'static u8); //~ ERROR expected a trait, found type
+
+fn main() {}
diff --git a/src/test/compile-fail/object-lifetime-default-from-box-error.rs b/src/test/compile-fail/object-lifetime-default-from-box-error.rs
index c50f425..b253612 100644
--- a/src/test/compile-fail/object-lifetime-default-from-box-error.rs
+++ b/src/test/compile-fail/object-lifetime-default-from-box-error.rs
@@ -25,7 +25,7 @@
// `Box<SomeTrait>` defaults to a `'static` bound, so this return
// is illegal.
- ss.r //~ ERROR cannot infer an appropriate lifetime
+ ss.r //~ ERROR explicit lifetime required in the type of `ss` [E0621]
}
fn store(ss: &mut SomeStruct, b: Box<SomeTrait>) {
diff --git a/src/test/compile-fail/phantom-oibit.rs b/src/test/compile-fail/phantom-oibit.rs
index 52bc012..e36c483 100644
--- a/src/test/compile-fail/phantom-oibit.rs
+++ b/src/test/compile-fail/phantom-oibit.rs
@@ -9,8 +9,7 @@
// except according to those terms.
// Ensure that OIBIT checks `T` when it encounters a `PhantomData<T>` field, instead of checking
-// the `PhantomData<T>` type itself (which almost always implements a "default" trait
-// (`impl Trait for ..`))
+// the `PhantomData<T>` type itself (which almost always implements an auto trait)
#![feature(optin_builtin_traits)]
diff --git a/src/test/compile-fail/private-in-public-ill-formed.rs b/src/test/compile-fail/private-in-public-ill-formed.rs
index 4e10614..4804060 100644
--- a/src/test/compile-fail/private-in-public-ill-formed.rs
+++ b/src/test/compile-fail/private-in-public-ill-formed.rs
@@ -21,7 +21,7 @@
type AssocAlias = m::Pub3;
}
- impl (<Priv as PrivTr>::AssocAlias) { //~ ERROR no base type found for inherent implementation
+ impl <Priv as PrivTr>::AssocAlias { //~ ERROR no base type found for inherent implementation
pub fn f(arg: Priv) {} // private type `aliases_pub::Priv` in public interface
}
}
@@ -37,7 +37,7 @@
type AssocAlias = Priv3;
}
- impl (<Priv as PrivTr>::AssocAlias) { //~ ERROR no base type found for inherent implementation
+ impl <Priv as PrivTr>::AssocAlias { //~ ERROR no base type found for inherent implementation
pub fn f(arg: Priv) {} // OK
}
}
diff --git a/src/test/compile-fail/region-object-lifetime-in-coercion.rs b/src/test/compile-fail/region-object-lifetime-in-coercion.rs
index 687b2c3..5bf397a 100644
--- a/src/test/compile-fail/region-object-lifetime-in-coercion.rs
+++ b/src/test/compile-fail/region-object-lifetime-in-coercion.rs
@@ -16,20 +16,20 @@
fn a(v: &[u8]) -> Box<Foo + 'static> {
let x: Box<Foo + 'static> = Box::new(v);
- //~^ ERROR cannot infer an appropriate lifetime due to conflicting
+ //~^ ERROR explicit lifetime required in the type of `v` [E0621]
x
}
fn b(v: &[u8]) -> Box<Foo + 'static> {
Box::new(v)
- //~^ ERROR cannot infer an appropriate lifetime due to conflicting
+ //~^ ERROR explicit lifetime required in the type of `v` [E0621]
}
fn c(v: &[u8]) -> Box<Foo> {
// same as previous case due to RFC 599
Box::new(v)
- //~^ ERROR cannot infer an appropriate lifetime due to conflicting
+ //~^ ERROR explicit lifetime required in the type of `v` [E0621]
}
fn d<'a,'b>(v: &'a [u8]) -> Box<Foo+'b> {
diff --git a/src/test/compile-fail/regions-proc-bound-capture.rs b/src/test/compile-fail/regions-proc-bound-capture.rs
index 17fd55b..dd7b2bf 100644
--- a/src/test/compile-fail/regions-proc-bound-capture.rs
+++ b/src/test/compile-fail/regions-proc-bound-capture.rs
@@ -16,7 +16,7 @@
fn static_proc(x: &isize) -> Box<FnMut()->(isize) + 'static> {
// This is illegal, because the region bound on `proc` is 'static.
- Box::new(move|| { *x }) //~ ERROR cannot infer an appropriate lifetime
+ Box::new(move|| { *x }) //~ ERROR explicit lifetime required in the type of `x` [E0621]
}
fn main() { }
diff --git a/src/test/compile-fail/regions-static-bound.rs b/src/test/compile-fail/regions-static-bound.rs
index a217cc9..13f9309 100644
--- a/src/test/compile-fail/regions-static-bound.rs
+++ b/src/test/compile-fail/regions-static-bound.rs
@@ -22,12 +22,12 @@
}
fn error(u: &(), v: &()) {
- static_id(&u); //[ll]~ ERROR cannot infer an appropriate lifetime
+ static_id(&u); //[ll]~ ERROR explicit lifetime required in the type of `u` [E0621]
//[nll]~^ WARNING not reporting region error due to -Znll
- //[nll]~| ERROR free region `` does not outlive free region `'static`
- static_id_indirect(&v); //[ll]~ ERROR cannot infer an appropriate lifetime
+ //[nll]~| ERROR explicit lifetime required in the type of `u` [E0621]
+ static_id_indirect(&v); //[ll]~ ERROR explicit lifetime required in the type of `v` [E0621]
//[nll]~^ WARNING not reporting region error due to -Znll
- //[nll]~| ERROR free region `` does not outlive free region `'static`
+ //[nll]~| ERROR explicit lifetime required in the type of `v` [E0621]
}
fn main() {}
diff --git a/src/test/compile-fail/specialization/defaultimpl/validation.rs b/src/test/compile-fail/specialization/defaultimpl/validation.rs
new file mode 100644
index 0000000..26b8b73
--- /dev/null
+++ b/src/test/compile-fail/specialization/defaultimpl/validation.rs
@@ -0,0 +1,23 @@
+// Copyright 2017 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(optin_builtin_traits)]
+#![feature(specialization)]
+
+struct S;
+struct Z;
+
+default impl S {} //~ ERROR inherent impls cannot be default
+
+default unsafe impl Send for S {} //~ ERROR impls of auto traits cannot be default
+default impl !Send for Z {} //~ ERROR impls of auto traits cannot be default
+
+trait Tr {}
+default impl !Tr for S {} //~ ERROR negative impls are only allowed for auto traits
diff --git a/src/test/compile-fail/syntax-trait-polarity-feature-gate.rs b/src/test/compile-fail/syntax-trait-polarity-feature-gate.rs
index a7ca5e3..8d5e89c 100644
--- a/src/test/compile-fail/syntax-trait-polarity-feature-gate.rs
+++ b/src/test/compile-fail/syntax-trait-polarity-feature-gate.rs
@@ -14,7 +14,7 @@
trait TestTrait {}
-unsafe impl !Send for TestType {}
+impl !Send for TestType {}
//~^ ERROR negative trait bounds
fn main() {}
diff --git a/src/test/parse-fail/syntax-trait-polarity.rs b/src/test/compile-fail/syntax-trait-polarity.rs
similarity index 70%
rename from src/test/parse-fail/syntax-trait-polarity.rs
rename to src/test/compile-fail/syntax-trait-polarity.rs
index 1971ffe..1a5d058 100644
--- a/src/test/parse-fail/syntax-trait-polarity.rs
+++ b/src/test/compile-fail/syntax-trait-polarity.rs
@@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-// compile-flags: -Z parse-only -Z continue-parse-after-error
-
#![feature(optin_builtin_traits)]
use std::marker::Send;
@@ -17,19 +15,23 @@
struct TestType;
impl !TestType {}
-//~^ ERROR inherent implementation can't be negated
+//~^ ERROR inherent impls cannot be negative
trait TestTrait {}
unsafe impl !Send for TestType {}
+//~^ ERROR negative impls cannot be unsafe
impl !TestTrait for TestType {}
+//~^ ERROR negative impls are only allowed for auto traits
-struct TestType2<T>;
+struct TestType2<T>(T);
impl<T> !TestType2<T> {}
-//~^ ERROR inherent implementation can't be negated
+//~^ ERROR inherent impls cannot be negative
unsafe impl<T> !Send for TestType2<T> {}
+//~^ ERROR negative impls cannot be unsafe
impl<T> !TestTrait for TestType2<T> {}
+//~^ ERROR negative impls are only allowed for auto traits
fn main() {}
diff --git a/src/test/compile-fail/trait-safety-inherent-impl.rs b/src/test/compile-fail/trait-safety-inherent-impl.rs
index 285d4c1..059fdc1 100644
--- a/src/test/compile-fail/trait-safety-inherent-impl.rs
+++ b/src/test/compile-fail/trait-safety-inherent-impl.rs
@@ -12,7 +12,7 @@
struct SomeStruct;
-unsafe impl SomeStruct { //~ ERROR inherent impls cannot be declared as unsafe
+unsafe impl SomeStruct { //~ ERROR inherent impls cannot be unsafe
fn foo(self) { }
}
diff --git a/src/test/compile-fail/typeck-negative-impls-builtin.rs b/src/test/compile-fail/typeck-negative-impls-builtin.rs
index 57a394d..d6d8fb6 100644
--- a/src/test/compile-fail/typeck-negative-impls-builtin.rs
+++ b/src/test/compile-fail/typeck-negative-impls-builtin.rs
@@ -17,6 +17,6 @@
}
impl !TestTrait for TestType {}
-//~^ ERROR negative impls are only allowed for traits with default impls (e.g., `Send` and `Sync`)
+//~^ ERROR negative impls are only allowed for auto traits (e.g., `Send` and `Sync`)
fn main() {}
diff --git a/src/test/parse-fail/impl-qpath.rs b/src/test/parse-fail/impl-qpath.rs
new file mode 100644
index 0000000..48dd888
--- /dev/null
+++ b/src/test/parse-fail/impl-qpath.rs
@@ -0,0 +1,18 @@
+// Copyright 2017 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// compile-flags: -Z parse-only
+
+impl <*const u8>::AssocTy {} // OK
+impl <Type as Trait>::AssocTy {} // OK
+impl <'a + Trait>::AssocTy {} // OK
+impl <<Type>::AssocTy>::AssocTy {} // OK
+
+FAIL //~ ERROR
diff --git a/src/test/parse-fail/trait-bounds-not-on-impl.rs b/src/test/parse-fail/trait-bounds-not-on-impl.rs
index b7dcc8a..7cd2774 100644
--- a/src/test/parse-fail/trait-bounds-not-on-impl.rs
+++ b/src/test/parse-fail/trait-bounds-not-on-impl.rs
@@ -15,9 +15,7 @@
struct Bar;
-impl Foo + Owned for Bar {
-//~^ ERROR not a trait
-//~^^ ERROR expected one of `where` or `{`, found `Bar`
+impl Foo + Owned for Bar { //~ ERROR expected a trait, found type
}
fn main() { }
diff --git a/src/test/parse-fail/where_with_bound.rs b/src/test/parse-fail/where_with_bound.rs
index cb57500..2948619 100644
--- a/src/test/parse-fail/where_with_bound.rs
+++ b/src/test/parse-fail/where_with_bound.rs
@@ -11,6 +11,6 @@
// compile-flags: -Z parse-only
fn foo<T>() where <T>::Item: ToString, T: Iterator { }
- //~^ syntax `where<T>` is reserved for future use
+//~^ ERROR generic parameters on `where` clauses are reserved for future use
fn main() {}
diff --git a/src/test/run-make/rustdoc-error-lines/Makefile b/src/test/run-make/rustdoc-error-lines/Makefile
new file mode 100644
index 0000000..0019e5e
--- /dev/null
+++ b/src/test/run-make/rustdoc-error-lines/Makefile
@@ -0,0 +1,8 @@
+-include ../tools.mk
+
+# Test that hir-tree output doens't crash and includes
+# the string constant we would expect to see.
+
+all:
+ $(RUSTDOC) --test input.rs > $(TMPDIR)/output || true
+ $(CGREP) 'input.rs:17:15' < $(TMPDIR)/output
diff --git a/src/test/run-make/rustdoc-error-lines/input.rs b/src/test/run-make/rustdoc-error-lines/input.rs
new file mode 100644
index 0000000..6dc7060
--- /dev/null
+++ b/src/test/run-make/rustdoc-error-lines/input.rs
@@ -0,0 +1,21 @@
+// Copyright 2014 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Test for #45868
+
+// random #![feature] to ensure that crate attrs
+// do not offset things
+/// ```rust
+/// #![feature(nll)]
+/// let x: char = 1;
+/// ```
+pub fn foo() {
+
+}
diff --git a/src/test/run-pass/issue-25693.rs b/src/test/run-pass/issue-25693.rs
index aee89be..0d9dc3c 100644
--- a/src/test/run-pass/issue-25693.rs
+++ b/src/test/run-pass/issue-25693.rs
@@ -8,16 +8,16 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-pub trait Paramters { type SelfRef; }
+pub trait Parameters { type SelfRef; }
struct RP<'a> { _marker: std::marker::PhantomData<&'a ()> }
struct BP;
-impl<'a> Paramters for RP<'a> { type SelfRef = &'a X<RP<'a>>; }
-impl Paramters for BP { type SelfRef = Box<X<BP>>; }
+impl<'a> Parameters for RP<'a> { type SelfRef = &'a X<RP<'a>>; }
+impl Parameters for BP { type SelfRef = Box<X<BP>>; }
pub struct Y;
-pub enum X<P: Paramters> {
+pub enum X<P: Parameters> {
Nothing,
SameAgain(P::SelfRef, Y)
}
diff --git a/src/test/ui-fulldeps/update-references.sh b/src/test/ui-fulldeps/update-references.sh
old mode 100644
new mode 100755
diff --git a/src/test/ui/borrowck/immutable-arg.rs b/src/test/ui/borrowck/immutable-arg.rs
new file mode 100644
index 0000000..7c387ed
--- /dev/null
+++ b/src/test/ui/borrowck/immutable-arg.rs
@@ -0,0 +1,20 @@
+// Copyright 2018 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+//compile-flags: -Z emit-end-regions -Z borrowck=compare
+
+fn foo(_x: u32) {
+ _x = 4;
+ //~^ ERROR cannot assign to immutable argument `_x` (Mir)
+ //~^^ ERROR cannot assign twice to immutable variable `_x` (Ast)
+}
+
+fn main() {}
+
diff --git a/src/test/ui/borrowck/immutable-arg.stderr b/src/test/ui/borrowck/immutable-arg.stderr
new file mode 100644
index 0000000..40e1878
--- /dev/null
+++ b/src/test/ui/borrowck/immutable-arg.stderr
@@ -0,0 +1,18 @@
+error[E0384]: cannot assign twice to immutable variable `_x` (Ast)
+ --> $DIR/immutable-arg.rs:14:5
+ |
+13 | fn foo(_x: u32) {
+ | -- first assignment to `_x`
+14 | _x = 4;
+ | ^^^^^^ cannot assign twice to immutable variable
+
+error[E0384]: cannot assign to immutable argument `_x` (Mir)
+ --> $DIR/immutable-arg.rs:14:5
+ |
+13 | fn foo(_x: u32) {
+ | -- argument not declared as `mut`
+14 | _x = 4;
+ | ^^^^^^ cannot assign to immutable argument
+
+error: aborting due to 2 previous errors
+
diff --git a/src/test/ui/feature-gate-abi-msp430-interrupt.stderr b/src/test/ui/feature-gate-abi-msp430-interrupt.stderr
index b05be6e..e1621d3 100644
--- a/src/test/ui/feature-gate-abi-msp430-interrupt.stderr
+++ b/src/test/ui/feature-gate-abi-msp430-interrupt.stderr
@@ -1,4 +1,4 @@
-error: msp430-interrupt ABI is experimental and subject to change (see issue #38487)
+error[E0658]: msp430-interrupt ABI is experimental and subject to change (see issue #38487)
--> $DIR/feature-gate-abi-msp430-interrupt.rs:14:1
|
14 | extern "msp430-interrupt" fn foo() {}
diff --git a/src/test/ui/feature-gate-abi.stderr b/src/test/ui/feature-gate-abi.stderr
index 7d2ad0b..ce31474 100644
--- a/src/test/ui/feature-gate-abi.stderr
+++ b/src/test/ui/feature-gate-abi.stderr
@@ -1,4 +1,4 @@
-error: intrinsics are subject to change
+error[E0658]: intrinsics are subject to change
--> $DIR/feature-gate-abi.rs:19:1
|
19 | extern "rust-intrinsic" fn f1() {} //~ ERROR intrinsics are subject to change
@@ -6,7 +6,7 @@
|
= help: add #![feature(intrinsics)] to the crate attributes to enable
-error: platform intrinsics are experimental and possibly buggy (see issue #27731)
+error[E0658]: platform intrinsics are experimental and possibly buggy (see issue #27731)
--> $DIR/feature-gate-abi.rs:20:1
|
20 | extern "platform-intrinsic" fn f2() {} //~ ERROR platform intrinsics are experimental
@@ -14,7 +14,7 @@
|
= help: add #![feature(platform_intrinsics)] to the crate attributes to enable
-error: vectorcall is experimental and subject to change
+error[E0658]: vectorcall is experimental and subject to change
--> $DIR/feature-gate-abi.rs:21:1
|
21 | extern "vectorcall" fn f3() {} //~ ERROR vectorcall is experimental and subject to change
@@ -22,7 +22,7 @@
|
= help: add #![feature(abi_vectorcall)] to the crate attributes to enable
-error: rust-call ABI is subject to change (see issue #29625)
+error[E0658]: rust-call ABI is subject to change (see issue #29625)
--> $DIR/feature-gate-abi.rs:22:1
|
22 | extern "rust-call" fn f4() {} //~ ERROR rust-call ABI is subject to change
@@ -30,7 +30,7 @@
|
= help: add #![feature(unboxed_closures)] to the crate attributes to enable
-error: msp430-interrupt ABI is experimental and subject to change (see issue #38487)
+error[E0658]: msp430-interrupt ABI is experimental and subject to change (see issue #38487)
--> $DIR/feature-gate-abi.rs:23:1
|
23 | extern "msp430-interrupt" fn f5() {} //~ ERROR msp430-interrupt ABI is experimental
@@ -38,7 +38,7 @@
|
= help: add #![feature(abi_msp430_interrupt)] to the crate attributes to enable
-error: PTX ABIs are experimental and subject to change
+error[E0658]: PTX ABIs are experimental and subject to change
--> $DIR/feature-gate-abi.rs:24:1
|
24 | extern "ptx-kernel" fn f6() {} //~ ERROR PTX ABIs are experimental and subject to change
@@ -46,7 +46,7 @@
|
= help: add #![feature(abi_ptx)] to the crate attributes to enable
-error: x86-interrupt ABI is experimental and subject to change (see issue #40180)
+error[E0658]: x86-interrupt ABI is experimental and subject to change (see issue #40180)
--> $DIR/feature-gate-abi.rs:25:1
|
25 | extern "x86-interrupt" fn f7() {} //~ ERROR x86-interrupt ABI is experimental
@@ -54,7 +54,7 @@
|
= help: add #![feature(abi_x86_interrupt)] to the crate attributes to enable
-error: thiscall is experimental and subject to change
+error[E0658]: thiscall is experimental and subject to change
--> $DIR/feature-gate-abi.rs:26:1
|
26 | extern "thiscall" fn f8() {} //~ ERROR thiscall is experimental and subject to change
@@ -62,7 +62,7 @@
|
= help: add #![feature(abi_thiscall)] to the crate attributes to enable
-error: intrinsics are subject to change
+error[E0658]: intrinsics are subject to change
--> $DIR/feature-gate-abi.rs:30:5
|
30 | extern "rust-intrinsic" fn m1(); //~ ERROR intrinsics are subject to change
@@ -70,7 +70,7 @@
|
= help: add #![feature(intrinsics)] to the crate attributes to enable
-error: platform intrinsics are experimental and possibly buggy (see issue #27731)
+error[E0658]: platform intrinsics are experimental and possibly buggy (see issue #27731)
--> $DIR/feature-gate-abi.rs:31:5
|
31 | extern "platform-intrinsic" fn m2(); //~ ERROR platform intrinsics are experimental
@@ -78,7 +78,7 @@
|
= help: add #![feature(platform_intrinsics)] to the crate attributes to enable
-error: vectorcall is experimental and subject to change
+error[E0658]: vectorcall is experimental and subject to change
--> $DIR/feature-gate-abi.rs:32:5
|
32 | extern "vectorcall" fn m3(); //~ ERROR vectorcall is experimental and subject to change
@@ -86,7 +86,7 @@
|
= help: add #![feature(abi_vectorcall)] to the crate attributes to enable
-error: rust-call ABI is subject to change (see issue #29625)
+error[E0658]: rust-call ABI is subject to change (see issue #29625)
--> $DIR/feature-gate-abi.rs:33:5
|
33 | extern "rust-call" fn m4(); //~ ERROR rust-call ABI is subject to change
@@ -94,7 +94,7 @@
|
= help: add #![feature(unboxed_closures)] to the crate attributes to enable
-error: msp430-interrupt ABI is experimental and subject to change (see issue #38487)
+error[E0658]: msp430-interrupt ABI is experimental and subject to change (see issue #38487)
--> $DIR/feature-gate-abi.rs:34:5
|
34 | extern "msp430-interrupt" fn m5(); //~ ERROR msp430-interrupt ABI is experimental
@@ -102,7 +102,7 @@
|
= help: add #![feature(abi_msp430_interrupt)] to the crate attributes to enable
-error: PTX ABIs are experimental and subject to change
+error[E0658]: PTX ABIs are experimental and subject to change
--> $DIR/feature-gate-abi.rs:35:5
|
35 | extern "ptx-kernel" fn m6(); //~ ERROR PTX ABIs are experimental and subject to change
@@ -110,7 +110,7 @@
|
= help: add #![feature(abi_ptx)] to the crate attributes to enable
-error: x86-interrupt ABI is experimental and subject to change (see issue #40180)
+error[E0658]: x86-interrupt ABI is experimental and subject to change (see issue #40180)
--> $DIR/feature-gate-abi.rs:36:5
|
36 | extern "x86-interrupt" fn m7(); //~ ERROR x86-interrupt ABI is experimental
@@ -118,7 +118,7 @@
|
= help: add #![feature(abi_x86_interrupt)] to the crate attributes to enable
-error: thiscall is experimental and subject to change
+error[E0658]: thiscall is experimental and subject to change
--> $DIR/feature-gate-abi.rs:37:5
|
37 | extern "thiscall" fn m8(); //~ ERROR thiscall is experimental and subject to change
@@ -126,7 +126,7 @@
|
= help: add #![feature(abi_thiscall)] to the crate attributes to enable
-error: intrinsics are subject to change
+error[E0658]: intrinsics are subject to change
--> $DIR/feature-gate-abi.rs:39:5
|
39 | extern "rust-intrinsic" fn dm1() {} //~ ERROR intrinsics are subject to change
@@ -134,7 +134,7 @@
|
= help: add #![feature(intrinsics)] to the crate attributes to enable
-error: platform intrinsics are experimental and possibly buggy (see issue #27731)
+error[E0658]: platform intrinsics are experimental and possibly buggy (see issue #27731)
--> $DIR/feature-gate-abi.rs:40:5
|
40 | extern "platform-intrinsic" fn dm2() {} //~ ERROR platform intrinsics are experimental
@@ -142,7 +142,7 @@
|
= help: add #![feature(platform_intrinsics)] to the crate attributes to enable
-error: vectorcall is experimental and subject to change
+error[E0658]: vectorcall is experimental and subject to change
--> $DIR/feature-gate-abi.rs:41:5
|
41 | extern "vectorcall" fn dm3() {} //~ ERROR vectorcall is experimental and subject to change
@@ -150,7 +150,7 @@
|
= help: add #![feature(abi_vectorcall)] to the crate attributes to enable
-error: rust-call ABI is subject to change (see issue #29625)
+error[E0658]: rust-call ABI is subject to change (see issue #29625)
--> $DIR/feature-gate-abi.rs:42:5
|
42 | extern "rust-call" fn dm4() {} //~ ERROR rust-call ABI is subject to change
@@ -158,7 +158,7 @@
|
= help: add #![feature(unboxed_closures)] to the crate attributes to enable
-error: msp430-interrupt ABI is experimental and subject to change (see issue #38487)
+error[E0658]: msp430-interrupt ABI is experimental and subject to change (see issue #38487)
--> $DIR/feature-gate-abi.rs:43:5
|
43 | extern "msp430-interrupt" fn dm5() {} //~ ERROR msp430-interrupt ABI is experimental
@@ -166,7 +166,7 @@
|
= help: add #![feature(abi_msp430_interrupt)] to the crate attributes to enable
-error: PTX ABIs are experimental and subject to change
+error[E0658]: PTX ABIs are experimental and subject to change
--> $DIR/feature-gate-abi.rs:44:5
|
44 | extern "ptx-kernel" fn dm6() {} //~ ERROR PTX ABIs are experimental and subject to change
@@ -174,7 +174,7 @@
|
= help: add #![feature(abi_ptx)] to the crate attributes to enable
-error: x86-interrupt ABI is experimental and subject to change (see issue #40180)
+error[E0658]: x86-interrupt ABI is experimental and subject to change (see issue #40180)
--> $DIR/feature-gate-abi.rs:45:5
|
45 | extern "x86-interrupt" fn dm7() {} //~ ERROR x86-interrupt ABI is experimental
@@ -182,7 +182,7 @@
|
= help: add #![feature(abi_x86_interrupt)] to the crate attributes to enable
-error: thiscall is experimental and subject to change
+error[E0658]: thiscall is experimental and subject to change
--> $DIR/feature-gate-abi.rs:46:5
|
46 | extern "thiscall" fn dm8() {} //~ ERROR thiscall is experimental and subject to change
@@ -190,7 +190,7 @@
|
= help: add #![feature(abi_thiscall)] to the crate attributes to enable
-error: intrinsics are subject to change
+error[E0658]: intrinsics are subject to change
--> $DIR/feature-gate-abi.rs:53:5
|
53 | extern "rust-intrinsic" fn m1() {} //~ ERROR intrinsics are subject to change
@@ -198,7 +198,7 @@
|
= help: add #![feature(intrinsics)] to the crate attributes to enable
-error: platform intrinsics are experimental and possibly buggy (see issue #27731)
+error[E0658]: platform intrinsics are experimental and possibly buggy (see issue #27731)
--> $DIR/feature-gate-abi.rs:54:5
|
54 | extern "platform-intrinsic" fn m2() {} //~ ERROR platform intrinsics are experimental
@@ -206,7 +206,7 @@
|
= help: add #![feature(platform_intrinsics)] to the crate attributes to enable
-error: vectorcall is experimental and subject to change
+error[E0658]: vectorcall is experimental and subject to change
--> $DIR/feature-gate-abi.rs:55:5
|
55 | extern "vectorcall" fn m3() {} //~ ERROR vectorcall is experimental and subject to change
@@ -214,7 +214,7 @@
|
= help: add #![feature(abi_vectorcall)] to the crate attributes to enable
-error: rust-call ABI is subject to change (see issue #29625)
+error[E0658]: rust-call ABI is subject to change (see issue #29625)
--> $DIR/feature-gate-abi.rs:56:5
|
56 | extern "rust-call" fn m4() {} //~ ERROR rust-call ABI is subject to change
@@ -222,7 +222,7 @@
|
= help: add #![feature(unboxed_closures)] to the crate attributes to enable
-error: msp430-interrupt ABI is experimental and subject to change (see issue #38487)
+error[E0658]: msp430-interrupt ABI is experimental and subject to change (see issue #38487)
--> $DIR/feature-gate-abi.rs:57:5
|
57 | extern "msp430-interrupt" fn m5() {} //~ ERROR msp430-interrupt ABI is experimental
@@ -230,7 +230,7 @@
|
= help: add #![feature(abi_msp430_interrupt)] to the crate attributes to enable
-error: PTX ABIs are experimental and subject to change
+error[E0658]: PTX ABIs are experimental and subject to change
--> $DIR/feature-gate-abi.rs:58:5
|
58 | extern "ptx-kernel" fn m6() {} //~ ERROR PTX ABIs are experimental and subject to change
@@ -238,7 +238,7 @@
|
= help: add #![feature(abi_ptx)] to the crate attributes to enable
-error: x86-interrupt ABI is experimental and subject to change (see issue #40180)
+error[E0658]: x86-interrupt ABI is experimental and subject to change (see issue #40180)
--> $DIR/feature-gate-abi.rs:59:5
|
59 | extern "x86-interrupt" fn m7() {} //~ ERROR x86-interrupt ABI is experimental
@@ -246,7 +246,7 @@
|
= help: add #![feature(abi_x86_interrupt)] to the crate attributes to enable
-error: thiscall is experimental and subject to change
+error[E0658]: thiscall is experimental and subject to change
--> $DIR/feature-gate-abi.rs:60:5
|
60 | extern "thiscall" fn m8() {} //~ ERROR thiscall is experimental and subject to change
@@ -254,7 +254,7 @@
|
= help: add #![feature(abi_thiscall)] to the crate attributes to enable
-error: intrinsics are subject to change
+error[E0658]: intrinsics are subject to change
--> $DIR/feature-gate-abi.rs:65:5
|
65 | extern "rust-intrinsic" fn im1() {} //~ ERROR intrinsics are subject to change
@@ -262,7 +262,7 @@
|
= help: add #![feature(intrinsics)] to the crate attributes to enable
-error: platform intrinsics are experimental and possibly buggy (see issue #27731)
+error[E0658]: platform intrinsics are experimental and possibly buggy (see issue #27731)
--> $DIR/feature-gate-abi.rs:66:5
|
66 | extern "platform-intrinsic" fn im2() {} //~ ERROR platform intrinsics are experimental
@@ -270,7 +270,7 @@
|
= help: add #![feature(platform_intrinsics)] to the crate attributes to enable
-error: vectorcall is experimental and subject to change
+error[E0658]: vectorcall is experimental and subject to change
--> $DIR/feature-gate-abi.rs:67:5
|
67 | extern "vectorcall" fn im3() {} //~ ERROR vectorcall is experimental and subject to change
@@ -278,7 +278,7 @@
|
= help: add #![feature(abi_vectorcall)] to the crate attributes to enable
-error: rust-call ABI is subject to change (see issue #29625)
+error[E0658]: rust-call ABI is subject to change (see issue #29625)
--> $DIR/feature-gate-abi.rs:68:5
|
68 | extern "rust-call" fn im4() {} //~ ERROR rust-call ABI is subject to change
@@ -286,7 +286,7 @@
|
= help: add #![feature(unboxed_closures)] to the crate attributes to enable
-error: msp430-interrupt ABI is experimental and subject to change (see issue #38487)
+error[E0658]: msp430-interrupt ABI is experimental and subject to change (see issue #38487)
--> $DIR/feature-gate-abi.rs:69:5
|
69 | extern "msp430-interrupt" fn im5() {} //~ ERROR msp430-interrupt ABI is experimental
@@ -294,7 +294,7 @@
|
= help: add #![feature(abi_msp430_interrupt)] to the crate attributes to enable
-error: PTX ABIs are experimental and subject to change
+error[E0658]: PTX ABIs are experimental and subject to change
--> $DIR/feature-gate-abi.rs:70:5
|
70 | extern "ptx-kernel" fn im6() {} //~ ERROR PTX ABIs are experimental and subject to change
@@ -302,7 +302,7 @@
|
= help: add #![feature(abi_ptx)] to the crate attributes to enable
-error: x86-interrupt ABI is experimental and subject to change (see issue #40180)
+error[E0658]: x86-interrupt ABI is experimental and subject to change (see issue #40180)
--> $DIR/feature-gate-abi.rs:71:5
|
71 | extern "x86-interrupt" fn im7() {} //~ ERROR x86-interrupt ABI is experimental
@@ -310,7 +310,7 @@
|
= help: add #![feature(abi_x86_interrupt)] to the crate attributes to enable
-error: thiscall is experimental and subject to change
+error[E0658]: thiscall is experimental and subject to change
--> $DIR/feature-gate-abi.rs:72:5
|
72 | extern "thiscall" fn im8() {} //~ ERROR thiscall is experimental and subject to change
@@ -318,7 +318,7 @@
|
= help: add #![feature(abi_thiscall)] to the crate attributes to enable
-error: intrinsics are subject to change
+error[E0658]: intrinsics are subject to change
--> $DIR/feature-gate-abi.rs:76:11
|
76 | type A1 = extern "rust-intrinsic" fn(); //~ ERROR intrinsics are subject to change
@@ -326,7 +326,7 @@
|
= help: add #![feature(intrinsics)] to the crate attributes to enable
-error: platform intrinsics are experimental and possibly buggy (see issue #27731)
+error[E0658]: platform intrinsics are experimental and possibly buggy (see issue #27731)
--> $DIR/feature-gate-abi.rs:77:11
|
77 | type A2 = extern "platform-intrinsic" fn(); //~ ERROR platform intrinsics are experimental
@@ -334,7 +334,7 @@
|
= help: add #![feature(platform_intrinsics)] to the crate attributes to enable
-error: vectorcall is experimental and subject to change
+error[E0658]: vectorcall is experimental and subject to change
--> $DIR/feature-gate-abi.rs:78:11
|
78 | type A3 = extern "vectorcall" fn(); //~ ERROR vectorcall is experimental and subject to change
@@ -342,7 +342,7 @@
|
= help: add #![feature(abi_vectorcall)] to the crate attributes to enable
-error: rust-call ABI is subject to change (see issue #29625)
+error[E0658]: rust-call ABI is subject to change (see issue #29625)
--> $DIR/feature-gate-abi.rs:79:11
|
79 | type A4 = extern "rust-call" fn(); //~ ERROR rust-call ABI is subject to change
@@ -350,7 +350,7 @@
|
= help: add #![feature(unboxed_closures)] to the crate attributes to enable
-error: msp430-interrupt ABI is experimental and subject to change (see issue #38487)
+error[E0658]: msp430-interrupt ABI is experimental and subject to change (see issue #38487)
--> $DIR/feature-gate-abi.rs:80:11
|
80 | type A5 = extern "msp430-interrupt" fn(); //~ ERROR msp430-interrupt ABI is experimental
@@ -358,7 +358,7 @@
|
= help: add #![feature(abi_msp430_interrupt)] to the crate attributes to enable
-error: PTX ABIs are experimental and subject to change
+error[E0658]: PTX ABIs are experimental and subject to change
--> $DIR/feature-gate-abi.rs:81:11
|
81 | type A6 = extern "ptx-kernel" fn (); //~ ERROR PTX ABIs are experimental and subject to change
@@ -366,7 +366,7 @@
|
= help: add #![feature(abi_ptx)] to the crate attributes to enable
-error: x86-interrupt ABI is experimental and subject to change (see issue #40180)
+error[E0658]: x86-interrupt ABI is experimental and subject to change (see issue #40180)
--> $DIR/feature-gate-abi.rs:82:11
|
82 | type A7 = extern "x86-interrupt" fn(); //~ ERROR x86-interrupt ABI is experimental
@@ -374,7 +374,7 @@
|
= help: add #![feature(abi_x86_interrupt)] to the crate attributes to enable
-error: thiscall is experimental and subject to change
+error[E0658]: thiscall is experimental and subject to change
--> $DIR/feature-gate-abi.rs:83:11
|
83 | type A8 = extern "thiscall" fn(); //~ ERROR thiscall is experimental and subject to change
@@ -382,7 +382,7 @@
|
= help: add #![feature(abi_thiscall)] to the crate attributes to enable
-error: intrinsics are subject to change
+error[E0658]: intrinsics are subject to change
--> $DIR/feature-gate-abi.rs:86:1
|
86 | extern "rust-intrinsic" {} //~ ERROR intrinsics are subject to change
@@ -390,7 +390,7 @@
|
= help: add #![feature(intrinsics)] to the crate attributes to enable
-error: platform intrinsics are experimental and possibly buggy (see issue #27731)
+error[E0658]: platform intrinsics are experimental and possibly buggy (see issue #27731)
--> $DIR/feature-gate-abi.rs:87:1
|
87 | extern "platform-intrinsic" {} //~ ERROR platform intrinsics are experimental
@@ -398,7 +398,7 @@
|
= help: add #![feature(platform_intrinsics)] to the crate attributes to enable
-error: vectorcall is experimental and subject to change
+error[E0658]: vectorcall is experimental and subject to change
--> $DIR/feature-gate-abi.rs:88:1
|
88 | extern "vectorcall" {} //~ ERROR vectorcall is experimental and subject to change
@@ -406,7 +406,7 @@
|
= help: add #![feature(abi_vectorcall)] to the crate attributes to enable
-error: rust-call ABI is subject to change (see issue #29625)
+error[E0658]: rust-call ABI is subject to change (see issue #29625)
--> $DIR/feature-gate-abi.rs:89:1
|
89 | extern "rust-call" {} //~ ERROR rust-call ABI is subject to change
@@ -414,7 +414,7 @@
|
= help: add #![feature(unboxed_closures)] to the crate attributes to enable
-error: msp430-interrupt ABI is experimental and subject to change (see issue #38487)
+error[E0658]: msp430-interrupt ABI is experimental and subject to change (see issue #38487)
--> $DIR/feature-gate-abi.rs:90:1
|
90 | extern "msp430-interrupt" {} //~ ERROR msp430-interrupt ABI is experimental
@@ -422,7 +422,7 @@
|
= help: add #![feature(abi_msp430_interrupt)] to the crate attributes to enable
-error: PTX ABIs are experimental and subject to change
+error[E0658]: PTX ABIs are experimental and subject to change
--> $DIR/feature-gate-abi.rs:91:1
|
91 | extern "ptx-kernel" {} //~ ERROR PTX ABIs are experimental and subject to change
@@ -430,7 +430,7 @@
|
= help: add #![feature(abi_ptx)] to the crate attributes to enable
-error: x86-interrupt ABI is experimental and subject to change (see issue #40180)
+error[E0658]: x86-interrupt ABI is experimental and subject to change (see issue #40180)
--> $DIR/feature-gate-abi.rs:92:1
|
92 | extern "x86-interrupt" {} //~ ERROR x86-interrupt ABI is experimental
@@ -438,7 +438,7 @@
|
= help: add #![feature(abi_x86_interrupt)] to the crate attributes to enable
-error: thiscall is experimental and subject to change
+error[E0658]: thiscall is experimental and subject to change
--> $DIR/feature-gate-abi.rs:93:1
|
93 | extern "thiscall" {} //~ ERROR thiscall is experimental and subject to change
diff --git a/src/test/ui/feature-gate-abi_unadjusted.stderr b/src/test/ui/feature-gate-abi_unadjusted.stderr
index 3cc4384..b3f7cd2 100644
--- a/src/test/ui/feature-gate-abi_unadjusted.stderr
+++ b/src/test/ui/feature-gate-abi_unadjusted.stderr
@@ -1,4 +1,4 @@
-error: unadjusted ABI is an implementation detail and perma-unstable
+error[E0658]: unadjusted ABI is an implementation detail and perma-unstable
--> $DIR/feature-gate-abi_unadjusted.rs:11:1
|
11 | / extern "unadjusted" fn foo() {
diff --git a/src/test/ui/feature-gate-advanced-slice-features.stderr b/src/test/ui/feature-gate-advanced-slice-features.stderr
index 815593d..63ede50 100644
--- a/src/test/ui/feature-gate-advanced-slice-features.stderr
+++ b/src/test/ui/feature-gate-advanced-slice-features.stderr
@@ -1,4 +1,4 @@
-error: multiple-element slice matches anywhere but at the end of a slice (e.g. `[0, ..xs, 0]`) are experimental (see issue #23121)
+error[E0658]: multiple-element slice matches anywhere but at the end of a slice (e.g. `[0, ..xs, 0]`) are experimental (see issue #23121)
--> $DIR/feature-gate-advanced-slice-features.rs:18:9
|
18 | [ xs.., 4, 5 ] => {} //~ ERROR multiple-element slice matches
@@ -6,7 +6,7 @@
|
= help: add #![feature(advanced_slice_patterns)] to the crate attributes to enable
-error: multiple-element slice matches anywhere but at the end of a slice (e.g. `[0, ..xs, 0]`) are experimental (see issue #23121)
+error[E0658]: multiple-element slice matches anywhere but at the end of a slice (e.g. `[0, ..xs, 0]`) are experimental (see issue #23121)
--> $DIR/feature-gate-advanced-slice-features.rs:19:9
|
19 | [ 1, xs.., 5 ] => {} //~ ERROR multiple-element slice matches
diff --git a/src/test/ui/feature-gate-allocator_internals.stderr b/src/test/ui/feature-gate-allocator_internals.stderr
index f1f4705..76d96f9 100644
--- a/src/test/ui/feature-gate-allocator_internals.stderr
+++ b/src/test/ui/feature-gate-allocator_internals.stderr
@@ -1,4 +1,4 @@
-error: the `#[default_lib_allocator]` attribute is an experimental feature
+error[E0658]: the `#[default_lib_allocator]` attribute is an experimental feature
--> $DIR/feature-gate-allocator_internals.rs:11:1
|
11 | #![default_lib_allocator] //~ ERROR: attribute is an experimental feature
diff --git a/src/test/ui/feature-gate-allow-internal-unsafe-nested-macro.stderr b/src/test/ui/feature-gate-allow-internal-unsafe-nested-macro.stderr
index 40bdde3..31de8d7 100644
--- a/src/test/ui/feature-gate-allow-internal-unsafe-nested-macro.stderr
+++ b/src/test/ui/feature-gate-allow-internal-unsafe-nested-macro.stderr
@@ -1,4 +1,4 @@
-error: allow_internal_unsafe side-steps the unsafe_code lint
+error[E0658]: allow_internal_unsafe side-steps the unsafe_code lint
--> $DIR/feature-gate-allow-internal-unsafe-nested-macro.rs:18:9
|
18 | #[allow_internal_unsafe] //~ ERROR allow_internal_unsafe side-steps
diff --git a/src/test/ui/feature-gate-allow-internal-unstable-nested-macro.stderr b/src/test/ui/feature-gate-allow-internal-unstable-nested-macro.stderr
index 60d72fb..3e2573e 100644
--- a/src/test/ui/feature-gate-allow-internal-unstable-nested-macro.stderr
+++ b/src/test/ui/feature-gate-allow-internal-unstable-nested-macro.stderr
@@ -1,4 +1,4 @@
-error: allow_internal_unstable side-steps feature gating and stability checks
+error[E0658]: allow_internal_unstable side-steps feature gating and stability checks
--> $DIR/feature-gate-allow-internal-unstable-nested-macro.rs:18:9
|
18 | #[allow_internal_unstable] //~ ERROR allow_internal_unstable side-steps
diff --git a/src/test/ui/feature-gate-allow-internal-unstable-struct.stderr b/src/test/ui/feature-gate-allow-internal-unstable-struct.stderr
index 2fb86ce..e19f328 100644
--- a/src/test/ui/feature-gate-allow-internal-unstable-struct.stderr
+++ b/src/test/ui/feature-gate-allow-internal-unstable-struct.stderr
@@ -1,4 +1,4 @@
-error: allow_internal_unstable side-steps feature gating and stability checks
+error[E0658]: allow_internal_unstable side-steps feature gating and stability checks
--> $DIR/feature-gate-allow-internal-unstable-struct.rs:14:1
|
14 | #[allow_internal_unstable] //~ ERROR allow_internal_unstable side-steps
diff --git a/src/test/ui/feature-gate-allow-internal-unstable.stderr b/src/test/ui/feature-gate-allow-internal-unstable.stderr
index a5740a1..f110afb 100644
--- a/src/test/ui/feature-gate-allow-internal-unstable.stderr
+++ b/src/test/ui/feature-gate-allow-internal-unstable.stderr
@@ -1,4 +1,4 @@
-error: allow_internal_unstable side-steps feature gating and stability checks
+error[E0658]: allow_internal_unstable side-steps feature gating and stability checks
--> $DIR/feature-gate-allow-internal-unstable.rs:13:1
|
13 | #[allow_internal_unstable] //~ ERROR allow_internal_unstable side-steps
diff --git a/src/test/ui/feature-gate-allow_fail.stderr b/src/test/ui/feature-gate-allow_fail.stderr
index 65cd137..e04f448 100644
--- a/src/test/ui/feature-gate-allow_fail.stderr
+++ b/src/test/ui/feature-gate-allow_fail.stderr
@@ -1,4 +1,4 @@
-error: allow_fail attribute is currently unstable (see issue #42219)
+error[E0658]: allow_fail attribute is currently unstable (see issue #42219)
--> $DIR/feature-gate-allow_fail.rs:13:1
|
13 | #[allow_fail] //~ ERROR allow_fail attribute is currently unstable
diff --git a/src/test/ui/feature-gate-arbitrary-self-types.stderr b/src/test/ui/feature-gate-arbitrary-self-types.stderr
index 2ef517c..ca47d40 100644
--- a/src/test/ui/feature-gate-arbitrary-self-types.stderr
+++ b/src/test/ui/feature-gate-arbitrary-self-types.stderr
@@ -1,4 +1,4 @@
-error: arbitrary `self` types are unstable (see issue #44874)
+error[E0658]: arbitrary `self` types are unstable (see issue #44874)
--> $DIR/feature-gate-arbitrary-self-types.rs:14:18
|
14 | fn foo(self: Rc<Box<Self>>); //~ ERROR arbitrary `self` types are unstable
@@ -7,7 +7,7 @@
= help: add #![feature(arbitrary_self_types)] to the crate attributes to enable
= help: consider changing to `self`, `&self`, `&mut self`, or `self: Box<Self>`
-error: arbitrary `self` types are unstable (see issue #44874)
+error[E0658]: arbitrary `self` types are unstable (see issue #44874)
--> $DIR/feature-gate-arbitrary-self-types.rs:20:18
|
20 | fn foo(self: Rc<Box<Self>>) {} //~ ERROR arbitrary `self` types are unstable
@@ -16,7 +16,7 @@
= help: add #![feature(arbitrary_self_types)] to the crate attributes to enable
= help: consider changing to `self`, `&self`, `&mut self`, or `self: Box<Self>`
-error: arbitrary `self` types are unstable (see issue #44874)
+error[E0658]: arbitrary `self` types are unstable (see issue #44874)
--> $DIR/feature-gate-arbitrary-self-types.rs:24:18
|
24 | fn bar(self: Box<Rc<Self>>) {} //~ ERROR arbitrary `self` types are unstable
diff --git a/src/test/ui/feature-gate-arbitrary_self_types-raw-pointer.stderr b/src/test/ui/feature-gate-arbitrary_self_types-raw-pointer.stderr
index d629ac4..33e8806 100644
--- a/src/test/ui/feature-gate-arbitrary_self_types-raw-pointer.stderr
+++ b/src/test/ui/feature-gate-arbitrary_self_types-raw-pointer.stderr
@@ -1,4 +1,4 @@
-error: raw pointer `self` is unstable (see issue #44874)
+error[E0658]: raw pointer `self` is unstable (see issue #44874)
--> $DIR/feature-gate-arbitrary_self_types-raw-pointer.rs:19:18
|
19 | fn bar(self: *const Self);
@@ -7,7 +7,7 @@
= help: add #![feature(arbitrary_self_types)] to the crate attributes to enable
= help: consider changing to `self`, `&self`, `&mut self`, or `self: Box<Self>`
-error: raw pointer `self` is unstable (see issue #44874)
+error[E0658]: raw pointer `self` is unstable (see issue #44874)
--> $DIR/feature-gate-arbitrary_self_types-raw-pointer.rs:14:18
|
14 | fn foo(self: *const Self) {}
@@ -16,7 +16,7 @@
= help: add #![feature(arbitrary_self_types)] to the crate attributes to enable
= help: consider changing to `self`, `&self`, `&mut self`, or `self: Box<Self>`
-error: raw pointer `self` is unstable (see issue #44874)
+error[E0658]: raw pointer `self` is unstable (see issue #44874)
--> $DIR/feature-gate-arbitrary_self_types-raw-pointer.rs:24:18
|
24 | fn bar(self: *const Self) {}
diff --git a/src/test/ui/feature-gate-asm.stderr b/src/test/ui/feature-gate-asm.stderr
index ff68a4f..481e6dc 100644
--- a/src/test/ui/feature-gate-asm.stderr
+++ b/src/test/ui/feature-gate-asm.stderr
@@ -1,4 +1,4 @@
-error: inline assembly is not stable enough for use and is subject to change (see issue #29722)
+error[E0658]: inline assembly is not stable enough for use and is subject to change (see issue #29722)
--> $DIR/feature-gate-asm.rs:13:9
|
13 | asm!(""); //~ ERROR inline assembly is not stable enough
diff --git a/src/test/ui/feature-gate-asm2.stderr b/src/test/ui/feature-gate-asm2.stderr
index 1e02ced..aba0f72 100644
--- a/src/test/ui/feature-gate-asm2.stderr
+++ b/src/test/ui/feature-gate-asm2.stderr
@@ -1,4 +1,4 @@
-error: inline assembly is not stable enough for use and is subject to change (see issue #29722)
+error[E0658]: inline assembly is not stable enough for use and is subject to change (see issue #29722)
--> $DIR/feature-gate-asm2.rs:15:24
|
15 | println!("{}", asm!("")); //~ ERROR inline assembly is not stable
diff --git a/src/test/ui/feature-gate-assoc-type-defaults.stderr b/src/test/ui/feature-gate-assoc-type-defaults.stderr
index 5e28846..1d44797 100644
--- a/src/test/ui/feature-gate-assoc-type-defaults.stderr
+++ b/src/test/ui/feature-gate-assoc-type-defaults.stderr
@@ -1,4 +1,4 @@
-error: associated type defaults are unstable (see issue #29661)
+error[E0658]: associated type defaults are unstable (see issue #29661)
--> $DIR/feature-gate-assoc-type-defaults.rs:14:5
|
14 | type Bar = u8; //~ ERROR associated type defaults are unstable
diff --git a/src/test/ui/feature-gate-box-expr.stderr b/src/test/ui/feature-gate-box-expr.stderr
index cef5adb..f9cccde 100644
--- a/src/test/ui/feature-gate-box-expr.stderr
+++ b/src/test/ui/feature-gate-box-expr.stderr
@@ -1,4 +1,4 @@
-error: box expression syntax is experimental; you can call `Box::new` instead. (see issue #27779)
+error[E0658]: box expression syntax is experimental; you can call `Box::new` instead. (see issue #27779)
--> $DIR/feature-gate-box-expr.rs:22:13
|
22 | let x = box 'c'; //~ ERROR box expression syntax is experimental
diff --git a/src/test/ui/feature-gate-box_patterns.stderr b/src/test/ui/feature-gate-box_patterns.stderr
index 0a30de5..ca00933 100644
--- a/src/test/ui/feature-gate-box_patterns.stderr
+++ b/src/test/ui/feature-gate-box_patterns.stderr
@@ -1,4 +1,4 @@
-error: box pattern syntax is experimental (see issue #29641)
+error[E0658]: box pattern syntax is experimental (see issue #29641)
--> $DIR/feature-gate-box_patterns.rs:12:9
|
12 | let box x = Box::new('c'); //~ ERROR box pattern syntax is experimental
diff --git a/src/test/ui/feature-gate-box_syntax.stderr b/src/test/ui/feature-gate-box_syntax.stderr
index 9b21dd0..eefaa72 100644
--- a/src/test/ui/feature-gate-box_syntax.stderr
+++ b/src/test/ui/feature-gate-box_syntax.stderr
@@ -1,4 +1,4 @@
-error: box expression syntax is experimental; you can call `Box::new` instead. (see issue #27779)
+error[E0658]: box expression syntax is experimental; you can call `Box::new` instead. (see issue #27779)
--> $DIR/feature-gate-box_syntax.rs:14:13
|
14 | let x = box 3;
diff --git a/src/test/ui/feature-gate-catch_expr.stderr b/src/test/ui/feature-gate-catch_expr.stderr
index f486373..4b3bfbb 100644
--- a/src/test/ui/feature-gate-catch_expr.stderr
+++ b/src/test/ui/feature-gate-catch_expr.stderr
@@ -1,4 +1,4 @@
-error: `catch` expression is experimental (see issue #31436)
+error[E0658]: `catch` expression is experimental (see issue #31436)
--> $DIR/feature-gate-catch_expr.rs:12:24
|
12 | let catch_result = do catch { //~ ERROR `catch` expression is experimental
diff --git a/src/test/ui/feature-gate-cfg-target-feature.stderr b/src/test/ui/feature-gate-cfg-target-feature.stderr
index 60dc6fb..f808e78 100644
--- a/src/test/ui/feature-gate-cfg-target-feature.stderr
+++ b/src/test/ui/feature-gate-cfg-target-feature.stderr
@@ -1,4 +1,4 @@
-error: `cfg(target_feature)` is experimental and subject to change (see issue #29717)
+error[E0658]: `cfg(target_feature)` is experimental and subject to change (see issue #29717)
--> $DIR/feature-gate-cfg-target-feature.rs:12:12
|
12 | #[cfg_attr(target_feature = "x", x)] //~ ERROR `cfg(target_feature)` is experimental
@@ -6,7 +6,7 @@
|
= help: add #![feature(cfg_target_feature)] to the crate attributes to enable
-error: `cfg(target_feature)` is experimental and subject to change (see issue #29717)
+error[E0658]: `cfg(target_feature)` is experimental and subject to change (see issue #29717)
--> $DIR/feature-gate-cfg-target-feature.rs:11:7
|
11 | #[cfg(target_feature = "x")] //~ ERROR `cfg(target_feature)` is experimental
@@ -14,7 +14,7 @@
|
= help: add #![feature(cfg_target_feature)] to the crate attributes to enable
-error: `cfg(target_feature)` is experimental and subject to change (see issue #29717)
+error[E0658]: `cfg(target_feature)` is experimental and subject to change (see issue #29717)
--> $DIR/feature-gate-cfg-target-feature.rs:15:19
|
15 | #[cfg(not(any(all(target_feature = "x"))))] //~ ERROR `cfg(target_feature)` is experimental
@@ -22,7 +22,7 @@
|
= help: add #![feature(cfg_target_feature)] to the crate attributes to enable
-error: `cfg(target_feature)` is experimental and subject to change (see issue #29717)
+error[E0658]: `cfg(target_feature)` is experimental and subject to change (see issue #29717)
--> $DIR/feature-gate-cfg-target-feature.rs:19:10
|
19 | cfg!(target_feature = "x");
diff --git a/src/test/ui/feature-gate-cfg-target-has-atomic.stderr b/src/test/ui/feature-gate-cfg-target-has-atomic.stderr
index 5daf5de..ace23b3 100644
--- a/src/test/ui/feature-gate-cfg-target-has-atomic.stderr
+++ b/src/test/ui/feature-gate-cfg-target-has-atomic.stderr
@@ -1,4 +1,4 @@
-error: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
+error[E0658]: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
--> $DIR/feature-gate-cfg-target-has-atomic.rs:23:7
|
23 | #[cfg(target_has_atomic = "8")]
@@ -6,7 +6,7 @@
|
= help: add #![feature(cfg_target_has_atomic)] to the crate attributes to enable
-error: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
+error[E0658]: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
--> $DIR/feature-gate-cfg-target-has-atomic.rs:29:7
|
29 | #[cfg(target_has_atomic = "8")]
@@ -14,7 +14,7 @@
|
= help: add #![feature(cfg_target_has_atomic)] to the crate attributes to enable
-error: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
+error[E0658]: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
--> $DIR/feature-gate-cfg-target-has-atomic.rs:34:7
|
34 | #[cfg(target_has_atomic = "16")]
@@ -22,7 +22,7 @@
|
= help: add #![feature(cfg_target_has_atomic)] to the crate attributes to enable
-error: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
+error[E0658]: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
--> $DIR/feature-gate-cfg-target-has-atomic.rs:39:7
|
39 | #[cfg(target_has_atomic = "16")]
@@ -30,7 +30,7 @@
|
= help: add #![feature(cfg_target_has_atomic)] to the crate attributes to enable
-error: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
+error[E0658]: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
--> $DIR/feature-gate-cfg-target-has-atomic.rs:44:7
|
44 | #[cfg(target_has_atomic = "32")]
@@ -38,7 +38,7 @@
|
= help: add #![feature(cfg_target_has_atomic)] to the crate attributes to enable
-error: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
+error[E0658]: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
--> $DIR/feature-gate-cfg-target-has-atomic.rs:49:7
|
49 | #[cfg(target_has_atomic = "32")]
@@ -46,7 +46,7 @@
|
= help: add #![feature(cfg_target_has_atomic)] to the crate attributes to enable
-error: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
+error[E0658]: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
--> $DIR/feature-gate-cfg-target-has-atomic.rs:54:7
|
54 | #[cfg(target_has_atomic = "64")]
@@ -54,7 +54,7 @@
|
= help: add #![feature(cfg_target_has_atomic)] to the crate attributes to enable
-error: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
+error[E0658]: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
--> $DIR/feature-gate-cfg-target-has-atomic.rs:59:7
|
59 | #[cfg(target_has_atomic = "64")]
@@ -62,7 +62,7 @@
|
= help: add #![feature(cfg_target_has_atomic)] to the crate attributes to enable
-error: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
+error[E0658]: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
--> $DIR/feature-gate-cfg-target-has-atomic.rs:64:7
|
64 | #[cfg(target_has_atomic = "ptr")]
@@ -70,7 +70,7 @@
|
= help: add #![feature(cfg_target_has_atomic)] to the crate attributes to enable
-error: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
+error[E0658]: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
--> $DIR/feature-gate-cfg-target-has-atomic.rs:69:7
|
69 | #[cfg(target_has_atomic = "ptr")]
@@ -78,7 +78,7 @@
|
= help: add #![feature(cfg_target_has_atomic)] to the crate attributes to enable
-error: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
+error[E0658]: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
--> $DIR/feature-gate-cfg-target-has-atomic.rs:76:10
|
76 | cfg!(target_has_atomic = "8");
@@ -86,7 +86,7 @@
|
= help: add #![feature(cfg_target_has_atomic)] to the crate attributes to enable
-error: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
+error[E0658]: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
--> $DIR/feature-gate-cfg-target-has-atomic.rs:78:10
|
78 | cfg!(target_has_atomic = "16");
@@ -94,7 +94,7 @@
|
= help: add #![feature(cfg_target_has_atomic)] to the crate attributes to enable
-error: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
+error[E0658]: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
--> $DIR/feature-gate-cfg-target-has-atomic.rs:80:10
|
80 | cfg!(target_has_atomic = "32");
@@ -102,7 +102,7 @@
|
= help: add #![feature(cfg_target_has_atomic)] to the crate attributes to enable
-error: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
+error[E0658]: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
--> $DIR/feature-gate-cfg-target-has-atomic.rs:82:10
|
82 | cfg!(target_has_atomic = "64");
@@ -110,7 +110,7 @@
|
= help: add #![feature(cfg_target_has_atomic)] to the crate attributes to enable
-error: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
+error[E0658]: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
--> $DIR/feature-gate-cfg-target-has-atomic.rs:84:10
|
84 | cfg!(target_has_atomic = "ptr");
diff --git a/src/test/ui/feature-gate-cfg-target-thread-local.stderr b/src/test/ui/feature-gate-cfg-target-thread-local.stderr
index 9e2eea6..a0a03bd 100644
--- a/src/test/ui/feature-gate-cfg-target-thread-local.stderr
+++ b/src/test/ui/feature-gate-cfg-target-thread-local.stderr
@@ -1,4 +1,4 @@
-error: `cfg(target_thread_local)` is experimental and subject to change (see issue #29594)
+error[E0658]: `cfg(target_thread_local)` is experimental and subject to change (see issue #29594)
--> $DIR/feature-gate-cfg-target-thread-local.rs:19:16
|
19 | #[cfg_attr(target_thread_local, thread_local)]
diff --git a/src/test/ui/feature-gate-cfg-target-vendor.stderr b/src/test/ui/feature-gate-cfg-target-vendor.stderr
index c570960..3e4a746 100644
--- a/src/test/ui/feature-gate-cfg-target-vendor.stderr
+++ b/src/test/ui/feature-gate-cfg-target-vendor.stderr
@@ -1,4 +1,4 @@
-error: `cfg(target_vendor)` is experimental and subject to change (see issue #29718)
+error[E0658]: `cfg(target_vendor)` is experimental and subject to change (see issue #29718)
--> $DIR/feature-gate-cfg-target-vendor.rs:12:12
|
12 | #[cfg_attr(target_vendor = "x", x)] //~ ERROR `cfg(target_vendor)` is experimental
@@ -6,7 +6,7 @@
|
= help: add #![feature(cfg_target_vendor)] to the crate attributes to enable
-error: `cfg(target_vendor)` is experimental and subject to change (see issue #29718)
+error[E0658]: `cfg(target_vendor)` is experimental and subject to change (see issue #29718)
--> $DIR/feature-gate-cfg-target-vendor.rs:11:7
|
11 | #[cfg(target_vendor = "x")] //~ ERROR `cfg(target_vendor)` is experimental
@@ -14,7 +14,7 @@
|
= help: add #![feature(cfg_target_vendor)] to the crate attributes to enable
-error: `cfg(target_vendor)` is experimental and subject to change (see issue #29718)
+error[E0658]: `cfg(target_vendor)` is experimental and subject to change (see issue #29718)
--> $DIR/feature-gate-cfg-target-vendor.rs:15:19
|
15 | #[cfg(not(any(all(target_vendor = "x"))))] //~ ERROR `cfg(target_vendor)` is experimental
@@ -22,7 +22,7 @@
|
= help: add #![feature(cfg_target_vendor)] to the crate attributes to enable
-error: `cfg(target_vendor)` is experimental and subject to change (see issue #29718)
+error[E0658]: `cfg(target_vendor)` is experimental and subject to change (see issue #29718)
--> $DIR/feature-gate-cfg-target-vendor.rs:19:10
|
19 | cfg!(target_vendor = "x");
diff --git a/src/test/ui/feature-gate-compiler-builtins.stderr b/src/test/ui/feature-gate-compiler-builtins.stderr
index ebf42b2..edb3c5d 100644
--- a/src/test/ui/feature-gate-compiler-builtins.stderr
+++ b/src/test/ui/feature-gate-compiler-builtins.stderr
@@ -1,4 +1,4 @@
-error: the `#[compiler_builtins]` attribute is used to identify the `compiler_builtins` crate which contains compiler-rt intrinsics and will never be stable
+error[E0658]: the `#[compiler_builtins]` attribute is used to identify the `compiler_builtins` crate which contains compiler-rt intrinsics and will never be stable
--> $DIR/feature-gate-compiler-builtins.rs:11:1
|
11 | #![compiler_builtins] //~ ERROR the `#[compiler_builtins]` attribute is
diff --git a/src/test/ui/feature-gate-concat_idents.stderr b/src/test/ui/feature-gate-concat_idents.stderr
index c980668..d0a07e3 100644
--- a/src/test/ui/feature-gate-concat_idents.stderr
+++ b/src/test/ui/feature-gate-concat_idents.stderr
@@ -1,4 +1,4 @@
-error: `concat_idents` is not stable enough for use and is subject to change (see issue #29599)
+error[E0658]: `concat_idents` is not stable enough for use and is subject to change (see issue #29599)
--> $DIR/feature-gate-concat_idents.rs:15:13
|
15 | let a = concat_idents!(X, Y_1); //~ ERROR `concat_idents` is not stable
@@ -6,7 +6,7 @@
|
= help: add #![feature(concat_idents)] to the crate attributes to enable
-error: `concat_idents` is not stable enough for use and is subject to change (see issue #29599)
+error[E0658]: `concat_idents` is not stable enough for use and is subject to change (see issue #29599)
--> $DIR/feature-gate-concat_idents.rs:16:13
|
16 | let b = concat_idents!(X, Y_2); //~ ERROR `concat_idents` is not stable
diff --git a/src/test/ui/feature-gate-concat_idents2.stderr b/src/test/ui/feature-gate-concat_idents2.stderr
index 9cfd954..0ef6921 100644
--- a/src/test/ui/feature-gate-concat_idents2.stderr
+++ b/src/test/ui/feature-gate-concat_idents2.stderr
@@ -1,4 +1,4 @@
-error: `concat_idents` is not stable enough for use and is subject to change (see issue #29599)
+error[E0658]: `concat_idents` is not stable enough for use and is subject to change (see issue #29599)
--> $DIR/feature-gate-concat_idents2.rs:14:5
|
14 | concat_idents!(a, b); //~ ERROR `concat_idents` is not stable enough
diff --git a/src/test/ui/feature-gate-concat_idents3.stderr b/src/test/ui/feature-gate-concat_idents3.stderr
index 8399ca3..a9a1e49 100644
--- a/src/test/ui/feature-gate-concat_idents3.stderr
+++ b/src/test/ui/feature-gate-concat_idents3.stderr
@@ -1,4 +1,4 @@
-error: `concat_idents` is not stable enough for use and is subject to change (see issue #29599)
+error[E0658]: `concat_idents` is not stable enough for use and is subject to change (see issue #29599)
--> $DIR/feature-gate-concat_idents3.rs:17:20
|
17 | assert_eq!(10, concat_idents!(X, Y_1)); //~ ERROR `concat_idents` is not stable
@@ -6,7 +6,7 @@
|
= help: add #![feature(concat_idents)] to the crate attributes to enable
-error: `concat_idents` is not stable enough for use and is subject to change (see issue #29599)
+error[E0658]: `concat_idents` is not stable enough for use and is subject to change (see issue #29599)
--> $DIR/feature-gate-concat_idents3.rs:18:20
|
18 | assert_eq!(20, concat_idents!(X, Y_2)); //~ ERROR `concat_idents` is not stable
diff --git a/src/test/ui/feature-gate-conservative_impl_trait.stderr b/src/test/ui/feature-gate-conservative_impl_trait.stderr
index 72a4f52..f3d3947 100644
--- a/src/test/ui/feature-gate-conservative_impl_trait.stderr
+++ b/src/test/ui/feature-gate-conservative_impl_trait.stderr
@@ -1,4 +1,4 @@
-error: `impl Trait` in return position is experimental (see issue #34511)
+error[E0658]: `impl Trait` in return position is experimental (see issue #34511)
--> $DIR/feature-gate-conservative_impl_trait.rs:11:13
|
11 | fn foo() -> impl Fn() { || {} }
diff --git a/src/test/ui/feature-gate-const_fn.stderr b/src/test/ui/feature-gate-const_fn.stderr
index c62229a..ecd1ff5 100644
--- a/src/test/ui/feature-gate-const_fn.stderr
+++ b/src/test/ui/feature-gate-const_fn.stderr
@@ -16,7 +16,7 @@
27 | const fn foo() -> u32 { 0 } //~ ERROR const fn is unstable
| ^^^^^ trait fns cannot be const
-error: const fn is unstable (see issue #24111)
+error[E0658]: const fn is unstable (see issue #24111)
--> $DIR/feature-gate-const_fn.rs:13:1
|
13 | const fn foo() -> usize { 0 } //~ ERROR const fn is unstable
@@ -24,7 +24,7 @@
|
= help: add #![feature(const_fn)] to the crate attributes to enable
-error: const fn is unstable (see issue #24111)
+error[E0658]: const fn is unstable (see issue #24111)
--> $DIR/feature-gate-const_fn.rs:16:5
|
16 | const fn foo() -> u32; //~ ERROR const fn is unstable
@@ -32,7 +32,7 @@
|
= help: add #![feature(const_fn)] to the crate attributes to enable
-error: const fn is unstable (see issue #24111)
+error[E0658]: const fn is unstable (see issue #24111)
--> $DIR/feature-gate-const_fn.rs:18:5
|
18 | const fn bar() -> u32 { 0 } //~ ERROR const fn is unstable
@@ -40,7 +40,7 @@
|
= help: add #![feature(const_fn)] to the crate attributes to enable
-error: const fn is unstable (see issue #24111)
+error[E0658]: const fn is unstable (see issue #24111)
--> $DIR/feature-gate-const_fn.rs:23:5
|
23 | const fn baz() -> u32 { 0 } //~ ERROR const fn is unstable
@@ -48,7 +48,7 @@
|
= help: add #![feature(const_fn)] to the crate attributes to enable
-error: const fn is unstable (see issue #24111)
+error[E0658]: const fn is unstable (see issue #24111)
--> $DIR/feature-gate-const_fn.rs:27:5
|
27 | const fn foo() -> u32 { 0 } //~ ERROR const fn is unstable
diff --git a/src/test/ui/feature-gate-crate_in_paths.stderr b/src/test/ui/feature-gate-crate_in_paths.stderr
index b13c82e..322a38a 100644
--- a/src/test/ui/feature-gate-crate_in_paths.stderr
+++ b/src/test/ui/feature-gate-crate_in_paths.stderr
@@ -1,4 +1,4 @@
-error: `crate` in paths is experimental (see issue #45477)
+error[E0658]: `crate` in paths is experimental (see issue #45477)
--> $DIR/feature-gate-crate_in_paths.rs:14:15
|
14 | let _ = ::crate::S; //~ ERROR `crate` in paths is experimental
diff --git a/src/test/ui/feature-gate-crate_visibility_modifier.stderr b/src/test/ui/feature-gate-crate_visibility_modifier.stderr
index 0862744..fadc76b 100644
--- a/src/test/ui/feature-gate-crate_visibility_modifier.stderr
+++ b/src/test/ui/feature-gate-crate_visibility_modifier.stderr
@@ -1,4 +1,4 @@
-error: `crate` visibility modifier is experimental (see issue #45388)
+error[E0658]: `crate` visibility modifier is experimental (see issue #45388)
--> $DIR/feature-gate-crate_visibility_modifier.rs:11:1
|
11 | crate struct Bender { //~ ERROR `crate` visibility modifier is experimental
diff --git a/src/test/ui/feature-gate-custom_attribute.stderr b/src/test/ui/feature-gate-custom_attribute.stderr
index 866ebfe..f4d726c 100644
--- a/src/test/ui/feature-gate-custom_attribute.stderr
+++ b/src/test/ui/feature-gate-custom_attribute.stderr
@@ -1,4 +1,4 @@
-error: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
+error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> $DIR/feature-gate-custom_attribute.rs:17:1
|
17 | #[fake_attr] //~ ERROR attribute `fake_attr` is currently unknown
@@ -6,7 +6,7 @@
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable
-error: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
+error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> $DIR/feature-gate-custom_attribute.rs:18:1
|
18 | #[fake_attr(100)] //~ ERROR attribute `fake_attr` is currently unknown
@@ -14,7 +14,7 @@
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable
-error: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
+error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> $DIR/feature-gate-custom_attribute.rs:19:1
|
19 | #[fake_attr(1, 2, 3)] //~ ERROR attribute `fake_attr` is currently unknown
@@ -22,7 +22,7 @@
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable
-error: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
+error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> $DIR/feature-gate-custom_attribute.rs:20:1
|
20 | #[fake_attr("hello")] //~ ERROR attribute `fake_attr` is currently unknown
@@ -30,7 +30,7 @@
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable
-error: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
+error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> $DIR/feature-gate-custom_attribute.rs:21:1
|
21 | #[fake_attr(name = "hello")] //~ ERROR attribute `fake_attr` is currently unknown
@@ -38,7 +38,7 @@
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable
-error: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
+error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> $DIR/feature-gate-custom_attribute.rs:22:1
|
22 | #[fake_attr(1, "hi", key = 12, true, false)] //~ ERROR attribute `fake_attr` is currently unknown
@@ -46,7 +46,7 @@
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable
-error: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
+error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> $DIR/feature-gate-custom_attribute.rs:23:1
|
23 | #[fake_attr(key = "hello", val = 10)] //~ ERROR attribute `fake_attr` is currently unknown
@@ -54,7 +54,7 @@
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable
-error: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
+error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> $DIR/feature-gate-custom_attribute.rs:24:1
|
24 | #[fake_attr(key("hello"), val(10))] //~ ERROR attribute `fake_attr` is currently unknown
@@ -62,7 +62,7 @@
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable
-error: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
+error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> $DIR/feature-gate-custom_attribute.rs:25:1
|
25 | #[fake_attr(enabled = true, disabled = false)] //~ ERROR attribute `fake_attr` is currently unknown
@@ -70,7 +70,7 @@
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable
-error: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
+error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> $DIR/feature-gate-custom_attribute.rs:26:1
|
26 | #[fake_attr(true)] //~ ERROR attribute `fake_attr` is currently unknown
@@ -78,7 +78,7 @@
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable
-error: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
+error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> $DIR/feature-gate-custom_attribute.rs:27:1
|
27 | #[fake_attr(pi = 3.14159)] //~ ERROR attribute `fake_attr` is currently unknown
@@ -86,7 +86,7 @@
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable
-error: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
+error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> $DIR/feature-gate-custom_attribute.rs:28:1
|
28 | #[fake_attr(b"hi")] //~ ERROR attribute `fake_attr` is currently unknown
@@ -94,7 +94,7 @@
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable
-error: The attribute `fake_doc` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
+error[E0658]: The attribute `fake_doc` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> $DIR/feature-gate-custom_attribute.rs:29:1
|
29 | #[fake_doc(r"doc")] //~ ERROR attribute `fake_doc` is currently unknown
diff --git a/src/test/ui/feature-gate-custom_attribute2.stderr b/src/test/ui/feature-gate-custom_attribute2.stderr
index 3e4ea58..08878e1 100644
--- a/src/test/ui/feature-gate-custom_attribute2.stderr
+++ b/src/test/ui/feature-gate-custom_attribute2.stderr
@@ -1,4 +1,4 @@
-error: The attribute `lt_struct` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
+error[E0658]: The attribute `lt_struct` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> $DIR/feature-gate-custom_attribute2.rs:23:13
|
23 | struct StLt<#[lt_struct] 'a>(&'a u32);
@@ -6,7 +6,7 @@
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable
-error: The attribute `ty_struct` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
+error[E0658]: The attribute `ty_struct` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> $DIR/feature-gate-custom_attribute2.rs:25:13
|
25 | struct StTy<#[ty_struct] I>(I);
@@ -14,7 +14,7 @@
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable
-error: The attribute `lt_enum` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
+error[E0658]: The attribute `lt_enum` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> $DIR/feature-gate-custom_attribute2.rs:28:11
|
28 | enum EnLt<#[lt_enum] 'b> { A(&'b u32), B }
@@ -22,7 +22,7 @@
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable
-error: The attribute `ty_enum` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
+error[E0658]: The attribute `ty_enum` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> $DIR/feature-gate-custom_attribute2.rs:30:11
|
30 | enum EnTy<#[ty_enum] J> { A(J), B }
@@ -30,7 +30,7 @@
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable
-error: The attribute `lt_trait` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
+error[E0658]: The attribute `lt_trait` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> $DIR/feature-gate-custom_attribute2.rs:33:12
|
33 | trait TrLt<#[lt_trait] 'c> { fn foo(&self, _: &'c [u32]) -> &'c u32; }
@@ -38,7 +38,7 @@
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable
-error: The attribute `ty_trait` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
+error[E0658]: The attribute `ty_trait` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> $DIR/feature-gate-custom_attribute2.rs:35:12
|
35 | trait TrTy<#[ty_trait] K> { fn foo(&self, _: K); }
@@ -46,7 +46,7 @@
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable
-error: The attribute `lt_type` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
+error[E0658]: The attribute `lt_type` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> $DIR/feature-gate-custom_attribute2.rs:38:11
|
38 | type TyLt<#[lt_type] 'd> = &'d u32;
@@ -54,7 +54,7 @@
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable
-error: The attribute `ty_type` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
+error[E0658]: The attribute `ty_type` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> $DIR/feature-gate-custom_attribute2.rs:40:11
|
40 | type TyTy<#[ty_type] L> = (L, );
@@ -62,7 +62,7 @@
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable
-error: The attribute `lt_inherent` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
+error[E0658]: The attribute `lt_inherent` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> $DIR/feature-gate-custom_attribute2.rs:43:6
|
43 | impl<#[lt_inherent] 'e> StLt<'e> { }
@@ -70,7 +70,7 @@
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable
-error: The attribute `ty_inherent` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
+error[E0658]: The attribute `ty_inherent` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> $DIR/feature-gate-custom_attribute2.rs:45:6
|
45 | impl<#[ty_inherent] M> StTy<M> { }
@@ -78,7 +78,7 @@
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable
-error: The attribute `lt_impl_for` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
+error[E0658]: The attribute `lt_impl_for` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> $DIR/feature-gate-custom_attribute2.rs:48:6
|
48 | impl<#[lt_impl_for] 'f> TrLt<'f> for StLt<'f> {
@@ -86,7 +86,7 @@
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable
-error: The attribute `ty_impl_for` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
+error[E0658]: The attribute `ty_impl_for` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> $DIR/feature-gate-custom_attribute2.rs:52:6
|
52 | impl<#[ty_impl_for] N> TrTy<N> for StTy<N> {
@@ -94,7 +94,7 @@
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable
-error: The attribute `lt_fn` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
+error[E0658]: The attribute `lt_fn` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> $DIR/feature-gate-custom_attribute2.rs:57:9
|
57 | fn f_lt<#[lt_fn] 'g>(_: &'g [u32]) -> &'g u32 { loop { } }
@@ -102,7 +102,7 @@
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable
-error: The attribute `ty_fn` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
+error[E0658]: The attribute `ty_fn` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> $DIR/feature-gate-custom_attribute2.rs:59:9
|
59 | fn f_ty<#[ty_fn] O>(_: O) { }
@@ -110,7 +110,7 @@
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable
-error: The attribute `lt_meth` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
+error[E0658]: The attribute `lt_meth` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> $DIR/feature-gate-custom_attribute2.rs:63:13
|
63 | fn m_lt<#[lt_meth] 'h>(_: &'h [u32]) -> &'h u32 { loop { } }
@@ -118,7 +118,7 @@
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable
-error: The attribute `ty_meth` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
+error[E0658]: The attribute `ty_meth` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> $DIR/feature-gate-custom_attribute2.rs:65:13
|
65 | fn m_ty<#[ty_meth] P>(_: P) { }
@@ -126,7 +126,7 @@
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable
-error: The attribute `lt_hof` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
+error[E0658]: The attribute `lt_hof` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> $DIR/feature-gate-custom_attribute2.rs:70:19
|
70 | where Q: for <#[lt_hof] 'i> Fn(&'i [u32]) -> &'i u32
diff --git a/src/test/ui/feature-gate-custom_derive.stderr b/src/test/ui/feature-gate-custom_derive.stderr
index e806c80..8606628 100644
--- a/src/test/ui/feature-gate-custom_derive.stderr
+++ b/src/test/ui/feature-gate-custom_derive.stderr
@@ -1,4 +1,4 @@
-error: attributes of the form `#[derive_*]` are reserved for the compiler (see issue #29644)
+error[E0658]: attributes of the form `#[derive_*]` are reserved for the compiler (see issue #29644)
--> $DIR/feature-gate-custom_derive.rs:11:1
|
11 | #[derive_Clone]
diff --git a/src/test/ui/feature-gate-decl_macro.stderr b/src/test/ui/feature-gate-decl_macro.stderr
index 49ce4eb..c7144f09 100644
--- a/src/test/ui/feature-gate-decl_macro.stderr
+++ b/src/test/ui/feature-gate-decl_macro.stderr
@@ -1,4 +1,4 @@
-error: `macro` is experimental (see issue #39412)
+error[E0658]: `macro` is experimental (see issue #39412)
--> $DIR/feature-gate-decl_macro.rs:13:1
|
13 | macro m() {} //~ ERROR `macro` is experimental (see issue #39412)
diff --git a/src/test/ui/feature-gate-doc_cfg.stderr b/src/test/ui/feature-gate-doc_cfg.stderr
index c2d8a93..e009e0b 100644
--- a/src/test/ui/feature-gate-doc_cfg.stderr
+++ b/src/test/ui/feature-gate-doc_cfg.stderr
@@ -1,4 +1,4 @@
-error: #[doc(cfg(...))] is experimental (see issue #43781)
+error[E0658]: #[doc(cfg(...))] is experimental (see issue #43781)
--> $DIR/feature-gate-doc_cfg.rs:11:1
|
11 | #[doc(cfg(unix))] //~ ERROR: #[doc(cfg(...))] is experimental
diff --git a/src/test/ui/feature-gate-doc_masked.stderr b/src/test/ui/feature-gate-doc_masked.stderr
index 1102076..ee2d384 100644
--- a/src/test/ui/feature-gate-doc_masked.stderr
+++ b/src/test/ui/feature-gate-doc_masked.stderr
@@ -1,4 +1,4 @@
-error: #[doc(masked)] is experimental (see issue #44027)
+error[E0658]: #[doc(masked)] is experimental (see issue #44027)
--> $DIR/feature-gate-doc_masked.rs:11:1
|
11 | #[doc(masked)] //~ ERROR: #[doc(masked)] is experimental
diff --git a/src/test/ui/feature-gate-doc_spotlight.stderr b/src/test/ui/feature-gate-doc_spotlight.stderr
index b743a1e..36d8548 100644
--- a/src/test/ui/feature-gate-doc_spotlight.stderr
+++ b/src/test/ui/feature-gate-doc_spotlight.stderr
@@ -1,4 +1,4 @@
-error: #[doc(spotlight)] is experimental (see issue #45040)
+error[E0658]: #[doc(spotlight)] is experimental (see issue #45040)
--> $DIR/feature-gate-doc_spotlight.rs:11:1
|
11 | #[doc(spotlight)] //~ ERROR: #[doc(spotlight)] is experimental
diff --git a/src/test/ui/feature-gate-dotdoteq_in_patterns.stderr b/src/test/ui/feature-gate-dotdoteq_in_patterns.stderr
index 5319dce..2d26c6a 100644
--- a/src/test/ui/feature-gate-dotdoteq_in_patterns.stderr
+++ b/src/test/ui/feature-gate-dotdoteq_in_patterns.stderr
@@ -1,4 +1,4 @@
-error: `..=` syntax in patterns is experimental (see issue #28237)
+error[E0658]: `..=` syntax in patterns is experimental (see issue #28237)
--> $DIR/feature-gate-dotdoteq_in_patterns.rs:13:9
|
13 | 0 ..= 3 => {} //~ ERROR `..=` syntax in patterns is experimental
diff --git a/src/test/ui/feature-gate-dropck-ugeh.stderr b/src/test/ui/feature-gate-dropck-ugeh.stderr
index b030ebc..cdeca70 100644
--- a/src/test/ui/feature-gate-dropck-ugeh.stderr
+++ b/src/test/ui/feature-gate-dropck-ugeh.stderr
@@ -1,4 +1,4 @@
-error: unsafe_destructor_blind_to_params has been replaced by may_dangle and will be removed in the future (see issue #28498)
+error[E0658]: unsafe_destructor_blind_to_params has been replaced by may_dangle and will be removed in the future (see issue #28498)
--> $DIR/feature-gate-dropck-ugeh.rs:29:5
|
29 | #[unsafe_destructor_blind_to_params] // This is the UGEH attribute
diff --git a/src/test/ui/feature-gate-dyn-trait.stderr b/src/test/ui/feature-gate-dyn-trait.stderr
index 28ecfdf..d6ba4b8 100644
--- a/src/test/ui/feature-gate-dyn-trait.stderr
+++ b/src/test/ui/feature-gate-dyn-trait.stderr
@@ -1,4 +1,4 @@
-error: `dyn Trait` syntax is unstable (see issue #44662)
+error[E0658]: `dyn Trait` syntax is unstable (see issue #44662)
--> $DIR/feature-gate-dyn-trait.rs:12:14
|
12 | type A = Box<dyn Trait>; //~ ERROR `dyn Trait` syntax is unstable
diff --git a/src/test/ui/feature-gate-exclusive-range-pattern.stderr b/src/test/ui/feature-gate-exclusive-range-pattern.stderr
index c6785d6..3185281 100644
--- a/src/test/ui/feature-gate-exclusive-range-pattern.stderr
+++ b/src/test/ui/feature-gate-exclusive-range-pattern.stderr
@@ -1,4 +1,4 @@
-error: exclusive range pattern syntax is experimental (see issue #37854)
+error[E0658]: exclusive range pattern syntax is experimental (see issue #37854)
--> $DIR/feature-gate-exclusive-range-pattern.rs:13:9
|
13 | 0 .. 3 => {} //~ ERROR exclusive range pattern syntax is experimental
diff --git a/src/test/ui/feature-gate-extern_in_paths.stderr b/src/test/ui/feature-gate-extern_in_paths.stderr
index ac68e79..022e53b 100644
--- a/src/test/ui/feature-gate-extern_in_paths.stderr
+++ b/src/test/ui/feature-gate-extern_in_paths.stderr
@@ -1,4 +1,4 @@
-error: `extern` in paths is experimental (see issue #44660)
+error[E0658]: `extern` in paths is experimental (see issue #44660)
--> $DIR/feature-gate-extern_in_paths.rs:14:13
|
14 | let _ = extern::std::vec::Vec::new(); //~ ERROR `extern` in paths is experimental
diff --git a/src/test/ui/feature-gate-extern_types.stderr b/src/test/ui/feature-gate-extern_types.stderr
index 3815862..71caa37 100644
--- a/src/test/ui/feature-gate-extern_types.stderr
+++ b/src/test/ui/feature-gate-extern_types.stderr
@@ -1,4 +1,4 @@
-error: extern types are experimental (see issue #43467)
+error[E0658]: extern types are experimental (see issue #43467)
--> $DIR/feature-gate-extern_types.rs:12:5
|
12 | type T; //~ ERROR extern types are experimental
diff --git a/src/test/ui/feature-gate-external_doc.stderr b/src/test/ui/feature-gate-external_doc.stderr
index 5479ab8..db6c99b 100644
--- a/src/test/ui/feature-gate-external_doc.stderr
+++ b/src/test/ui/feature-gate-external_doc.stderr
@@ -1,4 +1,4 @@
-error: #[doc(include = "...")] is experimental (see issue #44732)
+error[E0658]: #[doc(include = "...")] is experimental (see issue #44732)
--> $DIR/feature-gate-external_doc.rs:11:1
|
11 | #[doc(include="asdf.md")] //~ ERROR: #[doc(include = "...")] is experimental
diff --git a/src/test/ui/feature-gate-fundamental.stderr b/src/test/ui/feature-gate-fundamental.stderr
index 0fc75ee..28d8a80 100644
--- a/src/test/ui/feature-gate-fundamental.stderr
+++ b/src/test/ui/feature-gate-fundamental.stderr
@@ -1,4 +1,4 @@
-error: the `#[fundamental]` attribute is an experimental feature (see issue #29635)
+error[E0658]: the `#[fundamental]` attribute is an experimental feature (see issue #29635)
--> $DIR/feature-gate-fundamental.rs:11:1
|
11 | #[fundamental] //~ ERROR the `#[fundamental]` attribute is an experimental feature
diff --git a/src/test/ui/feature-gate-generators.stderr b/src/test/ui/feature-gate-generators.stderr
index 82acb40..f559227 100644
--- a/src/test/ui/feature-gate-generators.stderr
+++ b/src/test/ui/feature-gate-generators.stderr
@@ -1,4 +1,4 @@
-error: yield syntax is experimental
+error[E0658]: yield syntax is experimental
--> $DIR/feature-gate-generators.rs:12:5
|
12 | yield true; //~ ERROR yield syntax is experimental
diff --git a/src/test/ui/feature-gate-generic_associated_types.stderr b/src/test/ui/feature-gate-generic_associated_types.stderr
index 7b2507e..c047914 100644
--- a/src/test/ui/feature-gate-generic_associated_types.stderr
+++ b/src/test/ui/feature-gate-generic_associated_types.stderr
@@ -1,4 +1,4 @@
-error: generic associated types are unstable (see issue #44265)
+error[E0658]: generic associated types are unstable (see issue #44265)
--> $DIR/feature-gate-generic_associated_types.rs:14:5
|
14 | type Pointer<T>: Deref<Target = T>;
@@ -6,7 +6,7 @@
|
= help: add #![feature(generic_associated_types)] to the crate attributes to enable
-error: generic associated types are unstable (see issue #44265)
+error[E0658]: generic associated types are unstable (see issue #44265)
--> $DIR/feature-gate-generic_associated_types.rs:16:5
|
16 | type Pointer2<T>: Deref<Target = T> where T: Clone, U: Clone;
@@ -14,7 +14,7 @@
|
= help: add #![feature(generic_associated_types)] to the crate attributes to enable
-error: generic associated types are unstable (see issue #44265)
+error[E0658]: generic associated types are unstable (see issue #44265)
--> $DIR/feature-gate-generic_associated_types.rs:22:5
|
22 | type Pointer<usize> = Box<usize>;
@@ -22,7 +22,7 @@
|
= help: add #![feature(generic_associated_types)] to the crate attributes to enable
-error: generic associated types are unstable (see issue #44265)
+error[E0658]: generic associated types are unstable (see issue #44265)
--> $DIR/feature-gate-generic_associated_types.rs:24:5
|
24 | type Pointer2<u32> = Box<u32>;
diff --git a/src/test/ui/feature-gate-generic_param_attrs.stderr b/src/test/ui/feature-gate-generic_param_attrs.stderr
index da2e640..a18d104 100644
--- a/src/test/ui/feature-gate-generic_param_attrs.stderr
+++ b/src/test/ui/feature-gate-generic_param_attrs.stderr
@@ -1,4 +1,4 @@
-error: attributes on lifetime bindings are experimental (see issue #34761)
+error[E0658]: attributes on lifetime bindings are experimental (see issue #34761)
--> $DIR/feature-gate-generic_param_attrs.rs:22:13
|
22 | struct StLt<#[rustc_lt_struct] 'a>(&'a u32);
@@ -6,7 +6,7 @@
|
= help: add #![feature(generic_param_attrs)] to the crate attributes to enable
-error: attributes on type parameter bindings are experimental (see issue #34761)
+error[E0658]: attributes on type parameter bindings are experimental (see issue #34761)
--> $DIR/feature-gate-generic_param_attrs.rs:24:13
|
24 | struct StTy<#[rustc_ty_struct] I>(I);
@@ -14,7 +14,7 @@
|
= help: add #![feature(generic_param_attrs)] to the crate attributes to enable
-error: attributes on lifetime bindings are experimental (see issue #34761)
+error[E0658]: attributes on lifetime bindings are experimental (see issue #34761)
--> $DIR/feature-gate-generic_param_attrs.rs:27:11
|
27 | enum EnLt<#[rustc_lt_enum] 'b> { A(&'b u32), B }
@@ -22,7 +22,7 @@
|
= help: add #![feature(generic_param_attrs)] to the crate attributes to enable
-error: attributes on type parameter bindings are experimental (see issue #34761)
+error[E0658]: attributes on type parameter bindings are experimental (see issue #34761)
--> $DIR/feature-gate-generic_param_attrs.rs:29:11
|
29 | enum EnTy<#[rustc_ty_enum] J> { A(J), B }
@@ -30,7 +30,7 @@
|
= help: add #![feature(generic_param_attrs)] to the crate attributes to enable
-error: attributes on lifetime bindings are experimental (see issue #34761)
+error[E0658]: attributes on lifetime bindings are experimental (see issue #34761)
--> $DIR/feature-gate-generic_param_attrs.rs:32:12
|
32 | trait TrLt<#[rustc_lt_trait] 'c> { fn foo(&self, _: &'c [u32]) -> &'c u32; }
@@ -38,7 +38,7 @@
|
= help: add #![feature(generic_param_attrs)] to the crate attributes to enable
-error: attributes on type parameter bindings are experimental (see issue #34761)
+error[E0658]: attributes on type parameter bindings are experimental (see issue #34761)
--> $DIR/feature-gate-generic_param_attrs.rs:34:12
|
34 | trait TrTy<#[rustc_ty_trait] K> { fn foo(&self, _: K); }
@@ -46,7 +46,7 @@
|
= help: add #![feature(generic_param_attrs)] to the crate attributes to enable
-error: attributes on lifetime bindings are experimental (see issue #34761)
+error[E0658]: attributes on lifetime bindings are experimental (see issue #34761)
--> $DIR/feature-gate-generic_param_attrs.rs:37:11
|
37 | type TyLt<#[rustc_lt_type] 'd> = &'d u32;
@@ -54,7 +54,7 @@
|
= help: add #![feature(generic_param_attrs)] to the crate attributes to enable
-error: attributes on type parameter bindings are experimental (see issue #34761)
+error[E0658]: attributes on type parameter bindings are experimental (see issue #34761)
--> $DIR/feature-gate-generic_param_attrs.rs:39:11
|
39 | type TyTy<#[rustc_ty_type] L> = (L, );
@@ -62,7 +62,7 @@
|
= help: add #![feature(generic_param_attrs)] to the crate attributes to enable
-error: attributes on lifetime bindings are experimental (see issue #34761)
+error[E0658]: attributes on lifetime bindings are experimental (see issue #34761)
--> $DIR/feature-gate-generic_param_attrs.rs:42:6
|
42 | impl<#[rustc_lt_inherent] 'e> StLt<'e> { }
@@ -70,7 +70,7 @@
|
= help: add #![feature(generic_param_attrs)] to the crate attributes to enable
-error: attributes on type parameter bindings are experimental (see issue #34761)
+error[E0658]: attributes on type parameter bindings are experimental (see issue #34761)
--> $DIR/feature-gate-generic_param_attrs.rs:44:6
|
44 | impl<#[rustc_ty_inherent] M> StTy<M> { }
@@ -78,7 +78,7 @@
|
= help: add #![feature(generic_param_attrs)] to the crate attributes to enable
-error: attributes on lifetime bindings are experimental (see issue #34761)
+error[E0658]: attributes on lifetime bindings are experimental (see issue #34761)
--> $DIR/feature-gate-generic_param_attrs.rs:47:6
|
47 | impl<#[rustc_lt_impl_for] 'f> TrLt<'f> for StLt<'f> {
@@ -86,7 +86,7 @@
|
= help: add #![feature(generic_param_attrs)] to the crate attributes to enable
-error: attributes on type parameter bindings are experimental (see issue #34761)
+error[E0658]: attributes on type parameter bindings are experimental (see issue #34761)
--> $DIR/feature-gate-generic_param_attrs.rs:51:6
|
51 | impl<#[rustc_ty_impl_for] N> TrTy<N> for StTy<N> {
@@ -94,7 +94,7 @@
|
= help: add #![feature(generic_param_attrs)] to the crate attributes to enable
-error: attributes on lifetime bindings are experimental (see issue #34761)
+error[E0658]: attributes on lifetime bindings are experimental (see issue #34761)
--> $DIR/feature-gate-generic_param_attrs.rs:56:9
|
56 | fn f_lt<#[rustc_lt_fn] 'g>(_: &'g [u32]) -> &'g u32 { loop { } }
@@ -102,7 +102,7 @@
|
= help: add #![feature(generic_param_attrs)] to the crate attributes to enable
-error: attributes on type parameter bindings are experimental (see issue #34761)
+error[E0658]: attributes on type parameter bindings are experimental (see issue #34761)
--> $DIR/feature-gate-generic_param_attrs.rs:58:9
|
58 | fn f_ty<#[rustc_ty_fn] O>(_: O) { }
@@ -110,7 +110,7 @@
|
= help: add #![feature(generic_param_attrs)] to the crate attributes to enable
-error: attributes on lifetime bindings are experimental (see issue #34761)
+error[E0658]: attributes on lifetime bindings are experimental (see issue #34761)
--> $DIR/feature-gate-generic_param_attrs.rs:62:13
|
62 | fn m_lt<#[rustc_lt_meth] 'h>(_: &'h [u32]) -> &'h u32 { loop { } }
@@ -118,7 +118,7 @@
|
= help: add #![feature(generic_param_attrs)] to the crate attributes to enable
-error: attributes on type parameter bindings are experimental (see issue #34761)
+error[E0658]: attributes on type parameter bindings are experimental (see issue #34761)
--> $DIR/feature-gate-generic_param_attrs.rs:64:13
|
64 | fn m_ty<#[rustc_ty_meth] P>(_: P) { }
@@ -126,7 +126,7 @@
|
= help: add #![feature(generic_param_attrs)] to the crate attributes to enable
-error: attributes on lifetime bindings are experimental (see issue #34761)
+error[E0658]: attributes on lifetime bindings are experimental (see issue #34761)
--> $DIR/feature-gate-generic_param_attrs.rs:69:19
|
69 | where Q: for <#[rustc_lt_hof] 'i> Fn(&'i [u32]) -> &'i u32
diff --git a/src/test/ui/feature-gate-global_allocator.stderr b/src/test/ui/feature-gate-global_allocator.stderr
index 7e6c428..8d82f6e 100644
--- a/src/test/ui/feature-gate-global_allocator.stderr
+++ b/src/test/ui/feature-gate-global_allocator.stderr
@@ -1,4 +1,4 @@
-error: the `#[global_allocator]` attribute is an experimental feature
+error[E0658]: the `#[global_allocator]` attribute is an experimental feature
--> $DIR/feature-gate-global_allocator.rs:11:1
|
11 | #[global_allocator] //~ ERROR: attribute is an experimental feature
diff --git a/src/test/ui/feature-gate-global_asm.stderr b/src/test/ui/feature-gate-global_asm.stderr
index de0ba1a..ca94657 100644
--- a/src/test/ui/feature-gate-global_asm.stderr
+++ b/src/test/ui/feature-gate-global_asm.stderr
@@ -1,4 +1,4 @@
-error: `global_asm!` is not stable enough for use and is subject to change (see issue #35119)
+error[E0658]: `global_asm!` is not stable enough for use and is subject to change (see issue #35119)
--> $DIR/feature-gate-global_asm.rs:11:1
|
11 | global_asm!(""); //~ ERROR `global_asm!` is not stable
diff --git a/src/test/ui/feature-gate-i128_type.stderr b/src/test/ui/feature-gate-i128_type.stderr
index df623ca..06fdead 100644
--- a/src/test/ui/feature-gate-i128_type.stderr
+++ b/src/test/ui/feature-gate-i128_type.stderr
@@ -1,4 +1,4 @@
-error: 128-bit integers are not stable (see issue #35118)
+error[E0658]: 128-bit integers are not stable (see issue #35118)
--> $DIR/feature-gate-i128_type.rs:12:5
|
12 | 0i128; //~ ERROR 128-bit integers are not stable
@@ -6,7 +6,7 @@
|
= help: add #![feature(i128_type)] to the crate attributes to enable
-error: 128-bit integers are not stable (see issue #35118)
+error[E0658]: 128-bit integers are not stable (see issue #35118)
--> $DIR/feature-gate-i128_type.rs:16:5
|
16 | 0u128; //~ ERROR 128-bit integers are not stable
diff --git a/src/test/ui/feature-gate-i128_type2.stderr b/src/test/ui/feature-gate-i128_type2.stderr
index 26653a57..ee81a26 100644
--- a/src/test/ui/feature-gate-i128_type2.stderr
+++ b/src/test/ui/feature-gate-i128_type2.stderr
@@ -1,4 +1,4 @@
-error: 128-bit type is unstable (see issue #35118)
+error[E0658]: 128-bit type is unstable (see issue #35118)
--> $DIR/feature-gate-i128_type2.rs:13:15
|
13 | fn test1() -> i128 { //~ ERROR 128-bit type is unstable
@@ -6,7 +6,7 @@
|
= help: add #![feature(i128_type)] to the crate attributes to enable
-error: 128-bit type is unstable (see issue #35118)
+error[E0658]: 128-bit type is unstable (see issue #35118)
--> $DIR/feature-gate-i128_type2.rs:17:17
|
17 | fn test1_2() -> u128 { //~ ERROR 128-bit type is unstable
@@ -14,7 +14,7 @@
|
= help: add #![feature(i128_type)] to the crate attributes to enable
-error: 128-bit type is unstable (see issue #35118)
+error[E0658]: 128-bit type is unstable (see issue #35118)
--> $DIR/feature-gate-i128_type2.rs:22:12
|
22 | let x: i128 = 0; //~ ERROR 128-bit type is unstable
@@ -22,7 +22,7 @@
|
= help: add #![feature(i128_type)] to the crate attributes to enable
-error: 128-bit type is unstable (see issue #35118)
+error[E0658]: 128-bit type is unstable (see issue #35118)
--> $DIR/feature-gate-i128_type2.rs:26:12
|
26 | let x: u128 = 0; //~ ERROR 128-bit type is unstable
@@ -32,7 +32,7 @@
error[E0601]: main function not found
-error: repr with 128-bit type is unstable (see issue #35118)
+error[E0658]: repr with 128-bit type is unstable (see issue #35118)
--> $DIR/feature-gate-i128_type2.rs:30:1
|
30 | / enum A { //~ ERROR 128-bit type is unstable
diff --git a/src/test/ui/feature-gate-intrinsics.stderr b/src/test/ui/feature-gate-intrinsics.stderr
index 5382122..918c749 100644
--- a/src/test/ui/feature-gate-intrinsics.stderr
+++ b/src/test/ui/feature-gate-intrinsics.stderr
@@ -1,4 +1,4 @@
-error: intrinsics are subject to change
+error[E0658]: intrinsics are subject to change
--> $DIR/feature-gate-intrinsics.rs:11:1
|
11 | / extern "rust-intrinsic" { //~ ERROR intrinsics are subject to change
@@ -8,7 +8,7 @@
|
= help: add #![feature(intrinsics)] to the crate attributes to enable
-error: intrinsics are subject to change
+error[E0658]: intrinsics are subject to change
--> $DIR/feature-gate-intrinsics.rs:15:1
|
15 | / extern "rust-intrinsic" fn baz() { //~ ERROR intrinsics are subject to change
diff --git a/src/test/ui/feature-gate-lang-items.stderr b/src/test/ui/feature-gate-lang-items.stderr
index dab8ce2..28e3dab 100644
--- a/src/test/ui/feature-gate-lang-items.stderr
+++ b/src/test/ui/feature-gate-lang-items.stderr
@@ -1,4 +1,4 @@
-error: language items are subject to change
+error[E0658]: language items are subject to change
--> $DIR/feature-gate-lang-items.rs:11:1
|
11 | #[lang="foo"] //~ ERROR language items are subject to change
diff --git a/src/test/ui/feature-gate-link_args.stderr b/src/test/ui/feature-gate-link_args.stderr
index d6d05900..78070d5 100644
--- a/src/test/ui/feature-gate-link_args.stderr
+++ b/src/test/ui/feature-gate-link_args.stderr
@@ -1,4 +1,4 @@
-error: the `link_args` attribute is experimental and not portable across platforms, it is recommended to use `#[link(name = "foo")] instead (see issue #29596)
+error[E0658]: the `link_args` attribute is experimental and not portable across platforms, it is recommended to use `#[link(name = "foo")] instead (see issue #29596)
--> $DIR/feature-gate-link_args.rs:22:1
|
22 | #[link_args = "-l expected_use_case"]
@@ -6,7 +6,7 @@
|
= help: add #![feature(link_args)] to the crate attributes to enable
-error: the `link_args` attribute is experimental and not portable across platforms, it is recommended to use `#[link(name = "foo")] instead (see issue #29596)
+error[E0658]: the `link_args` attribute is experimental and not portable across platforms, it is recommended to use `#[link(name = "foo")] instead (see issue #29596)
--> $DIR/feature-gate-link_args.rs:26:1
|
26 | #[link_args = "-l unexected_use_on_non_extern_item"]
@@ -14,7 +14,7 @@
|
= help: add #![feature(link_args)] to the crate attributes to enable
-error: the `link_args` attribute is experimental and not portable across platforms, it is recommended to use `#[link(name = "foo")] instead (see issue #29596)
+error[E0658]: the `link_args` attribute is experimental and not portable across platforms, it is recommended to use `#[link(name = "foo")] instead (see issue #29596)
--> $DIR/feature-gate-link_args.rs:19:1
|
19 | #![link_args = "-l unexpected_use_as_inner_attr_on_mod"]
diff --git a/src/test/ui/feature-gate-link_cfg.stderr b/src/test/ui/feature-gate-link_cfg.stderr
index bbc52bd..8aada72 100644
--- a/src/test/ui/feature-gate-link_cfg.stderr
+++ b/src/test/ui/feature-gate-link_cfg.stderr
@@ -1,4 +1,4 @@
-error: is feature gated (see issue #37406)
+error[E0658]: is feature gated (see issue #37406)
--> $DIR/feature-gate-link_cfg.rs:11:1
|
11 | #[link(name = "foo", cfg(foo))]
diff --git a/src/test/ui/feature-gate-link_llvm_intrinsics.stderr b/src/test/ui/feature-gate-link_llvm_intrinsics.stderr
index b2e2caa..136658f 100644
--- a/src/test/ui/feature-gate-link_llvm_intrinsics.stderr
+++ b/src/test/ui/feature-gate-link_llvm_intrinsics.stderr
@@ -1,4 +1,4 @@
-error: linking to LLVM intrinsics is experimental (see issue #29602)
+error[E0658]: linking to LLVM intrinsics is experimental (see issue #29602)
--> $DIR/feature-gate-link_llvm_intrinsics.rs:13:5
|
13 | fn sqrt(x: f32) -> f32;
diff --git a/src/test/ui/feature-gate-linkage.stderr b/src/test/ui/feature-gate-linkage.stderr
index 62d857d..54764b1 100644
--- a/src/test/ui/feature-gate-linkage.stderr
+++ b/src/test/ui/feature-gate-linkage.stderr
@@ -1,4 +1,4 @@
-error: the `linkage` attribute is experimental and not portable across platforms (see issue #29603)
+error[E0658]: the `linkage` attribute is experimental and not portable across platforms (see issue #29603)
--> $DIR/feature-gate-linkage.rs:12:5
|
12 | #[linkage = "extern_weak"] static foo: isize;
diff --git a/src/test/ui/feature-gate-linker-flavor.stderr b/src/test/ui/feature-gate-linker-flavor.stderr
index 383e75e..e58693d 100644
--- a/src/test/ui/feature-gate-linker-flavor.stderr
+++ b/src/test/ui/feature-gate-linker-flavor.stderr
@@ -1,4 +1,4 @@
-error: the `#[used]` attribute is an experimental feature (see issue #40289)
+error[E0658]: the `#[used]` attribute is an experimental feature (see issue #40289)
--> $DIR/feature-gate-linker-flavor.rs:16:1
|
16 | #[used]
diff --git a/src/test/ui/feature-gate-log_syntax.stderr b/src/test/ui/feature-gate-log_syntax.stderr
index f1c0d30..363b175 100644
--- a/src/test/ui/feature-gate-log_syntax.stderr
+++ b/src/test/ui/feature-gate-log_syntax.stderr
@@ -1,4 +1,4 @@
-error: `log_syntax!` is not stable enough for use and is subject to change (see issue #29598)
+error[E0658]: `log_syntax!` is not stable enough for use and is subject to change (see issue #29598)
--> $DIR/feature-gate-log_syntax.rs:12:5
|
12 | log_syntax!() //~ ERROR `log_syntax!` is not stable enough
diff --git a/src/test/ui/feature-gate-log_syntax2.stderr b/src/test/ui/feature-gate-log_syntax2.stderr
index b1bb555..f47a507 100644
--- a/src/test/ui/feature-gate-log_syntax2.stderr
+++ b/src/test/ui/feature-gate-log_syntax2.stderr
@@ -1,4 +1,4 @@
-error: `log_syntax!` is not stable enough for use and is subject to change (see issue #29598)
+error[E0658]: `log_syntax!` is not stable enough for use and is subject to change (see issue #29598)
--> $DIR/feature-gate-log_syntax2.rs:14:20
|
14 | println!("{}", log_syntax!()); //~ ERROR `log_syntax!` is not stable
diff --git a/src/test/ui/feature-gate-macro-lifetime-matcher.stderr b/src/test/ui/feature-gate-macro-lifetime-matcher.stderr
index e78f768..553a7d3 100644
--- a/src/test/ui/feature-gate-macro-lifetime-matcher.stderr
+++ b/src/test/ui/feature-gate-macro-lifetime-matcher.stderr
@@ -1,4 +1,4 @@
-error: :lifetime fragment specifier is experimental and subject to change (see issue #46895)
+error[E0658]: :lifetime fragment specifier is experimental and subject to change (see issue #46895)
--> $DIR/feature-gate-macro-lifetime-matcher.rs:14:19
|
14 | macro_rules! m { ($lt:lifetime) => {} }
diff --git a/src/test/ui/feature-gate-macro-vis-matcher.stderr b/src/test/ui/feature-gate-macro-vis-matcher.stderr
index 09db500..ee1844c 100644
--- a/src/test/ui/feature-gate-macro-vis-matcher.stderr
+++ b/src/test/ui/feature-gate-macro-vis-matcher.stderr
@@ -1,4 +1,4 @@
-error: :vis fragment specifier is experimental and subject to change (see issue #41022)
+error[E0658]: :vis fragment specifier is experimental and subject to change (see issue #41022)
--> $DIR/feature-gate-macro-vis-matcher.rs:14:19
|
14 | macro_rules! m { ($v:vis) => {} }
diff --git a/src/test/ui/feature-gate-main.stderr b/src/test/ui/feature-gate-main.stderr
index 90cf128..56e9c8b 100644
--- a/src/test/ui/feature-gate-main.stderr
+++ b/src/test/ui/feature-gate-main.stderr
@@ -1,4 +1,4 @@
-error: declaration of a nonstandard #[main] function may change over time, for now a top-level `fn main()` is required (see issue #29634)
+error[E0658]: declaration of a nonstandard #[main] function may change over time, for now a top-level `fn main()` is required (see issue #29634)
--> $DIR/feature-gate-main.rs:12:1
|
12 | fn foo() {} //~ ERROR: declaration of a nonstandard #[main] function may change over time
diff --git a/src/test/ui/feature-gate-match_beginning_vert.stderr b/src/test/ui/feature-gate-match_beginning_vert.stderr
index 88053ad..1d45ded 100644
--- a/src/test/ui/feature-gate-match_beginning_vert.stderr
+++ b/src/test/ui/feature-gate-match_beginning_vert.stderr
@@ -1,4 +1,4 @@
-error: Use of a '|' at the beginning of a match arm is experimental (see issue #44101)
+error[E0658]: Use of a '|' at the beginning of a match arm is experimental (see issue #44101)
--> $DIR/feature-gate-match_beginning_vert.rs:24:9
|
24 | | A => println!("A"),
@@ -6,7 +6,7 @@
|
= help: add #![feature(match_beginning_vert)] to the crate attributes to enable
-error: Use of a '|' at the beginning of a match arm is experimental (see issue #44101)
+error[E0658]: Use of a '|' at the beginning of a match arm is experimental (see issue #44101)
--> $DIR/feature-gate-match_beginning_vert.rs:26:9
|
26 | | B | C => println!("BC!"),
@@ -14,7 +14,7 @@
|
= help: add #![feature(match_beginning_vert)] to the crate attributes to enable
-error: Use of a '|' at the beginning of a match arm is experimental (see issue #44101)
+error[E0658]: Use of a '|' at the beginning of a match arm is experimental (see issue #44101)
--> $DIR/feature-gate-match_beginning_vert.rs:28:9
|
28 | | _ => {},
diff --git a/src/test/ui/feature-gate-match_default_bindings.stderr b/src/test/ui/feature-gate-match_default_bindings.stderr
index d86e824..1bedfb7 100644
--- a/src/test/ui/feature-gate-match_default_bindings.stderr
+++ b/src/test/ui/feature-gate-match_default_bindings.stderr
@@ -1,4 +1,4 @@
-error: non-reference pattern used to match a reference (see issue #42640)
+error[E0658]: non-reference pattern used to match a reference (see issue #42640)
--> $DIR/feature-gate-match_default_bindings.rs:13:9
|
13 | Some(n) => {},
diff --git a/src/test/ui/feature-gate-may-dangle.stderr b/src/test/ui/feature-gate-may-dangle.stderr
index e51723d..a3a3f7b 100644
--- a/src/test/ui/feature-gate-may-dangle.stderr
+++ b/src/test/ui/feature-gate-may-dangle.stderr
@@ -1,4 +1,4 @@
-error: may_dangle has unstable semantics and may be removed in the future (see issue #34761)
+error[E0658]: may_dangle has unstable semantics and may be removed in the future (see issue #34761)
--> $DIR/feature-gate-may-dangle.rs:18:6
|
18 | impl<#[may_dangle] A> Drop for Pt<A> {
diff --git a/src/test/ui/feature-gate-naked_functions.stderr b/src/test/ui/feature-gate-naked_functions.stderr
index 9655982..5f72234 100644
--- a/src/test/ui/feature-gate-naked_functions.stderr
+++ b/src/test/ui/feature-gate-naked_functions.stderr
@@ -1,4 +1,4 @@
-error: the `#[naked]` attribute is an experimental feature (see issue #32408)
+error[E0658]: the `#[naked]` attribute is an experimental feature (see issue #32408)
--> $DIR/feature-gate-naked_functions.rs:11:1
|
11 | #[naked]
@@ -6,7 +6,7 @@
|
= help: add #![feature(naked_functions)] to the crate attributes to enable
-error: the `#[naked]` attribute is an experimental feature (see issue #32408)
+error[E0658]: the `#[naked]` attribute is an experimental feature (see issue #32408)
--> $DIR/feature-gate-naked_functions.rs:15:1
|
15 | #[naked]
diff --git a/src/test/ui/feature-gate-needs-allocator.stderr b/src/test/ui/feature-gate-needs-allocator.stderr
index 5124c10..11b8c31 100644
--- a/src/test/ui/feature-gate-needs-allocator.stderr
+++ b/src/test/ui/feature-gate-needs-allocator.stderr
@@ -1,4 +1,4 @@
-error: the `#[needs_allocator]` attribute is an experimental feature
+error[E0658]: the `#[needs_allocator]` attribute is an experimental feature
--> $DIR/feature-gate-needs-allocator.rs:11:1
|
11 | #![needs_allocator] //~ ERROR the `#[needs_allocator]` attribute is
diff --git a/src/test/ui/feature-gate-never_type.stderr b/src/test/ui/feature-gate-never_type.stderr
index c242e61..2fd04f5 100644
--- a/src/test/ui/feature-gate-never_type.stderr
+++ b/src/test/ui/feature-gate-never_type.stderr
@@ -1,4 +1,4 @@
-error: The `!` type is experimental (see issue #35121)
+error[E0658]: The `!` type is experimental (see issue #35121)
--> $DIR/feature-gate-never_type.rs:17:17
|
17 | type Ma = (u32, !, i32); //~ ERROR type is experimental
@@ -6,7 +6,7 @@
|
= help: add #![feature(never_type)] to the crate attributes to enable
-error: The `!` type is experimental (see issue #35121)
+error[E0658]: The `!` type is experimental (see issue #35121)
--> $DIR/feature-gate-never_type.rs:18:20
|
18 | type Meeshka = Vec<!>; //~ ERROR type is experimental
@@ -14,7 +14,7 @@
|
= help: add #![feature(never_type)] to the crate attributes to enable
-error: The `!` type is experimental (see issue #35121)
+error[E0658]: The `!` type is experimental (see issue #35121)
--> $DIR/feature-gate-never_type.rs:19:16
|
19 | type Mow = &fn(!) -> !; //~ ERROR type is experimental
@@ -22,7 +22,7 @@
|
= help: add #![feature(never_type)] to the crate attributes to enable
-error: The `!` type is experimental (see issue #35121)
+error[E0658]: The `!` type is experimental (see issue #35121)
--> $DIR/feature-gate-never_type.rs:20:19
|
20 | type Skwoz = &mut !; //~ ERROR type is experimental
@@ -30,7 +30,7 @@
|
= help: add #![feature(never_type)] to the crate attributes to enable
-error: The `!` type is experimental (see issue #35121)
+error[E0658]: The `!` type is experimental (see issue #35121)
--> $DIR/feature-gate-never_type.rs:23:16
|
23 | type Wub = !; //~ ERROR type is experimental
diff --git a/src/test/ui/feature-gate-no-debug.stderr b/src/test/ui/feature-gate-no-debug.stderr
index 83a8189..c7af8cf 100644
--- a/src/test/ui/feature-gate-no-debug.stderr
+++ b/src/test/ui/feature-gate-no-debug.stderr
@@ -1,4 +1,4 @@
-error: the `#[no_debug]` attribute was an experimental feature that has been deprecated due to lack of demand (see issue #29721)
+error[E0658]: the `#[no_debug]` attribute was an experimental feature that has been deprecated due to lack of demand (see issue #29721)
--> $DIR/feature-gate-no-debug.rs:13:1
|
13 | #[no_debug] //~ ERROR the `#[no_debug]` attribute was
diff --git a/src/test/ui/feature-gate-no_core.stderr b/src/test/ui/feature-gate-no_core.stderr
index 02e0b17..7fc8985 100644
--- a/src/test/ui/feature-gate-no_core.stderr
+++ b/src/test/ui/feature-gate-no_core.stderr
@@ -1,4 +1,4 @@
-error: no_core is experimental (see issue #29639)
+error[E0658]: no_core is experimental (see issue #29639)
--> $DIR/feature-gate-no_core.rs:11:1
|
11 | #![no_core] //~ ERROR no_core is experimental
diff --git a/src/test/ui/feature-gate-non_ascii_idents.stderr b/src/test/ui/feature-gate-non_ascii_idents.stderr
index 90d0b8d..deb7077 100644
--- a/src/test/ui/feature-gate-non_ascii_idents.stderr
+++ b/src/test/ui/feature-gate-non_ascii_idents.stderr
@@ -1,4 +1,4 @@
-error: non-ascii idents are not fully supported. (see issue #28979)
+error[E0658]: non-ascii idents are not fully supported. (see issue #28979)
--> $DIR/feature-gate-non_ascii_idents.rs:11:1
|
11 | extern crate core as bäz; //~ ERROR non-ascii idents
@@ -6,7 +6,7 @@
|
= help: add #![feature(non_ascii_idents)] to the crate attributes to enable
-error: non-ascii idents are not fully supported. (see issue #28979)
+error[E0658]: non-ascii idents are not fully supported. (see issue #28979)
--> $DIR/feature-gate-non_ascii_idents.rs:13:5
|
13 | use föö::bar; //~ ERROR non-ascii idents
@@ -14,7 +14,7 @@
|
= help: add #![feature(non_ascii_idents)] to the crate attributes to enable
-error: non-ascii idents are not fully supported. (see issue #28979)
+error[E0658]: non-ascii idents are not fully supported. (see issue #28979)
--> $DIR/feature-gate-non_ascii_idents.rs:15:1
|
15 | mod föö { //~ ERROR non-ascii idents
@@ -22,7 +22,7 @@
|
= help: add #![feature(non_ascii_idents)] to the crate attributes to enable
-error: non-ascii idents are not fully supported. (see issue #28979)
+error[E0658]: non-ascii idents are not fully supported. (see issue #28979)
--> $DIR/feature-gate-non_ascii_idents.rs:19:1
|
19 | / fn bär( //~ ERROR non-ascii idents
@@ -36,7 +36,7 @@
|
= help: add #![feature(non_ascii_idents)] to the crate attributes to enable
-error: non-ascii idents are not fully supported. (see issue #28979)
+error[E0658]: non-ascii idents are not fully supported. (see issue #28979)
--> $DIR/feature-gate-non_ascii_idents.rs:20:5
|
20 | bäz: isize //~ ERROR non-ascii idents
@@ -44,7 +44,7 @@
|
= help: add #![feature(non_ascii_idents)] to the crate attributes to enable
-error: non-ascii idents are not fully supported. (see issue #28979)
+error[E0658]: non-ascii idents are not fully supported. (see issue #28979)
--> $DIR/feature-gate-non_ascii_idents.rs:22:9
|
22 | let _ö: isize; //~ ERROR non-ascii idents
@@ -52,7 +52,7 @@
|
= help: add #![feature(non_ascii_idents)] to the crate attributes to enable
-error: non-ascii idents are not fully supported. (see issue #28979)
+error[E0658]: non-ascii idents are not fully supported. (see issue #28979)
--> $DIR/feature-gate-non_ascii_idents.rs:25:10
|
25 | (_ä, _) => {} //~ ERROR non-ascii idents
@@ -60,7 +60,7 @@
|
= help: add #![feature(non_ascii_idents)] to the crate attributes to enable
-error: non-ascii idents are not fully supported. (see issue #28979)
+error[E0658]: non-ascii idents are not fully supported. (see issue #28979)
--> $DIR/feature-gate-non_ascii_idents.rs:29:1
|
29 | struct Föö { //~ ERROR non-ascii idents
@@ -68,7 +68,7 @@
|
= help: add #![feature(non_ascii_idents)] to the crate attributes to enable
-error: non-ascii idents are not fully supported. (see issue #28979)
+error[E0658]: non-ascii idents are not fully supported. (see issue #28979)
--> $DIR/feature-gate-non_ascii_idents.rs:30:5
|
30 | föö: isize //~ ERROR non-ascii idents
@@ -76,7 +76,7 @@
|
= help: add #![feature(non_ascii_idents)] to the crate attributes to enable
-error: non-ascii idents are not fully supported. (see issue #28979)
+error[E0658]: non-ascii idents are not fully supported. (see issue #28979)
--> $DIR/feature-gate-non_ascii_idents.rs:33:1
|
33 | enum Bär { //~ ERROR non-ascii idents
@@ -84,7 +84,7 @@
|
= help: add #![feature(non_ascii_idents)] to the crate attributes to enable
-error: non-ascii idents are not fully supported. (see issue #28979)
+error[E0658]: non-ascii idents are not fully supported. (see issue #28979)
--> $DIR/feature-gate-non_ascii_idents.rs:34:5
|
34 | Bäz { //~ ERROR non-ascii idents
@@ -92,7 +92,7 @@
|
= help: add #![feature(non_ascii_idents)] to the crate attributes to enable
-error: non-ascii idents are not fully supported. (see issue #28979)
+error[E0658]: non-ascii idents are not fully supported. (see issue #28979)
--> $DIR/feature-gate-non_ascii_idents.rs:35:9
|
35 | qüx: isize //~ ERROR non-ascii idents
@@ -100,7 +100,7 @@
|
= help: add #![feature(non_ascii_idents)] to the crate attributes to enable
-error: non-ascii idents are not fully supported. (see issue #28979)
+error[E0658]: non-ascii idents are not fully supported. (see issue #28979)
--> $DIR/feature-gate-non_ascii_idents.rs:40:5
|
40 | fn qüx(); //~ ERROR non-ascii idents
diff --git a/src/test/ui/feature-gate-non_exhaustive.stderr b/src/test/ui/feature-gate-non_exhaustive.stderr
index 775e65b..320f40e 100644
--- a/src/test/ui/feature-gate-non_exhaustive.stderr
+++ b/src/test/ui/feature-gate-non_exhaustive.stderr
@@ -1,4 +1,4 @@
-error: non exhaustive is an experimental feature (see issue #44109)
+error[E0658]: non exhaustive is an experimental feature (see issue #44109)
--> $DIR/feature-gate-non_exhaustive.rs:13:1
|
13 | #[non_exhaustive] //~ERROR non exhaustive is an experimental feature (see issue #44109)
diff --git a/src/test/ui/feature-gate-omit-gdb-pretty-printer-section.stderr b/src/test/ui/feature-gate-omit-gdb-pretty-printer-section.stderr
index e50e1b4..4ceb697 100644
--- a/src/test/ui/feature-gate-omit-gdb-pretty-printer-section.stderr
+++ b/src/test/ui/feature-gate-omit-gdb-pretty-printer-section.stderr
@@ -1,4 +1,4 @@
-error: the `#[omit_gdb_pretty_printer_section]` attribute is just used for the Rust test suite
+error[E0658]: the `#[omit_gdb_pretty_printer_section]` attribute is just used for the Rust test suite
--> $DIR/feature-gate-omit-gdb-pretty-printer-section.rs:11:1
|
11 | #[omit_gdb_pretty_printer_section] //~ ERROR the `#[omit_gdb_pretty_printer_section]` attribute is
diff --git a/src/test/ui/feature-gate-on-unimplemented.stderr b/src/test/ui/feature-gate-on-unimplemented.stderr
index 06944a14..b1658c3 100644
--- a/src/test/ui/feature-gate-on-unimplemented.stderr
+++ b/src/test/ui/feature-gate-on-unimplemented.stderr
@@ -1,4 +1,4 @@
-error: the `#[rustc_on_unimplemented]` attribute is an experimental feature (see issue #29628)
+error[E0658]: the `#[rustc_on_unimplemented]` attribute is an experimental feature (see issue #29628)
--> $DIR/feature-gate-on-unimplemented.rs:14:1
|
14 | #[rustc_on_unimplemented = "test error `{Self}` with `{Bar}`"]
diff --git a/src/test/ui/feature-gate-optin-builtin-traits.stderr b/src/test/ui/feature-gate-optin-builtin-traits.stderr
index d66da12..beb734a 100644
--- a/src/test/ui/feature-gate-optin-builtin-traits.stderr
+++ b/src/test/ui/feature-gate-optin-builtin-traits.stderr
@@ -1,4 +1,4 @@
-error: auto traits are experimental and possibly buggy (see issue #13231)
+error[E0658]: auto traits are experimental and possibly buggy (see issue #13231)
--> $DIR/feature-gate-optin-builtin-traits.rs:20:1
|
20 | auto trait AutoDummyTrait {}
@@ -6,7 +6,7 @@
|
= help: add #![feature(optin_builtin_traits)] to the crate attributes to enable
-error: negative trait bounds are not yet fully implemented; use marker types for now (see issue #13231)
+error[E0658]: negative trait bounds are not yet fully implemented; use marker types for now (see issue #13231)
--> $DIR/feature-gate-optin-builtin-traits.rs:23:1
|
23 | impl !DummyTrait for DummyStruct {}
diff --git a/src/test/ui/feature-gate-placement-expr.stderr b/src/test/ui/feature-gate-placement-expr.stderr
index fdb7b50..c588cab 100644
--- a/src/test/ui/feature-gate-placement-expr.stderr
+++ b/src/test/ui/feature-gate-placement-expr.stderr
@@ -1,4 +1,4 @@
-error: placement-in expression syntax is experimental and subject to change. (see issue #27779)
+error[E0658]: placement-in expression syntax is experimental and subject to change. (see issue #27779)
--> $DIR/feature-gate-placement-expr.rs:24:13
|
24 | let x = HEAP <- 'c'; //~ ERROR placement-in expression syntax is experimental
diff --git a/src/test/ui/feature-gate-plugin.stderr b/src/test/ui/feature-gate-plugin.stderr
index b94d329..b54b2d8 100644
--- a/src/test/ui/feature-gate-plugin.stderr
+++ b/src/test/ui/feature-gate-plugin.stderr
@@ -1,4 +1,4 @@
-error: compiler plugins are experimental and possibly buggy (see issue #29597)
+error[E0658]: compiler plugins are experimental and possibly buggy (see issue #29597)
--> $DIR/feature-gate-plugin.rs:13:1
|
13 | #![plugin(foo)]
diff --git a/src/test/ui/feature-gate-plugin_registrar.stderr b/src/test/ui/feature-gate-plugin_registrar.stderr
index 3710239..fb5bd9d 100644
--- a/src/test/ui/feature-gate-plugin_registrar.stderr
+++ b/src/test/ui/feature-gate-plugin_registrar.stderr
@@ -1,4 +1,4 @@
-error: compiler plugins are experimental and possibly buggy (see issue #29597)
+error[E0658]: compiler plugins are experimental and possibly buggy (see issue #29597)
--> $DIR/feature-gate-plugin_registrar.rs:16:1
|
16 | pub fn registrar() {}
diff --git a/src/test/ui/feature-gate-prelude_import.stderr b/src/test/ui/feature-gate-prelude_import.stderr
index df44dff..5487ae2 100644
--- a/src/test/ui/feature-gate-prelude_import.stderr
+++ b/src/test/ui/feature-gate-prelude_import.stderr
@@ -1,4 +1,4 @@
-error: `#[prelude_import]` is for use by rustc only
+error[E0658]: `#[prelude_import]` is for use by rustc only
--> $DIR/feature-gate-prelude_import.rs:11:1
|
11 | #[prelude_import] //~ ERROR `#[prelude_import]` is for use by rustc only
diff --git a/src/test/ui/feature-gate-profiler-runtime.stderr b/src/test/ui/feature-gate-profiler-runtime.stderr
index c316543..f2893cb 100644
--- a/src/test/ui/feature-gate-profiler-runtime.stderr
+++ b/src/test/ui/feature-gate-profiler-runtime.stderr
@@ -1,4 +1,4 @@
-error: the `#[profiler_runtime]` attribute is used to identify the `profiler_builtins` crate which contains the profiler runtime and will never be stable
+error[E0658]: the `#[profiler_runtime]` attribute is used to identify the `profiler_builtins` crate which contains the profiler runtime and will never be stable
--> $DIR/feature-gate-profiler-runtime.rs:11:1
|
11 | #![profiler_runtime] //~ ERROR the `#[profiler_runtime]` attribute is
diff --git a/src/test/ui/feature-gate-repr-simd.stderr b/src/test/ui/feature-gate-repr-simd.stderr
index a2ff06d..e430a04 100644
--- a/src/test/ui/feature-gate-repr-simd.stderr
+++ b/src/test/ui/feature-gate-repr-simd.stderr
@@ -1,4 +1,4 @@
-error: SIMD types are experimental and possibly buggy (see issue #27731)
+error[E0658]: SIMD types are experimental and possibly buggy (see issue #27731)
--> $DIR/feature-gate-repr-simd.rs:11:1
|
11 | #[repr(simd)] //~ error: SIMD types are experimental
diff --git a/src/test/ui/feature-gate-repr128.stderr b/src/test/ui/feature-gate-repr128.stderr
index c5996488..982ebb0 100644
--- a/src/test/ui/feature-gate-repr128.stderr
+++ b/src/test/ui/feature-gate-repr128.stderr
@@ -1,4 +1,4 @@
-error: repr with 128-bit type is unstable (see issue #35118)
+error[E0658]: repr with 128-bit type is unstable (see issue #35118)
--> $DIR/feature-gate-repr128.rs:12:1
|
12 | / enum A { //~ ERROR repr with 128-bit type is unstable
diff --git a/src/test/ui/feature-gate-repr_align.stderr b/src/test/ui/feature-gate-repr_align.stderr
index 16fdc13..dd88067 100644
--- a/src/test/ui/feature-gate-repr_align.stderr
+++ b/src/test/ui/feature-gate-repr_align.stderr
@@ -1,4 +1,4 @@
-error: the struct `#[repr(align(u16))]` attribute is experimental (see issue #33626)
+error[E0658]: the struct `#[repr(align(u16))]` attribute is experimental (see issue #33626)
--> $DIR/feature-gate-repr_align.rs:12:1
|
12 | #[repr(align(64))] //~ error: the struct `#[repr(align(u16))]` attribute is experimental
diff --git a/src/test/ui/feature-gate-rustc-attrs.stderr b/src/test/ui/feature-gate-rustc-attrs.stderr
index c818b57..f47588c 100644
--- a/src/test/ui/feature-gate-rustc-attrs.stderr
+++ b/src/test/ui/feature-gate-rustc-attrs.stderr
@@ -1,4 +1,4 @@
-error: the `#[rustc_variance]` attribute is just used for rustc unit tests and will never be stable (see issue #29642)
+error[E0658]: the `#[rustc_variance]` attribute is just used for rustc unit tests and will never be stable (see issue #29642)
--> $DIR/feature-gate-rustc-attrs.rs:15:1
|
15 | #[rustc_variance] //~ ERROR the `#[rustc_variance]` attribute is just used for rustc unit tests and will never be stable
@@ -6,7 +6,7 @@
|
= help: add #![feature(rustc_attrs)] to the crate attributes to enable
-error: the `#[rustc_error]` attribute is just used for rustc unit tests and will never be stable (see issue #29642)
+error[E0658]: the `#[rustc_error]` attribute is just used for rustc unit tests and will never be stable (see issue #29642)
--> $DIR/feature-gate-rustc-attrs.rs:16:1
|
16 | #[rustc_error] //~ ERROR the `#[rustc_error]` attribute is just used for rustc unit tests and will never be stable
@@ -14,7 +14,7 @@
|
= help: add #![feature(rustc_attrs)] to the crate attributes to enable
-error: unless otherwise specified, attributes with the prefix `rustc_` are reserved for internal compiler diagnostics (see issue #29642)
+error[E0658]: unless otherwise specified, attributes with the prefix `rustc_` are reserved for internal compiler diagnostics (see issue #29642)
--> $DIR/feature-gate-rustc-attrs.rs:17:1
|
17 | #[rustc_foo]
diff --git a/src/test/ui/feature-gate-rustc_const_unstable.stderr b/src/test/ui/feature-gate-rustc_const_unstable.stderr
index c32abb8..922898b 100644
--- a/src/test/ui/feature-gate-rustc_const_unstable.stderr
+++ b/src/test/ui/feature-gate-rustc_const_unstable.stderr
@@ -1,4 +1,4 @@
-error: the `#[rustc_const_unstable]` attribute is an internal feature
+error[E0658]: the `#[rustc_const_unstable]` attribute is an internal feature
--> $DIR/feature-gate-rustc_const_unstable.rs:18:1
|
18 | #[rustc_const_unstable(feature="fzzzzzt")] //~ERROR internal feature
diff --git a/src/test/ui/feature-gate-sanitizer-runtime.stderr b/src/test/ui/feature-gate-sanitizer-runtime.stderr
index b9a43f8..6d77161 100644
--- a/src/test/ui/feature-gate-sanitizer-runtime.stderr
+++ b/src/test/ui/feature-gate-sanitizer-runtime.stderr
@@ -1,4 +1,4 @@
-error: the `#[sanitizer_runtime]` attribute is used to identify crates that contain the runtime of a sanitizer and will never be stable
+error[E0658]: the `#[sanitizer_runtime]` attribute is used to identify crates that contain the runtime of a sanitizer and will never be stable
--> $DIR/feature-gate-sanitizer-runtime.rs:11:1
|
11 | #![sanitizer_runtime] //~ ERROR the `#[sanitizer_runtime]` attribute is
diff --git a/src/test/ui/feature-gate-simd.stderr b/src/test/ui/feature-gate-simd.stderr
index b3225d5..447706a 100644
--- a/src/test/ui/feature-gate-simd.stderr
+++ b/src/test/ui/feature-gate-simd.stderr
@@ -1,4 +1,4 @@
-error: SIMD types are experimental and possibly buggy (see issue #27731)
+error[E0658]: SIMD types are experimental and possibly buggy (see issue #27731)
--> $DIR/feature-gate-simd.rs:14:1
|
14 | #[repr(simd)] //~ ERROR SIMD types are experimental
diff --git a/src/test/ui/feature-gate-slice-patterns.stderr b/src/test/ui/feature-gate-slice-patterns.stderr
index e5ba318b..7a2e67c 100644
--- a/src/test/ui/feature-gate-slice-patterns.stderr
+++ b/src/test/ui/feature-gate-slice-patterns.stderr
@@ -1,4 +1,4 @@
-error: slice pattern syntax is experimental (see issue #23121)
+error[E0658]: slice pattern syntax is experimental (see issue #23121)
--> $DIR/feature-gate-slice-patterns.rs:16:9
|
16 | [1, 2, xs..] => {} //~ ERROR slice pattern syntax is experimental
diff --git a/src/test/ui/feature-gate-start.stderr b/src/test/ui/feature-gate-start.stderr
index b36fae2..61cbe42 100644
--- a/src/test/ui/feature-gate-start.stderr
+++ b/src/test/ui/feature-gate-start.stderr
@@ -1,4 +1,4 @@
-error: a #[start] function is an experimental feature whose signature may change over time (see issue #29633)
+error[E0658]: a #[start] function is an experimental feature whose signature may change over time (see issue #29633)
--> $DIR/feature-gate-start.rs:12:1
|
12 | fn foo() {} //~ ERROR: a #[start] function is an experimental feature
diff --git a/src/test/ui/feature-gate-static-nobundle.stderr b/src/test/ui/feature-gate-static-nobundle.stderr
index 052516f..9ec4f64 100644
--- a/src/test/ui/feature-gate-static-nobundle.stderr
+++ b/src/test/ui/feature-gate-static-nobundle.stderr
@@ -1,4 +1,4 @@
-error: kind="static-nobundle" is feature gated (see issue #37403)
+error[E0658]: kind="static-nobundle" is feature gated (see issue #37403)
--> $DIR/feature-gate-static-nobundle.rs:11:1
|
11 | #[link(name="foo", kind="static-nobundle")]
diff --git a/src/test/ui/feature-gate-stmt_expr_attributes.stderr b/src/test/ui/feature-gate-stmt_expr_attributes.stderr
index 8091059..4d2e2f6 100644
--- a/src/test/ui/feature-gate-stmt_expr_attributes.stderr
+++ b/src/test/ui/feature-gate-stmt_expr_attributes.stderr
@@ -1,4 +1,4 @@
-error: attributes on non-item statements and expressions are experimental. (see issue #15701)
+error[E0658]: attributes on non-item statements and expressions are experimental. (see issue #15701)
--> $DIR/feature-gate-stmt_expr_attributes.rs:11:16
|
11 | const X: i32 = #[allow(dead_code)] 8;
diff --git a/src/test/ui/feature-gate-target_feature.stderr b/src/test/ui/feature-gate-target_feature.stderr
index 8c89eab..b6ad1b6 100644
--- a/src/test/ui/feature-gate-target_feature.stderr
+++ b/src/test/ui/feature-gate-target_feature.stderr
@@ -1,4 +1,4 @@
-error: the `#[target_feature]` attribute is an experimental feature
+error[E0658]: the `#[target_feature]` attribute is an experimental feature
--> $DIR/feature-gate-target_feature.rs:11:1
|
11 | #[target_feature = "+sse2"]
diff --git a/src/test/ui/feature-gate-thread_local.stderr b/src/test/ui/feature-gate-thread_local.stderr
index 2608018..0f932ab 100644
--- a/src/test/ui/feature-gate-thread_local.stderr
+++ b/src/test/ui/feature-gate-thread_local.stderr
@@ -1,4 +1,4 @@
-error: `#[thread_local]` is an experimental feature, and does not currently handle destructors. There is no corresponding `#[task_local]` mapping to the task model (see issue #29594)
+error[E0658]: `#[thread_local]` is an experimental feature, and does not currently handle destructors. There is no corresponding `#[task_local]` mapping to the task model (see issue #29594)
--> $DIR/feature-gate-thread_local.rs:18:1
|
18 | #[thread_local] //~ ERROR `#[thread_local]` is an experimental feature
diff --git a/src/test/ui/feature-gate-trace_macros.stderr b/src/test/ui/feature-gate-trace_macros.stderr
index aca7409..eae3baa 100644
--- a/src/test/ui/feature-gate-trace_macros.stderr
+++ b/src/test/ui/feature-gate-trace_macros.stderr
@@ -1,4 +1,4 @@
-error: `trace_macros` is not stable enough for use and is subject to change (see issue #29598)
+error[E0658]: `trace_macros` is not stable enough for use and is subject to change (see issue #29598)
--> $DIR/feature-gate-trace_macros.rs:12:5
|
12 | trace_macros!(true); //~ ERROR: `trace_macros` is not stable
diff --git a/src/test/ui/feature-gate-type_ascription.stderr b/src/test/ui/feature-gate-type_ascription.stderr
index d2a3ee2..fa6ef84 100644
--- a/src/test/ui/feature-gate-type_ascription.stderr
+++ b/src/test/ui/feature-gate-type_ascription.stderr
@@ -1,4 +1,4 @@
-error: type ascription is experimental (see issue #23416)
+error[E0658]: type ascription is experimental (see issue #23416)
--> $DIR/feature-gate-type_ascription.rs:14:13
|
14 | let a = 10: u8; //~ ERROR type ascription is experimental
diff --git a/src/test/ui/feature-gate-unboxed-closures-manual-impls.stderr b/src/test/ui/feature-gate-unboxed-closures-manual-impls.stderr
index 280fc12..ae14054 100644
--- a/src/test/ui/feature-gate-unboxed-closures-manual-impls.stderr
+++ b/src/test/ui/feature-gate-unboxed-closures-manual-impls.stderr
@@ -1,4 +1,4 @@
-error: rust-call ABI is subject to change (see issue #29625)
+error[E0658]: rust-call ABI is subject to change (see issue #29625)
--> $DIR/feature-gate-unboxed-closures-manual-impls.rs:20:5
|
20 | extern "rust-call" fn call(self, args: ()) -> () {}
@@ -6,7 +6,7 @@
|
= help: add #![feature(unboxed_closures)] to the crate attributes to enable
-error: rust-call ABI is subject to change (see issue #29625)
+error[E0658]: rust-call ABI is subject to change (see issue #29625)
--> $DIR/feature-gate-unboxed-closures-manual-impls.rs:25:5
|
25 | extern "rust-call" fn call_once(self, args: ()) -> () {}
@@ -14,7 +14,7 @@
|
= help: add #![feature(unboxed_closures)] to the crate attributes to enable
-error: rust-call ABI is subject to change (see issue #29625)
+error[E0658]: rust-call ABI is subject to change (see issue #29625)
--> $DIR/feature-gate-unboxed-closures-manual-impls.rs:30:5
|
30 | extern "rust-call" fn call_mut(&self, args: ()) -> () {}
@@ -22,7 +22,7 @@
|
= help: add #![feature(unboxed_closures)] to the crate attributes to enable
-error: rust-call ABI is subject to change (see issue #29625)
+error[E0658]: rust-call ABI is subject to change (see issue #29625)
--> $DIR/feature-gate-unboxed-closures-manual-impls.rs:35:5
|
35 | extern "rust-call" fn call_once(&self, args: ()) -> () {}
diff --git a/src/test/ui/feature-gate-unboxed-closures-method-calls.stderr b/src/test/ui/feature-gate-unboxed-closures-method-calls.stderr
index 1167bf0..a27b00a 100644
--- a/src/test/ui/feature-gate-unboxed-closures-method-calls.stderr
+++ b/src/test/ui/feature-gate-unboxed-closures-method-calls.stderr
@@ -1,4 +1,4 @@
-error: use of unstable library feature 'fn_traits' (see issue #29625)
+error[E0658]: use of unstable library feature 'fn_traits' (see issue #29625)
--> $DIR/feature-gate-unboxed-closures-method-calls.rs:14:7
|
14 | f.call(()); //~ ERROR use of unstable library feature 'fn_traits'
@@ -6,7 +6,7 @@
|
= help: add #![feature(fn_traits)] to the crate attributes to enable
-error: use of unstable library feature 'fn_traits' (see issue #29625)
+error[E0658]: use of unstable library feature 'fn_traits' (see issue #29625)
--> $DIR/feature-gate-unboxed-closures-method-calls.rs:15:7
|
15 | f.call_mut(()); //~ ERROR use of unstable library feature 'fn_traits'
@@ -14,7 +14,7 @@
|
= help: add #![feature(fn_traits)] to the crate attributes to enable
-error: use of unstable library feature 'fn_traits' (see issue #29625)
+error[E0658]: use of unstable library feature 'fn_traits' (see issue #29625)
--> $DIR/feature-gate-unboxed-closures-method-calls.rs:16:7
|
16 | f.call_once(()); //~ ERROR use of unstable library feature 'fn_traits'
diff --git a/src/test/ui/feature-gate-unboxed-closures-ufcs-calls.stderr b/src/test/ui/feature-gate-unboxed-closures-ufcs-calls.stderr
index 7eb491c..3d0dd15 100644
--- a/src/test/ui/feature-gate-unboxed-closures-ufcs-calls.stderr
+++ b/src/test/ui/feature-gate-unboxed-closures-ufcs-calls.stderr
@@ -1,4 +1,4 @@
-error: use of unstable library feature 'fn_traits' (see issue #29625)
+error[E0658]: use of unstable library feature 'fn_traits' (see issue #29625)
--> $DIR/feature-gate-unboxed-closures-ufcs-calls.rs:14:5
|
14 | Fn::call(&f, ()); //~ ERROR use of unstable library feature 'fn_traits'
@@ -6,7 +6,7 @@
|
= help: add #![feature(fn_traits)] to the crate attributes to enable
-error: use of unstable library feature 'fn_traits' (see issue #29625)
+error[E0658]: use of unstable library feature 'fn_traits' (see issue #29625)
--> $DIR/feature-gate-unboxed-closures-ufcs-calls.rs:15:5
|
15 | FnMut::call_mut(&mut f, ()); //~ ERROR use of unstable library feature 'fn_traits'
@@ -14,7 +14,7 @@
|
= help: add #![feature(fn_traits)] to the crate attributes to enable
-error: use of unstable library feature 'fn_traits' (see issue #29625)
+error[E0658]: use of unstable library feature 'fn_traits' (see issue #29625)
--> $DIR/feature-gate-unboxed-closures-ufcs-calls.rs:16:5
|
16 | FnOnce::call_once(f, ()); //~ ERROR use of unstable library feature 'fn_traits'
diff --git a/src/test/ui/feature-gate-unboxed-closures.stderr b/src/test/ui/feature-gate-unboxed-closures.stderr
index b791651..ca8a592 100644
--- a/src/test/ui/feature-gate-unboxed-closures.stderr
+++ b/src/test/ui/feature-gate-unboxed-closures.stderr
@@ -1,4 +1,4 @@
-error: rust-call ABI is subject to change (see issue #29625)
+error[E0658]: rust-call ABI is subject to change (see issue #29625)
--> $DIR/feature-gate-unboxed-closures.rs:16:5
|
16 | / extern "rust-call" fn call_once(self, (a, b): (u32, u32)) -> u32 {
diff --git a/src/test/ui/feature-gate-underscore-lifetimes.stderr b/src/test/ui/feature-gate-underscore-lifetimes.stderr
index 875b958..07c5e1a 100644
--- a/src/test/ui/feature-gate-underscore-lifetimes.stderr
+++ b/src/test/ui/feature-gate-underscore-lifetimes.stderr
@@ -1,4 +1,4 @@
-error: underscore lifetimes are unstable (see issue #44524)
+error[E0658]: underscore lifetimes are unstable (see issue #44524)
--> $DIR/feature-gate-underscore-lifetimes.rs:13:23
|
13 | fn foo(x: &u8) -> Foo<'_> { //~ ERROR underscore lifetimes are unstable
diff --git a/src/test/ui/feature-gate-universal.stderr b/src/test/ui/feature-gate-universal.stderr
index 7f889f9..978ce59 100644
--- a/src/test/ui/feature-gate-universal.stderr
+++ b/src/test/ui/feature-gate-universal.stderr
@@ -1,4 +1,4 @@
-error: `impl Trait` in argument position is experimental (see issue #34511)
+error[E0658]: `impl Trait` in argument position is experimental (see issue #34511)
--> $DIR/feature-gate-universal.rs:13:11
|
13 | fn foo(x: impl std::fmt::Debug) { print!("{:?}", x); }
diff --git a/src/test/ui/feature-gate-unsized_tuple_coercion.stderr b/src/test/ui/feature-gate-unsized_tuple_coercion.stderr
index f166b10..4714df9 100644
--- a/src/test/ui/feature-gate-unsized_tuple_coercion.stderr
+++ b/src/test/ui/feature-gate-unsized_tuple_coercion.stderr
@@ -1,4 +1,4 @@
-error: Unsized tuple coercion is not stable enough for use and is subject to change (see issue #42877)
+error[E0658]: Unsized tuple coercion is not stable enough for use and is subject to change (see issue #42877)
--> $DIR/feature-gate-unsized_tuple_coercion.rs:12:24
|
12 | let _ : &(Send,) = &((),);
diff --git a/src/test/ui/feature-gate-untagged_unions.stderr b/src/test/ui/feature-gate-untagged_unions.stderr
index 26b6989..14b66cb 100644
--- a/src/test/ui/feature-gate-untagged_unions.stderr
+++ b/src/test/ui/feature-gate-untagged_unions.stderr
@@ -1,4 +1,4 @@
-error: unions with non-`Copy` fields are unstable (see issue #32836)
+error[E0658]: unions with non-`Copy` fields are unstable (see issue #32836)
--> $DIR/feature-gate-untagged_unions.rs:19:1
|
19 | / union U3 { //~ ERROR unions with non-`Copy` fields are unstable
@@ -8,7 +8,7 @@
|
= help: add #![feature(untagged_unions)] to the crate attributes to enable
-error: unions with non-`Copy` fields are unstable (see issue #32836)
+error[E0658]: unions with non-`Copy` fields are unstable (see issue #32836)
--> $DIR/feature-gate-untagged_unions.rs:23:1
|
23 | / union U4<T> { //~ ERROR unions with non-`Copy` fields are unstable
@@ -18,7 +18,7 @@
|
= help: add #![feature(untagged_unions)] to the crate attributes to enable
-error: unions with `Drop` implementations are unstable (see issue #32836)
+error[E0658]: unions with `Drop` implementations are unstable (see issue #32836)
--> $DIR/feature-gate-untagged_unions.rs:27:1
|
27 | / union U5 { //~ ERROR unions with `Drop` implementations are unstable
diff --git a/src/test/ui/feature-gate-unwind-attributes.stderr b/src/test/ui/feature-gate-unwind-attributes.stderr
index 02d8bf9..d9b555e 100644
--- a/src/test/ui/feature-gate-unwind-attributes.stderr
+++ b/src/test/ui/feature-gate-unwind-attributes.stderr
@@ -1,4 +1,4 @@
-error: #[unwind] is experimental
+error[E0658]: #[unwind] is experimental
--> $DIR/feature-gate-unwind-attributes.rs:21:5
|
21 | #[unwind] //~ ERROR #[unwind] is experimental
diff --git a/src/test/ui/feature-gate-use_nested_groups.stderr b/src/test/ui/feature-gate-use_nested_groups.stderr
index 79f1d1a..6ae691c 100644
--- a/src/test/ui/feature-gate-use_nested_groups.stderr
+++ b/src/test/ui/feature-gate-use_nested_groups.stderr
@@ -1,4 +1,4 @@
-error: nested groups in `use` are experimental (see issue #44494)
+error[E0658]: nested groups in `use` are experimental (see issue #44494)
--> $DIR/feature-gate-use_nested_groups.rs:27:12
|
27 | use a::{B, d::{*, g::H}}; //~ ERROR glob imports in `use` groups are experimental
@@ -6,7 +6,7 @@
|
= help: add #![feature(use_nested_groups)] to the crate attributes to enable
-error: glob imports in `use` groups are experimental (see issue #44494)
+error[E0658]: glob imports in `use` groups are experimental (see issue #44494)
--> $DIR/feature-gate-use_nested_groups.rs:27:16
|
27 | use a::{B, d::{*, g::H}}; //~ ERROR glob imports in `use` groups are experimental
@@ -14,7 +14,7 @@
|
= help: add #![feature(use_nested_groups)] to the crate attributes to enable
-error: paths in `use` groups are experimental (see issue #44494)
+error[E0658]: paths in `use` groups are experimental (see issue #44494)
--> $DIR/feature-gate-use_nested_groups.rs:27:19
|
27 | use a::{B, d::{*, g::H}}; //~ ERROR glob imports in `use` groups are experimental
diff --git a/src/test/ui/feature-gate-used.stderr b/src/test/ui/feature-gate-used.stderr
index 228cf12..6d5ab1f 100644
--- a/src/test/ui/feature-gate-used.stderr
+++ b/src/test/ui/feature-gate-used.stderr
@@ -1,4 +1,4 @@
-error: the `#[used]` attribute is an experimental feature (see issue #40289)
+error[E0658]: the `#[used]` attribute is an experimental feature (see issue #40289)
--> $DIR/feature-gate-used.rs:11:1
|
11 | #[used]
diff --git a/src/test/ui/feature-gate-wasm_import_memory.stderr b/src/test/ui/feature-gate-wasm_import_memory.stderr
index c0486d0..10190ef 100644
--- a/src/test/ui/feature-gate-wasm_import_memory.stderr
+++ b/src/test/ui/feature-gate-wasm_import_memory.stderr
@@ -1,4 +1,4 @@
-error: wasm_import_memory attribute is currently unstable
+error[E0658]: wasm_import_memory attribute is currently unstable
--> $DIR/feature-gate-wasm_import_memory.rs:11:1
|
11 | #![wasm_import_memory] //~ ERROR: currently unstable
diff --git a/src/test/ui/issue-46983.rs b/src/test/ui/issue-46983.rs
new file mode 100644
index 0000000..ebbd474
--- /dev/null
+++ b/src/test/ui/issue-46983.rs
@@ -0,0 +1,18 @@
+// Copyright 2017 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(nll)]
+
+fn foo(x: &u32) -> &'static u32 {
+ &*x
+ //~^ ERROR explicit lifetime required in the type of `x` [E0621]
+}
+
+fn main() {}
diff --git a/src/test/ui/issue-46983.stderr b/src/test/ui/issue-46983.stderr
new file mode 100644
index 0000000..ac8417a
--- /dev/null
+++ b/src/test/ui/issue-46983.stderr
@@ -0,0 +1,10 @@
+error[E0621]: explicit lifetime required in the type of `x`
+ --> $DIR/issue-46983.rs:14:5
+ |
+13 | fn foo(x: &u32) -> &'static u32 {
+ | - consider changing the type of `x` to `&'static u32`
+14 | &*x
+ | ^^^ lifetime `'static` required
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/nll/borrowed-referent-issue-38899.rs b/src/test/ui/nll/borrowed-referent-issue-38899.rs
new file mode 100644
index 0000000..d7c1585
--- /dev/null
+++ b/src/test/ui/nll/borrowed-referent-issue-38899.rs
@@ -0,0 +1,30 @@
+// Copyright 2018 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Regression test for issue #38899
+
+#![feature(nll)]
+#![allow(dead_code)]
+
+pub struct Block<'a> {
+ current: &'a u8,
+ unrelated: &'a u8,
+}
+
+fn bump<'a>(mut block: &mut Block<'a>) {
+ let x = &mut block;
+ println!("{}", x.current);
+ let p: &'a u8 = &*block.current;
+ //~^ ERROR cannot borrow `*block.current` as immutable because it is also borrowed as mutable
+ drop(x);
+ drop(p);
+}
+
+fn main() {}
diff --git a/src/test/ui/nll/borrowed-referent-issue-38899.stderr b/src/test/ui/nll/borrowed-referent-issue-38899.stderr
new file mode 100644
index 0000000..3031fec
--- /dev/null
+++ b/src/test/ui/nll/borrowed-referent-issue-38899.stderr
@@ -0,0 +1,11 @@
+error[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable
+ --> $DIR/borrowed-referent-issue-38899.rs:24:21
+ |
+22 | let x = &mut block;
+ | ---------- mutable borrow occurs here
+23 | println!("{}", x.current);
+24 | let p: &'a u8 = &*block.current;
+ | ^^^^^^^^^^^^^^^ immutable borrow occurs here
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/nll/closure-requirements/region-lbr-anon-does-not-outlive-static.rs b/src/test/ui/nll/closure-requirements/region-lbr-anon-does-not-outlive-static.rs
index 3f56dfe..ac21fe2 100644
--- a/src/test/ui/nll/closure-requirements/region-lbr-anon-does-not-outlive-static.rs
+++ b/src/test/ui/nll/closure-requirements/region-lbr-anon-does-not-outlive-static.rs
@@ -18,7 +18,7 @@
fn foo(x: &u32) -> &'static u32 {
&*x
//~^ WARN not reporting region error due to -Znll
- //~| ERROR does not outlive free region
+ //~| ERROR explicit lifetime required in the type of `x`
}
fn main() { }
diff --git a/src/test/ui/nll/closure-requirements/region-lbr-anon-does-not-outlive-static.stderr b/src/test/ui/nll/closure-requirements/region-lbr-anon-does-not-outlive-static.stderr
index 6648e38..2a1122c 100644
--- a/src/test/ui/nll/closure-requirements/region-lbr-anon-does-not-outlive-static.stderr
+++ b/src/test/ui/nll/closure-requirements/region-lbr-anon-does-not-outlive-static.stderr
@@ -4,11 +4,13 @@
19 | &*x
| ^^^
-error: free region `ReFree(DefId(0/0:3 ~ region_lbr_anon_does_not_outlive_static[317d]::foo[0]), BrAnon(0))` does not outlive free region `ReStatic`
+error[E0621]: explicit lifetime required in the type of `x`
--> $DIR/region-lbr-anon-does-not-outlive-static.rs:19:5
|
+18 | fn foo(x: &u32) -> &'static u32 {
+ | - consider changing the type of `x` to `&ReStatic u32`
19 | &*x
- | ^^^
+ | ^^^ lifetime `ReStatic` required
error: aborting due to previous error
diff --git a/src/test/ui/nll/guarantor-issue-46974.rs b/src/test/ui/nll/guarantor-issue-46974.rs
index 57ecddb..09ce42ce 100644
--- a/src/test/ui/nll/guarantor-issue-46974.rs
+++ b/src/test/ui/nll/guarantor-issue-46974.rs
@@ -22,7 +22,7 @@
fn bar(s: &Box<(i32,)>) -> &'static i32 {
// FIXME(#46983): error message should be better
- &s.0 //~ ERROR free region `` does not outlive free region `'static`
+ &s.0 //~ ERROR explicit lifetime required in the type of `s` [E0621]
}
fn main() {
diff --git a/src/test/ui/nll/guarantor-issue-46974.stderr b/src/test/ui/nll/guarantor-issue-46974.stderr
index 68cc87e..4f0bd88 100644
--- a/src/test/ui/nll/guarantor-issue-46974.stderr
+++ b/src/test/ui/nll/guarantor-issue-46974.stderr
@@ -7,11 +7,14 @@
19 | *s = (2,); //~ ERROR cannot assign to `*s`
| ^^^^^^^^^ assignment to borrowed `*s` occurs here
-error: free region `` does not outlive free region `'static`
+error[E0621]: explicit lifetime required in the type of `s`
--> $DIR/guarantor-issue-46974.rs:25:5
|
-25 | &s.0 //~ ERROR free region `` does not outlive free region `'static`
- | ^^^^
+23 | fn bar(s: &Box<(i32,)>) -> &'static i32 {
+ | - consider changing the type of `s` to `&'static std::boxed::Box<(i32,)>`
+24 | // FIXME(#46983): error message should be better
+25 | &s.0 //~ ERROR explicit lifetime required in the type of `s` [E0621]
+ | ^^^^ lifetime `'static` required
error: aborting due to 2 previous errors
diff --git a/src/test/ui/nll/issue-47022.rs b/src/test/ui/nll/issue-47022.rs
new file mode 100644
index 0000000..a7362c3
--- /dev/null
+++ b/src/test/ui/nll/issue-47022.rs
@@ -0,0 +1,47 @@
+// Copyright 2017 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// must-compile-successfully
+
+#![allow(warnings)]
+#![feature(nll)]
+
+struct LoadedObject {
+ bodies: Vec<Body>,
+ color: Color,
+}
+
+struct Body;
+
+#[derive(Clone)]
+struct Color;
+
+struct Graphic {
+ color: Color,
+}
+
+fn convert(objects: Vec<LoadedObject>) -> (Vec<Body>, Vec<Graphic>) {
+ objects
+ .into_iter()
+ .flat_map(|LoadedObject { bodies, color, .. }| {
+ bodies.into_iter().map(move |body| {
+ (
+ body,
+ Graphic {
+ color: color.clone(),
+ },
+ )
+ })
+ })
+ .unzip()
+}
+
+fn main() {}
+
diff --git a/src/test/ui/nll/return-ref-mut-issue-46557.rs b/src/test/ui/nll/return-ref-mut-issue-46557.rs
new file mode 100644
index 0000000..79150f3
--- /dev/null
+++ b/src/test/ui/nll/return-ref-mut-issue-46557.rs
@@ -0,0 +1,21 @@
+// Copyright 2018 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Regression test for issue #46557
+
+#![feature(nll)]
+#![allow(dead_code)]
+
+fn gimme_static_mut() -> &'static mut u32 {
+ let ref mut x = 1234543; //~ ERROR borrowed value does not live long enough [E0597]
+ x
+}
+
+fn main() {}
diff --git a/src/test/ui/nll/return-ref-mut-issue-46557.stderr b/src/test/ui/nll/return-ref-mut-issue-46557.stderr
new file mode 100644
index 0000000..763e2bf
--- /dev/null
+++ b/src/test/ui/nll/return-ref-mut-issue-46557.stderr
@@ -0,0 +1,13 @@
+error[E0597]: borrowed value does not live long enough
+ --> $DIR/return-ref-mut-issue-46557.rs:17:21
+ |
+17 | let ref mut x = 1234543; //~ ERROR borrowed value does not live long enough [E0597]
+ | ^^^^^^^ temporary value does not live long enough
+18 | x
+19 | }
+ | - temporary value only lives until here
+ |
+ = note: borrowed value must be valid for lifetime '_#2r...
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/non_modrs_mods/non_modrs_mods.stderr b/src/test/ui/non_modrs_mods/non_modrs_mods.stderr
index 95a2539..f60d2e9 100644
--- a/src/test/ui/non_modrs_mods/non_modrs_mods.stderr
+++ b/src/test/ui/non_modrs_mods/non_modrs_mods.stderr
@@ -1,4 +1,4 @@
-error: mod statements in non-mod.rs files are unstable (see issue #44660)
+error[E0658]: mod statements in non-mod.rs files are unstable (see issue #44660)
--> $DIR/modrs_mod/inner_foors_mod.rs:11:9
|
11 | pub mod innest;
@@ -7,7 +7,7 @@
= help: add #![feature(non_modrs_mods)] to the crate attributes to enable
= help: on stable builds, rename this file to inner_foors_mod/mod.rs
-error: mod statements in non-mod.rs files are unstable (see issue #44660)
+error[E0658]: mod statements in non-mod.rs files are unstable (see issue #44660)
--> $DIR/foors_mod.rs:13:9
|
13 | pub mod inner_modrs_mod;
@@ -16,7 +16,7 @@
= help: add #![feature(non_modrs_mods)] to the crate attributes to enable
= help: on stable builds, rename this file to foors_mod/mod.rs
-error: mod statements in non-mod.rs files are unstable (see issue #44660)
+error[E0658]: mod statements in non-mod.rs files are unstable (see issue #44660)
--> $DIR/foors_mod.rs:14:9
|
14 | pub mod inner_foors_mod;
@@ -25,7 +25,7 @@
= help: add #![feature(non_modrs_mods)] to the crate attributes to enable
= help: on stable builds, rename this file to foors_mod/mod.rs
-error: mod statements in non-mod.rs files are unstable (see issue #44660)
+error[E0658]: mod statements in non-mod.rs files are unstable (see issue #44660)
--> $DIR/foors_mod/inner_foors_mod.rs:11:9
|
11 | pub mod innest;
diff --git a/src/test/ui/pat-slice-old-style.stderr b/src/test/ui/pat-slice-old-style.stderr
index 5e7cd10..29c41c4 100644
--- a/src/test/ui/pat-slice-old-style.stderr
+++ b/src/test/ui/pat-slice-old-style.stderr
@@ -1,4 +1,4 @@
-error: non-reference pattern used to match a reference (see issue #42640)
+error[E0658]: non-reference pattern used to match a reference (see issue #42640)
--> $DIR/pat-slice-old-style.rs:19:9
|
19 | [a, b..] => {},
diff --git a/src/test/ui/rfc-2005-default-binding-mode/suggestion.stderr b/src/test/ui/rfc-2005-default-binding-mode/suggestion.stderr
index ebf9e49..8aa17ad 100644
--- a/src/test/ui/rfc-2005-default-binding-mode/suggestion.stderr
+++ b/src/test/ui/rfc-2005-default-binding-mode/suggestion.stderr
@@ -1,4 +1,4 @@
-error: non-reference pattern used to match a reference (see issue #42640)
+error[E0658]: non-reference pattern used to match a reference (see issue #42640)
--> $DIR/suggestion.rs:12:12
|
12 | if let Some(y) = &Some(22) { //~ ERROR non-reference pattern
diff --git a/src/test/ui/span/gated-features-attr-spans.stderr b/src/test/ui/span/gated-features-attr-spans.stderr
index d067470..74a2c1d 100644
--- a/src/test/ui/span/gated-features-attr-spans.stderr
+++ b/src/test/ui/span/gated-features-attr-spans.stderr
@@ -1,4 +1,4 @@
-error: the struct `#[repr(align(u16))]` attribute is experimental (see issue #33626)
+error[E0658]: the struct `#[repr(align(u16))]` attribute is experimental (see issue #33626)
--> $DIR/gated-features-attr-spans.rs:13:1
|
13 | #[repr(align(16))] //~ ERROR is experimental
@@ -6,7 +6,7 @@
|
= help: add #![feature(repr_align)] to the crate attributes to enable
-error: SIMD types are experimental and possibly buggy (see issue #27731)
+error[E0658]: SIMD types are experimental and possibly buggy (see issue #27731)
--> $DIR/gated-features-attr-spans.rs:20:1
|
20 | #[repr(simd)] //~ ERROR are experimental
diff --git a/src/test/ui/span/impl-parsing.rs b/src/test/ui/span/impl-parsing.rs
new file mode 100644
index 0000000..064e3c3
--- /dev/null
+++ b/src/test/ui/span/impl-parsing.rs
@@ -0,0 +1,21 @@
+// Copyright 2017 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// compile-flags: -Z parse-only -Z continue-parse-after-error
+
+impl ! {} // OK
+impl ! where u8: Copy {} // OK
+
+impl Trait Type {} //~ ERROR missing `for` in a trait impl
+impl Trait .. {} //~ ERROR missing `for` in a trait impl
+impl ?Sized for Type {} //~ ERROR expected a trait, found type
+impl ?Sized for .. {} //~ ERROR expected a trait, found type
+
+default unsafe FAIL //~ ERROR expected `impl`, found `FAIL`
diff --git a/src/test/ui/span/impl-parsing.stderr b/src/test/ui/span/impl-parsing.stderr
new file mode 100644
index 0000000..9126384
--- /dev/null
+++ b/src/test/ui/span/impl-parsing.stderr
@@ -0,0 +1,32 @@
+error: missing `for` in a trait impl
+ --> $DIR/impl-parsing.rs:16:11
+ |
+16 | impl Trait Type {} //~ ERROR missing `for` in a trait impl
+ | ^
+
+error: missing `for` in a trait impl
+ --> $DIR/impl-parsing.rs:17:11
+ |
+17 | impl Trait .. {} //~ ERROR missing `for` in a trait impl
+ | ^
+
+error: expected a trait, found type
+ --> $DIR/impl-parsing.rs:18:6
+ |
+18 | impl ?Sized for Type {} //~ ERROR expected a trait, found type
+ | ^^^^^^
+
+error: expected a trait, found type
+ --> $DIR/impl-parsing.rs:19:6
+ |
+19 | impl ?Sized for .. {} //~ ERROR expected a trait, found type
+ | ^^^^^^
+
+error: expected `impl`, found `FAIL`
+ --> $DIR/impl-parsing.rs:21:16
+ |
+21 | default unsafe FAIL //~ ERROR expected `impl`, found `FAIL`
+ | ^^^^ expected `impl` here
+
+error: aborting due to 5 previous errors
+
diff --git a/src/test/ui/span/issue-36530.stderr b/src/test/ui/span/issue-36530.stderr
index 50908b2..7f39210 100644
--- a/src/test/ui/span/issue-36530.stderr
+++ b/src/test/ui/span/issue-36530.stderr
@@ -1,4 +1,4 @@
-error: The attribute `foo` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
+error[E0658]: The attribute `foo` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> $DIR/issue-36530.rs:11:1
|
11 | #[foo] //~ ERROR is currently unknown to the compiler
@@ -6,7 +6,7 @@
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable
-error: The attribute `foo` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
+error[E0658]: The attribute `foo` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> $DIR/issue-36530.rs:13:5
|
13 | #![foo] //~ ERROR is currently unknown to the compiler
diff --git a/src/test/ui/specialization-feature-gate-default.stderr b/src/test/ui/specialization-feature-gate-default.stderr
index e17d130..96e0fe1 100644
--- a/src/test/ui/specialization-feature-gate-default.stderr
+++ b/src/test/ui/specialization-feature-gate-default.stderr
@@ -1,4 +1,4 @@
-error: specialization is unstable (see issue #31844)
+error[E0658]: specialization is unstable (see issue #31844)
--> $DIR/specialization-feature-gate-default.rs:20:5
|
20 | default fn foo(&self) {} //~ ERROR specialization is unstable
diff --git a/src/test/ui/suggestions/dont-suggest-dereference-on-arg.stderr b/src/test/ui/suggestions/dont-suggest-dereference-on-arg.stderr
index 799d908..5413dcd 100644
--- a/src/test/ui/suggestions/dont-suggest-dereference-on-arg.stderr
+++ b/src/test/ui/suggestions/dont-suggest-dereference-on-arg.stderr
@@ -1,4 +1,4 @@
-error: non-reference pattern used to match a reference (see issue #42640)
+error[E0658]: non-reference pattern used to match a reference (see issue #42640)
--> $DIR/dont-suggest-dereference-on-arg.rs:16:18
|
16 | .filter(|&(ref a, _)| foo(a))
diff --git a/src/test/ui/typeck-default-trait-impl-outside-crate.stderr b/src/test/ui/typeck-default-trait-impl-outside-crate.stderr
deleted file mode 100644
index 6b50fde..0000000
--- a/src/test/ui/typeck-default-trait-impl-outside-crate.stderr
+++ /dev/null
@@ -1,8 +0,0 @@
-error[E0318]: cannot create default implementations for traits outside the crate they're defined in; define a new trait instead
- --> $DIR/typeck-default-trait-impl-outside-crate.rs:14:6
- |
-14 | impl Copy for .. {} //~ ERROR E0318
- | ^^^^ `Copy` trait not defined in this crate
-
-error: aborting due to previous error
-
diff --git a/src/tools/tidy/src/pal.rs b/src/tools/tidy/src/pal.rs
index fdbcfd1..8071f07 100644
--- a/src/tools/tidy/src/pal.rs
+++ b/src/tools/tidy/src/pal.rs
@@ -168,8 +168,8 @@
let prev_newline_idx = contents[..prev_newline_idx].rfind('\n');
if let Some(nl) = prev_newline_idx {
let prev_line = &contents[nl + 1 .. mod_tests_idx];
- let emcc_cfg = "cfg(all(test, not(target_os";
- if prev_line.contains(emcc_cfg) {
+ if prev_line.contains("cfg(all(test, not(target_os")
+ || prev_line.contains("cfg(all(test, not(any(target_os") {
nl
} else {
mod_tests_idx
diff --git a/src/tools/tidy/src/unstable_book.rs b/src/tools/tidy/src/unstable_book.rs
index a4a35a7..6ffe78e 100644
--- a/src/tools/tidy/src/unstable_book.rs
+++ b/src/tools/tidy/src/unstable_book.rs
@@ -49,7 +49,7 @@
features
.iter()
.filter(|&(_, ref f)| f.level == Status::Unstable)
- .map(|(name, _)| name.to_owned())
+ .map(|(name, _)| name.replace('_', "-"))
.collect()
}
@@ -60,7 +60,7 @@
.map(|entry| entry.expect("could not read directory entry"))
.filter(dir_entry_is_file)
.map(|entry| entry.file_name().into_string().unwrap())
- .map(|n| n.trim_right_matches(".md").replace('-', "_"))
+ .map(|n| n.trim_right_matches(".md").to_owned())
.collect()
}
diff --git a/src/tools/unstable-book-gen/src/main.rs b/src/tools/unstable-book-gen/src/main.rs
index f66a185..f66144f 100644
--- a/src/tools/unstable-book-gen/src/main.rs
+++ b/src/tools/unstable-book-gen/src/main.rs
@@ -53,9 +53,9 @@
set
.iter()
.map(|ref n| format!(" - [{}]({}/{}.md)",
- n,
+ n.replace('-', "_"),
dir,
- n.replace('_', "-")))
+ n))
.fold("".to_owned(), |s, a| s + &a + "\n")
}
@@ -96,14 +96,17 @@
let unstable_section_file_names = collect_unstable_book_section_file_names(src);
t!(fs::create_dir_all(&out));
for feature_name in &unstable_features - &unstable_section_file_names {
- let file_name = format!("{}.md", feature_name.replace('_', "-"));
+ let feature_name_underscore = feature_name.replace('-', "_");
+ let file_name = format!("{}.md", feature_name);
let out_file_path = out.join(&file_name);
- let feature = &features[&feature_name];
+ let feature = &features[&feature_name_underscore];
if has_valid_tracking_issue(&feature) {
- generate_stub_issue(&out_file_path, &feature_name, feature.tracking_issue.unwrap());
+ generate_stub_issue(&out_file_path,
+ &feature_name_underscore,
+ feature.tracking_issue.unwrap());
} else {
- generate_stub_no_issue(&out_file_path, &feature_name);
+ generate_stub_no_issue(&out_file_path, &feature_name_underscore);
}
}
}