mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-16 22:16:53 +00:00
Auto merge of #107021 - matthiaskrgr:rollup-0dzxfyi, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #106244 (Improve Markdown styling in README) - #106747 (Add 'static lifetime suggestion when GAT implied 'static requirement from HRTB) - #106873 (dont randomly use `_` to print out const generic arguments) - #106992 (Remove unused `#![feature(box_syntax)]` in `alloc`) - #106995 (bump failing assembly & codegen tests from LLVM 14 to LLVM 15) - #106996 (rustdoc: instead of `.setting-name { width: 100% }`, use default div CSS) - #106997 (Add heapsort fallback in `select_nth_unstable`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
74c1ad5d35
163
README.md
163
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 <subcommand> [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 <subcommand> [flags]
|
||||
python x.py <subcommand> [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=<triple>` 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
|
||||
|
@ -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::<Vec<_>>();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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<Item = ty::PlaceholderRegion> + '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());
|
||||
|
@ -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,21 +1286,25 @@ 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))
|
||||
}
|
||||
_ => {
|
||||
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 {
|
||||
print_underscore!()
|
||||
}
|
||||
DefKind::AnonConst => {
|
||||
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 {
|
||||
print_underscore!()
|
||||
// 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. `<T as Trait>::{constant#0}`. This would
|
||||
// cause printing to enter an infinite recursion if the anon const is in the self type i.e.
|
||||
// `impl<T: Default> 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),
|
||||
}
|
||||
}
|
||||
ty::ConstKind::Infer(infer_ct) => {
|
||||
@ -1339,7 +1326,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)
|
||||
|
@ -100,6 +100,13 @@ impl BoundRegionKind {
|
||||
|
||||
None
|
||||
}
|
||||
|
||||
pub fn get_id(&self) -> Option<DefId> {
|
||||
match *self {
|
||||
BoundRegionKind::BrNamed(id, _) => return Some(id),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub trait Article {
|
||||
|
@ -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)]
|
||||
|
@ -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);
|
||||
|
@ -33,10 +33,6 @@
|
||||
padding-bottom: 1px;
|
||||
}
|
||||
|
||||
.radio-line .setting-name {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.radio-line .choice {
|
||||
margin-top: 0.1em;
|
||||
margin-bottom: 0.1em;
|
||||
|
@ -135,7 +135,7 @@
|
||||
// This is a select setting.
|
||||
output += `\
|
||||
<div class="radio-line" id="${js_data_name}">
|
||||
<span class="setting-name">${setting_name}</span>
|
||||
<div class="setting-name">${setting_name}</div>
|
||||
<div class="choices">`;
|
||||
onEach(setting["options"], option => {
|
||||
const checked = option === setting["default"] ? " checked" : "";
|
||||
|
@ -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
|
||||
|
@ -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"]
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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: (
|
||||
|
@ -10,7 +10,7 @@ error[E0770]: the type of const parameters must not depend on other generic para
|
||||
LL | pub struct SelfDependent<const N: [u8; N]>;
|
||||
| ^ 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<const N: usize, const X: [u8; N]>([(); N]);
|
||||
@ -19,7 +19,7 @@ LL | pub struct Dependent<const N: usize, const X: [u8; N]>([(); 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<const N: [u8; N]>;
|
||||
|
@ -10,10 +10,10 @@
|
||||
|
||||
pub struct Dependent<const N: usize, const X: [u8; N]>([(); 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<const N: [u8; 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
|
||||
|
||||
fn main() {}
|
||||
|
@ -1,8 +1,8 @@
|
||||
error[E0277]: the trait bound `[Adt; _]: Foo` is not satisfied
|
||||
error[E0277]: the trait bound `[Adt; std::mem::size_of::<Self::Assoc>()]: Foo` is not satisfied
|
||||
--> $DIR/dont-evaluate-array-len-on-err-1.rs:15:9
|
||||
|
|
||||
LL | <[Adt; std::mem::size_of::<Self::Assoc>()] as Foo>::bar()
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `[Adt; _]`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `[Adt; std::mem::size_of::<Self::Assoc>()]`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -0,0 +1,8 @@
|
||||
#![feature(generic_const_exprs)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
pub struct Foo<const N: usize>;
|
||||
|
||||
pub fn foo<const N: usize>() -> Foo<{ N + 1 }> {
|
||||
Foo
|
||||
}
|
@ -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
|
||||
|
|
||||
|
@ -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::<Self::Assoc>()];
|
||||
| ------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected associated type, found array `[(); _]`
|
||||
| ------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected associated type, found array `[(); std::mem::size_of::<Self::Assoc>()]`
|
||||
| |
|
||||
| expected because this is `<Self as Foo>::Assoc`
|
||||
|
|
||||
= note: expected associated type `<Self as Foo>::Assoc`
|
||||
found array `[(); _]`
|
||||
= help: consider constraining the associated type `<Self as Foo>::Assoc` to `[(); _]` or calling a method that returns `<Self as Foo>::Assoc`
|
||||
found array `[(); std::mem::size_of::<Self::Assoc>()]`
|
||||
= help: consider constraining the associated type `<Self as Foo>::Assoc` to `[(); std::mem::size_of::<Self::Assoc>()]` or calling a method that returns `<Self as Foo>::Assoc`
|
||||
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
|
||||
|
||||
error: aborting due to previous error
|
||||
|
@ -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<const M: usize>()
|
||||
where
|
||||
[(); M + 1]:,
|
||||
{
|
||||
let _: anon_const_non_local::Foo<2> = anon_const_non_local::foo::<M>();
|
||||
//~^ ERROR: mismatched types
|
||||
}
|
||||
|
||||
fn main() {}
|
@ -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::<M>();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `2`, found `anon_const_non_local::::foo::{constant#0}`
|
||||
|
|
||||
= note: expected constant `2`
|
||||
found constant `anon_const_non_local::::foo::{constant#0}`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
@ -4,7 +4,7 @@ error[E0770]: the type of const parameters must not depend on other generic para
|
||||
LL | fn foo<const N: usize, const A: [u8; N]>() {}
|
||||
| ^ 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<const N: usize, const A: [u8; N]>() {}
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
fn foo<const N: usize, const A: [u8; N]>() {}
|
||||
//~^ 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] }>();
|
||||
|
@ -4,7 +4,7 @@ error[E0770]: the type of const parameters must not depend on other generic para
|
||||
LL | fn foo<const LEN: usize, const DATA: [u8; LEN]>() {}
|
||||
| ^^^ 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<const LEN: usize, const DATA: [u8; LEN]>() {}
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
fn foo<const LEN: usize, const DATA: [u8; LEN]>() {}
|
||||
//~^ 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>();
|
||||
|
@ -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<const IN: [u32; LEN]>() {}
|
||||
|
@ -6,6 +6,6 @@
|
||||
const LEN: usize = 1024;
|
||||
|
||||
fn hoge<const IN: [u32; LEN]>() {}
|
||||
//[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() {}
|
||||
|
@ -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<const N: [u8; 1 + 2]>() {}
|
||||
@ -7,7 +7,7 @@ LL | fn test<const N: [u8; 1 + 2]>() {}
|
||||
= 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<const N: [u8; 1 + 2]>;
|
||||
|
@ -4,9 +4,9 @@
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
|
||||
fn test<const N: [u8; 1 + 2]>() {}
|
||||
//[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<const N: [u8; 1 + 2]>;
|
||||
//[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() {}
|
||||
|
@ -1,4 +1,4 @@
|
||||
error: `[u8; _]` is forbidden as the type of a const generic parameter
|
||||
error: `[u8; Bar::<u32>::value()]` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/issue-75047.rs:14:21
|
||||
|
|
||||
LL | struct Foo<const N: [u8; Bar::<u32>::value()]>;
|
||||
|
@ -12,6 +12,6 @@ impl<T> Bar<T> {
|
||||
}
|
||||
|
||||
struct Foo<const N: [u8; Bar::<u32>::value()]>;
|
||||
//[min]~^ ERROR `[u8; _]` is forbidden as the type of a const generic parameter
|
||||
//[min]~^ ERROR `[u8; Bar::<u32>::value()]` is forbidden as the type of a const generic parameter
|
||||
|
||||
fn main() {}
|
||||
|
@ -1,4 +1,14 @@
|
||||
error: `[u8; _]` is forbidden as the type of a const generic parameter
|
||||
error: `[u8; {
|
||||
struct Foo<const N: usize>;
|
||||
|
||||
impl<const N: usize> Foo<N> {
|
||||
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<const N: [u8; {
|
||||
|
@ -15,8 +15,8 @@ note: ...which requires const-evaluating + checking `Foo::bytes::{constant#0}`..
|
||||
LL | bytes: [u8; std::mem::size_of::<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::<Foo>()]`...
|
||||
= note: ...which requires normalizing `[u8; std::mem::size_of::<Foo>()]`...
|
||||
= 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
|
||||
|
@ -15,8 +15,8 @@ note: ...which requires const-evaluating + checking `Foo::bytes::{constant#0}`..
|
||||
LL | bytes: [u8; unsafe { intrinsics::size_of::<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; unsafe { intrinsics::size_of::<Foo>() }]`...
|
||||
= note: ...which requires normalizing `[u8; unsafe { intrinsics::size_of::<Foo>() }]`...
|
||||
= 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
|
||||
|
@ -7,7 +7,7 @@ impl<A, B> Foo<A, B> {
|
||||
[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]`
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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<Rhs>`:
|
||||
<&[B] as PartialEq<[A; N]>>
|
||||
<&[T] as PartialEq<Vec<U, A>>>
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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<Value<'a> = ()>,
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
help: consider restricting the type parameter to the `'static` lifetime
|
||||
|
|
||||
LL | for<'a> T: Get<Value<'a> = ()> + 'static,
|
||||
| +++++++++
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -6,5 +6,5 @@ fn foo<const N: usize>(_: impl std::fmt::Display) -> [usize; N] {
|
||||
|
||||
fn main() {
|
||||
let _ = foo("foo");
|
||||
//~^ ERROR: type annotations needed for `[usize; _]`
|
||||
//~^ ERROR: type annotations needed for `[usize; N]`
|
||||
}
|
||||
|
@ -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
|
||||
|
43
tests/ui/lifetimes/issue-105507.fixed
Normal file
43
tests/ui/lifetimes/issue-105507.fixed
Normal file
@ -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<T> Project for Option<T> {
|
||||
type Projected<'a> = Option<Wrapper<'a, T>> where T: 'a;
|
||||
fn project(this: Wrapper<'_, Self>) -> Self::Projected<'_> {
|
||||
this.0.as_ref().map(Wrapper)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: MyTrait> MyTrait for Option<Wrapper<'_, T>> {}
|
||||
|
||||
impl<T: ProjectedMyTrait> MyTrait for Wrapper<'_, T> {}
|
||||
|
||||
impl<T> 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: MyTrait>(_: T) {}
|
||||
|
||||
fn foo<T : MyTrait + 'static + 'static, U : MyTrait + 'static + 'static>(wrap: Wrapper<'_, Option<T>>, wrap1: Wrapper<'_, Option<U>>) {
|
||||
//~^ 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() {}
|
43
tests/ui/lifetimes/issue-105507.rs
Normal file
43
tests/ui/lifetimes/issue-105507.rs
Normal file
@ -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<T> Project for Option<T> {
|
||||
type Projected<'a> = Option<Wrapper<'a, T>> where T: 'a;
|
||||
fn project(this: Wrapper<'_, Self>) -> Self::Projected<'_> {
|
||||
this.0.as_ref().map(Wrapper)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: MyTrait> MyTrait for Option<Wrapper<'_, T>> {}
|
||||
|
||||
impl<T: ProjectedMyTrait> MyTrait for Wrapper<'_, T> {}
|
||||
|
||||
impl<T> 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: MyTrait>(_: T) {}
|
||||
|
||||
fn foo<T : MyTrait, U : MyTrait>(wrap: Wrapper<'_, Option<T>>, wrap1: Wrapper<'_, Option<U>>) {
|
||||
//~^ 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() {}
|
34
tests/ui/lifetimes/issue-105507.stderr
Normal file
34
tests/ui/lifetimes/issue-105507.stderr
Normal file
@ -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<T : MyTrait + 'static, U : MyTrait + 'static>(wrap: Wrapper<'_, Option<T>>, wrap1: Wrapper<'_, Option<U>>) {
|
||||
| +++++++++ +++++++++
|
||||
|
||||
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<T : MyTrait + 'static, U : MyTrait + 'static>(wrap: Wrapper<'_, Option<T>>, wrap1: Wrapper<'_, Option<U>>) {
|
||||
| +++++++++ +++++++++
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
@ -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];
|
||||
|
@ -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];
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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]);
|
||||
|
@ -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
|
||||
|
||||
|
@ -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() {}
|
||||
|
@ -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]
|
||||
|
Loading…
Reference in New Issue
Block a user