Skip to content

Commit 41dfaaa

Browse files
committed
Auto merge of rust-lang#89739 - matthiaskrgr:rollup-kskwqy5, r=matthiaskrgr
Rollup of 11 pull requests Successful merges: - rust-lang#88374 (Fix documentation in Cell) - rust-lang#88713 (Improve docs for int_log) - rust-lang#89428 (Feature gate the non_exhaustive_omitted_patterns lint) - rust-lang#89438 (docs: `std::hash::Hash` should ensure prefix-free data) - rust-lang#89520 (Don't rebuild GUI test crates every time you run test src/test/rustdoc-gui) - rust-lang#89705 (Cfg hide no_global_oom_handling and no_fp_fmt_parse) - rust-lang#89713 (Fix ABNF of inline asm options) - rust-lang#89718 (Add #[must_use] to is_condition tests) - rust-lang#89719 (Add #[must_use] to char escape methods) - rust-lang#89720 (Add #[must_use] to math and bit manipulation methods) - rust-lang#89735 (Stabilize proc_macro::is_available) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 68dfa07 + 4d89488 commit 41dfaaa

File tree

28 files changed

+518
-71
lines changed

28 files changed

+518
-71
lines changed

compiler/rustc_feature/src/active.rs

+3
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,9 @@ declare_features! (
678678
/// Allows `#[doc(cfg_hide(...))]`.
679679
(active, doc_cfg_hide, "1.57.0", Some(43781), None),
680680

681+
/// Allows using the `non_exhaustive_omitted_patterns` lint.
682+
(active, non_exhaustive_omitted_patterns_lint, "1.57.0", Some(89554), None),
683+
681684
// -------------------------------------------------------------------------
682685
// feature-group-end: actual feature gates
683686
// -------------------------------------------------------------------------

compiler/rustc_lint_defs/src/builtin.rs

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
77
use crate::{declare_lint, declare_lint_pass, FutureIncompatibilityReason};
88
use rustc_span::edition::Edition;
9+
use rustc_span::symbol::sym;
910

1011
declare_lint! {
1112
/// The `forbidden_lint_groups` lint detects violations of
@@ -3476,6 +3477,8 @@ declare_lint! {
34763477
/// }
34773478
///
34783479
/// // in crate B
3480+
/// #![feature(non_exhaustive_omitted_patterns_lint)]
3481+
///
34793482
/// match Bar::A {
34803483
/// Bar::A => {},
34813484
/// #[warn(non_exhaustive_omitted_patterns)]
@@ -3512,6 +3515,7 @@ declare_lint! {
35123515
pub NON_EXHAUSTIVE_OMITTED_PATTERNS,
35133516
Allow,
35143517
"detect when patterns of types marked `non_exhaustive` are missed",
3518+
@feature_gate = sym::non_exhaustive_omitted_patterns_lint;
35153519
}
35163520

35173521
declare_lint! {

compiler/rustc_span/src/symbol.rs

+1
Original file line numberDiff line numberDiff line change
@@ -893,6 +893,7 @@ symbols! {
893893
nomem,
894894
non_ascii_idents,
895895
non_exhaustive,
896+
non_exhaustive_omitted_patterns_lint,
896897
non_modrs_mods,
897898
none_error,
898899
nontemporal_store,

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

+3
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,7 @@ impl<T> BTreeSet<T> {
534534
/// b.insert(1);
535535
/// assert_eq!(a.is_disjoint(&b), false);
536536
/// ```
537+
#[must_use]
537538
#[stable(feature = "rust1", since = "1.0.0")]
538539
pub fn is_disjoint(&self, other: &BTreeSet<T>) -> bool
539540
where
@@ -559,6 +560,7 @@ impl<T> BTreeSet<T> {
559560
/// set.insert(4);
560561
/// assert_eq!(set.is_subset(&sup), false);
561562
/// ```
563+
#[must_use]
562564
#[stable(feature = "rust1", since = "1.0.0")]
563565
pub fn is_subset(&self, other: &BTreeSet<T>) -> bool
564566
where
@@ -638,6 +640,7 @@ impl<T> BTreeSet<T> {
638640
/// set.insert(2);
639641
/// assert_eq!(set.is_superset(&sub), true);
640642
/// ```
643+
#[must_use]
641644
#[stable(feature = "rust1", since = "1.0.0")]
642645
pub fn is_superset(&self, other: &BTreeSet<T>) -> bool
643646
where

library/alloc/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
not(test),
7474
not(any(test, bootstrap)),
7575
any(not(feature = "miri-test-libstd"), test, doctest),
76+
no_global_oom_handling,
7677
target_has_atomic = "ptr"
7778
))
7879
)]

library/core/src/cell.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ impl<T> Cell<T> {
349349
drop(old);
350350
}
351351

352-
/// Swaps the values of two Cells.
352+
/// Swaps the values of two `Cell`s.
353353
/// Difference with `std::mem::swap` is that this function doesn't require `&mut` reference.
354354
///
355355
/// # Examples

library/core/src/char/methods.rs

+25
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,8 @@ impl char {
377377
/// ```
378378
/// assert_eq!('❤'.escape_unicode().to_string(), "\\u{2764}");
379379
/// ```
380+
#[must_use = "this returns the escaped char as an iterator, \
381+
without modifying the original"]
380382
#[stable(feature = "rust1", since = "1.0.0")]
381383
#[inline]
382384
pub fn escape_unicode(self) -> EscapeUnicode {
@@ -453,6 +455,8 @@ impl char {
453455
/// ```
454456
/// assert_eq!('\n'.escape_debug().to_string(), "\\n");
455457
/// ```
458+
#[must_use = "this returns the escaped char as an iterator, \
459+
without modifying the original"]
456460
#[stable(feature = "char_escape_debug", since = "1.20.0")]
457461
#[inline]
458462
pub fn escape_debug(self) -> EscapeDebug {
@@ -507,6 +511,8 @@ impl char {
507511
/// ```
508512
/// assert_eq!('"'.escape_default().to_string(), "\\\"");
509513
/// ```
514+
#[must_use = "this returns the escaped char as an iterator, \
515+
without modifying the original"]
510516
#[stable(feature = "rust1", since = "1.0.0")]
511517
#[inline]
512518
pub fn escape_default(self) -> EscapeDefault {
@@ -692,6 +698,7 @@ impl char {
692698
/// // love is many things, but it is not alphabetic
693699
/// assert!(!c.is_alphabetic());
694700
/// ```
701+
#[must_use]
695702
#[stable(feature = "rust1", since = "1.0.0")]
696703
#[inline]
697704
pub fn is_alphabetic(self) -> bool {
@@ -724,6 +731,7 @@ impl char {
724731
/// assert!(!'中'.is_lowercase());
725732
/// assert!(!' '.is_lowercase());
726733
/// ```
734+
#[must_use]
727735
#[stable(feature = "rust1", since = "1.0.0")]
728736
#[inline]
729737
pub fn is_lowercase(self) -> bool {
@@ -756,6 +764,7 @@ impl char {
756764
/// assert!(!'中'.is_uppercase());
757765
/// assert!(!' '.is_uppercase());
758766
/// ```
767+
#[must_use]
759768
#[stable(feature = "rust1", since = "1.0.0")]
760769
#[inline]
761770
pub fn is_uppercase(self) -> bool {
@@ -784,6 +793,7 @@ impl char {
784793
///
785794
/// assert!(!'越'.is_whitespace());
786795
/// ```
796+
#[must_use]
787797
#[stable(feature = "rust1", since = "1.0.0")]
788798
#[inline]
789799
pub fn is_whitespace(self) -> bool {
@@ -812,6 +822,7 @@ impl char {
812822
/// assert!('و'.is_alphanumeric());
813823
/// assert!('藏'.is_alphanumeric());
814824
/// ```
825+
#[must_use]
815826
#[stable(feature = "rust1", since = "1.0.0")]
816827
#[inline]
817828
pub fn is_alphanumeric(self) -> bool {
@@ -837,6 +848,7 @@ impl char {
837848
/// assert!('œ'.is_control());
838849
/// assert!(!'q'.is_control());
839850
/// ```
851+
#[must_use]
840852
#[stable(feature = "rust1", since = "1.0.0")]
841853
#[inline]
842854
pub fn is_control(self) -> bool {
@@ -852,6 +864,7 @@ impl char {
852864
/// [uax29]: https://www.unicode.org/reports/tr29/
853865
/// [ucd]: https://www.unicode.org/reports/tr44/
854866
/// [`DerivedCoreProperties.txt`]: https://www.unicode.org/Public/UCD/latest/ucd/DerivedCoreProperties.txt
867+
#[must_use]
855868
#[inline]
856869
pub(crate) fn is_grapheme_extended(self) -> bool {
857870
unicode::Grapheme_Extend(self)
@@ -881,6 +894,7 @@ impl char {
881894
/// assert!(!'و'.is_numeric());
882895
/// assert!(!'藏'.is_numeric());
883896
/// ```
897+
#[must_use]
884898
#[stable(feature = "rust1", since = "1.0.0")]
885899
#[inline]
886900
pub fn is_numeric(self) -> bool {
@@ -1060,6 +1074,7 @@ impl char {
10601074
/// assert!(ascii.is_ascii());
10611075
/// assert!(!non_ascii.is_ascii());
10621076
/// ```
1077+
#[must_use]
10631078
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
10641079
#[rustc_const_stable(feature = "const_ascii_methods_on_intrinsics", since = "1.32.0")]
10651080
#[inline]
@@ -1237,6 +1252,7 @@ impl char {
12371252
/// assert!(!lf.is_ascii_alphabetic());
12381253
/// assert!(!esc.is_ascii_alphabetic());
12391254
/// ```
1255+
#[must_use]
12401256
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
12411257
#[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")]
12421258
#[inline]
@@ -1270,6 +1286,7 @@ impl char {
12701286
/// assert!(!lf.is_ascii_uppercase());
12711287
/// assert!(!esc.is_ascii_uppercase());
12721288
/// ```
1289+
#[must_use]
12731290
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
12741291
#[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")]
12751292
#[inline]
@@ -1303,6 +1320,7 @@ impl char {
13031320
/// assert!(!lf.is_ascii_lowercase());
13041321
/// assert!(!esc.is_ascii_lowercase());
13051322
/// ```
1323+
#[must_use]
13061324
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
13071325
#[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")]
13081326
#[inline]
@@ -1339,6 +1357,7 @@ impl char {
13391357
/// assert!(!lf.is_ascii_alphanumeric());
13401358
/// assert!(!esc.is_ascii_alphanumeric());
13411359
/// ```
1360+
#[must_use]
13421361
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
13431362
#[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")]
13441363
#[inline]
@@ -1372,6 +1391,7 @@ impl char {
13721391
/// assert!(!lf.is_ascii_digit());
13731392
/// assert!(!esc.is_ascii_digit());
13741393
/// ```
1394+
#[must_use]
13751395
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
13761396
#[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")]
13771397
#[inline]
@@ -1408,6 +1428,7 @@ impl char {
14081428
/// assert!(!lf.is_ascii_hexdigit());
14091429
/// assert!(!esc.is_ascii_hexdigit());
14101430
/// ```
1431+
#[must_use]
14111432
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
14121433
#[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")]
14131434
#[inline]
@@ -1445,6 +1466,7 @@ impl char {
14451466
/// assert!(!lf.is_ascii_punctuation());
14461467
/// assert!(!esc.is_ascii_punctuation());
14471468
/// ```
1469+
#[must_use]
14481470
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
14491471
#[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")]
14501472
#[inline]
@@ -1478,6 +1500,7 @@ impl char {
14781500
/// assert!(!lf.is_ascii_graphic());
14791501
/// assert!(!esc.is_ascii_graphic());
14801502
/// ```
1503+
#[must_use]
14811504
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
14821505
#[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")]
14831506
#[inline]
@@ -1528,6 +1551,7 @@ impl char {
15281551
/// assert!(lf.is_ascii_whitespace());
15291552
/// assert!(!esc.is_ascii_whitespace());
15301553
/// ```
1554+
#[must_use]
15311555
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
15321556
#[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")]
15331557
#[inline]
@@ -1563,6 +1587,7 @@ impl char {
15631587
/// assert!(lf.is_ascii_control());
15641588
/// assert!(esc.is_ascii_control());
15651589
/// ```
1590+
#[must_use]
15661591
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
15671592
#[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")]
15681593
#[inline]

library/core/src/hash/mod.rs

+12
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,21 @@ mod sip;
153153
/// Thankfully, you won't need to worry about upholding this property when
154154
/// deriving both [`Eq`] and `Hash` with `#[derive(PartialEq, Eq, Hash)]`.
155155
///
156+
/// ## Prefix collisions
157+
///
158+
/// Implementations of `hash` should ensure that the data they
159+
/// pass to the `Hasher` are prefix-free. That is,
160+
/// unequal values should cause two different sequences of values to be written,
161+
/// and neither of the two sequences should be a prefix of the other.
162+
///
163+
/// For example, the standard implementation of [`Hash` for `&str`][impl] passes an extra
164+
/// `0xFF` byte to the `Hasher` so that the values `("ab", "c")` and `("a",
165+
/// "bc")` hash differently.
166+
///
156167
/// [`HashMap`]: ../../std/collections/struct.HashMap.html
157168
/// [`HashSet`]: ../../std/collections/struct.HashSet.html
158169
/// [`hash`]: Hash::hash
170+
/// [impl]: ../../std/primitive.str.html#impl-Hash
159171
#[stable(feature = "rust1", since = "1.0.0")]
160172
#[rustc_diagnostic_item = "Hash"]
161173
pub trait Hash {

library/core/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
doc(cfg_hide(
6666
not(test),
6767
any(not(feature = "miri-test-libstd"), test, doctest),
68+
no_fp_fmt_parse,
6869
target_pointer_width = "16",
6970
target_pointer_width = "32",
7071
target_pointer_width = "64",

0 commit comments

Comments
 (0)