Auto merge of #54021 - kennytm:rollup, r=kennytm

Rollup of 17 pull requests

Successful merges:

 - #53299 (Updated core/macros.rs to note it works in a no_std environment.)
 - #53376 (Cross reference io::copy and fs::copy in docs.)
 - #53455 (Individual docs for {from,to}_*_bytes)
 - #53550 (librustc_lint: In recursion warning, change 'recurring' to 'recursing')
 - #53860 (Migrate (some) of run-pass/ to ui)
 - #53874 (Implement Unpin for Box, Rc, and Arc)
 - #53895 (tidy: Cleanups and clippy warning fixes)
 - #53946 (Clarify `ManuallyDrop` docs)
 - #53948 (Minimized clippy test from when NLL disabled two-phase borrows)
 - #53959 (Add .git extension to submodule paths missing it)
 - #53966 (A few cleanups and minor improvements to mir/dataflow)
 - #53967 (propagate build.python into cmake)
 - #53979 (Remove `#[repr(transparent)]` from atomics)
 - #53991 (Add unchecked_shl/shr check for intrinsics to fix miri's test suit)
 - #53992 (migrate run-pass/borrowck to ui/run-pass)
 - #53994 (migrate run-pass/*/ to ui/run-pass)
 - #54023 (update clippy submodule)
This commit is contained in:
bors 2018-09-07 12:48:20 +00:00
commit 5a3292f163
2828 changed files with 5510 additions and 484 deletions

15
.gitmodules vendored
View file

@ -28,7 +28,7 @@
url = https://github.com/rust-lang-nursery/rls.git
[submodule "src/libcompiler_builtins"]
path = src/libcompiler_builtins
url = https://github.com/rust-lang-nursery/compiler-builtins
url = https://github.com/rust-lang-nursery/compiler-builtins.git
[submodule "src/tools/clippy"]
path = src/tools/clippy
url = https://github.com/rust-lang-nursery/rust-clippy.git
@ -43,24 +43,25 @@
url = https://github.com/alexcrichton/dlmalloc-rs.git
[submodule "src/doc/rust-by-example"]
path = src/doc/rust-by-example
url = https://github.com/rust-lang/rust-by-example
url = https://github.com/rust-lang/rust-by-example.git
[submodule "src/llvm-emscripten"]
path = src/llvm-emscripten
url = https://github.com/rust-lang/llvm
url = https://github.com/rust-lang/llvm.git
[submodule "src/stdsimd"]
path = src/stdsimd
url = https://github.com/rust-lang-nursery/stdsimd
url = https://github.com/rust-lang-nursery/stdsimd.git
[submodule "src/tools/lld"]
path = src/tools/lld
url = https://github.com/rust-lang/lld.git
[submodule "src/libbacktrace"]
path = src/libbacktrace
url = https://github.com/rust-lang-nursery/libbacktrace
url = https://github.com/rust-lang-nursery/libbacktrace.git
[submodule "src/tools/lldb"]
path = src/tools/lldb
url = https://github.com/rust-lang-nursery/lldb/
url = https://github.com/rust-lang-nursery/lldb.git
branch = rust-release-80-v1
[submodule "src/tools/clang"]
path = src/tools/clang
url = https://github.com/rust-lang-nursery/clang/
url = https://github.com/rust-lang-nursery/clang.git
branch = rust-release-80-v1

View file

