always work, and sometimes it's hard to know what to search for, so consider this
extra credit. We won't mind if you accidentally file a duplicate report.
+Similarly, to help others who encountered the bug find your issue,
+consider filing an issue with with a descriptive title, which contains information that might be unique to it.
+This can be the language or compiler feature used, the conditions that trigger the bug,
+or part of the error message if there is any.
+An example could be: **"impossible case reached" on lifetime inference for impl Trait in return position**.
+
Opening an issue is as easy as following [this
link](https://github.com/rust-lang/rust/issues/new) and filling out the fields.
Here's a template that you can use to file a bug, though it's not necessary to
pub fn get(&self) -> T {
unsafe{ *self.value.get() }
}
+
+ /// Updates the contained value using a function and returns the new value.
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// #![feature(cell_update)]
+ ///
+ /// use std::cell::Cell;
+ ///
+ /// let c = Cell::new(5);
+ /// let new = c.update(|x| x + 1);
+ ///
+ /// assert_eq!(new, 6);
+ /// assert_eq!(c.get(), 6);
+ /// ```
+ #[inline]
+ #[unstable(feature = "cell_update", issue = "50186")]
+ pub fn update<F>(&self, f: F) -> T
+ where
+ F: FnOnce(T) -> T,
+ {
+ let old = self.get();
+ let new = f(old);
+ self.set(new);
+ new
+ }
}
#[stable(feature = "rust1", since = "1.0.0")]
/// An iterator over an iterator of bytes of the characters the bytes represent
/// as UTF-8
#[unstable(feature = "decode_utf8", issue = "33906")]
+#[rustc_deprecated(since = "1.27.0", reason = "Use str::from_utf8 instead:
+ https://doc.rust-lang.org/nightly/std/str/struct.Utf8Error.html#examples")]
#[derive(Clone, Debug)]
+#[allow(deprecated)]
pub struct DecodeUtf8<I: Iterator<Item = u8>>(::iter::Peekable<I>);
/// Decodes an `Iterator` of bytes as UTF-8.
#[unstable(feature = "decode_utf8", issue = "33906")]
+#[rustc_deprecated(since = "1.27.0", reason = "Use str::from_utf8 instead:
+ https://doc.rust-lang.org/nightly/std/str/struct.Utf8Error.html#examples")]
+#[allow(deprecated)]
#[inline]
pub fn decode_utf8<I: IntoIterator<Item = u8>>(i: I) -> DecodeUtf8<I::IntoIter> {
DecodeUtf8(i.into_iter().peekable())
/// `<DecodeUtf8 as Iterator>::next` returns this for an invalid input sequence.
#[unstable(feature = "decode_utf8", issue = "33906")]
+#[rustc_deprecated(since = "1.27.0", reason = "Use str::from_utf8 instead:
+ https://doc.rust-lang.org/nightly/std/str/struct.Utf8Error.html#examples")]
#[derive(PartialEq, Eq, Debug)]
+#[allow(deprecated)]
pub struct InvalidSequence(());
#[unstable(feature = "decode_utf8", issue = "33906")]
+#[allow(deprecated)]
impl<I: Iterator<Item = u8>> Iterator for DecodeUtf8<I> {
type Item = Result<char, InvalidSequence>;
#[inline]
}
#[unstable(feature = "decode_utf8", issue = "33906")]
+#[allow(deprecated)]
impl<I: FusedIterator<Item = u8>> FusedIterator for DecodeUtf8<I> {}
/// An iterator that decodes UTF-16 encoded code points from an iterator of `u16`s.
#[unstable(feature = "unicode_version", issue = "49726")]
pub use unicode::version::UnicodeVersion;
#[unstable(feature = "decode_utf8", issue = "33906")]
+#[rustc_deprecated(since = "1.27.0", reason = "Use str::from_utf8 instead:
+ https://doc.rust-lang.org/nightly/std/str/struct.Utf8Error.html#examples")]
+#[allow(deprecated)]
pub use self::decode::{decode_utf8, DecodeUtf8, InvalidSequence};
use fmt::{self, Write};
--- /dev/null
+// 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.
+
+#![stable(feature = "core_hint", since = "1.27.0")]
+
+//! Hints to compiler that affects how code should be emitted or optimized.
+
+use intrinsics;
+
+/// Informs the compiler that this point in the code is not reachable, enabling
+/// further optimizations.
+///
+/// # Safety
+///
+/// Reaching this function is completely *undefined behavior* (UB). In
+/// particular, the compiler assumes that all UB must never happen, and
+/// therefore will eliminate all branches that reach to a call to
+/// `unreachable_unchecked()`.
+///
+/// Like all instances of UB, if this assumption turns out to be wrong, i.e. the
+/// `unreachable_unchecked()` call is actually reachable among all possible
+/// control flow, the compiler will apply the wrong optimization strategy, and
+/// may sometimes even corrupt seemingly unrelated code, causing
+/// difficult-to-debug problems.
+///
+/// Use this function only when you can prove that the code will never call it.
+///
+/// The [`unreachable!()`] macro is the safe counterpart of this function, which
+/// will panic instead when executed.
+///
+/// [`unreachable!()`]: ../macro.unreachable.html
+///
+/// # Example
+///
+/// ```
+/// fn div_1(a: u32, b: u32) -> u32 {
+/// use std::hint::unreachable_unchecked;
+///
+/// // `b.saturating_add(1)` is always positive (not zero),
+/// // hence `checked_div` will never return None.
+/// // Therefore, the else branch is unreachable.
+/// a.checked_div(b.saturating_add(1))
+/// .unwrap_or_else(|| unsafe { unreachable_unchecked() })
+/// }
+///
+/// assert_eq!(div_1(7, 0), 7);
+/// assert_eq!(div_1(9, 1), 4);
+/// assert_eq!(div_1(11, std::u32::MAX), 0);
+/// ```
+#[inline]
+#[stable(feature = "unreachable", since = "1.27.0")]
+pub unsafe fn unreachable_unchecked() -> ! {
+ intrinsics::unreachable()
+}
/// NB: This is very different from the `unreachable!()` macro: Unlike the
/// macro, which panics when it is executed, it is *undefined behavior* to
/// reach code marked with this function.
+ ///
+ /// The stabilized version of this intrinsic is
+ /// [`std::hint::unreachable_unchecked`](../../std/hint/fn.unreachable_unchecked.html).
pub fn unreachable() -> !;
/// Informs the optimizer that a condition is always true.
pub mod mem;
pub mod nonzero;
pub mod ptr;
+pub mod hint;
/* Core language traits */
/// * Iterators that dynamically terminate.
///
/// If the determination that the code is unreachable proves incorrect, the
-/// program immediately terminates with a [`panic!`]. The function [`unreachable`],
-/// which belongs to the [`std::intrinsics`] module, informs the compilier to
+/// program immediately terminates with a [`panic!`]. The function [`unreachable_unchecked`],
+/// which belongs to the [`std::hint`] module, informs the compilier to
/// optimize the code out of the release version entirely.
///
/// [`panic!`]: ../std/macro.panic.html
-/// [`unreachable`]: ../std/intrinsics/fn.unreachable.html
-/// [`std::intrinsics`]: ../std/intrinsics/index.html
+/// [`unreachable_unchecked`]: ../std/hint/fn.unreachable_unchecked.html
+/// [`std::hint`]: ../std/hint/index.html
///
/// # Panics
///
}
}
-/// Tells LLVM that this point in the code is not reachable, enabling further
-/// optimizations.
-///
-/// NB: This is very different from the `unreachable!()` macro: Unlike the
-/// macro, which panics when it is executed, it is *undefined behavior* to
-/// reach code marked with this function.
-#[inline]
-#[unstable(feature = "unreachable", issue = "43751")]
-pub unsafe fn unreachable() -> ! {
- intrinsics::unreachable()
-}
-
/// A pinned reference.
///
/// A pinned reference is a lot like a mutable reference, except that it is not
assert!(y.get() == (30, 40));
}
+#[test]
+fn cell_update() {
+ let x = Cell::new(10);
+
+ assert_eq!(x.update(|x| x + 5), 15);
+ assert_eq!(x.get(), 15);
+
+ assert_eq!(x.update(|x| x / 3), 5);
+ assert_eq!(x.get(), 5);
+}
+
#[test]
fn cell_has_sensible_show() {
let x = Cell::new("foo bar");
}
#[test]
+#[allow(deprecated)]
fn test_decode_utf8() {
macro_rules! assert_decode_utf8 {
($input_bytes: expr, $expected_str: expr) => {
#![feature(ascii_ctype)]
#![feature(box_syntax)]
+#![feature(cell_update)]
#![feature(core_float)]
#![feature(core_private_bignum)]
#![feature(core_private_diy_float)]
Ok(ecx)
}
-pub fn eval_body_with_mir<'a, 'mir, 'tcx>(
+pub fn eval_promoted<'a, 'mir, 'tcx>(
tcx: TyCtxt<'a, 'tcx, 'tcx>,
cid: GlobalId<'tcx>,
mir: &'mir mir::Mir<'tcx>,
match res {
Ok(val) => Some(val),
Err(mut err) => {
- ecx.report(&mut err, true, None);
+ ecx.report(&mut err, false, None);
None
}
}
pub use self::memory::{Memory, MemoryKind, HasMemory};
pub use self::const_eval::{
- eval_body_with_mir,
+ eval_promoted,
mk_borrowck_eval_cx,
eval_body,
CompileTimeEvaluator,
param_substs: instance.substs,
}.visit_mir(&mir);
let param_env = ty::ParamEnv::reveal_all();
- for (i, promoted) in mir.promoted.iter().enumerate() {
+ for i in 0..mir.promoted.len() {
use rustc_data_structures::indexed_vec::Idx;
let cid = GlobalId {
instance,
};
match tcx.const_eval(param_env.and(cid)) {
Ok(val) => collect_const(tcx, val, instance.substs, output),
- Err(err) => {
- err.report(tcx, promoted.span, "promoted");
- }
+ Err(_) => {},
}
}
}
use rustc::middle::const_val::ConstVal;
use rustc::ty::{TyCtxt, self, Instance};
use rustc::mir::interpret::{Value, PrimVal, GlobalId};
-use interpret::{eval_body_with_mir, mk_borrowck_eval_cx, ValTy};
+use interpret::{eval_promoted, mk_borrowck_eval_cx, ValTy};
use transform::{MirPass, MirSource};
use syntax::codemap::Span;
use rustc::ty::subst::Substs;
};
// cannot use `const_eval` here, because that would require having the MIR
// for the current function available, but we're producing said MIR right now
- let (value, _, ty) = eval_body_with_mir(self.tcx, cid, self.mir, self.param_env)?;
+ let (value, _, ty) = eval_promoted(self.tcx, cid, self.mir, self.param_env)?;
let val = (value, ty, c.span);
trace!("evaluated {:?} to {:?}", c, val);
Some(val)
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");
+ self.err_handler()
+ .struct_span_err(item.span, "inherent impls cannot be default")
+ .note("only trait implementations may be annotated with default").emit();
}
}
ItemKind::ForeignMod(..) => {
self.mir_constant_to_miri_value(bx, constant)
.and_then(|c| OperandRef::from_const(bx, c, ty))
.unwrap_or_else(|err| {
- err.report(bx.tcx(), constant.span, "const operand");
+ match constant.literal {
+ mir::Literal::Promoted { .. } => {
+ // don't report errors inside promoteds, just warnings.
+ },
+ mir::Literal::Value { .. } => {
+ err.report(bx.tcx(), constant.span, "const operand")
+ },
+ }
// We've errored, so we don't have to produce working code.
let layout = bx.cx.layout_of(ty);
PlaceRef::new_sized(
function search(e) {
var params = getQueryStringParams();
- var query = getQuery(document.getElementsByClassName('search-input')[0].value.trim());
+ var search_input = document.getElementsByClassName('search-input')[0];
+ var query = getQuery(search_input.value.trim());
if (e) {
e.preventDefault();
}
if (!query.query || query.id === currentResults) {
+ if (query.query.length > 0) {
+ putBackSearch(search_input);
+ }
return;
}
};
});
+ function putBackSearch(search_input) {
+ if (search_input.value !== "") {
+ addClass(document.getElementById("main"), "hidden");
+ removeClass(document.getElementById("search"), "hidden");
+ if (browserSupportsHistoryApi()) {
+ history.replaceState(search_input.value,
+ "",
+ "?search=" + encodeURIComponent(search_input.value));
+ }
+ }
+ }
+
var search_input = document.getElementsByClassName("search-input")[0];
if (search_input) {
search_input.onfocus = function() {
- if (search_input.value !== "") {
- addClass(document.getElementById("main"), "hidden");
- removeClass(document.getElementById("search"), "hidden");
- if (browserSupportsHistoryApi()) {
- history.replaceState(search_input.value,
- "",
- "?search=" + encodeURIComponent(search_input.value));
- }
- }
+ putBackSearch(this);
};
}
}
#[test]
+ #[allow(deprecated)]
fn read_char_buffered() {
let buf = [195, 159];
let reader = BufReader::with_capacity(1, &buf[..]);
}
#[test]
+ #[allow(deprecated)]
fn test_chars() {
let buf = [195, 159, b'a'];
let reader = BufReader::with_capacity(1, &buf[..]);
}
#[test]
+ #[allow(deprecated)]
fn test_read_char() {
let b = &b"Vi\xE1\xBB\x87t"[..];
let mut c = Cursor::new(b).chars();
}
#[test]
+ #[allow(deprecated)]
fn test_read_bad_char() {
let b = &b"\x80"[..];
let mut c = Cursor::new(b).chars();
of where errors happen is currently \
unclear and may change",
issue = "27802")]
+ #[rustc_deprecated(since = "1.27.0", reason = "Use str::from_utf8 instead:
+ https://doc.rust-lang.org/nightly/std/str/struct.Utf8Error.html#examples")]
+ #[allow(deprecated)]
fn chars(self) -> Chars<Self> where Self: Sized {
Chars { inner: self }
}
/// [chars]: trait.Read.html#method.chars
#[unstable(feature = "io", reason = "awaiting stability of Read::chars",
issue = "27802")]
+#[rustc_deprecated(since = "1.27.0", reason = "Use str::from_utf8 instead:
+ https://doc.rust-lang.org/nightly/std/str/struct.Utf8Error.html#examples")]
#[derive(Debug)]
+#[allow(deprecated)]
pub struct Chars<R> {
inner: R,
}
/// An enumeration of possible errors that can be generated from the `Chars`
/// adapter.
-#[derive(Debug)]
#[unstable(feature = "io", reason = "awaiting stability of Read::chars",
issue = "27802")]
+#[rustc_deprecated(since = "1.27.0", reason = "Use str::from_utf8 instead:
+ https://doc.rust-lang.org/nightly/std/str/struct.Utf8Error.html#examples")]
+#[derive(Debug)]
+#[allow(deprecated)]
pub enum CharsError {
/// Variant representing that the underlying stream was read successfully
/// but it did not contain valid utf8 data.
#[unstable(feature = "io", reason = "awaiting stability of Read::chars",
issue = "27802")]
+#[allow(deprecated)]
impl<R: Read> Iterator for Chars<R> {
type Item = result::Result<char, CharsError>;
#[unstable(feature = "io", reason = "awaiting stability of Read::chars",
issue = "27802")]
+#[allow(deprecated)]
impl std_error::Error for CharsError {
fn description(&self) -> &str {
match *self {
#[unstable(feature = "io", reason = "awaiting stability of Read::chars",
issue = "27802")]
+#[allow(deprecated)]
impl fmt::Display for CharsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
pub use core::char;
#[stable(feature = "i128", since = "1.26.0")]
pub use core::u128;
+#[stable(feature = "core_hint", since = "1.27.0")]
+pub use core::hint;
pub mod f32;
pub mod f64;
#[allow(deprecated)]
use os::android::raw;
-/// OS-specific extension methods for `fs::Metadata`
+/// OS-specific extensions to [`fs::Metadata`].
+///
+/// [`fs::Metadata`]: ../../../../std/fs/struct.Metadata.html
#[stable(feature = "metadata_ext", since = "1.1.0")]
pub trait MetadataExt {
/// Gain a reference to the underlying `stat` structure which contains
#[allow(deprecated)]
use os::bitrig::raw;
-/// OS-specific extension methods for `fs::Metadata`
+/// OS-specific extensions to [`fs::Metadata`].
+///
+/// [`fs::Metadata`]: ../../../../std/fs/struct.Metadata.html
#[stable(feature = "metadata_ext", since = "1.1.0")]
pub trait MetadataExt {
/// Gain a reference to the underlying `stat` structure which contains
#[allow(deprecated)]
use os::dragonfly::raw;
-/// OS-specific extension methods for `fs::Metadata`
+/// OS-specific extensions to [`fs::Metadata`].
+///
+/// [`fs::Metadata`]: ../../../../std/fs/struct.Metadata.html
#[stable(feature = "metadata_ext", since = "1.1.0")]
pub trait MetadataExt {
/// Gain a reference to the underlying `stat` structure which contains
#[allow(deprecated)]
use os::emscripten::raw;
-/// OS-specific extension methods for `fs::Metadata`
+/// OS-specific extensions to [`fs::Metadata`].
+///
+/// [`fs::Metadata`]: ../../../../std/fs/struct.Metadata.html
#[stable(feature = "metadata_ext", since = "1.1.0")]
pub trait MetadataExt {
/// Gain a reference to the underlying `stat` structure which contains
#[allow(deprecated)]
use os::freebsd::raw;
-/// OS-specific extension methods for `fs::Metadata`
+/// OS-specific extensions to [`fs::Metadata`].
+///
+/// [`fs::Metadata`]: ../../../../std/fs/struct.Metadata.html
#[stable(feature = "metadata_ext", since = "1.1.0")]
pub trait MetadataExt {
/// Gain a reference to the underlying `stat` structure which contains
use fs::Metadata;
use sys_common::AsInner;
-/// OS-specific extension methods for `fs::Metadata`
+/// OS-specific extensions to [`fs::Metadata`].
+///
+/// [`fs::Metadata`]: ../../../../std/fs/struct.Metadata.html
#[stable(feature = "metadata_ext", since = "1.1.0")]
pub trait MetadataExt {
#[stable(feature = "metadata_ext2", since = "1.8.0")]
#[allow(deprecated)]
use os::haiku::raw;
-/// OS-specific extension methods for `fs::Metadata`
+/// OS-specific extensions to [`fs::Metadata`].
+///
+/// [`fs::Metadata`]: ../../../../std/fs/struct.Metadata.html
#[stable(feature = "metadata_ext", since = "1.1.0")]
pub trait MetadataExt {
/// Gain a reference to the underlying `stat` structure which contains
#[allow(deprecated)]
use os::ios::raw;
-/// OS-specific extension methods for `fs::Metadata`
+/// OS-specific extensions to [`fs::Metadata`].
+///
+/// [`fs::Metadata`]: ../../../../std/fs/struct.Metadata.html
#[stable(feature = "metadata_ext", since = "1.1.0")]
pub trait MetadataExt {
/// Gain a reference to the underlying `stat` structure which contains
#[allow(deprecated)]
use os::linux::raw;
-/// OS-specific extension methods for `fs::Metadata`
+/// OS-specific extensions to [`fs::Metadata`].
+///
+/// [`fs::Metadata`]: ../../../../std/fs/struct.Metadata.html
#[stable(feature = "metadata_ext", since = "1.1.0")]
pub trait MetadataExt {
/// Gain a reference to the underlying `stat` structure which contains
#[allow(deprecated)]
use os::macos::raw;
-/// OS-specific extension methods for `fs::Metadata`
+/// OS-specific extensions to [`fs::Metadata`].
+///
+/// [`fs::Metadata`]: ../../../../std/fs/struct.Metadata.html
#[stable(feature = "metadata_ext", since = "1.1.0")]
pub trait MetadataExt {
/// Gain a reference to the underlying `stat` structure which contains
#[allow(deprecated)]
use os::netbsd::raw;
-/// OS-specific extension methods for `fs::Metadata`
+/// OS-specific extensions to [`fs::Metadata`].
+///
+/// [`fs::Metadata`]: ../../../../std/fs/struct.Metadata.html
#[stable(feature = "metadata_ext", since = "1.1.0")]
pub trait MetadataExt {
/// Gain a reference to the underlying `stat` structure which contains
#[allow(deprecated)]
use os::openbsd::raw;
-/// OS-specific extension methods for `fs::Metadata`
+/// OS-specific extensions to [`fs::Metadata`].
+///
+/// [`fs::Metadata`]: ../../../../std/fs/struct.Metadata.html
#[stable(feature = "metadata_ext", since = "1.1.0")]
pub trait MetadataExt {
/// Gain a reference to the underlying `stat` structure which contains
#[allow(deprecated)]
use os::solaris::raw;
-/// OS-specific extension methods for `fs::Metadata`
+/// OS-specific extensions to [`fs::Metadata`].
+///
+/// [`fs::Metadata`]: ../../../../std/fs/struct.Metadata.html
#[stable(feature = "metadata_ext", since = "1.1.0")]
pub trait MetadataExt {
/// Gain a reference to the underlying `stat` structure which contains
// Iterate through `iter` while it matches `prefix`; return `None` if `prefix`
// is not a prefix of `iter`, otherwise return `Some(iter_after_prefix)` giving
// `iter` after having exhausted `prefix`.
-fn iter_after<A, I, J>(mut iter: I, mut prefix: J) -> Option<I>
- where I: Iterator<Item = A> + Clone,
- J: Iterator<Item = A>,
- A: PartialEq
+fn iter_after<'a, 'b, I, J>(mut iter: I, mut prefix: J) -> Option<I>
+ where I: Iterator<Item = Component<'a>> + Clone,
+ J: Iterator<Item = Component<'b>>,
{
loop {
let mut iter_next = iter.clone();
/// # Examples
///
/// ```
- /// use std::path::Path;
+ /// use std::path::{Path, PathBuf};
///
/// let path = Path::new("/test/haha/foo.txt");
///
/// assert_eq!(path.strip_prefix("/test/haha/foo.txt/"), Ok(Path::new("")));
/// assert_eq!(path.strip_prefix("test").is_ok(), false);
/// assert_eq!(path.strip_prefix("/haha").is_ok(), false);
+ ///
+ /// let prefix = PathBuf::from("/test/");
+ /// assert_eq!(path.strip_prefix(prefix), Ok(Path::new("haha/foo.txt")));
/// ```
#[stable(since = "1.7.0", feature = "path_strip_prefix")]
- pub fn strip_prefix<'a, P: ?Sized>(&'a self, base: &'a P)
- -> Result<&'a Path, StripPrefixError>
+ pub fn strip_prefix<P>(&self, base: P)
+ -> Result<&Path, StripPrefixError>
where P: AsRef<Path>
{
self._strip_prefix(base.as_ref())
}
- fn _strip_prefix<'a>(&'a self, base: &'a Path)
- -> Result<&'a Path, StripPrefixError> {
+ fn _strip_prefix(&self, base: &Path)
+ -> Result<&Path, StripPrefixError> {
iter_after(self.components(), base.components())
.map(|c| c.as_path())
.ok_or(StripPrefixError(()))
}
impl Child {
- /// Forces the child to exit. This is equivalent to sending a
- /// SIGKILL on unix platforms.
+ /// Forces the child process to exit. If the child has already exited, an [`InvalidInput`]
+ /// error is returned.
+ ///
+ /// The mapping to [`ErrorKind`]s is not part of the compatibility contract of the function,
+ /// especially the [`Other`] kind might change to more specific kinds in the future.
+ ///
+ /// This is equivalent to sending a SIGKILL on Unix platforms.
///
/// # Examples
///
/// println!("yes command didn't start");
/// }
/// ```
+ ///
+ /// [`ErrorKind`]: ../io/enum.ErrorKind.html
+ /// [`InvalidInput`]: ../io/enum.ErrorKind.html#variant.InvalidInput
+ /// [`Other`]: ../io/enum.ErrorKind.html#variant.Other
#[stable(feature = "process", since = "1.0.0")]
pub fn kill(&mut self) -> io::Result<()> {
self.handle.kill()
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-//! Unix-specific extension to the primitives in the `std::ffi` module
+//! Redox-specific extension to the primitives in the `std::ffi` module.
#![stable(feature = "rust1", since = "1.0.0")]
use sys::os_str::Buf;
use sys_common::{FromInner, IntoInner, AsInner};
-/// Unix-specific extensions to `OsString`.
+/// Redox-specific extensions to [`OsString`].
+///
+/// [`OsString`]: ../../../../std/ffi/struct.OsString.html
#[stable(feature = "rust1", since = "1.0.0")]
pub trait OsStringExt {
/// Creates an `OsString` from a byte vector.
}
}
-/// Unix-specific extensions to `OsStr`.
+/// Redox-specific extensions to [`OsStr`].
+///
+/// [`OsStr`]: ../../../../std/ffi/struct.OsStr.html
#[stable(feature = "rust1", since = "1.0.0")]
pub trait OsStrExt {
#[stable(feature = "rust1", since = "1.0.0")]
use sys;
use sys_common::{FromInner, AsInner, AsInnerMut};
-/// Redox-specific extensions to `Permissions`
+/// Redox-specific extensions to [`fs::Permissions`].
+///
+/// [`fs::Permissions`]: ../../../../std/fs/struct.Permissions.html
#[stable(feature = "fs_ext", since = "1.1.0")]
pub trait PermissionsExt {
/// Returns the underlying raw `mode_t` bits that are the standard Redox
}
}
-/// Redox-specific extensions to `OpenOptions`
+/// Redox-specific extensions to [`fs::OpenOptions`].
+///
+/// [`fs::OpenOptions`]: ../../../../std/fs/struct.OpenOptions.html
#[stable(feature = "fs_ext", since = "1.1.0")]
pub trait OpenOptionsExt {
/// Sets the mode bits that a new file will be created with.
}
}
-// Hm, why are there casts here to the returned type, shouldn't the types always
-// be the same? Right you are! Turns out, however, on android at least the types
-// in the raw `stat` structure are not the same as the types being returned. Who
-// knew!
-//
-// As a result to make sure this compiles for all platforms we do the manual
-// casts and rely on manual lowering to `stat` if the raw type is desired.
+/// Redox-specific extensions to [`fs::Metadata`].
+///
+/// [`fs::Metadata`]: ../../../../std/fs/struct.Metadata.html
#[stable(feature = "metadata_ext", since = "1.1.0")]
pub trait MetadataExt {
#[stable(feature = "metadata_ext", since = "1.1.0")]
fn blocks(&self) -> u64;
}
+// Hm, why are there casts here to the returned type, shouldn't the types always
+// be the same? Right you are! Turns out, however, on android at least the types
+// in the raw `stat` structure are not the same as the types being returned. Who
+// knew!
+//
+// As a result to make sure this compiles for all platforms we do the manual
+// casts and rely on manual lowering to `stat` if the raw type is desired.
#[stable(feature = "metadata_ext", since = "1.1.0")]
impl MetadataExt for fs::Metadata {
fn dev(&self) -> u64 {
}
}
-/// Add special Redox types (block/char device, fifo and socket)
+/// Redox-specific extensions for [`FileType`].
+///
+/// Adds support for special Unix file types such as block/character devices,
+/// pipes, and sockets.
+///
+/// [`FileType`]: ../../../../std/fs/struct.FileType.html
#[stable(feature = "file_type_ext", since = "1.5.0")]
pub trait FileTypeExt {
/// Returns whether this file type is a block device.
sys::fs::symlink(src.as_ref(), dst.as_ref())
}
+/// Redox-specific extensions to [`fs::DirBuilder`].
+///
+/// [`fs::DirBuilder`]: ../../../../std/fs/struct.DirBuilder.html
#[stable(feature = "dir_builder", since = "1.6.0")]
-/// An extension trait for `fs::DirBuilder` for Redox-specific options.
pub trait DirBuilderExt {
/// Sets the mode to create new directories with. This option defaults to
/// 0o777.
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-//! Unix-specific extensions to primitives in the `std::process` module.
+//! Redox-specific extensions to primitives in the `std::process` module.
#![stable(feature = "rust1", since = "1.0.0")]
use sys;
use sys_common::{AsInnerMut, AsInner, FromInner, IntoInner};
-/// Unix-specific extensions to the `std::process::Command` builder
+/// Redox-specific extensions to the [`process::Command`] builder,
+///
+/// [`process::Command`]: ../../../../std/process/struct.Command.html
#[stable(feature = "rust1", since = "1.0.0")]
pub trait CommandExt {
/// Sets the child process's user id. This translates to a
}
}
-/// Unix-specific extensions to `std::process::ExitStatus`
+/// Redox-specific extensions to [`process::ExitStatus`].
+///
+/// [`process::ExitStatus`]: ../../../../std/process/struct.ExitStatus.html
#[stable(feature = "rust1", since = "1.0.0")]
pub trait ExitStatusExt {
/// Creates a new `ExitStatus` from the raw underlying `i32` return value of
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-//! Unix-specific extensions to primitives in the `std::thread` module.
+//! Redox-specific extensions to primitives in the `std::thread` module.
#![stable(feature = "thread_extensions", since = "1.9.0")]
#[allow(deprecated)]
pub type RawPthread = usize;
-/// Unix-specific extensions to `std::thread::JoinHandle`
+/// Redox-specific extensions to [`thread::JoinHandle`].
+///
+/// [`thread::JoinHandle`]: ../../../../std/thread/struct.JoinHandle.html
#[stable(feature = "thread_extensions", since = "1.9.0")]
pub trait JoinHandleExt {
/// Extracts the raw pthread_t without taking ownership
use sys::os_str::Buf;
use sys_common::{FromInner, IntoInner, AsInner};
-/// Unix-specific extensions to `OsString`.
+/// Unix-specific extensions to [`OsString`].
+///
+/// [`OsString`]: ../../../../std/ffi/struct.OsString.html
#[stable(feature = "rust1", since = "1.0.0")]
pub trait OsStringExt {
/// Creates an [`OsString`] from a byte vector.
}
}
-/// Unix-specific extensions to `OsStr`.
+/// Unix-specific extensions to [`OsStr`].
+///
+/// [`OsStr`]: ../../../../std/ffi/struct.OsStr.html
#[stable(feature = "rust1", since = "1.0.0")]
pub trait OsStrExt {
#[stable(feature = "rust1", since = "1.0.0")]
}
}
-/// Unix-specific extensions to `Permissions`
+/// Unix-specific extensions to [`fs::Permissions`].
+///
+/// [`fs::Permissions`]: ../../../../std/fs/struct.Permissions.html
#[stable(feature = "fs_ext", since = "1.1.0")]
pub trait PermissionsExt {
/// Returns the underlying raw `st_mode` bits that contain the standard
}
}
-/// Unix-specific extensions to `OpenOptions`
+/// Unix-specific extensions to [`fs::OpenOptions`].
+///
+/// [`fs::OpenOptions`]: ../../../../std/fs/struct.OpenOptions.html
#[stable(feature = "fs_ext", since = "1.1.0")]
pub trait OpenOptionsExt {
/// Sets the mode bits that a new file will be created with.
}
}
-// Hm, why are there casts here to the returned type, shouldn't the types always
-// be the same? Right you are! Turns out, however, on android at least the types
-// in the raw `stat` structure are not the same as the types being returned. Who
-// knew!
-//
-// As a result to make sure this compiles for all platforms we do the manual
-// casts and rely on manual lowering to `stat` if the raw type is desired.
+/// Unix-specific extensions to [`fs::Metadata`].
+///
+/// [`fs::Metadata`]: ../../../../std/fs/struct.Metadata.html
#[stable(feature = "metadata_ext", since = "1.1.0")]
pub trait MetadataExt {
/// Returns the ID of the device containing the file.
fn blocks(&self) -> u64 { self.st_blocks() }
}
-/// Add support for special unix types (block/char device, fifo and socket).
+/// Unix-specific extensions for [`FileType`].
+///
+/// Adds support for special Unix file types such as block/character devices,
+/// pipes, and sockets.
+///
+/// [`FileType`]: ../../../../std/fs/struct.FileType.html
#[stable(feature = "file_type_ext", since = "1.5.0")]
pub trait FileTypeExt {
/// Returns whether this file type is a block device.
sys::fs::symlink(src.as_ref(), dst.as_ref())
}
-#[stable(feature = "dir_builder", since = "1.6.0")]
-/// An extension trait for [`fs::DirBuilder`] for unix-specific options.
+/// Unix-specific extensions to [`fs::DirBuilder`].
///
/// [`fs::DirBuilder`]: ../../../../std/fs/struct.DirBuilder.html
+#[stable(feature = "dir_builder", since = "1.6.0")]
pub trait DirBuilderExt {
/// Sets the mode to create new directories with. This option defaults to
/// 0o777.
use sys;
use sys_common::{AsInnerMut, AsInner, FromInner, IntoInner};
-/// Unix-specific extensions to the `std::process::Command` builder
+/// Unix-specific extensions to the [`process::Command`] builder.
+///
+/// [`process::Command`]: ../../../../std/process/struct.Command.html
#[stable(feature = "rust1", since = "1.0.0")]
pub trait CommandExt {
/// Sets the child process's user id. This translates to a
}
}
-/// Unix-specific extensions to `std::process::ExitStatus`
+/// Unix-specific extensions to [`process::ExitStatus`].
+///
+/// [`process::ExitStatus`]: ../../../../std/process/struct.ExitStatus.html
#[stable(feature = "rust1", since = "1.0.0")]
pub trait ExitStatusExt {
/// Creates a new `ExitStatus` from the raw underlying `i32` return value of
#[allow(deprecated)]
pub type RawPthread = pthread_t;
-/// Unix-specific extensions to `std::thread::JoinHandle`
+/// Unix-specific extensions to [`thread::JoinHandle`].
+///
+/// [`thread::JoinHandle`]: ../../../../std/thread/struct.JoinHandle.html
#[stable(feature = "thread_extensions", since = "1.9.0")]
pub trait JoinHandleExt {
/// Extracts the raw pthread_t without taking ownership
#[stable(feature = "rust1", since = "1.0.0")]
pub use sys_common::wtf8::EncodeWide;
-/// Windows-specific extensions to `OsString`.
+/// Windows-specific extensions to [`OsString`].
+///
+/// [`OsString`]: ../../../../std/ffi/struct.OsString.html
#[stable(feature = "rust1", since = "1.0.0")]
pub trait OsStringExt {
/// Creates an `OsString` from a potentially ill-formed UTF-16 slice of
}
}
-/// Windows-specific extensions to `OsStr`.
+/// Windows-specific extensions to [`OsStr`].
+///
+/// [`OsStr`]: ../../../../std/ffi/struct.OsStr.html
#[stable(feature = "rust1", since = "1.0.0")]
pub trait OsStrExt {
/// Re-encodes an `OsStr` as a wide character sequence, i.e. potentially
}
}
-/// Windows-specific extensions to [`OpenOptions`].
+/// Windows-specific extensions to [`fs::OpenOptions`].
///
-/// [`OpenOptions`]: ../../../fs/struct.OpenOptions.html
+/// [`fs::OpenOptions`]: ../../../../std/fs/struct.OpenOptions.html
#[stable(feature = "open_options_ext", since = "1.10.0")]
pub trait OpenOptionsExt {
/// Overrides the `dwDesiredAccess` argument to the call to [`CreateFile`]
}
}
-/// Extension methods for [`fs::Metadata`] to access the raw fields contained
-/// within.
+/// Windows-specific extensions to [`fs::Metadata`].
///
/// The data members that this trait exposes correspond to the members
/// of the [`BY_HANDLE_FILE_INFORMATION`] structure.
///
-/// [`fs::Metadata`]: ../../../fs/struct.Metadata.html
+/// [`fs::Metadata`]: ../../../../std/fs/struct.Metadata.html
/// [`BY_HANDLE_FILE_INFORMATION`]:
/// https://msdn.microsoft.com/en-us/library/windows/desktop/aa363788.aspx
#[stable(feature = "metadata_ext", since = "1.1.0")]
fn file_size(&self) -> u64 { self.as_inner().size() }
}
-/// Add support for the Windows specific fact that a symbolic link knows whether it is a file
-/// or directory.
+/// Windows-specific extensions to [`FileType`].
+///
+/// On Windows, a symbolic link knows whether it is a file or directory.
+///
+/// [`FileType`]: ../../../../std/fs/struct.FileType.html
#[unstable(feature = "windows_file_type_ext", issue = "0")]
pub trait FileTypeExt {
/// Returns whether this file type is a symbolic link that is also a directory.
}
}
-/// Windows-specific extensions to `std::process::ExitStatus`
+/// Windows-specific extensions to [`process::ExitStatus`].
+///
+/// [`process::ExitStatus`]: ../../../../std/process/struct.ExitStatus.html
#[stable(feature = "exit_status_from", since = "1.12.0")]
pub trait ExitStatusExt {
/// Creates a new `ExitStatus` from the raw underlying `u32` return value of
}
}
-/// Windows-specific extensions to the `std::process::Command` builder
+/// Windows-specific extensions to the [`process::Command`] builder.
+///
+/// [`process::Command`]: ../../../../std/process/struct.Command.html
#[stable(feature = "windows_process_extensions", since = "1.16.0")]
pub trait CommandExt {
/// Sets the [process creation flags][1] to be passed to `CreateProcess`.
GateIssue::Library(lib) => lib,
};
- let explanation = if let Some(n) = issue {
- format!("{} (see issue #{})", explain, n)
- } else {
- explain.to_owned()
+ let explanation = match issue {
+ None | Some(0) => explain.to_owned(),
+ Some(n) => format!("{} (see issue #{})", explain, n)
};
let mut err = match level {
}
}
ast::TraitItemKind::Type(_, ref default) => {
- // We use two if statements instead of something like match guards so that both
- // of these errors can be emitted if both cases apply.
+ // We use three if statements instead of something like match guards so that all
+ // of these errors can be emitted if all cases apply.
if default.is_some() {
gate_feature_post!(&self, associated_type_defaults, ti.span,
"associated type defaults are unstable");
gate_feature_post!(&self, generic_associated_types, ti.span,
"generic associated types are unstable");
}
+ if !ti.generics.where_clause.predicates.is_empty() {
+ gate_feature_post!(&self, generic_associated_types, ti.span,
+ "where clauses on associated types are unstable");
+ }
}
_ => {}
}
use hygiene::SyntaxContext;
use {Span, DUMMY_SP, GLOBALS};
+use rustc_data_structures::fx::FxHashMap;
use serialize::{Decodable, Decoder, Encodable, Encoder};
-use std::collections::HashMap;
use std::fmt;
use std::hash::{Hash, Hasher};
#[derive(Default)]
pub struct Interner {
- names: HashMap<Box<str>, Symbol>,
+ names: FxHashMap<Box<str>, Symbol>,
strings: Vec<Box<str>>,
gensyms: Vec<Symbol>,
}
+++ /dev/null
-// 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.
-
-trait Foo {
- const AMT: usize;
-}
-
-enum Bar<A, B> {
- First(A),
- Second(B),
-}
-
-impl<A: Foo, B: Foo> Foo for Bar<A, B> {
- const AMT: usize = [A::AMT][(A::AMT > B::AMT) as usize];
-}
-
-impl Foo for u8 {
- const AMT: usize = 1;
-}
-
-impl Foo for u16 {
- const AMT: usize = 2;
-}
-
-fn main() {
- println!("{}", <Bar<u16, u8> as Foo>::AMT); //~ E0080
-}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// compile-pass
+
const X: u32 = 5;
const Y: u32 = 6;
const FOO: u32 = [X - Y, Y - X][(X < Y) as usize];
//~^ WARN attempt to subtract with overflow
fn main() {
- println!("{}", FOO); //~ E0080
+ println!("{}", FOO);
+ //~^ WARN constant evaluation error
}
warning: attempt to subtract with overflow
- --> $DIR/conditional_array_execution.rs:13:19
+ --> $DIR/conditional_array_execution.rs:15:19
|
LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize];
| ^^^^^
|
= note: #[warn(const_err)] on by default
-error[E0080]: constant evaluation error
- --> $DIR/conditional_array_execution.rs:17:20
+warning: constant evaluation error
+ --> $DIR/conditional_array_execution.rs:19:20
|
-LL | println!("{}", FOO); //~ E0080
+LL | println!("{}", FOO);
| ^^^ referenced constant has errors
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0080`.
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// compile-pass
+
#![feature(const_fn)]
const fn foo(x: u32) -> u32 {
const Y: u32 = foo(0-1);
//~^ WARN attempt to subtract with overflow
println!("{} {}", X, Y);
- //~^ ERROR constant evaluation error
- //~| ERROR constant evaluation error
+ //~^ WARN constant evaluation error
+ //~| WARN constant evaluation error
}
warning: attempt to subtract with overflow
- --> $DIR/issue-43197.rs:18:20
+ --> $DIR/issue-43197.rs:20:20
|
LL | const X: u32 = 0-1;
| ^^^
|
= note: #[warn(const_err)] on by default
-error[E0080]: constant evaluation error
- --> $DIR/issue-43197.rs:22:23
+warning: constant evaluation error
+ --> $DIR/issue-43197.rs:24:23
|
LL | println!("{} {}", X, Y);
| ^ referenced constant has errors
warning: attempt to subtract with overflow
- --> $DIR/issue-43197.rs:20:24
+ --> $DIR/issue-43197.rs:22:24
|
LL | const Y: u32 = foo(0-1);
| ^^^
-error[E0080]: constant evaluation error
- --> $DIR/issue-43197.rs:22:26
+warning: constant evaluation error
+ --> $DIR/issue-43197.rs:24:26
|
LL | println!("{} {}", X, Y);
| ^ referenced constant has errors
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0080`.
--- /dev/null
+// 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-pass
+
+trait Foo {
+ const AMT: usize;
+}
+
+enum Bar<A, B> {
+ First(A),
+ Second(B),
+}
+
+impl<A: Foo, B: Foo> Foo for Bar<A, B> {
+ const AMT: usize = [A::AMT][(A::AMT > B::AMT) as usize];
+}
+
+impl Foo for u8 {
+ const AMT: usize = 1;
+}
+
+impl Foo for u16 {
+ const AMT: usize = 2;
+}
+
+fn main() {
+ println!("{}", <Bar<u16, u8> as Foo>::AMT); //~ WARN const_err
+ //~^ WARN const_err
+}
--- /dev/null
+warning: constant evaluation error
+ --> $DIR/issue-44578.rs:35:20
+ |
+LL | println!("{}", <Bar<u16, u8> as Foo>::AMT); //~ WARN const_err
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
+ |
+ = note: #[warn(const_err)] on by default
+
+warning: constant evaluation error
+ --> $DIR/issue-44578.rs:35:20
+ |
+LL | println!("{}", <Bar<u16, u8> as Foo>::AMT); //~ WARN const_err
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
+
--- /dev/null
+// 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-pass
+// compile-flags: -O
+fn main() {
+ println!("{}", 0u32 - 1);
+ //~^ WARN const_err
+ //~| WARN const_err
+ let _x = 0u32 - 1;
+ //~^ WARN const_err
+ println!("{}", 1/(1-1));
+ //~^ WARN const_err
+ //~| WARN const_err
+ let _x = 1/(1-1);
+ //~^ WARN const_err
+ //~| WARN const_err
+ println!("{}", 1/(false as u32));
+ //~^ WARN const_err
+ let _x = 1/(false as u32);
+}
--- /dev/null
+warning: constant evaluation error
+ --> $DIR/promoted_errors.rs:14:20
+ |
+LL | println!("{}", 0u32 - 1);
+ | ^^^^^^^^ attempted to do overflowing math
+ |
+ = note: #[warn(const_err)] on by default
+
+warning: constant evaluation error
+ --> $DIR/promoted_errors.rs:14:20
+ |
+LL | println!("{}", 0u32 - 1);
+ | ^^^^^^^^ attempted to do overflowing math
+
+warning: constant evaluation error
+ --> $DIR/promoted_errors.rs:17:14
+ |
+LL | let _x = 0u32 - 1;
+ | ^^^^^^^^ attempted to do overflowing math
+
+warning: attempt to divide by zero
+ --> $DIR/promoted_errors.rs:19:20
+ |
+LL | println!("{}", 1/(1-1));
+ | ^^^^^^^
+
+warning: constant evaluation error
+ --> $DIR/promoted_errors.rs:19:20
+ |
+LL | println!("{}", 1/(1-1));
+ | ^^^^^^^ attempted to do overflowing math
+
+warning: attempt to divide by zero
+ --> $DIR/promoted_errors.rs:22:14
+ |
+LL | let _x = 1/(1-1);
+ | ^^^^^^^
+
+warning: constant evaluation error
+ --> $DIR/promoted_errors.rs:22:14
+ |
+LL | let _x = 1/(1-1);
+ | ^^^^^^^ attempted to do overflowing math
+
+warning: constant evaluation error
+ --> $DIR/promoted_errors.rs:25:20
+ |
+LL | println!("{}", 1/(false as u32));
+ | ^^^^^^^^^^^^^^^^ attempted to do overflowing math
+
//~^ ERROR generic associated types are unstable
type Pointer2<T>: Deref<Target = T> where T: Clone, U: Clone;
//~^ ERROR generic associated types are unstable
+ //~| ERROR where clauses on associated types are unstable
}
struct Foo;
//~^ ERROR generic associated types are unstable
}
+trait Bar {
+ type Assoc where Self: Sized;
+ //~^ ERROR where clauses on associated types are unstable
+}
+
+
fn main() {}
|
= help: add #![feature(generic_associated_types)] to the crate attributes to enable
+error[E0658]: where clauses on associated types are unstable (see issue #44265)
+ --> $DIR/feature-gate-generic_associated_types.rs:16:5
+ |
+LL | type Pointer2<T>: Deref<Target = T> where T: Clone, U: Clone;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = help: add #![feature(generic_associated_types)] to the crate attributes to enable
+
error[E0658]: generic associated types are unstable (see issue #44265)
- --> $DIR/feature-gate-generic_associated_types.rs:22:5
+ --> $DIR/feature-gate-generic_associated_types.rs:23:5
|
LL | type Pointer<usize> = Box<usize>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= help: add #![feature(generic_associated_types)] to the crate attributes to enable
error[E0658]: generic associated types are unstable (see issue #44265)
- --> $DIR/feature-gate-generic_associated_types.rs:24:5
+ --> $DIR/feature-gate-generic_associated_types.rs:25:5
|
LL | type Pointer2<u32> = Box<u32>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: add #![feature(generic_associated_types)] to the crate attributes to enable
-error: aborting due to 4 previous errors
+error[E0658]: where clauses on associated types are unstable (see issue #44265)
+ --> $DIR/feature-gate-generic_associated_types.rs:30:5
+ |
+LL | type Assoc where Self: Sized;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = help: add #![feature(generic_associated_types)] to the crate attributes to enable
+
+error: aborting due to 6 previous errors
For more information about this error, try `rustc --explain E0658`.
--- /dev/null
+// 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.
+
+extern crate core;
+
+// error should not say "(see issue #0)"
+#[allow(unused_imports)] use core::ptr::Unique; //~ ERROR use of unstable library feature
+
+fn main() {}
--- /dev/null
+error[E0658]: use of unstable library feature 'ptr_internals': use NonNull instead and consider PhantomData<T> (if you also use #[may_dangle]), Send, and/or Sync
+ --> $DIR/issue-49983-see-issue-0.rs:14:30
+ |
+LL | #[allow(unused_imports)] use core::ptr::Unique; //~ ERROR use of unstable library feature
+ | ^^^^^^^^^^^^^^^^^
+ |
+ = help: add #![feature(ptr_internals)] to the crate attributes to enable
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0658`.
BUILD_DIR="$1"
shift
+shopt -s nullglob
+
while [[ "$1" != "" ]]; do
- STDERR_NAME="${1/%.rs/.stderr}"
- STDERR_NLL_NAME="${1/%.rs/.nll.stderr}"
- STDOUT_NAME="${1/%.rs/.stdout}"
+ for EXT in "stderr" "stdout"; do
+ for OUT_NAME in $BUILD_DIR/${1%.rs}.*$EXT; do
+ OUT_BASE=`basename "$OUT_NAME"`
+ if ! (diff $OUT_NAME $MYDIR/$OUT_BASE >& /dev/null); then
+ echo updating $MYDIR/$OUT_BASE
+ cp $OUT_NAME $MYDIR
+ fi
+ done
+ done
shift
- if [ -f $BUILD_DIR/$STDOUT_NAME ] && \
- ! (diff $BUILD_DIR/$STDOUT_NAME $MYDIR/$STDOUT_NAME >& /dev/null); then
- echo updating $MYDIR/$STDOUT_NAME
- cp $BUILD_DIR/$STDOUT_NAME $MYDIR/$STDOUT_NAME
- fi
- if [ -f $BUILD_DIR/$STDERR_NAME ] && \
- ! (diff $BUILD_DIR/$STDERR_NAME $MYDIR/$STDERR_NAME >& /dev/null); then
- echo updating $MYDIR/$STDERR_NAME
- cp $BUILD_DIR/$STDERR_NAME $MYDIR/$STDERR_NAME
- fi
- if [ -f $BUILD_DIR/$STDERR_NLL_NAME ] && \
- ! (diff $BUILD_DIR/$STDERR_NLL_NAME $MYDIR/$STDERR_NLL_NAME >& /dev/null); then
- echo updating $MYDIR/$STDERR_NLL_NAME
- cp $BUILD_DIR/$STDERR_NLL_NAME $MYDIR/$STDERR_NLL_NAME
- fi
done
use std::collections::HashMap;
use std::collections::HashSet;
use std::env;
-use std::ffi::OsString;
+use std::ffi::{OsStr, OsString};
use std::fs::{self, create_dir_all, File};
use std::fmt;
use std::io::prelude::*;
}
}
+trait PathBufExt {
+ /// Append an extension to the path, even if it already has one.
+ fn with_extra_extension<S: AsRef<OsStr>>(&self, extension: S) -> PathBuf;
+}
+
+impl PathBufExt for PathBuf {
+ fn with_extra_extension<S: AsRef<OsStr>>(&self, extension: S) -> PathBuf {
+ if extension.as_ref().len() == 0 {
+ self.clone()
+ } else {
+ let mut fname = self.file_name().unwrap().to_os_string();
+ if !extension.as_ref().to_str().unwrap().starts_with(".") {
+ fname.push(".");
+ }
+ fname.push(extension);
+ self.with_file_name(fname)
+ }
+ }
+}
+
// Produces a diff between the expected output and actual output.
pub fn make_diff(expected: &str, actual: &str, context_size: usize) -> Vec<Mismatch> {
let mut line_number = 1;
}
fn make_exe_name(&self) -> PathBuf {
- let mut f = self.output_base_name();
+ let mut f = self.output_base_name_stage();
// FIXME: This is using the host architecture exe suffix, not target!
if self.config.target.contains("emscripten") {
- let mut fname = f.file_name().unwrap().to_os_string();
- fname.push(".js");
- f.set_file_name(&fname);
+ f = f.with_extra_extension("js");
} else if self.config.target.contains("wasm32") {
- let mut fname = f.file_name().unwrap().to_os_string();
- fname.push(".wasm");
- f.set_file_name(&fname);
+ f = f.with_extra_extension("wasm");
} else if !env::consts::EXE_SUFFIX.is_empty() {
- let mut fname = f.file_name().unwrap().to_os_string();
- fname.push(env::consts::EXE_SUFFIX);
- f.set_file_name(&fname);
+ f = f.with_extra_extension(env::consts::EXE_SUFFIX);
}
f
}
}
fn aux_output_dir_name(&self) -> PathBuf {
- let f = self.output_base_name();
- let mut fname = f.file_name().unwrap().to_os_string();
- fname.push(&format!("{}.aux", self.config.mode.disambiguator()));
- f.with_file_name(&fname)
+ self.output_base_name_stage()
+ .with_extra_extension(self.config.mode.disambiguator())
+ .with_extra_extension(".aux")
}
fn output_testname(&self, filepath: &Path) -> PathBuf {
PathBuf::from(filepath.file_stem().unwrap())
}
- /// Given a test path like `compile-fail/foo/bar.rs` Returns a name like
- ///
- /// <output>/foo/bar-stage1
+ /// Given a test path like `compile-fail/foo/bar.rs` returns a name like
+ /// `/path/to/build/<triple>/test/compile-fail/foo/bar`.
fn output_base_name(&self) -> PathBuf {
let dir = self.config.build_base.join(&self.testpaths.relative_dir);
// Note: The directory `dir` is created during `collect_tests_from_dir`
dir.join(&self.output_testname(&self.testpaths.file))
- .with_extension(&self.config.stage_id)
+ }
+
+ /// Same as `output_base_name`, but includes the stage ID as an extension,
+ /// such as: `.../compile-fail/foo/bar.stage1-<triple>`
+ fn output_base_name_stage(&self) -> PathBuf {
+ self.output_base_name().with_extension(&self.config.stage_id)
}
fn maybe_dump_to_stdout(&self, out: &str, err: &str) {
fn run_rustdoc_test(&self) {
assert!(self.revision.is_none(), "revisions not relevant here");
- let out_dir = self.output_base_name();
+ let out_dir = self.output_base_name_stage();
let _ = fs::remove_dir_all(&out_dir);
create_dir_all(&out_dir).unwrap();
.unwrap();
let src_root = cwd.join(&src_root);
- let tmpdir = cwd.join(self.output_base_name());
+ let tmpdir = cwd.join(self.output_base_name_stage());
if tmpdir.exists() {
self.aggressive_rm_rf(&tmpdir).unwrap();
}
self.revision,
&self.config.compare_mode,
kind);
-
if !path.exists() && self.config.compare_mode.is_some() {
// fallback!
path = expected_output_path(&self.testpaths, self.revision, &None, kind);
}
}
- let expected_output = self.expected_output_path(kind);
- // #50113: output is abspath; only want filename component.
- let expected_output = expected_output.file_name().expect("output path requires file name");
- let output_file = self.output_base_name().with_file_name(&expected_output);
+ let mode = self.config.compare_mode.as_ref().map_or("", |m| m.to_str());
+ let output_file = self.output_base_name()
+ .with_extra_extension(self.revision.unwrap_or(""))
+ .with_extra_extension(mode)
+ .with_extra_extension(kind);
+
match File::create(&output_file).and_then(|mut f| f.write_all(actual.as_bytes())) {
Ok(()) => {}
Err(e) => self.fatal(&format!(
use std::path::Path;
-// See rust-lang/rust#48879: In addition to the mapping from `foo.rs`
-// to `foo.stderr`/`foo.stdout`, we also can optionally have
-// `foo.$mode.stderr`, where $mode is one of the strings on this list,
-// as an alternative to use when running under that mode.
-static COMPARE_MODE_NAMES: [&'static str; 1] = ["nll"];
-
pub fn check(path: &Path, bad: &mut bool) {
super::walk_many(&[&path.join("test/ui"), &path.join("test/ui-fulldeps")],
&mut |_| false,
&mut |file_path| {
if let Some(ext) = file_path.extension() {
- if (ext == "stderr" || ext == "stdout") && !file_path.with_extension("rs").exists() {
-
- // rust-lang/rust#48879: this fn used to be beautful
- // because Path API special-cases replacing
- // extensions. That works great for ".stderr" but not
- // so well for ".nll.stderr". To support the latter,
- // we explicitly search backwards for mode's starting
- // point and build corresponding source name.
- let filename = file_path.file_name().expect("need filename")
- .to_str().expect("need UTF-8 filename");
- let found_matching_prefix = COMPARE_MODE_NAMES.iter().any(|mode| {
- if let Some(r_idx) = filename.rfind(&format!(".{}", mode)) {
- let source_name = format!("{}.rs", &filename[0..r_idx]);
- let source_path = file_path.with_file_name(source_name);
- source_path.exists()
- } else {
- false
- }
- });
-
- if !found_matching_prefix {
+ if ext == "stderr" || ext == "stdout" {
+ // Test output filenames have the format:
+ // $testname.stderr
+ // $testname.$mode.stderr
+ // $testname.$revision.stderr
+ // $testname.$revision.$mode.stderr
+ //
+ // For now, just make sure that there is a corresponding
+ // $testname.rs file.
+ let testname = file_path.file_name().unwrap()
+ .to_str().unwrap()
+ .splitn(2, '.').next().unwrap();
+ if !file_path.with_file_name(testname)
+ .with_extension("rs")
+ .exists() {
println!("Stray file with UI testing output: {:?}", file_path);
*bad = true;
}