Auto merge of #64354 - Centril:rollup-oaq0xoi, r=Centril

Rollup of 8 pull requests

Successful merges:

 - #63786 (Make `abs`, `wrapping_abs`, `overflowing_abs` const functions)
 - #63989 (Add Yaah to clippy toolstain notification list)
 - #64256 (test/c-variadic: Fix patterns on powerpc64)
 - #64292 (lowering: extend temporary lifetimes around await)
 - #64311 (lldb: avoid mixing "Hit breakpoint" message with other output.)
 - #64330 (Clarify E0507 to note Fn/FnMut relationship to borrowing)
 - #64331 (Changed instant is earlier to instant is later)
 - #64344 (rustc_mir: buffer -Zdump-mir output instead of pestering the kernel constantly.)

Failed merges:

r? @ghost
This commit is contained in:
bors 2019-09-10 16:19:48 +00:00
commit 34e82a7b79
14 changed files with 117 additions and 70 deletions

View File

@ -45,7 +45,10 @@ def normalize_whitespace(s):
def breakpoint_callback(frame, bp_loc, dict):
"""This callback is registered with every breakpoint and makes sure that the
frame containing the breakpoint location is selected"""
frame containing the breakpoint location is selected """
# HACK(eddyb) print a newline to avoid continuing an unfinished line.
print("")
print("Hit breakpoint " + str(bp_loc))
# Select the frame and the thread containing it

View File

@ -1401,12 +1401,8 @@ $EndFeature, "
```"),
#[stable(feature = "no_panic_abs", since = "1.13.0")]
#[inline]
pub fn wrapping_abs(self) -> Self {
if self.is_negative() {
self.wrapping_neg()
} else {
self
}
pub const fn wrapping_abs(self) -> Self {
(self ^ (self >> ($BITS - 1))).wrapping_sub(self >> ($BITS - 1))
}
}
@ -1764,12 +1760,8 @@ $EndFeature, "
```"),
#[stable(feature = "no_panic_abs", since = "1.13.0")]
#[inline]
pub fn overflowing_abs(self) -> (Self, bool) {
if self.is_negative() {
self.overflowing_neg()
} else {
(self, false)
}
pub const fn overflowing_abs(self) -> (Self, bool) {
(self ^ (self >> ($BITS - 1))).overflowing_sub(self >> ($BITS - 1))
}
}
@ -1973,15 +1965,11 @@ $EndFeature, "
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
#[rustc_inherit_overflow_checks]
pub fn abs(self) -> Self {
if self.is_negative() {
// Note that the #[inline] above means that the overflow
// semantics of this negation depend on the crate we're being
// inlined into.
-self
} else {
self
}
pub const fn abs(self) -> Self {
// Note that the #[inline] above means that the overflow
// semantics of the subtraction depend on the crate we're being
// inlined into.
(self ^ (self >> ($BITS - 1))) - (self >> ($BITS - 1))
}
}

View File

@ -507,14 +507,13 @@ impl LoweringContext<'_> {
/// Desugar `<expr>.await` into:
/// ```rust
/// {
/// let mut pinned = <expr>;
/// loop {
/// match <expr> {
/// mut pinned => loop {
/// match ::std::future::poll_with_tls_context(unsafe {
/// ::std::pin::Pin::new_unchecked(&mut pinned)
/// <::std::pin::Pin>::new_unchecked(&mut pinned)
/// }) {
/// ::std::task::Poll::Ready(result) => break result,
/// ::std::task::Poll::Pending => {},
/// ::std::task::Poll::Pending => {}
/// }
/// yield ();
/// }
@ -549,21 +548,12 @@ impl LoweringContext<'_> {
self.allow_gen_future.clone(),
);
// let mut pinned = <expr>;
let expr = P(self.lower_expr(expr));
let pinned_ident = Ident::with_dummy_span(sym::pinned);
let (pinned_pat, pinned_pat_hid) = self.pat_ident_binding_mode(
span,
pinned_ident,
hir::BindingAnnotation::Mutable,
);
let pinned_let = self.stmt_let_pat(
ThinVec::new(),
span,
Some(expr),
pinned_pat,
hir::LocalSource::AwaitDesugar,
);
// ::std::future::poll_with_tls_context(unsafe {
// ::std::pin::Pin::new_unchecked(&mut pinned)
@ -621,7 +611,7 @@ impl LoweringContext<'_> {
self.arm(hir_vec![pending_pat], empty_block)
};
let match_stmt = {
let inner_match_stmt = {
let match_expr = self.expr_match(
span,
poll_expr,
@ -643,10 +633,11 @@ impl LoweringContext<'_> {
let loop_block = P(self.block_all(
span,
hir_vec![match_stmt, yield_stmt],
hir_vec![inner_match_stmt, yield_stmt],
None,
));
// loop { .. }
let loop_expr = P(hir::Expr {
hir_id: loop_hir_id,
node: hir::ExprKind::Loop(
@ -658,10 +649,14 @@ impl LoweringContext<'_> {
attrs: ThinVec::new(),
});
hir::ExprKind::Block(
P(self.block_all(span, hir_vec![pinned_let], Some(loop_expr))),
None,
)
// mut pinned => loop { ... }
let pinned_arm = self.arm(hir_vec![pinned_pat], loop_expr);
// match <expr> {
// mut pinned => loop { .. }
// }
let expr = P(self.lower_expr(expr));
hir::ExprKind::Match(expr, hir_vec![pinned_arm], hir::MatchSource::AwaitDesugar)
}
fn lower_expr_closure(

View File

@ -1646,7 +1646,14 @@ fn print_fancy_ref(fancy_ref: &FancyNum){
"##,
E0507: r##"
You tried to move out of a value which was borrowed. Erroneous code example:
You tried to move out of a value which was borrowed.
This can also happen when using a type implementing `Fn` or `FnMut`, as neither
allows moving out of them (they usually represent closures which can be called
more than once). Much of the text following applies equally well to non-`FnOnce`
closure bodies.
Erroneous code example:
```compile_fail,E0507
use std::cell::RefCell;

View File

@ -227,12 +227,12 @@ pub(crate) fn create_dump_file(
pass_name: &str,
disambiguator: &dyn Display,
source: MirSource<'tcx>,
) -> io::Result<fs::File> {
) -> io::Result<io::BufWriter<fs::File>> {
let file_path = dump_path(tcx, extension, pass_num, pass_name, disambiguator, source);
if let Some(parent) = file_path.parent() {
fs::create_dir_all(parent)?;
}
fs::File::create(&file_path)
Ok(io::BufWriter::new(fs::File::create(&file_path)?))
}
/// Write out a human-readable textual representation for the given MIR.

View File

@ -216,7 +216,7 @@ impl Instant {
}
/// Returns the amount of time elapsed from another instant to this one,
/// or None if that instant is earlier than this one.
/// or None if that instant is later than this one.
///
/// # Examples
///

View File

@ -1,4 +1,5 @@
// compile-flags: -C no-prepopulate-passes
// ignore-tidy-linelength
#![crate_type = "lib"]
#![feature(c_variadic)]
@ -14,13 +15,13 @@ extern "C" {
#[unwind(aborts)] // FIXME(#58794)
pub unsafe extern "C" fn use_foreign_c_variadic_0() {
// Ensure that we correctly call foreign C-variadic functions.
// CHECK: invoke void (i32, ...) @foreign_c_variadic_0(i32 0)
// CHECK: invoke void (i32, ...) @foreign_c_variadic_0([[PARAM:i32( signext)?]] 0)
foreign_c_variadic_0(0);
// CHECK: invoke void (i32, ...) @foreign_c_variadic_0(i32 0, i32 42)
// CHECK: invoke void (i32, ...) @foreign_c_variadic_0([[PARAM]] 0, [[PARAM]] 42)
foreign_c_variadic_0(0, 42i32);
// CHECK: invoke void (i32, ...) @foreign_c_variadic_0(i32 0, i32 42, i32 1024)
// CHECK: invoke void (i32, ...) @foreign_c_variadic_0([[PARAM]] 0, [[PARAM]] 42, [[PARAM]] 1024)
foreign_c_variadic_0(0, 42i32, 1024i32);
// CHECK: invoke void (i32, ...) @foreign_c_variadic_0(i32 0, i32 42, i32 1024, i32 0)
// CHECK: invoke void (i32, ...) @foreign_c_variadic_0([[PARAM]] 0, [[PARAM]] 42, [[PARAM]] 1024, [[PARAM]] 0)
foreign_c_variadic_0(0, 42i32, 1024i32, 0i32);
}
@ -34,18 +35,18 @@ pub unsafe extern "C" fn use_foreign_c_variadic_1_0(ap: VaList) {
#[unwind(aborts)] // FIXME(#58794)
pub unsafe extern "C" fn use_foreign_c_variadic_1_1(ap: VaList) {
// CHECK: invoke void ({{.*}}*, ...) @foreign_c_variadic_1({{.*}} %ap, i32 42)
// CHECK: invoke void ({{.*}}*, ...) @foreign_c_variadic_1({{.*}} %ap, [[PARAM]] 42)
foreign_c_variadic_1(ap, 42i32);
}
#[unwind(aborts)] // FIXME(#58794)
pub unsafe extern "C" fn use_foreign_c_variadic_1_2(ap: VaList) {
// CHECK: invoke void ({{.*}}*, ...) @foreign_c_variadic_1({{.*}} %ap, i32 2, i32 42)
// CHECK: invoke void ({{.*}}*, ...) @foreign_c_variadic_1({{.*}} %ap, [[PARAM]] 2, [[PARAM]] 42)
foreign_c_variadic_1(ap, 2i32, 42i32);
}
#[unwind(aborts)] // FIXME(#58794)
pub unsafe extern "C" fn use_foreign_c_variadic_1_3(ap: VaList) {
// CHECK: invoke void ({{.*}}*, ...) @foreign_c_variadic_1({{.*}} %ap, i32 2, i32 42, i32 0)
// CHECK: invoke void ({{.*}}*, ...) @foreign_c_variadic_1({{.*}} %ap, [[PARAM]] 2, [[PARAM]] 42, [[PARAM]] 0)
foreign_c_variadic_1(ap, 2i32, 42i32, 0i32);
}
@ -64,12 +65,12 @@ pub unsafe extern "C" fn c_variadic(n: i32, mut ap: ...) -> i32 {
// Ensure that we generate the correct `call` signature when calling a Rust
// defined C-variadic.
pub unsafe fn test_c_variadic_call() {
// CHECK: call i32 (i32, ...) @c_variadic(i32 0)
// CHECK: call [[RET:(signext )?i32]] (i32, ...) @c_variadic([[PARAM]] 0)
c_variadic(0);
// CHECK: call i32 (i32, ...) @c_variadic(i32 0, i32 42)
// CHECK: call [[RET]] (i32, ...) @c_variadic([[PARAM]] 0, [[PARAM]] 42)
c_variadic(0, 42i32);
// CHECK: call i32 (i32, ...) @c_variadic(i32 0, i32 42, i32 1024)
// CHECK: call [[RET]] (i32, ...) @c_variadic([[PARAM]] 0, [[PARAM]] 42, [[PARAM]] 1024)
c_variadic(0, 42i32, 1024i32);
// CHECK: call i32 (i32, ...) @c_variadic(i32 0, i32 42, i32 1024, i32 0)
// CHECK: call [[RET]] (i32, ...) @c_variadic([[PARAM]] 0, [[PARAM]] 42, [[PARAM]] 1024, [[PARAM]] 0)
c_variadic(0, 42i32, 1024i32, 0i32);
}

View File

@ -9,9 +9,9 @@ LL | assert_send(local_dropped_before_await());
|
= help: within `impl std::future::Future`, the trait `std::marker::Send` is not implemented for `std::rc::Rc<()>`
= note: required because it appears within the type `impl std::fmt::Debug`
= note: required because it appears within the type `{impl std::fmt::Debug, impl std::future::Future, ()}`
= note: required because it appears within the type `[static generator@$DIR/async-fn-nonsend.rs:21:39: 26:2 {impl std::fmt::Debug, impl std::future::Future, ()}]`
= note: required because it appears within the type `std::future::GenFuture<[static generator@$DIR/async-fn-nonsend.rs:21:39: 26:2 {impl std::fmt::Debug, impl std::future::Future, ()}]>`
= note: required because it appears within the type `{impl std::fmt::Debug, fn() -> impl std::future::Future {fut}, impl std::future::Future, ()}`
= note: required because it appears within the type `[static generator@$DIR/async-fn-nonsend.rs:21:39: 26:2 {impl std::fmt::Debug, fn() -> impl std::future::Future {fut}, impl std::future::Future, ()}]`
= note: required because it appears within the type `std::future::GenFuture<[static generator@$DIR/async-fn-nonsend.rs:21:39: 26:2 {impl std::fmt::Debug, fn() -> impl std::future::Future {fut}, impl std::future::Future, ()}]>`
= note: required because it appears within the type `impl std::future::Future`
= note: required because it appears within the type `impl std::future::Future`
@ -26,9 +26,9 @@ LL | assert_send(non_send_temporary_in_match());
|
= help: within `impl std::future::Future`, the trait `std::marker::Send` is not implemented for `std::rc::Rc<()>`
= note: required because it appears within the type `impl std::fmt::Debug`
= note: required because it appears within the type `{fn(impl std::fmt::Debug) -> std::option::Option<impl std::fmt::Debug> {std::option::Option::<impl std::fmt::Debug>::Some}, fn() -> impl std::fmt::Debug {non_send}, impl std::fmt::Debug, std::option::Option<impl std::fmt::Debug>, impl std::future::Future, ()}`
= note: required because it appears within the type `[static generator@$DIR/async-fn-nonsend.rs:28:40: 37:2 {fn(impl std::fmt::Debug) -> std::option::Option<impl std::fmt::Debug> {std::option::Option::<impl std::fmt::Debug>::Some}, fn() -> impl std::fmt::Debug {non_send}, impl std::fmt::Debug, std::option::Option<impl std::fmt::Debug>, impl std::future::Future, ()}]`
= note: required because it appears within the type `std::future::GenFuture<[static generator@$DIR/async-fn-nonsend.rs:28:40: 37:2 {fn(impl std::fmt::Debug) -> std::option::Option<impl std::fmt::Debug> {std::option::Option::<impl std::fmt::Debug>::Some}, fn() -> impl std::fmt::Debug {non_send}, impl std::fmt::Debug, std::option::Option<impl std::fmt::Debug>, impl std::future::Future, ()}]>`
= note: required because it appears within the type `{fn(impl std::fmt::Debug) -> std::option::Option<impl std::fmt::Debug> {std::option::Option::<impl std::fmt::Debug>::Some}, fn() -> impl std::fmt::Debug {non_send}, impl std::fmt::Debug, std::option::Option<impl std::fmt::Debug>, fn() -> impl std::future::Future {fut}, impl std::future::Future, ()}`
= note: required because it appears within the type `[static generator@$DIR/async-fn-nonsend.rs:28:40: 37:2 {fn(impl std::fmt::Debug) -> std::option::Option<impl std::fmt::Debug> {std::option::Option::<impl std::fmt::Debug>::Some}, fn() -> impl std::fmt::Debug {non_send}, impl std::fmt::Debug, std::option::Option<impl std::fmt::Debug>, fn() -> impl std::future::Future {fut}, impl std::future::Future, ()}]`
= note: required because it appears within the type `std::future::GenFuture<[static generator@$DIR/async-fn-nonsend.rs:28:40: 37:2 {fn(impl std::fmt::Debug) -> std::option::Option<impl std::fmt::Debug> {std::option::Option::<impl std::fmt::Debug>::Some}, fn() -> impl std::fmt::Debug {non_send}, impl std::fmt::Debug, std::option::Option<impl std::fmt::Debug>, fn() -> impl std::future::Future {fut}, impl std::future::Future, ()}]>`
= note: required because it appears within the type `impl std::future::Future`
= note: required because it appears within the type `impl std::future::Future`
@ -45,9 +45,9 @@ LL | assert_send(non_sync_with_method_call());
= note: required because of the requirements on the impl of `std::marker::Send` for `&mut dyn std::fmt::Write`
= note: required because it appears within the type `std::fmt::Formatter<'_>`
= note: required because of the requirements on the impl of `std::marker::Send` for `&mut std::fmt::Formatter<'_>`
= note: required because it appears within the type `for<'r, 's> {&'r mut std::fmt::Formatter<'s>, bool, impl std::future::Future, ()}`
= note: required because it appears within the type `[static generator@$DIR/async-fn-nonsend.rs:39:38: 45:2 for<'r, 's> {&'r mut std::fmt::Formatter<'s>, bool, impl std::future::Future, ()}]`
= note: required because it appears within the type `std::future::GenFuture<[static generator@$DIR/async-fn-nonsend.rs:39:38: 45:2 for<'r, 's> {&'r mut std::fmt::Formatter<'s>, bool, impl std::future::Future, ()}]>`
= note: required because it appears within the type `for<'r, 's> {&'r mut std::fmt::Formatter<'s>, bool, fn() -> impl std::future::Future {fut}, impl std::future::Future, ()}`
= note: required because it appears within the type `[static generator@$DIR/async-fn-nonsend.rs:39:38: 45:2 for<'r, 's> {&'r mut std::fmt::Formatter<'s>, bool, fn() -> impl std::future::Future {fut}, impl std::future::Future, ()}]`
= note: required because it appears within the type `std::future::GenFuture<[static generator@$DIR/async-fn-nonsend.rs:39:38: 45:2 for<'r, 's> {&'r mut std::fmt::Formatter<'s>, bool, fn() -> impl std::future::Future {fut}, impl std::future::Future, ()}]>`
= note: required because it appears within the type `impl std::future::Future`
= note: required because it appears within the type `impl std::future::Future`
@ -68,9 +68,9 @@ LL | assert_send(non_sync_with_method_call());
= note: required because of the requirements on the impl of `std::marker::Send` for `std::slice::Iter<'_, std::fmt::ArgumentV1<'_>>`
= note: required because it appears within the type `std::fmt::Formatter<'_>`
= note: required because of the requirements on the impl of `std::marker::Send` for `&mut std::fmt::Formatter<'_>`
= note: required because it appears within the type `for<'r, 's> {&'r mut std::fmt::Formatter<'s>, bool, impl std::future::Future, ()}`
= note: required because it appears within the type `[static generator@$DIR/async-fn-nonsend.rs:39:38: 45:2 for<'r, 's> {&'r mut std::fmt::Formatter<'s>, bool, impl std::future::Future, ()}]`
= note: required because it appears within the type `std::future::GenFuture<[static generator@$DIR/async-fn-nonsend.rs:39:38: 45:2 for<'r, 's> {&'r mut std::fmt::Formatter<'s>, bool, impl std::future::Future, ()}]>`
= note: required because it appears within the type `for<'r, 's> {&'r mut std::fmt::Formatter<'s>, bool, fn() -> impl std::future::Future {fut}, impl std::future::Future, ()}`
= note: required because it appears within the type `[static generator@$DIR/async-fn-nonsend.rs:39:38: 45:2 for<'r, 's> {&'r mut std::fmt::Formatter<'s>, bool, fn() -> impl std::future::Future {fut}, impl std::future::Future, ()}]`
= note: required because it appears within the type `std::future::GenFuture<[static generator@$DIR/async-fn-nonsend.rs:39:38: 45:2 for<'r, 's> {&'r mut std::fmt::Formatter<'s>, bool, fn() -> impl std::future::Future {fut}, impl std::future::Future, ()}]>`
= note: required because it appears within the type `impl std::future::Future`
= note: required because it appears within the type `impl std::future::Future`

View File

@ -0,0 +1,19 @@
// check-pass
// edition:2018
struct Test(String);
impl Test {
async fn borrow_async(&self) {}
fn with(&mut self, s: &str) -> &mut Self {
self.0 = s.into();
self
}
}
async fn test() {
Test("".to_string()).with("123").borrow_async().await;
}
fn main() { }

View File

@ -0,0 +1,12 @@
// check-pass
// edition:2018
async fn foo(x: &[Vec<u32>]) -> u32 {
0
}
async fn bar() {
foo(&[vec![123]]).await;
}
fn main() { }

View File

@ -18,6 +18,10 @@ const SHR_B: (u32, bool) = 0x10u32.overflowing_shr(132);
const NEG_A: (u32, bool) = 0u32.overflowing_neg();
const NEG_B: (u32, bool) = core::u32::MAX.overflowing_neg();
const ABS_POS: (i32, bool) = 10i32.overflowing_abs();
const ABS_NEG: (i32, bool) = (-10i32).overflowing_abs();
const ABS_MIN: (i32, bool) = i32::min_value().overflowing_abs();
fn main() {
assert_eq!(ADD_A, (7, false));
assert_eq!(ADD_B, (0, true));
@ -36,4 +40,8 @@ fn main() {
assert_eq!(NEG_A, (0, false));
assert_eq!(NEG_B, (1, true));
assert_eq!(ABS_POS, (10, false));
assert_eq!(ABS_NEG, (10, false));
assert_eq!(ABS_MIN, (i32::min_value(), true));
}

View File

@ -11,6 +11,9 @@ const SIGNUM_POS: i32 = 10i32.signum();
const SIGNUM_NIL: i32 = 0i32.signum();
const SIGNUM_NEG: i32 = (-42i32).signum();
const ABS_A: i32 = 10i32.abs();
const ABS_B: i32 = (-10i32).abs();
fn main() {
assert!(NEGATIVE_A);
assert!(!NEGATIVE_B);
@ -20,4 +23,7 @@ fn main() {
assert_eq!(SIGNUM_POS, 1);
assert_eq!(SIGNUM_NIL, 0);
assert_eq!(SIGNUM_NEG, -1);
assert_eq!(ABS_A, 10);
assert_eq!(ABS_B, 10);
}

View File

@ -18,6 +18,10 @@ const SHR_B: u32 = 128u32.wrapping_shr(128);
const NEG_A: u32 = 5u32.wrapping_neg();
const NEG_B: u32 = 1234567890u32.wrapping_neg();
const ABS_POS: i32 = 10i32.wrapping_abs();
const ABS_NEG: i32 = (-10i32).wrapping_abs();
const ABS_MIN: i32 = i32::min_value().wrapping_abs();
fn main() {
assert_eq!(ADD_A, 255);
assert_eq!(ADD_B, 199);
@ -36,4 +40,8 @@ fn main() {
assert_eq!(NEG_A, 4294967291);
assert_eq!(NEG_B, 3060399406);
assert_eq!(ABS_POS, 10);
assert_eq!(ABS_NEG, 10);
assert_eq!(ABS_MIN, i32::min_value());
}

View File

@ -22,7 +22,7 @@ except ImportError:
# List of people to ping when the status of a tool or a book changed.
MAINTAINERS = {
'miri': '@oli-obk @RalfJung @eddyb',
'clippy-driver': '@Manishearth @llogiq @mcarton @oli-obk @phansch @flip1995',
'clippy-driver': '@Manishearth @llogiq @mcarton @oli-obk @phansch @flip1995 @yaahc',
'rls': '@Xanewok',
'rustfmt': '@topecongiro',
'book': '@carols10cents @steveklabnik',