Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 7 pull requests #69374

Merged
merged 16 commits into from
Feb 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/libcore/num/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4324,8 +4324,9 @@ impl u8 {
/// assert!(!non_ascii.is_ascii());
/// ```
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
#[rustc_const_stable(feature = "const_ascii_methods_on_intrinsics", since = "1.43.0")]
#[inline]
pub fn is_ascii(&self) -> bool {
pub const fn is_ascii(&self) -> bool {
*self & 128 == 0
}

Expand Down
6 changes: 6 additions & 0 deletions src/libcore/tests/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ fn creation() {
assert_eq!(Duration::from_millis(4000), Duration::new(4, 0));
}

#[test]
#[should_panic]
fn new_overflow() {
let _ = Duration::new(::core::u64::MAX, 1_000_000_000);
}

#[test]
fn secs() {
assert_eq!(Duration::new(0, 0).as_secs(), 0);
Expand Down
1 change: 1 addition & 0 deletions src/librustc_error_codes/error_codes/E0323.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
An associated const was implemented when another trait item was expected.

Erroneous code example:

```compile_fail,E0323
Expand Down
5 changes: 3 additions & 2 deletions src/librustc_error_codes/error_codes/E0324.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
A method was implemented when another trait item was expected. Erroneous
code example:
A method was implemented when another trait item was expected.

Erroneous code example:

```compile_fail,E0324
struct Bar;
Expand Down
1 change: 1 addition & 0 deletions src/librustc_error_codes/error_codes/E0325.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
An associated type was implemented when another trait item was expected.

Erroneous code example:

```compile_fail,E0325
Expand Down
8 changes: 5 additions & 3 deletions src/librustc_error_codes/error_codes/E0326.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
The types of any associated constants in a trait implementation must match the
types in the trait definition. This error indicates that there was a mismatch.
An implementation of a trait doesn't match the type contraint.

Here's an example of this error:
Erroneous code example:

```compile_fail,E0326
trait Foo {
Expand All @@ -14,3 +13,6 @@ impl Foo for Bar {
const BAR: u32 = 5; // error, expected bool, found u32
}
```

The types of any associated constants in a trait implementation must match the
types in the trait definition.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/librustc_mir/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!

Rust MIR: a lowered representation of Rust. Also: an experiment!
Rust MIR: a lowered representation of Rust.

*/

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir_build/hair/pattern/check_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ fn check_borrow_conflicts_in_at_patterns(cx: &MatchVisitor<'_, '_>, pat: &Pat<'_
});
if !conflicts_ref.is_empty() {
let occurs_because = format!(
"move occurs because `{}` has type `{}` which does implement the `Copy` trait",
"move occurs because `{}` has type `{}` which does not implement the `Copy` trait",
name,
tables.node_type(pat.hir_id),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
static X: bool = 'a'.is_ascii();
static Y: bool = 'ä'.is_ascii();

static BX: bool = b'a'.is_ascii();
static BY: bool = 192u8.is_ascii();

fn main() {
assert!(X);
assert!(!Y);

assert!(BX);
assert!(!BY);
}
10 changes: 10 additions & 0 deletions src/test/ui/consts/issue-69312.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// build-pass

// Verify that the compiler doesn't ICE during const prop while evaluating the index operation.

#![allow(unconditional_panic)]

fn main() {
let cols = [0u32; 0];
cols[0];
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ LL | Some(_z @ ref _y) => {}
| | |
| | value borrowed here after move
| value moved into `_z` here
| move occurs because `_z` has type `X` which does implement the `Copy` trait
| move occurs because `_z` has type `X` which does not implement the `Copy` trait

error: cannot move out of value because it is borrowed
--> $DIR/bind-by-move-neither-can-live-while-the-other-survives-1.rs:29:14
Expand All @@ -34,7 +34,7 @@ LL | Some(_z @ ref mut _y) => {}
| | |
| | value borrowed here after move
| value moved into `_z` here
| move occurs because `_z` has type `X` which does implement the `Copy` trait
| move occurs because `_z` has type `X` which does not implement the `Copy` trait

error[E0382]: borrow of moved value
--> $DIR/bind-by-move-neither-can-live-while-the-other-survives-1.rs:21:19
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ LL | let a @ ref b = U;
| | |
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `main::U` which does implement the `Copy` trait
| move occurs because `a` has type `main::U` which does not implement the `Copy` trait

error: aborting due to previous error

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ LL | let a @ ref b = U;
| | |
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `main::U` which does implement the `Copy` trait
| move occurs because `a` has type `main::U` which does not implement the `Copy` trait

error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:31:9
Expand All @@ -17,7 +17,7 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (U, U);
| | | value borrowed here after move
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `(main::U, main::U)` which does implement the `Copy` trait
| move occurs because `a` has type `(main::U, main::U)` which does not implement the `Copy` trait

error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:31:14
Expand All @@ -27,7 +27,7 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (U, U);
| | |
| | value borrowed here after move
| value moved into `b` here
| move occurs because `b` has type `main::U` which does implement the `Copy` trait
| move occurs because `b` has type `main::U` which does not implement the `Copy` trait

error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:31:33
Expand All @@ -37,7 +37,7 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (U, U);
| | |
| | value borrowed here after move
| value moved into `d` here
| move occurs because `d` has type `main::U` which does implement the `Copy` trait
| move occurs because `d` has type `main::U` which does not implement the `Copy` trait

error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:38:9
Expand All @@ -48,7 +48,7 @@ LL | let a @ [ref mut b, ref c] = [U, U];
| | | value borrowed here after move
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `[main::U; 2]` which does implement the `Copy` trait
| move occurs because `a` has type `[main::U; 2]` which does not implement the `Copy` trait

error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:41:9
Expand All @@ -58,7 +58,7 @@ LL | let a @ ref b = u();
| | |
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `main::U` which does implement the `Copy` trait
| move occurs because `a` has type `main::U` which does not implement the `Copy` trait

error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:44:9
Expand All @@ -69,7 +69,7 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (u(), u());
| | | value borrowed here after move
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `(main::U, main::U)` which does implement the `Copy` trait
| move occurs because `a` has type `(main::U, main::U)` which does not implement the `Copy` trait

error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:44:14
Expand All @@ -79,7 +79,7 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (u(), u());
| | |
| | value borrowed here after move
| value moved into `b` here
| move occurs because `b` has type `main::U` which does implement the `Copy` trait
| move occurs because `b` has type `main::U` which does not implement the `Copy` trait

error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:44:33
Expand All @@ -89,7 +89,7 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (u(), u());
| | |
| | value borrowed here after move
| value moved into `d` here
| move occurs because `d` has type `main::U` which does implement the `Copy` trait
| move occurs because `d` has type `main::U` which does not implement the `Copy` trait

error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:51:9
Expand All @@ -100,7 +100,7 @@ LL | let a @ [ref mut b, ref c] = [u(), u()];
| | | value borrowed here after move
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `[main::U; 2]` which does implement the `Copy` trait
| move occurs because `a` has type `[main::U; 2]` which does not implement the `Copy` trait

error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:56:9
Expand All @@ -110,7 +110,7 @@ LL | a @ Some(ref b) => {}
| | |
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `std::option::Option<main::U>` which does implement the `Copy` trait
| move occurs because `a` has type `std::option::Option<main::U>` which does not implement the `Copy` trait

error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:61:9
Expand All @@ -121,7 +121,7 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {}
| | | value borrowed here after move
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `std::option::Option<(main::U, main::U)>` which does implement the `Copy` trait
| move occurs because `a` has type `std::option::Option<(main::U, main::U)>` which does not implement the `Copy` trait

error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:61:19
Expand All @@ -131,7 +131,7 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {}
| | |
| | value borrowed here after move
| value moved into `b` here
| move occurs because `b` has type `main::U` which does implement the `Copy` trait
| move occurs because `b` has type `main::U` which does not implement the `Copy` trait

error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:61:38
Expand All @@ -141,7 +141,7 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {}
| | |
| | value borrowed here after move
| value moved into `d` here
| move occurs because `d` has type `main::U` which does implement the `Copy` trait
| move occurs because `d` has type `main::U` which does not implement the `Copy` trait

error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:71:9
Expand All @@ -152,7 +152,7 @@ LL | mut a @ Some([ref b, ref mut c]) => {}
| | | value borrowed here after move
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `std::option::Option<[main::U; 2]>` which does implement the `Copy` trait
| move occurs because `a` has type `std::option::Option<[main::U; 2]>` which does not implement the `Copy` trait

error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:77:9
Expand All @@ -162,7 +162,7 @@ LL | a @ Some(ref b) => {}
| | |
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `std::option::Option<main::U>` which does implement the `Copy` trait
| move occurs because `a` has type `std::option::Option<main::U>` which does not implement the `Copy` trait

error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:83:9
Expand All @@ -173,7 +173,7 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {}
| | | value borrowed here after move
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `std::option::Option<(main::U, main::U)>` which does implement the `Copy` trait
| move occurs because `a` has type `std::option::Option<(main::U, main::U)>` which does not implement the `Copy` trait

error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:83:19
Expand All @@ -183,7 +183,7 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {}
| | |
| | value borrowed here after move
| value moved into `b` here
| move occurs because `b` has type `main::U` which does implement the `Copy` trait
| move occurs because `b` has type `main::U` which does not implement the `Copy` trait

error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:83:38
Expand All @@ -193,7 +193,7 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {}
| | |
| | value borrowed here after move
| value moved into `d` here
| move occurs because `d` has type `main::U` which does implement the `Copy` trait
| move occurs because `d` has type `main::U` which does not implement the `Copy` trait

error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:93:9
Expand All @@ -204,7 +204,7 @@ LL | mut a @ Some([ref b, ref mut c]) => {}
| | | value borrowed here after move
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `std::option::Option<[main::U; 2]>` which does implement the `Copy` trait
| move occurs because `a` has type `std::option::Option<[main::U; 2]>` which does not implement the `Copy` trait

error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:14:11
Expand All @@ -214,7 +214,7 @@ LL | fn f1(a @ ref b: U) {}
| | |
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `main::U` which does implement the `Copy` trait
| move occurs because `a` has type `main::U` which does not implement the `Copy` trait

error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:18:11
Expand All @@ -225,7 +225,7 @@ LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {}
| | | value borrowed here after move
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `(main::U, main::U)` which does implement the `Copy` trait
| move occurs because `a` has type `(main::U, main::U)` which does not implement the `Copy` trait

error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:18:20
Expand All @@ -235,7 +235,7 @@ LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {}
| | |
| | value borrowed here after move
| value moved into `b` here
| move occurs because `b` has type `main::U` which does implement the `Copy` trait
| move occurs because `b` has type `main::U` which does not implement the `Copy` trait

error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:18:31
Expand All @@ -245,7 +245,7 @@ LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {}
| | |
| | value borrowed here after move
| value moved into `d` here
| move occurs because `d` has type `main::U` which does implement the `Copy` trait
| move occurs because `d` has type `main::U` which does not implement the `Copy` trait

error: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:25:11
Expand All @@ -256,7 +256,7 @@ LL | fn f3(a @ [ref mut b, ref c]: [U; 2]) {}
| | | value borrowed here after move
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `[main::U; 2]` which does implement the `Copy` trait
| move occurs because `a` has type `[main::U; 2]` which does not implement the `Copy` trait

error[E0382]: borrow of moved value
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:31:22
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ LL | let a @ (ref mut b, ref mut c) = (U, U);
| | | value borrowed here after move
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `(main::U, main::U)` which does implement the `Copy` trait
| move occurs because `a` has type `(main::U, main::U)` which does not implement the `Copy` trait

error: borrow of moved value
--> $DIR/borrowck-pat-ref-mut-twice.rs:70:9
Expand All @@ -108,7 +108,7 @@ LL | let a @ (b, [c, d]) = &mut val; // Same as ^--
| | | value borrowed here after move
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `&mut (main::U, [main::U; 2])` which does implement the `Copy` trait
| move occurs because `a` has type `&mut (main::U, [main::U; 2])` which does not implement the `Copy` trait

error: borrow of moved value
--> $DIR/borrowck-pat-ref-mut-twice.rs:74:9
Expand All @@ -118,7 +118,7 @@ LL | let a @ &mut ref mut b = &mut U;
| | |
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `&mut main::U` which does implement the `Copy` trait
| move occurs because `a` has type `&mut main::U` which does not implement the `Copy` trait

error: borrow of moved value
--> $DIR/borrowck-pat-ref-mut-twice.rs:77:9
Expand All @@ -129,7 +129,7 @@ LL | let a @ &mut (ref mut b, ref mut c) = &mut (U, U);
| | | value borrowed here after move
| | value borrowed here after move
| value moved into `a` here
| move occurs because `a` has type `&mut (main::U, main::U)` which does implement the `Copy` trait
| move occurs because `a` has type `&mut (main::U, main::U)` which does not implement the `Copy` trait

error: cannot borrow value as mutable more than once at a time
--> $DIR/borrowck-pat-ref-mut-twice.rs:82:9
Expand Down
Loading