Skip to content

Commit 04689e2

Browse files
committed
Auto merge of rust-lang#71907 - Dylan-DPC:rollup-z8iaqlv, r=Dylan-DPC
Rollup of 10 pull requests Successful merges: - rust-lang#71587 (Report cannot move errors in promoted MIR) - rust-lang#71711 (Updates to some ignored tests) - rust-lang#71845 (Add const examples) - rust-lang#71878 (Add remove_current_as_list to LinkedList's CursorMut) - rust-lang#71881 (Correctly handle UEFI targets as Windows-like when emitting sections for LLVM bitcode) - rust-lang#71883 (add a missing "at" in a comment) - rust-lang#71891 (¬∃x. ¬y => ∀x. y) - rust-lang#71892 (Update btree_map::VacantEntry::insert docs to actually call insert) - rust-lang#71902 (Suggest to add missing feature when using gated const features) - rust-lang#71904 (fix typo in function name) Failed merges: r? @ghost
2 parents 2454a68 + 8b781b0 commit 04689e2

33 files changed

+526
-54
lines changed

src/liballoc/collections/btree/map.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -2499,15 +2499,14 @@ impl<'a, K: Ord, V> VacantEntry<'a, K, V> {
24992499
///
25002500
/// ```
25012501
/// use std::collections::BTreeMap;
2502+
/// use std::collections::btree_map::Entry;
25022503
///
2503-
/// let mut count: BTreeMap<&str, usize> = BTreeMap::new();
2504+
/// let mut map: BTreeMap<&str, u32> = BTreeMap::new();
25042505
///
2505-
/// // count the number of occurrences of letters in the vec
2506-
/// for x in vec!["a","b","a","c","a","b"] {
2507-
/// *count.entry(x).or_insert(0) += 1;
2506+
/// if let Entry::Vacant(o) = map.entry("poneyland") {
2507+
/// o.insert(37);
25082508
/// }
2509-
///
2510-
/// assert_eq!(count["a"], 3);
2509+
/// assert_eq!(map["poneyland"], 37);
25112510
/// ```
25122511
#[stable(feature = "rust1", since = "1.0.0")]
25132512
pub fn insert(self, value: V) -> &'a mut V {

src/liballoc/collections/linked_list.rs

+25
Original file line numberDiff line numberDiff line change
@@ -1496,6 +1496,31 @@ impl<'a, T> CursorMut<'a, T> {
14961496
}
14971497
}
14981498

1499+
/// Removes the current element from the `LinkedList` without deallocating the list node.
1500+
///
1501+
/// The node that was removed is returned as a new `LinkedList` containing only this node.
1502+
/// The cursor is moved to point to the next element in the current `LinkedList`.
1503+
///
1504+
/// If the cursor is currently pointing to the "ghost" non-element then no element
1505+
/// is removed and `None` is returned.
1506+
#[unstable(feature = "linked_list_cursors", issue = "58533")]
1507+
pub fn remove_current_as_list(&mut self) -> Option<LinkedList<T>> {
1508+
let mut unlinked_node = self.current?;
1509+
unsafe {
1510+
self.current = unlinked_node.as_ref().next;
1511+
self.list.unlink_node(unlinked_node);
1512+
1513+
unlinked_node.as_mut().prev = None;
1514+
unlinked_node.as_mut().next = None;
1515+
Some(LinkedList {
1516+
head: Some(unlinked_node),
1517+
tail: Some(unlinked_node),
1518+
len: 1,
1519+
marker: PhantomData,
1520+
})
1521+
}
1522+
}
1523+
14991524
/// Inserts the elements from the given `LinkedList` after the current one.
15001525
///
15011526
/// If the cursor is pointing at the "ghost" non-element then the new elements are

src/libcore/num/f32.rs

+147
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,46 @@ use crate::num::FpCategory;
1818

1919
/// The radix or base of the internal representation of `f32`.
2020
/// Use [`f32::RADIX`](../../std/primitive.f32.html#associatedconstant.RADIX) instead.
21+
///
22+
/// # Examples
23+
///
24+
/// ```rust
25+
/// // deprecated way
26+
/// let r = std::f32::RADIX;
27+
///
28+
/// // intended way
29+
/// let r = f32::RADIX;
30+
/// ```
2131
#[stable(feature = "rust1", since = "1.0.0")]
2232
pub const RADIX: u32 = f32::RADIX;
2333

