Skip to content

Commit 0ebd3ab

Browse files
committed
Auto merge of #101411 - matthiaskrgr:rollup-uj24yb5, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #101322 (Fix internal doc link) - #101385 (updated description of File struct in std::fs) - #101388 (Don't delay invalid LHS bug unless it will be covered by an error in `check_overloaded_binop`) - #101394 (Forbid mixing `System` with direct sytem allocator calls) - #101397 (rustdoc: remove redundant mobile-sized `.source nav:not(.sidebar).sub`) - #101401 (Make `char::is_lowercase` and `char::is_uppercase` const) - #101407 (Remove duplicated test (superseeded by search-form-elements.goml)) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents a2cdcb3 + cea11f5 commit 0ebd3ab

File tree

14 files changed

+130
-60
lines changed

14 files changed

+130
-60
lines changed

compiler/rustc_typeck/src/check/op.rs

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,28 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
5757
)
5858
.is_ok()
5959
{
60-
// Suppress this error, since we already emitted
61-
// a deref suggestion in check_overloaded_binop
62-
err.downgrade_to_delayed_bug();
60+
// If LHS += RHS is an error, but *LHS += RHS is successful, then we will have
61+
// emitted a better suggestion during error handling in check_overloaded_binop.
62+
if self
63+
.lookup_op_method(
64+
lhs_ty,
65+
Some(rhs_ty),
66+
Some(rhs),
67+
Op::Binary(op, IsAssign::Yes),
68+
expected,
69+
)
70+
.is_err()
71+
{
72+
err.downgrade_to_delayed_bug();
73+
} else {
74+
// Otherwise, it's valid to suggest dereferencing the LHS here.
75+
err.span_suggestion_verbose(
76+
lhs.span.shrink_to_lo(),
77+
"consider dereferencing the left-hand side of this operation",
78+
"*",
79+
Applicability::MaybeIncorrect,
80+
);
81+
}
6382
}
6483
}
6584
});

library/alloc/src/collections/btree/dedup_sorted_iter.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ use core::iter::Peekable;
33
/// A iterator for deduping the key of a sorted iterator.
44
/// When encountering the duplicated key, only the last key-value pair is yielded.
55
///
6-
/// Used by [`BTreeMap::bulk_build_from_sorted_iter`].
6+
/// Used by [`BTreeMap::bulk_build_from_sorted_iter`][1].
7+
///
8+
/// [1]: crate::collections::BTreeMap::bulk_build_from_sorted_iter
79
pub struct DedupSortedIter<K, V, I>
810
where
911
I: Iterator<Item = (K, V)>,

