From 89a23bf54f666b396405bc43765424aeeccac065 Mon Sep 17 00:00:00 2001 From: Takayuki Maeda Date: Mon, 27 Jun 2022 10:07:19 +0900 Subject: [PATCH 01/14] add regression test for #85907 --- src/test/ui/consts/const-eval/issue-85907.rs | 7 +++++++ src/test/ui/consts/const-eval/issue-85907.stderr | 10 ++++++++++ 2 files changed, 17 insertions(+) create mode 100644 src/test/ui/consts/const-eval/issue-85907.rs create mode 100644 src/test/ui/consts/const-eval/issue-85907.stderr diff --git a/src/test/ui/consts/const-eval/issue-85907.rs b/src/test/ui/consts/const-eval/issue-85907.rs new file mode 100644 index 0000000000000..6ae40ae6ddbf6 --- /dev/null +++ b/src/test/ui/consts/const-eval/issue-85907.rs @@ -0,0 +1,7 @@ +const fn hey() -> usize { + panic!(123); //~ ERROR argument to `panic!()` in a const context must have type `&str` +} + +fn main() { + let _: [u8; hey()] = todo!(); +} diff --git a/src/test/ui/consts/const-eval/issue-85907.stderr b/src/test/ui/consts/const-eval/issue-85907.stderr new file mode 100644 index 0000000000000..381f2fd1114ec --- /dev/null +++ b/src/test/ui/consts/const-eval/issue-85907.stderr @@ -0,0 +1,10 @@ +error: argument to `panic!()` in a const context must have type `&str` + --> $DIR/issue-85907.rs:2:5 + | +LL | panic!(123); + | ^^^^^^^^^^^ + | + = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to previous error + From d16187c47f023601b74e41550e7e36058baa02c4 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Sun, 26 Jun 2022 23:25:12 -0500 Subject: [PATCH 02/14] Remove references to `./tmp` in-tree These used to be used by codegen-units tests, but were switched from manually specifying directories to just using `// incremental` in https://github.com/rust-lang/rust/pull/89101. Remove the old references. --- .gitignore | 2 -- src/tools/compiletest/src/main.rs | 5 ----- 2 files changed, 7 deletions(-) diff --git a/.gitignore b/.gitignore index ec6cb6ed2e4d3..a6625ac2ac4a1 100644 --- a/.gitignore +++ b/.gitignore @@ -46,8 +46,6 @@ no_llvm_build /unicode-downloads /target /src/tools/x/target -# Generated by compiletest for incremental -/tmp/ # Created by default with `src/ci/docker/run.sh` /obj/ diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs index e23cccf6cd129..4e8e5afd4bbe2 100644 --- a/src/tools/compiletest/src/main.rs +++ b/src/tools/compiletest/src/main.rs @@ -351,11 +351,6 @@ pub fn opt_str2(maybestr: Option) -> String { } pub fn run_tests(config: Config) { - // FIXME(#33435) Avoid spurious failures in codegen-units/partitioning tests. - if let Mode::CodegenUnits = config.mode { - let _ = fs::remove_dir_all("tmp/partitioning-tests"); - } - // If we want to collect rustfix coverage information, // we first make sure that the coverage file does not exist. // It will be created later on. From 05263f05bd5c78fe129e1a32479852f1c2bb66fa Mon Sep 17 00:00:00 2001 From: Takayuki Maeda Date: Tue, 28 Jun 2022 12:28:04 +0900 Subject: [PATCH 03/14] add regression test for #80074 --- src/test/ui/extern/auxiliary/issue-80074-macro.rs | 4 ++++ src/test/ui/extern/issue-80074.rs | 10 ++++++++++ 2 files changed, 14 insertions(+) create mode 100644 src/test/ui/extern/auxiliary/issue-80074-macro.rs create mode 100644 src/test/ui/extern/issue-80074.rs diff --git a/src/test/ui/extern/auxiliary/issue-80074-macro.rs b/src/test/ui/extern/auxiliary/issue-80074-macro.rs new file mode 100644 index 0000000000000..30e0f19ab8d84 --- /dev/null +++ b/src/test/ui/extern/auxiliary/issue-80074-macro.rs @@ -0,0 +1,4 @@ +// edition:2018 + +macro_rules! foo_ { () => {}; } +use foo_ as foo; diff --git a/src/test/ui/extern/issue-80074.rs b/src/test/ui/extern/issue-80074.rs new file mode 100644 index 0000000000000..f83027d4abfd2 --- /dev/null +++ b/src/test/ui/extern/issue-80074.rs @@ -0,0 +1,10 @@ +// edition:2018 +// build-pass +// aux-crate:issue_80074=issue-80074-macro.rs + +#[macro_use] +extern crate issue_80074; + +fn main() { + foo!(); +} From 396342a1fba683ab7ba42b3654ff26eaac0be180 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Tue, 28 Jun 2022 09:54:21 +0300 Subject: [PATCH 04/14] :arrow_up: rust-analyzer --- src/tools/rust-analyzer | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/rust-analyzer b/src/tools/rust-analyzer index 427061da19723..b74e96f509baf 160000 --- a/src/tools/rust-analyzer +++ b/src/tools/rust-analyzer @@ -1 +1 @@ -Subproject commit 427061da19723f2206fe4dcb175c9c43b9a6193d +Subproject commit b74e96f509baf0be70281c55f14cb18fefbc6b22 From ae4b929c00fbead6a0923a07306ffde077d622ad Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Sun, 26 Jun 2022 20:22:04 +0200 Subject: [PATCH 05/14] rustdoc-json: Add assoc type ICE regression test --- src/test/rustdoc-json/assoc_type.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/test/rustdoc-json/assoc_type.rs diff --git a/src/test/rustdoc-json/assoc_type.rs b/src/test/rustdoc-json/assoc_type.rs new file mode 100644 index 0000000000000..b7e985958bcef --- /dev/null +++ b/src/test/rustdoc-json/assoc_type.rs @@ -0,0 +1,16 @@ +// Regression test for . + +// @has assoc_type.json +// @has - "$.index[*][?(@.name=='Trait')]" +// @has - "$.index[*][?(@.name=='AssocType')]" +// @has - "$.index[*][?(@.name=='S')]" + +pub trait Trait { + type AssocType; +} + +impl Trait for T { + type AssocType = Self; +} + +pub struct S; From 2888e76d06483e505bf4956a08bc24d4e7764beb Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Tue, 28 Jun 2022 11:02:14 +0200 Subject: [PATCH 06/14] test/rustdoc-json/assoc_type.rs: Maximize chance of detecting future ICEs --- src/test/rustdoc-json/assoc_type.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/test/rustdoc-json/assoc_type.rs b/src/test/rustdoc-json/assoc_type.rs index b7e985958bcef..716bb3d2848cc 100644 --- a/src/test/rustdoc-json/assoc_type.rs +++ b/src/test/rustdoc-json/assoc_type.rs @@ -4,6 +4,7 @@ // @has - "$.index[*][?(@.name=='Trait')]" // @has - "$.index[*][?(@.name=='AssocType')]" // @has - "$.index[*][?(@.name=='S')]" +// @has - "$.index[*][?(@.name=='S2')]" pub trait Trait { type AssocType; @@ -14,3 +15,8 @@ impl Trait for T { } pub struct S; + +/// Not needed for the #98547 ICE to occur, but added to maximize the chance of +/// getting an ICE in the future. See +/// +pub struct S2; From 8c7d9f609212d4525cc05e2d1d4955425d78f7d8 Mon Sep 17 00:00:00 2001 From: Takayuki Maeda Date: Tue, 28 Jun 2022 18:29:07 +0900 Subject: [PATCH 07/14] fix ice for associated constant generics --- compiler/rustc_span/src/source_map.rs | 2 +- src/test/ui/generics/issue-98432.rs | 9 +++++++++ src/test/ui/generics/issue-98432.stderr | 14 ++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 src/test/ui/generics/issue-98432.rs create mode 100644 src/test/ui/generics/issue-98432.stderr diff --git a/compiler/rustc_span/src/source_map.rs b/compiler/rustc_span/src/source_map.rs index 95ea702961701..227127aed50d7 100644 --- a/compiler/rustc_span/src/source_map.rs +++ b/compiler/rustc_span/src/source_map.rs @@ -956,7 +956,7 @@ impl SourceMap { } pub fn generate_fn_name_span(&self, span: Span) -> Option { - let prev_span = self.span_extend_to_prev_str(span, "fn", true, true).unwrap_or(span); + let prev_span = self.span_extend_to_prev_str(span, "fn", true, true)?; if let Ok(snippet) = self.span_to_snippet(prev_span) { debug!( "generate_fn_name_span: span={:?}, prev_span={:?}, snippet={:?}", diff --git a/src/test/ui/generics/issue-98432.rs b/src/test/ui/generics/issue-98432.rs new file mode 100644 index 0000000000000..780c50d6ffa19 --- /dev/null +++ b/src/test/ui/generics/issue-98432.rs @@ -0,0 +1,9 @@ +struct Struct(T); + +impl Struct { + const CONST: fn() = || { + struct _Obligation where T:; //~ ERROR can't use generic parameters from outer function + }; +} + +fn main() {} diff --git a/src/test/ui/generics/issue-98432.stderr b/src/test/ui/generics/issue-98432.stderr new file mode 100644 index 0000000000000..afa67b63bd9a1 --- /dev/null +++ b/src/test/ui/generics/issue-98432.stderr @@ -0,0 +1,14 @@ +error[E0401]: can't use generic parameters from outer function + --> $DIR/issue-98432.rs:5:34 + | +LL | impl Struct { + | - type parameter from outer function +LL | const CONST: fn() = || { +LL | struct _Obligation where T:; + | ^ use of generic parameter from outer function + | + = help: try using a local generic parameter instead + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0401`. From b7e62000ddced5d8bd4b7e21d9e247bbc1912723 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 28 Jun 2022 11:46:03 +0200 Subject: [PATCH 08/14] Fix glob import ICE in rustdoc JSON format --- src/librustdoc/clean/types.rs | 6 +++++- src/librustdoc/json/conversions.rs | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 2762d5e8502b2..352803855a4e7 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -2161,8 +2161,12 @@ impl Path { self.res.def_id() } + pub(crate) fn last_opt(&self) -> Option { + self.segments.last().map(|s| s.name) + } + pub(crate) fn last(&self) -> Symbol { - self.segments.last().expect("segments were empty").name + self.last_opt().expect("segments were empty") } pub(crate) fn whole_name(&self) -> String { diff --git a/src/librustdoc/json/conversions.rs b/src/librustdoc/json/conversions.rs index c627dcc30d667..84b3d7431cfb8 100644 --- a/src/librustdoc/json/conversions.rs +++ b/src/librustdoc/json/conversions.rs @@ -663,7 +663,12 @@ impl FromWithTcx for Import { }, Glob => Import { source: import.source.path.whole_name(), - name: import.source.path.last().to_string(), + name: import + .source + .path + .last_opt() + .unwrap_or_else(|| Symbol::intern("*")) + .to_string(), id: import.source.did.map(ItemId::from).map(|i| from_item_id(i, tcx)), glob: true, }, From c2221eff6213224f0828173f9a3061373c437306 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 28 Jun 2022 11:46:24 +0200 Subject: [PATCH 09/14] Add regression test for glob import ICE in rustdoc JSON --- src/test/rustdoc-json/glob_import.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/test/rustdoc-json/glob_import.rs diff --git a/src/test/rustdoc-json/glob_import.rs b/src/test/rustdoc-json/glob_import.rs new file mode 100644 index 0000000000000..d7ac952d1bbc5 --- /dev/null +++ b/src/test/rustdoc-json/glob_import.rs @@ -0,0 +1,24 @@ +// This is a regression test for . + +#![feature(no_core)] +#![no_std] +#![no_core] + +// @has glob_import.json +// @has - "$.index[*][?(@.name=='glob')]" +// @has - "$.index[*][?(@.kind=='import')].inner.name" \"*\" + + +mod m1 { + pub fn f() {} +} +mod m2 { + pub fn f(_: u8) {} +} + +pub use m1::*; +pub use m2::*; + +pub mod glob { + pub use *; +} From 2ee92419dd17606d6b50f44b413dcf7ef49ac116 Mon Sep 17 00:00:00 2001 From: Chris Denton Date: Tue, 28 Jun 2022 11:37:48 +0100 Subject: [PATCH 10/14] Remove feature `const_option` from std --- library/std/src/lib.rs | 1 - library/std/src/sys/windows/args.rs | 16 ++++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index 7da9f248c877a..65b8df4299663 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -335,7 +335,6 @@ #![feature(const_ip)] #![feature(const_ipv4)] #![feature(const_ipv6)] -#![feature(const_option)] #![feature(const_socketaddr)] #![feature(thread_local_internals)] // diff --git a/library/std/src/sys/windows/args.rs b/library/std/src/sys/windows/args.rs index c5918103fec25..361cf0590a17c 100644 --- a/library/std/src/sys/windows/args.rs +++ b/library/std/src/sys/windows/args.rs @@ -21,6 +21,14 @@ use crate::vec; use core::iter; +/// This is the const equivalent to `NonZeroU16::new(n).unwrap()` +const fn non_zero_u16(n: u16) -> NonZeroU16 { + match NonZeroU16::new(n) { + Some(n) => n, + None => panic!("called `unwrap` on a `None` value"), + } +} + pub fn args() -> Args { // SAFETY: `GetCommandLineW` returns a pointer to a null terminated UTF-16 // string so it's safe for `WStrUnits` to use. @@ -58,10 +66,10 @@ fn parse_lp_cmd_line<'a, F: Fn() -> OsString>( lp_cmd_line: Option>, exe_name: F, ) -> Vec { - const BACKSLASH: NonZeroU16 = NonZeroU16::new(b'\\' as u16).unwrap(); - const QUOTE: NonZeroU16 = NonZeroU16::new(b'"' as u16).unwrap(); - const TAB: NonZeroU16 = NonZeroU16::new(b'\t' as u16).unwrap(); - const SPACE: NonZeroU16 = NonZeroU16::new(b' ' as u16).unwrap(); + const BACKSLASH: NonZeroU16 = non_zero_u16(b'\\' as u16); + const QUOTE: NonZeroU16 = non_zero_u16(b'"' as u16); + const TAB: NonZeroU16 = non_zero_u16(b'\t' as u16); + const SPACE: NonZeroU16 = non_zero_u16(b' ' as u16); let mut ret_val = Vec::new(); // If the cmd line pointer is null or it points to an empty string then From 720c430822ab093449d495487cc103b39bcf9f4a Mon Sep 17 00:00:00 2001 From: Chris Denton Date: Tue, 28 Jun 2022 12:18:16 +0100 Subject: [PATCH 11/14] Add a fixme comment --- library/std/src/sys/windows/args.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/library/std/src/sys/windows/args.rs b/library/std/src/sys/windows/args.rs index 361cf0590a17c..01f26298290f0 100644 --- a/library/std/src/sys/windows/args.rs +++ b/library/std/src/sys/windows/args.rs @@ -22,6 +22,9 @@ use crate::vec; use core::iter; /// This is the const equivalent to `NonZeroU16::new(n).unwrap()` +/// +/// FIXME: This can be removed once `Option::unwrap` is stably const. +/// See the `const_option` feature (#67441). const fn non_zero_u16(n: u16) -> NonZeroU16 { match NonZeroU16::new(n) { Some(n) => n, From d6b9c10e03014ed6a3091aa79c78ab1d183e86ed Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Tue, 28 Jun 2022 08:14:42 -0400 Subject: [PATCH 12/14] Fix mir-opt wg name --- triagebot.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/triagebot.toml b/triagebot.toml index 8aefb1f620b3d..100dfd613f0cb 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -244,7 +244,7 @@ cc = ["@rust-lang/miri"] [mentions."compiler/rustc_mir_transform/src/"] message = "Some changes occurred to MIR optimizations" -cc = ["@rust-lang/mir-opt"] +cc = ["@rust-lang/wg-mir-opt"] [mentions."compiler/rustc_trait_selection/src/traits/const_evaluatable.rs"] message = "Some changes occurred in const_evaluatable.rs" From fe02ee8be97fc94166e3920d16d550bd6994fabd Mon Sep 17 00:00:00 2001 From: Krasimir Georgiev Date: Tue, 28 Jun 2022 14:08:35 +0000 Subject: [PATCH 13/14] llvm-wrapper: adapt for an LLVM API change This adapts llvm-wrapper for https://github.com/llvm/llvm-project/commit/dacfa24f75c328ae30b710ecadaa18e4ba10cdc6, which removed ASanGlobalsMetadataAnalysis. --- compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp index 38fddbdba54dd..0f4973ebf7129 100644 --- a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp @@ -985,7 +985,9 @@ LLVMRustOptimizeWithNewPassManager( if (SanitizerOptions->SanitizeAddress) { OptimizerLastEPCallbacks.push_back( [SanitizerOptions](ModulePassManager &MPM, OptimizationLevel Level) { +#if LLVM_VERSION_LT(15, 0) MPM.addPass(RequireAnalysisPass()); +#endif #if LLVM_VERSION_GE(14, 0) AddressSanitizerOptions opts = AddressSanitizerOptions{ /*CompileKernel=*/false, From 8c22b6bcaccd4a2fa1ac3f4e03c74847f203e166 Mon Sep 17 00:00:00 2001 From: Proloy Mishra <67726964+pro465@users.noreply.github.com> Date: Tue, 28 Jun 2022 19:59:09 +0530 Subject: [PATCH 14/14] fix typo in comment --- compiler/rustc_lexer/src/unescape.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_lexer/src/unescape.rs b/compiler/rustc_lexer/src/unescape.rs index 97f9588ae1ef5..3da6bc14622a0 100644 --- a/compiler/rustc_lexer/src/unescape.rs +++ b/compiler/rustc_lexer/src/unescape.rs @@ -238,7 +238,7 @@ fn scan_escape(chars: &mut Chars<'_>, mode: Mode) -> Result { c.to_digit(16).ok_or(EscapeError::InvalidCharInUnicodeEscape)?; n_digits += 1; if n_digits > 6 { - // Stop updating value since we're sure that it's is incorrect already. + // Stop updating value since we're sure that it's incorrect already. continue; } let digit = digit as u32;