Skip to content

Commit 8308806

Browse files
committed
Auto merge of rust-lang#98632 - matthiaskrgr:rollup-peg868d, r=matthiaskrgr
Rollup of 11 pull requests Successful merges: - rust-lang#98548 (rustdoc-json: Allow Typedef to be different in sanity assert) - rust-lang#98560 (Add regression test for rust-lang#85907) - rust-lang#98564 (Remove references to `./tmp` in-tree) - rust-lang#98602 (Add regression test for rust-lang#80074) - rust-lang#98606 (:arrow_up: rust-analyzer) - rust-lang#98609 (Fix ICE for associated constant generics) - rust-lang#98611 (Fix glob import ICE in rustdoc JSON format) - rust-lang#98617 (Remove feature `const_option` from std) - rust-lang#98619 (Fix mir-opt wg name) - rust-lang#98621 (llvm-wrapper: adapt for removal of the ASanGlobalsMetadataAnalysis LLVM API) - rust-lang#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

-2
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

+1-1
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

+2
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

+1-1
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

-1
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

+15-4
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

+5-1
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

+6-1
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

+22
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

+24
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+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const fn hey() -> usize {
2+
panic!(123); //~ ERROR argument to `panic!()` in a const context must have type `&str`
3+
}
4+
5+
fn main() {
6+
let _: [u8; hey()] = todo!();
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: argument to `panic!()` in a const context must have type `&str`
2+
--> $DIR/issue-85907.rs:2:5
3+
|
4+
LL | panic!(123);
5+
| ^^^^^^^^^^^
6+
|
7+
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
8+
9+
error: aborting due to previous error
10+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// edition:2018
2+
3+
macro_rules! foo_ { () => {}; }
4+
use foo_ as foo;

src/test/ui/extern/issue-80074.rs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// edition:2018
2+
// build-pass
3+
// aux-crate:issue_80074=issue-80074-macro.rs
4+
5+
#[macro_use]
6+
extern crate issue_80074;
7+
8+
fn main() {
9+
foo!();
10+
}

src/test/ui/generics/issue-98432.rs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
struct Struct<T>(T);
2+
3+
impl<T> Struct<T> {
4+
const CONST: fn() = || {
5+
struct _Obligation where T:; //~ ERROR can't use generic parameters from outer function
6+
};
7+
}
8+
9+
fn main() {}
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error[E0401]: can't use generic parameters from outer function
2+
--> $DIR/issue-98432.rs:5:34
3+
|
4+
LL | impl<T> Struct<T> {
5+
| - type parameter from outer function
6+
LL | const CONST: fn() = || {
7+
LL | struct _Obligation where T:;
8+
| ^ use of generic parameter from outer function
9+
|
10+
= help: try using a local generic parameter instead
11+
12+
error: aborting due to previous error
13+
14+
For more information about this error, try `rustc --explain E0401`.

src/tools/compiletest/src/main.rs

-5
Original file line numberDiff line numberDiff line change
@@ -351,11 +351,6 @@ pub fn opt_str2(maybestr: Option<String>) -> String {
351351
}
352352

353353
pub fn run_tests(config: Config) {
354-
// FIXME(#33435) Avoid spurious failures in codegen-units/partitioning tests.
355-
if let Mode::CodegenUnits = config.mode {
356-
let _ = fs::remove_dir_all("tmp/partitioning-tests");
357-
}
358-
359354
// If we want to collect rustfix coverage information,
360355
// we first make sure that the coverage file does not exist.
361356
// It will be created later on.

src/tools/rust-analyzer

triagebot.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ cc = ["@rust-lang/miri"]
244244

245245
[mentions."compiler/rustc_mir_transform/src/"]
246246
message = "Some changes occurred to MIR optimizations"
247-
cc = ["@rust-lang/mir-opt"]
247+
cc = ["@rust-lang/wg-mir-opt"]
248248

249249
[mentions."compiler/rustc_trait_selection/src/traits/const_evaluatable.rs"]
250250
message = "Some changes occurred in const_evaluatable.rs"

0 commit comments

Comments
 (0)