2434
/// Number of significant digits in base 2.
2535
/// Use [`f32::MANTISSA_DIGITS`](../../std/primitive.f32.html#associatedconstant.MANTISSA_DIGITS) instead.
36+
///
37+
/// # Examples
38+
///
39+
/// ```rust
40+
/// // deprecated way
41+
/// let d = std::f32::MANTISSA_DIGITS;
42+
///
43+
/// // intended way
44+
/// let d = f32::MANTISSA_DIGITS;
45+
/// ```
2646
#[stable(feature = "rust1", since = "1.0.0")]
2747
pub const MANTISSA_DIGITS: u32 = f32::MANTISSA_DIGITS;
48+
2849
/// Approximate number of significant digits in base 10.
2950
/// Use [`f32::DIGITS`](../../std/primitive.f32.html#associatedconstant.DIGITS) instead.
51+
///
52+
/// # Examples
53+
///
54+
/// ```rust
55+
/// // deprecated way
56+
/// let d = std::f32::DIGITS;
57+
///
58+
/// // intended way
59+
/// let d = f32::DIGITS;
60+
/// ```
3061
#[stable(feature = "rust1", since = "1.0.0")]
3162
pub const DIGITS: u32 = f32::DIGITS;
3263

@@ -36,50 +67,166 @@ pub const DIGITS: u32 = f32::DIGITS;
3667
/// This is the difference between `1.0` and the next larger representable number.
3768
///
3869
/// [Machine epsilon]: https://en.wikipedia.org/wiki/Machine_epsilon
70+
///
71+
/// # Examples
72+
///
73+
/// ```rust
74+
/// // deprecated way
75+
/// let e = std::f32::EPSILON;
76+
///
77+
/// // intended way
78+
/// let e = f32::EPSILON;
79+
/// ```
3980
#[stable(feature = "rust1", since = "1.0.0")]
4081
pub const EPSILON: f32 = f32::EPSILON;
4182

4283
/// Smallest finite `f32` value.
4384
/// Use [`f32::MIN`](../../std/primitive.f32.html#associatedconstant.MIN) instead.
85+
///
86+
/// # Examples
87+
///
88+
/// ```rust
89+
/// // deprecated way
90+
/// let min = std::f32::MIN;
91+
///
92+
/// // intended way
93+
/// let min = f32::MIN;
94+
/// ```
4495
#[stable(feature = "rust1", since = "1.0.0")]
4596
pub const MIN: f32 = f32::MIN;
97+
4698
/// Smallest positive normal `f32` value.
4799
/// Use [`f32::MIN_POSITIVE`](../../std/primitive.f32.html#associatedconstant.MIN_POSITIVE) instead.
100+
///
101+
/// # Examples
102+
///
103+
/// ```rust
104+
/// // deprecated way
105+
/// let min = std::f32::MIN_POSITIVE;
106+
///
107+
/// // intended way
108+
/// let min = f32::MIN_POSITIVE;
109+
/// ```
48110
#[stable(feature = "rust1", since = "1.0.0")]
49111
pub const MIN_POSITIVE: f32 = f32::MIN_POSITIVE;
112+
50113
/// Largest finite `f32` value.
51114
/// Use [`f32::MAX`](../../std/primitive.f32.html#associatedconstant.MAX) instead.
115+
///
116+
/// # Examples
117+
///
118+
/// ```rust
119+
/// // deprecated way
120+
/// let max = std::f32::MAX;
121+
///
122+
/// // intended way
123+
/// let max = f32::MAX;
124+
/// ```
52125
#[stable(feature = "rust1", since = "1.0.0")]
53126
pub const MAX: f32 = f32::MAX;
54127