library/core/src/char/methods.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -746,10 +746,19 @@ impl char {
746746
/// assert!(!'中'.is_lowercase());
747747
/// assert!(!' '.is_lowercase());
748748
/// ```
749+
///
750+
/// In a const context:
751+
///
752+
/// ```
753+
/// #![feature(const_unicode_case_lookup)]
754+
/// const CAPITAL_DELTA_IS_LOWERCASE: bool = 'Δ'.is_lowercase();
755+
/// assert!(!CAPITAL_DELTA_IS_LOWERCASE);
756+
/// ```
749757
#[must_use]
750758
#[stable(feature = "rust1", since = "1.0.0")]
759+
#[rustc_const_unstable(feature = "const_unicode_case_lookup", issue = "101400")]
751760
#[inline]
752-
pub fn is_lowercase(self) -> bool {
761+
pub const fn is_lowercase(self) -> bool {
753762
match self {
754763
'a'..='z' => true,
755764
c => c > '\x7f' && unicode::Lowercase(c),
@@ -779,10 +788,19 @@ impl char {
779788
/// assert!(!'中'.is_uppercase());
780789
/// assert!(!' '.is_uppercase());
781790
/// ```
791+
///
792+
/// In a const context:
793+
///
794+
/// ```
795+
/// #![feature(const_unicode_case_lookup)]
796+
/// const CAPITAL_DELTA_IS_UPPERCASE: bool = 'Δ'.is_uppercase();
797+
/// assert!(CAPITAL_DELTA_IS_UPPERCASE);
798+
/// ```
782799
#[must_use]
783800
#[stable(feature = "rust1", since = "1.0.0")]
801+
#[rustc_const_unstable(feature = "const_unicode_case_lookup", issue = "101400")]
784802
#[inline]
785-
pub fn is_uppercase(self) -> bool {
803+
pub const fn is_uppercase(self) -> bool {
786804
match self {
787805
'A'..='Z' => true,
788806
c => c > '\x7f' && unicode::Uppercase(c),

library/core/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@
143143
#![feature(const_type_id)]
144144
#![feature(const_type_name)]
145145
#![feature(const_default_impls)]
146+
#![feature(const_unicode_case_lookup)]
146147
#![feature(const_unsafecell_get_mut)]
147148
#![feature(core_panic)]
148149
#![feature(duration_consts_float)]

library/core/src/unicode/unicode_data.rs

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
///! This file is generated by src/tools/unicode-table-generator; do not edit manually!
22
3+
#[rustc_const_unstable(feature = "const_unicode_case_lookup", issue = "101400")]
34
#[inline(always)]
4-
fn bitset_search<
5+
const fn bitset_search<
56
const N: usize,
67
const CHUNK_SIZE: usize,
78
const N1: usize,
@@ -17,14 +18,18 @@ fn bitset_search<
1718
let bucket_idx = (needle / 64) as usize;
1819
let chunk_map_idx = bucket_idx / CHUNK_SIZE;
1920
let chunk_piece = bucket_idx % CHUNK_SIZE;
20-
let chunk_idx = if let Some(&v) = chunk_idx_map.get(chunk_map_idx) {
21-
v
21+
// FIXME: const-hack: Revert to `slice::get` after `const_slice_index`
22+
// feature stabilizes.
23+
let chunk_idx = if chunk_map_idx < chunk_idx_map.len() {
24+
chunk_idx_map[chunk_map_idx]
2225
} else {
2326
return false;
2427
};
2528
let idx = bitset_chunk_idx[chunk_idx as usize][chunk_piece] as usize;
26-
let word = if let Some(word) = bitset_canonical.get(idx) {
27-
*word
29+
// FIXME: const-hack: Revert to `slice::get` after `const_slice_index`
30+
// feature stabilizes.
31+
let word = if idx < bitset_canonical.len() {
32+
bitset_canonical[idx]
2833
} else {
2934
let (real_idx, mapping) = bitset_canonicalized[idx - bitset_canonical.len()];
3035
let mut word = bitset_canonical[real_idx as usize];
@@ -318,14 +323,14 @@ pub mod grapheme_extend {
318323

319324
#[rustfmt::skip]
320325
pub mod lowercase {
321-
static BITSET_CHUNKS_MAP: [u8; 123] = [
326+
const BITSET_CHUNKS_MAP: &'static [u8; 123] = &[
322327
14, 17, 0, 0, 9, 0, 0, 12, 13, 10, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
323328
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
324329
0, 0, 0, 4, 1, 0, 15, 0, 8, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
325330
0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0,
326331
3, 0, 0, 7,
327332
];
328-
static BITSET_INDEX_CHUNKS: [[u8; 16]; 19] = [
333+
const BITSET_INDEX_CHUNKS: &'static [[u8; 16]; 19] = &[
329334
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
330335
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 59, 0, 0],
331336
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 14, 55, 0],
@@ -346,7 +351,7 @@ pub mod lowercase {
346351
[16, 49, 2, 20, 66, 9, 57, 0, 0, 0, 0, 0, 0, 0, 0, 0],
347352
[63, 39, 54, 12, 73, 61, 18, 1, 6, 62, 71, 19, 68, 69, 3, 44],
348353
];
349-
static BITSET_CANONICAL: [u64; 55] = [
354+
const BITSET_CANONICAL: &'static [u64; 55] = &[
350355
0b0000000000000000000000000000000000000000000000000000000000000000,
351356
0b1111111111111111110000000000000000000000000011111111111111111111,
352357
0b1010101010101010101010101010101010101010101010101010100000000010,
@@ -403,13 +408,14 @@ pub mod lowercase {
403408
0b1110011111111111111111111111111111111111111111110000000000000000,
404409
0b1110101111000000000000000000000000001111111111111111111111111100,
405410
];
406-
static BITSET_MAPPING: [(u8, u8); 20] = [
411+
const BITSET_MAPPING: &'static [(u8, u8); 20] = &[
407412
(0, 64), (1, 188), (1, 183), (1, 176), (1, 109), (1, 124), (1, 126), (1, 66), (1, 70),
408413
(1, 77), (2, 146), (2, 144), (2, 83), (3, 12), (3, 6), (4, 156), (4, 78), (5, 187),
409414
(6, 132), (7, 93),
410415
];
411416

412-
pub fn lookup(c: char) -> bool {
417+
#[rustc_const_unstable(feature = "const_unicode_case_lookup", issue = "101400")]
418+
pub const fn lookup(c: char) -> bool {
413419
super::bitset_search(
414420
c as u32,
415421
&BITSET_CHUNKS_MAP,
@@ -454,14 +460,14 @@ pub mod n {
454460

455461
#[rustfmt::skip]
456462
pub mod uppercase {
457-
static BITSET_CHUNKS_MAP: [u8; 125] = [
463+
const BITSET_CHUNKS_MAP: &'static [u8; 125] = &[
458464
12, 15, 6, 6, 0, 6, 6, 2, 4, 11, 6, 16, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
459465
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 8, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
460466
6, 6, 6, 5, 6, 14, 6, 10, 6, 6, 1, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
461467
6, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 13, 6, 6,
462468
6, 6, 9, 6, 3,
463469
];
464-
static BITSET_INDEX_CHUNKS: [[u8; 16]; 17] = [
470+
const BITSET_INDEX_CHUNKS: &'static [[u8; 16]; 17] = &[
465471
[43, 43, 5, 34, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 5, 1],
466472
[43, 43, 5, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43],
467473
[43, 43, 39, 43, 43, 43, 43, 43, 17, 17, 62, 17, 42, 29, 24, 23],
@@ -480,7 +486,7 @@ pub mod uppercase {
480486
[57, 19, 2, 18, 10, 47, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43],
481487
[57, 37, 17, 27, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43],
482488
];
483-
static BITSET_CANONICAL: [u64; 43] = [
489+
const BITSET_CANONICAL: &'static [u64; 43] = &[
484490
0b0000011111111111111111111111111000000000000000000000000000000000,
485491
0b0000000000111111111111111111111111111111111111111111111111111111,
486492
0b0101010101010101010101010101010101010101010101010101010000000001,
@@ -525,13 +531,14 @@ pub mod uppercase {
525531
0b1111011111111111000000000000000000000000000000000000000000000000,
526532
0b1111111100000000111111110000000000111111000000001111111100000000,
527533
];
528-
static BITSET_MAPPING: [(u8, u8); 25] = [
534+
const BITSET_MAPPING: &'static [(u8, u8); 25] = &[
529535
(0, 187), (0, 177), (0, 171), (0, 167), (0, 164), (0, 32), (0, 47), (0, 51), (0, 121),
530536
(0, 117), (0, 109), (1, 150), (1, 148), (1, 142), (1, 134), (1, 131), (1, 64), (2, 164),
531537
(2, 146), (2, 20), (3, 146), (3, 140), (3, 134), (4, 178), (4, 171),
532538
];
533539

534-
pub fn lookup(c: char) -> bool {
540+
#[rustc_const_unstable(feature = "const_unicode_case_lookup", issue = "101400")]
541+
pub const fn lookup(c: char) -> bool {
535542
super::bitset_search(
536543
c as u32,
537544
&BITSET_CHUNKS_MAP,

library/std/src/alloc.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,10 @@ pub use alloc_crate::alloc::*;
6868
/// The default memory allocator provided by the operating system.
6969
///
7070
/// This is based on `malloc` on Unix platforms and `HeapAlloc` on Windows,
71-
/// plus related functions.
71+
/// plus related functions. However, it is not valid to mix use of the backing
72+
/// system allocator with `System`, as this implementation may include extra
73+
/// work, such as to serve alignment requests greater than the alignment
74+
/// provided directly by the backing system allocator.
7275
///
7376
/// This type implements the `GlobalAlloc` trait and Rust programs by default
7477
/// work as if they had this definition:

library/std/src/fs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use crate::sys::fs as fs_imp;
1919
use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner};
2020
use crate::time::SystemTime;
2121

22-
/// A reference to an open file on the filesystem.
22+
/// An object providing access to an open file on the filesystem.
2323
///
2424
/// An instance of a `File` can be read and/or written depending on what options
2525
/// it was opened with. Files also implement [`Seek`] to alter the logical cursor

src/ci/docker/host-x86_64/mingw-check/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ ENV SCRIPT python3 ../x.py --stage 2 test src/tools/expand-yaml-anchors && \
4545
python3 ../x.py test --stage 0 src/tools/compiletest && \
4646
python3 ../x.py test --stage 2 src/tools/tidy && \
4747
python3 ../x.py test --stage 0 core alloc std test proc_macro && \
48-
python3 ../x.py doc --stage 0 library/test && \
48+
# Build both public and internal documentation.
49+
RUSTDOCFLAGS="--document-private-items" python3 ../x.py doc --stage 0 library/test && \
4950
/scripts/validate-toolstate.sh && \
5051
/scripts/validate-error-codes.sh && \
5152
reuse lint && \

src/librustdoc/html/static/css/rustdoc.css

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1883,10 +1883,6 @@ in storage.js plus the media query with (min-width: 701px)
18831883
background-color: var(--sidebar-background-color);
18841884
}
18851885

1886-
.source nav:not(.sidebar).sub {
1887-
margin-left: 32px;
1888-
}
1889-
18901886
.content {
18911887
margin-left: 0px;
18921888
}

src/test/rustdoc-gui/search-input.goml

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)