From 35726e909d44f41e090ac22e626bb4fa0e68afdb Mon Sep 17 00:00:00 2001 From: Kai Luo Date: Thu, 23 Mar 2023 17:56:26 +0800 Subject: [PATCH 1/9] LIBPATH is used as dylib's path environment variable on AIX --- src/bootstrap/dylib_util.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/bootstrap/dylib_util.rs b/src/bootstrap/dylib_util.rs index 6d75272c50130..b14c0bed66c2c 100644 --- a/src/bootstrap/dylib_util.rs +++ b/src/bootstrap/dylib_util.rs @@ -12,6 +12,8 @@ pub fn dylib_path_var() -> &'static str { "DYLD_LIBRARY_PATH" } else if cfg!(target_os = "haiku") { "LIBRARY_PATH" + } else if cfg!(target_os = "aix") { + "LIBPATH" } else { "LD_LIBRARY_PATH" } From 88b3ae96904312c7c0fe9b40357613f9fc29dbc8 Mon Sep 17 00:00:00 2001 From: Lenko Donchev Date: Sun, 26 Mar 2023 15:43:23 -0500 Subject: [PATCH 2/9] check for missing codegen backeng config --- src/bootstrap/compile.rs | 44 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 54971af644c28..783061d8ee84b 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -20,7 +20,7 @@ use serde_derive::Deserialize; use crate::builder::crate_description; use crate::builder::Cargo; -use crate::builder::{Builder, Kind, RunConfig, ShouldRun, Step}; +use crate::builder::{Builder, Kind, PathSet, RunConfig, ShouldRun, Step, TaskPath}; use crate::cache::{Interned, INTERNER}; use crate::config::{LlvmLibunwind, RustcLto, TargetSelection}; use crate::dist; @@ -995,6 +995,44 @@ pub struct CodegenBackend { pub backend: Interned, } +fn needs_codegen_config(run: &RunConfig<'_>) -> bool { + let mut needs_codegen_cfg = false; + for path_set in &run.paths { + needs_codegen_cfg = match path_set { + PathSet::Set(set) => set.iter().any(|p| is_codegen_cfg_needed(p, run)), + PathSet::Suite(suite) => is_codegen_cfg_needed(&suite, run), + } + } + needs_codegen_cfg +} + +const CODEGEN_BACKEND_PREFIX: &str = "rustc_codegen_"; + +fn is_codegen_cfg_needed(path: &TaskPath, run: &RunConfig<'_>) -> bool { + if path.path.to_str().unwrap().contains(&CODEGEN_BACKEND_PREFIX) { + let mut needs_codegen_backend_config = true; + for &backend in &run.builder.config.rust_codegen_backends { + if path + .path + .to_str() + .unwrap() + .ends_with(&(CODEGEN_BACKEND_PREFIX.to_owned() + &backend)) + { + needs_codegen_backend_config = false; + } + } + if needs_codegen_backend_config { + run.builder.info( + "Warning: no codegen-backends config matched the requested path to build a codegen backend. \ + Help: add backend to codegen-backends in config.toml.", + ); + return true; + } + } + + return false; +} + impl Step for CodegenBackend { type Output = (); const ONLY_HOSTS: bool = true; @@ -1006,6 +1044,10 @@ impl Step for CodegenBackend { } fn make_run(run: RunConfig<'_>) { + if needs_codegen_config(&run) { + return; + } + for &backend in &run.builder.config.rust_codegen_backends { if backend == "llvm" { continue; // Already built as part of rustc From b56fcb173bbf5ae0a52f26362639b7f2b922e7e9 Mon Sep 17 00:00:00 2001 From: Kai Luo Date: Tue, 28 Mar 2023 10:59:45 +0800 Subject: [PATCH 3/9] Set LIBPATH --- src/bootstrap/bootstrap.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index 013d1ab525b0c..d12781cc33af0 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -741,6 +741,9 @@ def build_bootstrap(self, color, verbose_count): env["LIBRARY_PATH"] = os.path.join(self.bin_root(), "lib") + \ (os.pathsep + env["LIBRARY_PATH"]) \ if "LIBRARY_PATH" in env else "" + env["LIBPATH"] = os.path.join(self.bin_root(), "lib") + \ + (os.pathsep + env["LIBPATH"]) \ + if "LIBPATH" in env else "" # Export Stage0 snapshot compiler related env variables build_section = "target.{}".format(self.build) From d3cc2f76465b854129daa4dca2a10b137a8699bf Mon Sep 17 00:00:00 2001 From: Kai Luo Date: Wed, 29 Mar 2023 14:55:30 +0800 Subject: [PATCH 4/9] Use LIBPATH in compiletest --- src/tools/compiletest/src/util.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/tools/compiletest/src/util.rs b/src/tools/compiletest/src/util.rs index 5f6a27e536638..748240cc94bc6 100644 --- a/src/tools/compiletest/src/util.rs +++ b/src/tools/compiletest/src/util.rs @@ -156,6 +156,8 @@ pub fn dylib_env_var() -> &'static str { "DYLD_LIBRARY_PATH" } else if cfg!(target_os = "haiku") { "LIBRARY_PATH" + } else if cfg!(target_os = "aix") { + "LIBPATH" } else { "LD_LIBRARY_PATH" } From a9aaf3fedba1ddbfa4e60c47794bd78688297ec2 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Wed, 29 Mar 2023 15:29:36 +0200 Subject: [PATCH 5/9] Implement read_buf for RustHermit In principle, this PR extends rust-lang/rust#108326 for RustyHermit. Signed-off-by: Stefan Lankes --- library/std/src/sys/hermit/net.rs | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/library/std/src/sys/hermit/net.rs b/library/std/src/sys/hermit/net.rs index 5fb6281aa1e3d..d6f64a2971902 100644 --- a/library/std/src/sys/hermit/net.rs +++ b/library/std/src/sys/hermit/net.rs @@ -1,7 +1,7 @@ #![allow(dead_code)] use crate::cmp; -use crate::io::{self, IoSlice, IoSliceMut}; +use crate::io::{self, BorrowedBuf, BorrowedCursor, IoSlice, IoSliceMut}; use crate::mem; use crate::net::{Shutdown, SocketAddr}; use crate::os::hermit::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, RawFd}; @@ -146,18 +146,35 @@ impl Socket { Ok(Socket(unsafe { FileDesc::from_raw_fd(fd) })) } - fn recv_with_flags(&self, buf: &mut [u8], flags: i32) -> io::Result { - let ret = - cvt(unsafe { netc::recv(self.0.as_raw_fd(), buf.as_mut_ptr(), buf.len(), flags) })?; - Ok(ret as usize) + fn recv_with_flags(&self, mut buf: BorrowedCursor<'_>, flags: i32) -> io::Result<()> { + let ret = cvt(unsafe { + netc::recv( + self.0.as_raw_fd(), + buf.as_mut().as_mut_ptr() as *mut u8, + buf.capacity(), + flags, + ) + })?; + unsafe { + buf.advance(ret as usize); + } + Ok(()) } pub fn read(&self, buf: &mut [u8]) -> io::Result { - self.recv_with_flags(buf, 0) + let mut buf = BorrowedBuf::from(buf); + self.recv_with_flags(buf.unfilled(), 0)?; + Ok(buf.len()) } pub fn peek(&self, buf: &mut [u8]) -> io::Result { - self.recv_with_flags(buf, netc::MSG_PEEK) + let mut buf = BorrowedBuf::from(buf); + self.recv_with_flags(buf.unfilled(), netc::MSG_PEEK)?; + Ok(buf.len()) + } + + pub fn read_buf(&self, buf: BorrowedCursor<'_>) -> io::Result<()> { + self.recv_with_flags(buf, 0) } pub fn read_vectored(&self, bufs: &mut [IoSliceMut<'_>]) -> io::Result { From 423e76f1ddf2ffeec4235b09946f563d3ddb6004 Mon Sep 17 00:00:00 2001 From: jyn Date: Sun, 2 Apr 2023 17:48:12 -0400 Subject: [PATCH 6/9] Improve job names in Github Actions preview Before: `CI / PR (mingw-check, false, ubuntu-20.04-16core-64gb) (pull_request)` After: `CI / PR - mingw-check (pull_request)` --- .github/workflows/ci.yml | 6 +++--- src/ci/github-actions/ci.yml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b45246eb4ead8..a917d9a7d55dd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,7 +34,7 @@ jobs: pr: permissions: actions: write - name: PR + name: "PR - ${{ matrix.name }}" env: CI_JOB_NAME: "${{ matrix.name }}" CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse @@ -159,7 +159,7 @@ jobs: auto: permissions: actions: write - name: auto + name: "auto - ${{ matrix.name }}" env: CI_JOB_NAME: "${{ matrix.name }}" CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse @@ -578,7 +578,7 @@ jobs: try: permissions: actions: write - name: try + name: "try - ${{ matrix.name }}" env: CI_JOB_NAME: "${{ matrix.name }}" CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse diff --git a/src/ci/github-actions/ci.yml b/src/ci/github-actions/ci.yml index c594288dcf81d..403953b5047d9 100644 --- a/src/ci/github-actions/ci.yml +++ b/src/ci/github-actions/ci.yml @@ -284,7 +284,7 @@ jobs: permissions: actions: write # for rust-lang/simpleinfra/github-actions/cancel-outdated-builds <<: *base-ci-job - name: PR + name: PR - ${{ matrix.name }} env: <<: [*shared-ci-variables, *public-variables] if: github.event_name == 'pull_request' @@ -312,7 +312,7 @@ jobs: permissions: actions: write # for rust-lang/simpleinfra/github-actions/cancel-outdated-builds <<: *base-ci-job - name: auto + name: auto - ${{ matrix.name }} env: <<: [*shared-ci-variables, *prod-variables] if: github.event_name == 'push' && github.ref == 'refs/heads/auto' && github.repository == 'rust-lang-ci/rust' @@ -741,7 +741,7 @@ jobs: permissions: actions: write # for rust-lang/simpleinfra/github-actions/cancel-outdated-builds <<: *base-ci-job - name: try + name: try - ${{ matrix.name }} env: <<: [*shared-ci-variables, *prod-variables] if: github.event_name == 'push' && (github.ref == 'refs/heads/try' || github.ref == 'refs/heads/try-perf') && github.repository == 'rust-lang-ci/rust' From dd85271ef5ea61fc4be3cd7607c838b99f8740f5 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Sun, 2 Apr 2023 19:02:55 -0400 Subject: [PATCH 7/9] Include invocation start times For multi-invocation builders (e.g., dist-x86_64-linux) this timestamp is necessary to correlate the data in the metrics JSON with other data sources (e.g., logs, cpu-usage CSV, etc.). Such correlation may not be perfect but is sometimes helpful and awkward to do otherwise. --- src/bootstrap/metrics.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/metrics.rs b/src/bootstrap/metrics.rs index 5f254761aa19f..82b123ec8a5e1 100644 --- a/src/bootstrap/metrics.rs +++ b/src/bootstrap/metrics.rs @@ -11,7 +11,7 @@ use serde_derive::{Deserialize, Serialize}; use std::cell::RefCell; use std::fs::File; use std::io::BufWriter; -use std::time::{Duration, Instant}; +use std::time::{Duration, Instant, SystemTime}; use sysinfo::{CpuExt, System, SystemExt}; pub(crate) struct BuildMetrics { @@ -27,6 +27,7 @@ impl BuildMetrics { system_info: System::new(), timer_start: None, invocation_timer_start: Instant::now(), + invocation_start: SystemTime::now(), }); BuildMetrics { state } @@ -124,6 +125,11 @@ impl BuildMetrics { } }; invocations.push(JsonInvocation { + start_time: state + .invocation_start + .duration_since(SystemTime::UNIX_EPOCH) + .unwrap() + .as_secs(), duration_including_children_sec: state.invocation_timer_start.elapsed().as_secs_f64(), children: steps.into_iter().map(|step| self.prepare_json_step(step)).collect(), }); @@ -166,6 +172,7 @@ struct MetricsState { system_info: System, timer_start: Option, invocation_timer_start: Instant, + invocation_start: SystemTime, } struct StepMetrics { @@ -194,6 +201,10 @@ struct JsonRoot { #[derive(Serialize, Deserialize)] #[serde(rename_all = "snake_case")] struct JsonInvocation { + // Unix timestamp in seconds + // + // This is necessary to easily correlate this invocation with logs or other data. + start_time: u64, duration_including_children_sec: f64, children: Vec, } From 01b75e20f2f92e3086bc004cd2f4430bf41ccdc0 Mon Sep 17 00:00:00 2001 From: jyn Date: Sun, 2 Apr 2023 19:30:32 -0400 Subject: [PATCH 8/9] Move some UI tests into subdirectories to avoid going over the existing limit now that the ui-fulldeps tests have been moved to ui. --- src/tools/tidy/src/ui_tests.rs | 2 +- .../ui/{ => generics}/slightly-nice-generic-literal-messages.rs | 0 .../slightly-nice-generic-literal-messages.stderr | 0 tests/ui/{ => lexer}/unterminated-comment.rs | 0 tests/ui/{ => lexer}/unterminated-comment.stderr | 0 tests/ui/{ => lexer}/unterminated-nested-comment.rs | 0 tests/ui/{ => lexer}/unterminated-nested-comment.stderr | 0 tests/ui/{ => privacy}/auxiliary/xc-private-method-lib.rs | 0 tests/ui/{ => privacy}/xc-private-method.rs | 0 tests/ui/{ => privacy}/xc-private-method.stderr | 0 tests/ui/{ => privacy}/xc-private-method2.rs | 0 tests/ui/{ => privacy}/xc-private-method2.stderr | 0 tests/ui/{ => reachable}/reachable-unnameable-type-alias.rs | 0 tests/ui/{ => resolve}/disambiguate-identical-names.rs | 0 tests/ui/{ => resolve}/disambiguate-identical-names.stderr | 0 tests/ui/{ => thread-local}/thread-local-mutation.rs | 0 tests/ui/{ => thread-local}/thread-local-mutation.stderr | 0 tests/ui/{ => thread-local}/thread-local-static.rs | 0 tests/ui/{ => thread-local}/thread-local-static.stderr | 0 tests/ui/{ => traits}/wrong-mul-method-signature.rs | 0 tests/ui/{ => traits}/wrong-mul-method-signature.stderr | 0 tests/ui/{ => tuple}/tuple-index.rs | 0 tests/ui/{ => typeck}/output-type-mismatch.rs | 0 tests/ui/{ => typeck}/output-type-mismatch.stderr | 0 tests/ui/{ => typeck}/suppressed-error.rs | 0 tests/ui/{ => typeck}/suppressed-error.stderr | 0 tests/ui/{ => typeck}/tag-that-dare-not-speak-its-name.rs | 0 tests/ui/{ => typeck}/tag-that-dare-not-speak-its-name.stderr | 0 tests/ui/{ => typeck}/terr-in-field.rs | 0 tests/ui/{ => typeck}/terr-in-field.stderr | 0 tests/ui/{ => typeck}/terr-sorts.rs | 0 tests/ui/{ => typeck}/terr-sorts.stderr | 0 tests/ui/{ => typeck}/while-type-error.rs | 0 tests/ui/{ => typeck}/while-type-error.stderr | 0 tests/ui/{ => typeck}/wrong-ret-type.rs | 0 tests/ui/{ => typeck}/wrong-ret-type.stderr | 0 tests/ui/{ => ufcs}/ufcs-polymorphic-paths.rs | 0 tests/ui/{ => unique}/expr-block-generic-unique1.rs | 0 tests/ui/{ => unique}/expr-block-generic-unique2.rs | 0 tests/ui/{ => unique}/expr-if-unique.rs | 0 tests/ui/{ => unique}/unique-object-noncopyable.rs | 0 tests/ui/{ => unique}/unique-object-noncopyable.stderr | 0 tests/ui/{ => unique}/unique-pinned-nocopy.rs | 0 tests/ui/{ => unique}/unique-pinned-nocopy.stderr | 0 tests/ui/{ => unique}/unwind-unique.rs | 0 tests/ui/{ => unpretty}/mir-unpretty.rs | 0 tests/ui/{ => unpretty}/mir-unpretty.stderr | 0 tests/ui/{ => unpretty}/unpretty-expr-fn-arg.rs | 0 tests/ui/{ => unpretty}/unpretty-expr-fn-arg.stdout | 0 tests/ui/{ => unsafe}/foreign-unsafe-fn-called.mir.stderr | 0 tests/ui/{ => unsafe}/foreign-unsafe-fn-called.rs | 0 tests/ui/{ => unsafe}/foreign-unsafe-fn-called.thir.stderr | 0 tests/ui/{ => unsafe}/new-unsafe-pointers.rs | 0 tests/ui/{ => unsafe}/unsafe-fn-called-from-unsafe-blk.rs | 0 tests/ui/{ => unsafe}/unsafe-fn-called-from-unsafe-fn.rs | 0 tests/ui/{ => unsafe}/unsafe-pointer-assignability.rs | 0 .../{ => variance}/variance-intersection-of-ref-and-opt-ref.rs | 0 tests/ui/{ => variance}/variance-iterators-in-libcore.rs | 0 tests/ui/{ => wasm}/wasm-custom-section-relocations.rs | 0 tests/ui/{ => wasm}/wasm-custom-section-relocations.stderr | 0 60 files changed, 1 insertion(+), 1 deletion(-) rename tests/ui/{ => generics}/slightly-nice-generic-literal-messages.rs (100%) rename tests/ui/{ => generics}/slightly-nice-generic-literal-messages.stderr (100%) rename tests/ui/{ => lexer}/unterminated-comment.rs (100%) rename tests/ui/{ => lexer}/unterminated-comment.stderr (100%) rename tests/ui/{ => lexer}/unterminated-nested-comment.rs (100%) rename tests/ui/{ => lexer}/unterminated-nested-comment.stderr (100%) rename tests/ui/{ => privacy}/auxiliary/xc-private-method-lib.rs (100%) rename tests/ui/{ => privacy}/xc-private-method.rs (100%) rename tests/ui/{ => privacy}/xc-private-method.stderr (100%) rename tests/ui/{ => privacy}/xc-private-method2.rs (100%) rename tests/ui/{ => privacy}/xc-private-method2.stderr (100%) rename tests/ui/{ => reachable}/reachable-unnameable-type-alias.rs (100%) rename tests/ui/{ => resolve}/disambiguate-identical-names.rs (100%) rename tests/ui/{ => resolve}/disambiguate-identical-names.stderr (100%) rename tests/ui/{ => thread-local}/thread-local-mutation.rs (100%) rename tests/ui/{ => thread-local}/thread-local-mutation.stderr (100%) rename tests/ui/{ => thread-local}/thread-local-static.rs (100%) rename tests/ui/{ => thread-local}/thread-local-static.stderr (100%) rename tests/ui/{ => traits}/wrong-mul-method-signature.rs (100%) rename tests/ui/{ => traits}/wrong-mul-method-signature.stderr (100%) rename tests/ui/{ => tuple}/tuple-index.rs (100%) rename tests/ui/{ => typeck}/output-type-mismatch.rs (100%) rename tests/ui/{ => typeck}/output-type-mismatch.stderr (100%) rename tests/ui/{ => typeck}/suppressed-error.rs (100%) rename tests/ui/{ => typeck}/suppressed-error.stderr (100%) rename tests/ui/{ => typeck}/tag-that-dare-not-speak-its-name.rs (100%) rename tests/ui/{ => typeck}/tag-that-dare-not-speak-its-name.stderr (100%) rename tests/ui/{ => typeck}/terr-in-field.rs (100%) rename tests/ui/{ => typeck}/terr-in-field.stderr (100%) rename tests/ui/{ => typeck}/terr-sorts.rs (100%) rename tests/ui/{ => typeck}/terr-sorts.stderr (100%) rename tests/ui/{ => typeck}/while-type-error.rs (100%) rename tests/ui/{ => typeck}/while-type-error.stderr (100%) rename tests/ui/{ => typeck}/wrong-ret-type.rs (100%) rename tests/ui/{ => typeck}/wrong-ret-type.stderr (100%) rename tests/ui/{ => ufcs}/ufcs-polymorphic-paths.rs (100%) rename tests/ui/{ => unique}/expr-block-generic-unique1.rs (100%) rename tests/ui/{ => unique}/expr-block-generic-unique2.rs (100%) rename tests/ui/{ => unique}/expr-if-unique.rs (100%) rename tests/ui/{ => unique}/unique-object-noncopyable.rs (100%) rename tests/ui/{ => unique}/unique-object-noncopyable.stderr (100%) rename tests/ui/{ => unique}/unique-pinned-nocopy.rs (100%) rename tests/ui/{ => unique}/unique-pinned-nocopy.stderr (100%) rename tests/ui/{ => unique}/unwind-unique.rs (100%) rename tests/ui/{ => unpretty}/mir-unpretty.rs (100%) rename tests/ui/{ => unpretty}/mir-unpretty.stderr (100%) rename tests/ui/{ => unpretty}/unpretty-expr-fn-arg.rs (100%) rename tests/ui/{ => unpretty}/unpretty-expr-fn-arg.stdout (100%) rename tests/ui/{ => unsafe}/foreign-unsafe-fn-called.mir.stderr (100%) rename tests/ui/{ => unsafe}/foreign-unsafe-fn-called.rs (100%) rename tests/ui/{ => unsafe}/foreign-unsafe-fn-called.thir.stderr (100%) rename tests/ui/{ => unsafe}/new-unsafe-pointers.rs (100%) rename tests/ui/{ => unsafe}/unsafe-fn-called-from-unsafe-blk.rs (100%) rename tests/ui/{ => unsafe}/unsafe-fn-called-from-unsafe-fn.rs (100%) rename tests/ui/{ => unsafe}/unsafe-pointer-assignability.rs (100%) rename tests/ui/{ => variance}/variance-intersection-of-ref-and-opt-ref.rs (100%) rename tests/ui/{ => variance}/variance-iterators-in-libcore.rs (100%) rename tests/ui/{ => wasm}/wasm-custom-section-relocations.rs (100%) rename tests/ui/{ => wasm}/wasm-custom-section-relocations.stderr (100%) diff --git a/src/tools/tidy/src/ui_tests.rs b/src/tools/tidy/src/ui_tests.rs index 20b8a2c3b24d4..f582666ab2830 100644 --- a/src/tools/tidy/src/ui_tests.rs +++ b/src/tools/tidy/src/ui_tests.rs @@ -9,7 +9,7 @@ use std::path::{Path, PathBuf}; const ENTRY_LIMIT: usize = 1000; // FIXME: The following limits should be reduced eventually. -const ROOT_ENTRY_LIMIT: usize = 940; +const ROOT_ENTRY_LIMIT: usize = 881; const ISSUES_ENTRY_LIMIT: usize = 1978; fn check_entries(tests_path: &Path, bad: &mut bool) { diff --git a/tests/ui/slightly-nice-generic-literal-messages.rs b/tests/ui/generics/slightly-nice-generic-literal-messages.rs similarity index 100% rename from tests/ui/slightly-nice-generic-literal-messages.rs rename to tests/ui/generics/slightly-nice-generic-literal-messages.rs diff --git a/tests/ui/slightly-nice-generic-literal-messages.stderr b/tests/ui/generics/slightly-nice-generic-literal-messages.stderr similarity index 100% rename from tests/ui/slightly-nice-generic-literal-messages.stderr rename to tests/ui/generics/slightly-nice-generic-literal-messages.stderr diff --git a/tests/ui/unterminated-comment.rs b/tests/ui/lexer/unterminated-comment.rs similarity index 100% rename from tests/ui/unterminated-comment.rs rename to tests/ui/lexer/unterminated-comment.rs diff --git a/tests/ui/unterminated-comment.stderr b/tests/ui/lexer/unterminated-comment.stderr similarity index 100% rename from tests/ui/unterminated-comment.stderr rename to tests/ui/lexer/unterminated-comment.stderr diff --git a/tests/ui/unterminated-nested-comment.rs b/tests/ui/lexer/unterminated-nested-comment.rs similarity index 100% rename from tests/ui/unterminated-nested-comment.rs rename to tests/ui/lexer/unterminated-nested-comment.rs diff --git a/tests/ui/unterminated-nested-comment.stderr b/tests/ui/lexer/unterminated-nested-comment.stderr similarity index 100% rename from tests/ui/unterminated-nested-comment.stderr rename to tests/ui/lexer/unterminated-nested-comment.stderr diff --git a/tests/ui/auxiliary/xc-private-method-lib.rs b/tests/ui/privacy/auxiliary/xc-private-method-lib.rs similarity index 100% rename from tests/ui/auxiliary/xc-private-method-lib.rs rename to tests/ui/privacy/auxiliary/xc-private-method-lib.rs diff --git a/tests/ui/xc-private-method.rs b/tests/ui/privacy/xc-private-method.rs similarity index 100% rename from tests/ui/xc-private-method.rs rename to tests/ui/privacy/xc-private-method.rs diff --git a/tests/ui/xc-private-method.stderr b/tests/ui/privacy/xc-private-method.stderr similarity index 100% rename from tests/ui/xc-private-method.stderr rename to tests/ui/privacy/xc-private-method.stderr diff --git a/tests/ui/xc-private-method2.rs b/tests/ui/privacy/xc-private-method2.rs similarity index 100% rename from tests/ui/xc-private-method2.rs rename to tests/ui/privacy/xc-private-method2.rs diff --git a/tests/ui/xc-private-method2.stderr b/tests/ui/privacy/xc-private-method2.stderr similarity index 100% rename from tests/ui/xc-private-method2.stderr rename to tests/ui/privacy/xc-private-method2.stderr diff --git a/tests/ui/reachable-unnameable-type-alias.rs b/tests/ui/reachable/reachable-unnameable-type-alias.rs similarity index 100% rename from tests/ui/reachable-unnameable-type-alias.rs rename to tests/ui/reachable/reachable-unnameable-type-alias.rs diff --git a/tests/ui/disambiguate-identical-names.rs b/tests/ui/resolve/disambiguate-identical-names.rs similarity index 100% rename from tests/ui/disambiguate-identical-names.rs rename to tests/ui/resolve/disambiguate-identical-names.rs diff --git a/tests/ui/disambiguate-identical-names.stderr b/tests/ui/resolve/disambiguate-identical-names.stderr similarity index 100% rename from tests/ui/disambiguate-identical-names.stderr rename to tests/ui/resolve/disambiguate-identical-names.stderr diff --git a/tests/ui/thread-local-mutation.rs b/tests/ui/thread-local/thread-local-mutation.rs similarity index 100% rename from tests/ui/thread-local-mutation.rs rename to tests/ui/thread-local/thread-local-mutation.rs diff --git a/tests/ui/thread-local-mutation.stderr b/tests/ui/thread-local/thread-local-mutation.stderr similarity index 100% rename from tests/ui/thread-local-mutation.stderr rename to tests/ui/thread-local/thread-local-mutation.stderr diff --git a/tests/ui/thread-local-static.rs b/tests/ui/thread-local/thread-local-static.rs similarity index 100% rename from tests/ui/thread-local-static.rs rename to tests/ui/thread-local/thread-local-static.rs diff --git a/tests/ui/thread-local-static.stderr b/tests/ui/thread-local/thread-local-static.stderr similarity index 100% rename from tests/ui/thread-local-static.stderr rename to tests/ui/thread-local/thread-local-static.stderr diff --git a/tests/ui/wrong-mul-method-signature.rs b/tests/ui/traits/wrong-mul-method-signature.rs similarity index 100% rename from tests/ui/wrong-mul-method-signature.rs rename to tests/ui/traits/wrong-mul-method-signature.rs diff --git a/tests/ui/wrong-mul-method-signature.stderr b/tests/ui/traits/wrong-mul-method-signature.stderr similarity index 100% rename from tests/ui/wrong-mul-method-signature.stderr rename to tests/ui/traits/wrong-mul-method-signature.stderr diff --git a/tests/ui/tuple-index.rs b/tests/ui/tuple/tuple-index.rs similarity index 100% rename from tests/ui/tuple-index.rs rename to tests/ui/tuple/tuple-index.rs diff --git a/tests/ui/output-type-mismatch.rs b/tests/ui/typeck/output-type-mismatch.rs similarity index 100% rename from tests/ui/output-type-mismatch.rs rename to tests/ui/typeck/output-type-mismatch.rs diff --git a/tests/ui/output-type-mismatch.stderr b/tests/ui/typeck/output-type-mismatch.stderr similarity index 100% rename from tests/ui/output-type-mismatch.stderr rename to tests/ui/typeck/output-type-mismatch.stderr diff --git a/tests/ui/suppressed-error.rs b/tests/ui/typeck/suppressed-error.rs similarity index 100% rename from tests/ui/suppressed-error.rs rename to tests/ui/typeck/suppressed-error.rs diff --git a/tests/ui/suppressed-error.stderr b/tests/ui/typeck/suppressed-error.stderr similarity index 100% rename from tests/ui/suppressed-error.stderr rename to tests/ui/typeck/suppressed-error.stderr diff --git a/tests/ui/tag-that-dare-not-speak-its-name.rs b/tests/ui/typeck/tag-that-dare-not-speak-its-name.rs similarity index 100% rename from tests/ui/tag-that-dare-not-speak-its-name.rs rename to tests/ui/typeck/tag-that-dare-not-speak-its-name.rs diff --git a/tests/ui/tag-that-dare-not-speak-its-name.stderr b/tests/ui/typeck/tag-that-dare-not-speak-its-name.stderr similarity index 100% rename from tests/ui/tag-that-dare-not-speak-its-name.stderr rename to tests/ui/typeck/tag-that-dare-not-speak-its-name.stderr diff --git a/tests/ui/terr-in-field.rs b/tests/ui/typeck/terr-in-field.rs similarity index 100% rename from tests/ui/terr-in-field.rs rename to tests/ui/typeck/terr-in-field.rs diff --git a/tests/ui/terr-in-field.stderr b/tests/ui/typeck/terr-in-field.stderr similarity index 100% rename from tests/ui/terr-in-field.stderr rename to tests/ui/typeck/terr-in-field.stderr diff --git a/tests/ui/terr-sorts.rs b/tests/ui/typeck/terr-sorts.rs similarity index 100% rename from tests/ui/terr-sorts.rs rename to tests/ui/typeck/terr-sorts.rs diff --git a/tests/ui/terr-sorts.stderr b/tests/ui/typeck/terr-sorts.stderr similarity index 100% rename from tests/ui/terr-sorts.stderr rename to tests/ui/typeck/terr-sorts.stderr diff --git a/tests/ui/while-type-error.rs b/tests/ui/typeck/while-type-error.rs similarity index 100% rename from tests/ui/while-type-error.rs rename to tests/ui/typeck/while-type-error.rs diff --git a/tests/ui/while-type-error.stderr b/tests/ui/typeck/while-type-error.stderr similarity index 100% rename from tests/ui/while-type-error.stderr rename to tests/ui/typeck/while-type-error.stderr diff --git a/tests/ui/wrong-ret-type.rs b/tests/ui/typeck/wrong-ret-type.rs similarity index 100% rename from tests/ui/wrong-ret-type.rs rename to tests/ui/typeck/wrong-ret-type.rs diff --git a/tests/ui/wrong-ret-type.stderr b/tests/ui/typeck/wrong-ret-type.stderr similarity index 100% rename from tests/ui/wrong-ret-type.stderr rename to tests/ui/typeck/wrong-ret-type.stderr diff --git a/tests/ui/ufcs-polymorphic-paths.rs b/tests/ui/ufcs/ufcs-polymorphic-paths.rs similarity index 100% rename from tests/ui/ufcs-polymorphic-paths.rs rename to tests/ui/ufcs/ufcs-polymorphic-paths.rs diff --git a/tests/ui/expr-block-generic-unique1.rs b/tests/ui/unique/expr-block-generic-unique1.rs similarity index 100% rename from tests/ui/expr-block-generic-unique1.rs rename to tests/ui/unique/expr-block-generic-unique1.rs diff --git a/tests/ui/expr-block-generic-unique2.rs b/tests/ui/unique/expr-block-generic-unique2.rs similarity index 100% rename from tests/ui/expr-block-generic-unique2.rs rename to tests/ui/unique/expr-block-generic-unique2.rs diff --git a/tests/ui/expr-if-unique.rs b/tests/ui/unique/expr-if-unique.rs similarity index 100% rename from tests/ui/expr-if-unique.rs rename to tests/ui/unique/expr-if-unique.rs diff --git a/tests/ui/unique-object-noncopyable.rs b/tests/ui/unique/unique-object-noncopyable.rs similarity index 100% rename from tests/ui/unique-object-noncopyable.rs rename to tests/ui/unique/unique-object-noncopyable.rs diff --git a/tests/ui/unique-object-noncopyable.stderr b/tests/ui/unique/unique-object-noncopyable.stderr similarity index 100% rename from tests/ui/unique-object-noncopyable.stderr rename to tests/ui/unique/unique-object-noncopyable.stderr diff --git a/tests/ui/unique-pinned-nocopy.rs b/tests/ui/unique/unique-pinned-nocopy.rs similarity index 100% rename from tests/ui/unique-pinned-nocopy.rs rename to tests/ui/unique/unique-pinned-nocopy.rs diff --git a/tests/ui/unique-pinned-nocopy.stderr b/tests/ui/unique/unique-pinned-nocopy.stderr similarity index 100% rename from tests/ui/unique-pinned-nocopy.stderr rename to tests/ui/unique/unique-pinned-nocopy.stderr diff --git a/tests/ui/unwind-unique.rs b/tests/ui/unique/unwind-unique.rs similarity index 100% rename from tests/ui/unwind-unique.rs rename to tests/ui/unique/unwind-unique.rs diff --git a/tests/ui/mir-unpretty.rs b/tests/ui/unpretty/mir-unpretty.rs similarity index 100% rename from tests/ui/mir-unpretty.rs rename to tests/ui/unpretty/mir-unpretty.rs diff --git a/tests/ui/mir-unpretty.stderr b/tests/ui/unpretty/mir-unpretty.stderr similarity index 100% rename from tests/ui/mir-unpretty.stderr rename to tests/ui/unpretty/mir-unpretty.stderr diff --git a/tests/ui/unpretty-expr-fn-arg.rs b/tests/ui/unpretty/unpretty-expr-fn-arg.rs similarity index 100% rename from tests/ui/unpretty-expr-fn-arg.rs rename to tests/ui/unpretty/unpretty-expr-fn-arg.rs diff --git a/tests/ui/unpretty-expr-fn-arg.stdout b/tests/ui/unpretty/unpretty-expr-fn-arg.stdout similarity index 100% rename from tests/ui/unpretty-expr-fn-arg.stdout rename to tests/ui/unpretty/unpretty-expr-fn-arg.stdout diff --git a/tests/ui/foreign-unsafe-fn-called.mir.stderr b/tests/ui/unsafe/foreign-unsafe-fn-called.mir.stderr similarity index 100% rename from tests/ui/foreign-unsafe-fn-called.mir.stderr rename to tests/ui/unsafe/foreign-unsafe-fn-called.mir.stderr diff --git a/tests/ui/foreign-unsafe-fn-called.rs b/tests/ui/unsafe/foreign-unsafe-fn-called.rs similarity index 100% rename from tests/ui/foreign-unsafe-fn-called.rs rename to tests/ui/unsafe/foreign-unsafe-fn-called.rs diff --git a/tests/ui/foreign-unsafe-fn-called.thir.stderr b/tests/ui/unsafe/foreign-unsafe-fn-called.thir.stderr similarity index 100% rename from tests/ui/foreign-unsafe-fn-called.thir.stderr rename to tests/ui/unsafe/foreign-unsafe-fn-called.thir.stderr diff --git a/tests/ui/new-unsafe-pointers.rs b/tests/ui/unsafe/new-unsafe-pointers.rs similarity index 100% rename from tests/ui/new-unsafe-pointers.rs rename to tests/ui/unsafe/new-unsafe-pointers.rs diff --git a/tests/ui/unsafe-fn-called-from-unsafe-blk.rs b/tests/ui/unsafe/unsafe-fn-called-from-unsafe-blk.rs similarity index 100% rename from tests/ui/unsafe-fn-called-from-unsafe-blk.rs rename to tests/ui/unsafe/unsafe-fn-called-from-unsafe-blk.rs diff --git a/tests/ui/unsafe-fn-called-from-unsafe-fn.rs b/tests/ui/unsafe/unsafe-fn-called-from-unsafe-fn.rs similarity index 100% rename from tests/ui/unsafe-fn-called-from-unsafe-fn.rs rename to tests/ui/unsafe/unsafe-fn-called-from-unsafe-fn.rs diff --git a/tests/ui/unsafe-pointer-assignability.rs b/tests/ui/unsafe/unsafe-pointer-assignability.rs similarity index 100% rename from tests/ui/unsafe-pointer-assignability.rs rename to tests/ui/unsafe/unsafe-pointer-assignability.rs diff --git a/tests/ui/variance-intersection-of-ref-and-opt-ref.rs b/tests/ui/variance/variance-intersection-of-ref-and-opt-ref.rs similarity index 100% rename from tests/ui/variance-intersection-of-ref-and-opt-ref.rs rename to tests/ui/variance/variance-intersection-of-ref-and-opt-ref.rs diff --git a/tests/ui/variance-iterators-in-libcore.rs b/tests/ui/variance/variance-iterators-in-libcore.rs similarity index 100% rename from tests/ui/variance-iterators-in-libcore.rs rename to tests/ui/variance/variance-iterators-in-libcore.rs diff --git a/tests/ui/wasm-custom-section-relocations.rs b/tests/ui/wasm/wasm-custom-section-relocations.rs similarity index 100% rename from tests/ui/wasm-custom-section-relocations.rs rename to tests/ui/wasm/wasm-custom-section-relocations.rs diff --git a/tests/ui/wasm-custom-section-relocations.stderr b/tests/ui/wasm/wasm-custom-section-relocations.stderr similarity index 100% rename from tests/ui/wasm-custom-section-relocations.stderr rename to tests/ui/wasm/wasm-custom-section-relocations.stderr From d8a4e7cf51fbdca489084e117050fe2e2c22cb21 Mon Sep 17 00:00:00 2001 From: bohan Date: Sun, 2 Apr 2023 18:50:01 +0800 Subject: [PATCH 9/9] fix(middle): emit error rather than delay bug when reaching limit --- compiler/rustc_middle/messages.ftl | 4 ++ compiler/rustc_middle/src/error.rs | 8 +++ compiler/rustc_middle/src/ty/util.rs | 14 +++-- tests/ui/autoref-autoderef/issue-38940.rs | 52 ------------------- tests/ui/autoref-autoderef/issue-38940.stderr | 23 -------- .../did_you_mean/recursion_limit_deref.stderr | 6 ++- 6 files changed, 26 insertions(+), 81 deletions(-) delete mode 100644 tests/ui/autoref-autoderef/issue-38940.rs delete mode 100644 tests/ui/autoref-autoderef/issue-38940.stderr diff --git a/compiler/rustc_middle/messages.ftl b/compiler/rustc_middle/messages.ftl index 4f4e5c6a2c9c2..bd9d89deee179 100644 --- a/compiler/rustc_middle/messages.ftl +++ b/compiler/rustc_middle/messages.ftl @@ -16,6 +16,10 @@ middle_limit_invalid = `limit` must be a non-negative integer .label = {$error_str} +middle_recursion_limit_reached = + reached the recursion limit finding the struct tail for `{$ty}` + .help = consider increasing the recursion limit by adding a `#![recursion_limit = "{$suggested_limit}"]` + middle_const_eval_non_int = constant evaluation of enum discriminant resulted in non-integer diff --git a/compiler/rustc_middle/src/error.rs b/compiler/rustc_middle/src/error.rs index 5e94da8cb4d36..dc4aa18640fb3 100644 --- a/compiler/rustc_middle/src/error.rs +++ b/compiler/rustc_middle/src/error.rs @@ -49,6 +49,14 @@ pub struct LimitInvalid<'a> { pub error_str: &'a str, } +#[derive(Diagnostic)] +#[diag(middle_recursion_limit_reached)] +#[help] +pub struct RecursionLimitReached<'tcx> { + pub ty: Ty<'tcx>, + pub suggested_limit: rustc_session::Limit, +} + #[derive(Diagnostic)] #[diag(middle_const_eval_non_int)] pub struct ConstEvalNonIntError { diff --git a/compiler/rustc_middle/src/ty/util.rs b/compiler/rustc_middle/src/ty/util.rs index d3565b28ae5f9..4411bcd927d71 100644 --- a/compiler/rustc_middle/src/ty/util.rs +++ b/compiler/rustc_middle/src/ty/util.rs @@ -19,7 +19,8 @@ use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_index::bit_set::GrowableBitSet; use rustc_index::vec::{Idx, IndexVec}; use rustc_macros::HashStable; -use rustc_span::{sym, DUMMY_SP}; +use rustc_session::Limit; +use rustc_span::sym; use rustc_target::abi::{Integer, IntegerType, Size, TargetDataLayout}; use rustc_target::spec::abi::Abi; use smallvec::SmallVec; @@ -225,10 +226,13 @@ impl<'tcx> TyCtxt<'tcx> { let recursion_limit = self.recursion_limit(); for iteration in 0.. { if !recursion_limit.value_within_limit(iteration) { - return self.ty_error_with_message( - DUMMY_SP, - &format!("reached the recursion limit finding the struct tail for {}", ty), - ); + let suggested_limit = match recursion_limit { + Limit(0) => Limit(2), + limit => limit * 2, + }; + let reported = + self.sess.emit_err(crate::error::RecursionLimitReached { ty, suggested_limit }); + return self.ty_error(reported); } match *ty.kind() { ty::Adt(def, substs) => { diff --git a/tests/ui/autoref-autoderef/issue-38940.rs b/tests/ui/autoref-autoderef/issue-38940.rs deleted file mode 100644 index d2f1c6e327192..0000000000000 --- a/tests/ui/autoref-autoderef/issue-38940.rs +++ /dev/null @@ -1,52 +0,0 @@ -// issue-38940: error printed twice for deref recursion limit exceeded -// Test that the recursion limit can be changed. In this case, we have -// deeply nested types that will fail the `Send` check by overflow -// when the recursion limit is set very low. -// compile-flags: -Zdeduplicate-diagnostics=yes - -#![allow(dead_code)] -#![recursion_limit = "10"] -macro_rules! link { - ($outer:ident, $inner:ident) => { - struct $outer($inner); - impl $outer { - fn new() -> $outer { - $outer($inner::new()) - } - } - impl std::ops::Deref for $outer { - type Target = $inner; - fn deref(&self) -> &$inner { - &self.0 - } - } - }; -} - -struct Bottom; - -impl Bottom { - fn new() -> Bottom { - Bottom - } -} - -link!(Top, A); -link!(A, B); -link!(B, C); -link!(C, D); -link!(D, E); -link!(E, F); -link!(F, G); -link!(G, H); -link!(H, I); -link!(I, J); -link!(J, K); -link!(K, Bottom); - -fn main() { - let t = Top::new(); - let x: &Bottom = &t; - //~^ ERROR mismatched types - //~| ERROR reached the recursion limit while auto-dereferencing `J` -} diff --git a/tests/ui/autoref-autoderef/issue-38940.stderr b/tests/ui/autoref-autoderef/issue-38940.stderr deleted file mode 100644 index 8e98bfcd90fbc..0000000000000 --- a/tests/ui/autoref-autoderef/issue-38940.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error[E0055]: reached the recursion limit while auto-dereferencing `J` - --> $DIR/issue-38940.rs:49:22 - | -LL | let x: &Bottom = &t; - | ^^ deref recursion limit reached - | - = help: consider increasing the recursion limit by adding a `#![recursion_limit = "20"]` attribute to your crate (`issue_38940`) - -error[E0308]: mismatched types - --> $DIR/issue-38940.rs:49:22 - | -LL | let x: &Bottom = &t; - | ------- ^^ expected `&Bottom`, found `&Top` - | | - | expected due to this - | - = note: expected reference `&Bottom` - found reference `&Top` - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0055, E0308. -For more information about an error, try `rustc --explain E0055`. diff --git a/tests/ui/did_you_mean/recursion_limit_deref.stderr b/tests/ui/did_you_mean/recursion_limit_deref.stderr index 32fb628c4707b..b0c493faf1ef2 100644 --- a/tests/ui/did_you_mean/recursion_limit_deref.stderr +++ b/tests/ui/did_you_mean/recursion_limit_deref.stderr @@ -1,3 +1,7 @@ +error: reached the recursion limit finding the struct tail for `Bottom` + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "20"]` + error[E0055]: reached the recursion limit while auto-dereferencing `J` --> $DIR/recursion_limit_deref.rs:51:22 | @@ -17,7 +21,7 @@ LL | let x: &Bottom = &t; = note: expected reference `&Bottom` found reference `&Top` -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors Some errors have detailed explanations: E0055, E0308. For more information about an error, try `rustc --explain E0055`.