Skip to content

Commit b99bd8f

Browse files
committed
Auto merge of #90598 - JohnTitor:rollup-kz1qioz, r=JohnTitor
Rollup of 9 pull requests Successful merges: - #90507 (Suggest `extern crate alloc` when using undeclared module `alloc`) - #90530 (Simplify js tester a bit) - #90533 (Add note about x86 instruction prefixes in asm! to unstable book) - #90537 (Update aarch64 `target_feature` list for LLVM 12.) - #90544 (Demote metadata load warning to "info".) - #90554 (Clean up some `-Z unstable-options` in tests.) - #90556 (Add more text and examples to `carrying_{add|mul}`) - #90563 (rustbot allow labels) - #90571 (Fix missing bottom border for headings in sidebar) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents a6162f6 + 3821ab2 commit b99bd8f

38 files changed

+182
-96
lines changed

compiler/rustc_codegen_llvm/src/llvm_util.rs

+1
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ pub fn to_llvm_feature<'a>(sess: &Session, s: &'a str) -> Vec<&'a str> {
180180
("aarch64", "dpb2") => vec!["ccdp"],
181181
("aarch64", "frintts") => vec!["fptoint"],
182182
("aarch64", "fcma") => vec!["complxnum"],
183+
("aarch64", "pmuv3") => vec!["perfmon"],
183184
(_, s) => vec![s],
184185
}
185186
}

compiler/rustc_codegen_ssa/src/target_features.rs

+17-8
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ const ARM_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
3636
("thumb-mode", Some(sym::arm_target_feature)),
3737
];
3838

39-
// Commented features are not available in LLVM 10.0, or have since been renamed
4039
const AARCH64_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
4140
// FEAT_AdvSimd
4241
("neon", Some(sym::aarch64_target_feature)),
@@ -67,13 +66,13 @@ const AARCH64_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
6766
// FEAT_DIT
6867
("dit", Some(sym::aarch64_target_feature)),
6968
// FEAT_FLAGM
70-
// ("flagm", Some(sym::aarch64_target_feature)),
69+
("flagm", Some(sym::aarch64_target_feature)),
7170
// FEAT_SSBS
7271
("ssbs", Some(sym::aarch64_target_feature)),
7372
// FEAT_SB
7473
("sb", Some(sym::aarch64_target_feature)),
7574
// FEAT_PAUTH
76-
// ("pauth", Some(sym::aarch64_target_feature)),
75+
("pauth", Some(sym::aarch64_target_feature)),
7776
// FEAT_DPB
7877
("dpb", Some(sym::aarch64_target_feature)),
7978
// FEAT_DPB2
@@ -93,11 +92,11 @@ const AARCH64_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
9392
// FEAT_I8MM
9493
("i8mm", Some(sym::aarch64_target_feature)),
9594
// FEAT_F32MM
96-
// ("f32mm", Some(sym::aarch64_target_feature)),
95+
("f32mm", Some(sym::aarch64_target_feature)),
9796
// FEAT_F64MM
98-
// ("f64mm", Some(sym::aarch64_target_feature)),
97+
("f64mm", Some(sym::aarch64_target_feature)),
9998
// FEAT_BF16
100-
// ("bf16", Some(sym::aarch64_target_feature)),
99+
("bf16", Some(sym::aarch64_target_feature)),
101100
// FEAT_RAND
102101
("rand", Some(sym::aarch64_target_feature)),
103102
// FEAT_BTI
@@ -116,13 +115,23 @@ const AARCH64_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
116115
("sha3", Some(sym::aarch64_target_feature)),
117116
// FEAT_SM3 & FEAT_SM4
118117
("sm4", Some(sym::aarch64_target_feature)),
118+
// FEAT_PAN
119+
("pan", Some(sym::aarch64_target_feature)),
120+
// FEAT_LOR
121+
("lor", Some(sym::aarch64_target_feature)),
122+
// FEAT_VHE
123+
("vh", Some(sym::aarch64_target_feature)),
124+
// FEAT_PMUv3
125+
("pmuv3", Some(sym::aarch64_target_feature)),
126+
// FEAT_SPE
127+
("spe", Some(sym::aarch64_target_feature)),
119128
("v8.1a", Some(sym::aarch64_target_feature)),
120129
("v8.2a", Some(sym::aarch64_target_feature)),
121130
("v8.3a", Some(sym::aarch64_target_feature)),
122131
("v8.4a", Some(sym::aarch64_target_feature)),
123132
("v8.5a", Some(sym::aarch64_target_feature)),
124-
// ("v8.6a", Some(sym::aarch64_target_feature)),
125-
// ("v8.7a", Some(sym::aarch64_target_feature)),
133+
("v8.6a", Some(sym::aarch64_target_feature)),
134+
("v8.7a", Some(sym::aarch64_target_feature)),
126135
];
127136