55128
/// One greater than the minimum possible normal power of 2 exponent.
56129
/// Use [`f32::MIN_EXP`](../../std/primitive.f32.html#associatedconstant.MIN_EXP) instead.
130+
///
131+
/// # Examples
132+
///
133+
/// ```rust
134+
/// // deprecated way
135+
/// let min = std::f32::MIN_EXP;
136+
///
137+
/// // intended way
138+
/// let min = f32::MIN_EXP;
139+
/// ```
57140
#[stable(feature = "rust1", since = "1.0.0")]
58141
pub const MIN_EXP: i32 = f32::MIN_EXP;
142+
59143
/// Maximum possible power of 2 exponent.
60144
/// Use [`f32::MAX_EXP`](../../std/primitive.f32.html#associatedconstant.MAX_EXP) instead.
145+
///
146+
/// # Examples
147+
///
148+
/// ```rust
149+
/// // deprecated way
150+
/// let max = std::f32::MAX_EXP;
151+
///
152+
/// // intended way
153+
/// let max = f32::MAX_EXP;
154+
/// ```
61155
#[stable(feature = "rust1", since = "1.0.0")]
62156
pub const MAX_EXP: i32 = f32::MAX_EXP;
63157

64158
/// Minimum possible normal power of 10 exponent.
65159
/// Use [`f32::MIN_10_EXP`](../../std/primitive.f32.html#associatedconstant.MIN_10_EXP) instead.
160+
///
161+
/// # Examples
162+
///
163+
/// ```rust
164+
/// // deprecated way
165+
/// let min = std::f32::MIN_10_EXP;
166+
///
167+
/// // intended way
168+
/// let min = f32::MIN_10_EXP;
169+
/// ```
66170
#[stable(feature = "rust1", since = "1.0.0")]
67171
pub const MIN_10_EXP: i32 = f32::MIN_10_EXP;
172+
68173
/// Maximum possible power of 10 exponent.
69174
/// Use [`f32::MAX_10_EXP`](../../std/primitive.f32.html#associatedconstant.MAX_10_EXP) instead.
175+
///
176+
/// # Examples
177+
///
178+
/// ```rust
179+
/// // deprecated way
180+
/// let max = std::f32::MAX_10_EXP;
181+
///
182+
/// // intended way
183+
/// let max = f32::MAX_10_EXP;
184+
/// ```
70185
#[stable(feature = "rust1", since = "1.0.0")]
71186
pub const MAX_10_EXP: i32 = f32::MAX_10_EXP;
72187

73188
/// Not a Number (NaN).
74189
/// Use [`f32::NAN`](../../std/primitive.f32.html#associatedconstant.NAN) instead.
190+
///
191+
/// # Examples
192+
///
193+
/// ```rust
194+
/// // deprecated way
195+
/// let nan = std::f32::NAN;
196+
///
197+
/// // intended way
198+
/// let nan = f32::NAN;
199+
/// ```
75200
#[stable(feature = "rust1", since = "1.0.0")]
76201
pub const NAN: f32 = f32::NAN;
202+
77203
/// Infinity (∞).
78204
/// Use [`f32::INFINITY`](../../std/primitive.f32.html#associatedconstant.INFINITY) instead.
205+
///
206+
/// # Examples
207+
///
208+
/// ```rust
209+
/// // deprecated way
210+
/// let inf = std::f32::INFINITY;
211+
///
212+
/// // intended way
213+
/// let inf = f32::INFINITY;
214+
/// ```
79215
#[stable(feature = "rust1", since = "1.0.0")]
80216
pub const INFINITY: f32 = f32::INFINITY;
217+
81218
/// Negative infinity (−∞).
82219
/// Use [`f32::NEG_INFINITY`](../../std/primitive.f32.html#associatedconstant.NEG_INFINITY) instead.
220+
///
221+
/// # Examples
222+
///
223+
/// ```rust
224+
/// // deprecated way
225+
/// let ninf = std::f32::NEG_INFINITY;
226+
///
227+
/// // intended way
228+
/// let ninf = f32::NEG_INFINITY;
229+
/// ```
83230
#[stable(feature = "rust1", since = "1.0.0")]
84231
pub const NEG_INFINITY: f32 = f32::NEG_INFINITY;
85232

0 commit comments

Comments
 (0)