Skip to content

Commit 1603a70

Browse files
committed
Auto merge of rust-lang#100356 - matthiaskrgr:rollup-he0vkjc, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - rust-lang#99573 (Stabilize backtrace) - rust-lang#100069 (Add error if link_ordinal used with unsupported link kind) - rust-lang#100086 (Add more `// unit-test`s to MIR opt tests) - rust-lang#100332 (Rename integer log* methods to ilog*) - rust-lang#100334 (Suggest a missing semicolon before an array) - rust-lang#100340 (Iterate generics_def_id_map in reverse order to fix P-critical issue) - rust-lang#100345 (docs: remove repetition in `is_numeric` function docs) - rust-lang#100352 (Update cargo) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 0459d2f + f6ce6ab commit 1603a70

File tree

65 files changed

+504
-342
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+504
-342
lines changed

Cargo.lock

+3-2
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,7 @@ dependencies = [
465465
"termcolor",
466466
"toml_edit",
467467
"url 2.2.2",
468+
"winapi",
468469
]
469470

470471
[[package]]
@@ -2655,9 +2656,9 @@ checksum = "dd20eec3dbe4376829cb7d80ae6ac45e0a766831dca50202ff2d40db46a8a024"
26552656

26562657
[[package]]
26572658
name = "os_info"
2658-
version = "3.4.0"
2659+
version = "3.5.0"
26592660
source = "registry+https://github.com/rust-lang/crates.io-index"
2660-
checksum = "0eca3ecae1481e12c3d9379ec541b238a16f0b75c9a409942daa8ec20dbfdb62"
2661+
checksum = "5209b2162b2c140df493a93689e04f8deab3a67634f5bc7a553c0a98e5b8d399"
26612662
dependencies = [
26622663
"log",
26632664
"serde",

compiler/rustc_ast_lowering/src/lib.rs

+14-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,20 @@ impl ResolverAstLoweringExt for ResolverAstLowering {
220220
}
221221

222222
fn get_remapped_def_id(&self, mut local_def_id: LocalDefId) -> LocalDefId {
223-
for map in &self.generics_def_id_map {
223+
// `generics_def_id_map` is a stack of mappings. As we go deeper in impl traits nesting we
224+
// push new mappings so we need to try first the latest mappings, hence `iter().rev()`.
225+
//
226+
// Consider:
227+
//
228+
// `fn test<'a, 'b>() -> impl Trait<&'a u8, Ty = impl Sized + 'b> {}`
229+
//
230+
// We would end with a generics_def_id_map like:
231+
//
232+
// `[[fn#'b -> impl_trait#'b], [fn#'b -> impl_sized#'b]]`
233+
//
234+
// for the opaque type generated on `impl Sized + 'b`, We want the result to be:
235+
// impl_sized#'b, so iterating forward is the wrong thing to do.
236+
for map in self.generics_def_id_map.iter().rev() {
224237
if let Some(r) = map.get(&local_def_id) {
225238
debug!("def_id_remapper: remapping from `{local_def_id:?}` to `{r:?}`");
226239
local_def_id = *r;

compiler/rustc_errors/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
55
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
66
#![feature(drain_filter)]
7-
#![feature(backtrace)]
87
#![feature(if_let_guard)]
98
#![cfg_attr(bootstrap, feature(let_chains))]
109
#![feature(let_else)]

compiler/rustc_metadata/src/native_libs.rs

+25-1
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,31 @@ impl<'tcx> Collector<'tcx> {
328328
.map(|child_item| self.build_dll_import(abi, child_item))
329329
.collect()
330330
}
331-
_ => Vec::new(),
331+
_ => {
332+
for child_item in foreign_mod_items {
333+
if self.tcx.def_kind(child_item.id.def_id).has_codegen_attrs()
334+
&& self
335+
.tcx
336+
.codegen_fn_attrs(child_item.id.def_id)
337+
.link_ordinal
338+
.is_some()
339+
{
340+
let link_ordinal_attr = self
341+
.tcx
342+
.hir()
343+
.attrs(self.tcx.hir().local_def_id_to_hir_id(child_item.id.def_id))
344+
.iter()
345+
.find(|a| a.has_name(sym::link_ordinal))
346+
.unwrap();
347+
sess.span_err(
348+
link_ordinal_attr.span,
349+
"`#[link_ordinal]` is only supported if link kind is `raw-dylib`",
350+
);
351+
}
352+
}
353+
354+
Vec::new()
355+
}
332356
};
333357
self.libs.push(NativeLib {
334358
name: name.map(|(name, _)| name),

compiler/rustc_middle/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#![feature(allocator_api)]
2727
#![feature(array_windows)]
2828
#![feature(assert_matches)]
29-
#![feature(backtrace)]
3029
#![feature(box_patterns)]
3130
#![feature(core_intrinsics)]
3231
#![feature(discriminant_kind)]

compiler/rustc_parse/src/parser/expr.rs

+42
Original file line numberDiff line numberDiff line change
@@ -1258,8 +1258,11 @@ impl<'a> Parser<'a> {
12581258

12591259
/// Parse an indexing expression `expr[...]`.
12601260
fn parse_index_expr(&mut self, lo: Span, base: P<Expr>) -> PResult<'a, P<Expr>> {
1261+
let prev_span = self.prev_token.span;
1262+
let open_delim_span = self.token.span;
12611263
self.bump(); // `[`
12621264
let index = self.parse_expr()?;
1265+
self.suggest_missing_semicolon_before_array(prev_span, open_delim_span)?;
12631266
self.expect(&token::CloseDelim(Delimiter::Bracket))?;
12641267
Ok(self.mk_expr(lo.to(self.prev_token.span), self.mk_index(base, index), AttrVec::new()))
12651268
}
@@ -2056,6 +2059,45 @@ impl<'a> Parser<'a> {
20562059
}
20572060
}
20582061

2062+
fn suggest_missing_semicolon_before_array(
2063+
&self,
2064+
prev_span: Span,
2065+
open_delim_span: Span,
2066+
) -> PResult<'a, ()> {
2067+
if self.token.kind == token::Comma {
2068+
let mut snapshot = self.create_snapshot_for_diagnostic();
2069+
snapshot.bump();
2070+
match snapshot.parse_seq_to_before_end(
2071+
&token::CloseDelim(Delimiter::Bracket),
2072+
SeqSep::trailing_allowed(token::Comma),
2073+
|p| p.parse_expr(),
2074+
) {
2075+
Ok(_)
2076+
// When the close delim is `)`, `token.kind` is expected to be `token::CloseDelim(Delimiter::Parenthesis)`,
2077+
// but the actual `token.kind` is `token::CloseDelim(Delimiter::Bracket)`.
2078+
// This is because the `token.kind` of the close delim is treated as the same as
2079+
// that of the open delim in `TokenTreesReader::parse_token_tree`, even if the delimiters of them are different.
2080+
// Therefore, `token.kind` should not be compared here.
2081+
if snapshot
2082+
.span_to_snippet(snapshot.token.span)
2083+
.map_or(false, |snippet| snippet == "]") =>
2084+
{
2085+
let mut err = self.struct_span_err(open_delim_span, "expected `;`, found `[`");
2086+
err.span_suggestion_verbose(
2087+
prev_span.shrink_to_hi(),
2088+
"consider adding `;` here",
2089+
';',
2090+
Applicability::MaybeIncorrect,
2091+
);
2092+
return Err(err);
2093+
}
2094+
Ok(_) => (),
2095+
Err(err) => err.cancel(),
2096+
}
2097+
}
2098+
Ok(())
2099+
}
2100+
20592101
/// Parses a block or unsafe block.
20602102
pub(super) fn parse_block_expr(
20612103
&mut self,

library/core/benches/num/int_log/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ macro_rules! int_log_bench {
99
for n in 0..(<$t>::BITS / 8) {
1010
for i in 1..=(100 as $t) {
1111
let x = black_box(i << (n * 8));
12-
black_box(x.log10());
12+
black_box(x.ilog10());
1313
}
1414
}
1515
});
@@ -27,7 +27,7 @@ macro_rules! int_log_bench {
2727
.collect();
2828
bench.iter(|| {
2929
for x in &numbers {
30-
black_box(black_box(x).log10());
30+
black_box(black_box(x).ilog10());
3131
}
3232
});
3333
}
@@ -44,7 +44,7 @@ macro_rules! int_log_bench {
4444
.collect();
4545
bench.iter(|| {
4646
for x in &numbers {
47-
black_box(black_box(x).log10());
47+
black_box(black_box(x).ilog10());
4848
}
4949
});
5050
}

library/core/src/char/methods.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -892,8 +892,7 @@ impl char {
892892
///
893893
/// The general categories for numbers (`Nd` for decimal digits, `Nl` for letter-like numeric
894894
/// characters, and `No` for other numeric characters) are specified in the [Unicode Character
895-
/// Database][ucd] [`UnicodeData.txt`]. Note that this means ideographic numbers like '三'
896-
/// are considered alphabetic, not numeric. Please consider to use `is_ascii_digit` or `is_digit`.
895+
/// Database][ucd] [`UnicodeData.txt`].
897896
///
898897
/// This method doesn't cover everything that could be considered a number, e.g. ideographic numbers like '三'.
899898
/// If you want everything including characters with overlapping purposes then you might want to use

library/core/src/num/bignum.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ macro_rules! define_bignum {
137137
// Find the most significant non-zero digit.
138138
let msd = digits.iter().rposition(|&x| x != 0);
139139
match msd {
140-
Some(msd) => msd * digitbits + digits[msd].log2() as usize + 1,
140+
Some(msd) => msd * digitbits + digits[msd].ilog2() as usize + 1,
141141
// There are no non-zero digits, i.e., the number is zero.
142142
_ => 0,
143143
}

library/core/src/num/int_macros.rs

+19-19
Original file line numberDiff line numberDiff line change
@@ -2204,7 +2204,7 @@ macro_rules! int_impl {
22042204
/// rounded down.
22052205
///
22062206
/// This method might not be optimized owing to implementation details;
2207-
/// `log2` can produce results more efficiently for base 2, and `log10`
2207+
/// `ilog2` can produce results more efficiently for base 2, and `ilog10`
22082208
/// can produce results more efficiently for base 10.
22092209
///
22102210
/// # Panics
@@ -2217,7 +2217,7 @@ macro_rules! int_impl {
22172217
///
22182218
/// ```
22192219
/// #![feature(int_log)]
2220-
#[doc = concat!("assert_eq!(5", stringify!($SelfT), ".log(5), 1);")]
2220+
#[doc = concat!("assert_eq!(5", stringify!($SelfT), ".ilog(5), 1);")]
22212221
/// ```
22222222
#[unstable(feature = "int_log", issue = "70887")]
22232223
#[must_use = "this returns the result of the operation, \
@@ -2226,8 +2226,8 @@ macro_rules! int_impl {
22262226
#[track_caller]
22272227
#[rustc_inherit_overflow_checks]
22282228
#[allow(arithmetic_overflow)]
2229-
pub const fn log(self, base: Self) -> u32 {
2230-
match self.checked_log(base) {
2229+
pub const fn ilog(self, base: Self) -> u32 {
2230+
match self.checked_ilog(base) {
22312231
Some(n) => n,
22322232
None => {
22332233
// In debug builds, trigger a panic on None.
@@ -2250,7 +2250,7 @@ macro_rules! int_impl {
22502250
///
22512251
/// ```
22522252
/// #![feature(int_log)]
2253-
#[doc = concat!("assert_eq!(2", stringify!($SelfT), ".log2(), 1);")]
2253+
#[doc = concat!("assert_eq!(2", stringify!($SelfT), ".ilog2(), 1);")]
22542254
/// ```
22552255
#[unstable(feature = "int_log", issue = "70887")]
22562256
#[must_use = "this returns the result of the operation, \
@@ -2259,8 +2259,8 @@ macro_rules! int_impl {
22592259
#[track_caller]
22602260
#[rustc_inherit_overflow_checks]
22612261
#[allow(arithmetic_overflow)]
2262-
pub const fn log2(self) -> u32 {
2263-
match self.checked_log2() {
2262+
pub const fn ilog2(self) -> u32 {
2263+
match self.checked_ilog2() {
22642264
Some(n) => n,
22652265
None => {
22662266
// In debug builds, trigger a panic on None.
@@ -2283,7 +2283,7 @@ macro_rules! int_impl {
22832283
///
22842284
/// ```
22852285
/// #![feature(int_log)]
2286-
#[doc = concat!("assert_eq!(10", stringify!($SelfT), ".log10(), 1);")]
2286+
#[doc = concat!("assert_eq!(10", stringify!($SelfT), ".ilog10(), 1);")]
22872287
/// ```
22882288
#[unstable(feature = "int_log", issue = "70887")]
22892289
#[must_use = "this returns the result of the operation, \
@@ -2292,8 +2292,8 @@ macro_rules! int_impl {
22922292
#[track_caller]
22932293
#[rustc_inherit_overflow_checks]
22942294
#[allow(arithmetic_overflow)]
2295-
pub const fn log10(self) -> u32 {
2296-
match self.checked_log10() {
2295+
pub const fn ilog10(self) -> u32 {
2296+
match self.checked_ilog10() {
22972297
Some(n) => n,
22982298
None => {
22992299
// In debug builds, trigger a panic on None.
@@ -2311,20 +2311,20 @@ macro_rules! int_impl {
23112311
/// Returns `None` if the number is negative or zero, or if the base is not at least 2.
23122312
///
23132313
/// This method might not be optimized owing to implementation details;
2314-
/// `checked_log2` can produce results more efficiently for base 2, and
2315-
/// `checked_log10` can produce results more efficiently for base 10.
2314+
/// `checked_ilog2` can produce results more efficiently for base 2, and
2315+
/// `checked_ilog10` can produce results more efficiently for base 10.
23162316
///
23172317
/// # Examples
23182318
///
23192319
/// ```
23202320
/// #![feature(int_log)]
2321-
#[doc = concat!("assert_eq!(5", stringify!($SelfT), ".checked_log(5), Some(1));")]
2321+
#[doc = concat!("assert_eq!(5", stringify!($SelfT), ".checked_ilog(5), Some(1));")]
23222322
/// ```
23232323
#[unstable(feature = "int_log", issue = "70887")]
23242324
#[must_use = "this returns the result of the operation, \
23252325
without modifying the original"]
23262326
#[inline]
2327-
pub const fn checked_log(self, base: Self) -> Option<u32> {
2327+
pub const fn checked_ilog(self, base: Self) -> Option<u32> {
23282328
if self <= 0 || base <= 1 {
23292329
None
23302330
} else {
@@ -2333,7 +2333,7 @@ macro_rules! int_impl {
23332333

23342334
// Optimization for 128 bit wide integers.
23352335
if Self::BITS == 128 {
2336-
let b = Self::log2(self) / (Self::log2(base) + 1);
2336+
let b = Self::ilog2(self) / (Self::ilog2(base) + 1);
23372337
n += b;
23382338
r /= base.pow(b as u32);
23392339
}
@@ -2354,13 +2354,13 @@ macro_rules! int_impl {
23542354
///
23552355
/// ```
23562356
/// #![feature(int_log)]
2357-
#[doc = concat!("assert_eq!(2", stringify!($SelfT), ".checked_log2(), Some(1));")]
2357+
#[doc = concat!("assert_eq!(2", stringify!($SelfT), ".checked_ilog2(), Some(1));")]
23582358
/// ```
23592359
#[unstable(feature = "int_log", issue = "70887")]
23602360
#[must_use = "this returns the result of the operation, \
23612361
without modifying the original"]
23622362
#[inline]
2363-
pub const fn checked_log2(self) -> Option<u32> {
2363+
pub const fn checked_ilog2(self) -> Option<u32> {
23642364
if self <= 0 {
23652365
None
23662366
} else {
@@ -2378,13 +2378,13 @@ macro_rules! int_impl {
23782378
///
23792379
/// ```
23802380
/// #![feature(int_log)]
2381-
#[doc = concat!("assert_eq!(10", stringify!($SelfT), ".checked_log10(), Some(1));")]
2381+
#[doc = concat!("assert_eq!(10", stringify!($SelfT), ".checked_ilog10(), Some(1));")]
23822382
/// ```
23832383
#[unstable(feature = "int_log", issue = "70887")]
23842384
#[must_use = "this returns the result of the operation, \
23852385
without modifying the original"]
23862386
#[inline]
2387-
pub const fn checked_log10(self) -> Option<u32> {
2387+
pub const fn checked_ilog10(self) -> Option<u32> {
23882388
if self > 0 {
23892389
Some(int_log10::$ActualT(self as $ActualT))
23902390
} else {

library/core/src/num/nonzero.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ macro_rules! nonzero_unsigned_operations {
450450
/// Returns the base 2 logarithm of the number, rounded down.
451451
///
452452
/// This is the same operation as
453-
#[doc = concat!("[`", stringify!($Int), "::log2`],")]
453+
#[doc = concat!("[`", stringify!($Int), "::ilog2`],")]
454454
/// except that it has no failure cases to worry about
455455
/// since this value can never be zero.
456456
///
@@ -460,22 +460,22 @@ macro_rules! nonzero_unsigned_operations {
460460
/// #![feature(int_log)]
461461
#[doc = concat!("# use std::num::", stringify!($Ty), ";")]
462462
///
463-
#[doc = concat!("assert_eq!(", stringify!($Ty), "::new(7).unwrap().log2(), 2);")]
464-
#[doc = concat!("assert_eq!(", stringify!($Ty), "::new(8).unwrap().log2(), 3);")]
465-
#[doc = concat!("assert_eq!(", stringify!($Ty), "::new(9).unwrap().log2(), 3);")]
463+
#[doc = concat!("assert_eq!(", stringify!($Ty), "::new(7).unwrap().ilog2(), 2);")]
464+
#[doc = concat!("assert_eq!(", stringify!($Ty), "::new(8).unwrap().ilog2(), 3);")]
465+
#[doc = concat!("assert_eq!(", stringify!($Ty), "::new(9).unwrap().ilog2(), 3);")]
466466
/// ```
467467
#[unstable(feature = "int_log", issue = "70887")]
468468
#[must_use = "this returns the result of the operation, \
469469
without modifying the original"]
470470
#[inline]
471-
pub const fn log2(self) -> u32 {
471+
pub const fn ilog2(self) -> u32 {
472472
Self::BITS - 1 - self.leading_zeros()
473473
}
474474

475475
/// Returns the base 10 logarithm of the number, rounded down.
476476
///
477477
/// This is the same operation as
478-
#[doc = concat!("[`", stringify!($Int), "::log10`],")]
478+
#[doc = concat!("[`", stringify!($Int), "::ilog10`],")]
479479
/// except that it has no failure cases to worry about
480480
/// since this value can never be zero.
481481
///
@@ -485,15 +485,15 @@ macro_rules! nonzero_unsigned_operations {
485485
/// #![feature(int_log)]
486486
#[doc = concat!("# use std::num::", stringify!($Ty), ";")]
487487
///
488-
#[doc = concat!("assert_eq!(", stringify!($Ty), "::new(99).unwrap().log10(), 1);")]
489-
#[doc = concat!("assert_eq!(", stringify!($Ty), "::new(100).unwrap().log10(), 2);")]
490-
#[doc = concat!("assert_eq!(", stringify!($Ty), "::new(101).unwrap().log10(), 2);")]
488+
#[doc = concat!("assert_eq!(", stringify!($Ty), "::new(99).unwrap().ilog10(), 1);")]
489+
#[doc = concat!("assert_eq!(", stringify!($Ty), "::new(100).unwrap().ilog10(), 2);")]
490+
#[doc = concat!("assert_eq!(", stringify!($Ty), "::new(101).unwrap().ilog10(), 2);")]
491491
/// ```
492492
#[unstable(feature = "int_log", issue = "70887")]
493493
#[must_use = "this returns the result of the operation, \
494494
without modifying the original"]
495495
#[inline]
496-
pub const fn log10(self) -> u32 {
496+
pub const fn ilog10(self) -> u32 {
497497
super::int_log10::$Int(self.0)
498498
}
499499
}

0 commit comments

Comments
 (0)