128137
const X86_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[

compiler/rustc_metadata/src/locator.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ use std::fmt::Write as _;
236236
use std::io::{Read, Result as IoResult, Write};
237237
use std::path::{Path, PathBuf};
238238
use std::{cmp, fmt, fs};
239-
use tracing::{debug, info, warn};
239+
use tracing::{debug, info};
240240

241241
#[derive(Clone)]
242242
crate struct CrateLocator<'a> {
@@ -549,7 +549,7 @@ impl<'a> CrateLocator<'a> {
549549
}
550550
}
551551
Err(err) => {
552-
warn!("no metadata found: {}", err);
552+
info!("no metadata found: {}", err);
553553
continue;
554554
}
555555
};

compiler/rustc_resolve/src/diagnostics.rs

+4
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,10 @@ impl<'a> Resolver<'a> {
420420
err.span_label(span, label);
421421

422422
if let Some((suggestions, msg, applicability)) = suggestion {
423+
if suggestions.is_empty() {
424+
err.help(&msg);
425+
return err;
426+
}
423427
err.multipart_suggestion(&msg, suggestions, applicability);
424428
}
425429

compiler/rustc_resolve/src/lib.rs

+19-9
Original file line numberDiff line numberDiff line change
@@ -2523,19 +2523,29 @@ impl<'a> Resolver<'a> {
25232523
} else {
25242524
(
25252525
format!("use of undeclared crate or module `{}`", ident),
2526-
self.find_similarly_named_module_or_crate(
2527-
ident.name,
2528-
&parent_scope.module,
2529-
)
2530-
.map(|sugg| {
2531-
(
2532-
vec![(ident.span, sugg.to_string())],
2526+
if ident.name == sym::alloc {
2527+
Some((
2528+
vec![],
25332529
String::from(
2534-
"there is a crate or module with a similar name",
2530+
"add `extern crate alloc` to use the `alloc` crate",
25352531
),
25362532
Applicability::MaybeIncorrect,
2533+
))
2534+
} else {
2535+
self.find_similarly_named_module_or_crate(
2536+
ident.name,
2537+
&parent_scope.module,
25372538
)
2538-
}),
2539+
.map(|sugg| {
2540+
(
2541+
vec![(ident.span, sugg.to_string())],
2542+
String::from(
2543+
"there is a crate or module with a similar name",
2544+
),
2545+
Applicability::MaybeIncorrect,
2546+
)
2547+
})
2548+
},
25392549
)
25402550
}
25412551
} else {

library/core/src/num/mod.rs

+48-15
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,13 @@ depending on the target pointer size.
9494
}
9595

9696
macro_rules! widening_impl {
97-
($SelfT:ty, $WideT:ty, $BITS:literal) => {
97+
($SelfT:ty, $WideT:ty, $BITS:literal, unsigned) => {
98+
widening_impl!($SelfT, $WideT, $BITS, "");
99+
};
100+
($SelfT:ty, $WideT:ty, $BITS:literal, signed) => {
101+
widening_impl!($SelfT, $WideT, $BITS, "# //");
102+
};
103+
($SelfT:ty, $WideT:ty, $BITS:literal, $AdaptiveTestPrefix:literal) => {
98104
/// Calculates the complete product `self * rhs` without the possibility to overflow.
99105
///
100106
/// This returns the low-order (wrapping) bits and the high-order (overflow) bits
@@ -148,6 +154,33 @@ macro_rules! widening_impl {
148154
/// assert_eq!(5u32.carrying_mul(2, 10), (20, 0));
149155
/// assert_eq!(1_000_000_000u32.carrying_mul(10, 0), (1410065408, 2));
150156
/// assert_eq!(1_000_000_000u32.carrying_mul(10, 10), (1410065418, 2));
157+
#[doc = concat!($AdaptiveTestPrefix, "assert_eq!(",
158+
stringify!($SelfT), "::MAX.carrying_mul(", stringify!($SelfT), "::MAX, ", stringify!($SelfT), "::MAX), ",
159+
"(0, ", stringify!($SelfT), "::MAX));"
160+
)]
161+
/// ```
162+
///
163+
/// If `carry` is zero, this is similar to [`overflowing_mul`](Self::overflowing_mul),
164+
/// except that it gives the value of the overflow instead of just whether one happened:
165+
///
166+
/// ```
167+
/// #![feature(bigint_helper_methods)]
168+
/// let r = u8::carrying_mul(7, 13, 0);
169+
/// assert_eq!((r.0, r.1 != 0), u8::overflowing_mul(7, 13));
170+
/// let r = u8::carrying_mul(13, 42, 0);
171+
/// assert_eq!((r.0, r.1 != 0), u8::overflowing_mul(13, 42));
172+
/// ```
173+
///
174+
/// The value of the first field in the returned tuple matches what you'd get
175+
/// by combining the [`wrapping_mul`](Self::wrapping_mul) and
176+
/// [`wrapping_add`](Self::wrapping_add) methods:
177+
///
178+
/// ```
179+
/// #![feature(bigint_helper_methods)]
180+
/// assert_eq!(
181+
/// 789_u16.carrying_mul(456, 123).0,
182+
/// 789_u16.wrapping_mul(456).wrapping_add(123),
183+
/// );
151184
/// ```
152185
#[unstable(feature = "bigint_helper_methods", issue = "85532")]
153186
#[rustc_const_unstable(feature = "bigint_helper_methods", issue = "85532")]
@@ -168,29 +201,29 @@ macro_rules! widening_impl {
168201

169202
#[lang = "i8"]
170203
impl i8 {
171-
widening_impl! { i8, i16, 8 }
204+
widening_impl! { i8, i16, 8, signed }
172205
int_impl! { i8, i8, u8, 8, 7, -128, 127, 2, "-0x7e", "0xa", "0x12", "0x12", "0x48",
173206
"[0x12]", "[0x12]", "", "" }
174207
}
175208

176209
#[lang = "i16"]
177210
impl i16 {
178-
widening_impl! { i16, i32, 16 }
211+
widening_impl! { i16, i32, 16, signed }
179212
int_impl! { i16, i16, u16, 16, 15, -32768, 32767, 4, "-0x5ffd", "0x3a", "0x1234", "0x3412",
180213
"0x2c48", "[0x34, 0x12]", "[0x12, 0x34]", "", "" }
181214
}
182215

183216
#[lang = "i32"]
184217
impl i32 {
185-
widening_impl! { i32, i64, 32 }
218+
widening_impl! { i32, i64, 32, signed }
186219
int_impl! { i32, i32, u32, 32, 31, -2147483648, 2147483647, 8, "0x10000b3", "0xb301",
187220
"0x12345678", "0x78563412", "0x1e6a2c48", "[0x78, 0x56, 0x34, 0x12]",
188221
"[0x12, 0x34, 0x56, 0x78]", "", "" }
189222
}
190223

191224
#[lang = "i64"]
192225
impl i64 {
193-
widening_impl! { i64, i128, 64 }
226+
widening_impl! { i64, i128, 64, signed }
194227
int_impl! { i64, i64, u64, 64, 63, -9223372036854775808, 9223372036854775807, 12,
195228
"0xaa00000000006e1", "0x6e10aa", "0x1234567890123456", "0x5634129078563412",
196229
"0x6a2c48091e6a2c48", "[0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x34, 0x12]",
@@ -212,7 +245,7 @@ impl i128 {
212245
#[cfg(target_pointer_width = "16")]
213246
#[lang = "isize"]
214247
impl isize {
215-
widening_impl! { isize, i32, 16 }
248+
widening_impl! { isize, i32, 16, signed }
216249
int_impl! { isize, i16, usize, 16, 15, -32768, 32767, 4, "-0x5ffd", "0x3a", "0x1234",
217250
"0x3412", "0x2c48", "[0x34, 0x12]", "[0x12, 0x34]",
218251
usize_isize_to_xe_bytes_doc!(), usize_isize_from_xe_bytes_doc!() }
@@ -221,7 +254,7 @@ impl isize {
221254
#[cfg(target_pointer_width = "32")]
222255
#[lang = "isize"]
223256
impl isize {
224-
widening_impl! { isize, i64, 32 }
257+
widening_impl! { isize, i64, 32, signed }
225258
int_impl! { isize, i32, usize, 32, 31, -2147483648, 2147483647, 8, "0x10000b3", "0xb301",
226259
"0x12345678", "0x78563412", "0x1e6a2c48", "[0x78, 0x56, 0x34, 0x12]",
227260
"[0x12, 0x34, 0x56, 0x78]",
@@ -231,7 +264,7 @@ impl isize {
231264
#[cfg(target_pointer_width = "64")]
232265
#[lang = "isize"]
233266
impl isize {
234-
widening_impl! { isize, i128, 64 }
267+
widening_impl! { isize, i128, 64, signed }
235268
int_impl! { isize, i64, usize, 64, 63, -9223372036854775808, 9223372036854775807,
236269
12, "0xaa00000000006e1", "0x6e10aa", "0x1234567890123456", "0x5634129078563412",
237270
"0x6a2c48091e6a2c48", "[0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x34, 0x12]",
@@ -244,7 +277,7 @@ const ASCII_CASE_MASK: u8 = 0b0010_0000;
244277

245278
#[lang = "u8"]
246279
impl u8 {
247-
widening_impl! { u8, u16, 8 }
280+
widening_impl! { u8, u16, 8, unsigned }
248281
uint_impl! { u8, u8, i8, 8, 255, 2, "0x82", "0xa", "0x12", "0x12", "0x48", "[0x12]",
249282
"[0x12]", "", "" }
250283

@@ -793,21 +826,21 @@ impl u8 {
793826

794827
#[lang = "u16"]
795828
impl u16 {
796-
widening_impl! { u16, u32, 16 }
829+
widening_impl! { u16, u32, 16, unsigned }
797830
uint_impl! { u16, u16, i16, 16, 65535, 4, "0xa003", "0x3a", "0x1234", "0x3412", "0x2c48",
798831
"[0x34, 0x12]", "[0x12, 0x34]", "", "" }
799832
}
800833

801834
#[lang = "u32"]
802835
impl u32 {
803-
widening_impl! { u32, u64, 32 }
836+
widening_impl! { u32, u64, 32, unsigned }
804837
uint_impl! { u32, u32, i32, 32, 4294967295, 8, "0x10000b3", "0xb301", "0x12345678",
805838
"0x78563412", "0x1e6a2c48", "[0x78, 0x56, 0x34, 0x12]", "[0x12, 0x34, 0x56, 0x78]", "", "" }
806839
}
807840

808841
#[lang = "u64"]
809842
impl u64 {
810-
widening_impl! { u64, u128, 64 }
843+
widening_impl! { u64, u128, 64, unsigned }
811844
uint_impl! { u64, u64, i64, 64, 18446744073709551615, 12, "0xaa00000000006e1", "0x6e10aa",
812845
"0x1234567890123456", "0x5634129078563412", "0x6a2c48091e6a2c48",
813846
"[0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x34, 0x12]",
@@ -830,15 +863,15 @@ impl u128 {
830863
#[cfg(target_pointer_width = "16")]
831864
#[lang = "usize"]
832865
impl usize {
833-
widening_impl! { usize, u32, 16 }
866+
widening_impl! { usize, u32, 16, unsigned }
834867
uint_impl! { usize, u16, isize, 16, 65535, 4, "0xa003", "0x3a", "0x1234", "0x3412", "0x2c48",
835868
"[0x34, 0x12]", "[0x12, 0x34]",
836869
usize_isize_to_xe_bytes_doc!(), usize_isize_from_xe_bytes_doc!() }
837870
}
838871
#[cfg(target_pointer_width = "32")]
839872
#[lang = "usize"]
840873
impl usize {
841-
widening_impl! { usize, u64, 32 }
874+
widening_impl! { usize, u64, 32, unsigned }
842875
uint_impl! { usize, u32, isize, 32, 4294967295, 8, "0x10000b3", "0xb301", "0x12345678",
843876
"0x78563412", "0x1e6a2c48", "[0x78, 0x56, 0x34, 0x12]", "[0x12, 0x34, 0x56, 0x78]",
844877
usize_isize_to_xe_bytes_doc!(), usize_isize_from_xe_bytes_doc!() }
@@ -847,7 +880,7 @@ impl usize {
847880
#[cfg(target_pointer_width = "64")]
848881
#[lang = "usize"]
849882
impl usize {
850-
widening_impl! { usize, u128, 64 }
883+
widening_impl! { usize, u128, 64, unsigned }
851884
uint_impl! { usize, u64, isize, 64, 18446744073709551615, 12, "0xaa00000000006e1", "0x6e10aa",
852885
"0x1234567890123456", "0x5634129078563412", "0x6a2c48091e6a2c48",
853886
"[0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x34, 0x12]",

library/core/src/num/uint_macros.rs

+15
Original file line numberDiff line numberDiff line change
@@ -1504,6 +1504,8 @@ macro_rules! uint_impl {
15041504
/// additional bit of overflow. This allows for chaining together multiple additions
15051505
/// to create "big integers" which represent larger values.
15061506
///
1507+
#[doc = concat!("This can be thought of as a ", stringify!($BITS), "-bit \"full adder\", in the electronics sense.")]
1508+
///
15071509
/// # Examples
15081510
///
15091511
/// Basic usage
@@ -1513,7 +1515,20 @@ macro_rules! uint_impl {
15131515
#[doc = concat!("assert_eq!(5", stringify!($SelfT), ".carrying_add(2, false), (7, false));")]
15141516
#[doc = concat!("assert_eq!(5", stringify!($SelfT), ".carrying_add(2, true), (8, false));")]
15151517
#[doc = concat!("assert_eq!(", stringify!($SelfT), "::MAX.carrying_add(1, false), (0, true));")]
1518+
#[doc = concat!("assert_eq!(", stringify!($SelfT), "::MAX.carrying_add(0, true), (0, true));")]
15161519
#[doc = concat!("assert_eq!(", stringify!($SelfT), "::MAX.carrying_add(1, true), (1, true));")]
1520+
#[doc = concat!("assert_eq!(",
1521+
stringify!($SelfT), "::MAX.carrying_add(", stringify!($SelfT), "::MAX, true), ",
1522+
"(", stringify!($SelfT), "::MAX, true));"
1523+
)]
1524+
/// ```
1525+
///
1526+
/// If `carry` is false, this method is equivalent to [`overflowing_add`](Self::overflowing_add):
1527+
///
1528+
/// ```
1529+
/// #![feature(bigint_helper_methods)]
1530+
#[doc = concat!("assert_eq!(5_", stringify!($SelfT), ".carrying_add(2, false), 5_", stringify!($SelfT), ".overflowing_add(2));")]
1531+
#[doc = concat!("assert_eq!(", stringify!($SelfT), "::MAX.carrying_add(1, false), ", stringify!($SelfT), "::MAX.overflowing_add(1));")]
15171532
/// ```
15181533
#[unstable(feature = "bigint_helper_methods", issue = "85532")]
15191534
#[rustc_const_unstable(feature = "const_bigint_helper_methods", issue = "85532")]

src/doc/unstable-book/src/library-features/asm.md

+2
Original file line numberDiff line numberDiff line change
@@ -885,5 +885,7 @@ The compiler performs some additional checks on options:
885885
- You are responsible for switching any target-specific state (e.g. thread-local storage, stack bounds).
886886
- The set of memory locations that you may access is the intersection of those allowed by the `asm!` blocks you entered and exited.
887887
- You cannot assume that an `asm!` block will appear exactly once in the output binary. The compiler is allowed to instantiate multiple copies of the `asm!` block, for example when the function containing it is inlined in multiple places.
888+
- On x86, inline assembly must not end with an instruction prefix (such as `LOCK`) that would apply to instructions generated by the compiler.
889+
- The compiler is currently unable to detect this due to the way inline assembly is compiled, but may catch and reject this in the future.
888890

889891
> **Note**: As a general rule, the flags covered by `preserves_flags` are those which are *not* preserved when performing a function call.

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ h1.fqn > .in-band > a:hover {
156156
section hierarchies. */
157157
h2,
158158
.top-doc h3,
159-
.top-doc h4 {
159+
.top-doc h4,
160+
.sidebar .others h3 {
160161
border-bottom: 1px solid;
161162
}
162163
h3.code-header {

src/librustdoc/html/static/js/main.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,7 @@ function hideThemeButtonState() {
566566
// delayed sidebar rendering.
567567
window.initSidebarItems = function(items) {
568568
var sidebar = document.getElementsByClassName("sidebar-elems")[0];
569+
var others;
569570
var current = window.sidebarCurrent;
570571

571572
function addSidebarCrates(crates) {
@@ -594,7 +595,7 @@ function hideThemeButtonState() {
594595
li.appendChild(link);
595596
ul.appendChild(li);
596597
}
597-
sidebar.appendChild(div);
598+
others.appendChild(div);
598599
}
599600

600601
function block(shortty, longty) {
@@ -635,10 +636,14 @@ function hideThemeButtonState() {
635636
ul.appendChild(li);
636637
}
637638
div.appendChild(ul);
638-
sidebar.appendChild(div);
639+
others.appendChild(div);
639640
}
640641

641642
if (sidebar) {
643+
others = document.createElement("div");
644+
others.className = "others";
645+
sidebar.appendChild(others);
646+
642647
var isModule = hasClass(document.body, "mod");
643648
if (!isModule) {
644649
block("primitive", "Primitive Types");

0 commit comments

Comments
 (0)