@ -296,12 +296,14 @@ version = "0.0.212"
dependencies = [
"cargo_metadata 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"clippy-mini-macro-test 0.2.0",
"clippy_dev 0.0.1",
"clippy_lints 0.0.212",
"compiletest_rs 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)",
"derive-new 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-workspace-hack 1.0.0",
"rustc_tools_util 0.1.0",
"semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.75 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.75 (registry+https://github.com/rust-lang/crates.io-index)",
@ -311,6 +313,16 @@ dependencies = [
name = "clippy-mini-macro-test"
version = "0.2.0"
[[package]]
name = "clippy_dev"
version = "0.0.1"
dependencies = [
"clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)",
"itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "clippy_lints"
version = "0.0.212"
@ -2361,6 +2373,10 @@ dependencies = [
"serialize 0.0.0",
]
[[package]]
name = "rustc_tools_util"
version = "0.1.0"
[[package]]
name = "rustc_traits"
version = "0.0.0"

View file

@ -239,6 +239,10 @@ impl Step for Llvm {
cfg.define("LLVM_NATIVE_BUILD", builder.llvm_out(builder.config.build).join("build"));
}
if let Some(ref python) = builder.config.python {
cfg.define("PYTHON_EXECUTABLE", python);
}
configure_cmake(builder, target, &mut cfg, false);
// FIXME: we don't actually need to build all LLVM tools and all LLVM

View file

@ -603,11 +603,11 @@ fn foo() {
This will produce:
```text
warning: function cannot return without recurring
warning: function cannot return without recursing
--> src/main.rs:1:1
|
1 | fn foo() {
| ^^^^^^^^ cannot return without recurring
| ^^^^^^^^ cannot return without recursing
2 | foo();
| ----- recursive call site
|

View file

@ -749,6 +749,31 @@ impl<T: ?Sized> AsMut<T> for Box<T> {
}
}
/* Nota bene
*
* We could have chosen not to add this impl, and instead have written a
* function of Pin<Box<T>> to Pin<T>. Such a function would not be sound,
* because Box<T> implements Unpin even when T does not, as a result of
* this impl.
*
* We chose this API instead of the alternative for a few reasons:
* - Logically, it is helpful to understand pinning in regard to the
* memory region being pointed to. For this reason none of the
* standard library pointer types support projecting through a pin
* (Box<T> is the only pointer type in std for which this would be
* safe.)
* - It is in practice very useful to have Box<T> be unconditionally
* Unpin because of trait objects, for which the structural auto
* trait functionality does not apply (e.g. Box<dyn Foo> would
* otherwise not be Unpin).
*
* Another type with the same semantics as Box but only a conditional
* implementation of `Unpin` (where `T: Unpin`) would be valid/safe, and
* could have a method to project a Pin<T> from it.
*/
#[unstable(feature = "pin", issue = "49150")]
impl<T: ?Sized> Unpin for Box<T> { }
#[unstable(feature = "generator_trait", issue = "43122")]
impl<T> Generator for Box<T>
where T: Generator + ?Sized

View file

@ -252,7 +252,7 @@ use core::fmt;
use core::hash::{Hash, Hasher};
use core::intrinsics::abort;
use core::marker;
use core::marker::{Unsize, PhantomData};
use core::marker::{Unpin, Unsize, PhantomData};
use core::mem::{self, align_of_val, forget, size_of_val};
use core::ops::Deref;
use core::ops::CoerceUnsized;
@ -1830,3 +1830,6 @@ impl<T: ?Sized> AsRef<T> for Rc<T> {
&**self
}
}
#[unstable(feature = "pin", issue = "49150")]
impl<T: ?Sized> Unpin for Rc<T> { }

View file

@ -27,7 +27,7 @@ use core::mem::{self, align_of_val, size_of_val};
use core::ops::Deref;
use core::ops::CoerceUnsized;
use core::ptr::{self, NonNull};
use core::marker::{Unsize, PhantomData};
use core::marker::{Unpin, Unsize, PhantomData};
use core::hash::{Hash, Hasher};
use core::{isize, usize};
use core::convert::From;
@ -1943,3 +1943,6 @@ impl<T: ?Sized> AsRef<T> for Arc<T> {
&**self
}
}
#[unstable(feature = "pin", issue = "49150")]
impl<T: ?Sized> Unpin for Arc<T> { }

View file

@ -349,6 +349,26 @@ macro_rules! try {
/// write!(&mut v, "s = {:?}", s).unwrap(); // uses io::Write::write_fmt
/// assert_eq!(v, b"s = \"abc 123\"");
/// ```
///
/// Note: This macro can be used in `no_std` setups as well
/// In a `no_std` setup you are responsible for the
/// implementation details of the components.
///
/// ```no_run
/// # extern crate core;
/// use core::fmt::Write;
///
/// struct Example;
///
/// impl Write for Example {
/// fn write_str(&mut self, _s: &str) -> core::fmt::Result {
/// unimplemented!();
/// }
/// }
///
/// let mut m = Example{};
/// write!(&mut m, "Hello World").expect("Not written");
/// ```
#[macro_export]
#[stable(feature = "rust1", since = "1.0.0")]
macro_rules! write {

View file

@ -971,14 +971,16 @@ impl<T> ManuallyDrop<T> {
ManuallyDrop { value }
}
/// Extract the value from the ManuallyDrop container.
/// Extract the value from the `ManuallyDrop` container.
///
/// This allows the value to be dropped again.
///
/// # Examples
///
/// ```rust
/// use std::mem::ManuallyDrop;
/// let x = ManuallyDrop::new(Box::new(()));
/// let _: Box<()> = ManuallyDrop::into_inner(x);
/// let _: Box<()> = ManuallyDrop::into_inner(x); // This drops the `Box`.
/// ```
#[stable(feature = "manually_drop", since = "1.20.0")]
#[inline]
@ -990,11 +992,15 @@ impl<T> ManuallyDrop<T> {
impl<T: ?Sized> ManuallyDrop<T> {
/// Manually drops the contained value.
///
/// If you have ownership of the value, you can use [`ManuallyDrop::into_inner`] instead.
///
/// # Safety
///
/// This function runs the destructor of the contained value and thus the wrapped value
/// now represents uninitialized data. It is up to the user of this method to ensure the
/// uninitialized data is not actually used.
///
/// [`ManuallyDrop::into_inner`]: #method.into_inner
#[stable(feature = "manually_drop", since = "1.20.0")]
#[inline]
pub unsafe fn drop(slot: &mut ManuallyDrop<T>) {

View file

@ -192,7 +192,7 @@ mod wrapping;
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, $swap_op:expr, $swapped:expr,
$reversed:expr) => {
$reversed:expr, $le_bytes:expr, $be_bytes:expr) => {
doc_comment! {
concat!("Returns the smallest value that can be represented by this integer type.
@ -2063,23 +2063,25 @@ $EndFeature, "
self.to_be().to_ne_bytes()
}
/// Return the memory representation of this integer as a byte array in
/// big-endian (network) byte order.
///
/// # Examples
///
/// ```
/// #![feature(int_to_from_bytes)]
///
/// let bytes = 0x12_34_56_78_i32.to_be_bytes();
/// assert_eq!(bytes, [0x12, 0x34, 0x56, 0x78]);
/// ```
#[unstable(feature = "int_to_from_bytes", issue = "52963")]
#[rustc_const_unstable(feature = "const_int_conversion")]
#[inline]
#[cfg(not(stage0))]
pub const fn to_be_bytes(self) -> [u8; mem::size_of::<Self>()] {
self.to_be().to_ne_bytes()
doc_comment! {
concat!("Return the memory representation of this integer as a byte array in
big-endian (network) byte order.
# Examples
```
#![feature(int_to_from_bytes)]
let bytes = ", $swap_op, stringify!($SelfT), ".to_be_bytes();
assert_eq!(bytes, ", $be_bytes, ");
```"),
#[unstable(feature = "int_to_from_bytes", issue = "52963")]
#[rustc_const_unstable(feature = "const_int_conversion")]
#[inline]
#[cfg(not(stage0))]
pub const fn to_be_bytes(self) -> [u8; mem::size_of::<Self>()] {
self.to_be().to_ne_bytes()
}
}
/// no docs here
@ -2090,23 +2092,25 @@ $EndFeature, "
self.to_le().to_ne_bytes()
}
/// Return the memory representation of this integer as a byte array in
/// little-endian byte order.
///
/// # Examples
///
/// ```
/// #![feature(int_to_from_bytes)]
///
/// let bytes = 0x12_34_56_78_i32.to_le_bytes();
/// assert_eq!(bytes, [0x78, 0x56, 0x34, 0x12]);
/// ```
#[unstable(feature = "int_to_from_bytes", issue = "52963")]
#[rustc_const_unstable(feature = "const_int_conversion")]
#[inline]
#[cfg(not(stage0))]
pub const fn to_le_bytes(self) -> [u8; mem::size_of::<Self>()] {
self.to_le().to_ne_bytes()
doc_comment! {
concat!("Return the memory representation of this integer as a byte array in
little-endian byte order.
# Examples
```
#![feature(int_to_from_bytes)]
let bytes = ", $swap_op, stringify!($SelfT), ".to_le_bytes();
assert_eq!(bytes, ", $le_bytes, ");
```"),
#[unstable(feature = "int_to_from_bytes", issue = "52963")]
#[rustc_const_unstable(feature = "const_int_conversion")]
#[inline]
#[cfg(not(stage0))]
pub const fn to_le_bytes(self) -> [u8; mem::size_of::<Self>()] {
self.to_le().to_ne_bytes()
}
}
/// no docs here
@ -2117,30 +2121,37 @@ $EndFeature, "
unsafe { mem::transmute(self) }
}
/// Return the memory representation of this integer as a byte array in
/// native byte order.
///
/// As the target platform's native endianness is used, portable code
/// should use [`to_be_bytes`] or [`to_le_bytes`], as appropriate,
/// instead.
///
/// [`to_be_bytes`]: #method.to_be_bytes
/// [`to_le_bytes`]: #method.to_le_bytes
///
/// # Examples
///
/// ```
/// #![feature(int_to_from_bytes)]
///
/// let bytes = i32::min_value().to_be().to_ne_bytes();
/// assert_eq!(bytes, [0x80, 0, 0, 0]);
/// ```
#[unstable(feature = "int_to_from_bytes", issue = "52963")]
#[rustc_const_unstable(feature = "const_int_conversion")]
#[inline]
#[cfg(not(stage0))]
pub const fn to_ne_bytes(self) -> [u8; mem::size_of::<Self>()] {
unsafe { mem::transmute(self) }
doc_comment! {
concat!("
Return the memory representation of this integer as a byte array in
native byte order.
As the target platform's native endianness is used, portable code
should use [`to_be_bytes`] or [`to_le_bytes`], as appropriate,
instead.
[`to_be_bytes`]: #method.to_be_bytes
[`to_le_bytes`]: #method.to_le_bytes
# Examples
```
#![feature(int_to_from_bytes)]
let bytes = ", $swap_op, stringify!($SelfT), ".to_ne_bytes();
assert_eq!(bytes, if cfg!(target_endian = \"big\") {
", $be_bytes, "
} else {
", $le_bytes, "
});
```"),
#[unstable(feature = "int_to_from_bytes", issue = "52963")]
#[rustc_const_unstable(feature = "const_int_conversion")]
#[inline]
#[cfg(not(stage0))]
pub const fn to_ne_bytes(self) -> [u8; mem::size_of::<Self>()] {
unsafe { mem::transmute(self) }
}
}
/// no docs here
@ -2151,23 +2162,25 @@ $EndFeature, "
Self::from_be(Self::from_ne_bytes(bytes))
}
/// Create an integer value from its representation as a byte array in
/// big endian.
///
/// # Examples
///
/// ```
/// #![feature(int_to_from_bytes)]
///
/// let int = i32::from_be_bytes([0x12, 0x34, 0x56, 0x78]);
/// assert_eq!(int, 0x12_34_56_78);
/// ```
#[unstable(feature = "int_to_from_bytes", issue = "52963")]
#[rustc_const_unstable(feature = "const_int_conversion")]
#[inline]
#[cfg(not(stage0))]
pub const fn from_be_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
Self::from_be(Self::from_ne_bytes(bytes))
doc_comment! {
concat!("Create an integer value from its representation as a byte array in
big endian.
# Examples
```
#![feature(int_to_from_bytes)]
let value = ", stringify!($SelfT), "::from_be_bytes(", $be_bytes, ");
assert_eq!(value, ", $swap_op, ");
```"),
#[unstable(feature = "int_to_from_bytes", issue = "52963")]
#[rustc_const_unstable(feature = "const_int_conversion")]
#[inline]
#[cfg(not(stage0))]
pub const fn from_be_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
Self::from_be(Self::from_ne_bytes(bytes))
}
}
/// no docs here
@ -2178,23 +2191,26 @@ $EndFeature, "
Self::from_le(Self::from_ne_bytes(bytes))
}
/// Create an integer value from its representation as a byte array in
/// little endian.
///
/// # Examples
///
/// ```
/// #![feature(int_to_from_bytes)]
///
/// let int = i32::from_le_bytes([0x12, 0x34, 0x56, 0x78]);
/// assert_eq!(int, 0x78_56_34_12);
/// ```
#[unstable(feature = "int_to_from_bytes", issue = "52963")]
#[rustc_const_unstable(feature = "const_int_conversion")]
#[inline]
#[cfg(not(stage0))]
pub const fn from_le_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
Self::from_le(Self::from_ne_bytes(bytes))
doc_comment! {
concat!("
Create an integer value from its representation as a byte array in
little endian.
# Examples
```
#![feature(int_to_from_bytes)]
let value = ", stringify!($SelfT), "::from_le_bytes(", $le_bytes, ");
assert_eq!(value, ", $swap_op, ");
```"),
#[unstable(feature = "int_to_from_bytes", issue = "52963")]
#[rustc_const_unstable(feature = "const_int_conversion")]
#[inline]
#[cfg(not(stage0))]
pub const fn from_le_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
Self::from_le(Self::from_ne_bytes(bytes))
}
}
/// no docs here
@ -2205,56 +2221,65 @@ $EndFeature, "
unsafe { mem::transmute(bytes) }
}
/// Create an integer value from its memory representation as a byte
/// array in native endianness.
///
/// As the target platform's native endianness is used, portable code
/// likely wants to use [`from_be_bytes`] or [`from_le_bytes`], as
/// appropriate instead.
///
/// [`from_be_bytes`]: #method.from_be_bytes
/// [`from_le_bytes`]: #method.from_le_bytes
///
/// # Examples
///
/// ```
/// #![feature(int_to_from_bytes)]
///
/// let int = i32::from_be(i32::from_ne_bytes([0x80, 0, 0, 0]));
/// assert_eq!(int, i32::min_value());
/// ```
#[unstable(feature = "int_to_from_bytes", issue = "52963")]
#[rustc_const_unstable(feature = "const_int_conversion")]
#[inline]
#[cfg(not(stage0))]
pub const fn from_ne_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
unsafe { mem::transmute(bytes) }
doc_comment! {
concat!("Create an integer value from its memory representation as a byte
array in native endianness.
As the target platform's native endianness is used, portable code
likely wants to use [`from_be_bytes`] or [`from_le_bytes`], as
appropriate instead.
[`from_be_bytes`]: #method.from_be_bytes
[`from_le_bytes`]: #method.from_le_bytes
# Examples
```
#![feature(int_to_from_bytes)]
let value = ", stringify!($SelfT), "::from_ne_bytes(if cfg!(target_endian = \"big\") {
", $be_bytes, "
} else {
", $le_bytes, "
});
assert_eq!(value, ", $swap_op, ");
```"),
#[unstable(feature = "int_to_from_bytes", issue = "52963")]
#[rustc_const_unstable(feature = "const_int_conversion")]
#[inline]
#[cfg(not(stage0))]
pub const fn from_ne_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
unsafe { mem::transmute(bytes) }
}
}
}
}
#[lang = "i8"]
impl i8 {
int_impl! { i8, i8, u8, 8, -128, 127, "", "", 2, "-0x7e", "0xa", "0x12", "0x12", "0x48" }
int_impl! { i8, i8, u8, 8, -128, 127, "", "", 2, "-0x7e", "0xa", "0x12", "0x12", "0x48",
"[0x12]", "[0x12]" }
}
#[lang = "i16"]
impl i16 {
int_impl! { i16, i16, u16, 16, -32768, 32767, "", "", 4, "-0x5ffd", "0x3a", "0x1234", "0x3412",
"0x2c48" }
"0x2c48", "[0x34, 0x12]", "[0x12, 0x34]" }
}
#[lang = "i32"]
impl i32 {
int_impl! { i32, i32, u32, 32, -2147483648, 2147483647, "", "", 8, "0x10000b3", "0xb301",
"0x12345678", "0x78563412", "0x1e6a2c48" }
"0x12345678", "0x78563412", "0x1e6a2c48", "[0x78, 0x56, 0x34, 0x12]",
"[0x12, 0x34, 0x56, 0x78]" }
}
#[lang = "i64"]
impl i64 {
int_impl! { i64, i64, u64, 64, -9223372036854775808, 9223372036854775807, "", "", 12,
"0xaa00000000006e1", "0x6e10aa", "0x1234567890123456", "0x5634129078563412",
"0x6a2c48091e6a2c48" }
"0x6a2c48091e6a2c48", "[0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x34, 0x12]",
"[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]" }
}
#[lang = "i128"]
@ -2262,22 +2287,26 @@ impl i128 {
int_impl! { i128, i128, u128, 128, -170141183460469231731687303715884105728,
170141183460469231731687303715884105727, "", "", 16,
"0x13f40000000000000000000000004f76", "0x4f7613f4", "0x12345678901234567890123456789012",
"0x12907856341290785634129078563412", "0x48091e6a2c48091e6a2c48091e6a2c48"
}
"0x12907856341290785634129078563412", "0x48091e6a2c48091e6a2c48091e6a2c48",
"[0x12, 0x90, 0x78, 0x56, 0x34, 0x12, 0x90, 0x78, \
0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x34, 0x12]",
"[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56, \
0x78, 0x90, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12]" }
}
#[cfg(target_pointer_width = "16")]
#[lang = "isize"]
impl isize {
int_impl! { isize, i16, u16, 16, -32768, 32767, "", "", 4, "-0x5ffd", "0x3a", "0x1234",
"0x3412", "0x2c48" }
"0x3412", "0x2c48", "[0x34, 0x12]", "[0x12, 0x34]" }
}
#[cfg(target_pointer_width = "32")]
#[lang = "isize"]
impl isize {
int_impl! { isize, i32, u32, 32, -2147483648, 2147483647, "", "", 8, "0x10000b3", "0xb301",
"0x12345678", "0x78563412", "0x1e6a2c48" }
"0x12345678", "0x78563412", "0x1e6a2c48", "[0x78, 0x56, 0x34, 0x12]",
"[0x12, 0x34, 0x56, 0x78]" }
}
#[cfg(target_pointer_width = "64")]
@ -2285,7 +2314,8 @@ impl isize {
impl isize {
int_impl! { isize, i64, u64, 64, -9223372036854775808, 9223372036854775807, "", "",
12, "0xaa00000000006e1", "0x6e10aa", "0x1234567890123456", "0x5634129078563412",
"0x6a2c48091e6a2c48" }
"0x6a2c48091e6a2c48", "[0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x34, 0x12]",
"[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]" }
}
// Emits the correct `cttz` call, depending on the size of the type.
@ -2305,7 +2335,7 @@ macro_rules! uint_cttz_call {
macro_rules! uint_impl {
($SelfT:ty, $ActualT:ty, $BITS:expr, $MaxV:expr, $Feature:expr, $EndFeature:expr,
$rot:expr, $rot_op:expr, $rot_result:expr, $swap_op:expr, $swapped:expr,
$reversed:expr ) => {
$reversed:expr, $le_bytes:expr, $be_bytes:expr) => {
doc_comment! {
concat!("Returns the smallest value that can be represented by this integer type.
@ -3960,23 +3990,25 @@ $EndFeature, "
self.to_be().to_ne_bytes()
}
/// Return the memory representation of this integer as a byte array in
/// big-endian (network) byte order.
///
/// # Examples
///
/// ```
/// #![feature(int_to_from_bytes)]
///
/// let bytes = 0x12_34_56_78_i32.to_be_bytes();
/// assert_eq!(bytes, [0x12, 0x34, 0x56, 0x78]);
/// ```
#[unstable(feature = "int_to_from_bytes", issue = "52963")]
#[rustc_const_unstable(feature = "const_int_conversion")]
#[inline]
#[cfg(not(stage0))]
pub const fn to_be_bytes(self) -> [u8; mem::size_of::<Self>()] {
self.to_be().to_ne_bytes()
doc_comment! {
concat!("Return the memory representation of this integer as a byte array in
big-endian (network) byte order.
# Examples
```
#![feature(int_to_from_bytes)]
let bytes = ", $swap_op, stringify!($SelfT), ".to_be_bytes();
assert_eq!(bytes, ", $be_bytes, ");
```"),
#[unstable(feature = "int_to_from_bytes", issue = "52963")]
#[rustc_const_unstable(feature = "const_int_conversion")]
#[inline]
#[cfg(not(stage0))]
pub const fn to_be_bytes(self) -> [u8; mem::size_of::<Self>()] {
self.to_be().to_ne_bytes()
}
}
/// no docs here
@ -3987,23 +4019,25 @@ $EndFeature, "
self.to_le().to_ne_bytes()
}
/// Return the memory representation of this integer as a byte array in
/// little-endian byte order.
///
/// # Examples
///
/// ```
/// #![feature(int_to_from_bytes)]
///
/// let bytes = 0x12_34_56_78_i32.to_le_bytes();
/// assert_eq!(bytes, [0x78, 0x56, 0x34, 0x12]);
/// ```
#[unstable(feature = "int_to_from_bytes", issue = "52963")]
#[rustc_const_unstable(feature = "const_int_conversion")]
#[inline]
#[cfg(not(stage0))]
pub const fn to_le_bytes(self) -> [u8; mem::size_of::<Self>()] {
self.to_le().to_ne_bytes()
doc_comment! {
concat!("Return the memory representation of this integer as a byte array in
little-endian byte order.
# Examples
```
#![feature(int_to_from_bytes)]
let bytes = ", $swap_op, stringify!($SelfT), ".to_le_bytes();
assert_eq!(bytes, ", $le_bytes, ");
```"),
#[unstable(feature = "int_to_from_bytes", issue = "52963")]
#[rustc_const_unstable(feature = "const_int_conversion")]
#[inline]
#[cfg(not(stage0))]
pub const fn to_le_bytes(self) -> [u8; mem::size_of::<Self>()] {
self.to_le().to_ne_bytes()
}
}
/// no docs here
@ -4014,30 +4048,37 @@ $EndFeature, "
unsafe { mem::transmute(self) }
}
/// Return the memory representation of this integer as a byte array in
/// native byte order.
///
/// As the target platform's native endianness is used, portable code
/// should use [`to_be_bytes`] or [`to_le_bytes`], as appropriate,
/// instead.
///
/// [`to_be_bytes`]: #method.to_be_bytes
/// [`to_le_bytes`]: #method.to_le_bytes
///
/// # Examples
///
/// ```
/// #![feature(int_to_from_bytes)]
///
/// let bytes = i32::min_value().to_be().to_ne_bytes();
/// assert_eq!(bytes, [0x80, 0, 0, 0]);
/// ```
#[unstable(feature = "int_to_from_bytes", issue = "52963")]
#[rustc_const_unstable(feature = "const_int_conversion")]
#[inline]
#[cfg(not(stage0))]
pub const fn to_ne_bytes(self) -> [u8; mem::size_of::<Self>()] {
unsafe { mem::transmute(self) }
doc_comment! {
concat!("
Return the memory representation of this integer as a byte array in
native byte order.
As the target platform's native endianness is used, portable code
should use [`to_be_bytes`] or [`to_le_bytes`], as appropriate,
instead.
[`to_be_bytes`]: #method.to_be_bytes
[`to_le_bytes`]: #method.to_le_bytes
# Examples
```
#![feature(int_to_from_bytes)]
let bytes = ", $swap_op, stringify!($SelfT), ".to_ne_bytes();
assert_eq!(bytes, if cfg!(target_endian = \"big\") {
", $be_bytes, "
} else {
", $le_bytes, "
});
```"),
#[unstable(feature = "int_to_from_bytes", issue = "52963")]
#[rustc_const_unstable(feature = "const_int_conversion")]
#[inline]
#[cfg(not(stage0))]
pub const fn to_ne_bytes(self) -> [u8; mem::size_of::<Self>()] {
unsafe { mem::transmute(self) }
}
}
/// no docs here
@ -4048,23 +4089,25 @@ $EndFeature, "
Self::from_be(Self::from_ne_bytes(bytes))
}
/// Create an integer value from its representation as a byte array in
/// big endian.
///
/// # Examples
///
/// ```
/// #![feature(int_to_from_bytes)]
///
/// let int = i32::from_be_bytes([0x12, 0x34, 0x56, 0x78]);
/// assert_eq!(int, 0x12_34_56_78);
/// ```
#[unstable(feature = "int_to_from_bytes", issue = "52963")]
#[rustc_const_unstable(feature = "const_int_conversion")]
#[inline]
#[cfg(not(stage0))]
pub const fn from_be_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
Self::from_be(Self::from_ne_bytes(bytes))
doc_comment! {
concat!("Create an integer value from its representation as a byte array in
big endian.
# Examples
```
#![feature(int_to_from_bytes)]
let value = ", stringify!($SelfT), "::from_be_bytes(", $be_bytes, ");
assert_eq!(value, ", $swap_op, ");
```"),
#[unstable(feature = "int_to_from_bytes", issue = "52963")]
#[rustc_const_unstable(feature = "const_int_conversion")]
#[inline]
#[cfg(not(stage0))]
pub const fn from_be_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
Self::from_be(Self::from_ne_bytes(bytes))
}
}
/// no docs here
@ -4075,23 +4118,26 @@ $EndFeature, "
Self::from_le(Self::from_ne_bytes(bytes))
}
/// Create an integer value from its representation as a byte array in
/// little endian.
///
/// # Examples
///
/// ```
/// #![feature(int_to_from_bytes)]
///
/// let int = i32::from_le_bytes([0x12, 0x34, 0x56, 0x78]);
/// assert_eq!(int, 0x78_56_34_12);
/// ```
#[unstable(feature = "int_to_from_bytes", issue = "52963")]
#[rustc_const_unstable(feature = "const_int_conversion")]
#[inline]
#[cfg(not(stage0))]
pub const fn from_le_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
Self::from_le(Self::from_ne_bytes(bytes))
doc_comment! {
concat!("
Create an integer value from its representation as a byte array in
little endian.
# Examples
```
#![feature(int_to_from_bytes)]
let value = ", stringify!($SelfT), "::from_le_bytes(", $le_bytes, ");
assert_eq!(value, ", $swap_op, ");
```"),
#[unstable(feature = "int_to_from_bytes", issue = "52963")]
#[rustc_const_unstable(feature = "const_int_conversion")]
#[inline]
#[cfg(not(stage0))]
pub const fn from_le_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
Self::from_le(Self::from_ne_bytes(bytes))
}
}
/// no docs here
@ -4102,37 +4148,44 @@ $EndFeature, "
unsafe { mem::transmute(bytes) }
}
/// Create an integer value from its memory representation as a byte
/// array in native endianness.
///
/// As the target platform's native endianness is used, portable code
/// likely wants to use [`from_be_bytes`] or [`from_le_bytes`], as
/// appropriate instead.
///
/// [`from_be_bytes`]: #method.from_be_bytes
/// [`from_le_bytes`]: #method.from_le_bytes
///
/// # Examples
///
/// ```
/// #![feature(int_to_from_bytes)]
///
/// let int = i32::from_be(i32::from_ne_bytes([0x80, 0, 0, 0]));
/// assert_eq!(int, i32::min_value());
/// ```
#[unstable(feature = "int_to_from_bytes", issue = "52963")]
#[rustc_const_unstable(feature = "const_int_conversion")]
#[inline]
#[cfg(not(stage0))]
pub const fn from_ne_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
unsafe { mem::transmute(bytes) }
doc_comment! {
concat!("Create an integer value from its memory representation as a byte
array in native endianness.
As the target platform's native endianness is used, portable code
likely wants to use [`from_be_bytes`] or [`from_le_bytes`], as
appropriate instead.
[`from_be_bytes`]: #method.from_be_bytes
[`from_le_bytes`]: #method.from_le_bytes
# Examples
```
#![feature(int_to_from_bytes)]
let value = ", stringify!($SelfT), "::from_ne_bytes(if cfg!(target_endian = \"big\") {
", $be_bytes, "
} else {
", $le_bytes, "
});
assert_eq!(value, ", $swap_op, ");
```"),
#[unstable(feature = "int_to_from_bytes", issue = "52963")]
#[rustc_const_unstable(feature = "const_int_conversion")]
#[inline]
#[cfg(not(stage0))]
pub const fn from_ne_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
unsafe { mem::transmute(bytes) }
}
}
}
}
#[lang = "u8"]
impl u8 {
uint_impl! { u8, u8, 8, 255, "", "", 2, "0x82", "0xa", "0x12", "0x12", "0x48" }
uint_impl! { u8, u8, 8, 255, "", "", 2, "0x82", "0xa", "0x12", "0x12", "0x48", "[0x12]",
"[0x12]" }
/// Checks if the value is within the ASCII range.
@ -4658,45 +4711,55 @@ impl u8 {
#[lang = "u16"]
impl u16 {
uint_impl! { u16, u16, 16, 65535, "", "", 4, "0xa003", "0x3a", "0x1234", "0x3412", "0x2c48" }
uint_impl! { u16, u16, 16, 65535, "", "", 4, "0xa003", "0x3a", "0x1234", "0x3412", "0x2c48",
"[0x34, 0x12]", "[0x12, 0x34]" }
}
#[lang = "u32"]
impl u32 {
uint_impl! { u32, u32, 32, 4294967295, "", "", 8, "0x10000b3", "0xb301", "0x12345678",
"0x78563412", "0x1e6a2c48" }
"0x78563412", "0x1e6a2c48", "[0x78, 0x56, 0x34, 0x12]", "[0x12, 0x34, 0x56, 0x78]" }
}
#[lang = "u64"]
impl u64 {
uint_impl! { u64, u64, 64, 18446744073709551615, "", "", 12, "0xaa00000000006e1", "0x6e10aa",
"0x1234567890123456", "0x5634129078563412", "0x6a2c48091e6a2c48" }
"0x1234567890123456", "0x5634129078563412", "0x6a2c48091e6a2c48",
"[0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x34, 0x12]",
"[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]" }
}
#[lang = "u128"]
impl u128 {
uint_impl! { u128, u128, 128, 340282366920938463463374607431768211455, "", "", 16,
"0x13f40000000000000000000000004f76", "0x4f7613f4", "0x12345678901234567890123456789012",
"0x12907856341290785634129078563412", "0x48091e6a2c48091e6a2c48091e6a2c48" }
"0x12907856341290785634129078563412", "0x48091e6a2c48091e6a2c48091e6a2c48",
"[0x12, 0x90, 0x78, 0x56, 0x34, 0x12, 0x90, 0x78, \
0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x34, 0x12]",
"[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56, \
0x78, 0x90, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12]" }
}
#[cfg(target_pointer_width = "16")]
#[lang = "usize"]
impl usize {
uint_impl! { usize, u16, 16, 65536, "", "", 4, "0xa003", "0x3a", "0x1234", "0x3412", "0x2c48" }
uint_impl! { usize, u16, 16, 65536, "", "", 4, "0xa003", "0x3a", "0x1234", "0x3412", "0x2c48",
"[0x34, 0x12]", "[0x12, 0x34]" }
}
#[cfg(target_pointer_width = "32")]
#[lang = "usize"]
impl usize {
uint_impl! { usize, u32, 32, 4294967295, "", "", 8, "0x10000b3", "0xb301", "0x12345678",
"0x78563412", "0x1e6a2c48" }
"0x78563412", "0x1e6a2c48", "[0x78, 0x56, 0x34, 0x12]", "[0x12, 0x34, 0x56, 0x78]" }
}
#[cfg(target_pointer_width = "64")]
#[lang = "usize"]
impl usize {
uint_impl! { usize, u64, 64, 18446744073709551615, "", "", 12, "0xaa00000000006e1", "0x6e10aa",
"0x1234567890123456", "0x5634129078563412", "0x6a2c48091e6a2c48" }
"0x1234567890123456", "0x5634129078563412", "0x6a2c48091e6a2c48",
"[0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x34, 0x12]",
"[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]" }
}
/// A classification of floating point numbers.

View file

@ -124,7 +124,6 @@ pub fn spin_loop_hint() {
/// [`bool`]: ../../../std/primitive.bool.html
#[cfg(target_has_atomic = "8")]
#[stable(feature = "rust1", since = "1.0.0")]
#[repr(transparent)]
pub struct AtomicBool {
v: UnsafeCell<u8>,
}
@ -148,7 +147,6 @@ unsafe impl Sync for AtomicBool {}
/// This type has the same in-memory representation as a `*mut T`.
#[cfg(target_has_atomic = "ptr")]
#[stable(feature = "rust1", since = "1.0.0")]
#[repr(transparent)]
pub struct AtomicPtr<T> {
p: UnsafeCell<*mut T>,
}
@ -1101,7 +1099,6 @@ macro_rules! atomic_int {
///
/// [module-level documentation]: index.html
#[$stable]
#[repr(transparent)]
pub struct $atomic_type {
v: UnsafeCell<$int_type>,
}

View file

@ -901,7 +901,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnconditionalRecursion {
// considers this to be an error for two reasons, (a) it is
// easier to implement, and (b) it seems rare to actually want
// to have behaviour like the above, rather than
// e.g. accidentally recurring after an assert.
// e.g. accidentally recursing after an assert.
let cfg = cfg::CFG::new(cx.tcx, &body);
@ -961,8 +961,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnconditionalRecursion {
let sp = cx.tcx.sess.source_map().def_span(sp);
let mut db = cx.struct_span_lint(UNCONDITIONAL_RECURSION,
sp,
"function cannot return without recurring");
db.span_label(sp, "cannot return without recurring");
"function cannot return without recursing");
db.span_label(sp, "cannot return without recursing");
// offer some help to the programmer.
for call in &self_call_spans {
db.span_label(*call, "recursive call site");
@ -1090,7 +1090,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnconditionalRecursion {
// a default method definition.
Ok(Some(traits::VtableParam(_))) => {
let on_self = trait_ref.self_ty().is_self();
// We can only be recurring in a default
// We can only be recursing in a default
// method if we're being called literally
// on the `Self` type.
on_self && callee_id == method.def_id

View file

@ -265,15 +265,12 @@ impl<'a, 'tcx, MWF, P> dot::GraphWalk<'a> for Graph<'a, 'tcx, MWF, P>
fn edges(&self) -> dot::Edges<Edge> {
let mir = self.mbcx.mir();
// base initial capacity on assumption every block has at
// least one outgoing edge (Which should be true for all
// blocks but one, the exit-block).
let mut edges = Vec::with_capacity(mir.basic_blocks().len());
for bb in mir.basic_blocks().indices() {
let outgoing = outgoing(mir, bb);
edges.extend(outgoing.into_iter());
}
edges.into_cow()
mir.basic_blocks()
.indices()
.flat_map(|bb| outgoing(mir, bb))
.collect::<Vec<_>>()
.into_cow()
}
fn source(&self, edge: &Edge) -> Node {

View file

@ -168,9 +168,7 @@ impl<'a, 'gcx, 'tcx> Borrows<'a, 'gcx, 'tcx> {
// region, then setting that gen-bit will override any
// potential kill introduced here.
if let Some(indices) = self.borrows_out_of_scope_at_location.get(&location) {
for index in indices {
sets.kill(&index);
}
sets.kill_all(indices);
}
}

View file

@ -250,8 +250,7 @@ impl<'b, 'a: 'b, 'tcx: 'a, BD> PropagationContext<'b, 'a, 'tcx, BD> where BD: Bi
}
}
fn dataflow_path(context: &str, prepost: &str, path: &str) -> PathBuf {
format!("{}_{}", context, prepost);
fn dataflow_path(context: &str, path: &str) -> PathBuf {
let mut path = PathBuf::from(path);
let new_file_name = {
let orig_file_name = path.file_name().unwrap().to_str().unwrap();
@ -267,7 +266,7 @@ impl<'a, 'tcx: 'a, BD> DataflowBuilder<'a, 'tcx, BD> where BD: BitDenotation
where P: Fn(&BD, BD::Idx) -> DebugFormatted
{
if let Some(ref path_str) = self.print_preflow_to {
let path = dataflow_path(BD::name(), "preflow", path_str);
let path = dataflow_path(BD::name(), path_str);
graphviz::print_borrowck_graph_to(self, &path, p)
} else {
Ok(())
@ -278,9 +277,9 @@ impl<'a, 'tcx: 'a, BD> DataflowBuilder<'a, 'tcx, BD> where BD: BitDenotation
where P: Fn(&BD, BD::Idx) -> DebugFormatted
{
if let Some(ref path_str) = self.print_postflow_to {
let path = dataflow_path(BD::name(), "postflow", path_str);
let path = dataflow_path(BD::name(), path_str);
graphviz::print_borrowck_graph_to(self, &path, p)
} else{
} else {
Ok(())
}
}

View file

@ -201,7 +201,7 @@ impl<'a, 'gcx, 'tcx> MoveDataBuilder<'a, 'gcx, 'tcx> {
"done dumping moves"
});
if self.errors.len() > 0 {
if !self.errors.is_empty() {
Err((self.data, self.errors))
} else {
Ok(self.data)

View file

@ -105,8 +105,6 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
| "overflowing_add"
| "overflowing_sub"
| "overflowing_mul"
| "unchecked_shl"
| "unchecked_shr"
| "add_with_overflow"
| "sub_with_overflow"
| "mul_with_overflow" => {
@ -116,8 +114,6 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
"overflowing_add" => (BinOp::Add, true),
"overflowing_sub" => (BinOp::Sub, true),
"overflowing_mul" => (BinOp::Mul, true),
"unchecked_shl" => (BinOp::Shl, true),
"unchecked_shr" => (BinOp::Shr, true),
"add_with_overflow" => (BinOp::Add, false),
"sub_with_overflow" => (BinOp::Sub, false),
"mul_with_overflow" => (BinOp::Mul, false),
@ -129,6 +125,24 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
self.binop_with_overflow(bin_op, lhs, rhs, dest)?;
}
}
"unchecked_shl" | "unchecked_shr" => {
let l = self.read_value(args[0])?;
let r = self.read_value(args[1])?;
let bin_op = match intrinsic_name {
"unchecked_shl" => BinOp::Shl,
"unchecked_shr" => BinOp::Shr,
_ => bug!("Already checked for int ops")
};
let (val, overflowed) = self.binary_op_val(bin_op, l, r)?;
if overflowed {
let layout = self.layout_of(substs.type_at(0))?;
let r_val = r.to_scalar()?.to_bits(layout.size)?;
return err!(Intrinsic(
format!("Overflowing shift by {} in {}", r_val, intrinsic_name),
));
}
self.write_scalar(val, dest)?;
}
"transmute" => {
// Go through an allocation, to make sure the completely different layouts
// do not pose a problem. (When the user transmutes through a union,

View file

@ -1566,6 +1566,12 @@ pub fn rename<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> io::Result<()>
/// On success, the total number of bytes copied is returned and it is equal to
/// the length of the `to` file as reported by `metadata`.
///
/// If youre wanting to copy the contents of one file to another and youre
/// working with [`File`]s, see the [`io::copy`] function.
///
/// [`io::copy`]: ../io/fn.copy.html
/// [`File`]: ./struct.File.html
///
/// # Platform-specific behavior
///
/// This function currently corresponds to the `open` function in Unix

View file

@ -23,6 +23,11 @@ use mem;
/// On success, the total number of bytes that were copied from
/// `reader` to `writer` is returned.
///
/// If youre wanting to copy the contents of one file to another and youre
/// working with filesystem paths, see the [`fs::copy`] function.
///
/// [`fs::copy`]: ../fs/fn.copy.html
///
/// # Errors
///
/// This function will return an error immediately if any call to `read` or

View file

@ -0,0 +1,133 @@
error[E0503]: cannot use `self.cx` because it was mutably borrowed
--> $DIR/two-phase-surprise-no-conflict.rs:40:13
|
LL | let _mut_borrow = &mut *self;
| ----- borrow of `*self` occurs here
LL | let _access = self.cx;
| ^^^^^^^ use of borrowed `*self`
error[E0502]: cannot borrow `*self.cx_mut` as immutable because `*self` is also borrowed as mutable
--> $DIR/two-phase-surprise-no-conflict.rs:79:33
|
LL | self.hash_expr(&self.cx_mut.body(eid).value);
| ---- ^^^^^^^^^^^ - mutable borrow ends here
| | |
| | immutable borrow occurs here
| mutable borrow occurs here
error[E0502]: cannot borrow `reg.sess_mut` as immutable because `*reg` is also borrowed as mutable
--> $DIR/two-phase-surprise-no-conflict.rs:131:52
|
LL | reg.register_static(Box::new(TrivialPass::new(&reg.sess_mut)));
| --- ^^^^^^^^^^^^ - mutable borrow ends here
| | |
| mutable borrow occurs here immutable borrow occurs here
error[E0502]: cannot borrow `reg.sess_mut` as immutable because `*reg` is also borrowed as mutable
--> $DIR/two-phase-surprise-no-conflict.rs:135:51
|
LL | reg.register_bound(Box::new(TrivialPass::new(&reg.sess_mut)));
| --- ^^^^^^^^^^^^ - mutable borrow ends here
| | |
| mutable borrow occurs here immutable borrow occurs here
error[E0502]: cannot borrow `reg.sess_mut` as immutable because `*reg` is also borrowed as mutable
--> $DIR/two-phase-surprise-no-conflict.rs:139:50
|
LL | reg.register_univ(Box::new(TrivialPass::new(&reg.sess_mut)));
| --- ^^^^^^^^^^^^ - mutable borrow ends here
| | |
| mutable borrow occurs here immutable borrow occurs here
error[E0502]: cannot borrow `reg.sess_mut` as immutable because `*reg` is also borrowed as mutable
--> $DIR/two-phase-surprise-no-conflict.rs:143:41
|
LL | reg.register_ref(&TrivialPass::new(&reg.sess_mut));
| --- ^^^^^^^^^^^^ - mutable borrow ends here
| | |
| mutable borrow occurs here immutable borrow occurs here
error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time
--> $DIR/two-phase-surprise-no-conflict.rs:151:56
|
LL | reg.register_static(Box::new(TrivialPass::new(&mut reg.sess_mut)));
| --- ^^^^^^^^^^^^ - first borrow ends here
| | |
| first mutable borrow occurs here second mutable borrow occurs here
error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time
--> $DIR/two-phase-surprise-no-conflict.rs:156:59
|
LL | reg.register_bound(Box::new(TrivialPass::new_mut(&mut reg.sess_mut)));
| --- ^^^^^^^^^^^^ - first borrow ends here
| | |
| first mutable borrow occurs here second mutable borrow occurs here
error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time
--> $DIR/two-phase-surprise-no-conflict.rs:161:58
|
LL | reg.register_univ(Box::new(TrivialPass::new_mut(&mut reg.sess_mut)));
| --- ^^^^^^^^^^^^ - first borrow ends here
| | |
| first mutable borrow occurs here second mutable borrow occurs here
error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time
--> $DIR/two-phase-surprise-no-conflict.rs:166:49
|
LL | reg.register_ref(&TrivialPass::new_mut(&mut reg.sess_mut));
| --- ^^^^^^^^^^^^ - first borrow ends here
| | |
| first mutable borrow occurs here second mutable borrow occurs here
error[E0502]: cannot borrow `reg.sess_mut` as immutable because `*reg` is also borrowed as mutable
--> $DIR/two-phase-surprise-no-conflict.rs:178:51
|
LL | reg.register_bound(Box::new(CapturePass::new(&reg.sess_mut)));
| --- ^^^^^^^^^^^^ - mutable borrow ends here
| | |
| mutable borrow occurs here immutable borrow occurs here
error[E0502]: cannot borrow `reg.sess_mut` as immutable because `*reg` is also borrowed as mutable
--> $DIR/two-phase-surprise-no-conflict.rs:183:50
|
LL | reg.register_univ(Box::new(CapturePass::new(&reg.sess_mut)));
| --- ^^^^^^^^^^^^ - mutable borrow ends here
| | |
| mutable borrow occurs here immutable borrow occurs here
error[E0502]: cannot borrow `reg.sess_mut` as immutable because `*reg` is also borrowed as mutable
--> $DIR/two-phase-surprise-no-conflict.rs:188:41
|
LL | reg.register_ref(&CapturePass::new(&reg.sess_mut));
| --- ^^^^^^^^^^^^ - mutable borrow ends here
| | |
| mutable borrow occurs here immutable borrow occurs here
error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time
--> $DIR/two-phase-surprise-no-conflict.rs:200:59
|
LL | reg.register_bound(Box::new(CapturePass::new_mut(&mut reg.sess_mut)));
| --- ^^^^^^^^^^^^ - first borrow ends here
| | |
| first mutable borrow occurs here second mutable borrow occurs here
error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time
--> $DIR/two-phase-surprise-no-conflict.rs:206:58
|
LL | reg.register_univ(Box::new(CapturePass::new_mut(&mut reg.sess_mut)));
| --- ^^^^^^^^^^^^ - first borrow ends here
| | |
| first mutable borrow occurs here second mutable borrow occurs here
error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time
--> $DIR/two-phase-surprise-no-conflict.rs:212:49
|
LL | reg.register_ref(&CapturePass::new_mut(&mut reg.sess_mut));
| --- ^^^^^^^^^^^^ - first borrow ends here
| | |
| first mutable borrow occurs here second mutable borrow occurs here
error: aborting due to 16 previous errors
Some errors occurred: E0499, E0502, E0503.
For more information about an error, try `rustc --explain E0499`.

View file

@ -0,0 +1,165 @@
error[E0503]: cannot use `self.cx` because it was mutably borrowed
--> $DIR/two-phase-surprise-no-conflict.rs:40:23
|
LL | let _mut_borrow = &mut *self;
| ---------- borrow of `*self` occurs here
LL | let _access = self.cx;
| ^^^^^^^ use of borrowed `*self`
...
LL | _mut_borrow;
| ----------- borrow later used here
error[E0502]: cannot borrow `*self` as mutable because it is also borrowed as immutable
--> $DIR/two-phase-surprise-no-conflict.rs:79:17
|
LL | self.hash_expr(&self.cx_mut.body(eid).value);
| ^^^^^^^^^^^^^^^^-----------^^^^^^^^^^^^^^^^^
| | |
| | immutable borrow occurs here
| mutable borrow occurs here
| borrow later used here
error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time
--> $DIR/two-phase-surprise-no-conflict.rs:151:51
|
LL | reg.register_static(Box::new(TrivialPass::new(&mut reg.sess_mut)));
| ----------------------------------------------^^^^^^^^^^^^^^^^^---
| | |
| | second mutable borrow occurs here
| first mutable borrow occurs here
| borrow later used here
error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time
--> $DIR/two-phase-surprise-no-conflict.rs:156:54
|
LL | reg.register_bound(Box::new(TrivialPass::new_mut(&mut reg.sess_mut)));
| -------------------------------------------------^^^^^^^^^^^^^^^^^---
| | |
| | second mutable borrow occurs here
| first mutable borrow occurs here
| borrow later used here
error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time
--> $DIR/two-phase-surprise-no-conflict.rs:161:53
|
LL | reg.register_univ(Box::new(TrivialPass::new_mut(&mut reg.sess_mut)));
| ------------------------------------------------^^^^^^^^^^^^^^^^^---
| | |
| | second mutable borrow occurs here
| first mutable borrow occurs here
| borrow later used here
error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time
--> $DIR/two-phase-surprise-no-conflict.rs:166:44
|
LL | reg.register_ref(&TrivialPass::new_mut(&mut reg.sess_mut));
| ---------------------------------------^^^^^^^^^^^^^^^^^--
| | |
| | second mutable borrow occurs here
| first mutable borrow occurs here
| borrow later used here
error[E0502]: cannot borrow `*reg` as mutable because it is also borrowed as immutable
--> $DIR/two-phase-surprise-no-conflict.rs:178:5
|
LL | reg.register_bound(Box::new(CapturePass::new(&reg.sess_mut)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------------^^^
| | |
| | immutable borrow occurs here
| mutable borrow occurs here
| borrow later used here
error[E0502]: cannot borrow `*reg` as mutable because it is also borrowed as immutable
--> $DIR/two-phase-surprise-no-conflict.rs:183:5
|
LL | reg.register_univ(Box::new(CapturePass::new(&reg.sess_mut)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------------^^^
| | |
| | immutable borrow occurs here
| mutable borrow occurs here
|
note: borrowed value must be valid for the lifetime 'a as defined on the function body at 122:21...
--> $DIR/two-phase-surprise-no-conflict.rs:122:21
|
LL | fn register_plugins<'a>(mk_reg: impl Fn() -> &'a mut Registry<'a>) {
| ^^
error[E0502]: cannot borrow `*reg` as mutable because it is also borrowed as immutable
--> $DIR/two-phase-surprise-no-conflict.rs:188:5
|
LL | reg.register_ref(&CapturePass::new(&reg.sess_mut));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------------^^
| | |
| | immutable borrow occurs here
| mutable borrow occurs here
| borrow later used here
error[E0499]: cannot borrow `*reg` as mutable more than once at a time
--> $DIR/two-phase-surprise-no-conflict.rs:200:5
|
LL | reg.register_bound(Box::new(CapturePass::new_mut(&mut reg.sess_mut)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------^^^
| | |
| | first mutable borrow occurs here
| second mutable borrow occurs here
| borrow later used here
error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time
--> $DIR/two-phase-surprise-no-conflict.rs:200:54
|
LL | reg.register_bound(Box::new(CapturePass::new_mut(&mut reg.sess_mut)));
| -------------------------------------------------^^^^^^^^^^^^^^^^^---
| | |
| | second mutable borrow occurs here
| first mutable borrow occurs here
| borrow later used here
error[E0499]: cannot borrow `*reg` as mutable more than once at a time
--> $DIR/two-phase-surprise-no-conflict.rs:206:5
|
LL | reg.register_univ(Box::new(CapturePass::new_mut(&mut reg.sess_mut)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------^^^
| | |
| | first mutable borrow occurs here
| second mutable borrow occurs here
|
note: borrowed value must be valid for the lifetime 'a as defined on the function body at 122:21...
--> $DIR/two-phase-surprise-no-conflict.rs:122:21
|
LL | fn register_plugins<'a>(mk_reg: impl Fn() -> &'a mut Registry<'a>) {
| ^^
error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time
--> $DIR/two-phase-surprise-no-conflict.rs:206:53
|
LL | reg.register_univ(Box::new(CapturePass::new_mut(&mut reg.sess_mut)));
| ------------------------------------------------^^^^^^^^^^^^^^^^^---
| | |
| | second mutable borrow occurs here
| first mutable borrow occurs here
| borrow later used here
error[E0499]: cannot borrow `*reg` as mutable more than once at a time
--> $DIR/two-phase-surprise-no-conflict.rs:212:5
|
LL | reg.register_ref(&CapturePass::new_mut(&mut reg.sess_mut));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------^^
| | |
| | first mutable borrow occurs here
| second mutable borrow occurs here
| borrow later used here
error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time
--> $DIR/two-phase-surprise-no-conflict.rs:212:44
|
LL | reg.register_ref(&CapturePass::new_mut(&mut reg.sess_mut));
| ---------------------------------------^^^^^^^^^^^^^^^^^--
| | |
| | second mutable borrow occurs here
| first mutable borrow occurs here
| borrow later used here
error: aborting due to 15 previous errors
Some errors occurred: E0499, E0502, E0503.
For more information about an error, try `rustc --explain E0499`.

View file

@ -0,0 +1,175 @@
error[E0503]: cannot use `self.cx` because it was mutably borrowed
--> $DIR/two-phase-surprise-no-conflict.rs:40:23
|
LL | let _mut_borrow = &mut *self;
| ---------- borrow of `*self` occurs here
LL | let _access = self.cx;
| ^^^^^^^ use of borrowed `*self`
...
LL | _mut_borrow;
| ----------- borrow later used here
error[E0502]: cannot borrow `*self.cx` as immutable because it is also borrowed as mutable
--> $DIR/two-phase-surprise-no-conflict.rs:64:33
|
LL | self.hash_expr(&self.cx.body(eid).value);
| ----------------^^^^^^^-----------------
| | |
| | immutable borrow occurs here
| mutable borrow occurs here
| borrow later used here
error[E0502]: cannot borrow `*self.cx_mut` as immutable because it is also borrowed as mutable
--> $DIR/two-phase-surprise-no-conflict.rs:79:33
|
LL | self.hash_expr(&self.cx_mut.body(eid).value);
| ----------------^^^^^^^^^^^-----------------
| | |
| | immutable borrow occurs here
| mutable borrow occurs here
| borrow later used here
error[E0502]: cannot borrow `reg.sess_mut` as immutable because it is also borrowed as mutable
--> $DIR/two-phase-surprise-no-conflict.rs:131:51
|
LL | reg.register_static(Box::new(TrivialPass::new(&reg.sess_mut)));
| ----------------------------------------------^^^^^^^^^^^^^---
| | |
| | immutable borrow occurs here
| mutable borrow occurs here
| borrow later used here
error[E0502]: cannot borrow `reg.sess_mut` as immutable because it is also borrowed as mutable
--> $DIR/two-phase-surprise-no-conflict.rs:135:50
|
LL | reg.register_bound(Box::new(TrivialPass::new(&reg.sess_mut)));
| ---------------------------------------------^^^^^^^^^^^^^---
| | |
| | immutable borrow occurs here
| mutable borrow occurs here
| borrow later used here
error[E0502]: cannot borrow `reg.sess_mut` as immutable because it is also borrowed as mutable
--> $DIR/two-phase-surprise-no-conflict.rs:139:49
|
LL | reg.register_univ(Box::new(TrivialPass::new(&reg.sess_mut)));
| --------------------------------------------^^^^^^^^^^^^^---
| | |
| | immutable borrow occurs here
| mutable borrow occurs here
| borrow later used here
error[E0502]: cannot borrow `reg.sess_mut` as immutable because it is also borrowed as mutable
--> $DIR/two-phase-surprise-no-conflict.rs:143:40
|
LL | reg.register_ref(&TrivialPass::new(&reg.sess_mut));
| -----------------------------------^^^^^^^^^^^^^--
| | |
| | immutable borrow occurs here
| mutable borrow occurs here
| borrow later used here
error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time
--> $DIR/two-phase-surprise-no-conflict.rs:151:51
|
LL | reg.register_static(Box::new(TrivialPass::new(&mut reg.sess_mut)));
| ----------------------------------------------^^^^^^^^^^^^^^^^^---
| | |
| | second mutable borrow occurs here
| first mutable borrow occurs here
| borrow later used here
error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time
--> $DIR/two-phase-surprise-no-conflict.rs:156:54
|
LL | reg.register_bound(Box::new(TrivialPass::new_mut(&mut reg.sess_mut)));
| -------------------------------------------------^^^^^^^^^^^^^^^^^---
| | |
| | second mutable borrow occurs here
| first mutable borrow occurs here
| borrow later used here
error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time
--> $DIR/two-phase-surprise-no-conflict.rs:161:53
|
LL | reg.register_univ(Box::new(TrivialPass::new_mut(&mut reg.sess_mut)));
| ------------------------------------------------^^^^^^^^^^^^^^^^^---
| | |
| | second mutable borrow occurs here
| first mutable borrow occurs here
| borrow later used here
error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time
--> $DIR/two-phase-surprise-no-conflict.rs:166:44
|
LL | reg.register_ref(&TrivialPass::new_mut(&mut reg.sess_mut));
| ---------------------------------------^^^^^^^^^^^^^^^^^--
| | |
| | second mutable borrow occurs here
| first mutable borrow occurs here
| borrow later used here
error[E0502]: cannot borrow `reg.sess_mut` as immutable because it is also borrowed as mutable
--> $DIR/two-phase-surprise-no-conflict.rs:178:50
|
LL | reg.register_bound(Box::new(CapturePass::new(&reg.sess_mut)));
| ---------------------------------------------^^^^^^^^^^^^^---
| | |
| | immutable borrow occurs here
| mutable borrow occurs here
| borrow later used here
error[E0502]: cannot borrow `reg.sess_mut` as immutable because it is also borrowed as mutable
--> $DIR/two-phase-surprise-no-conflict.rs:183:49
|
LL | reg.register_univ(Box::new(CapturePass::new(&reg.sess_mut)));
| --------------------------------------------^^^^^^^^^^^^^---
| | |
| | immutable borrow occurs here
| mutable borrow occurs here
| borrow later used here
error[E0502]: cannot borrow `reg.sess_mut` as immutable because it is also borrowed as mutable
--> $DIR/two-phase-surprise-no-conflict.rs:188:40
|
LL | reg.register_ref(&CapturePass::new(&reg.sess_mut));
| -----------------------------------^^^^^^^^^^^^^--
| | |
| | immutable borrow occurs here
| mutable borrow occurs here
| borrow later used here
error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time
--> $DIR/two-phase-surprise-no-conflict.rs:200:54
|
LL | reg.register_bound(Box::new(CapturePass::new_mut(&mut reg.sess_mut)));
| -------------------------------------------------^^^^^^^^^^^^^^^^^---
| | |
| | second mutable borrow occurs here
| first mutable borrow occurs here
| borrow later used here
error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time
--> $DIR/two-phase-surprise-no-conflict.rs:206:53
|
LL | reg.register_univ(Box::new(CapturePass::new_mut(&mut reg.sess_mut)));
| ------------------------------------------------^^^^^^^^^^^^^^^^^---
| | |
| | second mutable borrow occurs here
| first mutable borrow occurs here
| borrow later used here
error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time
--> $DIR/two-phase-surprise-no-conflict.rs:212:44
|
LL | reg.register_ref(&CapturePass::new_mut(&mut reg.sess_mut));
| ---------------------------------------^^^^^^^^^^^^^^^^^--
| | |
| | second mutable borrow occurs here
| first mutable borrow occurs here
| borrow later used here
error: aborting due to 17 previous errors
Some errors occurred: E0499, E0502, E0503.
For more information about an error, try `rustc --explain E0499`.

View file

@ -0,0 +1,219 @@
// 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.
// This is a test adapted from a minimization of the code from
// rust-lang/rust#52934, where an accidental disabling of
// two-phase-borrows (in the initial 2018 edition integration) broke
// Clippy, but the scenarios where it was breaking were subtle enough
// that we decided it warranted its own unit test, and pnkfelix
// decided to use that test as an opportunity to illustrate the cases.
// revisions: ast no2pb nll
//[ast]compile-flags: -Z borrowck=ast
//[no2pb]compile-flags: -Z borrowck=mir
//[nll]compile-flags: -Z borrowck=mir -Z two-phase-borrows
// (Since we are manually toggling NLL variations on and off, don't
// bother with compare-mode=nll)
// ignore-compare-mode-nll
#[derive(Copy, Clone)]
struct BodyId;
enum Expr { Closure(BodyId), Others }
struct Body { value: Expr }
struct Map { body: Body, }
impl Map { fn body(&self, _: BodyId) -> &Body { unimplemented!() } }
struct SpanlessHash<'a> { cx: &'a Map, cx_mut: &'a mut Map }
impl <'a> SpanlessHash<'a> {
fn demo(&mut self) {
let _mut_borrow = &mut *self;
let _access = self.cx;
//[ast]~^ ERROR cannot use `self.cx` because it was mutably borrowed [E0503]
//[no2pb]~^^ ERROR cannot use `self.cx` because it was mutably borrowed [E0503]
//[nll]~^^^ ERROR cannot use `self.cx` because it was mutably borrowed [E0503]
_mut_borrow;
}
fn hash_expr(&mut self, e: &Expr) {
match *e {
Expr::Closure(eid) => {
// Accepted by AST-borrowck for erroneous reasons
// (rust-lang/rust#38899).
//
// Not okay without two-phase borrows: the implicit
// `&mut self` of the receiver is evaluated first, and
// that conflicts with the `self.cx`` access during
// argument evaluation, as demonstrated in `fn demo`
// above.
//
// Okay if we have two-phase borrows. Note that even
// if `self.cx.body(..)` holds onto a reference into
// `self.cx`, `self.cx` is an immutable-borrow, so
// nothing in the activation for `self.hash_expr(..)`
// can interfere with that immutable borrow.
self.hash_expr(&self.cx.body(eid).value);
//[no2pb]~^ ERROR cannot borrow `*self.cx`
},
_ => {}
}
}
fn hash_expr_mut(&mut self, e: &Expr) {
match *e {
Expr::Closure(eid) => {
// Not okay: the call to `self.cx_mut.body(eid)` might
// hold on to some mutably borrowed state in
// `self.cx_mut`, which would then interfere with the
// eventual activation of the `self` mutable borrow
// for `self.hash_expr(..)`
self.hash_expr(&self.cx_mut.body(eid).value);
//[ast]~^ ERROR cannot borrow `*self.cx_mut`
//[no2pb]~^^ ERROR cannot borrow `*self.cx_mut`
//[nll]~^^^ ERROR cannot borrow `*self`
},
_ => {}
}
}
}
struct Session;
struct Config;
trait LateLintPass<'a> { }
struct TrivialPass;
impl TrivialPass {
fn new(_: &Session) -> Self { TrivialPass }
fn new_mut(_: &mut Session) -> Self { TrivialPass }
}
struct CapturePass<'a> { s: &'a Session }
impl<'a> CapturePass<'a> {
fn new(s: &'a Session) -> Self { CapturePass { s } }
fn new_mut(s: &'a mut Session) -> Self { CapturePass { s } }
}
impl<'a> LateLintPass<'a> for TrivialPass { }
impl<'a, 'b> LateLintPass<'a> for CapturePass<'b> { }
struct Registry<'a> { sess_mut: &'a mut Session }
impl<'a> Registry<'a> {
fn register_static(&mut self, _: Box<dyn LateLintPass + 'static>) { }
// Note: there isn't an interesting distinction between these
// different methods explored by any of the cases in the test
// below. pnkfelix just happened to write these cases out while
// exploring variations on `dyn for <'a> Trait<'a> + 'static`, and
// then decided to keep these particular ones in.
fn register_bound(&mut self, _: Box<dyn LateLintPass + 'a>) { }
fn register_univ(&mut self, _: Box<dyn for <'b> LateLintPass<'b> + 'a>) { }
fn register_ref(&mut self, _: &dyn LateLintPass) { }
}
fn register_plugins<'a>(mk_reg: impl Fn() -> &'a mut Registry<'a>) {
// Not okay without two-phase borrows: The implicit `&mut reg` of
// the receiver is evaluaated first, and that conflicts with the
// `reg.sess_mut` access during argument evaluation.
//
// Okay if we have two-phase borrows: inner borrows do not survive
// to the actual method invocation, because `TrivialPass::new`
// cannot (according to its type) keep them alive.
let reg = mk_reg();
reg.register_static(Box::new(TrivialPass::new(&reg.sess_mut)));
//[ast]~^ ERROR cannot borrow `reg.sess_mut`
//[no2pb]~^^ ERROR cannot borrow `reg.sess_mut`
let reg = mk_reg();
reg.register_bound(Box::new(TrivialPass::new(&reg.sess_mut)));
//[ast]~^ ERROR cannot borrow `reg.sess_mut`
//[no2pb]~^^ ERROR cannot borrow `reg.sess_mut`
let reg = mk_reg();
reg.register_univ(Box::new(TrivialPass::new(&reg.sess_mut)));
//[ast]~^ ERROR cannot borrow `reg.sess_mut`
//[no2pb]~^^ ERROR cannot borrow `reg.sess_mut`
let reg = mk_reg();
reg.register_ref(&TrivialPass::new(&reg.sess_mut));
//[ast]~^ ERROR cannot borrow `reg.sess_mut`
//[no2pb]~^^ ERROR cannot borrow `reg.sess_mut`
// These are not okay: the inner mutable borrows immediately
// conflict with the outer borrow/reservation, even with support
// for two-phase borrows.
let reg = mk_reg();
reg.register_static(Box::new(TrivialPass::new(&mut reg.sess_mut)));
//[ast]~^ ERROR cannot borrow `reg.sess_mut`
//[no2pb]~^^ ERROR cannot borrow `reg.sess_mut`
//[nll]~^^^ ERROR cannot borrow `reg.sess_mut`
let reg = mk_reg();
reg.register_bound(Box::new(TrivialPass::new_mut(&mut reg.sess_mut)));
//[ast]~^ ERROR cannot borrow `reg.sess_mut`
//[no2pb]~^^ ERROR cannot borrow `reg.sess_mut`
//[nll]~^^^ ERROR cannot borrow `reg.sess_mut`
let reg = mk_reg();
reg.register_univ(Box::new(TrivialPass::new_mut(&mut reg.sess_mut)));
//[ast]~^ ERROR cannot borrow `reg.sess_mut`
//[no2pb]~^^ ERROR cannot borrow `reg.sess_mut`
//[nll]~^^^ ERROR cannot borrow `reg.sess_mut`
let reg = mk_reg();
reg.register_ref(&TrivialPass::new_mut(&mut reg.sess_mut));
//[ast]~^ ERROR cannot borrow `reg.sess_mut`
//[no2pb]~^^ ERROR cannot borrow `reg.sess_mut`
//[nll]~^^^ ERROR cannot borrow `reg.sess_mut`
// These are not okay: the inner borrows may reach the actual
// method invocation, because `CapturePass::new` might (according
// to its type) keep them alive.
//
// (Also, we don't test `register_static` on CapturePass because
// that will fail to get past lifetime inference.)
let reg = mk_reg();
reg.register_bound(Box::new(CapturePass::new(&reg.sess_mut)));
//[ast]~^ ERROR cannot borrow `reg.sess_mut`
//[no2pb]~^^ ERROR cannot borrow `reg.sess_mut`
//[nll]~^^^ ERROR cannot borrow `*reg` as mutable
let reg = mk_reg();
reg.register_univ(Box::new(CapturePass::new(&reg.sess_mut)));
//[ast]~^ ERROR cannot borrow `reg.sess_mut`
//[no2pb]~^^ ERROR cannot borrow `reg.sess_mut`
//[nll]~^^^ ERROR cannot borrow `*reg` as mutable
let reg = mk_reg();
reg.register_ref(&CapturePass::new(&reg.sess_mut));
//[ast]~^ ERROR cannot borrow `reg.sess_mut`
//[no2pb]~^^ ERROR cannot borrow `reg.sess_mut`
//[nll]~^^^ ERROR cannot borrow `*reg` as mutable
// These are not okay: the inner mutable borrows immediately
// conflict with the outer borrow/reservation, even with support
// for two-phase borrows.
//
// (Again, we don't test `register_static` on CapturePass because
// that will fail to get past lifetime inference.)
let reg = mk_reg();
reg.register_bound(Box::new(CapturePass::new_mut(&mut reg.sess_mut)));
//[ast]~^ ERROR cannot borrow `reg.sess_mut`
//[no2pb]~^^ ERROR cannot borrow `reg.sess_mut`
//[nll]~^^^ ERROR cannot borrow `reg.sess_mut` as mutable more than once at a time
//[nll]~^^^^ ERROR cannot borrow `*reg` as mutable more than once at a time
let reg = mk_reg();
reg.register_univ(Box::new(CapturePass::new_mut(&mut reg.sess_mut)));
//[ast]~^ ERROR cannot borrow `reg.sess_mut`
//[no2pb]~^^ ERROR cannot borrow `reg.sess_mut`
//[nll]~^^^ ERROR cannot borrow `reg.sess_mut` as mutable more than once at a time
//[nll]~^^^^ ERROR cannot borrow `*reg` as mutable more than once at a time
let reg = mk_reg();
reg.register_ref(&CapturePass::new_mut(&mut reg.sess_mut));
//[ast]~^ ERROR cannot borrow `reg.sess_mut`
//[no2pb]~^^ ERROR cannot borrow `reg.sess_mut`
//[nll]~^^^ ERROR cannot borrow `reg.sess_mut` as mutable more than once at a time
//[nll]~^^^^ ERROR cannot borrow `*reg` as mutable more than once at a time
}
fn main() { }

View file

@ -0,0 +1,21 @@
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(core_intrinsics)]
use std::intrinsics;
const SHR: u8 = unsafe { intrinsics::unchecked_shr(5_u8, 8) };
//^~ ERROR: Overflowing shift by 8 in unchecked_shr
const SHL: u8 = unsafe { intrinsics::unchecked_shl(5_u8, 8) };
//^~ ERROR: Overflowing shift by 8 in unchecked_shl
fn main() {
}

View file

@ -0,0 +1,20 @@
error: this constant cannot be used
--> $DIR/const-int-unchecked.rs:15:1
|
LL | const SHR: u8 = unsafe { intrinsics::unchecked_shr(5_u8, 8) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^----------------------------------^^^
| |
| Overflowing shift by 8 in unchecked_shr
|
= note: #[deny(const_err)] on by default
error: this constant cannot be used
--> $DIR/const-int-unchecked.rs:17:1
|
LL | const SHL: u8 = unsafe { intrinsics::unchecked_shl(5_u8, 8) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^----------------------------------^^^
| |
| Overflowing shift by 8 in unchecked_shl
error: aborting due to 2 previous errors

View file

@ -15,7 +15,7 @@ fn generic<T>() {
generic::<Option<T>>();
}
//~^^^ ERROR reached the recursion limit while instantiating `generic::<std::option::Option<
//~| WARN function cannot return without recurring
//~| WARN function cannot return without recursing

View file

@ -1,8 +1,8 @@
warning: function cannot return without recurring
warning: function cannot return without recursing
--> $DIR/issue-8727.rs:14:1
|
LL | fn generic<T>() {
| ^^^^^^^^^^^^^^^ cannot return without recurring
| ^^^^^^^^^^^^^^^ cannot return without recursing
LL | generic::<Option<T>>();
| ---------------------- recursive call site
|

View file

@ -11,7 +11,7 @@
#![deny(unconditional_recursion)]
#![allow(dead_code)]
fn foo() { //~ ERROR function cannot return without recurring
fn foo() { //~ ERROR function cannot return without recursing
foo();
}
@ -21,7 +21,7 @@ fn bar() {
}
}
fn baz() { //~ ERROR function cannot return without recurring
fn baz() { //~ ERROR function cannot return without recursing
if true {
baz()
} else {
@ -33,7 +33,7 @@ fn qux() {
loop {}
}
fn quz() -> bool { //~ ERROR function cannot return without recurring
fn quz() -> bool { //~ ERROR function cannot return without recursing
if true {
while quz() {}
true
@ -44,13 +44,13 @@ fn quz() -> bool { //~ ERROR function cannot return without recurring
// Trait method calls.
trait Foo {
fn bar(&self) { //~ ERROR function cannot return without recurring
fn bar(&self) { //~ ERROR function cannot return without recursing
self.bar()
}
}
impl Foo for Box<Foo+'static> {
fn bar(&self) { //~ ERROR function cannot return without recurring
fn bar(&self) { //~ ERROR function cannot return without recursing
loop {
self.bar()
}
@ -59,7 +59,7 @@ impl Foo for Box<Foo+'static> {
// Trait method call with integer fallback after method resolution.
impl Foo for i32 {
fn bar(&self) { //~ ERROR function cannot return without recurring
fn bar(&self) { //~ ERROR function cannot return without recursing
0.bar()
}
}
@ -72,13 +72,13 @@ impl Foo for u32 {
// Trait method calls via paths.
trait Foo2 {
fn bar(&self) { //~ ERROR function cannot return without recurring
fn bar(&self) { //~ ERROR function cannot return without recursing
Foo2::bar(self)
}
}
impl Foo2 for Box<Foo2+'static> {
fn bar(&self) { //~ ERROR function cannot return without recurring
fn bar(&self) { //~ ERROR function cannot return without recursing
loop {
Foo2::bar(self)
}
@ -88,19 +88,19 @@ impl Foo2 for Box<Foo2+'static> {
struct Baz;
impl Baz {
// Inherent method call.
fn qux(&self) { //~ ERROR function cannot return without recurring
fn qux(&self) { //~ ERROR function cannot return without recursing
self.qux();
}
// Inherent method call via path.
fn as_ref(&self) -> &Self { //~ ERROR function cannot return without recurring
fn as_ref(&self) -> &Self { //~ ERROR function cannot return without recursing
Baz::as_ref(self)
}
}
// Trait method calls to impls via paths.
impl Default for Baz {
fn default() -> Baz { //~ ERROR function cannot return without recurring
fn default() -> Baz { //~ ERROR function cannot return without recursing
let x = Default::default();
x
}
@ -109,14 +109,14 @@ impl Default for Baz {
// Overloaded operators.
impl std::ops::Deref for Baz {
type Target = ();
fn deref(&self) -> &() { //~ ERROR function cannot return without recurring
fn deref(&self) -> &() { //~ ERROR function cannot return without recursing
&**self
}
}
impl std::ops::Index<usize> for Baz {
type Output = Baz;
fn index(&self, x: usize) -> &Baz { //~ ERROR function cannot return without recurring
fn index(&self, x: usize) -> &Baz { //~ ERROR function cannot return without recursing
&self[x]
}
}
@ -125,7 +125,7 @@ impl std::ops::Index<usize> for Baz {
struct Quux;
impl std::ops::Deref for Quux {
type Target = Baz;
fn deref(&self) -> &Baz { //~ ERROR function cannot return without recurring
fn deref(&self) -> &Baz { //~ ERROR function cannot return without recursing
self.as_ref()
}
}

View file

@ -1,8 +1,8 @@
error: function cannot return without recurring
error: function cannot return without recursing
--> $DIR/lint-unconditional-recursion.rs:14:1
|
LL | fn foo() { //~ ERROR function cannot return without recurring
| ^^^^^^^^ cannot return without recurring
LL | fn foo() { //~ ERROR function cannot return without recursing
| ^^^^^^^^ cannot return without recursing
LL | foo();
| ----- recursive call site
|
@ -13,11 +13,11 @@ LL | #![deny(unconditional_recursion)]
| ^^^^^^^^^^^^^^^^^^^^^^^
= help: a `loop` may express intention better if this is on purpose
error: function cannot return without recurring
error: function cannot return without recursing
--> $DIR/lint-unconditional-recursion.rs:24:1
|
LL | fn baz() { //~ ERROR function cannot return without recurring
| ^^^^^^^^ cannot return without recurring
LL | fn baz() { //~ ERROR function cannot return without recursing
| ^^^^^^^^ cannot return without recursing
LL | if true {
LL | baz()
| ----- recursive call site
@ -27,11 +27,11 @@ LL | baz()
|
= help: a `loop` may express intention better if this is on purpose
error: function cannot return without recurring
error: function cannot return without recursing
--> $DIR/lint-unconditional-recursion.rs:36:1
|
LL | fn quz() -> bool { //~ ERROR function cannot return without recurring
| ^^^^^^^^^^^^^^^^ cannot return without recurring
LL | fn quz() -> bool { //~ ERROR function cannot return without recursing
| ^^^^^^^^^^^^^^^^ cannot return without recursing
LL | if true {
LL | while quz() {}
| ----- recursive call site
@ -41,113 +41,113 @@ LL | loop { quz(); }
|
= help: a `loop` may express intention better if this is on purpose
error: function cannot return without recurring
error: function cannot return without recursing
--> $DIR/lint-unconditional-recursion.rs:47:5
|
LL | fn bar(&self) { //~ ERROR function cannot return without recurring
| ^^^^^^^^^^^^^ cannot return without recurring
LL | fn bar(&self) { //~ ERROR function cannot return without recursing
| ^^^^^^^^^^^^^ cannot return without recursing
LL | self.bar()
| ---------- recursive call site
|
= help: a `loop` may express intention better if this is on purpose
error: function cannot return without recurring
error: function cannot return without recursing
--> $DIR/lint-unconditional-recursion.rs:53:5
|
LL | fn bar(&self) { //~ ERROR function cannot return without recurring
| ^^^^^^^^^^^^^ cannot return without recurring
LL | fn bar(&self) { //~ ERROR function cannot return without recursing
| ^^^^^^^^^^^^^ cannot return without recursing
LL | loop {
LL | self.bar()
| ---------- recursive call site
|
= help: a `loop` may express intention better if this is on purpose
error: function cannot return without recurring
error: function cannot return without recursing
--> $DIR/lint-unconditional-recursion.rs:62:5
|
LL | fn bar(&self) { //~ ERROR function cannot return without recurring
| ^^^^^^^^^^^^^ cannot return without recurring
LL | fn bar(&self) { //~ ERROR function cannot return without recursing
| ^^^^^^^^^^^^^ cannot return without recursing
LL | 0.bar()
| ------- recursive call site
|
= help: a `loop` may express intention better if this is on purpose
error: function cannot return without recurring
error: function cannot return without recursing
--> $DIR/lint-unconditional-recursion.rs:75:5
|
LL | fn bar(&self) { //~ ERROR function cannot return without recurring
| ^^^^^^^^^^^^^ cannot return without recurring
LL | fn bar(&self) { //~ ERROR function cannot return without recursing
| ^^^^^^^^^^^^^ cannot return without recursing
LL | Foo2::bar(self)
| --------------- recursive call site
|
= help: a `loop` may express intention better if this is on purpose
error: function cannot return without recurring
error: function cannot return without recursing
--> $DIR/lint-unconditional-recursion.rs:81:5
|
LL | fn bar(&self) { //~ ERROR function cannot return without recurring
| ^^^^^^^^^^^^^ cannot return without recurring
LL | fn bar(&self) { //~ ERROR function cannot return without recursing
| ^^^^^^^^^^^^^ cannot return without recursing
LL | loop {
LL | Foo2::bar(self)
| --------------- recursive call site
|
= help: a `loop` may express intention better if this is on purpose
error: function cannot return without recurring
error: function cannot return without recursing
--> $DIR/lint-unconditional-recursion.rs:91:5
|
LL | fn qux(&self) { //~ ERROR function cannot return without recurring
| ^^^^^^^^^^^^^ cannot return without recurring
LL | fn qux(&self) { //~ ERROR function cannot return without recursing
| ^^^^^^^^^^^^^ cannot return without recursing
LL | self.qux();
| ---------- recursive call site
|
= help: a `loop` may express intention better if this is on purpose
error: function cannot return without recurring
error: function cannot return without recursing
--> $DIR/lint-unconditional-recursion.rs:96:5
|
LL | fn as_ref(&self) -> &Self { //~ ERROR function cannot return without recurring
| ^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recurring
LL | fn as_ref(&self) -> &Self { //~ ERROR function cannot return without recursing
| ^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing
LL | Baz::as_ref(self)
| ----------------- recursive call site
|
= help: a `loop` may express intention better if this is on purpose
error: function cannot return without recurring
error: function cannot return without recursing
--> $DIR/lint-unconditional-recursion.rs:103:5
|
LL | fn default() -> Baz { //~ ERROR function cannot return without recurring
| ^^^^^^^^^^^^^^^^^^^ cannot return without recurring
LL | fn default() -> Baz { //~ ERROR function cannot return without recursing
| ^^^^^^^^^^^^^^^^^^^ cannot return without recursing
LL | let x = Default::default();
| ------------------ recursive call site
|
= help: a `loop` may express intention better if this is on purpose
error: function cannot return without recurring
error: function cannot return without recursing
--> $DIR/lint-unconditional-recursion.rs:112:5
|
LL | fn deref(&self) -> &() { //~ ERROR function cannot return without recurring
| ^^^^^^^^^^^^^^^^^^^^^^ cannot return without recurring
LL | fn deref(&self) -> &() { //~ ERROR function cannot return without recursing
| ^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing
LL | &**self
| ------ recursive call site
|
= help: a `loop` may express intention better if this is on purpose
error: function cannot return without recurring
error: function cannot return without recursing
--> $DIR/lint-unconditional-recursion.rs:119:5
|
LL | fn index(&self, x: usize) -> &Baz { //~ ERROR function cannot return without recurring
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recurring
LL | fn index(&self, x: usize) -> &Baz { //~ ERROR function cannot return without recursing
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing
LL | &self[x]
| ------- recursive call site
|
= help: a `loop` may express intention better if this is on purpose
error: function cannot return without recurring
error: function cannot return without recursing
--> $DIR/lint-unconditional-recursion.rs:128:5
|
LL | fn deref(&self) -> &Baz { //~ ERROR function cannot return without recurring
| ^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recurring
LL | fn deref(&self) -> &Baz { //~ ERROR function cannot return without recursing
| ^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing
LL | self.as_ref()
| ---- recursive call site
|

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
// aux-build:helper.rs
// no-prefer-dynamic

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
// aux-build:custom.rs
// aux-build:helper.rs
// no-prefer-dynamic

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
// aux-build:custom.rs
// aux-build:custom-as-global.rs
// aux-build:helper.rs

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
use std::cell::Cell;
#[derive(Debug)]

View file

@ -8,6 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
#![allow(stable_features)]
#![feature(const_indexing)]
fn main() {

View file

@ -8,6 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
#![allow(overflowing_literals)]
// Test that we cleanup a fixed size Box<[D; k]> properly when D has a
// destructor.

View file

@ -8,6 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
#![allow(overflowing_literals)]
// Test that we cleanup dynamic sized Box<[D]> properly when D has a
// destructor.

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
// issues #10618 and #16382
// pretty-expanded FIXME #23616

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
// Checks that mutable static items can have mutable slices

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
// Check that the various ways of getting to a reference to a vec (both sized
// and unsized) work properly.

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
// Ensure that we can copy out of a fixed-size array.
//
// (Compare with compile-fail/move-out-of-array-1.rs)

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
// Ensure that we can do a destructuring bind of a fixed-size array,
// even when the element type has a destructor.

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
// pretty-expanded FIXME #23616
#![allow(unused_mut)]

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
pub fn main() {
let x = "hello";

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![allow(dead_assignment)]
// run-pass
pub fn main() {
let x : &[isize] = &[1,2,3,4,5];

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
pub fn main() {
let arr = [1,2,3];

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
use std::mem::size_of;

View file

@ -8,5 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
fn f(_a: Vec<isize> ) { }
pub fn main() { f(vec![1, 2, 3, 4, 5]); }

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
fn test1() {
let mut ints = [0; 32];

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
fn grow(v: &mut Vec<isize> ) {
v.push(1);
}

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
// Test that using the `vec!` macro nested within itself works
fn main() {

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
// Test that using the `vec!` macro nested within itself works
// when the contents implement Drop

View file

@ -8,6 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
#![allow(overflowing_literals)]
// ignore-emscripten no threads support
// Test that using the `vec!` macro nested within itself works when

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
static FOO: [isize; 3] = [1, 2, 3];
pub fn main() {

View file

@ -8,6 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
#![allow(non_camel_case_types)]
trait sum {
fn sum_(self) -> isize;

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
pub fn main() {
let x = [ [true]; 512 ];
let y = [ 0; 1 ];

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
#[derive(Debug)]
struct Foo(Box<[u8]>);

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
// Test slicing expressions on slices and Vecs.

View file

@ -8,6 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
#![allow(stable_features)]
// compile-flags: -C debug-assertions
#![feature(iter_to_slice)]

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
// ignore-emscripten no threads support
// Test that if a slicing expr[..] fails, the correct cleanups happen.

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
// ignore-emscripten no threads support
// Test that if a slicing expr[..] fails, the correct cleanups happen.

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
// Test slicing sugar.
extern crate core;

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
// Test binary_search_by_key lifetime. Issue #34683
#[derive(Debug)]

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
// Test that vec is now covariant in its argument type.
#![allow(dead_code)]

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
use std::vec;
pub fn main() {

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
#![feature(box_syntax)]
pub fn main() {

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
use std::mem::size_of;

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
pub fn main() {

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
pub fn main() {
let mut later: Vec<isize> ;

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
// ignore-emscripten no no_std executables
#![feature(lang_items, start, libc, alloc)]

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
pub fn main() {

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
fn one() -> i32 { 1 }

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
// pretty-expanded FIXME #23616
macro_rules! vec [

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
pub fn main() {

View file

@ -8,6 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
#![allow(illegal_floating_point_literal_pattern)] // FIXME #41620
pub fn main() {
let x = [1, 2, 3];
match x {

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
#![feature(slice_patterns)]
fn a() {

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
#![feature(slice_patterns)]
use std::fmt::Debug;

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
#![feature(slice_patterns)]
pub fn main() {

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
#![feature(slice_patterns)]
fn a() {

View file

@ -8,4 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
pub fn main() { let mut v = vec![1, 2, 3]; v.push(1); }

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
// pretty-expanded FIXME #23616
pub fn main() { let _a = [0; 1 as usize]; }

View file

@ -8,6 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
#![allow(non_camel_case_types)]
use std::cell::Cell;
// Make sure that destructors get run on slice literals

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
pub fn main() {
let v = vec![1,2,3,4,5];

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
#![feature(slice_patterns)]
struct Foo {

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
pub fn main() {
assert_eq!(format!("{:?}", vec![0, 1]), "[0, 1]".to_string());

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
pub fn main() {

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
use std::cell::Cell;
#[derive(Debug)]

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
use std::cell::Cell;
#[derive(Debug)]

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
// pretty-expanded FIXME #23616
#![feature(box_syntax)]

View file

@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
trait Foo {
const NUM: usize;

View file

@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
// aux-build:associated-const-cc-lib.rs

View file

@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
// aux-build:associated-const-cc-lib.rs

View file

@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
// aux-build:associated-const-cc-lib.rs

View file

@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
struct Foo;

View file

@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
struct Foo;

View file

@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
#![deny(dead_code)]

View file

@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
// aux-build:empty-struct.rs

View file

@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
trait Lattice {
const BOTTOM: Self;
}

Some files were not shown because too many files have changed in this diff Show more