From 8915ba7b1b6433032400ace217e765bd96686763 Mon Sep 17 00:00:00 2001 From: Alex Touchet Date: Wed, 28 Dec 2022 21:47:09 -0800 Subject: [PATCH 01/11] Improve Markdown styling in README --- README.md | 163 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 90 insertions(+), 73 deletions(-) diff --git a/README.md b/README.md index ac39435a8c7fb..0eb7c4b266a9f 100644 --- a/README.md +++ b/README.md @@ -3,10 +3,11 @@ This is the main source code repository for [Rust]. It contains the compiler, standard library, and documentation. -[Rust]: https://www.rust-lang.org +[Rust]: https://www.rust-lang.org/ **Note: this README is for _users_ rather than _contributors_.** -If you wish to _contribute_ to the compiler, you should read [CONTRIBUTING.md](CONTRIBUTING.md) instead. +If you wish to _contribute_ to the compiler, you should read +[CONTRIBUTING.md](CONTRIBUTING.md) instead. ## Quick Start @@ -20,13 +21,15 @@ Read ["Installation"] from [The Book]. The Rust build system uses a Python script called `x.py` to build the compiler, which manages the bootstrapping process. It lives at the root of the project. -The `x.py` command can be run directly on most Unix systems in the following format: +The `x.py` command can be run directly on most Unix systems in the following +format: ```sh ./x.py [flags] ``` -This is how the documentation and examples assume you are running `x.py`. Some alternative ways are: +This is how the documentation and examples assume you are running `x.py`. +Some alternative ways are: ```sh # On a Unix shell if you don't have the necessary `python3` command @@ -39,8 +42,8 @@ x.py [flags] python x.py [flags] ``` -More information about `x.py` can be found -by running it with the `--help` flag or reading the [rustc dev guide][rustcguidebuild]. +More information about `x.py` can be found by running it with the `--help` flag +or reading the [rustc dev guide][rustcguidebuild]. [gettingstarted]: https://rustc-dev-guide.rust-lang.org/getting-started.html [rustcguidebuild]: https://rustc-dev-guide.rust-lang.org/building/how-to-build-and-run.html @@ -49,24 +52,29 @@ by running it with the `--help` flag or reading the [rustc dev guide][rustcguide Make sure you have installed the dependencies: - * `python` 3 or 2.7 - * `git` - * A C compiler (when building for the host, `cc` is enough; cross-compiling may need additional compilers) - * `curl` (not needed on Windows) - * `pkg-config` if you are compiling on Linux and targeting Linux - * `libiconv` (already included with glibc on Debian-based distros) +* `python` 3 or 2.7 +* `git` +* A C compiler (when building for the host, `cc` is enough; cross-compiling may + need additional compilers) +* `curl` (not needed on Windows) +* `pkg-config` if you are compiling on Linux and targeting Linux +* `libiconv` (already included with glibc on Debian-based distros) -To build cargo, you'll also need OpenSSL (`libssl-dev` or `openssl-devel` on most Unix distros). +To build Cargo, you'll also need OpenSSL (`libssl-dev` or `openssl-devel` on +most Unix distros). If building LLVM from source, you'll need additional tools: * `g++`, `clang++`, or MSVC with versions listed on [LLVM's documentation](https://llvm.org/docs/GettingStarted.html#host-c-toolchain-both-compiler-and-standard-library) -* `ninja`, or GNU `make` 3.81 or later (ninja is recommended, especially on Windows) +* `ninja`, or GNU `make` 3.81 or later (Ninja is recommended, especially on + Windows) * `cmake` 3.13.4 or later -* `libstdc++-static` may be required on some Linux distributions such as Fedora and Ubuntu +* `libstdc++-static` may be required on some Linux distributions such as Fedora + and Ubuntu -On tier 1 or tier 2 with host tools platforms, you can also choose to download LLVM by setting `llvm.download-ci-llvm = true`. +On tier 1 or tier 2 with host tools platforms, you can also choose to download +LLVM by setting `llvm.download-ci-llvm = true`. Otherwise, you'll need LLVM installed and `llvm-config` in your path. See [the rustc-dev-guide for more info][sysllvm]. @@ -86,34 +94,37 @@ See [the rustc-dev-guide for more info][sysllvm]. 2. Configure the build settings: - The Rust build system uses a file named `config.toml` in the root of the - source tree to determine various configuration settings for the build. - Set up the defaults intended for distros to get started. You can see a full list of options - in `config.toml.example`. + The Rust build system uses a file named `config.toml` in the root of the + source tree to determine various configuration settings for the build. + Set up the defaults intended for distros to get started. You can see a full + list of options in `config.toml.example`. - ```sh - printf 'profile = "user" \nchangelog-seen = 2 \n' > config.toml - ``` + ```sh + printf 'profile = "user" \nchangelog-seen = 2 \n' > config.toml + ``` - If you plan to use `x.py install` to create an installation, it is recommended - that you set the `prefix` value in the `[install]` section to a directory. + If you plan to use `x.py install` to create an installation, it is + recommended that you set the `prefix` value in the `[install]` section to a + directory. 3. Build and install: - ```sh - ./x.py build && ./x.py install - ``` + ```sh + ./x.py build && ./x.py install + ``` - When complete, `./x.py install` will place several programs into - `$PREFIX/bin`: `rustc`, the Rust compiler, and `rustdoc`, the - API-documentation tool. If you've set `profile = "user"` or `build.extended = true`, it will - also include [Cargo], Rust's package manager. + When complete, `./x.py install` will place several programs into + `$PREFIX/bin`: `rustc`, the Rust compiler, and `rustdoc`, the + API-documentation tool. If you've set `profile = "user"` or + `build.extended = true`, it will also include [Cargo], Rust's package + manager. [Cargo]: https://github.com/rust-lang/cargo ### Building on Windows -On Windows, we suggest using [winget] to install dependencies by running the following in a terminal: +On Windows, we suggest using [winget] to install dependencies by running the +following in a terminal: ```powershell winget install -e Python.Python.3 @@ -121,17 +132,19 @@ winget install -e Kitware.CMake winget install -e Git.Git ``` -Then edit your system's `PATH` variable and add: `C:\Program Files\CMake\bin`. See -[this guide on editing the system `PATH`](https://www.java.com/en/download/help/path.html) from the -Java documentation. +Then edit your system's `PATH` variable and add: `C:\Program Files\CMake\bin`. +See +[this guide on editing the system `PATH`](https://www.java.com/en/download/help/path.html) +from the Java documentation. [winget]: https://github.com/microsoft/winget-cli There are two prominent ABIs in use on Windows: the native (MSVC) ABI used by Visual Studio and the GNU ABI used by the GCC toolchain. Which version of Rust you need depends largely on what C/C++ libraries you want to interoperate with. -Use the MSVC build of Rust to interop with software produced by Visual Studio and -the GNU build to interop with GNU software built using the MinGW/MSYS2 toolchain. +Use the MSVC build of Rust to interop with software produced by Visual Studio +and the GNU build to interop with GNU software built using the MinGW/MSYS2 +toolchain. #### MinGW @@ -144,7 +157,7 @@ the GNU build to interop with GNU software built using the MinGW/MSYS2 toolchain 2. Run `mingw32_shell.bat` or `mingw64_shell.bat` from the MSYS2 installation directory (e.g. `C:\msys64`), depending on whether you want 32-bit or 64-bit Rust. (As of the latest version of MSYS2 you have to run `msys2_shell.cmd - -mingw32` or `msys2_shell.cmd -mingw64` from the command line instead) + -mingw32` or `msys2_shell.cmd -mingw64` from the command line instead.) 3. From this terminal, install the required tools: @@ -153,11 +166,11 @@ the GNU build to interop with GNU software built using the MinGW/MSYS2 toolchain pacman -Sy pacman-mirrors # Install build tools needed for Rust. If you're building a 32-bit compiler, - # then replace "x86_64" below with "i686". If you've already got git, python, - # or CMake installed and in PATH you can remove them from this list. Note - # that it is important that you do **not** use the 'python2', 'cmake' and 'ninja' - # packages from the 'msys2' subsystem. The build has historically been known - # to fail with these packages. + # then replace "x86_64" below with "i686". If you've already got Git, Python, + # or CMake installed and in PATH you can remove them from this list. + # Note that it is important that you do **not** use the 'python2', 'cmake', + # and 'ninja' packages from the 'msys2' subsystem. + # The build has historically been known to fail with these packages. pacman -S git \ make \ diffutils \ @@ -178,12 +191,12 @@ the GNU build to interop with GNU software built using the MinGW/MSYS2 toolchain MSVC builds of Rust additionally require an installation of Visual Studio 2017 (or later) so `rustc` can use its linker. The simplest way is to get -[Visual Studio], check the “C++ build tools” and “Windows 10 SDK” workload. +[Visual Studio], check the "C++ build tools" and "Windows 10 SDK" workload. [Visual Studio]: https://visualstudio.microsoft.com/downloads/ -(If you're installing cmake yourself, be careful that “C++ CMake tools for -Windows” doesn't get included under “Individual components”.) +(If you're installing CMake yourself, be careful that "C++ CMake tools for +Windows" doesn't get included under "Individual components".) With these dependencies installed, you can build the compiler in a `cmd.exe` shell with: @@ -192,10 +205,11 @@ shell with: python x.py build ``` -Right now, building Rust only works with some known versions of Visual Studio. If -you have a more recent version installed and the build system doesn't understand, -you may need to force rustbuild to use an older version. This can be done -by manually calling the appropriate vcvars file before running the bootstrap. +Right now, building Rust only works with some known versions of Visual Studio. +If you have a more recent version installed and the build system doesn't +understand, you may need to force rustbuild to use an older version. +This can be done by manually calling the appropriate vcvars file before running +the bootstrap. ```batch CALL "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat" @@ -215,9 +229,9 @@ Windows build triples are: - `x86_64-pc-windows-msvc` The build triple can be specified by either specifying `--build=` when -invoking `x.py` commands, or by creating a `config.toml` file (as described -in [Installing From Source](#installing-from-source)), and modifying the -`build` option under the `[build]` section. +invoking `x.py` commands, or by creating a `config.toml` file (as described in +[Installing from Source](#installing-from-source)), and modifying the `build` +option under the `[build]` section. ### Configure and Make @@ -229,33 +243,35 @@ configure script and makefile (the latter of which just invokes `x.py`). make && sudo make install ``` -`configure` generates a `config.toml` which can also be used with normal `x.py` invocations. +`configure` generates a `config.toml` which can also be used with normal `x.py` +invocations. ## Building Documentation -If you’d like to build the documentation, it’s almost the same: +If you'd like to build the documentation, it's almost the same: ```sh ./x.py doc ``` The generated documentation will appear under `doc` in the `build` directory for -the ABI used. I.e., if the ABI was `x86_64-pc-windows-msvc`, the directory will be -`build\x86_64-pc-windows-msvc\doc`. +the ABI used. That is, if the ABI was `x86_64-pc-windows-msvc`, the directory +will be `build\x86_64-pc-windows-msvc\doc`. ## Notes -Since the Rust compiler is written in Rust, it must be built by a -precompiled "snapshot" version of itself (made in an earlier stage of -development). As such, source builds require an Internet connection to -fetch snapshots, and an OS that can execute the available snapshot binaries. +Since the Rust compiler is written in Rust, it must be built by a precompiled +"snapshot" version of itself (made in an earlier stage of development). +As such, source builds require an Internet connection to fetch snapshots, and an +OS that can execute the available snapshot binaries. -See https://doc.rust-lang.org/nightly/rustc/platform-support.html for a list of supported platforms. -Only "host tools" platforms have a pre-compiled snapshot binary available; to compile for a platform -without host tools you must cross-compile. +See https://doc.rust-lang.org/nightly/rustc/platform-support.html for a list of +supported platforms. +Only "host tools" platforms have a pre-compiled snapshot binary available; to +compile for a platform without host tools you must cross-compile. -You may find that other platforms work, but these are our officially -supported build environments that are most likely to work. +You may find that other platforms work, but these are our officially supported +build environments that are most likely to work. ## Getting Help @@ -267,9 +283,9 @@ See [CONTRIBUTING.md](CONTRIBUTING.md). ## License -Rust is primarily distributed under the terms of both the MIT license -and the Apache License (Version 2.0), with portions covered by various -BSD-like licenses. +Rust is primarily distributed under the terms of both the MIT license and the +Apache License (Version 2.0), with portions covered by various BSD-like +licenses. See [LICENSE-APACHE](LICENSE-APACHE), [LICENSE-MIT](LICENSE-MIT), and [COPYRIGHT](COPYRIGHT) for details. @@ -277,13 +293,14 @@ See [LICENSE-APACHE](LICENSE-APACHE), [LICENSE-MIT](LICENSE-MIT), and ## Trademark [The Rust Foundation][rust-foundation] owns and protects the Rust and Cargo -trademarks and logos (the “Rust Trademarks”). +trademarks and logos (the "Rust Trademarks"). -If you want to use these names or brands, please read the [media guide][media-guide]. +If you want to use these names or brands, please read the +[media guide][media-guide]. Third-party logos may be subject to third-party copyrights and trademarks. See [Licenses][policies-licenses] for details. [rust-foundation]: https://foundation.rust-lang.org/ -[media-guide]: https://www.rust-lang.org/policies/media-guide +[media-guide]: https://foundation.rust-lang.org/policies/logo-policy-and-media-guide/ [policies-licenses]: https://www.rust-lang.org/policies/licenses From be9c363066088f0a560d181a19ee852e95da6c23 Mon Sep 17 00:00:00 2001 From: joboet Date: Tue, 17 Jan 2023 18:55:44 +0100 Subject: [PATCH 02/11] refactor[alloc]: remove unused box syntax feature --- library/alloc/tests/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/library/alloc/tests/lib.rs b/library/alloc/tests/lib.rs index d6d2b055b2395..2a93a242d5174 100644 --- a/library/alloc/tests/lib.rs +++ b/library/alloc/tests/lib.rs @@ -1,7 +1,6 @@ #![feature(allocator_api)] #![feature(alloc_layout_extra)] #![feature(assert_matches)] -#![feature(box_syntax)] #![feature(btree_drain_filter)] #![feature(cow_is_borrowed)] #![feature(const_box)] From 273c6c3913e4d32c3321a3c92fb2ce32c1db9cb8 Mon Sep 17 00:00:00 2001 From: Markus Everling Date: Tue, 17 Jan 2023 19:38:37 +0100 Subject: [PATCH 03/11] Add heapsort fallback in `select_nth_unstable` --- library/core/src/slice/sort.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/library/core/src/slice/sort.rs b/library/core/src/slice/sort.rs index 4d2fcd917849c..3ac01d1727513 100644 --- a/library/core/src/slice/sort.rs +++ b/library/core/src/slice/sort.rs @@ -831,6 +831,15 @@ fn partition_at_index_loop<'a, T, F>( ) where F: FnMut(&T, &T) -> bool, { + // Limit the amount of iterations and fall back to heapsort, similarly to `slice::sort_unstable`. + // This lowers the worst case running time from O(n^2) to O(n log n). + // FIXME: Investigate whether it would be better to use something like Median of Medians + // or Fast Deterministic Selection to guarantee O(n) worst case. + let mut limit = usize::BITS - v.len().leading_zeros(); + + // True if the last partitioning was reasonably balanced. + let mut was_balanced = true; + loop { // For slices of up to this length it's probably faster to simply sort them. const MAX_INSERTION: usize = 10; @@ -839,6 +848,18 @@ fn partition_at_index_loop<'a, T, F>( return; } + if limit == 0 { + heapsort(v, is_less); + return; + } + + // If the last partitioning was imbalanced, try breaking patterns in the slice by shuffling + // some elements around. Hopefully we'll choose a better pivot this time. + if !was_balanced { + break_patterns(v); + limit -= 1; + } + // Choose a pivot let (pivot, _) = choose_pivot(v, is_less); @@ -863,6 +884,7 @@ fn partition_at_index_loop<'a, T, F>( } let (mid, _) = partition(v, pivot, is_less); + was_balanced = cmp::min(mid, v.len() - mid) >= v.len() / 8; // Split the slice into `left`, `pivot`, and `right`. let (left, right) = v.split_at_mut(mid); From 54089e6390e4dd179f35438bd46099fb09854427 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Tue, 17 Jan 2023 11:49:36 -0700 Subject: [PATCH 04/11] rustdoc: instead of `.setting-name { width: 100% }`, use default div CSS --- src/librustdoc/html/static/css/settings.css | 4 ---- src/librustdoc/html/static/js/settings.js | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/librustdoc/html/static/css/settings.css b/src/librustdoc/html/static/css/settings.css index 91419093147d7..3fa478751737f 100644 --- a/src/librustdoc/html/static/css/settings.css +++ b/src/librustdoc/html/static/css/settings.css @@ -33,10 +33,6 @@ padding-bottom: 1px; } -.radio-line .setting-name { - width: 100%; -} - .radio-line .choice { margin-top: 0.1em; margin-bottom: 0.1em; diff --git a/src/librustdoc/html/static/js/settings.js b/src/librustdoc/html/static/js/settings.js index 9ed8f63610ff6..84df1b7d3911a 100644 --- a/src/librustdoc/html/static/js/settings.js +++ b/src/librustdoc/html/static/js/settings.js @@ -135,7 +135,7 @@ // This is a select setting. output += `\
- ${setting_name} +
${setting_name}
`; onEach(setting["options"], option => { const checked = option === setting["default"] ? " checked" : ""; From 1216cc7f1c7762bd82afeeb6ec22121f57980e80 Mon Sep 17 00:00:00 2001 From: Lukas Markeffsky <@> Date: Tue, 17 Jan 2023 19:35:19 +0100 Subject: [PATCH 05/11] bump failing assembly & codegen tests from LLVM 14 to LLVM 15 --- tests/assembly/is_aligned.rs | 2 +- tests/codegen/issue-96497-slice-size-nowrap.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/assembly/is_aligned.rs b/tests/assembly/is_aligned.rs index 04b5de8342370..620a3da94636e 100644 --- a/tests/assembly/is_aligned.rs +++ b/tests/assembly/is_aligned.rs @@ -1,5 +1,5 @@ // assembly-output: emit-asm -// min-llvm-version: 14.0 +// min-llvm-version: 15.0 // only-x86_64 // revisions: opt-speed opt-size // [opt-speed] compile-flags: -Copt-level=1 diff --git a/tests/codegen/issue-96497-slice-size-nowrap.rs b/tests/codegen/issue-96497-slice-size-nowrap.rs index a5dbef9346027..0413ed6b26f36 100644 --- a/tests/codegen/issue-96497-slice-size-nowrap.rs +++ b/tests/codegen/issue-96497-slice-size-nowrap.rs @@ -3,7 +3,7 @@ // in some situations, see https://github.com/rust-lang/rust/issues/96497#issuecomment-1112865218 // compile-flags: -O -// min-llvm-version: 14.0 +// min-llvm-version: 15.0 #![crate_type="lib"] From a242a2c6ade769b4986dff36c8d62cb22db59f75 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Tue, 17 Jan 2023 12:09:38 -0700 Subject: [PATCH 06/11] rustdoc: add test cases for settings radio button layout --- tests/rustdoc-gui/settings.goml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/rustdoc-gui/settings.goml b/tests/rustdoc-gui/settings.goml index f236dc3e0fe76..72de41e41bae1 100644 --- a/tests/rustdoc-gui/settings.goml +++ b/tests/rustdoc-gui/settings.goml @@ -105,6 +105,33 @@ assert-css: ( "box-shadow": "rgb(33, 150, 243) 0px 0px 1px 1px", }, ) +// Now we check the setting-name for radio buttons is on a different line than the label. +compare-elements-position-near: ( + "#theme .setting-name", + "#theme .choices", + {"x": 1} +) +compare-elements-position-near-false: ( + "#theme .setting-name", + "#theme .choices", + {"y": 1} +) +// Now we check that the label positions are all on the same line. +compare-elements-position-near: ( + "#theme .choices #theme-light", + "#theme .choices #theme-dark", + {"y": 1} +) +compare-elements-position-near: ( + "#theme .choices #theme-dark", + "#theme .choices #theme-ayu", + {"y": 1} +) +compare-elements-position-near: ( + "#theme .choices #theme-ayu", + "#theme .choices #theme-system-preference", + {"y": 1} +) // First we check the "default" display for toggles. assert-css: ( From aadd58ef7a78c3eabc75c73db6b166debdd7f1d2 Mon Sep 17 00:00:00 2001 From: yanchen4791 Date: Wed, 11 Jan 2023 00:19:40 -0800 Subject: [PATCH 07/11] Add 'static lifetime suggestion when GAT implied 'static requirement from HRTB --- .../src/diagnostics/region_errors.rs | 117 +++++++++++++++++- .../rustc_borrowck/src/region_infer/mod.rs | 8 ++ compiler/rustc_middle/src/ty/sty.rs | 7 ++ .../collectivity-regression.stderr | 10 ++ tests/ui/lifetimes/issue-105507.fixed | 43 +++++++ tests/ui/lifetimes/issue-105507.rs | 43 +++++++ tests/ui/lifetimes/issue-105507.stderr | 34 +++++ 7 files changed, 258 insertions(+), 4 deletions(-) create mode 100644 tests/ui/lifetimes/issue-105507.fixed create mode 100644 tests/ui/lifetimes/issue-105507.rs create mode 100644 tests/ui/lifetimes/issue-105507.stderr diff --git a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs index f3050a6ef3f07..187861ba127bd 100644 --- a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs @@ -5,8 +5,13 @@ use rustc_data_structures::fx::FxIndexSet; use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed, MultiSpan}; use rustc_hir as hir; +use rustc_hir::def::Res::Def; use rustc_hir::def_id::DefId; use rustc_hir::intravisit::Visitor; +use rustc_hir::GenericBound::Trait; +use rustc_hir::QPath::Resolved; +use rustc_hir::WherePredicate::BoundPredicate; +use rustc_hir::{PolyTraitRef, TyKind, WhereBoundPredicate}; use rustc_infer::infer::{ error_reporting::nice_region_error::{ self, find_anon_type, find_param_with_region, suggest_adding_lifetime_params, @@ -186,6 +191,101 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { false } + // For generic associated types (GATs) which implied 'static requirement + // from higher-ranked trait bounds (HRTB). Try to locate span of the trait + // and the span which bounded to the trait for adding 'static lifetime suggestion + fn suggest_static_lifetime_for_gat_from_hrtb( + &self, + diag: &mut DiagnosticBuilder<'_, ErrorGuaranteed>, + lower_bound: RegionVid, + ) { + let mut suggestions = vec![]; + let hir = self.infcx.tcx.hir(); + + // find generic associated types in the given region 'lower_bound' + let gat_id_and_generics = self + .regioncx + .placeholders_contained_in(lower_bound) + .map(|placeholder| { + if let Some(id) = placeholder.name.get_id() + && let Some(placeholder_id) = id.as_local() + && let gat_hir_id = hir.local_def_id_to_hir_id(placeholder_id) + && let Some(generics_impl) = hir.get_parent(gat_hir_id).generics() + { + Some((gat_hir_id, generics_impl)) + } else { + None + } + }) + .collect::>(); + debug!(?gat_id_and_generics); + + // find higher-ranked trait bounds bounded to the generic associated types + let mut hrtb_bounds = vec![]; + gat_id_and_generics.iter().flatten().for_each(|(gat_hir_id, generics)| { + for pred in generics.predicates { + let BoundPredicate( + WhereBoundPredicate { + bound_generic_params, + bounds, + .. + }) = pred else { continue; }; + if bound_generic_params + .iter() + .rfind(|bgp| hir.local_def_id_to_hir_id(bgp.def_id) == *gat_hir_id) + .is_some() + { + for bound in *bounds { + hrtb_bounds.push(bound); + } + } + } + }); + debug!(?hrtb_bounds); + + hrtb_bounds.iter().for_each(|bound| { + let Trait(PolyTraitRef { trait_ref, span: trait_span, .. }, _) = bound else { return; }; + diag.span_note( + *trait_span, + format!("due to current limitations in the borrow checker, this implies a `'static` lifetime") + ); + let Some(generics_fn) = hir.get_generics(self.body.source.def_id().expect_local()) else { return; }; + let Def(_, trait_res_defid) = trait_ref.path.res else { return; }; + debug!(?generics_fn); + generics_fn.predicates.iter().for_each(|predicate| { + let BoundPredicate( + WhereBoundPredicate { + span: bounded_span, + bounded_ty, + bounds, + .. + } + ) = predicate else { return; }; + bounds.iter().for_each(|bd| { + if let Trait(PolyTraitRef { trait_ref: tr_ref, .. }, _) = bd + && let Def(_, res_defid) = tr_ref.path.res + && res_defid == trait_res_defid // trait id matches + && let TyKind::Path(Resolved(_, path)) = bounded_ty.kind + && let Def(_, defid) = path.res + && generics_fn.params + .iter() + .rfind(|param| param.def_id.to_def_id() == defid) + .is_some() { + suggestions.push((bounded_span.shrink_to_hi(), format!(" + 'static"))); + } + }); + }); + }); + if suggestions.len() > 0 { + suggestions.dedup(); + diag.multipart_suggestion_verbose( + format!("consider restricting the type parameter to the `'static` lifetime"), + suggestions, + Applicability::MaybeIncorrect, + ); + } + } + /// Produces nice borrowck error diagnostics for all the errors collected in `nll_errors`. pub(crate) fn report_region_errors(&mut self, nll_errors: RegionErrors<'tcx>) { // Iterate through all the errors, producing a diagnostic for each one. The diagnostics are @@ -223,12 +323,21 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { // to report it; we could probably handle it by // iterating over the universal regions and reporting // an error that multiple bounds are required. - self.buffer_error(self.infcx.tcx.sess.create_err( - GenericDoesNotLiveLongEnough { + let mut diag = + self.infcx.tcx.sess.create_err(GenericDoesNotLiveLongEnough { kind: type_test.generic_kind.to_string(), span: type_test_span, - }, - )); + }); + + // Add notes and suggestions for the case of 'static lifetime + // implied but not specified when a generic associated types + // are from higher-ranked trait bounds + self.suggest_static_lifetime_for_gat_from_hrtb( + &mut diag, + type_test.lower_bound, + ); + + self.buffer_error(diag); } } diff --git a/compiler/rustc_borrowck/src/region_infer/mod.rs b/compiler/rustc_borrowck/src/region_infer/mod.rs index 308f6e19a73e8..7eae52bca5896 100644 --- a/compiler/rustc_borrowck/src/region_infer/mod.rs +++ b/compiler/rustc_borrowck/src/region_infer/mod.rs @@ -527,6 +527,14 @@ impl<'tcx> RegionInferenceContext<'tcx> { self.scc_values.region_value_str(scc) } + pub(crate) fn placeholders_contained_in<'a>( + &'a self, + r: RegionVid, + ) -> impl Iterator + 'a { + let scc = self.constraint_sccs.scc(r.to_region_vid()); + self.scc_values.placeholders_contained_in(scc) + } + /// Returns access to the value of `r` for debugging purposes. pub(crate) fn region_universe(&self, r: RegionVid) -> ty::UniverseIndex { let scc = self.constraint_sccs.scc(r.to_region_vid()); diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index e49e7e86da085..ce2f03679e042 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -100,6 +100,13 @@ impl BoundRegionKind { None } + + pub fn get_id(&self) -> Option { + match *self { + BoundRegionKind::BrNamed(id, _) => return Some(id), + _ => None, + } + } } pub trait Article { diff --git a/tests/ui/generic-associated-types/collectivity-regression.stderr b/tests/ui/generic-associated-types/collectivity-regression.stderr index 1dbe1e2cb2245..a085096e1f8c5 100644 --- a/tests/ui/generic-associated-types/collectivity-regression.stderr +++ b/tests/ui/generic-associated-types/collectivity-regression.stderr @@ -9,6 +9,16 @@ LL | | // probably should work. LL | | let _x = x; LL | | }; | |_____^ + | +note: due to current limitations in the borrow checker, this implies a `'static` lifetime + --> $DIR/collectivity-regression.rs:11:16 + | +LL | for<'a> T: Get = ()>, + | ^^^^^^^^^^^^^^^^^^^ +help: consider restricting the type parameter to the `'static` lifetime + | +LL | for<'a> T: Get = ()> + 'static, + | +++++++++ error: aborting due to previous error diff --git a/tests/ui/lifetimes/issue-105507.fixed b/tests/ui/lifetimes/issue-105507.fixed new file mode 100644 index 0000000000000..277ce8a77e974 --- /dev/null +++ b/tests/ui/lifetimes/issue-105507.fixed @@ -0,0 +1,43 @@ +// run-rustfix +// +#![allow(warnings)] +struct Wrapper<'a, T: ?Sized>(&'a T); + +trait Project { + type Projected<'a> where Self: 'a; + fn project(this: Wrapper<'_, Self>) -> Self::Projected<'_>; +} +trait MyTrait {} +trait ProjectedMyTrait {} + +impl Project for Option { + type Projected<'a> = Option> where T: 'a; + fn project(this: Wrapper<'_, Self>) -> Self::Projected<'_> { + this.0.as_ref().map(Wrapper) + } +} + +impl MyTrait for Option> {} + +impl MyTrait for Wrapper<'_, T> {} + +impl ProjectedMyTrait for T + where + T: Project, + for<'a> T::Projected<'a>: MyTrait, + //~^ NOTE due to current limitations in the borrow checker, this implies a `'static` lifetime + //~| NOTE due to current limitations in the borrow checker, this implies a `'static` lifetime +{} + +fn require_trait(_: T) {} + +fn foo(wrap: Wrapper<'_, Option>, wrap1: Wrapper<'_, Option>) { + //~^ HELP consider restricting the type parameter to the `'static` lifetime + //~| HELP consider restricting the type parameter to the `'static` lifetime + require_trait(wrap); + //~^ ERROR `T` does not live long enough + require_trait(wrap1); + //~^ ERROR `U` does not live long enough +} + +fn main() {} diff --git a/tests/ui/lifetimes/issue-105507.rs b/tests/ui/lifetimes/issue-105507.rs new file mode 100644 index 0000000000000..f46c6b6f21e86 --- /dev/null +++ b/tests/ui/lifetimes/issue-105507.rs @@ -0,0 +1,43 @@ +// run-rustfix +// +#![allow(warnings)] +struct Wrapper<'a, T: ?Sized>(&'a T); + +trait Project { + type Projected<'a> where Self: 'a; + fn project(this: Wrapper<'_, Self>) -> Self::Projected<'_>; +} +trait MyTrait {} +trait ProjectedMyTrait {} + +impl Project for Option { + type Projected<'a> = Option> where T: 'a; + fn project(this: Wrapper<'_, Self>) -> Self::Projected<'_> { + this.0.as_ref().map(Wrapper) + } +} + +impl MyTrait for Option> {} + +impl MyTrait for Wrapper<'_, T> {} + +impl ProjectedMyTrait for T + where + T: Project, + for<'a> T::Projected<'a>: MyTrait, + //~^ NOTE due to current limitations in the borrow checker, this implies a `'static` lifetime + //~| NOTE due to current limitations in the borrow checker, this implies a `'static` lifetime +{} + +fn require_trait(_: T) {} + +fn foo(wrap: Wrapper<'_, Option>, wrap1: Wrapper<'_, Option>) { + //~^ HELP consider restricting the type parameter to the `'static` lifetime + //~| HELP consider restricting the type parameter to the `'static` lifetime + require_trait(wrap); + //~^ ERROR `T` does not live long enough + require_trait(wrap1); + //~^ ERROR `U` does not live long enough +} + +fn main() {} diff --git a/tests/ui/lifetimes/issue-105507.stderr b/tests/ui/lifetimes/issue-105507.stderr new file mode 100644 index 0000000000000..44d3a7eb9a420 --- /dev/null +++ b/tests/ui/lifetimes/issue-105507.stderr @@ -0,0 +1,34 @@ +error: `T` does not live long enough + --> $DIR/issue-105507.rs:37:5 + | +LL | require_trait(wrap); + | ^^^^^^^^^^^^^^^^^^^ + | +note: due to current limitations in the borrow checker, this implies a `'static` lifetime + --> $DIR/issue-105507.rs:27:35 + | +LL | for<'a> T::Projected<'a>: MyTrait, + | ^^^^^^^ +help: consider restricting the type parameter to the `'static` lifetime + | +LL | fn foo(wrap: Wrapper<'_, Option>, wrap1: Wrapper<'_, Option>) { + | +++++++++ +++++++++ + +error: `U` does not live long enough + --> $DIR/issue-105507.rs:39:5 + | +LL | require_trait(wrap1); + | ^^^^^^^^^^^^^^^^^^^^ + | +note: due to current limitations in the borrow checker, this implies a `'static` lifetime + --> $DIR/issue-105507.rs:27:35 + | +LL | for<'a> T::Projected<'a>: MyTrait, + | ^^^^^^^ +help: consider restricting the type parameter to the `'static` lifetime + | +LL | fn foo(wrap: Wrapper<'_, Option>, wrap1: Wrapper<'_, Option>) { + | +++++++++ +++++++++ + +error: aborting due to 2 previous errors + From 4ca5368a122e06e33fd8fb5f3e2c4b63492273f1 Mon Sep 17 00:00:00 2001 From: Boxy Date: Sat, 14 Jan 2023 18:32:17 +0000 Subject: [PATCH 08/11] defer array len printing to const arg printing --- compiler/rustc_middle/src/ty/print/pretty.rs | 24 ++++--------------- ...ram-type-depends-on-const-param.min.stderr | 4 ++-- ...const-param-type-depends-on-const-param.rs | 4 ++-- .../dont-evaluate-array-len-on-err-1.stderr | 4 ++-- .../issue-62504.min.stderr | 2 +- ...-default_trait_method_normalization.stderr | 6 ++--- .../issues/issue-62878.min.stderr | 2 +- tests/ui/const-generics/issues/issue-62878.rs | 2 +- .../issues/issue-71169.min.stderr | 2 +- tests/ui/const-generics/issues/issue-71169.rs | 2 +- .../issues/issue-73491.min.stderr | 2 +- tests/ui/const-generics/issues/issue-73491.rs | 2 +- .../issues/issue-74101.min.stderr | 4 ++-- tests/ui/const-generics/issues/issue-74101.rs | 4 ++-- .../issues/issue-75047.min.stderr | 2 +- tests/ui/const-generics/issues/issue-75047.rs | 2 +- .../ui/const-generics/nested-type.min.stderr | 12 +++++++++- tests/ui/consts/const-size_of-cycle.stderr | 4 ++-- tests/ui/consts/issue-44415.stderr | 4 ++-- tests/ui/consts/too_generic_eval_ice.rs | 2 +- tests/ui/consts/too_generic_eval_ice.stderr | 6 ++--- ...uginfo-type-name-layout-ice-94961-1.stderr | 2 +- ...uginfo-type-name-layout-ice-94961-2.stderr | 2 +- tests/ui/inference/issue-83606.rs | 2 +- tests/ui/inference/issue-83606.stderr | 4 ++-- tests/ui/limits/issue-15919-64.stderr | 2 +- tests/ui/limits/issue-55878.stderr | 4 ++-- ...ssue-69485-var-size-diffs-too-large.stderr | 2 +- tests/ui/limits/issue-75158-64.stderr | 2 +- tests/ui/symbol-names/impl2.rs | 7 +++--- tests/ui/symbol-names/impl2.stderr | 2 +- 31 files changed, 59 insertions(+), 66 deletions(-) diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index 42fc78a4715f4..eba3016aca82c 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -854,24 +854,7 @@ pub trait PrettyPrinter<'tcx>: } p!("]"); } - ty::Array(ty, sz) => { - p!("[", print(ty), "; "); - if self.should_print_verbose() { - p!(write("{:?}", sz)); - } else if let ty::ConstKind::Unevaluated(..) = sz.kind() { - // Do not try to evaluate unevaluated constants. If we are const evaluating an - // array length anon const, rustc will (with debug assertions) print the - // constant's path. Which will end up here again. - p!("_"); - } else if let Some(n) = sz.kind().try_to_bits(self.tcx().data_layout.pointer_size) { - p!(write("{}", n)); - } else if let ty::ConstKind::Param(param) = sz.kind() { - p!(print(param)); - } else { - p!("_"); - } - p!("]") - } + ty::Array(ty, sz) => p!("[", print(ty), "; ", print(sz), "]"), ty::Slice(ty) => p!("[", print(ty), "]"), } @@ -1303,10 +1286,10 @@ pub trait PrettyPrinter<'tcx>: match ct.kind() { ty::ConstKind::Unevaluated(ty::UnevaluatedConst { def, substs }) => { match self.tcx().def_kind(def.did) { - DefKind::Static(..) | DefKind::Const | DefKind::AssocConst => { + DefKind::Const | DefKind::AssocConst => { p!(print_value_path(def.did, substs)) } - _ => { + DefKind::AnonConst => { if def.is_local() { let span = self.tcx().def_span(def.did); if let Ok(snip) = self.tcx().sess.source_map().span_to_snippet(span) { @@ -1318,6 +1301,7 @@ pub trait PrettyPrinter<'tcx>: print_underscore!() } } + defkind => bug!("`{:?}` has unexpcted defkind {:?}", ct, defkind), } } ty::ConstKind::Infer(infer_ct) => { diff --git a/tests/ui/const-generics/const-param-type-depends-on-const-param.min.stderr b/tests/ui/const-generics/const-param-type-depends-on-const-param.min.stderr index a7b78b80ca5ea..24aa405211f4c 100644 --- a/tests/ui/const-generics/const-param-type-depends-on-const-param.min.stderr +++ b/tests/ui/const-generics/const-param-type-depends-on-const-param.min.stderr @@ -10,7 +10,7 @@ error[E0770]: the type of const parameters must not depend on other generic para LL | pub struct SelfDependent; | ^ the type must not depend on the parameter `N` -error: `[u8; _]` is forbidden as the type of a const generic parameter +error: `[u8; N]` is forbidden as the type of a const generic parameter --> $DIR/const-param-type-depends-on-const-param.rs:11:47 | LL | pub struct Dependent([(); N]); @@ -19,7 +19,7 @@ LL | pub struct Dependent([(); N]); = note: the only supported types are integers, `bool` and `char` = help: more complex types are supported with `#![feature(adt_const_params)]` -error: `[u8; _]` is forbidden as the type of a const generic parameter +error: `[u8; N]` is forbidden as the type of a const generic parameter --> $DIR/const-param-type-depends-on-const-param.rs:15:35 | LL | pub struct SelfDependent; diff --git a/tests/ui/const-generics/const-param-type-depends-on-const-param.rs b/tests/ui/const-generics/const-param-type-depends-on-const-param.rs index 9d50f9a47ff6e..64b2acb036292 100644 --- a/tests/ui/const-generics/const-param-type-depends-on-const-param.rs +++ b/tests/ui/const-generics/const-param-type-depends-on-const-param.rs @@ -10,10 +10,10 @@ pub struct Dependent([(); N]); //~^ ERROR: the type of const parameters must not depend on other generic parameters -//[min]~^^ ERROR `[u8; _]` is forbidden +//[min]~^^ ERROR `[u8; N]` is forbidden pub struct SelfDependent; //~^ ERROR: the type of const parameters must not depend on other generic parameters -//[min]~^^ ERROR `[u8; _]` is forbidden +//[min]~^^ ERROR `[u8; N]` is forbidden fn main() {} diff --git a/tests/ui/const-generics/dont-evaluate-array-len-on-err-1.stderr b/tests/ui/const-generics/dont-evaluate-array-len-on-err-1.stderr index 68ce61bd4a374..d8eebeb0d2115 100644 --- a/tests/ui/const-generics/dont-evaluate-array-len-on-err-1.stderr +++ b/tests/ui/const-generics/dont-evaluate-array-len-on-err-1.stderr @@ -1,8 +1,8 @@ -error[E0277]: the trait bound `[Adt; _]: Foo` is not satisfied +error[E0277]: the trait bound `[Adt; std::mem::size_of::()]: Foo` is not satisfied --> $DIR/dont-evaluate-array-len-on-err-1.rs:15:9 | LL | <[Adt; std::mem::size_of::()] as Foo>::bar() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `[Adt; _]` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `[Adt; std::mem::size_of::()]` error: aborting due to previous error diff --git a/tests/ui/const-generics/generic_const_exprs/issue-62504.min.stderr b/tests/ui/const-generics/generic_const_exprs/issue-62504.min.stderr index 9bea4105d58b0..65822856e1d7c 100644 --- a/tests/ui/const-generics/generic_const_exprs/issue-62504.min.stderr +++ b/tests/ui/const-generics/generic_const_exprs/issue-62504.min.stderr @@ -15,7 +15,7 @@ LL | ArrayHolder([0; Self::SIZE]) | arguments to this struct are incorrect | = note: expected array `[u32; X]` - found array `[u32; _]` + found array `[u32; Self::SIZE]` note: tuple struct defined here --> $DIR/issue-62504.rs:14:8 | diff --git a/tests/ui/const-generics/generic_const_exprs/issue-79518-default_trait_method_normalization.stderr b/tests/ui/const-generics/generic_const_exprs/issue-79518-default_trait_method_normalization.stderr index 029528c3a8172..9baf9790e19b3 100644 --- a/tests/ui/const-generics/generic_const_exprs/issue-79518-default_trait_method_normalization.stderr +++ b/tests/ui/const-generics/generic_const_exprs/issue-79518-default_trait_method_normalization.stderr @@ -2,13 +2,13 @@ error[E0308]: mismatched types --> $DIR/issue-79518-default_trait_method_normalization.rs:16:32 | LL | Self::AssocInstance == [(); std::mem::size_of::()]; - | ------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected associated type, found array `[(); _]` + | ------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected associated type, found array `[(); std::mem::size_of::()]` | | | expected because this is `::Assoc` | = note: expected associated type `::Assoc` - found array `[(); _]` - = help: consider constraining the associated type `::Assoc` to `[(); _]` or calling a method that returns `::Assoc` + found array `[(); std::mem::size_of::()]` + = help: consider constraining the associated type `::Assoc` to `[(); std::mem::size_of::()]` or calling a method that returns `::Assoc` = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html error: aborting due to previous error diff --git a/tests/ui/const-generics/issues/issue-62878.min.stderr b/tests/ui/const-generics/issues/issue-62878.min.stderr index af029a6516bc6..5a721720d78b5 100644 --- a/tests/ui/const-generics/issues/issue-62878.min.stderr +++ b/tests/ui/const-generics/issues/issue-62878.min.stderr @@ -4,7 +4,7 @@ error[E0770]: the type of const parameters must not depend on other generic para LL | fn foo() {} | ^ the type must not depend on the parameter `N` -error: `[u8; _]` is forbidden as the type of a const generic parameter +error: `[u8; N]` is forbidden as the type of a const generic parameter --> $DIR/issue-62878.rs:5:33 | LL | fn foo() {} diff --git a/tests/ui/const-generics/issues/issue-62878.rs b/tests/ui/const-generics/issues/issue-62878.rs index 578ce765b2fb8..4c08a484ef47b 100644 --- a/tests/ui/const-generics/issues/issue-62878.rs +++ b/tests/ui/const-generics/issues/issue-62878.rs @@ -4,7 +4,7 @@ fn foo() {} //~^ ERROR the type of const parameters must not -//[min]~| ERROR `[u8; _]` is forbidden as the type of a const generic parameter +//[min]~| ERROR `[u8; N]` is forbidden as the type of a const generic parameter fn main() { foo::<_, { [1] }>(); diff --git a/tests/ui/const-generics/issues/issue-71169.min.stderr b/tests/ui/const-generics/issues/issue-71169.min.stderr index 87ed2d4f8da8c..998b16a79e638 100644 --- a/tests/ui/const-generics/issues/issue-71169.min.stderr +++ b/tests/ui/const-generics/issues/issue-71169.min.stderr @@ -4,7 +4,7 @@ error[E0770]: the type of const parameters must not depend on other generic para LL | fn foo() {} | ^^^ the type must not depend on the parameter `LEN` -error: `[u8; _]` is forbidden as the type of a const generic parameter +error: `[u8; LEN]` is forbidden as the type of a const generic parameter --> $DIR/issue-71169.rs:5:38 | LL | fn foo() {} diff --git a/tests/ui/const-generics/issues/issue-71169.rs b/tests/ui/const-generics/issues/issue-71169.rs index 617149a841893..e4ec6b0737613 100644 --- a/tests/ui/const-generics/issues/issue-71169.rs +++ b/tests/ui/const-generics/issues/issue-71169.rs @@ -4,7 +4,7 @@ fn foo() {} //~^ ERROR the type of const parameters must not -//[min]~^^ ERROR `[u8; _]` is forbidden as the type of a const generic parameter +//[min]~^^ ERROR `[u8; LEN]` is forbidden as the type of a const generic parameter fn main() { const DATA: [u8; 4] = *b"ABCD"; foo::<4, DATA>(); diff --git a/tests/ui/const-generics/issues/issue-73491.min.stderr b/tests/ui/const-generics/issues/issue-73491.min.stderr index f2b58e59f731f..f03354fc472c0 100644 --- a/tests/ui/const-generics/issues/issue-73491.min.stderr +++ b/tests/ui/const-generics/issues/issue-73491.min.stderr @@ -1,4 +1,4 @@ -error: `[u32; _]` is forbidden as the type of a const generic parameter +error: `[u32; LEN]` is forbidden as the type of a const generic parameter --> $DIR/issue-73491.rs:8:19 | LL | fn hoge() {} diff --git a/tests/ui/const-generics/issues/issue-73491.rs b/tests/ui/const-generics/issues/issue-73491.rs index f15c1f2d45521..482dbb04daae9 100644 --- a/tests/ui/const-generics/issues/issue-73491.rs +++ b/tests/ui/const-generics/issues/issue-73491.rs @@ -6,6 +6,6 @@ const LEN: usize = 1024; fn hoge() {} -//[min]~^ ERROR `[u32; _]` is forbidden as the type of a const generic parameter +//[min]~^ ERROR `[u32; LEN]` is forbidden as the type of a const generic parameter fn main() {} diff --git a/tests/ui/const-generics/issues/issue-74101.min.stderr b/tests/ui/const-generics/issues/issue-74101.min.stderr index 82ffb23324044..134c248347d3c 100644 --- a/tests/ui/const-generics/issues/issue-74101.min.stderr +++ b/tests/ui/const-generics/issues/issue-74101.min.stderr @@ -1,4 +1,4 @@ -error: `[u8; _]` is forbidden as the type of a const generic parameter +error: `[u8; 1 + 2]` is forbidden as the type of a const generic parameter --> $DIR/issue-74101.rs:6:18 | LL | fn test() {} @@ -7,7 +7,7 @@ LL | fn test() {} = note: the only supported types are integers, `bool` and `char` = help: more complex types are supported with `#![feature(adt_const_params)]` -error: `[u8; _]` is forbidden as the type of a const generic parameter +error: `[u8; 1 + 2]` is forbidden as the type of a const generic parameter --> $DIR/issue-74101.rs:9:21 | LL | struct Foo; diff --git a/tests/ui/const-generics/issues/issue-74101.rs b/tests/ui/const-generics/issues/issue-74101.rs index 6b606b9460fe2..4c9b2d3c634da 100644 --- a/tests/ui/const-generics/issues/issue-74101.rs +++ b/tests/ui/const-generics/issues/issue-74101.rs @@ -4,9 +4,9 @@ #![cfg_attr(full, allow(incomplete_features))] fn test() {} -//[min]~^ ERROR `[u8; _]` is forbidden as the type of a const generic parameter +//[min]~^ ERROR `[u8; 1 + 2]` is forbidden as the type of a const generic parameter struct Foo; -//[min]~^ ERROR `[u8; _]` is forbidden as the type of a const generic parameter +//[min]~^ ERROR `[u8; 1 + 2]` is forbidden as the type of a const generic parameter fn main() {} diff --git a/tests/ui/const-generics/issues/issue-75047.min.stderr b/tests/ui/const-generics/issues/issue-75047.min.stderr index 7798ae7962983..46af19ef39540 100644 --- a/tests/ui/const-generics/issues/issue-75047.min.stderr +++ b/tests/ui/const-generics/issues/issue-75047.min.stderr @@ -1,4 +1,4 @@ -error: `[u8; _]` is forbidden as the type of a const generic parameter +error: `[u8; Bar::::value()]` is forbidden as the type of a const generic parameter --> $DIR/issue-75047.rs:14:21 | LL | struct Foo::value()]>; diff --git a/tests/ui/const-generics/issues/issue-75047.rs b/tests/ui/const-generics/issues/issue-75047.rs index ee3dcf9ecec50..7b6fb92bca96e 100644 --- a/tests/ui/const-generics/issues/issue-75047.rs +++ b/tests/ui/const-generics/issues/issue-75047.rs @@ -12,6 +12,6 @@ impl Bar { } struct Foo::value()]>; -//[min]~^ ERROR `[u8; _]` is forbidden as the type of a const generic parameter +//[min]~^ ERROR `[u8; Bar::::value()]` is forbidden as the type of a const generic parameter fn main() {} diff --git a/tests/ui/const-generics/nested-type.min.stderr b/tests/ui/const-generics/nested-type.min.stderr index 276ebf31ff8b8..cff02b0d445c8 100644 --- a/tests/ui/const-generics/nested-type.min.stderr +++ b/tests/ui/const-generics/nested-type.min.stderr @@ -1,4 +1,14 @@ -error: `[u8; _]` is forbidden as the type of a const generic parameter +error: `[u8; { + struct Foo; + + impl Foo { + fn value() -> usize { + N + } + } + + Foo::<17>::value() + }]` is forbidden as the type of a const generic parameter --> $DIR/nested-type.rs:6:21 | LL | struct Foo()] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: ...which requires computing layout of `Foo`... - = note: ...which requires computing layout of `[u8; _]`... - = note: ...which requires normalizing `[u8; _]`... + = note: ...which requires computing layout of `[u8; std::mem::size_of::()]`... + = note: ...which requires normalizing `[u8; std::mem::size_of::()]`... = note: ...which again requires evaluating type-level constant, completing the cycle note: cycle used when checking that `Foo` is well-formed --> $DIR/const-size_of-cycle.rs:3:1 diff --git a/tests/ui/consts/issue-44415.stderr b/tests/ui/consts/issue-44415.stderr index 57f94f8c6ab52..ec64b956dfe2b 100644 --- a/tests/ui/consts/issue-44415.stderr +++ b/tests/ui/consts/issue-44415.stderr @@ -15,8 +15,8 @@ note: ...which requires const-evaluating + checking `Foo::bytes::{constant#0}`.. LL | bytes: [u8; unsafe { intrinsics::size_of::() }], | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: ...which requires computing layout of `Foo`... - = note: ...which requires computing layout of `[u8; _]`... - = note: ...which requires normalizing `[u8; _]`... + = note: ...which requires computing layout of `[u8; unsafe { intrinsics::size_of::() }]`... + = note: ...which requires normalizing `[u8; unsafe { intrinsics::size_of::() }]`... = note: ...which again requires evaluating type-level constant, completing the cycle note: cycle used when checking that `Foo` is well-formed --> $DIR/issue-44415.rs:5:1 diff --git a/tests/ui/consts/too_generic_eval_ice.rs b/tests/ui/consts/too_generic_eval_ice.rs index af494e3734914..8b3f4b714e1bd 100644 --- a/tests/ui/consts/too_generic_eval_ice.rs +++ b/tests/ui/consts/too_generic_eval_ice.rs @@ -7,7 +7,7 @@ impl Foo { [5; Self::HOST_SIZE] == [6; 0] //~^ ERROR constant expression depends on a generic parameter //~| ERROR constant expression depends on a generic parameter - //~| ERROR can't compare `[{integer}; _]` with `[{integer}; 0]` + //~| ERROR can't compare `[{integer}; Self::HOST_SIZE]` with `[{integer}; 0]` } } diff --git a/tests/ui/consts/too_generic_eval_ice.stderr b/tests/ui/consts/too_generic_eval_ice.stderr index 8de61fcfb7330..5af82a3e34bf5 100644 --- a/tests/ui/consts/too_generic_eval_ice.stderr +++ b/tests/ui/consts/too_generic_eval_ice.stderr @@ -14,13 +14,13 @@ LL | [5; Self::HOST_SIZE] == [6; 0] | = note: this may fail depending on what value the parameter takes -error[E0277]: can't compare `[{integer}; _]` with `[{integer}; 0]` +error[E0277]: can't compare `[{integer}; Self::HOST_SIZE]` with `[{integer}; 0]` --> $DIR/too_generic_eval_ice.rs:7:30 | LL | [5; Self::HOST_SIZE] == [6; 0] - | ^^ no implementation for `[{integer}; _] == [{integer}; 0]` + | ^^ no implementation for `[{integer}; Self::HOST_SIZE] == [{integer}; 0]` | - = help: the trait `PartialEq<[{integer}; 0]>` is not implemented for `[{integer}; _]` + = help: the trait `PartialEq<[{integer}; 0]>` is not implemented for `[{integer}; Self::HOST_SIZE]` = help: the following other types implement trait `PartialEq`: <&[B] as PartialEq<[A; N]>> <&[T] as PartialEq>> diff --git a/tests/ui/debuginfo/debuginfo-type-name-layout-ice-94961-1.stderr b/tests/ui/debuginfo/debuginfo-type-name-layout-ice-94961-1.stderr index 851dca84c3dc0..d5991bcf5693d 100644 --- a/tests/ui/debuginfo/debuginfo-type-name-layout-ice-94961-1.stderr +++ b/tests/ui/debuginfo/debuginfo-type-name-layout-ice-94961-1.stderr @@ -1,4 +1,4 @@ -error: values of the type `[u8; SIZE]` are too big for the current architecture +error: values of the type `[u8; usize::MAX]` are too big for the current architecture error: aborting due to previous error diff --git a/tests/ui/debuginfo/debuginfo-type-name-layout-ice-94961-2.stderr b/tests/ui/debuginfo/debuginfo-type-name-layout-ice-94961-2.stderr index 851dca84c3dc0..d5991bcf5693d 100644 --- a/tests/ui/debuginfo/debuginfo-type-name-layout-ice-94961-2.stderr +++ b/tests/ui/debuginfo/debuginfo-type-name-layout-ice-94961-2.stderr @@ -1,4 +1,4 @@ -error: values of the type `[u8; SIZE]` are too big for the current architecture +error: values of the type `[u8; usize::MAX]` are too big for the current architecture error: aborting due to previous error diff --git a/tests/ui/inference/issue-83606.rs b/tests/ui/inference/issue-83606.rs index eaaef3463ddc9..c387046e91008 100644 --- a/tests/ui/inference/issue-83606.rs +++ b/tests/ui/inference/issue-83606.rs @@ -6,5 +6,5 @@ fn foo(_: impl std::fmt::Display) -> [usize; N] { fn main() { let _ = foo("foo"); - //~^ ERROR: type annotations needed for `[usize; _]` + //~^ ERROR: type annotations needed for `[usize; N]` } diff --git a/tests/ui/inference/issue-83606.stderr b/tests/ui/inference/issue-83606.stderr index f5c84f960641a..f2ee8692e38a6 100644 --- a/tests/ui/inference/issue-83606.stderr +++ b/tests/ui/inference/issue-83606.stderr @@ -1,4 +1,4 @@ -error[E0282]: type annotations needed for `[usize; _]` +error[E0282]: type annotations needed for `[usize; N]` --> $DIR/issue-83606.rs:8:9 | LL | let _ = foo("foo"); @@ -6,7 +6,7 @@ LL | let _ = foo("foo"); | help: consider giving this pattern a type, where the the value of const parameter `N` is specified | -LL | let _: [usize; _] = foo("foo"); +LL | let _: [usize; N] = foo("foo"); | ++++++++++++ error: aborting due to previous error diff --git a/tests/ui/limits/issue-15919-64.stderr b/tests/ui/limits/issue-15919-64.stderr index 193b823035c09..3399d644ede3a 100644 --- a/tests/ui/limits/issue-15919-64.stderr +++ b/tests/ui/limits/issue-15919-64.stderr @@ -1,4 +1,4 @@ -error: values of the type `[usize; 18446744073709551615]` are too big for the current architecture +error: values of the type `[usize; usize::MAX]` are too big for the current architecture --> $DIR/issue-15919-64.rs:9:9 | LL | let x = [0usize; 0xffff_ffff_ffff_ffff]; diff --git a/tests/ui/limits/issue-55878.stderr b/tests/ui/limits/issue-55878.stderr index f455dcb06f79d..99f1fdf755aa2 100644 --- a/tests/ui/limits/issue-55878.stderr +++ b/tests/ui/limits/issue-55878.stderr @@ -1,7 +1,7 @@ -error[E0080]: values of the type `[u8; SIZE]` are too big for the current architecture +error[E0080]: values of the type `[u8; usize::MAX]` are too big for the current architecture --> $SRC_DIR/core/src/mem/mod.rs:LL:COL | -note: inside `std::mem::size_of::<[u8; SIZE]>` +note: inside `std::mem::size_of::<[u8; usize::MAX]>` --> $SRC_DIR/core/src/mem/mod.rs:LL:COL note: inside `main` --> $DIR/issue-55878.rs:7:26 diff --git a/tests/ui/limits/issue-69485-var-size-diffs-too-large.stderr b/tests/ui/limits/issue-69485-var-size-diffs-too-large.stderr index f7923bd47439f..44b2be269494a 100644 --- a/tests/ui/limits/issue-69485-var-size-diffs-too-large.stderr +++ b/tests/ui/limits/issue-69485-var-size-diffs-too-large.stderr @@ -1,4 +1,4 @@ -error: values of the type `[u8; 18446744073709551615]` are too big for the current architecture +error: values of the type `[u8; usize::MAX]` are too big for the current architecture --> $DIR/issue-69485-var-size-diffs-too-large.rs:6:5 | LL | Bug::V([0; !0]); diff --git a/tests/ui/limits/issue-75158-64.stderr b/tests/ui/limits/issue-75158-64.stderr index dc11d05615427..d5991bcf5693d 100644 --- a/tests/ui/limits/issue-75158-64.stderr +++ b/tests/ui/limits/issue-75158-64.stderr @@ -1,4 +1,4 @@ -error: values of the type `[u8; 18446744073709551615]` are too big for the current architecture +error: values of the type `[u8; usize::MAX]` are too big for the current architecture error: aborting due to previous error diff --git a/tests/ui/symbol-names/impl2.rs b/tests/ui/symbol-names/impl2.rs index 08add29cb9cd5..81aba403d0ba2 100644 --- a/tests/ui/symbol-names/impl2.rs +++ b/tests/ui/symbol-names/impl2.rs @@ -8,9 +8,8 @@ trait Foo { } impl Foo for [u8; 1 + 2] { - #[rustc_def_path] //~ ERROR def-path(<[u8; _] as Foo>::baz) - fn baz() { } + #[rustc_def_path] //~ ERROR def-path(<[u8; 1 + 2] as Foo>::baz) + fn baz() {} } -fn main() { -} +fn main() {} diff --git a/tests/ui/symbol-names/impl2.stderr b/tests/ui/symbol-names/impl2.stderr index 9833003160223..0c3205e0108e6 100644 --- a/tests/ui/symbol-names/impl2.stderr +++ b/tests/ui/symbol-names/impl2.stderr @@ -1,4 +1,4 @@ -error: def-path(<[u8; _] as Foo>::baz) +error: def-path(<[u8; 1 + 2] as Foo>::baz) --> $DIR/impl2.rs:11:5 | LL | #[rustc_def_path] From 88f81a0de122843afc122468823f1ed6f0b8f2c8 Mon Sep 17 00:00:00 2001 From: Boxy Date: Sat, 14 Jan 2023 19:01:31 +0000 Subject: [PATCH 09/11] test for non local anon const printing --- .../auxiliary/anon_const_non_local.rs | 8 ++++++++ .../non_local_anon_const_diagnostics.rs | 16 ++++++++++++++++ .../non_local_anon_const_diagnostics.stderr | 12 ++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 tests/ui/const-generics/generic_const_exprs/auxiliary/anon_const_non_local.rs create mode 100644 tests/ui/const-generics/generic_const_exprs/non_local_anon_const_diagnostics.rs create mode 100644 tests/ui/const-generics/generic_const_exprs/non_local_anon_const_diagnostics.stderr diff --git a/tests/ui/const-generics/generic_const_exprs/auxiliary/anon_const_non_local.rs b/tests/ui/const-generics/generic_const_exprs/auxiliary/anon_const_non_local.rs new file mode 100644 index 0000000000000..97be074933d9b --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/auxiliary/anon_const_non_local.rs @@ -0,0 +1,8 @@ +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +pub struct Foo; + +pub fn foo() -> Foo<{ N + 1 }> { + Foo +} diff --git a/tests/ui/const-generics/generic_const_exprs/non_local_anon_const_diagnostics.rs b/tests/ui/const-generics/generic_const_exprs/non_local_anon_const_diagnostics.rs new file mode 100644 index 0000000000000..1254b4435f738 --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/non_local_anon_const_diagnostics.rs @@ -0,0 +1,16 @@ +// aux-build:anon_const_non_local.rs + +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +extern crate anon_const_non_local; + +fn bar() +where + [(); M + 1]:, +{ + let _: anon_const_non_local::Foo<2> = anon_const_non_local::foo::(); + //~^ ERROR: mismatched types +} + +fn main() {} diff --git a/tests/ui/const-generics/generic_const_exprs/non_local_anon_const_diagnostics.stderr b/tests/ui/const-generics/generic_const_exprs/non_local_anon_const_diagnostics.stderr new file mode 100644 index 0000000000000..c18281beb0502 --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/non_local_anon_const_diagnostics.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/non_local_anon_const_diagnostics.rs:12:43 + | +LL | let _: anon_const_non_local::Foo<2> = anon_const_non_local::foo::(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `2`, found `_` + | + = note: expected constant `2` + found constant `_` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. From a2a50f96f3532347a0ad61f2d6bfed4c64de4e54 Mon Sep 17 00:00:00 2001 From: Boxy Date: Sat, 14 Jan 2023 19:03:50 +0000 Subject: [PATCH 10/11] actually print out non local anon consts --- compiler/rustc_middle/src/ty/print/pretty.rs | 6 +++--- .../non_local_anon_const_diagnostics.stderr | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index eba3016aca82c..df37b2b4628b5 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -1295,10 +1295,10 @@ pub trait PrettyPrinter<'tcx>: if let Ok(snip) = self.tcx().sess.source_map().span_to_snippet(span) { p!(write("{}", snip)) } else { - print_underscore!() + p!(print_value_path(def.did, substs)) } } else { - print_underscore!() + p!(print_value_path(def.did, substs)) } } defkind => bug!("`{:?}` has unexpcted defkind {:?}", ct, defkind), @@ -1323,7 +1323,7 @@ pub trait PrettyPrinter<'tcx>: ty::ConstKind::Placeholder(placeholder) => p!(write("Placeholder({:?})", placeholder)), // FIXME(generic_const_exprs): // write out some legible representation of an abstract const? - ty::ConstKind::Expr(_) => p!("[Const Expr]"), + ty::ConstKind::Expr(_) => p!("[const expr]"), ty::ConstKind::Error(_) => p!("[const error]"), }; Ok(self) diff --git a/tests/ui/const-generics/generic_const_exprs/non_local_anon_const_diagnostics.stderr b/tests/ui/const-generics/generic_const_exprs/non_local_anon_const_diagnostics.stderr index c18281beb0502..c1a846acf8862 100644 --- a/tests/ui/const-generics/generic_const_exprs/non_local_anon_const_diagnostics.stderr +++ b/tests/ui/const-generics/generic_const_exprs/non_local_anon_const_diagnostics.stderr @@ -2,10 +2,10 @@ error[E0308]: mismatched types --> $DIR/non_local_anon_const_diagnostics.rs:12:43 | LL | let _: anon_const_non_local::Foo<2> = anon_const_non_local::foo::(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `2`, found `_` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `2`, found `foo::::{constant#0}` | = note: expected constant `2` - found constant `_` + found constant `foo::::{constant#0}` error: aborting due to previous error From 1171fe5c455e63a1617d56f7dba2b7901182a1eb Mon Sep 17 00:00:00 2001 From: Boxy Date: Wed, 18 Jan 2023 04:45:35 +0000 Subject: [PATCH 11/11] i am free --- compiler/rustc_middle/src/ty/print/pretty.rs | 19 +++++++++++-------- ...egion_subtyping_basic.main.nll.0.32bit.mir | 2 +- ...egion_subtyping_basic.main.nll.0.64bit.mir | 2 +- .../non_local_anon_const_diagnostics.stderr | 4 ++-- tests/ui/limits/issue-15919-32.stderr | 2 +- tests/ui/limits/issue-17913.rs | 2 +- tests/ui/limits/issue-17913.stderr | 2 +- 7 files changed, 18 insertions(+), 15 deletions(-) diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index df37b2b4628b5..aed7051bb993d 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -1290,15 +1290,18 @@ pub trait PrettyPrinter<'tcx>: p!(print_value_path(def.did, substs)) } DefKind::AnonConst => { - if def.is_local() { - let span = self.tcx().def_span(def.did); - if let Ok(snip) = self.tcx().sess.source_map().span_to_snippet(span) { - p!(write("{}", snip)) - } else { - p!(print_value_path(def.did, substs)) - } + if def.is_local() + && let span = self.tcx().def_span(def.did) + && let Ok(snip) = self.tcx().sess.source_map().span_to_snippet(span) + { + p!(write("{}", snip)) } else { - p!(print_value_path(def.did, substs)) + // Do not call `print_value_path` as if a parent of this anon const is an impl it will + // attempt to print out the impl trait ref i.e. `::{constant#0}`. This would + // cause printing to enter an infinite recursion if the anon const is in the self type i.e. + // `impl Default for [T; 32 - 1 - 1 - 1] {` + // where we would try to print `<[T; /* print `constant#0` again */] as Default>::{constant#0}` + p!(write("{}::{}", self.tcx().crate_name(def.did.krate), self.tcx().def_path(def.did).to_string_no_crate_verbose())) } } defkind => bug!("`{:?}` has unexpcted defkind {:?}", ct, defkind), diff --git a/tests/mir-opt/nll/region_subtyping_basic.main.nll.0.32bit.mir b/tests/mir-opt/nll/region_subtyping_basic.main.nll.0.32bit.mir index 8e6564a38b0bb..798e45df8ca76 100644 --- a/tests/mir-opt/nll/region_subtyping_basic.main.nll.0.32bit.mir +++ b/tests/mir-opt/nll/region_subtyping_basic.main.nll.0.32bit.mir @@ -22,7 +22,7 @@ | fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/region_subtyping_basic.rs:+0:11: +0:11 - let mut _1: [usize; Const { ty: usize, kind: Value(Leaf(0x00000003)) }]; // in scope 0 at $DIR/region_subtyping_basic.rs:+1:9: +1:14 + let mut _1: [usize; Const(Value(Leaf(0x00000003)): usize)]; // in scope 0 at $DIR/region_subtyping_basic.rs:+1:9: +1:14 let _3: usize; // in scope 0 at $DIR/region_subtyping_basic.rs:+2:16: +2:17 let mut _4: usize; // in scope 0 at $DIR/region_subtyping_basic.rs:+2:14: +2:18 let mut _5: bool; // in scope 0 at $DIR/region_subtyping_basic.rs:+2:14: +2:18 diff --git a/tests/mir-opt/nll/region_subtyping_basic.main.nll.0.64bit.mir b/tests/mir-opt/nll/region_subtyping_basic.main.nll.0.64bit.mir index 74d44c6741a92..4767bfc76ed9d 100644 --- a/tests/mir-opt/nll/region_subtyping_basic.main.nll.0.64bit.mir +++ b/tests/mir-opt/nll/region_subtyping_basic.main.nll.0.64bit.mir @@ -22,7 +22,7 @@ | fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/region_subtyping_basic.rs:+0:11: +0:11 - let mut _1: [usize; Const { ty: usize, kind: Value(Leaf(0x0000000000000003)) }]; // in scope 0 at $DIR/region_subtyping_basic.rs:+1:9: +1:14 + let mut _1: [usize; Const(Value(Leaf(0x0000000000000003)): usize)]; // in scope 0 at $DIR/region_subtyping_basic.rs:+1:9: +1:14 let _3: usize; // in scope 0 at $DIR/region_subtyping_basic.rs:+2:16: +2:17 let mut _4: usize; // in scope 0 at $DIR/region_subtyping_basic.rs:+2:14: +2:18 let mut _5: bool; // in scope 0 at $DIR/region_subtyping_basic.rs:+2:14: +2:18 diff --git a/tests/ui/const-generics/generic_const_exprs/non_local_anon_const_diagnostics.stderr b/tests/ui/const-generics/generic_const_exprs/non_local_anon_const_diagnostics.stderr index c1a846acf8862..3926c830adb7a 100644 --- a/tests/ui/const-generics/generic_const_exprs/non_local_anon_const_diagnostics.stderr +++ b/tests/ui/const-generics/generic_const_exprs/non_local_anon_const_diagnostics.stderr @@ -2,10 +2,10 @@ error[E0308]: mismatched types --> $DIR/non_local_anon_const_diagnostics.rs:12:43 | LL | let _: anon_const_non_local::Foo<2> = anon_const_non_local::foo::(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `2`, found `foo::::{constant#0}` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `2`, found `anon_const_non_local::::foo::{constant#0}` | = note: expected constant `2` - found constant `foo::::{constant#0}` + found constant `anon_const_non_local::::foo::{constant#0}` error: aborting due to previous error diff --git a/tests/ui/limits/issue-15919-32.stderr b/tests/ui/limits/issue-15919-32.stderr index 133637f9a058b..0d79fc0c77069 100644 --- a/tests/ui/limits/issue-15919-32.stderr +++ b/tests/ui/limits/issue-15919-32.stderr @@ -1,4 +1,4 @@ -error: values of the type `[usize; 4294967295]` are too big for the current architecture +error: values of the type `[usize; usize::MAX]` are too big for the current architecture --> $DIR/issue-15919-32.rs:9:9 | LL | let x = [0usize; 0xffff_ffff]; diff --git a/tests/ui/limits/issue-17913.rs b/tests/ui/limits/issue-17913.rs index 8d4cbe2018461..56cf5d831bd7e 100644 --- a/tests/ui/limits/issue-17913.rs +++ b/tests/ui/limits/issue-17913.rs @@ -1,5 +1,5 @@ // build-fail -// normalize-stderr-test "\[&usize; \d+\]" -> "[&usize; N]" +// normalize-stderr-test "\[&usize; \d+\]" -> "[&usize; usize::MAX]" // error-pattern: too big for the current architecture // FIXME https://github.com/rust-lang/rust/issues/59774 diff --git a/tests/ui/limits/issue-17913.stderr b/tests/ui/limits/issue-17913.stderr index 9a6431d447004..684db53a91909 100644 --- a/tests/ui/limits/issue-17913.stderr +++ b/tests/ui/limits/issue-17913.stderr @@ -1,4 +1,4 @@ -error: values of the type `[&usize; N]` are too big for the current architecture +error: values of the type `[&usize; usize::MAX]` are too big for the current architecture error: aborting due to previous error