Skip to content

Commit 337b2d4

Browse files
committed
Auto merge of #68861 - Dylan-DPC:rollup-0m09hsg, r=Dylan-DPC
Rollup of 8 pull requests Successful merges: - #68762 (Strip unnecessary subexpression) - #68790 (Improve `merge_from_succ`) - #68809 (Make more arithmetic functions unstably const) - #68832 (Clean up E0264, E0267 and E0268 explanations) - #68840 (On suggesting `#![recursion_limit = "X"]`, note current crate name) - #68846 (doc fix on doc attribute) - #68851 (Fix issue number of `capacity` method) - #68858 (Merge item id stable hashing functions) Failed merges: r? @ghost
2 parents eda1a7a + b37f968 commit 337b2d4

File tree

31 files changed

+320
-120
lines changed

31 files changed

+320
-120
lines changed

src/doc/rustdoc/src/the-doc-attribute.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ crate level, and ones that are useful at the item level.
3939

4040
## At the crate level
4141

42-
These options control how the docs look at a macro level.
42+
These options control how the docs look at a crate level.
4343

4444
### `html_favicon_url`
4545

src/libcore/intrinsics.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,9 +1305,11 @@ extern "rust-intrinsic" {
13051305

13061306
/// Performs an unchecked division, resulting in undefined behavior
13071307
/// where y = 0 or x = `T::min_value()` and y = -1
1308+
#[rustc_const_unstable(feature = "const_int_unchecked_arith", issue = "none")]
13081309
pub fn unchecked_div<T>(x: T, y: T) -> T;
13091310
/// Returns the remainder of an unchecked division, resulting in
13101311
/// undefined behavior where y = 0 or x = `T::min_value()` and y = -1
1312+
#[rustc_const_unstable(feature = "const_int_unchecked_arith", issue = "none")]
13111313
pub fn unchecked_rem<T>(x: T, y: T) -> T;
13121314

13131315
/// Performs an unchecked left shift, resulting in undefined behavior when
@@ -1321,14 +1323,17 @@ extern "rust-intrinsic" {
13211323

13221324
/// Returns the result of an unchecked addition, resulting in
13231325
/// undefined behavior when `x + y > T::max_value()` or `x + y < T::min_value()`.
1326+
#[rustc_const_unstable(feature = "const_int_unchecked_arith", issue = "none")]
13241327
pub fn unchecked_add<T>(x: T, y: T) -> T;
13251328

13261329
/// Returns the result of an unchecked subtraction, resulting in
13271330
/// undefined behavior when `x - y > T::max_value()` or `x - y < T::min_value()`.
1331+
#[rustc_const_unstable(feature = "const_int_unchecked_arith", issue = "none")]
13281332
pub fn unchecked_sub<T>(x: T, y: T) -> T;
13291333

13301334
/// Returns the result of an unchecked multiplication, resulting in
13311335
/// undefined behavior when `x * y > T::max_value()` or `x * y < T::min_value()`.
1336+
#[rustc_const_unstable(feature = "const_int_unchecked_arith", issue = "none")]
13321337
pub fn unchecked_mul<T>(x: T, y: T) -> T;
13331338

13341339
/// Performs rotate left.

src/libcore/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@
7272
#![feature(concat_idents)]
7373
#![feature(const_alloc_layout)]
7474
#![feature(const_if_match)]
75+
#![feature(const_checked_int_methods)]
76+
#![feature(const_euclidean_int_methods)]
77+
#![feature(const_overflowing_int_methods)]
78+
#![feature(const_saturating_int_methods)]
79+
#![feature(const_int_unchecked_arith)]
7580
#![feature(const_panic)]
7681
#![feature(const_fn_union)]
7782
#![feature(const_generics)]

src/libcore/num/mod.rs

Lines changed: 98 additions & 49 deletions
Large diffs are not rendered by default.

src/librustc/ich/impls_hir.rs

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -40,40 +40,14 @@ impl<'ctx> rustc_hir::HashStableContext for StableHashingContext<'ctx> {
4040
}
4141
}
4242

43-
// The following implementations of HashStable for `ItemId`, `TraitItemId`, and
44-
// `ImplItemId` deserve special attention. Normally we do not hash `NodeId`s within
45-
// the HIR, since they just signify a HIR nodes own path. But `ItemId` et al
46-
// are used when another item in the HIR is *referenced* and we certainly
47-
// want to pick up on a reference changing its target, so we hash the NodeIds
48-
// in "DefPath Mode".
49-
50-
fn hash_item_id(&mut self, id: hir::ItemId, hasher: &mut StableHasher) {
43+
fn hash_reference_to_item(&mut self, id: hir::HirId, hasher: &mut StableHasher) {
5144
let hcx = self;
52-
let hir::ItemId { id } = id;
5345

5446
hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
5547
id.hash_stable(hcx, hasher);
5648
})
5749
}
5850

