"aarch64-linux-android" => "linux-aarch64",
"aarch64-unknown-linux-gnu" => "linux-aarch64",
"aarch64-unknown-linux-musl" => "linux-aarch64",
+ "aarch64-unknown-netbsd" => "BSD-generic64",
"arm-linux-androideabi" => "android",
"arm-unknown-linux-gnueabi" => "linux-armv4",
"arm-unknown-linux-gnueabihf" => "linux-armv4",
/// between the two. Not all byte slices are valid strings, however: strings
/// are required to be valid UTF-8. During this conversion,
/// `from_utf8_lossy()` will replace any invalid UTF-8 sequences with
- /// `U+FFFD REPLACEMENT CHARACTER`, which looks like this: �
+ /// [`U+FFFD REPLACEMENT CHARACTER`][U+FFFD], which looks like this: �
///
/// [`u8`]: ../../std/primitive.u8.html
/// [byteslice]: ../../std/primitive.slice.html
+ /// [U+FFFD]: ../char/constant.REPLACEMENT_CHARACTER.html
///
/// If you are sure that the byte slice is valid UTF-8, and you don't want
/// to incur the overhead of the conversion, there is an unsafe version
}
/// Decode a UTF-16 encoded slice `v` into a `String`, replacing
- /// invalid data with the replacement character (U+FFFD).
+ /// invalid data with [the replacement character (`U+FFFD`)][U+FFFD].
///
/// Unlike [`from_utf8_lossy`] which returns a [`Cow<'a, str>`],
/// `from_utf16_lossy` returns a `String` since the UTF-16 to UTF-8
///
/// [`from_utf8_lossy`]: #method.from_utf8_lossy
/// [`Cow<'a, str>`]: ../borrow/enum.Cow.html
+ /// [U+FFFD]: ../char/constant.REPLACEMENT_CHARACTER.html
///
/// # Examples
///
let len_rounded_up = len.wrapping_add(align).wrapping_sub(1)
& !align.wrapping_sub(1);
- return len_rounded_up.wrapping_sub(len);
+ len_rounded_up.wrapping_sub(len)
}
/// Creates a layout describing the record for `n` instances of
// _l <= layout.size() [guaranteed by usable_size()]
// layout.size() <= new_layout.size() [required by this method]
if new_size <= u {
- return Ok(());
+ Ok(())
} else {
- return Err(CannotReallocInPlace);
+ Err(CannotReallocInPlace)
}
}
// layout.size() <= _u [guaranteed by usable_size()]
// new_layout.size() <= layout.size() [required by this method]
if l <= new_size {
- return Ok(());
+ Ok(())
} else {
- return Err(CannotReallocInPlace);
+ Err(CannotReallocInPlace)
}
}
None
}
},
- EscapeDefaultState::Done => return None,
- EscapeDefaultState::Unicode(ref mut i) => return i.nth(n),
+ EscapeDefaultState::Done => None,
+ EscapeDefaultState::Unicode(ref mut i) => i.nth(n),
}
}
#![feature(lang_items)]
#![feature(link_llvm_intrinsics)]
#![feature(never_type)]
+#![cfg_attr(not(stage0), feature(nll))]
#![feature(exhaustive_patterns)]
#![feature(macro_at_most_once_rep)]
#![feature(no_core)]
// `Int` + `SignedInt` implemented for signed integers
macro_rules! int_impl {
($SelfT:ty, $ActualT:ident, $UnsignedT:ty, $BITS:expr, $Min:expr, $Max:expr, $Feature:expr,
- $EndFeature:expr, $rot:expr, $rot_op:expr, $rot_result:expr) => {
+ $EndFeature:expr, $rot:expr, $rot_op:expr, $rot_result:expr, $swap_op:expr, $swapped:expr,
+ $reversed:expr) => {
doc_comment! {
concat!("Returns the smallest value that can be represented by this integer type.
(self as $UnsignedT).rotate_right(n) as Self
}
}
- /// Reverses the byte order of the integer.
- ///
- /// # Examples
- ///
- /// Please note that this example is shared between integer types.
- /// Which explains why `i16` is used here.
- ///
- /// Basic usage:
- ///
- /// ```
- /// let n: i16 = 0b0000000_01010101;
- /// assert_eq!(n, 85);
- ///
- /// let m = n.swap_bytes();
- ///
- /// assert_eq!(m, 0b01010101_00000000);
- /// assert_eq!(m, 21760);
- /// ```
- #[stable(feature = "rust1", since = "1.0.0")]
- #[rustc_const_unstable(feature = "const_int_ops")]
- #[inline]
- pub const fn swap_bytes(self) -> Self {
- (self as $UnsignedT).swap_bytes() as Self
+ doc_comment! {
+ concat!("Reverses the byte order of the integer.
+
+# Examples
+
+Basic usage:
+
+```
+let n = ", $swap_op, stringify!($SelfT), ";
+
+let m = n.swap_bytes();
+
+assert_eq!(m, ", $swapped, ");
+```"),
+ #[stable(feature = "rust1", since = "1.0.0")]
+ #[rustc_const_unstable(feature = "const_int_ops")]
+ #[inline]
+ pub const fn swap_bytes(self) -> Self {
+ (self as $UnsignedT).swap_bytes() as Self
+ }
}
- /// Reverses the bit pattern of the integer.
- ///
- /// # Examples
- ///
- /// Please note that this example is shared between integer types.
- /// Which explains why `i16` is used here.
- ///
- /// Basic usage:
- ///
- /// ```
- /// #![feature(reverse_bits)]
- ///
- /// let n: i16 = 0b0000000_01010101;
- /// assert_eq!(n, 85);
- ///
- /// let m = n.reverse_bits();
- ///
- /// assert_eq!(m as u16, 0b10101010_00000000);
- /// assert_eq!(m, -22016);
- /// ```
- #[unstable(feature = "reverse_bits", issue = "48763")]
- #[inline]
- pub fn reverse_bits(self) -> Self {
- (self as $UnsignedT).reverse_bits() as Self
+ doc_comment! {
+ concat!("Reverses the bit pattern of the integer.
+
+# Examples
+
+Basic usage:
+
+```
+#![feature(reverse_bits)]
+
+let n = ", $swap_op, stringify!($SelfT), ";
+let m = n.reverse_bits();
+
+assert_eq!(m, ", $reversed, ");
+```"),
+ #[unstable(feature = "reverse_bits", issue = "48763")]
+ #[inline]
+ pub fn reverse_bits(self) -> Self {
+ (self as $UnsignedT).reverse_bits() as Self
+ }
}
doc_comment! {
#[lang = "i8"]
impl i8 {
- int_impl! { i8, i8, u8, 8, -128, 127, "", "", 2, "-0x7e", "0xa" }
+ int_impl! { i8, i8, u8, 8, -128, 127, "", "", 2, "-0x7e", "0xa", "0x12", "0x12", "0x48" }
}
#[lang = "i16"]
impl i16 {
- int_impl! { i16, i16, u16, 16, -32768, 32767, "", "", 4, "-0x5ffd", "0x3a" }
+ int_impl! { i16, i16, u16, 16, -32768, 32767, "", "", 4, "-0x5ffd", "0x3a", "0x1234", "0x3412",
+ "0x2c48" }
}
#[lang = "i32"]
impl i32 {
- int_impl! { i32, i32, u32, 32, -2147483648, 2147483647, "", "", 8, "0x10000b3", "0xb301" }
+ int_impl! { i32, i32, u32, 32, -2147483648, 2147483647, "", "", 8, "0x10000b3", "0xb301",
+ "0x12345678", "0x78563412", "0x1e6a2c48" }
}
#[lang = "i64"]
impl i64 {
int_impl! { i64, i64, u64, 64, -9223372036854775808, 9223372036854775807, "", "", 12,
- "0xaa00000000006e1", "0x6e10aa" }
+ "0xaa00000000006e1", "0x6e10aa", "0x1234567890123456", "0x5634129078563412",
+ "0x6a2c48091e6a2c48" }
}
#[lang = "i128"]
impl i128 {
int_impl! { i128, i128, u128, 128, -170141183460469231731687303715884105728,
170141183460469231731687303715884105727, "", "", 16,
- "0x13f40000000000000000000000004f76", "0x4f7613f4"
+ "0x13f40000000000000000000000004f76", "0x4f7613f4", "0x12345678901234567890123456789012",
+ "0x12907856341290785634129078563412", "0x48091e6a2c48091e6a2c48091e6a2c48"
}
}
#[cfg(target_pointer_width = "16")]
#[lang = "isize"]
impl isize {
- int_impl! { isize, i16, u16, 16, -32768, 32767, "", "", 4, "-0x5ffd", "0x3a" }
+ int_impl! { isize, i16, u16, 16, -32768, 32767, "", "", 4, "-0x5ffd", "0x3a", "0x1234",
+ "0x3412", "0x2c48" }
}
#[cfg(target_pointer_width = "32")]
#[lang = "isize"]
impl isize {
- int_impl! { isize, i32, u32, 32, -2147483648, 2147483647, "", "", 8, "0x10000b3", "0xb301" }
+ int_impl! { isize, i32, u32, 32, -2147483648, 2147483647, "", "", 8, "0x10000b3", "0xb301",
+ "0x12345678", "0x78563412", "0x1e6a2c48" }
}
#[cfg(target_pointer_width = "64")]
#[lang = "isize"]
impl isize {
int_impl! { isize, i64, u64, 64, -9223372036854775808, 9223372036854775807, "", "",
- 12, "0xaa00000000006e1", "0x6e10aa" }
+ 12, "0xaa00000000006e1", "0x6e10aa", "0x1234567890123456", "0x5634129078563412",
+ "0x6a2c48091e6a2c48" }
}
// Emits the correct `cttz` call, depending on the size of the type.
// `Int` + `UnsignedInt` implemented for unsigned integers
macro_rules! uint_impl {
($SelfT:ty, $ActualT:ty, $BITS:expr, $MaxV:expr, $Feature:expr, $EndFeature:expr,
- $rot:expr, $rot_op:expr, $rot_result:expr) => {
+ $rot:expr, $rot_op:expr, $rot_result:expr, $swap_op:expr, $swapped:expr,
+ $reversed:expr ) => {
doc_comment! {
concat!("Returns the smallest value that can be represented by this integer type.
}
}
- /// Reverses the byte order of the integer.
- ///
- /// # Examples
- ///
- /// Basic usage:
- ///
- /// Please note that this example is shared between integer types.
- /// Which explains why `u16` is used here.
- ///
- /// ```
- /// let n: u16 = 0b0000000_01010101;
- /// assert_eq!(n, 85);
- ///
- /// let m = n.swap_bytes();
- ///
- /// assert_eq!(m, 0b01010101_00000000);
- /// assert_eq!(m, 21760);
- /// ```
- #[stable(feature = "rust1", since = "1.0.0")]
- #[rustc_const_unstable(feature = "const_int_ops")]
- #[inline]
- pub const fn swap_bytes(self) -> Self {
- unsafe { intrinsics::bswap(self as $ActualT) as Self }
+ doc_comment! {
+ concat!("
+Reverses the byte order of the integer.
+
+# Examples
+
+Basic usage:
+
+```
+let n = ", $swap_op, stringify!($SelfT), ";
+let m = n.swap_bytes();
+
+assert_eq!(m, ", $swapped, ");
+```"),
+ #[stable(feature = "rust1", since = "1.0.0")]
+ #[rustc_const_unstable(feature = "const_int_ops")]
+ #[inline]
+ pub const fn swap_bytes(self) -> Self {
+ unsafe { intrinsics::bswap(self as $ActualT) as Self }
+ }
}
- /// Reverses the bit pattern of the integer.
- ///
- /// # Examples
- ///
- /// Basic usage:
- ///
- /// Please note that this example is shared between integer types.
- /// Which explains why `u16` is used here.
- ///
- /// ```
- /// #![feature(reverse_bits)]
- ///
- /// let n: u16 = 0b0000000_01010101;
- /// assert_eq!(n, 85);
- ///
- /// let m = n.reverse_bits();
- ///
- /// assert_eq!(m, 0b10101010_00000000);
- /// assert_eq!(m, 43520);
- /// ```
- #[unstable(feature = "reverse_bits", issue = "48763")]
- #[inline]
- pub fn reverse_bits(self) -> Self {
- unsafe { intrinsics::bitreverse(self as $ActualT) as Self }
+ doc_comment! {
+ concat!("Reverses the bit pattern of the integer.
+
+# Examples
+
+Basic usage:
+
+```
+#![feature(reverse_bits)]
+
+let n = ", $swap_op, stringify!($SelfT), ";
+let m = n.reverse_bits();
+
+assert_eq!(m, ", $reversed, ");
+```"),
+ #[unstable(feature = "reverse_bits", issue = "48763")]
+ #[inline]
+ pub fn reverse_bits(self) -> Self {
+ unsafe { intrinsics::bitreverse(self as $ActualT) as Self }
+ }
}
doc_comment! {
#[lang = "u8"]
impl u8 {
- uint_impl! { u8, u8, 8, 255, "", "", 2, "0x82", "0xa" }
+ uint_impl! { u8, u8, 8, 255, "", "", 2, "0x82", "0xa", "0x12", "0x12", "0x48" }
/// Checks if the value is within the ASCII range.
#[lang = "u16"]
impl u16 {
- uint_impl! { u16, u16, 16, 65535, "", "", 4, "0xa003", "0x3a" }
+ uint_impl! { u16, u16, 16, 65535, "", "", 4, "0xa003", "0x3a", "0x1234", "0x3412", "0x2c48" }
}
#[lang = "u32"]
impl u32 {
- uint_impl! { u32, u32, 32, 4294967295, "", "", 8, "0x10000b3", "0xb301" }
+ uint_impl! { u32, u32, 32, 4294967295, "", "", 8, "0x10000b3", "0xb301", "0x12345678",
+ "0x78563412", "0x1e6a2c48" }
}
#[lang = "u64"]
impl u64 {
- uint_impl! { u64, u64, 64, 18446744073709551615, "", "", 12, "0xaa00000000006e1", "0x6e10aa" }
+ uint_impl! { u64, u64, 64, 18446744073709551615, "", "", 12, "0xaa00000000006e1", "0x6e10aa",
+ "0x1234567890123456", "0x5634129078563412", "0x6a2c48091e6a2c48" }
}
#[lang = "u128"]
impl u128 {
uint_impl! { u128, u128, 128, 340282366920938463463374607431768211455, "", "", 16,
- "0x13f40000000000000000000000004f76", "0x4f7613f4" }
+ "0x13f40000000000000000000000004f76", "0x4f7613f4", "0x12345678901234567890123456789012",
+ "0x12907856341290785634129078563412", "0x48091e6a2c48091e6a2c48091e6a2c48" }
}
#[cfg(target_pointer_width = "16")]
#[lang = "usize"]
impl usize {
- uint_impl! { usize, u16, 16, 65536, "", "", 4, "0xa003", "0x3a" }
+ uint_impl! { usize, u16, 16, 65536, "", "", 4, "0xa003", "0x3a", "0x1234", "0x3412", "0x2c48" }
}
#[cfg(target_pointer_width = "32")]
#[lang = "usize"]
impl usize {
- uint_impl! { usize, u32, 32, 4294967295, "", "", 8, "0x10000b3", "0xb301" }
+ uint_impl! { usize, u32, 32, 4294967295, "", "", 8, "0x10000b3", "0xb301", "0x12345678",
+ "0x78563412", "0x1e6a2c48" }
}
#[cfg(target_pointer_width = "64")]
#[lang = "usize"]
impl usize {
- uint_impl! { usize, u64, 64, 18446744073709551615, "", "", 12, "0xaa00000000006e1",
- "0x6e10aa" }
+ uint_impl! { usize, u64, 64, 18446744073709551615, "", "", 12, "0xaa00000000006e1", "0x6e10aa",
+ "0x1234567890123456", "0x5634129078563412", "0x6a2c48091e6a2c48" }
}
/// A classification of floating point numbers.
let table_inverse = INV_TABLE_MOD_16[(x & (INV_TABLE_MOD - 1)) >> 1];
if m <= INV_TABLE_MOD {
- return table_inverse & (m - 1);
+ table_inverse & (m - 1)
} else {
// We iterate "up" using the following formula:
//
}
// Cannot be aligned at all.
- return usize::max_value();
+ usize::max_value()
}
ctz_b = ::intrinsics::cttz_nonzero(b);
}
}
- return a << k;
+ a << k
}
let gcd: usize = gcd(::mem::size_of::<T>(), ::mem::size_of::<U>());
let ts: usize = ::mem::size_of::<U>() / gcd;
let us_len = self.len() / ts * us;
// And how many `T`s will be in the trailing slice!
let ts_len = self.len() % ts;
- return (us_len, ts_len);
+ (us_len, ts_len)
}
/// Transmute the slice to a slice of another type, ensuring aligment of the types is
let ptr = self.as_ptr();
let offset = ::ptr::align_offset(ptr, ::mem::align_of::<U>());
if offset > self.len() {
- return (self, &[], &[]);
+ (self, &[], &[])
} else {
let (left, rest) = self.split_at(offset);
let (us_len, ts_len) = rest.align_to_offsets::<U>();
- return (left,
- from_raw_parts(rest.as_ptr() as *const U, us_len),
- from_raw_parts(rest.as_ptr().offset((rest.len() - ts_len) as isize), ts_len))
+ (left,
+ from_raw_parts(rest.as_ptr() as *const U, us_len),
+ from_raw_parts(rest.as_ptr().offset((rest.len() - ts_len) as isize), ts_len))
}
}
let ptr = self.as_ptr();
let offset = ::ptr::align_offset(ptr, ::mem::align_of::<U>());
if offset > self.len() {
- return (self, &mut [], &mut []);
+ (self, &mut [], &mut [])
} else {
let (left, rest) = self.split_at_mut(offset);
let (us_len, ts_len) = rest.align_to_offsets::<U>();
let mut_ptr = rest.as_mut_ptr();
- return (left,
- from_raw_parts_mut(mut_ptr as *mut U, us_len),
- from_raw_parts_mut(mut_ptr.offset((rest.len() - ts_len) as isize), ts_len))
+ (left,
+ from_raw_parts_mut(mut_ptr as *mut U, us_len),
+ from_raw_parts_mut(mut_ptr.offset((rest.len() - ts_len) as isize), ts_len))
}
}
}
broken: &[],
};
self.source = &[];
- return Some(r);
+ Some(r)
}
}
/// The length provided is that of the invalid byte sequence
/// that starts at the index given by `valid_up_to()`.
/// Decoding should resume after that sequence
- /// (after inserting a U+FFFD REPLACEMENT CHARACTER) in case of lossy decoding.
+ /// (after inserting a [`U+FFFD REPLACEMENT CHARACTER`][U+FFFD]) in case of
+ /// lossy decoding.
+ ///
+ /// [U+FFFD]: ../../std/char/constant.REPLACEMENT_CHARACTER.html
#[stable(feature = "utf8_error_error_len", since = "1.20.0")]
pub fn error_len(&self) -> Option<usize> {
self.error_len.map(|len| len as usize)
#[unstable(feature = "str_internals", issue = "0")]
#[inline]
pub fn utf8_char_width(b: u8) -> usize {
- return UTF8_CHAR_WIDTH[b as usize] as usize;
+ UTF8_CHAR_WIDTH[b as usize] as usize
}
/// Mask of the value bits of a continuation byte.
test(no_crate_inject, attr(deny(warnings))),
test(attr(allow(dead_code, deprecated, unused_variables, unused_mut))))]
+#![cfg_attr(not(stage0), feature(nll))]
#![feature(rustc_private)]
#![feature(staged_api)]
#![feature(lang_items)]
reason = "internal implementation detail of rustc right now",
issue = "0")]
#![allow(unused_features)]
+#![cfg_attr(not(stage0), feature(nll))]
#![feature(staged_api)]
self.projection_cache
.borrow_mut()
- .commit(projection_cache_snapshot);
+ .commit(&projection_cache_snapshot);
self.type_variables
.borrow_mut()
.commit(type_snapshot);
debug!("process_registered_region_obligations()");
// pull out the region obligations with the given `body_id` (leaving the rest)
- let my_region_obligations = {
+ let mut my_region_obligations = Vec::with_capacity(self.region_obligations.borrow().len());
+ {
let mut r_o = self.region_obligations.borrow_mut();
- let my_r_o = r_o.drain_filter(|(ro_body_id, _)| *ro_body_id == body_id)
- .map(|(_, obligation)| obligation).collect::<Vec<_>>();
- my_r_o
- };
+ my_region_obligations.extend(
+ r_o.drain_filter(|(ro_body_id, _)| *ro_body_id == body_id)
+ .map(|(_, obligation)| obligation)
+ );
+ }
let outlives = &mut TypeOutlives::new(
self,
#![feature(never_type)]
#![feature(exhaustive_patterns)]
#![feature(extern_types)]
+#![cfg_attr(not(stage0), feature(nll))]
#![feature(non_exhaustive)]
#![feature(proc_macro_internals)]
#![feature(quote)]
debug!("normalize_projection_type(projection_ty={:?})",
projection_ty);
- assert!(!projection_ty.has_escaping_regions());
+ debug_assert!(!projection_ty.has_escaping_regions());
// FIXME(#20304) -- cache
if !is_default {
true
} else if obligation.param_env.reveal == Reveal::All {
- assert!(!poly_trait_ref.needs_infer());
+ debug_assert!(!poly_trait_ref.needs_infer());
if !poly_trait_ref.needs_subst() {
true
} else {
}
pub fn rollback_to(&mut self, snapshot: ProjectionCacheSnapshot) {
- self.map.rollback_to(snapshot.snapshot);
+ self.map.rollback_to(&snapshot.snapshot);
}
pub fn rollback_skolemized(&mut self, snapshot: &ProjectionCacheSnapshot) {
self.map.partial_rollback(&snapshot.snapshot, &|k| k.ty.has_re_skol());
}
- pub fn commit(&mut self, snapshot: ProjectionCacheSnapshot) {
- self.map.commit(snapshot.snapshot);
+ pub fn commit(&mut self, snapshot: &ProjectionCacheSnapshot) {
+ self.map.commit(&snapshot.snapshot);
}
/// Try to start normalize `key`; returns an error if
pub fn select(&mut self, obligation: &TraitObligation<'tcx>)
-> SelectionResult<'tcx, Selection<'tcx>> {
debug!("select({:?})", obligation);
- assert!(!obligation.predicate.has_escaping_regions());
+ debug_assert!(!obligation.predicate.has_escaping_regions());
let stack = self.push_stack(TraitObligationStackList::empty(), obligation);
match obligation.predicate {
ty::Predicate::Trait(ref t) => {
- assert!(!t.has_escaping_regions());
+ debug_assert!(!t.has_escaping_regions());
let obligation = obligation.with(t.clone());
self.evaluate_trait_predicate_recursively(previous_stack, obligation)
}
debug!("candidate_from_obligation(cache_fresh_trait_pred={:?}, obligation={:?})",
cache_fresh_trait_pred,
stack);
- assert!(!stack.obligation.predicate.has_escaping_regions());
+ debug_assert!(!stack.obligation.predicate.has_escaping_regions());
if let Some(c) = self.check_candidate_cache(stack.obligation.param_env,
&cache_fresh_trait_pred) {
snapshot: &infer::CombinedSnapshot<'cx, 'tcx>)
-> bool
{
- assert!(!skol_trait_ref.has_escaping_regions());
+ debug_assert!(!skol_trait_ref.has_escaping_regions());
if self.infcx.at(&obligation.cause, obligation.param_env)
.sup(ty::Binder::dummy(skol_trait_ref), trait_bound).is_err() {
return false;
use std::fmt;
use rustc_target::spec::abi;
use syntax::ast;
-use errors::DiagnosticBuilder;
+use errors::{Applicability, DiagnosticBuilder};
use syntax_pos::Span;
use hir;
db.note("no two closures, even if identical, have the same type");
db.help("consider boxing your closure and/or using it as a trait object");
}
+ match (&values.found.sty, &values.expected.sty) { // Issue #53280
+ (ty::TyInfer(ty::IntVar(_)), ty::TyFloat(_)) => {
+ if let Ok(snippet) = self.sess.codemap().span_to_snippet(sp) {
+ if snippet.chars().all(|c| c.is_digit(10) || c == '-' || c == '_') {
+ db.span_suggestion_with_applicability(
+ sp,
+ "use a float literal",
+ format!("{}.0", snippet),
+ Applicability::MachineApplicable
+ );
+ }
+ }
+ },
+ _ => {}
+ }
},
OldStyleLUB(err) => {
db.note("this was previously accepted by the compiler but has been phased out");
let univariant = |fields: &[TyLayout], repr: &ReprOptions, kind| {
Ok(tcx.intern_layout(univariant_uninterned(fields, repr, kind)?))
};
- assert!(!ty.has_infer_types());
+ debug_assert!(!ty.has_infer_types());
Ok(match ty.sty {
// Basic scalars.
tcx: TyCtxt<'a, 'tcx, 'tcx>,
param_env: ty::ParamEnv<'tcx>)
-> Result<SizeSkeleton<'tcx>, LayoutError<'tcx>> {
- assert!(!ty.has_infer_types());
+ debug_assert!(!ty.has_infer_types());
// First try computing a static layout.
let err = match tcx.layout_of(param_env.and(ty)) {
let tail = tcx.struct_tail(pointee);
match tail.sty {
ty::TyParam(_) | ty::TyProjection(_) => {
- assert!(tail.has_param_types() || tail.has_self_ty());
+ debug_assert!(tail.has_param_types() || tail.has_self_ty());
Ok(SizeSkeleton::Pointer {
non_zero,
tail: tcx.erase_regions(&tail)
pub fn with_self_ty(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, self_ty: Ty<'tcx>)
-> ty::TraitRef<'tcx> {
// otherwise the escaping regions would be captured by the binder
- assert!(!self_ty.has_escaping_regions());
+ debug_assert!(!self_ty.has_escaping_regions());
ty::TraitRef {
def_id: self.def_id,
pub fn dummy<'tcx>(value: T) -> Binder<T>
where T: TypeFoldable<'tcx>
{
- assert!(!value.has_escaping_regions());
+ debug_assert!(!value.has_escaping_regions());
Binder(value)
}
-> ty::ProjectionPredicate<'tcx>
{
// otherwise the escaping regions would be captured by the binders
- assert!(!self_ty.has_escaping_regions());
+ debug_assert!(!self_ty.has_escaping_regions());
ty::ProjectionPredicate {
projection_ty: ty::ProjectionTy {
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+#![cfg_attr(not(stage0), feature(nll))]
#![feature(rustc_private)]
#[macro_use] extern crate log;
#![feature(in_band_lifetimes)]
#![allow(unused_attributes)]
#![feature(libc)]
+#![cfg_attr(not(stage0), feature(nll))]
#![feature(quote)]
#![feature(range_contains)]
#![feature(rustc_diagnostic_macros)]
-> LLVMRustResult;
pub fn LLVMRustArchiveMemberNew(Filename: *const c_char,
Name: *const c_char,
- Child: Option<&'a ArchiveChild>)
+ Child: Option<&ArchiveChild<'a>>)
-> &'a mut RustArchiveMember<'a>;
pub fn LLVMRustArchiveMemberFree(Member: &'a mut RustArchiveMember<'a>);
Type::struct_(cx, &[fill], packed)
}
Some(ref name) => {
- let mut llty = Type::named_struct(cx, name);
+ let llty = Type::named_struct(cx, name);
llty.set_struct_body(&[fill], packed);
llty
}
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(custom_attribute)]
+#![cfg_attr(not(stage0), feature(nll))]
#![allow(unused_attributes)]
#![feature(quote)]
#![feature(rustc_diagnostic_macros)]
pub const ALPHANUMERIC_ONLY: usize = 62;
pub const CASE_INSENSITIVE: usize = 36;
-const BASE_64: &'static [u8; MAX_BASE as usize] =
+const BASE_64: &[u8; MAX_BASE as usize] =
b"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@$";
#[inline]
break;
}
}
- &mut s[0..index].reverse();
+ s[0..index].reverse();
+
output.push_str(str::from_utf8(&s[0..index]).unwrap());
}
let word = bit / word_bits;
let bit_in_word = bit % word_bits;
let bit_mask = 1 << bit_in_word;
- BitLookup { word: word, bit_in_word: bit_in_word, bit_mask: bit_mask }
+ BitLookup { word, bit_in_word, bit_mask }
}
pub fn bits_to_string(words: &[Word], bits: usize) -> String {
sep = '|';
}
result.push(']');
- return result
+
+ result
}
#[inline]
self.current >>= offset;
self.current >>= 1; // shift otherwise overflows for 0b1000_0000_…_0000
self.idx += offset + 1;
- return Some(C::new(self.idx - 1));
+
+ Some(C::new(self.idx - 1))
}
fn size_hint(&self) -> (usize, Option<usize>) {
let v1 = vector[write_index];
let v2 = v1 | vector[read_index];
vector[write_index] = v2;
- changed = changed | (v1 != v2);
+ changed |= v1 != v2;
}
changed
}
type ULONG_PTR = usize;
type LPOVERLAPPED = *mut OVERLAPPED;
- const LOCKFILE_EXCLUSIVE_LOCK: DWORD = 0x00000002;
- const LOCKFILE_FAIL_IMMEDIATELY: DWORD = 0x00000001;
+ const LOCKFILE_EXCLUSIVE_LOCK: DWORD = 0x0000_0002;
+ const LOCKFILE_FAIL_IMMEDIATELY: DWORD = 0x0000_0001;
const FILE_SHARE_DELETE: DWORD = 0x4;
const FILE_SHARE_READ: DWORD = 0x1;
node2 = immediate_dominators[node2].unwrap();
}
}
- return node1;
+
+ node1
}
#[derive(Clone, Debug)]
impl NodeIndex {
/// Returns unique id (unique with respect to the graph holding associated node).
- pub fn node_id(&self) -> usize {
+ pub fn node_id(self) -> usize {
self.0
}
}
self.nodes[source.0].first_edge[OUTGOING.repr] = idx;
self.nodes[target.0].first_edge[INCOMING.repr] = idx;
- return idx;
+ idx
}
pub fn edge(&self, idx: EdgeIndex) -> &Edge<E> {
DepthFirstTraversal::with_start_node(self, start, direction)
}
- pub fn nodes_in_postorder<'a>(
- &'a self,
+ pub fn nodes_in_postorder(
+ &self,
direction: Direction,
entry_node: NodeIndex,
) -> Vec<NodeIndex> {
// pnkfelix wants to have this be `IdxSet<T>([Word]) and then pass
// around `&mut IdxSet<T>` or `&IdxSet<T>`.
-//
-// WARNING: Mapping a `&IdxSetBuf<T>` to `&IdxSet<T>` (at least today)
-// requires a transmute relying on representation guarantees that may
-// not hold in the future.
/// Represents a set (or packed family of sets), of some element type
/// E, where each E is identified by some unique index type `T`.
///
/// In other words, `T` is the type used to index into the bitslice
/// this type uses to represent the set of object it holds.
+#[repr(transparent)]
pub struct IdxSet<T: Idx> {
_pd: PhantomData<fn(&T)>,
bits: [Word],
impl<T: Idx> IdxSet<T> {
unsafe fn from_slice(s: &[Word]) -> &Self {
- mem::transmute(s) // (see above WARNING)
+ &*(s as *const [Word] as *const Self)
}
unsafe fn from_slice_mut(s: &mut [Word]) -> &mut Self {
- mem::transmute(s) // (see above WARNING)
+ &mut *(s as *mut [Word] as *mut Self)
}
}
#[test]
fn test_new_filled() {
for i in 0..128 {
- let mut idx_buf = IdxSetBuf::new_filled(i);
+ let idx_buf = IdxSetBuf::new_filled(i);
let elems: Vec<usize> = idx_buf.iter().collect();
let expected: Vec<usize> = (0..i).collect();
assert_eq!(elems, expected);
#![feature(specialization)]
#![feature(optin_builtin_traits)]
#![feature(macro_vis_matcher)]
+#![cfg_attr(not(stage0), feature(nll))]
#![feature(allow_internal_unstable)]
#![feature(vec_resize_with)]
}
let mut kill_list = vec![];
- for (predicate, index) in self.waiting_cache.iter_mut() {
+ for (predicate, index) in &mut self.waiting_cache {
let new_index = node_rewrites[index.get()];
if new_index >= nodes_len {
kill_list.push(predicate.clone());
A::Element: Decodable {
fn decode<D: Decoder>(d: &mut D) -> Result<SmallVec<A>, D::Error> {
d.read_seq(|d, len| {
- (0..len).map(|i| d.read_seq_elt(i, |d| Decodable::decode(d))).collect()
+ let mut vec = SmallVec::with_capacity(len);
+ // FIXME(#48994) - could just be collected into a Result<SmallVec, D::Error>
+ for i in 0..len {
+ vec.push(d.read_seq_elt(i, |d| Decodable::decode(d))?);
+ }
+ Ok(vec)
})
}
}
pub fn snapshot(&mut self) -> Snapshot {
self.undo_log.push(UndoLog::OpenSnapshot);
let len = self.undo_log.len() - 1;
- Snapshot { len: len }
+ Snapshot { len }
}
fn assert_open_snapshot(&self, snapshot: &Snapshot) {
});
}
- pub fn commit(&mut self, snapshot: Snapshot) {
- self.assert_open_snapshot(&snapshot);
+ pub fn commit(&mut self, snapshot: &Snapshot) {
+ self.assert_open_snapshot(snapshot);
if snapshot.len == 0 {
// The root snapshot.
self.undo_log.truncate(0);
}
}
- pub fn rollback_to(&mut self, snapshot: Snapshot) {
- self.assert_open_snapshot(&snapshot);
+ pub fn rollback_to(&mut self, snapshot: &Snapshot) {
+ self.assert_open_snapshot(snapshot);
while self.undo_log.len() > snapshot.len + 1 {
let entry = self.undo_log.pop().unwrap();
self.reverse(entry);
map.insert(44, "fourty-four");
assert_eq!(map[&44], "fourty-four");
assert_eq!(map.get(&33), None);
- map.rollback_to(snapshot);
+ map.rollback_to(&snapshot);
assert_eq!(map[&22], "twenty-two");
assert_eq!(map.get(&33), None);
assert_eq!(map.get(&44), None);
map.insert(22, "twenty-two");
let snapshot1 = map.snapshot();
let _snapshot2 = map.snapshot();
- map.rollback_to(snapshot1);
+ map.rollback_to(&snapshot1);
}
#[test]
let snapshot1 = map.snapshot();
let snapshot2 = map.snapshot();
map.insert(22, "thirty-three");
- map.commit(snapshot2);
+ map.commit(&snapshot2);
assert_eq!(map[&22], "thirty-three");
- map.rollback_to(snapshot1);
+ map.rollback_to(&snapshot1);
assert_eq!(map[&22], "twenty-two");
}
};
self.next = new_next;
- return true
+
+ true
}
fn len(&self) -> usize {
..
} = self;
- map.entry(a.clone())
+ *map.entry(a.clone())
.or_insert_with(|| {
elements.push(a);
Index(elements.len() - 1)
})
- .clone()
}
/// Applies the (partial) function to each edge and returns a new
{
let mut result = TransitiveRelation::new();
for edge in &self.edges {
- let r = f(&self.elements[edge.source.0]).and_then(|source| {
+ f(&self.elements[edge.source.0]).and_then(|source| {
f(&self.elements[edge.target.0]).and_then(|target| {
- Some(result.add(source, target))
+ result.add(source, target);
+ Some(())
})
- });
- if r.is_none() {
- return None;
- }
+ })?;
}
Some(result)
}
let mut changed = true;
while changed {
changed = false;
- for edge in self.edges.iter() {
+ for edge in &self.edges {
// add an edge from S -> T
changed |= matrix.add(edge.source.0, edge.target.0);
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+#![cfg_attr(not(stage0), feature(nll))]
#![feature(static_nobundle)]
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
#![sanitizer_runtime]
#![feature(alloc_system)]
+#![cfg_attr(not(stage0), feature(nll))]
#![feature(sanitizer_runtime)]
#![feature(staged_api)]
#![no_std]
*/
+#![cfg_attr(not(stage0), feature(nll))]
#![feature(infer_outlives_requirements)]
#![feature(in_band_lifetimes)]
#![feature(slice_patterns)]
#![sanitizer_runtime]
#![feature(alloc_system)]
+#![cfg_attr(not(stage0), feature(nll))]
#![feature(sanitizer_runtime)]
#![feature(staged_api)]
#![no_std]
```
"##,
+E0642: r##"
+Trait methods currently cannot take patterns as arguments.
+
+Example of erroneous code:
+
+```compile_fail,E0642
+trait Foo {
+ fn foo((x, y): (i32, i32)); // error: patterns aren't allowed
+ // in trait methods
+}
+```
+
+You can instead use a single name for the argument:
+
+```
+trait Foo {
+ fn foo(x_and_y: (i32, i32)); // ok!
+}
+```
+"##,
+
E0695: r##"
A `break` statement without a label appeared inside a labeled block.
E0561, // patterns aren't allowed in function pointer types
E0567, // auto traits can not have generic parameters
E0568, // auto traits can not have super traits
- E0642, // patterns aren't allowed in methods without bodies
E0666, // nested `impl Trait` is illegal
E0667, // `impl Trait` in projections
E0696, // `continue` pointing to a labeled block
#![allow(bad_style)]
+#![cfg_attr(not(stage0), feature(nll))]
+
pub struct Intrinsic {
pub inputs: &'static [&'static Type],
pub output: &'static Type,
--- /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.
+
+use spec::{LinkerFlavor, Target, TargetResult};
+
+pub fn target() -> TargetResult {
+ let mut base = super::netbsd_base::opts();
+ base.max_atomic_width = Some(128);
+ base.abi_blacklist = super::arm_base::abi_blacklist();
+
+ Ok(Target {
+ llvm_target: "aarch64-unknown-netbsd".to_string(),
+ target_endian: "little".to_string(),
+ target_pointer_width: "64".to_string(),
+ target_c_int_width: "32".to_string(),
+ data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(),
+ arch: "aarch64".to_string(),
+ target_os: "netbsd".to_string(),
+ target_env: "".to_string(),
+ target_vendor: "unknown".to_string(),
+ linker_flavor: LinkerFlavor::Gcc,
+ options: base,
+ })
+}
("i686-unknown-openbsd", i686_unknown_openbsd),
("x86_64-unknown-openbsd", x86_64_unknown_openbsd),
+ ("aarch64-unknown-netbsd", aarch64_unknown_netbsd),
("armv6-unknown-netbsd-eabihf", armv6_unknown_netbsd_eabihf),
("armv7-unknown-netbsd-eabihf", armv7_unknown_netbsd_eabihf),
("i686-unknown-netbsd", i686_unknown_netbsd),
#![feature(crate_visibility_modifier)]
#![feature(exhaustive_patterns)]
#![feature(iterator_find_map)]
+#![cfg_attr(not(stage0), feature(nll))]
#![feature(quote)]
#![feature(refcell_replace_swap)]
#![feature(rustc_diagnostic_macros)]
if (hash !== null) {
var elem = document.getElementById(hash);
if (elem && elem.offsetParent === null) {
- console.log(elem, elem.parentNode);
if (elem.parentNode && elem.parentNode.previousSibling) {
var collapses = elem.parentNode
.previousSibling
color: #ddd;
}
-.docblock a:not(.srclink):not(.test-arrow), .docblock-short a:not(.srclink):not(.test-arrow),
-.stability a {
+.docblock:not(.type-decl) a:not(.srclink):not(.test-arrow), .docblock-short
+a:not(.srclink):not(.test-arrow), .stability a {
color: #D2991D;
}
color: #000;
}
-.docblock a:not(.srclink):not(.test-arrow), .docblock-short a:not(.srclink):not(.test-arrow),
-.stability a {
+.docblock:not(.type-decl) a:not(.srclink):not(.test-arrow), .docblock-short
+a:not(.srclink):not(.test-arrow), .stability a {
color: #3873AD;
}
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(iterator_find_map)]
+#![cfg_attr(not(stage0), feature(nll))]
#![feature(set_stdio)]
#![feature(slice_sort_by_cached_key)]
#![feature(test)]
#![feature(core_intrinsics)]
#![feature(specialization)]
#![feature(never_type)]
+#![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(test, feature(test))]
pub use self::serialize::{Decoder, Encoder, Decodable, Encodable};
/// If the contents of the `CStr` are valid UTF-8 data, this
/// function will return a [`Cow`]`::`[`Borrowed`]`(`[`&str`]`)`
/// with the the corresponding [`&str`] slice. Otherwise, it will
- /// replace any invalid UTF-8 sequences with `U+FFFD REPLACEMENT
- /// CHARACTER` and return a [`Cow`]`::`[`Owned`]`(`[`String`]`)`
- /// with the result.
+ /// replace any invalid UTF-8 sequences with
+ /// [`U+FFFD REPLACEMENT CHARACTER`][U+FFFD] and return a
+ /// [`Cow`]`::`[`Owned`]`(`[`String`]`)` with the result.
///
/// > **Note**: This method is currently implemented to check for validity
/// > after a constant-time cast, but it is planned to alter its definition
/// [`Owned`]: ../borrow/enum.Cow.html#variant.Owned
/// [`str`]: ../primitive.str.html
/// [`String`]: ../string/struct.String.html
+ /// [U+FFFD]: ../char/constant.REPLACEMENT_CHARACTER.html
///
/// # Examples
///
/// Converts an `OsStr` to a [`Cow`]`<`[`str`]`>`.
///
- /// Any non-Unicode sequences are replaced with U+FFFD REPLACEMENT CHARACTER.
+ /// Any non-Unicode sequences are replaced with
+ /// [`U+FFFD REPLACEMENT CHARACTER`][U+FFFD].
///
/// [`Cow`]: ../../std/borrow/enum.Cow.html
/// [`str`]: ../../std/primitive.str.html
+ /// [U+FFFD]: ../../std/char/constant.REPLACEMENT_CHARACTER.html
///
/// # Examples
///
-// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// 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.
//
///
/// [book]: https://doc.rust-lang.org/book/second-edition/ch03-03-how-functions-work.html
mod fn_keyword { }
+
+#[doc(keyword = "let")]
+//
+/// The `let` keyword.
+///
+/// The `let` keyword is used to declare a variable.
+///
+/// Example:
+///
+/// ```rust
+/// # #![allow(unused_assignments)]
+/// let x = 3; // We create a variable named `x` with the value `3`.
+/// ```
+///
+/// By default, all variables are **not** mutable. If you want a mutable variable,
+/// you'll have to use the `mut` keyword.
+///
+/// Example:
+///
+/// ```rust
+/// # #![allow(unused_assignments)]
+/// let mut x = 3; // We create a mutable variable named `x` with the value `3`.
+///
+/// x += 4; // `x` is now equal to `7`.
+/// ```
+///
+/// For more information about the `let` keyword, take a look at the [Rust Book][book].
+///
+/// [book]: https://doc.rust-lang.org/book/second-edition/ch03-01-variables-and-mutability.html
+mod let_keyword { }
#![feature(macro_vis_matcher)]
#![feature(needs_panic_runtime)]
#![feature(never_type)]
+#![cfg_attr(not(stage0), feature(nll))]
#![feature(exhaustive_patterns)]
#![feature(on_unimplemented)]
#![feature(optin_builtin_traits)]
all(target_os = "android", any(target_arch = "aarch64",
target_arch = "arm")),
all(target_os = "l4re", target_arch = "x86_64"),
- all(target_os = "netbsd", any(target_arch = "arm",
+ all(target_os = "netbsd", any(target_arch = "aarch64",
+ target_arch = "arm",
target_arch = "powerpc")),
all(target_os = "openbsd", target_arch = "aarch64"),
all(target_os = "fuchsia", target_arch = "aarch64")))]
all(target_os = "android", any(target_arch = "aarch64",
target_arch = "arm")),
all(target_os = "l4re", target_arch = "x86_64"),
- all(target_os = "netbsd", any(target_arch = "arm",
+ all(target_os = "netbsd", any(target_arch = "aarch64",
+ target_arch = "arm",
target_arch = "powerpc")),
all(target_os = "openbsd", target_arch = "aarch64"),
all(target_os = "fuchsia", target_arch = "aarch64"))))]
/// Converts a `Path` to a [`Cow<str>`].
///
- /// Any non-Unicode sequences are replaced with U+FFFD REPLACEMENT CHARACTER.
+ /// Any non-Unicode sequences are replaced with
+ /// [`U+FFFD REPLACEMENT CHARACTER`][U+FFFD].
///
/// [`Cow<str>`]: ../borrow/enum.Cow.html
+ /// [U+FFFD]: ../char/constant.REPLACEMENT_CHARACTER.html
///
/// # Examples
///
///
/// let hello = output.stdout;
/// ```
+///
+/// `Command` can be reused to spawn multiple processes. The builder methods
+/// change the command without needing to immediately spawn the process.
+///
+/// ```no_run
+/// use std::process::Command;
+///
+/// let mut echo_hello = Command::new("sh");
+/// echo_hello.arg("-c")
+/// .arg("echo hello");
+/// let hello_1 = echo_hello.output().expect("failed to execute process");
+/// let hello_2 = echo_hello.output().expect("failed to execute process");
+/// ```
+///
+/// Similarly, you can call builder methods after spawning a process and then
+/// spawn a new process with the modified settings.
+///
+/// ```no_run
+/// use std::process::Command;
+///
+/// let mut list_dir = Command::new("ls");
+///
+/// // Execute `ls` in the current directory of the program.
+/// list_dir.status().expect("process failed to execute");
+///
+/// println!("");
+///
+/// // Change `ls` to execute in the root directory.
+/// list_dir.current_dir("/");
+///
+/// // And then execute `ls` again but in the root directory.
+/// list_dir.status().expect("process failed to execute");
+/// ```
#[stable(feature = "process", since = "1.0.0")]
pub struct Command {
inner: imp::Command,
//!
//! If Rust code *does* need to look into those strings, it can
//! convert them to valid UTF-8, possibly lossily, by substituting
-//! invalid sequences with U+FFFD REPLACEMENT CHARACTER, as is
+//! invalid sequences with [`U+FFFD REPLACEMENT CHARACTER`][U+FFFD], as is
//! conventionally done in other Rust APIs that deal with string
//! encodings.
//!
//! [`from_wide`]: trait.OsStringExt.html#tymethod.from_wide
//! [`encode_wide`]: trait.OsStrExt.html#tymethod.encode_wide
//! [`collect`]: ../../../iter/trait.Iterator.html#method.collect
+//! [U+FFFD]: ../../../char/constant.REPLACEMENT_CHARACTER.html
#![stable(feature = "rust1", since = "1.0.0")]
PatKind::Slice(pats, None, _) if pats.len() == 1 =>
pats[0].to_ty().map(TyKind::Slice)?,
PatKind::Tuple(pats, None) => {
- let tys = pats.iter().map(|pat| pat.to_ty()).collect::<Option<Vec<_>>>()?;
+ let mut tys = Vec::with_capacity(pats.len());
+ // FIXME(#48994) - could just be collected into an Option<Vec>
+ for pat in pats {
+ tys.push(pat.to_ty()?);
+ }
TyKind::Tup(tys)
}
_ => return None,
#![feature(crate_visibility_modifier)]
#![feature(macro_at_most_once_rep)]
+#![cfg_attr(not(stage0), feature(nll))]
#![feature(rustc_attrs)]
#![feature(rustc_diagnostic_macros)]
#![feature(slice_sort_by_cached_key)]
#![feature(str_escape)]
#![feature(unicode_internals)]
+#![feature(catch_expr)]
#![recursion_limit="256"]
use {ast, attr};
use codemap::{self, CodeMap, Spanned, respan};
use syntax_pos::{self, Span, MultiSpan, BytePos, FileName, edition::Edition};
-use errors::{self, Applicability, DiagnosticBuilder};
+use errors::{self, Applicability, DiagnosticBuilder, DiagnosticId};
use parse::{self, SeqSep, classify, token};
use parse::lexer::TokenAndSpan;
use parse::lexer::comments::{doc_comment_style, strip_doc_comment_decoration};
let ident = self.parse_ident()?;
let mut generics = self.parse_generics()?;
- let d = self.parse_fn_decl_with_self(|p: &mut Parser<'a>|{
+ let d = self.parse_fn_decl_with_self(|p: &mut Parser<'a>| {
// This is somewhat dubious; We don't want to allow
// argument names to be left off if there is a
// definition...
(pat, self.parse_ty()?)
} else {
debug!("parse_arg_general ident_to_pat");
- let ident = Ident::new(keywords::Invalid.name(), self.prev_span);
- let ty = self.parse_ty()?;
- let pat = P(Pat {
- id: ast::DUMMY_NODE_ID,
- node: PatKind::Ident(BindingMode::ByValue(Mutability::Immutable), ident, None),
- span: ty.span,
- });
- (pat, ty)
+
+ let parser_snapshot_before_pat = self.clone();
+
+ // We're going to try parsing the argument as a pattern (even though it's not
+ // allowed). This way we can provide better errors to the user.
+ let pat_arg: PResult<'a, _> = do catch {
+ let pat = self.parse_pat()?;
+ self.expect(&token::Colon)?;
+ (pat, self.parse_ty()?)
+ };
+
+ match pat_arg {
+ Ok((pat, ty)) => {
+ let mut err = self.diagnostic().struct_span_err_with_code(
+ pat.span,
+ "patterns aren't allowed in methods without bodies",
+ DiagnosticId::Error("E0642".into()),
+ );
+ err.span_suggestion_short_with_applicability(
+ pat.span,
+ "give this argument a name or use an underscore to ignore it",
+ "_".to_owned(),
+ Applicability::MachineApplicable,
+ );
+ err.emit();
+ // Pretend the pattern is `_`, to avoid duplicate errors from AST validation.
+ let pat = P(Pat {
+ node: PatKind::Wild,
+ span: pat.span,
+ id: ast::DUMMY_NODE_ID
+ });
+ (pat, ty)
+ }
+ Err(mut err) => {
+ err.cancel();
+ // Recover from attempting to parse the argument as a pattern. This means
+ // the type is alone, with no name, e.g. `fn foo(u32)`.
+ mem::replace(self, parser_snapshot_before_pat);
+ debug!("parse_arg_general ident_to_pat");
+ let ident = Ident::new(keywords::Invalid.name(), self.prev_span);
+ let ty = self.parse_ty()?;
+ let pat = P(Pat {
+ id: ast::DUMMY_NODE_ID,
+ node: PatKind::Ident(
+ BindingMode::ByValue(Mutability::Immutable), ident, None),
+ span: ty.span,
+ });
+ (pat, ty)
+ }
+ }
};
- Ok(Arg {
- ty,
- pat,
- id: ast::DUMMY_NODE_ID,
- })
+ Ok(Arg { ty, pat, id: ast::DUMMY_NODE_ID })
}
/// Parse a single function argument
GenericParamKind::Type { .. } => {
// I don't think this can be moved out of the loop, since
// a GenericBound requires an ast id
- let mut bounds: Vec<_> =
+ let bounds: Vec<_> =
// extra restrictions on the generics parameters to the
// type being derived upon
self.additional_bounds.iter().map(|p| {
#![feature(proc_macro_internals)]
#![feature(decl_macro)]
+#![cfg_attr(not(stage0), feature(nll))]
#![feature(str_escape)]
#![feature(rustc_diagnostic_macros)]
#![feature(asm)]
#![feature(fnbox)]
#![cfg_attr(any(unix, target_os = "cloudabi"), feature(libc))]
+#![cfg_attr(not(stage0), feature(nll))]
#![feature(set_stdio)]
#![feature(panic_unwind)]
#![feature(staged_api)]
# Compiler Test Documentation
-In the Rust project, we use a special set of commands embedded in
-comments to test the Rust compiler. There are two groups of commands:
-
-1. Header commands
-2. Error info commands
-
-Both types of commands are inside comments, but header commands should
-be in a comment before any code.
-
-## Summary of Error Info Commands
-
-Error commands specify something about certain lines of the
-program. They tell the test what kind of error and what message you
-are expecting.
-
-* `~`: Associates the following error level and message with the
- current line
-* `~|`: Associates the following error level and message with the same
- line as the previous comment
-* `~^`: Associates the following error level and message with the
- previous line. Each caret (`^`) that you add adds a line to this, so
- `~^^^^^^^` is seven lines up.
-
-The error levels that you can have are:
-
-1. `ERROR`
-2. `WARNING`
-3. `NOTE`
-4. `HELP` and `SUGGESTION`*
-
-\* **Note**: `SUGGESTION` must follow immediately after `HELP`.
-
-## Summary of Header Commands
-
-Header commands specify something about the entire test file as a
-whole. They are normally put right after the copyright comment, e.g.:
-
-```Rust
-// Copyright blah blah blah
-// except according to those terms.
-
-// ignore-test This doesn't actually work
-```
-
-### Ignoring tests
-
-These are used to ignore the test in some situations, which means the test won't
-be compiled or run.
-
-* `ignore-X` where `X` is a target detail or stage will ignore the test accordingly (see below)
-* `ignore-pretty` will not compile the pretty-printed test (this is done to test the pretty-printer, but might not always work)
-* `ignore-test` always ignores the test
-* `ignore-lldb` and `ignore-gdb` will skip a debuginfo test on that debugger.
-
-`only-X` is the opposite. The test will run only when `X` matches.
-
-Some examples of `X` in `ignore-X`:
-
-* Architecture: `aarch64`, `arm`, `asmjs`, `mips`, `wasm32`, `x86_64`, `x86`, ...
-* OS: `android`, `emscripten`, `freebsd`, `ios`, `linux`, `macos`, `windows`, ...
-* Environment (fourth word of the target triple): `gnu`, `msvc`, `musl`.
-* Pointer width: `32bit`, `64bit`.
-* Stage: `stage0`, `stage1`, `stage2`.
-
-### Other Header Commands
-
-* `min-{gdb,lldb}-version`
-* `min-llvm-version`
-* `compile-pass` for UI tests, indicates that the test is supposed
- to compile, as opposed to the default where the test is supposed to error out.
-* `compile-flags` passes extra command-line args to the compiler,
- e.g. `compile-flags -g` which forces debuginfo to be enabled.
-* `should-fail` indicates that the test should fail; used for "meta testing",
- where we test the compiletest program itself to check that it will generate
- errors in appropriate scenarios. This header is ignored for pretty-printer tests.
-* `gate-test-X` where `X` is a feature marks the test as "gate test" for feature X.
- Such tests are supposed to ensure that the compiler errors when usage of a gated
- feature is attempted without the proper `#![feature(X)]` tag.
- Each unstable lang feature is required to have a gate test.
-
-## Revisions
-
-Certain classes of tests support "revisions" (as of the time of this
-writing, this includes run-pass, compile-fail, run-fail, and
-incremental, though incremental tests are somewhat
-different). Revisions allow a single test file to be used for multiple
-tests. This is done by adding a special header at the top of the file:
-
-```
-// revisions: foo bar baz
-```
-
-This will result in the test being compiled (and tested) three times,
-once with `--cfg foo`, once with `--cfg bar`, and once with `--cfg
-baz`. You can therefore use `#[cfg(foo)]` etc within the test to tweak
-each of these results.
-
-You can also customize headers and expected error messages to a particular
-revision. To do this, add `[foo]` (or `bar`, `baz`, etc) after the `//`
-comment, like so:
-
-```
-// A flag to pass in only for cfg `foo`:
-//[foo]compile-flags: -Z verbose
-
-#[cfg(foo)]
-fn test_foo() {
- let x: usize = 32_u32; //[foo]~ ERROR mismatched types
-}
-```
-
-Note that not all headers have meaning when customized to a revision.
-For example, the `ignore-test` header (and all "ignore" headers)
-currently only apply to the test as a whole, not to particular
-revisions. The only headers that are intended to really work when
-customized to a revision are error patterns and compiler flags.
-
-## Guide to the UI Tests
-
-The UI tests are intended to capture the compiler's complete output,
-so that we can test all aspects of the presentation. They work by
-compiling a file (e.g., `ui/hello_world/main.rs`), capturing the output,
-and then applying some normalization (see below). This normalized
-result is then compared against reference files named
-`ui/hello_world/main.stderr` and `ui/hello_world/main.stdout`. If either of
-those files doesn't exist, the output must be empty. If the test run
-fails, we will print out the current output, but it is also saved in
-`build/<target-triple>/test/ui/hello_world/main.stdout` (this path is
-printed as part of the test failure message), so you can run `diff` and
-so forth.
-
-Normally, the test-runner checks that UI tests fail compilation. If you want
-to do a UI test for code that *compiles* (e.g. to test warnings, or if you
-have a collection of tests, only some of which error out), you can use the
-`// compile-pass` header command to have the test runner instead
-check that the test compiles successfully.
-
-### Editing and updating the reference files
-
-If you have changed the compiler's output intentionally, or you are
-making a new test, you can pass `--bless` to the command you used to
-run the tests. This will then copy over the files
-from the build directory and use them as the new reference.
-
-### Normalization
-
-The normalization applied is aimed at eliminating output difference
-between platforms, mainly about filenames:
-
-- the test directory is replaced with `$DIR`
-- all backslashes (`\`) are converted to forward slashes (`/`) (for Windows)
-- all CR LF newlines are converted to LF
-
-Sometimes these built-in normalizations are not enough. In such cases, you
-may provide custom normalization rules using the header commands, e.g.
-
-```
-// normalize-stdout-test: "foo" -> "bar"
-// normalize-stderr-32bit: "fn\(\) \(32 bits\)" -> "fn\(\) \($$PTR bits\)"
-// normalize-stderr-64bit: "fn\(\) \(64 bits\)" -> "fn\(\) \($$PTR bits\)"
-```
-
-This tells the test, on 32-bit platforms, whenever the compiler writes
-`fn() (32 bits)` to stderr, it should be normalized to read `fn() ($PTR bits)`
-instead. Similar for 64-bit. The replacement is performed by regexes using
-default regex flavor provided by `regex` crate.
-
-The corresponding reference file will use the normalized output to test both
-32-bit and 64-bit platforms:
-
-```
-...
- |
- = note: source type: fn() ($PTR bits)
- = note: target type: u16 (16 bits)
-...
-```
-
-Please see `ui/transmute/main.rs` and `.stderr` for a concrete usage example.
-
-Besides `normalize-stderr-32bit` and `-64bit`, one may use any target
-information or stage supported by `ignore-X` here as well (e.g.
-`normalize-stderr-windows` or simply `normalize-stderr-test` for unconditional
-replacement).
+Documentation the compiler testing framework has moved to
+[the rustc guide](https://rust-lang-nursery.github.io/rustc-guide/tests/intro.html).
--- /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.
+
+#[derive(Clone, Copy)]
+struct S;
+
+trait T {
+ fn foo((x, y): (i32, i32)); //~ ERROR patterns aren't allowed in methods without bodies
+
+ fn bar((x, y): (i32, i32)) {} //~ ERROR patterns aren't allowed in methods without bodies
+
+ fn f(&ident: &S) {} // ok
+ fn g(&&ident: &&S) {} // ok
+ fn h(mut ident: S) {} // ok
+}
+
+fn main() {}
--- /dev/null
+error[E0642]: patterns aren't allowed in methods without bodies
+ --> $DIR/E0642.rs:15:12
+ |
+LL | fn foo((x, y): (i32, i32)); //~ ERROR patterns aren't allowed in methods without bodies
+ | ^^^^^^
+help: give this argument a name or use an underscore to ignore it
+ |
+LL | fn foo(_: (i32, i32)); //~ ERROR patterns aren't allowed in methods without bodies
+ | ^
+
+error[E0642]: patterns aren't allowed in methods without bodies
+ --> $DIR/E0642.rs:17:12
+ |
+LL | fn bar((x, y): (i32, i32)) {} //~ ERROR patterns aren't allowed in methods without bodies
+ | ^^^^^^
+help: give this argument a name or use an underscore to ignore it
+ |
+LL | fn bar(_: (i32, i32)) {} //~ ERROR patterns aren't allowed in methods without bodies
+ | ^
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0642`.
--> $DIR/catch-block-type-error.rs:18:9
|
LL | 42
- | ^^ expected f32, found integral variable
+ | ^^
+ | |
+ | expected f32, found integral variable
+ | help: use a float literal: `42.0`
|
= note: expected type `f32`
found type `{integer}`
--- /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.
+
+fn main() {
+ let sixteen: f32 = 16;
+ //~^ ERROR mismatched types
+ //~| HELP use a float literal
+ let a_million_and_seventy: f64 = 1_000_070;
+ //~^ ERROR mismatched types
+ //~| HELP use a float literal
+ let negative_nine: f32 = -9;
+ //~^ ERROR mismatched types
+ //~| HELP use a float literal
+
+
+ // only base-10 literals get the suggestion
+
+ let sixteen_again: f64 = 0x10;
+ //~^ ERROR mismatched types
+ let and_once_more: f32 = 0o20;
+ //~^ ERROR mismatched types
+}
--- /dev/null
+error[E0308]: mismatched types
+ --> $DIR/issue-53280-expected-float-found-integer-literal.rs:12:24
+ |
+LL | let sixteen: f32 = 16;
+ | ^^
+ | |
+ | expected f32, found integral variable
+ | help: use a float literal: `16.0`
+ |
+ = note: expected type `f32`
+ found type `{integer}`
+
+error[E0308]: mismatched types
+ --> $DIR/issue-53280-expected-float-found-integer-literal.rs:15:38
+ |
+LL | let a_million_and_seventy: f64 = 1_000_070;
+ | ^^^^^^^^^
+ | |
+ | expected f64, found integral variable
+ | help: use a float literal: `1_000_070.0`
+ |
+ = note: expected type `f64`
+ found type `{integer}`
+
+error[E0308]: mismatched types
+ --> $DIR/issue-53280-expected-float-found-integer-literal.rs:18:30
+ |
+LL | let negative_nine: f32 = -9;
+ | ^^
+ | |
+ | expected f32, found integral variable
+ | help: use a float literal: `-9.0`
+ |
+ = note: expected type `f32`
+ found type `{integer}`
+
+error[E0308]: mismatched types
+ --> $DIR/issue-53280-expected-float-found-integer-literal.rs:25:30
+ |
+LL | let sixteen_again: f64 = 0x10;
+ | ^^^^ expected f64, found integral variable
+ |
+ = note: expected type `f64`
+ found type `{integer}`
+
+error[E0308]: mismatched types
+ --> $DIR/issue-53280-expected-float-found-integer-literal.rs:27:30
+ |
+LL | let and_once_more: f32 = 0o20;
+ | ^^^^ expected f32, found integral variable
+ |
+ = note: expected type `f32`
+ found type `{integer}`
+
+error: aborting due to 5 previous errors
+
+For more information about this error, try `rustc --explain E0308`.
t!(io::copy(&mut io.take(amt),
&mut t!(File::create(&dst))));
t!(fs::set_permissions(&dst, Permissions::from_mode(0o755)));
- return dst
+ dst
}
fn my_copy(src: &mut dyn Read, which: u8, dst: &Mutex<dyn Write>) {
// versions of them accidentally sneak into our dependency graph to
// ensure we keep our CI times under control
// "cargo", // FIXME(#53005)
- // "rustc-ap-syntax", // FIXME(#53006)
+ "rustc-ap-syntax",
];
let mut name_to_id = HashMap::new();
for node in resolve.nodes.iter() {