Skip to content

Commit 8308806

Browse files
committed
Auto merge of #98632 - matthiaskrgr:rollup-peg868d, r=matthiaskrgr
Rollup of 11 pull requests Successful merges: - #98548 (rustdoc-json: Allow Typedef to be different in sanity assert) - #98560 (Add regression test for #85907) - #98564 (Remove references to `./tmp` in-tree) - #98602 (Add regression test for #80074) - #98606 (:arrow_up: rust-analyzer) - #98609 (Fix ICE for associated constant generics) - #98611 (Fix glob import ICE in rustdoc JSON format) - #98617 (Remove feature `const_option` from std) - #98619 (Fix mir-opt wg name) - #98621 (llvm-wrapper: adapt for removal of the ASanGlobalsMetadataAnalysis LLVM API) - #98623 (fix typo in comment) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 94e9374 + 164c98e commit 8308806

File tree

19 files changed

+132
-18
lines changed

19 files changed

+132
-18
lines changed

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ no_llvm_build
4646
/unicode-downloads
4747
/target
4848
/src/tools/x/target
49-
# Generated by compiletest for incremental
50-
/tmp/
5149
# Created by default with `src/ci/docker/run.sh`
5250
/obj/
5351

compiler/rustc_lexer/src/unescape.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ fn scan_escape(chars: &mut Chars<'_>, mode: Mode) -> Result<char, EscapeError> {
238238
c.to_digit(16).ok_or(EscapeError::InvalidCharInUnicodeEscape)?;
239239
n_digits += 1;
240240
if n_digits > 6 {
241-
// Stop updating value since we're sure that it's is incorrect already.
241+
// Stop updating value since we're sure that it's incorrect already.
242242
continue;
243243
}
244244
let digit = digit as u32;

compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -985,7 +985,9 @@ LLVMRustOptimizeWithNewPassManager(
985985
if (SanitizerOptions->SanitizeAddress) {
986986
OptimizerLastEPCallbacks.push_back(
987987
[SanitizerOptions](ModulePassManager &MPM, OptimizationLevel Level) {
988+
#if LLVM_VERSION_LT(15, 0)
988989
MPM.addPass(RequireAnalysisPass<ASanGlobalsMetadataAnalysis, Module>());
990+
#endif
989991
#if LLVM_VERSION_GE(14, 0)
990992
AddressSanitizerOptions opts = AddressSanitizerOptions{
991993
/*CompileKernel=*/false,

compiler/rustc_span/src/source_map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,7 @@ impl SourceMap {
956956
}
957957

958958
pub fn generate_fn_name_span(&self, span: Span) -> Option<Span> {
959-
let prev_span = self.span_extend_to_prev_str(span, "fn", true, true).unwrap_or(span);
959+
let prev_span = self.span_extend_to_prev_str(span, "fn", true, true)?;
960960
if let Ok(snippet) = self.span_to_snippet(prev_span) {
961961
debug!(
962962
"generate_fn_name_span: span={:?}, prev_span={:?}, snippet={:?}",

library/std/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,6 @@
335335
#![feature(const_ip)]
336336
#![feature(const_ipv4)]
337337
#![feature(const_ipv6)]
338-
#![feature(const_option)]
339338
#![feature(const_socketaddr)]
340339
#![feature(thread_local_internals)]
341340
//

library/std/src/sys/windows/args.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,17 @@ use crate::vec;
2121

2222
use core::iter;
2323

24+
/// This is the const equivalent to `NonZeroU16::new(n).unwrap()`
25+
///
26+
/// FIXME: This can be removed once `Option::unwrap` is stably const.
27+
/// See the `const_option` feature (#67441).
28+
const fn non_zero_u16(n: u16) -> NonZeroU16 {
29+
match NonZeroU16::new(n) {
30+
Some(n) => n,
31+
None => panic!("called `unwrap` on a `None` value"),
32+
}
33+
}
34+
2435
pub fn args() -> Args {
2536
// SAFETY: `GetCommandLineW` returns a pointer to a null terminated UTF-16
2637
// string so it's safe for `WStrUnits` to use.
@@ -58,10 +69,10 @@ fn parse_lp_cmd_line<'a, F: Fn() -> OsString>(
5869
lp_cmd_line: Option<WStrUnits<'a>>,
5970
exe_name: F,
6071
) -> Vec<OsString> {
61-
const BACKSLASH: NonZeroU16 = NonZeroU16::new(b'\\' as u16).unwrap();
62-
const QUOTE: NonZeroU16 = NonZeroU16::new(b'"' as u16).unwrap();
63-
const TAB: NonZeroU16 = NonZeroU16::new(b'\t' as u16).unwrap();
64-
const SPACE: NonZeroU16 = NonZeroU16::new(b' ' as u16).unwrap();
72+
const BACKSLASH: NonZeroU16 = non_zero_u16(b'\\' as u16);
73+
const QUOTE: NonZeroU16 = non_zero_u16(b'"' as u16);
74+
const TAB: NonZeroU16 = non_zero_u16(b'\t' as u16);
75+
const SPACE: NonZeroU16 = non_zero_u16(b' ' as u16);
6576

6677
let mut ret_val = Vec::new();
6778
// If the cmd line pointer is null or it points to an empty string then

src/librustdoc/clean/types.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2161,8 +2161,12 @@ impl Path {
21612161
self.res.def_id()
21622162
}
21632163

2164+
pub(crate) fn last_opt(&self) -> Option<Symbol> {
2165+
self.segments.last().map(|s| s.name)
2166+
}
2167+
21642168
pub(crate) fn last(&self) -> Symbol {
2165-
self.segments.last().expect("segments were empty").name
2169+
self.last_opt().expect("segments were empty")
21662170
}
21672171

21682172
pub(crate) fn whole_name(&self) -> String {

src/librustdoc/json/conversions.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,12 @@ impl FromWithTcx<clean::Import> for Import {
666666
},
667667
Glob => Import {
668668
source: import.source.path.whole_name(),
669-
name: import.source.path.last().to_string(),
669+
name: import
670+
.source
671+
.path
672+
.last_opt()
673+
.unwrap_or_else(|| Symbol::intern("*"))
674+
.to_string(),
670675
id: import.source.did.map(ItemId::from).map(|i| from_item_id(i, tcx)),
671676
glob: true,
672677
},

src/test/rustdoc-json/assoc_type.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Regression test for <https://github.com/rust-lang/rust/issues/98547>.
2+
3+
// @has assoc_type.json
4+
// @has - "$.index[*][?(@.name=='Trait')]"
5+
// @has - "$.index[*][?(@.name=='AssocType')]"
6+
// @has - "$.index[*][?(@.name=='S')]"
7+
// @has - "$.index[*][?(@.name=='S2')]"
8+
9+
pub trait Trait {
10+
type AssocType;
11+
}
12+
13+
impl<T> Trait for T {
14+
type AssocType = Self;
15+
}
16+
17+
pub struct S;
18+
19+
/// Not needed for the #98547 ICE to occur, but added to maximize the chance of
20+
/// getting an ICE in the future. See
21+
/// <https://github.com/rust-lang/rust/pull/98548#discussion_r908219164>
22+
pub struct S2;

src/test/rustdoc-json/glob_import.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// This is a regression test for <https://github.com/rust-lang/rust/issues/98003>.
2+
3+
#![feature(no_core)]
4+
#![no_std]
5+
#![no_core]
6+
7+
// @has glob_import.json
8+
// @has - "$.index[*][?(@.name=='glob')]"
9+
// @has - "$.index[*][?(@.kind=='import')].inner.name" \"*\"
10+
11+
12+
mod m1 {
13+
pub fn f() {}
14+
}
15+
mod m2 {
16+
pub fn f(_: u8) {}
17+
}
18+
19+
pub use m1::*;
20+
pub use m2::*;
21+
22+
pub mod glob {
23+
pub use *;
24+
}

0 commit comments

Comments
 (0)