59-
fn hash_impl_item_id(&mut self, id: hir::ImplItemId, hasher: &mut StableHasher) {
60-
let hcx = self;
61-
let hir::ImplItemId { hir_id } = id;
62-
63-
hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
64-
hir_id.hash_stable(hcx, hasher);
65-
})
66-
}
67-
68-
fn hash_trait_item_id(&mut self, id: hir::TraitItemId, hasher: &mut StableHasher) {
69-
let hcx = self;
70-
let hir::TraitItemId { hir_id } = id;
71-
72-
hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
73-
hir_id.hash_stable(hcx, hasher);
74-
})
75-
}
76-
7751
fn hash_hir_mod(&mut self, module: &hir::Mod<'_>, hasher: &mut StableHasher) {
7852
let hcx = self;
7953
let hir::Mod { inner: ref inner_span, ref item_ids } = *module;

src/librustc/traits/error_reporting/suggestions.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1646,8 +1646,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
16461646
let current_limit = self.tcx.sess.recursion_limit.get();
16471647
let suggested_limit = current_limit * 2;
16481648
err.help(&format!(
1649-
"consider adding a `#![recursion_limit=\"{}\"]` attribute to your crate",
1650-
suggested_limit
1649+
"consider adding a `#![recursion_limit=\"{}\"]` attribute to your crate (`{}`)",
1650+
suggested_limit, self.tcx.crate_name,
16511651
));
16521652
}
16531653
}

src/librustc_error_codes/error_codes/E0264.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
An unknown external lang item was used. Erroneous code example:
1+
An unknown external lang item was used.
2+
3+
Erroneous code example:
24

35
```compile_fail,E0264
46
#![feature(lang_items)]

src/librustc_error_codes/error_codes/E0267.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
This error indicates the use of a loop keyword (`break` or `continue`) inside a
2-
closure but outside of any loop. Erroneous code example:
1+
A loop keyword (`break` or `continue`) was used inside a closure but outside of
2+
any loop.
3+
4+
Erroneous code example:
35

46
```compile_fail,E0267
57
let w = || { break; }; // error: `break` inside of a closure

src/librustc_error_codes/error_codes/E0268.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
This error indicates the use of a loop keyword (`break` or `continue`) outside
2-
of a loop. Without a loop to break out of or continue in, no sensible action can
3-
be taken. Erroneous code example:
1+
A loop keyword (`break` or `continue`) was used outside of a loop.
2+
3+
Erroneous code example:
44

55
```compile_fail,E0268
66
fn some_func() {
77
break; // error: `break` outside of a loop
88
}
99
```
1010

11+
Without a loop to break out of or continue in, no sensible action can be taken.
1112
Please verify that you are using `break` and `continue` only in loops. Example:
1213

1314
```

src/librustc_expand/expand.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -609,8 +609,8 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
609609
&format!("recursion limit reached while expanding `{}`", expn_data.kind.descr()),
610610
);
611611
err.help(&format!(
612-
"consider adding a `#![recursion_limit=\"{}\"]` attribute to your crate",
613-
suggested_limit
612+
"consider adding a `#![recursion_limit=\"{}\"]` attribute to your crate (`{}`)",
613+
suggested_limit, self.cx.ecfg.crate_name,
614614
));
615615
err.emit();
616616
self.cx.trace_macros_diag();

0 commit comments

Comments
 (0)