Skip to content

Commit 3eeefc2

Browse files
committed
Auto merge of #69374 - Dylan-DPC:rollup-x7mjd5z, r=Dylan-DPC
Rollup of 7 pull requests Successful merges: - #68984 (Make `u8::is_ascii` a stable `const fn`) - #69339 (Add test for #69312) - #69346 (Clean up E0323, E0324, E0325 and E0326 explanations) - #69348 (Wrong error message for move_ref_pattern) - #69349 (MIR is not an experiment anymore) - #69354 (Test `Duration::new` panics on overflow) - #69370 (move const_eval.rs into the module folder) Failed merges: r? @ghost
2 parents 0753459 + e5fb129 commit 3eeefc2

File tree

16 files changed

+69
-41
lines changed

16 files changed

+69
-41
lines changed

src/libcore/num/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4324,8 +4324,9 @@ impl u8 {
43244324
/// assert!(!non_ascii.is_ascii());
43254325
/// ```
43264326
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
4327+
#[rustc_const_stable(feature = "const_ascii_methods_on_intrinsics", since = "1.43.0")]
43274328
#[inline]
4328-
pub fn is_ascii(&self) -> bool {
4329+
pub const fn is_ascii(&self) -> bool {
43294330
*self & 128 == 0
43304331
}
43314332

src/libcore/tests/time.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ fn creation() {
1111
assert_eq!(Duration::from_millis(4000), Duration::new(4, 0));
1212
}
1313

14+
#[test]
15+
#[should_panic]
16+
fn new_overflow() {
17+
let _ = Duration::new(::core::u64::MAX, 1_000_000_000);
18+
}
19+
1420
#[test]
1521
fn secs() {
1622
assert_eq!(Duration::new(0, 0).as_secs(), 0);

src/librustc_error_codes/error_codes/E0323.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
An associated const was implemented when another trait item was expected.
2+
23
Erroneous code example:
34

45
```compile_fail,E0323

src/librustc_error_codes/error_codes/E0324.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
A method was implemented when another trait item was expected. Erroneous
2-
code example:
1+
A method was implemented when another trait item was expected.
2+
3+
Erroneous code example:
34

45
```compile_fail,E0324
56
struct Bar;

src/librustc_error_codes/error_codes/E0325.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
An associated type was implemented when another trait item was expected.
2+
23
Erroneous code example:
34

45
```compile_fail,E0325

src/librustc_error_codes/error_codes/E0326.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
The types of any associated constants in a trait implementation must match the
2-
types in the trait definition. This error indicates that there was a mismatch.
1+
An implementation of a trait doesn't match the type contraint.
32

4-
Here's an example of this error:
3+
Erroneous code example:
54

65
```compile_fail,E0326
76
trait Foo {
@@ -14,3 +13,6 @@ impl Foo for Bar {
1413
const BAR: u32 = 5; // error, expected bool, found u32
1514
}
1615
```
16+
17+
The types of any associated constants in a trait implementation must match the
18+
types in the trait definition.
File renamed without changes.

src/librustc_mir/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*!
22
3-
Rust MIR: a lowered representation of Rust. Also: an experiment!
3+
Rust MIR: a lowered representation of Rust.
44
55
*/
66

src/librustc_mir_build/hair/pattern/check_match.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ fn check_borrow_conflicts_in_at_patterns(cx: &MatchVisitor<'_, '_>, pat: &Pat<'_
659659
});
660660
if !conflicts_ref.is_empty() {
661661
let occurs_because = format!(
662-
"move occurs because `{}` has type `{}` which does implement the `Copy` trait",
662+
"move occurs because `{}` has type `{}` which does not implement the `Copy` trait",
663663
name,
664664
tables.node_type(pat.hir_id),
665665
);

src/test/ui/consts/std/char.rs renamed to src/test/ui/consts/is_ascii.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@
33
static X: bool = 'a'.is_ascii();
44
static Y: bool = 'ä'.is_ascii();
55

6+
static BX: bool = b'a'.is_ascii();
7+
static BY: bool = 192u8.is_ascii();
8+
69
fn main() {
710
assert!(X);
811
assert!(!Y);
12+
13+
assert!(BX);
14+
assert!(!BY);
915
}

0 commit comments

Comments
 (0)