"walkdir",
]
+[[package]]
+name = "tier-check"
+version = "0.1.0"
+
[[package]]
name = "time"
version = "0.1.42"
"src/tools/rustbook",
"src/tools/unstable-book-gen",
"src/tools/tidy",
+ "src/tools/tier-check",
"src/tools/build-manifest",
"src/tools/remote-test-client",
"src/tools/remote-test-server",
///
/// [`write`]: Self::write
/// [`flush`]: Self::flush
-/// [`std::io`]: index.html
+/// [`std::io`]: self
///
/// # Examples
///
/// # Errors
///
/// Seeking to a negative offset is considered an error.
- ///
- /// [`SeekFrom::Start`]: enum.SeekFrom.html#variant.Start
#[stable(feature = "rust1", since = "1.0.0")]
fn seek(&mut self, pos: SeekFrom) -> Result<u64>;
/// Enumeration of possible methods to seek within an I/O object.
///
/// It is used by the [`Seek`] trait.
-///
-/// [`Seek`]: trait.Seek.html
#[derive(Copy, PartialEq, Eq, Clone, Debug)]
#[stable(feature = "rust1", since = "1.0.0")]
pub enum SeekFrom {
/// For example, [`File`] implements [`Read`], but not `BufRead`.
/// [`BufReader`] to the rescue!
///
-/// [`BufReader`]: struct.BufReader.html
/// [`File`]: crate::fs::File
/// [`read_line`]: Self::read_line
/// [`lines`]: Self::lines
-/// [`Read`]: trait.Read.html
///
/// ```no_run
/// use std::io::{self, BufReader};
/// present in `buf` and its length will have been adjusted appropriately.
///
/// [`fill_buf`]: Self::fill_buf
- /// [`ErrorKind::Interrupted`]: enum.ErrorKind.html#variant.Interrupted
///
/// # Examples
///
/// this example, we use [`Cursor`] to read all the bytes in a byte slice
/// in hyphen delimited segments:
///
- /// [`Cursor`]: struct.Cursor.html
- ///
/// ```
/// use std::io::{self, BufRead};
///
/// [`std::io::Cursor`][`Cursor`] is a type that implements `BufRead`. In
/// this example, we use [`Cursor`] to read all the lines in a byte slice:
///
- /// [`Cursor`]: struct.Cursor.html
- ///
/// ```
/// use std::io::{self, BufRead};
///
/// this example, we use [`Cursor`] to iterate over all hyphen delimited
/// segments in a byte slice
///
- /// [`Cursor`]: struct.Cursor.html
- ///
/// ```
/// use std::io::{self, BufRead};
///
/// # Errors
///
/// Each line of the iterator has the same error semantics as [`BufRead::read_line`].
- ///
- /// [`BufRead::read_line`]: trait.BufRead.html#method.read_line
#[stable(feature = "rust1", since = "1.0.0")]
fn lines(self) -> Lines<Self>
where
/// This struct is generally created by calling [`chain`] on a reader.
/// Please see the documentation of [`chain`] for more details.
///
-/// [`chain`]: trait.Read.html#method.chain
+/// [`chain`]: Read::chain
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Chain<T, U> {
first: T,
/// This struct is generally created by calling [`take`] on a reader.
/// Please see the documentation of [`take`] for more details.
///
-/// [`take`]: trait.Read.html#method.take
+/// [`take`]: Read::take
#[stable(feature = "rust1", since = "1.0.0")]
#[derive(Debug)]
pub struct Take<T> {
/// This struct is generally created by calling [`bytes`] on a reader.
/// Please see the documentation of [`bytes`] for more details.
///
-/// [`bytes`]: trait.Read.html#method.bytes
+/// [`bytes`]: Read::bytes
#[stable(feature = "rust1", since = "1.0.0")]
#[derive(Debug)]
pub struct Bytes<R> {
/// This struct is generally created by calling [`split`] on a `BufRead`.
/// Please see the documentation of [`split`] for more details.
///
-/// [`split`]: trait.BufRead.html#method.split
+/// [`split`]: BufRead::split
#[stable(feature = "rust1", since = "1.0.0")]
#[derive(Debug)]
pub struct Split<B> {
/// This struct is generally created by calling [`lines`] on a `BufRead`.
/// Please see the documentation of [`lines`] for more details.
///
-/// [`lines`]: trait.BufRead.html#method.lines
+/// [`lines`]: BufRead::lines
#[stable(feature = "rust1", since = "1.0.0")]
#[derive(Debug)]
pub struct Lines<B> {
//! * [`std::*` modules](#modules)
//! * [Primitive types](#primitives)
//! * [Standard macros](#macros)
-//! * [The Rust Prelude](prelude/index.html)
+//! * [The Rust Prelude]
//!
//! If this is your first time, the documentation for the standard library is
//! written to be casually perused. Clicking on interesting things should
//! So for example there is a [page for the primitive type
//! `i32`](primitive.i32.html) that lists all the methods that can be called on
//! 32-bit integers (very useful), and there is a [page for the module
-//! `std::i32`](i32/index.html) that documents the constant values [`MIN`] and
-//! [`MAX`](i32/constant.MAX.html) (rarely useful).
+//! `std::i32`] that documents the constant values [`MIN`] and [`MAX`] (rarely
+//! useful).
//!
//! Note the documentation for the primitives [`str`] and [`[T]`][slice] (also
//! called 'slice'). Many method calls on [`String`] and [`Vec<T>`] are actually
//! contains further primitive shared memory types, including [`atomic`] and
//! [`mpsc`], which contains the channel types for message passing.
//!
-//! [I/O]: io/index.html
-//! [`MIN`]: i32/constant.MIN.html
-//! [TCP]: net/struct.TcpStream.html
-//! [The Rust Prelude]: prelude/index.html
-//! [UDP]: net/struct.UdpSocket.html
-//! [`Arc`]: sync/struct.Arc.html
-//! [owned slice]: boxed/index.html
-//! [`Cell`]: cell/struct.Cell.html
-//! [`FromStr`]: str/trait.FromStr.html
-//! [`HashMap<K, V>`]: collections/struct.HashMap.html
-//! [`Iterator`]: iter/trait.Iterator.html
-//! [`Mutex`]: sync/struct.Mutex.html
-//! [`Option<T>`]: option/enum.Option.html
-//! [`Rc`]: rc/struct.Rc.html
-//! [`RefCell`]: cell/struct.RefCell.html
-//! [`Result<T, E>`]: result/enum.Result.html
-//! [`String`]: string/struct.String.html
-//! [`Vec<T>`]: vec/struct.Vec.html
-//! [array]: primitive.array.html
-//! [slice]: primitive.slice.html
-//! [`atomic`]: sync/atomic/index.html
-//! [`collections`]: collections/index.html
+//! [I/O]: io
+//! [`MIN`]: i32::MIN
+//! [`MAX`]: i32::MAX
+//! [page for the module `std::i32`]: crate::i32
+//! [TCP]: net::TcpStream
+//! [The Rust Prelude]: prelude
+//! [UDP]: net::UdpSocket
+//! [`Arc`]: sync::Arc
+//! [owned slice]: boxed
+//! [`Cell`]: cell::Cell
+//! [`FromStr`]: str::FromStr
+//! [`HashMap<K, V>`]: collections::HashMap
+//! [`Mutex`]: sync::Mutex
+//! [`Option<T>`]: option::Option
+//! [`Rc`]: rc::Rc
+//! [`RefCell`]: cell::RefCell
+//! [`Result<T, E>`]: result::Result
+//! [`Vec<T>`]: vec::Vec
+//! [`atomic`]: sync::atomic
//! [`for`]: ../book/ch03-05-control-flow.html#looping-through-a-collection-with-for
-//! [`format!`]: macro.format.html
-//! [`fs`]: fs/index.html
-//! [`io`]: io/index.html
-//! [`iter`]: iter/index.html
-//! [`mpsc`]: sync/mpsc/index.html
-//! [`net`]: net/index.html
-//! [`option`]: option/index.html
-//! [`result`]: result/index.html
-//! [`std::cmp`]: cmp/index.html
-//! [`std::slice`]: slice/index.html
-//! [`str`]: primitive.str.html
-//! [`sync`]: sync/index.html
-//! [`thread`]: thread/index.html
+//! [`mpsc`]: sync::mpsc
+//! [`std::cmp`]: cmp
+//! [`std::slice`]: slice
//! [`use std::env`]: env/index.html
//! [`use`]: ../book/ch07-02-defining-modules-to-control-scope-and-privacy.html
//! [crates.io]: https://crates.io
//! [deref-coercions]: ../book/ch15-02-deref.html#implicit-deref-coercions-with-functions-and-methods
-//! [files]: fs/struct.File.html
-//! [multithreading]: thread/index.html
+//! [files]: fs::File
+//! [multithreading]: thread
//! [other]: #what-is-in-the-standard-library-documentation
//! [primitive types]: ../book/ch03-02-data-types.html
//! [rust-discord]: https://discord.gg/rust-lang
///
/// This type can represent a wide range of decimal numbers, like `3.5`, `27`,
/// `-113.75`, `0.0078125`, `34359738368`, `0`, `-1`. So unlike integer types
-/// (like `i32`), floating point types can represent non-integer numbers, too.
+/// (such as `i32`), floating point types can represent non-integer numbers,
+/// too.
///
/// However, being able to represent this wide range of numbers comes at the
/// cost of precision: floats can only represent some of the real numbers and
/// often discard insignificant digits: `println!("{}", 1.0f32 / 5.0f32)` will
/// print `0.2`.
///
-/// The precision is better for numbers near 0 and worse for large numbers. For
-/// example, above 2<sup>24</sup>, not even all integers are representable.
-///
/// Additionally, `f32` can represent a couple of special values:
///
/// - `-0`: this is just due to how floats are encoded. It is semantically
/// equivalent to `0` and `-0.0 == 0.0` results in `true`.
/// - [∞](#associatedconstant.INFINITY) and
-/// [-∞](#associatedconstant.NEG_INFINITY): these result from calculations
+/// [−∞](#associatedconstant.NEG_INFINITY): these result from calculations
/// like `1.0 / 0.0`.
/// - [NaN (not a number)](#associatedconstant.NAN): this value results from
/// calculations like `(-1.0).sqrt()`. NaN has some potentially unexpected
pub struct OpenOptions {
read: bool,
write: bool,
+ append: bool,
dirflags: wasi::Lookupflags,
fdflags: wasi::Fdflags,
oflags: wasi::Oflags,
}
}
- pub fn append(&mut self, set: bool) {
- self.fdflag(wasi::FDFLAGS_APPEND, set);
+ pub fn append(&mut self, append: bool) {
+ self.append = append;
+ self.fdflag(wasi::FDFLAGS_APPEND, append);
}
pub fn dsync(&mut self, set: bool) {
base |= wasi::RIGHTS_FD_READ;
base |= wasi::RIGHTS_FD_READDIR;
}
- if self.write {
+ if self.write || self.append {
base |= wasi::RIGHTS_FD_WRITE;
base |= wasi::RIGHTS_FD_DATASYNC;
base |= wasi::RIGHTS_FD_ALLOCATE;
/// # Panics
///
/// This function may panic if the resulting point in time cannot be represented by the
- /// underlying data structure. See [`checked_add`] for a version without panic.
- ///
- /// [`checked_add`]: Instant::checked_add
+ /// underlying data structure. See [`Instant::checked_add`] for a version without panic.
fn add(self, other: Duration) -> Instant {
self.checked_add(other).expect("overflow when adding duration to instant")
}
/// # Panics
///
/// This function may panic if the resulting point in time cannot be represented by the
- /// underlying data structure. See [`checked_add`] for a version without panic.
- ///
- /// [`checked_add`]: SystemTime::checked_add
+ /// underlying data structure. See [`SystemTime::checked_add`] for a version without panic.
fn add(self, dur: Duration) -> SystemTime {
self.checked_add(dur).expect("overflow when adding duration to instant")
}
test::CrateLibrustc,
test::CrateRustdoc,
test::Linkcheck,
+ test::TierCheck,
test::Cargotest,
test::Cargo,
test::Rls,
run.builder.ensure(Bootstrap);
}
}
+
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
+pub struct TierCheck {
+ pub compiler: Compiler,
+ target: TargetSelection,
+}
+
+impl Step for TierCheck {
+ type Output = ();
+ const DEFAULT: bool = true;
+ const ONLY_HOSTS: bool = true;
+
+ fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
+ run.path("src/tools/tier-check")
+ }
+
+ fn make_run(run: RunConfig<'_>) {
+ let compiler = run.builder.compiler_for(run.builder.top_stage, run.host, run.host);
+ run.builder.ensure(TierCheck { compiler, target: run.host });
+ }
+
+ /// Tests the Platform Support page in the rustc book.
+ fn run(self, builder: &Builder<'_>) {
+ builder.ensure(compile::Std { compiler: self.compiler, target: self.target });
+ let mut cargo = tool::prepare_tool_cargo(
+ builder,
+ self.compiler,
+ Mode::ToolRustc,
+ self.target,
+ "run",
+ "src/tools/tier-check",
+ SourceType::InTree,
+ &[],
+ );
+ cargo.arg(builder.src.join("src/doc/rustc/src/platform-support.md"));
+ cargo.arg(&builder.rustc(self.compiler));
+ if builder.is_verbose() {
+ cargo.arg("--verbose");
+ }
+
+ builder.info("platform support check");
+ try_run(builder, &mut cargo.into());
+ }
+}
- [Deny-by-default lints](lints/listing/deny-by-default.md)
- [Codegen options](codegen-options/index.md)
- [JSON Output](json.md)
+- [Platform Support](platform-support.md)
- [Targets](targets/index.md)
- [Built-in Targets](targets/built-in.md)
- [Custom Targets](targets/custom.md)
--- /dev/null
+# Platform Support
+
+<style type="text/css">
+ td code {
+ white-space: nowrap;
+ }
+</style>
+
+Support for different platforms are organized into three tiers, each with a
+different set of guarantees.
+
+Platforms are identified by their "target triple" which is the string to
+inform the compiler what kind of output should be produced. The columns in the
+tables below have the following meanings:
+
+* std:
+ * ✓ indicates the full standard library is available.
+ * \* indicates the target only supports [`no_std`] development.
+ * ? indicates the standard library support is unknown or a work-in-progress.
+* host: A ✓ indicates that `rustc` and `cargo` can run on the host platform.
+
+[`no_std`]: https://rust-embedded.github.io/book/intro/no-std.html
+
+## Tier 1
+
+Tier 1 platforms can be thought of as "guaranteed to work".
+Specifically they will each satisfy the following requirements:
+
+* Official binary releases are provided for the platform.
+* Automated testing is set up to run tests for the platform.
+* Landing changes to the `rust-lang/rust` repository's master branch is gated
+ on tests passing.
+* Documentation for how to use and how to build the platform is available.
+
+target | std | host | notes
+-------|-----|------|-------
+`i686-pc-windows-gnu` | ✓ | ✓ | 32-bit MinGW (Windows 7+)
+`i686-pc-windows-msvc` | ✓ | ✓ | 32-bit MSVC (Windows 7+)
+`i686-unknown-linux-gnu` | ✓ | ✓ | 32-bit Linux (kernel 2.6.32+, glibc 2.11+)
+`x86_64-apple-darwin` | ✓ | ✓ | 64-bit OSX (10.7+, Lion+)
+`x86_64-pc-windows-gnu` | ✓ | ✓ | 64-bit MinGW (Windows 7+)
+`x86_64-pc-windows-msvc` | ✓ | ✓ | 64-bit MSVC (Windows 7+)
+`x86_64-unknown-linux-gnu` | ✓ | ✓ | 64-bit Linux (kernel 2.6.32+, glibc 2.11+)
+
+## Tier 2
+
+Tier 2 platforms can be thought of as "guaranteed to build". Automated tests
+are not run so it's not guaranteed to produce a working build, but platforms
+often work to quite a good degree and patches are always welcome!
+Specifically, these platforms are required to have each of the following:
+
+* Official binary releases are provided for the platform.
+* Automated building is set up, but may not be running tests.
+* Landing changes to the `rust-lang/rust` repository's master branch is gated on
+ platforms **building**. For some platforms only the standard library is
+ compiled, but for others `rustc` and `cargo` are too.
+
+target | std | host | notes
+-------|-----|------|-------
+`aarch64-apple-ios` | ✓[^apple] | | ARM64 iOS
+`aarch64-fuchsia` | ✓ | | ARM64 Fuchsia
+`aarch64-linux-android` | ✓ | | ARM64 Android
+`aarch64-pc-windows-msvc` | ✓ | | ARM64 Windows MSVC
+`aarch64-unknown-linux-gnu` | ✓ | ✓ | ARM64 Linux (kernel 4.2, glibc 2.17)
+`aarch64-unknown-linux-musl` | ✓ | | ARM64 Linux with MUSL
+`aarch64-unknown-none` | * | | Bare ARM64, hardfloat
+`aarch64-unknown-none-softfloat` | * | | Bare ARM64, softfloat
+`arm-linux-androideabi` | ✓ | | ARMv7 Android
+`arm-unknown-linux-gnueabi` | ✓ | ✓ | ARMv6 Linux (kernel 3.2, glibc 2.17)
+`arm-unknown-linux-gnueabihf` | ✓ | ✓ | ARMv6 Linux, hardfloat (kernel 3.2, glibc 2.17)
+`arm-unknown-linux-musleabi` | ✓ | | ARMv6 Linux with MUSL
+`arm-unknown-linux-musleabihf` | ✓ | | ARMv6 Linux with MUSL, hardfloat
+`armebv7r-none-eabi` | * | | Bare ARMv7-R, Big Endian
+`armebv7r-none-eabihf` | * | | Bare ARMv7-R, Big Endian, hardfloat
+`armv5te-unknown-linux-gnueabi` | ✓ | | ARMv5TE Linux (kernel 4.4, glibc 2.23)
+`armv5te-unknown-linux-musleabi` | ✓ | | ARMv5TE Linux with MUSL
+`armv7-linux-androideabi` | ✓ | | ARMv7a Android
+`armv7a-none-eabi` | * | | Bare ARMv7-A
+`armv7r-none-eabi` | * | | Bare ARMv7-R
+`armv7r-none-eabihf` | * | | Bare ARMv7-R, hardfloat
+`armv7-unknown-linux-gnueabi` | ✓ | | ARMv7 Linux (kernel 4.15, glibc 2.27)
+`armv7-unknown-linux-gnueabihf` | ✓ | ✓ | ARMv7 Linux, hardfloat (kernel 3.2, glibc 2.17)
+`armv7-unknown-linux-musleabi` | ✓ | | ARMv7 Linux, MUSL
+`armv7-unknown-linux-musleabihf` | ✓ | | ARMv7 Linux with MUSL
+`asmjs-unknown-emscripten` | ✓ | | asm.js via Emscripten
+`i586-pc-windows-msvc` | ✓ | | 32-bit Windows w/o SSE
+`i586-unknown-linux-gnu` | ✓ | | 32-bit Linux w/o SSE (kernel 4.4, glibc 2.23)
+`i586-unknown-linux-musl` | ✓ | | 32-bit Linux w/o SSE, MUSL
+`i686-linux-android` | ✓ | | 32-bit x86 Android
+`i686-unknown-freebsd` | ✓ | ✓ | 32-bit FreeBSD
+`i686-unknown-linux-musl` | ✓ | | 32-bit Linux with MUSL
+`mips-unknown-linux-gnu` | ✓ | ✓ | MIPS Linux (kernel 4.4, glibc 2.23)
+`mips-unknown-linux-musl` | ✓ | | MIPS Linux with MUSL
+`mips64-unknown-linux-gnuabi64` | ✓ | ✓ | MIPS64 Linux, n64 ABI (kernel 4.4, glibc 2.23)
+`mips64-unknown-linux-muslabi64` | ✓ | | MIPS64 Linux, n64 ABI, MUSL
+`mips64el-unknown-linux-gnuabi64` | ✓ | ✓ | MIPS64 (LE) Linux, n64 ABI (kernel 4.4, glibc 2.23)
+`mips64el-unknown-linux-muslabi64` | ✓ | | MIPS64 (LE) Linux, n64 ABI, MUSL
+`mipsel-unknown-linux-gnu` | ✓ | ✓ | MIPS (LE) Linux (kernel 4.4, glibc 2.23)
+`mipsel-unknown-linux-musl` | ✓ | | MIPS (LE) Linux with MUSL
+`nvptx64-nvidia-cuda` | ✓ | | --emit=asm generates PTX code that [runs on NVIDIA GPUs]
+`powerpc-unknown-linux-gnu` | ✓ | ✓ | PowerPC Linux (kernel 2.6.32, glibc 2.11)
+`powerpc64-unknown-linux-gnu` | ✓ | ✓ | PPC64 Linux (kernel 2.6.32, glibc 2.11)
+`powerpc64le-unknown-linux-gnu` | ✓ | ✓ | PPC64LE Linux (kernel 3.10, glibc 2.17)
+`riscv32i-unknown-none-elf` | * | | Bare RISC-V (RV32I ISA)
+`riscv32imac-unknown-none-elf` | * | | Bare RISC-V (RV32IMAC ISA)
+`riscv32imc-unknown-none-elf` | * | | Bare RISC-V (RV32IMC ISA)
+`riscv64gc-unknown-linux-gnu` | ✓ | ✓ | RISC-V Linux (kernel 4.20, glibc 2.29)
+`riscv64gc-unknown-none-elf` | * | | Bare RISC-V (RV64IMAFDC ISA)
+`riscv64imac-unknown-none-elf` | * | | Bare RISC-V (RV64IMAC ISA)
+`s390x-unknown-linux-gnu` | ✓ | ✓ | S390x Linux (kernel 2.6.32, glibc 2.11)
+`sparc64-unknown-linux-gnu` | ✓ | | SPARC Linux (kernel 4.4, glibc 2.23)
+`sparcv9-sun-solaris` | ✓ | | SPARC Solaris 10/11, illumos
+`thumbv6m-none-eabi` | * | | Bare Cortex-M0, M0+, M1
+`thumbv7em-none-eabi` | * | | Bare Cortex-M4, M7
+`thumbv7em-none-eabihf` | * | | Bare Cortex-M4F, M7F, FPU, hardfloat
+`thumbv7m-none-eabi` | * | | Bare Cortex-M3
+`thumbv7neon-linux-androideabi` | ✓ | | Thumb2-mode ARMv7a Android with NEON
+`thumbv7neon-unknown-linux-gnueabihf` | ✓ | | Thumb2-mode ARMv7a Linux with NEON (kernel 4.4, glibc 2.23)
+`thumbv8m.base-none-eabi` | * | | ARMv8-M Baseline
+`thumbv8m.main-none-eabi` | * | | ARMv8-M Mainline
+`thumbv8m.main-none-eabihf` | * | | ARMv8-M Baseline, hardfloat
+`wasm32-unknown-emscripten` | ✓ | | WebAssembly via Emscripten
+`wasm32-unknown-unknown` | ✓ | | WebAssembly
+`wasm32-wasi` | ✓ | | WebAssembly with WASI
+`x86_64-apple-ios` | ✓[^apple] | | 64-bit x86 iOS
+`x86_64-fortanix-unknown-sgx` | ✓ | | [Fortanix ABI] for 64-bit Intel SGX
+`x86_64-fuchsia` | ✓ | | 64-bit Fuchsia
+`x86_64-linux-android` | ✓ | | 64-bit x86 Android
+`x86_64-rumprun-netbsd` | ✓ | | 64-bit NetBSD Rump Kernel
+`x86_64-sun-solaris` | ✓ | | 64-bit Solaris 10/11, illumos
+`x86_64-unknown-cloudabi` | ✓ | | 64-bit CloudABI
+`x86_64-unknown-freebsd` | ✓ | ✓ | 64-bit FreeBSD
+`x86_64-unknown-illumos` | ✓ | ✓ | illumos
+`x86_64-unknown-linux-gnux32` | ✓ | | 64-bit Linux (x32 ABI) (kernel 4.15, glibc 2.27)
+`x86_64-unknown-linux-musl` | ✓ | ✓ | 64-bit Linux with MUSL
+`x86_64-unknown-netbsd` | ✓ | ✓ | NetBSD/amd64
+`x86_64-unknown-redox` | ✓ | | Redox OS
+
+[Fortanix ABI]: https://edp.fortanix.com/
+
+## Tier 3
+
+Tier 3 platforms are those which the Rust codebase has support for, but which
+are not built or tested automatically, and may not work. Official builds are
+not available.
+
+target | std | host | notes
+-------|-----|------|-------
+`aarch64-apple-darwin` | ? | | ARM64 macOS
+`aarch64-apple-tvos` | *[^apple] | | ARM64 tvOS
+`aarch64-unknown-cloudabi` | ✓ | | ARM64 CloudABI
+`aarch64-unknown-freebsd` | ✓ | ✓ | ARM64 FreeBSD
+`aarch64-unknown-hermit` | ? | |
+`aarch64-unknown-netbsd` | ? | |
+`aarch64-unknown-openbsd` | ✓ | ✓ | ARM64 OpenBSD
+`aarch64-unknown-redox` | ? | | ARM64 Redox OS
+`aarch64-uwp-windows-msvc` | ? | |
+`aarch64-wrs-vxworks` | ? | |
+`armv4t-unknown-linux-gnueabi` | ? | |
+`armv6-unknown-freebsd` | ✓ | ✓ | ARMv6 FreeBSD
+`armv6-unknown-netbsd-eabihf` | ? | |
+`armv7-apple-ios` | ✓[^apple] | | ARMv7 iOS, Cortex-a8
+`armv7-unknown-cloudabi-eabihf` | ✓ | | ARMv7 CloudABI, hardfloat
+`armv7-unknown-freebsd` | ✓ | ✓ | ARMv7 FreeBSD
+`armv7-unknown-netbsd-eabihf` | ? | |
+`armv7-wrs-vxworks-eabihf` | ? | |
+`armv7a-none-eabihf` | * | | ARM Cortex-A, hardfloat
+`armv7s-apple-ios` | ✓[^apple] | |
+`avr-unknown-unknown` | ? | | AVR
+`hexagon-unknown-linux-musl` | ? | |
+`i386-apple-ios` | ✓[^apple] | | 32-bit x86 iOS
+`i686-apple-darwin` | ✓ | ✓ | 32-bit OSX (10.7+, Lion+)
+`i686-pc-windows-msvc` | ✓ | | 32-bit Windows XP support
+`i686-unknown-cloudabi` | ✓ | | 32-bit CloudABI
+`i686-unknown-uefi` | ? | | 32-bit UEFI
+`i686-unknown-haiku` | ✓ | ✓ | 32-bit Haiku
+`i686-unknown-netbsd` | ✓ | | NetBSD/i386 with SSE2
+`i686-unknown-openbsd` | ✓ | ✓ | 32-bit OpenBSD
+`i686-uwp-windows-gnu` | ? | |
+`i686-uwp-windows-msvc` | ? | |
+`i686-wrs-vxworks` | ? | |
+`mips-unknown-linux-uclibc` | ✓ | | MIPS Linux with uClibc
+`mipsel-unknown-linux-uclibc` | ✓ | | MIPS (LE) Linux with uClibc
+`mipsel-sony-psp` | * | | MIPS (LE) Sony PlayStation Portable (PSP)
+`mipsisa32r6-unknown-linux-gnu` | ? | |
+`mipsisa32r6el-unknown-linux-gnu` | ? | |
+`mipsisa64r6-unknown-linux-gnuabi64` | ? | |
+`mipsisa64r6el-unknown-linux-gnuabi64` | ? | |
+`msp430-none-elf` | * | | 16-bit MSP430 microcontrollers
+`powerpc-unknown-linux-gnuspe` | ✓ | | PowerPC SPE Linux
+`powerpc-unknown-linux-musl` | ? | |
+`powerpc-unknown-netbsd` | ? | |
+`powerpc-wrs-vxworks` | ? | |
+`powerpc-wrs-vxworks-spe` | ? | |
+`powerpc64-unknown-freebsd` | ✓ | ✓ | PPC64 FreeBSD (ELFv1 and ELFv2)
+`powerpc64-unknown-linux-musl` | ? | |
+`powerpc64-wrs-vxworks` | ? | |
+`powerpc64le-unknown-linux-musl` | ? | |
+`sparc-unknown-linux-gnu` | ✓ | | 32-bit SPARC Linux
+`sparc64-unknown-netbsd` | ✓ | ✓ | NetBSD/sparc64
+`sparc64-unknown-openbsd` | ? | |
+`thumbv7a-pc-windows-msvc` | ? | |
+`thumbv7a-uwp-windows-msvc` | ✓ | |
+`thumbv7neon-unknown-linux-musleabihf` | ? | | Thumb2-mode ARMv7a Linux with NEON, MUSL
+`thumbv4t-none-eabi` | * | | ARMv4T T32
+`x86_64-apple-ios-macabi` | ✓[^apple] | | Apple Catalyst
+`x86_64-apple-tvos` | *[^apple] | | x86 64-bit tvOS
+`x86_64-linux-kernel` | ? | | Linux kernel modules
+`x86_64-pc-solaris` | ? | |
+`x86_64-pc-windows-msvc` | ✓ | | 64-bit Windows XP support
+`x86_64-unknown-dragonfly` | ✓ | ✓ | 64-bit DragonFlyBSD
+`x86_64-unknown-haiku` | ✓ | ✓ | 64-bit Haiku
+`x86_64-unknown-hermit` | ? | |
+`x86_64-unknown-hermit-kernel` | ? | | HermitCore kernel
+`x86_64-unknown-l4re-uclibc` | ? | |
+`x86_64-unknown-openbsd` | ✓ | ✓ | 64-bit OpenBSD
+`x86_64-unknown-uefi` | ? | |
+`x86_64-uwp-windows-gnu` | ✓ | |
+`x86_64-uwp-windows-msvc` | ✓ | |
+`x86_64-wrs-vxworks` | ? | |
+
+[runs on NVIDIA GPUs]: https://github.com/japaric-archived/nvptx#targets
+[^apple]: These targets are only available on macOS.
`rustc` ships with the ability to compile to many targets automatically, we
call these "built-in" targets, and they generally correspond to targets that
-the team is supporting directly.
+the team is supporting directly. To see the list of built-in targets, you can
+run `rustc --print target-list`.
-To see the list of built-in targets, you can run `rustc --print target-list`,
-or look at [the API
-docs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_target/spec/index.html#modules).
-Each module there defines a builder for a particular target.
\ No newline at end of file
+Typically, a target needs a compiled copy of the Rust standard library to
+work. If using [rustup], then check out the documentation on
+[Cross-compilation][rustup-cross] on how to download a pre-built standard
+library built by the official Rust distributions. Most targets will need a
+system linker, and possibly other things.
+
+[rustup]: https://github.com/rust-lang/rustup
+[rustup-cross]: https://github.com/rust-lang/rustup#cross-compilation
if sess.features_untracked().const_generics {
", then consts and types"
} else if sess.features_untracked().min_const_generics {
- ", then consts, then types"
+ ", then types, then consts"
} else {
", then types"
},
(llvm::CodeGenOptLevel::Default, ..) => {
llvm::LLVMPassManagerBuilderUseInlinerWithThreshold(builder, 225);
}
- (llvm::CodeGenOptLevel::Other, ..) => bug!("CodeGenOptLevel::Other selected"),
}
f(builder);
#[derive(Copy, Clone)]
#[repr(C)]
pub enum SynchronizationScope {
- // FIXME: figure out if this variant is needed at all.
- #[allow(dead_code)]
- Other,
SingleThread,
CrossThread,
}
impl SynchronizationScope {
pub fn from_generic(sc: rustc_codegen_ssa::common::SynchronizationScope) -> Self {
match sc {
- rustc_codegen_ssa::common::SynchronizationScope::Other => SynchronizationScope::Other,
rustc_codegen_ssa::common::SynchronizationScope::SingleThread => {
SynchronizationScope::SingleThread
}
#[derive(Copy, Clone)]
#[repr(C)]
pub enum FileType {
- // FIXME: figure out if this variant is needed at all.
- #[allow(dead_code)]
- Other,
AssemblyFile,
ObjectFile,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub enum AsmDialect {
- // FIXME: figure out if this variant is needed at all.
- #[allow(dead_code)]
- Other,
Att,
Intel,
}
#[derive(Copy, Clone, PartialEq)]
#[repr(C)]
pub enum CodeGenOptLevel {
- // FIXME: figure out if this variant is needed at all.
- #[allow(dead_code)]
- Other,
None,
Less,
Default,
#[derive(Copy, Clone)]
#[repr(C)]
pub enum ArchiveKind {
- // FIXME: figure out if this variant is needed at all.
- #[allow(dead_code)]
- Other,
K_GNU,
K_BSD,
K_DARWIN,
}
pub enum SynchronizationScope {
- // FIXME: figure out if this variant is needed at all.
- #[allow(dead_code)]
- Other,
SingleThread,
CrossThread,
}
```compile_fail,E0751
trait MyTrait {}
impl MyTrait for i32 { }
-impl !MyTrait for i32 { }
+impl !MyTrait for i32 { } // error!
```
-Negative implementations are a promise that the trait will never be
-implemented for the given types.
+Negative implementations are a promise that the trait will never be implemented
+for the given types. Therefore, both cannot exists at the same time.
use rustc_hir::PrimTy;
use rustc_session::config::nightly_options;
use rustc_span::hygiene::MacroKind;
-use rustc_span::symbol::{kw, sym, Ident};
-use rustc_span::{BytePos, Span};
+use rustc_span::symbol::{kw, sym, Ident, Symbol};
+use rustc_span::{BytePos, Span, DUMMY_SP};
use log::debug;
crate enum MissingLifetimeSpot<'tcx> {
Generics(&'tcx hir::Generics<'tcx>),
HigherRanked { span: Span, span_type: ForLifetimeSpanType },
+ Static,
}
crate enum ForLifetimeSpanType {
https://doc.rust-lang.org/nomicon/hrtb.html",
);
}
+ _ => {}
}
}
if nightly_options::is_nightly_build()
err: &mut DiagnosticBuilder<'_>,
span: Span,
count: usize,
- lifetime_names: &FxHashSet<Ident>,
+ lifetime_names: &FxHashSet<Symbol>,
+ lifetime_spans: Vec<Span>,
params: &[ElisionFailureInfo],
) {
let snippet = self.tcx.sess.source_map().span_to_snippet(span).ok();
),
);
- let suggest_existing = |err: &mut DiagnosticBuilder<'_>, sugg| {
+ let suggest_existing = |err: &mut DiagnosticBuilder<'_>,
+ name: &str,
+ formatter: &dyn Fn(&str) -> String| {
+ if let Some(MissingLifetimeSpot::HigherRanked { span: for_span, span_type }) =
+ self.missing_named_lifetime_spots.iter().rev().next()
+ {
+ // When we have `struct S<'a>(&'a dyn Fn(&X) -> &X);` we want to not only suggest
+ // using `'a`, but also introduce the concept of HRLTs by suggesting
+ // `struct S<'a>(&'a dyn for<'b> Fn(&X) -> &'b X);`. (#72404)
+ let mut introduce_suggestion = vec![];
+
+ let a_to_z_repeat_n = |n| {
+ (b'a'..=b'z').map(move |c| {
+ let mut s = '\''.to_string();
+ s.extend(std::iter::repeat(char::from(c)).take(n));
+ s
+ })
+ };
+
+ // If all single char lifetime names are present, we wrap around and double the chars.
+ let lt_name = (1..)
+ .flat_map(a_to_z_repeat_n)
+ .find(|lt| !lifetime_names.contains(&Symbol::intern(<)))
+ .unwrap();
+ let msg = format!(
+ "consider making the {} lifetime-generic with a new `{}` lifetime",
+ span_type.descr(),
+ lt_name,
+ );
+ err.note(
+ "for more information on higher-ranked polymorphism, visit \
+ https://doc.rust-lang.org/nomicon/hrtb.html",
+ );
+ let for_sugg = span_type.suggestion(<_name);
+ for param in params {
+ if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(param.span) {
+ if snippet.starts_with('&') && !snippet.starts_with("&'") {
+ introduce_suggestion
+ .push((param.span, format!("&{} {}", lt_name, &snippet[1..])));
+ } else if snippet.starts_with("&'_ ") {
+ introduce_suggestion
+ .push((param.span, format!("&{} {}", lt_name, &snippet[4..])));
+ }
+ }
+ }
+ introduce_suggestion.push((*for_span, for_sugg.to_string()));
+ introduce_suggestion.push((span, formatter(<_name)));
+ err.multipart_suggestion(&msg, introduce_suggestion, Applicability::MaybeIncorrect);
+ }
+
err.span_suggestion_verbose(
span,
&format!("consider using the `{}` lifetime", lifetime_names.iter().next().unwrap()),
- sugg,
+ formatter(name),
Applicability::MaybeIncorrect,
);
};
let should_break;
introduce_suggestion.push(match missing {
MissingLifetimeSpot::Generics(generics) => {
+ if generics.span == DUMMY_SP {
+ // Account for malformed generics in the HIR. This shouldn't happen,
+ // but if we make a mistake elsewhere, mainly by keeping something in
+ // `missing_named_lifetime_spots` that we shouldn't, like associated
+ // `const`s or making a mistake in the AST lowering we would provide
+ // non-sensical suggestions. Guard against that by skipping these.
+ // (#74264)
+ continue;
+ }
msg = "consider introducing a named lifetime parameter".to_string();
should_break = true;
if let Some(param) = generics.params.iter().find(|p| match p.kind {
);
(*span, span_type.suggestion("'a"))
}
+ MissingLifetimeSpot::Static => {
+ let (span, sugg) = match snippet.as_deref() {
+ Some("&") => (span.shrink_to_hi(), "'static ".to_owned()),
+ Some("'_") => (span, "'static".to_owned()),
+ Some(snippet) if !snippet.ends_with('>') => {
+ if snippet == "" {
+ (
+ span,
+ std::iter::repeat("'static")
+ .take(count)
+ .collect::<Vec<_>>()
+ .join(", "),
+ )
+ } else {
+ (
+ span.shrink_to_hi(),
+ format!(
+ "<{}>",
+ std::iter::repeat("'static")
+ .take(count)
+ .collect::<Vec<_>>()
+ .join(", ")
+ ),
+ )
+ }
+ }
+ _ => continue,
+ };
+ err.span_suggestion_verbose(
+ span,
+ "consider using the `'static` lifetime",
+ sugg.to_string(),
+ Applicability::MaybeIncorrect,
+ );
+ continue;
+ }
});
for param in params {
if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(param.span) {
}
};
- match (lifetime_names.len(), lifetime_names.iter().next(), snippet.as_deref()) {
- (1, Some(name), Some("&")) => {
- suggest_existing(err, format!("&{} ", name));
+ let lifetime_names: Vec<_> = lifetime_names.into_iter().collect();
+ match (&lifetime_names[..], snippet.as_deref()) {
+ ([name], Some("&")) => {
+ suggest_existing(err, &name.as_str()[..], &|name| format!("&{} ", name));
}
- (1, Some(name), Some("'_")) => {
- suggest_existing(err, name.to_string());
+ ([name], Some("'_")) => {
+ suggest_existing(err, &name.as_str()[..], &|n| n.to_string());
}
- (1, Some(name), Some("")) => {
- suggest_existing(err, format!("{}, ", name).repeat(count));
+ ([name], Some("")) => {
+ suggest_existing(err, &name.as_str()[..], &|n| format!("{}, ", n).repeat(count));
}
- (1, Some(name), Some(snippet)) if !snippet.ends_with('>') => {
- suggest_existing(
- err,
+ ([name], Some(snippet)) if !snippet.ends_with('>') => {
+ let f = |name: &str| {
format!(
"{}<{}>",
snippet,
.take(count)
.collect::<Vec<_>>()
.join(", ")
- ),
- );
+ )
+ };
+ suggest_existing(err, &name.as_str()[..], &f);
}
- (0, _, Some("&")) if count == 1 => {
+ ([], Some("&")) if count == 1 => {
suggest_new(err, "&'a ");
}
- (0, _, Some("'_")) if count == 1 => {
+ ([], Some("'_")) if count == 1 => {
suggest_new(err, "'a");
}
- (0, _, Some(snippet)) if !snippet.ends_with('>') && count == 1 => {
- suggest_new(err, &format!("{}<'a>", snippet));
+ ([], Some(snippet)) if !snippet.ends_with('>') => {
+ if snippet == "" {
+ // This happens when we have `type Bar<'a> = Foo<T>` where we point at the space
+ // before `T`. We will suggest `type Bar<'a> = Foo<'a, T>`.
+ suggest_new(
+ err,
+ &std::iter::repeat("'a, ").take(count).collect::<Vec<_>>().join(""),
+ );
+ } else {
+ suggest_new(
+ err,
+ &format!(
+ "{}<{}>",
+ snippet,
+ std::iter::repeat("'a").take(count).collect::<Vec<_>>().join(", ")
+ ),
+ );
+ }
}
- (n, ..) if n > 1 => {
- let spans: Vec<Span> = lifetime_names.iter().map(|lt| lt.span).collect();
- err.span_note(spans, "these named lifetimes are available to use");
+ (lts, ..) if lts.len() > 1 => {
+ err.span_note(lifetime_spans, "these named lifetimes are available to use");
if Some("") == snippet.as_deref() {
// This happens when we have `Foo<T>` where we point at the space before `T`,
// but this can be confusing so we give a suggestion with placeholders.
fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem<'tcx>) {
use self::hir::TraitItemKind::*;
- self.missing_named_lifetime_spots.push((&trait_item.generics).into());
match trait_item.kind {
Fn(ref sig, _) => {
+ self.missing_named_lifetime_spots.push((&trait_item.generics).into());
let tcx = self.tcx;
self.visit_early_late(
Some(tcx.hir().get_parent_item(trait_item.hir_id)),
&trait_item.generics,
|this| intravisit::walk_trait_item(this, trait_item),
);
+ self.missing_named_lifetime_spots.pop();
}
Type(bounds, ref ty) => {
+ self.missing_named_lifetime_spots.push((&trait_item.generics).into());
let generics = &trait_item.generics;
let mut index = self.next_early_index();
debug!("visit_ty: index = {}", index);
this.visit_ty(ty);
}
});
+ self.missing_named_lifetime_spots.pop();
}
Const(_, _) => {
// Only methods and types support generics.
assert!(trait_item.generics.params.is_empty());
+ self.missing_named_lifetime_spots.push(MissingLifetimeSpot::Static);
intravisit::walk_trait_item(self, trait_item);
+ self.missing_named_lifetime_spots.pop();
}
}
- self.missing_named_lifetime_spots.pop();
}
fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem<'tcx>) {
use self::hir::ImplItemKind::*;
- self.missing_named_lifetime_spots.push((&impl_item.generics).into());
match impl_item.kind {
Fn(ref sig, _) => {
+ self.missing_named_lifetime_spots.push((&impl_item.generics).into());
let tcx = self.tcx;
self.visit_early_late(
Some(tcx.hir().get_parent_item(impl_item.hir_id)),
&sig.decl,
&impl_item.generics,
|this| intravisit::walk_impl_item(this, impl_item),
- )
+ );
+ self.missing_named_lifetime_spots.pop();
}
TyAlias(ref ty) => {
let generics = &impl_item.generics;
+ self.missing_named_lifetime_spots.push(generics.into());
let mut index = self.next_early_index();
let mut non_lifetime_count = 0;
debug!("visit_ty: index = {}", index);
this.visit_generics(generics);
this.visit_ty(ty);
});
+ self.missing_named_lifetime_spots.pop();
}
Const(_, _) => {
// Only methods and types support generics.
assert!(impl_item.generics.params.is_empty());
+ self.missing_named_lifetime_spots.push(MissingLifetimeSpot::Static);
intravisit::walk_impl_item(self, impl_item);
+ self.missing_named_lifetime_spots.pop();
}
}
- self.missing_named_lifetime_spots.pop();
}
fn visit_lifetime(&mut self, lifetime_ref: &'tcx hir::Lifetime) {
let mut late_depth = 0;
let mut scope = self.scope;
let mut lifetime_names = FxHashSet::default();
+ let mut lifetime_spans = vec![];
let error = loop {
match *scope {
// Do not assign any resolution, it will be inferred.
// collect named lifetimes for suggestions
for name in lifetimes.keys() {
if let hir::ParamName::Plain(name) = name {
- lifetime_names.insert(*name);
+ lifetime_names.insert(name.name);
+ lifetime_spans.push(name.span);
}
}
late_depth += 1;
}
Elide::Exact(l) => l.shifted(late_depth),
Elide::Error(ref e) => {
- if let Scope::Binder { ref lifetimes, .. } = s {
- // collect named lifetimes for suggestions
- for name in lifetimes.keys() {
- if let hir::ParamName::Plain(name) = name {
- lifetime_names.insert(*name);
+ let mut scope = s;
+ loop {
+ match scope {
+ Scope::Binder { ref lifetimes, s, .. } => {
+ // Collect named lifetimes for suggestions.
+ for name in lifetimes.keys() {
+ if let hir::ParamName::Plain(name) = name {
+ lifetime_names.insert(name.name);
+ lifetime_spans.push(name.span);
+ }
+ }
+ scope = s;
+ }
+ Scope::ObjectLifetimeDefault { ref s, .. }
+ | Scope::Elision { ref s, .. } => {
+ scope = s;
}
+ _ => break,
}
}
break Some(e);
if let Some(params) = error {
// If there's no lifetime available, suggest `'static`.
if self.report_elision_failure(&mut err, params) && lifetime_names.is_empty() {
- lifetime_names.insert(Ident::with_dummy_span(kw::StaticLifetime));
+ lifetime_names.insert(kw::StaticLifetime);
}
}
self.add_missing_lifetime_specifiers_label(
span,
lifetime_refs.len(),
&lifetime_names,
+ lifetime_spans,
error.map(|p| &p[..]).unwrap_or(&[]),
);
err.emit();
{
fn encode<S: Encoder>(&self, e: &mut S) -> Result<(), S::Error> {
e.emit_map(self.len(), |e| {
- let mut i = 0;
- for (key, val) in self {
+ for (i, (key, val)) in self.iter().enumerate() {
e.emit_map_elt_key(i, |e| key.encode(e))?;
e.emit_map_elt_val(i, |e| val.encode(e))?;
- i += 1;
}
Ok(())
})
{
fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
s.emit_seq(self.len(), |s| {
- let mut i = 0;
- for e in self {
+ for (i, e) in self.iter().enumerate() {
s.emit_seq_elt(i, |s| e.encode(s))?;
- i += 1;
}
Ok(())
})
{
fn encode<E: Encoder>(&self, e: &mut E) -> Result<(), E::Error> {
e.emit_map(self.len(), |e| {
- let mut i = 0;
- for (key, val) in self {
+ for (i, (key, val)) in self.iter().enumerate() {
e.emit_map_elt_key(i, |e| key.encode(e))?;
e.emit_map_elt_val(i, |e| val.encode(e))?;
- i += 1;
}
Ok(())
})
{
fn encode<E: Encoder>(&self, s: &mut E) -> Result<(), E::Error> {
s.emit_seq(self.len(), |s| {
- let mut i = 0;
- for e in self {
+ for (i, e) in self.iter().enumerate() {
s.emit_seq_elt(i, |s| e.encode(s))?;
- i += 1;
}
Ok(())
})
{
fn encode<E: Encoder>(&self, e: &mut E) -> Result<(), E::Error> {
e.emit_map(self.len(), |e| {
- let mut i = 0;
- for (key, val) in self {
+ for (i, (key, val)) in self.iter().enumerate() {
e.emit_map_elt_key(i, |e| key.encode(e))?;
e.emit_map_elt_val(i, |e| val.encode(e))?;
- i += 1;
}
Ok(())
})
{
fn encode<E: Encoder>(&self, s: &mut E) -> Result<(), E::Error> {
s.emit_seq(self.len(), |s| {
- let mut i = 0;
- for e in self {
+ for (i, e) in self.iter().enumerate() {
s.emit_seq_elt(i, |s| e.encode(s))?;
- i += 1;
}
Ok(())
})
//! data_vector: Vec<u8>,
//! }
//!
-//! fn main() {
-//! let object = TestStruct {
-//! data_int: 1,
-//! data_str: "homura".to_string(),
-//! data_vector: vec![2,3,4,5],
-//! };
+//! let object = TestStruct {
+//! data_int: 1,
+//! data_str: "homura".to_string(),
+//! data_vector: vec![2,3,4,5],
+//! };
//!
-//! // Serialize using `json::encode`
-//! let encoded = json::encode(&object).unwrap();
+//! // Serialize using `json::encode`
+//! let encoded = json::encode(&object).unwrap();
//!
-//! // Deserialize using `json::decode`
-//! let decoded: TestStruct = json::decode(&encoded[..]).unwrap();
-//! }
+//! // Deserialize using `json::decode`
+//! let decoded: TestStruct = json::decode(&encoded[..]).unwrap();
//! ```
//!
//! ## Using the `ToJson` trait
//! val: Json,
//! }
//!
-//! fn main() {
-//! let num = ComplexNum { a: 0.0001, b: 12.539 };
-//! let data: String = json::encode(&ComplexNumRecord{
-//! uid: 1,
-//! dsc: "test".to_string(),
-//! val: num.to_json(),
-//! }).unwrap();
-//! println!("data: {}", data);
-//! // data: {"uid":1,"dsc":"test","val":"0.0001+12.539i"};
-//! }
+//! let num = ComplexNum { a: 0.0001, b: 12.539 };
+//! let data: String = json::encode(&ComplexNumRecord{
+//! uid: 1,
+//! dsc: "test".to_string(),
+//! val: num.to_json(),
+//! }).unwrap();
+//! println!("data: {}", data);
+//! // data: {"uid":1,"dsc":"test","val":"0.0001+12.539i"};
//! ```
//!
//! ### Verbose example of `ToJson` usage
//! }
//! }
//!
-//! fn main() {
-//! // Serialize using `ToJson`
-//! let input_data = TestStruct {
-//! data_int: 1,
-//! data_str: "madoka".to_string(),
-//! data_vector: vec![2,3,4,5],
-//! };
-//! let json_obj: Json = input_data.to_json();
-//! let json_str: String = json_obj.to_string();
+//! // Serialize using `ToJson`
+//! let input_data = TestStruct {
+//! data_int: 1,
+//! data_str: "madoka".to_string(),
+//! data_vector: vec![2,3,4,5],
+//! };
+//! let json_obj: Json = input_data.to_json();
+//! let json_str: String = json_obj.to_string();
//!
-//! // Deserialize like before
-//! let decoded: TestStruct = json::decode(&json_str).unwrap();
-//! }
+//! // Deserialize like before
+//! let decoded: TestStruct = json::decode(&json_str).unwrap();
//! ```
use self::DecoderError::*;
/// Returns `true` if the Json value is a `Number`.
pub fn is_number(&self) -> bool {
- match *self {
- Json::I64(_) | Json::U64(_) | Json::F64(_) => true,
- _ => false,
- }
+ matches!(*self, Json::I64(_) | Json::U64(_) | Json::F64(_))
}
/// Returns `true` if the Json value is a `i64`.
pub fn is_i64(&self) -> bool {
- match *self {
- Json::I64(_) => true,
- _ => false,
- }
+ matches!(*self, Json::I64(_))
}
/// Returns `true` if the Json value is a `u64`.
pub fn is_u64(&self) -> bool {
- match *self {
- Json::U64(_) => true,
- _ => false,
- }
+ matches!(*self, Json::U64(_))
}
/// Returns `true` if the Json value is a `f64`.
pub fn is_f64(&self) -> bool {
- match *self {
- Json::F64(_) => true,
- _ => false,
- }
+ matches!(*self, Json::F64(_))
}
/// If the Json value is a number, returns or cast it to a `i64`;
/// structure of the JSON stream.
///
/// An example is `foo.bar[3].x`.
+#[derive(Default)]
pub struct Stack {
stack: Vec<InternalStackElement>,
str_buffer: Vec<u8>,
impl Stack {
pub fn new() -> Stack {
- Stack { stack: Vec::new(), str_buffer: Vec::new() }
+ Self::default()
}
/// Returns The number of elements in the Stack.
// Used by Parser to test whether the top-most element is an index.
fn last_is_index(&self) -> bool {
- match self.stack.last() {
- Some(InternalIndex(_)) => true,
- _ => false,
- }
+ matches!(self.stack.last(), Some(InternalIndex(_)))
}
// Used by Parser to increment the index of the top-most element.
#[inline]
fn emit_f64(&mut self, v: f64) -> EncodeResult {
- let as_u64: u64 = unsafe { ::std::mem::transmute(v) };
+ let as_u64: u64 = v.to_bits();
self.emit_u64(as_u64)
}
#[inline]
fn emit_f32(&mut self, v: f32) -> EncodeResult {
- let as_u32: u32 = unsafe { ::std::mem::transmute(v) };
+ let as_u32: u32 = v.to_bits();
self.emit_u32(as_u32)
}
};
enum class LLVMRustArchiveKind {
- Other,
GNU,
BSD,
DARWIN,
}
enum class LLVMRustCodeGenOptLevel {
- Other,
None,
Less,
Default,
}
enum class LLVMRustFileType {
- Other,
AssemblyFile,
ObjectFile,
};
}
enum class LLVMRustSynchronizationScope {
- Other,
SingleThread,
CrossThread,
};
}
enum class LLVMRustAsmDialect {
- Other,
Att,
Intel,
};
| ^ expected named lifetime parameter
|
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
+ = note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html
+help: consider making the bound lifetime-generic with a new `'a` lifetime
+ |
+LL | fn elision<T: for<'a> Fn() -> &'a i32>() {
+ | ^^^^^^^ ^^^
help: consider using the `'static` lifetime
|
LL | fn elision<T: Fn() -> &'static i32>() {
| ^ expected named lifetime parameter
|
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
+ = note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html
+help: consider making the type lifetime-generic with a new `'a` lifetime
+ |
+LL | fn elision(_: for<'a> fn() -> &'a i32) {
+ | ^^^^^^^ ^^^
help: consider using the `'static` lifetime
|
LL | fn elision(_: fn() -> &'static i32) {
// check-pass
+// revisions: full min
-#![feature(const_generics)]
-//~^ WARN the feature `const_generics` is incomplete
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
trait Trait {}
+++ /dev/null
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/apit-with-const-param.rs:3:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-warning: 1 warning emitted
-
--- /dev/null
+error: constant expression depends on a generic parameter
+ --> $DIR/array-size-in-generic-struct-param.rs:9:38
+ |
+LL | struct ArithArrayLen<const N: usize>([u32; 0 + N]);
+ | ^^^^^^^^^^^^
+ |
+ = note: this may fail depending on what value the parameter takes
+
+error: constant expression depends on a generic parameter
+ --> $DIR/array-size-in-generic-struct-param.rs:20:10
+ |
+LL | arr: [u8; CFG.arr_size],
+ | ^^^^^^^^^^^^^^^^^^
+ |
+ = note: this may fail depending on what value the parameter takes
+
+error: aborting due to 2 previous errors
+
--- /dev/null
+error: generic parameters must not be used inside of non trivial constant values
+ --> $DIR/array-size-in-generic-struct-param.rs:9:48
+ |
+LL | struct ArithArrayLen<const N: usize>([u32; 0 + N]);
+ | ^ non-trivial anonymous constants must not depend on the parameter `N`
+ |
+ = help: it is currently only allowed to use either `N` or `{ N }` as generic constants
+
+error: generic parameters must not be used inside of non trivial constant values
+ --> $DIR/array-size-in-generic-struct-param.rs:20:15
+ |
+LL | arr: [u8; CFG.arr_size],
+ | ^^^ non-trivial anonymous constants must not depend on the parameter `CFG`
+ |
+ = help: it is currently only allowed to use either `CFG` or `{ CFG }` as generic constants
+
+error: using `Config` as const generic parameters is forbidden
+ --> $DIR/array-size-in-generic-struct-param.rs:18:21
+ |
+LL | struct B<const CFG: Config> {
+ | ^^^^^^
+ |
+ = note: the only supported types are integers, `bool` and `char`
+ = note: more complex types are supported with `#[feature(const_generics)]`
+
+error: aborting due to 3 previous errors
+
-#![feature(const_generics)]
-//~^ WARN the feature `const_generics` is incomplete
+// Tests that array sizes that depend on const-params are checked using `ConstEvaluatable`.
+// revisions: full min
+
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
#[allow(dead_code)]
struct ArithArrayLen<const N: usize>([u32; 0 + N]);
-//~^ ERROR constant expression depends on a generic parameter
+//[full]~^ ERROR constant expression depends on a generic parameter
+//[min]~^^ ERROR generic parameters must not be used inside of non trivial constant values
#[derive(PartialEq, Eq)]
struct Config {
}
struct B<const CFG: Config> {
- arr: [u8; CFG.arr_size], //~ ERROR constant expression depends on a generic parameter
+ //[min]~^ ERROR using `Config` as const generic parameters is forbidden
+ arr: [u8; CFG.arr_size],
+ //[full]~^ ERROR constant expression depends on a generic parameter
+ //[min]~^^ ERROR generic parameters must not be used inside of non trivial
}
const C: Config = Config { arr_size: 5 };
+++ /dev/null
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/array-size-in-generic-struct-param.rs:1:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-error: constant expression depends on a generic parameter
- --> $DIR/array-size-in-generic-struct-param.rs:5:38
- |
-LL | struct ArithArrayLen<const N: usize>([u32; 0 + N]);
- | ^^^^^^^^^^^^
- |
- = note: this may fail depending on what value the parameter takes
-
-error: constant expression depends on a generic parameter
- --> $DIR/array-size-in-generic-struct-param.rs:14:10
- |
-LL | arr: [u8; CFG.arr_size],
- | ^^^^^^^^^^^^^^^^^^
- |
- = note: this may fail depending on what value the parameter takes
-
-error: aborting due to 2 previous errors; 1 warning emitted
-
// run-pass
+// revisions: full min
-#![feature(const_generics)]
-//~^ WARN the feature `const_generics` is incomplete
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
pub trait Foo {
fn foo(&self);
+++ /dev/null
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/broken-mir-1.rs:3:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-warning: 1 warning emitted
-
// run-pass
+// revisions: full min
-#![feature(const_generics)]
-//~^ WARN the feature `const_generics` is incomplete
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
use std::fmt::Debug;
+++ /dev/null
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/broken-mir-2.rs:3:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-warning: 1 warning emitted
-
--- /dev/null
+error[E0282]: type annotations needed
+ --> $DIR/cannot-infer-const-args.rs:12:5
+ |
+LL | foo();
+ | ^^^
+ |
+ = note: unable to infer the value of a const parameter
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0282`.
--- /dev/null
+error[E0282]: type annotations needed
+ --> $DIR/cannot-infer-const-args.rs:12:5
+ |
+LL | foo();
+ | ^^^
+ |
+ = note: unable to infer the value of a const parameter
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0282`.
-#![feature(const_generics)]
-//~^ WARN the feature `const_generics` is incomplete
+// revisions: full min
+
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
fn foo<const X: usize>() -> usize {
0
+++ /dev/null
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/cannot-infer-const-args.rs:1:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-error[E0282]: type annotations needed
- --> $DIR/cannot-infer-const-args.rs:9:5
- |
-LL | foo();
- | ^^^
- |
- = note: unable to infer the value of a const parameter
-
-error: aborting due to previous error; 1 warning emitted
-
-For more information about this error, try `rustc --explain E0282`.
// run-pass
-#![feature(const_generics)]
-#![allow(incomplete_features)]
+// revisions: full min
+
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
fn foo<const N: usize>(v: &[u8; N]) -> &[u8] {
v
// Test that a concrete const type i.e. A<2>, can be used as an argument type in a function
// run-pass
+// revisions: full min
-#![feature(const_generics)]
-//~^ WARN the feature `const_generics` is incomplete
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
struct A<const N: usize>; // ok
+++ /dev/null
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/concrete-const-as-fn-arg.rs:4:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-warning: 1 warning emitted
-
// Test that a method/associated non-method within an impl block of a concrete const type i.e. A<2>,
// is callable.
// run-pass
+// revisions: full min
-#![feature(const_generics)]
-//~^ WARN the feature `const_generics` is incomplete
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
pub struct A<const N: u32>;
+++ /dev/null
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/concrete-const-impl-method.rs:5:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-warning: 1 warning emitted
-
+// Checks that `impl Trait<{anon_const}> for Type` evaluates successfully.
// run-pass
+// revisions: full min
-#![feature(const_generics)]
-//~^ WARN the feature `const_generics` is incomplete
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
trait IsZeroTrait<const IS_ZERO: bool>{}
+++ /dev/null
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/condition-in-trait-const-arg.rs:3:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-warning: 1 warning emitted
-
// run-pass
+// revisions: full min
-#![feature(const_generics)]
-//~^ WARN the feature `const_generics` is incomplete
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
fn const_u32_identity<const X: u32>() -> u32 {
X
+++ /dev/null
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/const-arg-in-fn.rs:3:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-warning: 1 warning emitted
-
// run-pass
+// revisions: full
+// FIXME(#75323) Omitted min revision for now due to ICE.
-#![feature(const_generics)]
-//~^ WARN the feature `const_generics` is incomplete
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
#![allow(dead_code)]
fn test<const N: usize>() {}
+++ /dev/null
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/const-argument-non-static-lifetime.rs:3:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-warning: 1 warning emitted
-
--- /dev/null
+error: expected one of `,` or `>`, found `+`
+ --> $DIR/const-expression-parameter.rs:16:22
+ |
+LL | i32_identity::<1 + 2>();
+ | ^ expected one of `,` or `>`
+
+error: aborting due to previous error
+
--- /dev/null
+error: expected one of `,` or `>`, found `+`
+ --> $DIR/const-expression-parameter.rs:16:22
+ |
+LL | i32_identity::<1 + 2>();
+ | ^ expected one of `,` or `>`
+
+error: aborting due to previous error
+
-#![feature(const_generics)]
-//~^ WARN the feature `const_generics` is incomplete
+// revisions: full min
+
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
fn i32_identity<const X: i32>() -> i32 {
5
+++ /dev/null
-error: expected one of `,` or `>`, found `+`
- --> $DIR/const-expression-parameter.rs:13:22
- |
-LL | i32_identity::<1 + 2>();
- | ^ expected one of `,` or `>`
-
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/const-expression-parameter.rs:1:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-error: aborting due to previous error; 1 warning emitted
-
+// Checks that `const fn` with const params can be used.
// run-pass
-#![feature(const_generics)]
-//~^ WARN the feature `const_generics` is incomplete
+// revisions: full min
+
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
const fn const_u32_identity<const X: u32>() -> u32 {
X
+++ /dev/null
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/const-fn-with-const-param.rs:2:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-warning: 1 warning emitted
-
// run-pass
+// revisions: full min
-#![feature(const_generics)]
-//~^ WARN the feature `const_generics` is incomplete
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
struct Foo<T, const N: usize>([T; N]);
+++ /dev/null
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/const-generic-array-wrapper.rs:3:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-warning: 1 warning emitted
-
// run-pass
+// revisions: full min
-#![feature(const_generics)]
-//~^ WARN the feature `const_generics` is incomplete
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
#[derive(Debug)]
struct S<const N: usize>;
+++ /dev/null
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/const-generic-type_name.rs:3:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-warning: 1 warning emitted
-
// check-pass
+// revisions: full min
-#![allow(incomplete_features)]
-#![feature(const_generics)]
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
struct Foo<const A: usize, const B: usize>;
--- /dev/null
+error[E0637]: `&` without an explicit lifetime name cannot be used here
+ --> $DIR/const-param-elided-lifetime.rs:11:19
+ |
+LL | struct A<const N: &u8>;
+ | ^ explicit lifetime name needed here
+
+error[E0637]: `&` without an explicit lifetime name cannot be used here
+ --> $DIR/const-param-elided-lifetime.rs:16:15
+ |
+LL | impl<const N: &u8> A<N> {
+ | ^ explicit lifetime name needed here
+
+error[E0637]: `&` without an explicit lifetime name cannot be used here
+ --> $DIR/const-param-elided-lifetime.rs:19:21
+ |
+LL | fn foo<const M: &u8>(&self) {}
+ | ^ explicit lifetime name needed here
+
+error[E0637]: `&` without an explicit lifetime name cannot be used here
+ --> $DIR/const-param-elided-lifetime.rs:24:15
+ |
+LL | impl<const N: &u8> B for A<N> {}
+ | ^ explicit lifetime name needed here
+
+error[E0637]: `&` without an explicit lifetime name cannot be used here
+ --> $DIR/const-param-elided-lifetime.rs:28:17
+ |
+LL | fn bar<const N: &u8>() {}
+ | ^ explicit lifetime name needed here
+
+error: aborting due to 5 previous errors
+
+For more information about this error, try `rustc --explain E0637`.
--- /dev/null
+error[E0637]: `&` without an explicit lifetime name cannot be used here
+ --> $DIR/const-param-elided-lifetime.rs:11:19
+ |
+LL | struct A<const N: &u8>;
+ | ^ explicit lifetime name needed here
+
+error[E0637]: `&` without an explicit lifetime name cannot be used here
+ --> $DIR/const-param-elided-lifetime.rs:16:15
+ |
+LL | impl<const N: &u8> A<N> {
+ | ^ explicit lifetime name needed here
+
+error[E0637]: `&` without an explicit lifetime name cannot be used here
+ --> $DIR/const-param-elided-lifetime.rs:19:21
+ |
+LL | fn foo<const M: &u8>(&self) {}
+ | ^ explicit lifetime name needed here
+
+error[E0637]: `&` without an explicit lifetime name cannot be used here
+ --> $DIR/const-param-elided-lifetime.rs:24:15
+ |
+LL | impl<const N: &u8> B for A<N> {}
+ | ^ explicit lifetime name needed here
+
+error[E0637]: `&` without an explicit lifetime name cannot be used here
+ --> $DIR/const-param-elided-lifetime.rs:28:17
+ |
+LL | fn bar<const N: &u8>() {}
+ | ^ explicit lifetime name needed here
+
+error: using `&'static u8` as const generic parameters is forbidden
+ --> $DIR/const-param-elided-lifetime.rs:11:19
+ |
+LL | struct A<const N: &u8>;
+ | ^^^
+ |
+ = note: the only supported types are integers, `bool` and `char`
+ = note: more complex types are supported with `#[feature(const_generics)]`
+
+error: using `&'static u8` as const generic parameters is forbidden
+ --> $DIR/const-param-elided-lifetime.rs:16:15
+ |
+LL | impl<const N: &u8> A<N> {
+ | ^^^
+ |
+ = note: the only supported types are integers, `bool` and `char`
+ = note: more complex types are supported with `#[feature(const_generics)]`
+
+error: using `&'static u8` as const generic parameters is forbidden
+ --> $DIR/const-param-elided-lifetime.rs:24:15
+ |
+LL | impl<const N: &u8> B for A<N> {}
+ | ^^^
+ |
+ = note: the only supported types are integers, `bool` and `char`
+ = note: more complex types are supported with `#[feature(const_generics)]`
+
+error: using `&'static u8` as const generic parameters is forbidden
+ --> $DIR/const-param-elided-lifetime.rs:28:17
+ |
+LL | fn bar<const N: &u8>() {}
+ | ^^^
+ |
+ = note: the only supported types are integers, `bool` and `char`
+ = note: more complex types are supported with `#[feature(const_generics)]`
+
+error: using `&'static u8` as const generic parameters is forbidden
+ --> $DIR/const-param-elided-lifetime.rs:19:21
+ |
+LL | fn foo<const M: &u8>(&self) {}
+ | ^^^
+ |
+ = note: the only supported types are integers, `bool` and `char`
+ = note: more complex types are supported with `#[feature(const_generics)]`
+
+error: aborting due to 10 previous errors
+
+For more information about this error, try `rustc --explain E0637`.
// behaviour of trait bounds where `fn foo<T: Ord<&u8>>() {}` is illegal. Though we could change
// elided lifetimes within the type of a const generic parameters to be 'static, like elided
// lifetimes within const/static items.
+// revisions: full min
-#![feature(const_generics)]
-//~^ WARN the feature `const_generics` is incomplete
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
struct A<const N: &u8>;
//~^ ERROR `&` without an explicit lifetime name cannot be used here
+//[min]~^^ ERROR using `&'static u8` as const generic parameters is forbidden
trait B {}
-impl<const N: &u8> A<N> { //~ ERROR `&` without an explicit lifetime name cannot be used here
+impl<const N: &u8> A<N> {
+//~^ ERROR `&` without an explicit lifetime name cannot be used here
+//[min]~^^ ERROR using `&'static u8` as const generic parameters is forbidden
fn foo<const M: &u8>(&self) {}
//~^ ERROR `&` without an explicit lifetime name cannot be used here
+ //[min]~^^ ERROR using `&'static u8` as const generic parameters is forbidden
}
impl<const N: &u8> B for A<N> {}
//~^ ERROR `&` without an explicit lifetime name cannot be used here
+//[min]~^^ ERROR using `&'static u8` as const generic parameters is forbidden
fn bar<const N: &u8>() {}
//~^ ERROR `&` without an explicit lifetime name cannot be used here
+//[min]~^^ ERROR using `&'static u8` as const generic parameters is forbidden
fn main() {}
+++ /dev/null
-error[E0637]: `&` without an explicit lifetime name cannot be used here
- --> $DIR/const-param-elided-lifetime.rs:9:19
- |
-LL | struct A<const N: &u8>;
- | ^ explicit lifetime name needed here
-
-error[E0637]: `&` without an explicit lifetime name cannot be used here
- --> $DIR/const-param-elided-lifetime.rs:13:15
- |
-LL | impl<const N: &u8> A<N> {
- | ^ explicit lifetime name needed here
-
-error[E0637]: `&` without an explicit lifetime name cannot be used here
- --> $DIR/const-param-elided-lifetime.rs:14:21
- |
-LL | fn foo<const M: &u8>(&self) {}
- | ^ explicit lifetime name needed here
-
-error[E0637]: `&` without an explicit lifetime name cannot be used here
- --> $DIR/const-param-elided-lifetime.rs:18:15
- |
-LL | impl<const N: &u8> B for A<N> {}
- | ^ explicit lifetime name needed here
-
-error[E0637]: `&` without an explicit lifetime name cannot be used here
- --> $DIR/const-param-elided-lifetime.rs:21:17
- |
-LL | fn bar<const N: &u8>() {}
- | ^ explicit lifetime name needed here
-
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/const-param-elided-lifetime.rs:6:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-error: aborting due to 5 previous errors; 1 warning emitted
-
-For more information about this error, try `rustc --explain E0637`.
--- /dev/null
+error[E0401]: can't use generic parameters from outer function
+ --> $DIR/const-param-from-outer-fn.rs:9:9
+ |
+LL | fn foo<const X: u32>() {
+ | - const parameter from outer function
+LL | fn bar() -> u32 {
+ | --- try adding a local generic parameter in this method instead
+LL | X
+ | ^ use of generic parameter from outer function
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0401`.
--- /dev/null
+error[E0401]: can't use generic parameters from outer function
+ --> $DIR/const-param-from-outer-fn.rs:9:9
+ |
+LL | fn foo<const X: u32>() {
+ | - const parameter from outer function
+LL | fn bar() -> u32 {
+ | --- try adding a local generic parameter in this method instead
+LL | X
+ | ^ use of generic parameter from outer function
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0401`.
-#![feature(const_generics)]
-//~^ WARN the feature `const_generics` is incomplete
+// revisions: full min
+
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
fn foo<const X: u32>() {
fn bar() -> u32 {
+++ /dev/null
-error[E0401]: can't use generic parameters from outer function
- --> $DIR/const-param-from-outer-fn.rs:6:9
- |
-LL | fn foo<const X: u32>() {
- | - const parameter from outer function
-LL | fn bar() -> u32 {
- | --- try adding a local generic parameter in this method instead
-LL | X
- | ^ use of generic parameter from outer function
-
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/const-param-from-outer-fn.rs:1:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-error: aborting due to previous error; 1 warning emitted
-
-For more information about this error, try `rustc --explain E0401`.
+// Check that const parameters are permitted in traits.
// run-pass
+// revisions: full min
-#![feature(const_generics)]
-//~^ WARN the feature `const_generics` is incomplete
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
-trait Trait<const T: ()> {}
+
+trait Trait<const T: u8> {}
fn main() {}
+++ /dev/null
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/const-param-in-trait.rs:3:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-warning: 1 warning emitted
-
--- /dev/null
+error[E0770]: the type of const parameters must not depend on other generic parameters
+ --> $DIR/const-param-type-depends-on-const-param.rs:12:52
+ |
+LL | pub struct Dependent<const N: usize, const X: [u8; N]>([(); N]);
+ | ^ the type must not depend on the parameter `N`
+
+error[E0770]: the type of const parameters must not depend on other generic parameters
+ --> $DIR/const-param-type-depends-on-const-param.rs:16:40
+ |
+LL | pub struct SelfDependent<const N: [u8; N]>;
+ | ^ the type must not depend on the parameter `N`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0770`.
--- /dev/null
+error[E0770]: the type of const parameters must not depend on other generic parameters
+ --> $DIR/const-param-type-depends-on-const-param.rs:12:52
+ |
+LL | pub struct Dependent<const N: usize, const X: [u8; N]>([(); N]);
+ | ^ the type must not depend on the parameter `N`
+
+error[E0770]: the type of const parameters must not depend on other generic parameters
+ --> $DIR/const-param-type-depends-on-const-param.rs:16:40
+ |
+LL | pub struct SelfDependent<const N: [u8; N]>;
+ | ^ the type must not depend on the parameter `N`
+
+error: using `[u8; _]` as const generic parameters is forbidden
+ --> $DIR/const-param-type-depends-on-const-param.rs:12:47
+ |
+LL | pub struct Dependent<const N: usize, const X: [u8; N]>([(); N]);
+ | ^^^^^^^
+ |
+ = note: the only supported types are integers, `bool` and `char`
+ = note: more complex types are supported with `#[feature(const_generics)]`
+
+error: using `[u8; _]` as const generic parameters is forbidden
+ --> $DIR/const-param-type-depends-on-const-param.rs:16:35
+ |
+LL | pub struct SelfDependent<const N: [u8; N]>;
+ | ^^^^^^^
+ |
+ = note: the only supported types are integers, `bool` and `char`
+ = note: more complex types are supported with `#[feature(const_generics)]`
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0770`.
-#![feature(const_generics)]
-//~^ WARN the feature `const_generics` is incomplete
+// revisions: full min
+
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
// Currently, const parameters cannot depend on other generic parameters,
// as our current implementation can't really support this.
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 using `[u8; _]` as const generic parameters is forbidden
pub struct SelfDependent<const N: [u8; N]>;
//~^ ERROR: the type of const parameters must not depend on other generic parameters
+//[min]~^^ ERROR using `[u8; _]` as const generic parameters is forbidden
fn main() {}
+++ /dev/null
-error[E0770]: the type of const parameters must not depend on other generic parameters
- --> $DIR/const-param-type-depends-on-const-param.rs:9:52
- |
-LL | pub struct Dependent<const N: usize, const X: [u8; N]>([(); N]);
- | ^ the type must not depend on the parameter `N`
-
-error[E0770]: the type of const parameters must not depend on other generic parameters
- --> $DIR/const-param-type-depends-on-const-param.rs:12:40
- |
-LL | pub struct SelfDependent<const N: [u8; N]>;
- | ^ the type must not depend on the parameter `N`
-
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/const-param-type-depends-on-const-param.rs:1:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-error: aborting due to 2 previous errors; 1 warning emitted
-
-For more information about this error, try `rustc --explain E0770`.
--- /dev/null
+error[E0770]: the type of const parameters must not depend on other generic parameters
+ --> $DIR/const-param-type-depends-on-type-param.rs:12:34
+ |
+LL | pub struct Dependent<T, const X: T>([(); X]);
+ | ^ the type must not depend on the parameter `T`
+
+error[E0392]: parameter `T` is never used
+ --> $DIR/const-param-type-depends-on-type-param.rs:12:22
+ |
+LL | pub struct Dependent<T, const X: T>([(); X]);
+ | ^ unused parameter
+ |
+ = help: consider removing `T`, referring to it in a field, or using a marker such as `std::marker::PhantomData`
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0392, E0770.
+For more information about an error, try `rustc --explain E0392`.
--- /dev/null
+error[E0770]: the type of const parameters must not depend on other generic parameters
+ --> $DIR/const-param-type-depends-on-type-param.rs:12:34
+ |
+LL | pub struct Dependent<T, const X: T>([(); X]);
+ | ^ the type must not depend on the parameter `T`
+
+error[E0392]: parameter `T` is never used
+ --> $DIR/const-param-type-depends-on-type-param.rs:12:22
+ |
+LL | pub struct Dependent<T, const X: T>([(); X]);
+ | ^ unused parameter
+ |
+ = help: consider removing `T`, referring to it in a field, or using a marker such as `std::marker::PhantomData`
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0392, E0770.
+For more information about an error, try `rustc --explain E0392`.
-#![feature(const_generics)]
-//~^ WARN the feature `const_generics` is incomplete
+// revisions: full min
+
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
// Currently, const parameters cannot depend on other generic parameters,
// as our current implementation can't really support this.
+++ /dev/null
-error[E0770]: the type of const parameters must not depend on other generic parameters
- --> $DIR/const-param-type-depends-on-type-param.rs:9:34
- |
-LL | pub struct Dependent<T, const X: T>([(); X]);
- | ^ the type must not depend on the parameter `T`
-
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/const-param-type-depends-on-type-param.rs:1:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-error[E0392]: parameter `T` is never used
- --> $DIR/const-param-type-depends-on-type-param.rs:9:22
- |
-LL | pub struct Dependent<T, const X: T>([(); X]);
- | ^ unused parameter
- |
- = help: consider removing `T`, referring to it in a field, or using a marker such as `std::marker::PhantomData`
-
-error: aborting due to 2 previous errors; 1 warning emitted
-
-Some errors have detailed explanations: E0392, E0770.
-For more information about an error, try `rustc --explain E0392`.
--- /dev/null
+error: const parameter `x` should have an upper case name
+ --> $DIR/const-parameter-uppercase-lint.rs:9:15
+ |
+LL | fn noop<const x: u32>() {
+ | ^ help: convert the identifier to upper case (notice the capitalization): `X`
+ |
+note: the lint level is defined here
+ --> $DIR/const-parameter-uppercase-lint.rs:7:9
+ |
+LL | #![deny(non_upper_case_globals)]
+ | ^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+error: const parameter `x` should have an upper case name
+ --> $DIR/const-parameter-uppercase-lint.rs:9:15
+ |
+LL | fn noop<const x: u32>() {
+ | ^ help: convert the identifier to upper case (notice the capitalization): `X`
+ |
+note: the lint level is defined here
+ --> $DIR/const-parameter-uppercase-lint.rs:7:9
+ |
+LL | #![deny(non_upper_case_globals)]
+ | ^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
-#![feature(const_generics)]
-//~^ WARN the feature `const_generics` is incomplete
+// revisions: full min
+
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
#![deny(non_upper_case_globals)]
+++ /dev/null
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/const-parameter-uppercase-lint.rs:1:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-error: const parameter `x` should have an upper case name
- --> $DIR/const-parameter-uppercase-lint.rs:6:15
- |
-LL | fn noop<const x: u32>() {
- | ^ help: convert the identifier to upper case (notice the capitalization): `X`
- |
-note: the lint level is defined here
- --> $DIR/const-parameter-uppercase-lint.rs:4:9
- |
-LL | #![deny(non_upper_case_globals)]
- | ^^^^^^^^^^^^^^^^^^^^^^
-
-error: aborting due to previous error; 1 warning emitted
-
+// Check that arrays can be used with generic const and type.
// run-pass
+// revisions: full min
-#![feature(const_generics)]
-//~^ WARN the feature `const_generics` is incomplete
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
#![allow(dead_code, unused_variables)]
+++ /dev/null
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/const-types.rs:3:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-warning: 1 warning emitted
-
--> $DIR/needs-feature.rs:10:26
|
LL | struct A<const N: usize, T=u32>(T);
- | -----------------^----- help: reorder the parameters: lifetimes, then consts, then types: `<T, const N: usize>`
+ | -----------------^----- help: reorder the parameters: lifetimes, then types, then consts: `<T, const N: usize>`
error: aborting due to previous error
+// Check that deriving debug on struct with const is permitted.
// run-pass
+// revisions: full min
-#![feature(const_generics)]
-//~^ WARN the feature `const_generics` is incomplete
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
#[derive(Debug)]
struct X<const N: usize> {
+++ /dev/null
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/derive-debug-array-wrapper.rs:3:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-warning: 1 warning emitted
-
--- /dev/null
+error[E0308]: mismatched types
+ --> $DIR/different_byref.rs:13:9
+ |
+LL | x = Const::<{ [4] }> {};
+ | ^^^^^^^^^^^^^^^^^^^ expected `3_usize`, found `4_usize`
+ |
+ = note: expected type `[3_usize]`
+ found type `[4_usize]`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
--- /dev/null
+error: using `[usize; 1]` as const generic parameters is forbidden
+ --> $DIR/different_byref.rs:8:23
+ |
+LL | struct Const<const V: [usize; 1]> {}
+ | ^^^^^^^^^^
+ |
+ = note: the only supported types are integers, `bool` and `char`
+ = note: more complex types are supported with `#[feature(const_generics)]`
+
+error: aborting due to previous error
+
-#![feature(const_generics)]
-//~^ WARN the feature `const_generics` is incomplete
+// Check that different const types are different.
+// revisions: full min
+
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
struct Const<const V: [usize; 1]> {}
+//[min]~^ using `[usize; 1]` as const generic parameters is forbidden
fn main() {
let mut x = Const::<{ [3] }> {};
x = Const::<{ [4] }> {};
- //~^ ERROR mismatched types
-
+ //[full]~^ ERROR mismatched types
}
+++ /dev/null
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/different_byref.rs:1:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-error[E0308]: mismatched types
- --> $DIR/different_byref.rs:8:9
- |
-LL | x = Const::<{ [4] }> {};
- | ^^^^^^^^^^^^^^^^^^^ expected `3_usize`, found `4_usize`
- |
- = note: expected type `[3_usize]`
- found type `[4_usize]`
-
-error: aborting due to previous error; 1 warning emitted
-
-For more information about this error, try `rustc --explain E0308`.
--- /dev/null
+error[E0308]: mismatched types
+ --> $DIR/different_byref_simple.rs:12:9
+ |
+LL | u = ConstUsize::<4> {};
+ | ^^^^^^^^^^^^^^^^^^ expected `3_usize`, found `4_usize`
+ |
+ = note: expected struct `ConstUsize<3_usize>`
+ found struct `ConstUsize<4_usize>`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
--- /dev/null
+error[E0308]: mismatched types
+ --> $DIR/different_byref_simple.rs:12:9
+ |
+LL | u = ConstUsize::<4> {};
+ | ^^^^^^^^^^^^^^^^^^ expected `3_usize`, found `4_usize`
+ |
+ = note: expected struct `ConstUsize<3_usize>`
+ found struct `ConstUsize<4_usize>`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
--- /dev/null
+// Check that different const types are different.
+// revisions: full min
+
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
+
+struct ConstUsize<const V: usize> {}
+
+fn main() {
+ let mut u = ConstUsize::<3> {};
+ u = ConstUsize::<4> {};
+ //~^ ERROR mismatched types
+}
--- /dev/null
+error: using function pointers as const generic parameters is forbidden
+ --> $DIR/fn-const-param-call.rs:12:25
+ |
+LL | struct Wrapper<const F: fn() -> u32>;
+ | ^^^^^^^^^^^
+
+error: using function pointers as const generic parameters is forbidden
+ --> $DIR/fn-const-param-call.rs:14:15
+ |
+LL | impl<const F: fn() -> u32> Wrapper<F> {
+ | ^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
--- /dev/null
+error: using function pointers as const generic parameters is forbidden
+ --> $DIR/fn-const-param-call.rs:12:25
+ |
+LL | struct Wrapper<const F: fn() -> u32>;
+ | ^^^^^^^^^^^
+ |
+ = note: the only supported types are integers, `bool` and `char`
+ = note: more complex types are supported with `#[feature(const_generics)]`
+
+error: using function pointers as const generic parameters is forbidden
+ --> $DIR/fn-const-param-call.rs:14:15
+ |
+LL | impl<const F: fn() -> u32> Wrapper<F> {
+ | ^^^^^^^^^^^
+ |
+ = note: the only supported types are integers, `bool` and `char`
+ = note: more complex types are supported with `#[feature(const_generics)]`
+
+error: aborting due to 2 previous errors
+
-#![feature(const_generics)]
-//~^ WARN the feature `const_generics` is incomplete
+// Check that functions cannot be used as const parameters.
+// revisions: full min
+
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
fn function() -> u32 {
17
+++ /dev/null
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/fn-const-param-call.rs:1:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-error: using function pointers as const generic parameters is forbidden
- --> $DIR/fn-const-param-call.rs:8:25
- |
-LL | struct Wrapper<const F: fn() -> u32>;
- | ^^^^^^^^^^^
-
-error: using function pointers as const generic parameters is forbidden
- --> $DIR/fn-const-param-call.rs:10:15
- |
-LL | impl<const F: fn() -> u32> Wrapper<F> {
- | ^^^^^^^^^^^
-
-error: aborting due to 2 previous errors; 1 warning emitted
-
--- /dev/null
+error: using function pointers as const generic parameters is forbidden
+ --> $DIR/fn-const-param-infer.rs:7:25
+ |
+LL | struct Checked<const F: fn(usize) -> bool>;
+ | ^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+error: using function pointers as const generic parameters is forbidden
+ --> $DIR/fn-const-param-infer.rs:7:25
+ |
+LL | struct Checked<const F: fn(usize) -> bool>;
+ | ^^^^^^^^^^^^^^^^^
+ |
+ = note: the only supported types are integers, `bool` and `char`
+ = note: more complex types are supported with `#[feature(const_generics)]`
+
+error: aborting due to previous error
+
-#![feature(const_generics)]
-//~^ WARN the feature `const_generics` is incomplete
+// revisions: full min
+
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
struct Checked<const F: fn(usize) -> bool>;
//~^ ERROR: using function pointers as const generic parameters
+++ /dev/null
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/fn-const-param-infer.rs:1:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-error: using function pointers as const generic parameters is forbidden
- --> $DIR/fn-const-param-infer.rs:4:25
- |
-LL | struct Checked<const F: fn(usize) -> bool>;
- | ^^^^^^^^^^^^^^^^^
-
-error: aborting due to previous error; 1 warning emitted
-
// run-pass
+// revisions: full min
-#![feature(const_generics)]
-//~^ WARN the feature `const_generics` is incomplete
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
use std::fmt::Display;
+++ /dev/null
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/fn-taking-const-generic-array.rs:3:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-warning: 1 warning emitted
-
--- /dev/null
+error[E0741]: `C` must be annotated with `#[derive(PartialEq, Eq)]` to be used as the type of a const parameter
+ --> $DIR/forbid-non-structural_match-types.rs:15:19
+ |
+LL | struct D<const X: C>;
+ | ^ `C` doesn't derive both `PartialEq` and `Eq`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0741`.
--- /dev/null
+error: using `A` as const generic parameters is forbidden
+ --> $DIR/forbid-non-structural_match-types.rs:10:19
+ |
+LL | struct B<const X: A>; // ok
+ | ^
+ |
+ = note: the only supported types are integers, `bool` and `char`
+ = note: more complex types are supported with `#[feature(const_generics)]`
+
+error: using `C` as const generic parameters is forbidden
+ --> $DIR/forbid-non-structural_match-types.rs:15:19
+ |
+LL | struct D<const X: C>;
+ | ^
+ |
+ = note: the only supported types are integers, `bool` and `char`
+ = note: more complex types are supported with `#[feature(const_generics)]`
+
+error[E0741]: `C` must be annotated with `#[derive(PartialEq, Eq)]` to be used as the type of a const parameter
+ --> $DIR/forbid-non-structural_match-types.rs:15:19
+ |
+LL | struct D<const X: C>;
+ | ^ `C` doesn't derive both `PartialEq` and `Eq`
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0741`.
-#![feature(const_generics)]
-//~^ WARN the feature `const_generics` is incomplete
+// revisions: full min
+
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
#[derive(PartialEq, Eq)]
struct A;
struct B<const X: A>; // ok
+//[min]~^ ERROR using `A` as const generic parameters is forbidden
struct C;
struct D<const X: C>; //~ ERROR `C` must be annotated with `#[derive(PartialEq, Eq)]`
+//[min]~^ ERROR using `C` as const generic parameters is forbidden
fn main() {}
+++ /dev/null
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/forbid-non-structural_match-types.rs:1:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-error[E0741]: `C` must be annotated with `#[derive(PartialEq, Eq)]` to be used as the type of a const parameter
- --> $DIR/forbid-non-structural_match-types.rs:11:19
- |
-LL | struct D<const X: C>;
- | ^ `C` doesn't derive both `PartialEq` and `Eq`
-
-error: aborting due to previous error; 1 warning emitted
-
-For more information about this error, try `rustc --explain E0741`.
--- /dev/null
+error[E0044]: foreign items may not have const parameters
+ --> $DIR/foreign-item-const-parameter.rs:8:5
+ |
+LL | fn foo<const X: usize>();
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^ can't have const parameters
+ |
+ = help: replace the const parameters with concrete consts
+
+error[E0044]: foreign items may not have type or const parameters
+ --> $DIR/foreign-item-const-parameter.rs:10:5
+ |
+LL | fn bar<T, const X: usize>(_: T);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't have type or const parameters
+ |
+ = help: replace the type or const parameters with concrete types or consts
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0044`.
--- /dev/null
+error[E0044]: foreign items may not have const parameters
+ --> $DIR/foreign-item-const-parameter.rs:8:5
+ |
+LL | fn foo<const X: usize>();
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^ can't have const parameters
+ |
+ = help: replace the const parameters with concrete consts
+
+error[E0044]: foreign items may not have type or const parameters
+ --> $DIR/foreign-item-const-parameter.rs:10:5
+ |
+LL | fn bar<T, const X: usize>(_: T);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't have type or const parameters
+ |
+ = help: replace the type or const parameters with concrete types or consts
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0044`.
-#![feature(const_generics)]
-//~^ WARN the feature `const_generics` is incomplete
+// revisions: full min
+
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
extern "C" {
fn foo<const X: usize>(); //~ ERROR foreign items may not have const parameters
+++ /dev/null
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/foreign-item-const-parameter.rs:1:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-error[E0044]: foreign items may not have const parameters
- --> $DIR/foreign-item-const-parameter.rs:5:5
- |
-LL | fn foo<const X: usize>();
- | ^^^^^^^^^^^^^^^^^^^^^^^^^ can't have const parameters
- |
- = help: replace the const parameters with concrete consts
-
-error[E0044]: foreign items may not have type or const parameters
- --> $DIR/foreign-item-const-parameter.rs:7:5
- |
-LL | fn bar<T, const X: usize>(_: T);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't have type or const parameters
- |
- = help: replace the type or const parameters with concrete types or consts
-
-error: aborting due to 2 previous errors; 1 warning emitted
-
-For more information about this error, try `rustc --explain E0044`.
// run-pass
+// revisions: full min
-#![feature(const_generics)]
-//~^ WARN the feature `const_generics` is incomplete
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
struct S<const X: u32>;
+++ /dev/null
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/impl-const-generic-struct.rs:3:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-warning: 1 warning emitted
-
--- /dev/null
+error[E0107]: wrong number of const arguments: expected 2, found 1
+ --> $DIR/incorrect-number-of-const-args.rs:12:5
+ |
+LL | foo::<0>();
+ | ^^^^^^^^ expected 2 const arguments
+
+error[E0107]: wrong number of const arguments: expected 2, found 3
+ --> $DIR/incorrect-number-of-const-args.rs:13:17
+ |
+LL | foo::<0, 0, 0>();
+ | ^ unexpected const argument
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0107`.
--- /dev/null
+error[E0107]: wrong number of const arguments: expected 2, found 1
+ --> $DIR/incorrect-number-of-const-args.rs:12:5
+ |
+LL | foo::<0>();
+ | ^^^^^^^^ expected 2 const arguments
+
+error[E0107]: wrong number of const arguments: expected 2, found 3
+ --> $DIR/incorrect-number-of-const-args.rs:13:17
+ |
+LL | foo::<0, 0, 0>();
+ | ^ unexpected const argument
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0107`.
-#![feature(const_generics)]
-//~^ WARN the feature `const_generics` is incomplete
+// revisions: full min
+
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
fn foo<const X: usize, const Y: usize>() -> usize {
0
+++ /dev/null
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/incorrect-number-of-const-args.rs:1:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-error[E0107]: wrong number of const arguments: expected 2, found 1
- --> $DIR/incorrect-number-of-const-args.rs:9:5
- |
-LL | foo::<0>();
- | ^^^^^^^^ expected 2 const arguments
-
-error[E0107]: wrong number of const arguments: expected 2, found 3
- --> $DIR/incorrect-number-of-const-args.rs:10:17
- |
-LL | foo::<0, 0, 0>();
- | ^ unexpected const argument
-
-error: aborting due to 2 previous errors; 1 warning emitted
-
-For more information about this error, try `rustc --explain E0107`.
// run-pass
//
// see issue #70529
-#![feature(const_generics)]
-//~^ WARN the feature `const_generics` is incomplete
+// revisions: full min
+
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
struct A<const N: usize> {
arr: [u8; N],
+++ /dev/null
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/infer_arg_from_pat.rs:4:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-warning: 1 warning emitted
-
// check-pass
//
// see issue #70529
-#![feature(const_generics)]
-//~^ WARN the feature `const_generics` is incomplete
+// revisions: full min
+
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
fn as_chunks<const N: usize>() -> [u8; N] {
loop {}
+++ /dev/null
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/infer_arr_len_from_pat.rs:4:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-warning: 1 warning emitted
-
// check-pass
+// revisions: full min
-#![feature(const_generics)]
-//~^ WARN the feature `const_generics` is incomplete
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
fn takes_closure_of_array_3<F>(f: F) where F: Fn([i32; 3]) {
f([1, 2, 3]);
|_| {}
}
-fn main() {}
+fn main() {
+ takes_closure_of_array_3(returns_closure_of_array_3());
+ takes_closure_of_array_3_apit(returns_closure_of_array_3());
+}
+++ /dev/null
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/integer-literal-generic-arg-in-where-clause.rs:3:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-warning: 1 warning emitted
-
--- /dev/null
+error: constant expression depends on a generic parameter
+ --> $DIR/issue-61522-array-len-succ.rs:7:40
+ |
+LL | pub struct MyArray<const COUNT: usize>([u8; COUNT + 1]);
+ | ^^^^^^^^^^^^^^^
+ |
+ = note: this may fail depending on what value the parameter takes
+
+error: constant expression depends on a generic parameter
+ --> $DIR/issue-61522-array-len-succ.rs:12:24
+ |
+LL | fn inner(&self) -> &[u8; COUNT + 1] {
+ | ^^^^^^^^^^^^^^^^
+ |
+ = note: this may fail depending on what value the parameter takes
+
+error: aborting due to 2 previous errors
+
--- /dev/null
+error: generic parameters must not be used inside of non trivial constant values
+ --> $DIR/issue-61522-array-len-succ.rs:7:45
+ |
+LL | pub struct MyArray<const COUNT: usize>([u8; COUNT + 1]);
+ | ^^^^^ non-trivial anonymous constants must not depend on the parameter `COUNT`
+ |
+ = help: it is currently only allowed to use either `COUNT` or `{ COUNT }` as generic constants
+
+error: generic parameters must not be used inside of non trivial constant values
+ --> $DIR/issue-61522-array-len-succ.rs:12:30
+ |
+LL | fn inner(&self) -> &[u8; COUNT + 1] {
+ | ^^^^^ non-trivial anonymous constants must not depend on the parameter `COUNT`
+ |
+ = help: it is currently only allowed to use either `COUNT` or `{ COUNT }` as generic constants
+
+error: aborting due to 2 previous errors
+
-#![feature(const_generics)]
-//~^ WARN the feature `const_generics` is incomplete
+// revisions: full min
+
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
pub struct MyArray<const COUNT: usize>([u8; COUNT + 1]);
-//~^ ERROR constant expression depends on a generic parameter
+//[full]~^ ERROR constant expression depends on a generic parameter
+//[min]~^^ ERROR generic parameters must not be used
impl<const COUNT: usize> MyArray<COUNT> {
fn inner(&self) -> &[u8; COUNT + 1] {
- //~^ ERROR constant expression depends on a generic parameter
+ //[full]~^ ERROR constant expression depends on a generic parameter
+ //[min]~^^ ERROR generic parameters must not be used
&self.0
}
}
+++ /dev/null
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/issue-61522-array-len-succ.rs:1:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-error: constant expression depends on a generic parameter
- --> $DIR/issue-61522-array-len-succ.rs:4:40
- |
-LL | pub struct MyArray<const COUNT: usize>([u8; COUNT + 1]);
- | ^^^^^^^^^^^^^^^
- |
- = note: this may fail depending on what value the parameter takes
-
-error: constant expression depends on a generic parameter
- --> $DIR/issue-61522-array-len-succ.rs:8:24
- |
-LL | fn inner(&self) -> &[u8; COUNT + 1] {
- | ^^^^^^^^^^^^^^^^
- |
- = note: this may fail depending on what value the parameter takes
-
-error: aborting due to 2 previous errors; 1 warning emitted
-
--- /dev/null
+error: using `&'static str` as const generic parameters is forbidden
+ --> $DIR/issue-66596-impl-trait-for-str-const-arg.rs:9:25
+ |
+LL | trait Trait<const NAME: &'static str> {
+ | ^^^^^^^^^^^^
+ |
+ = note: the only supported types are integers, `bool` and `char`
+ = note: more complex types are supported with `#[feature(const_generics)]`
+
+error: aborting due to previous error
+
-// check-pass
+//[full] check-pass
+// revisions: full min
+
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
-#![feature(const_generics)]
-//~^ WARN the feature `const_generics` is incomplete
trait Trait<const NAME: &'static str> {
+//[min]~^ ERROR using `&'static str` as const generic parameters is forbidden
type Assoc;
}
+++ /dev/null
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/issue-66596-impl-trait-for-str-const-arg.rs:3:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-warning: 1 warning emitted
-
// aux-build:impl-const.rs
// run-pass
+// revisions: full min
-#![feature(const_generics)]
-#![allow(incomplete_features)]
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
extern crate impl_const;
// build-pass
-#![feature(const_generics)]
-#![allow(incomplete_features)]
+// revisions: full min
+
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
pub fn works() {
let array/*: [_; _]*/ = default_array();
// build-pass
-#![feature(const_generics)]
-#![allow(incomplete_features)]
+// revisions: full min
+
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
fn works() {
let array/*: [u8; _]*/ = default_byte_array();
// check-pass
-#![allow(incomplete_features)]
-#![feature(const_generics)]
+// revisions: full min
+
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
pub trait Foo<const B: bool> {}
pub fn bar<T: Foo<{ true }>>() {}
// run-pass
+// revisions: full min
+
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
-#![feature(const_generics)]
-//~^ WARN the feature `const_generics` is incomplete
use std::ops::AddAssign;
+++ /dev/null
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/mut-ref-const-param-array.rs:3:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-warning: 1 warning emitted
-
--- /dev/null
+error[E0391]: cycle detected when computing type of `Foo`
+ --> $DIR/nested-type.rs:7:1
+ |
+LL | struct Foo<const N: [u8; {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+note: ...which requires computing type of `Foo::N`...
+ --> $DIR/nested-type.rs:7:18
+ |
+LL | struct Foo<const N: [u8; {
+ | ^
+note: ...which requires const-evaluating + checking `Foo::{{constant}}#0`...
+ --> $DIR/nested-type.rs:7:26
+ |
+LL | struct Foo<const N: [u8; {
+ | __________________________^
+LL | |
+LL | |
+LL | |
+... |
+LL | | Foo::<17>::value()
+LL | | }]>;
+ | |_^
+note: ...which requires const-evaluating + checking `Foo::{{constant}}#0`...
+ --> $DIR/nested-type.rs:7:26
+ |
+LL | struct Foo<const N: [u8; {
+ | __________________________^
+LL | |
+LL | |
+LL | |
+... |
+LL | | Foo::<17>::value()
+LL | | }]>;
+ | |_^
+note: ...which requires const-evaluating `Foo::{{constant}}#0`...
+ --> $DIR/nested-type.rs:7:26
+ |
+LL | struct Foo<const N: [u8; {
+ | __________________________^
+LL | |
+LL | |
+LL | |
+... |
+LL | | Foo::<17>::value()
+LL | | }]>;
+ | |_^
+note: ...which requires type-checking `Foo::{{constant}}#0`...
+ --> $DIR/nested-type.rs:7:26
+ |
+LL | struct Foo<const N: [u8; {
+ | __________________________^
+LL | |
+LL | |
+LL | |
+... |
+LL | | Foo::<17>::value()
+LL | | }]>;
+ | |_^
+note: ...which requires computing the variances of `Foo::{{constant}}#0::Foo`...
+ --> $DIR/nested-type.rs:11:5
+ |
+LL | struct Foo<const N: usize>;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ = note: ...which requires computing the variances for items in this crate...
+ = note: ...which again requires computing type of `Foo`, completing the cycle
+note: cycle used when collecting item types in top-level module
+ --> $DIR/nested-type.rs:3:1
+ |
+LL | / #![cfg_attr(full, feature(const_generics))]
+LL | | #![cfg_attr(full, allow(incomplete_features))]
+LL | | #![cfg_attr(min, feature(min_const_generics))]
+LL | |
+... |
+LL | |
+LL | | fn main() {}
+ | |____________^
+
+error[E0391]: cycle detected when computing type of `Foo`
+ --> $DIR/nested-type.rs:7:1
+ |
+LL | struct Foo<const N: [u8; {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+note: ...which requires computing type of `Foo::N`...
+ --> $DIR/nested-type.rs:7:18
+ |
+LL | struct Foo<const N: [u8; {
+ | ^
+note: ...which requires const-evaluating + checking `Foo::{{constant}}#0`...
+ --> $DIR/nested-type.rs:7:26
+ |
+LL | struct Foo<const N: [u8; {
+ | __________________________^
+LL | |
+LL | |
+LL | |
+... |
+LL | | Foo::<17>::value()
+LL | | }]>;
+ | |_^
+note: ...which requires const-evaluating + checking `Foo::{{constant}}#0`...
+ --> $DIR/nested-type.rs:7:26
+ |
+LL | struct Foo<const N: [u8; {
+ | __________________________^
+LL | |
+LL | |
+LL | |
+... |
+LL | | Foo::<17>::value()
+LL | | }]>;
+ | |_^
+note: ...which requires const-evaluating `Foo::{{constant}}#0`...
+ --> $DIR/nested-type.rs:7:26
+ |
+LL | struct Foo<const N: [u8; {
+ | __________________________^
+LL | |
+LL | |
+LL | |
+... |
+LL | | Foo::<17>::value()
+LL | | }]>;
+ | |_^
+note: ...which requires type-checking `Foo::{{constant}}#0`...
+ --> $DIR/nested-type.rs:7:26
+ |
+LL | struct Foo<const N: [u8; {
+ | __________________________^
+LL | |
+LL | |
+LL | |
+... |
+LL | | Foo::<17>::value()
+LL | | }]>;
+ | |_^
+note: ...which requires computing the variances of `Foo::{{constant}}#0::Foo`...
+ --> $DIR/nested-type.rs:11:5
+ |
+LL | struct Foo<const N: usize>;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ = note: ...which requires computing the variances for items in this crate...
+ = note: ...which again requires computing type of `Foo`, completing the cycle
+note: cycle used when collecting item types in top-level module
+ --> $DIR/nested-type.rs:3:1
+ |
+LL | / #![cfg_attr(full, feature(const_generics))]
+LL | | #![cfg_attr(full, allow(incomplete_features))]
+LL | | #![cfg_attr(min, feature(min_const_generics))]
+LL | |
+... |
+LL | |
+LL | | fn main() {}
+ | |____________^
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0391`.
--- /dev/null
+error: using `[u8; _]` as const generic parameters is forbidden
+ --> $DIR/nested-type.rs:7:21
+ |
+LL | struct Foo<const N: [u8; {
+ | _____________________^
+LL | |
+LL | |
+LL | |
+... |
+LL | | Foo::<17>::value()
+LL | | }]>;
+ | |__^
+ |
+ = note: the only supported types are integers, `bool` and `char`
+ = note: more complex types are supported with `#[feature(const_generics)]`
+
+error[E0391]: cycle detected when computing type of `Foo`
+ --> $DIR/nested-type.rs:7:1
+ |
+LL | struct Foo<const N: [u8; {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+note: ...which requires computing type of `Foo::N`...
+ --> $DIR/nested-type.rs:7:18
+ |
+LL | struct Foo<const N: [u8; {
+ | ^
+note: ...which requires const-evaluating + checking `Foo::{{constant}}#0`...
+ --> $DIR/nested-type.rs:7:26
+ |
+LL | struct Foo<const N: [u8; {
+ | __________________________^
+LL | |
+LL | |
+LL | |
+... |
+LL | | Foo::<17>::value()
+LL | | }]>;
+ | |_^
+note: ...which requires const-evaluating + checking `Foo::{{constant}}#0`...
+ --> $DIR/nested-type.rs:7:26
+ |
+LL | struct Foo<const N: [u8; {
+ | __________________________^
+LL | |
+LL | |
+LL | |
+... |
+LL | | Foo::<17>::value()
+LL | | }]>;
+ | |_^
+note: ...which requires const-evaluating `Foo::{{constant}}#0`...
+ --> $DIR/nested-type.rs:7:26
+ |
+LL | struct Foo<const N: [u8; {
+ | __________________________^
+LL | |
+LL | |
+LL | |
+... |
+LL | | Foo::<17>::value()
+LL | | }]>;
+ | |_^
+note: ...which requires type-checking `Foo::{{constant}}#0`...
+ --> $DIR/nested-type.rs:7:26
+ |
+LL | struct Foo<const N: [u8; {
+ | __________________________^
+LL | |
+LL | |
+LL | |
+... |
+LL | | Foo::<17>::value()
+LL | | }]>;
+ | |_^
+note: ...which requires computing the variances of `Foo::{{constant}}#0::Foo`...
+ --> $DIR/nested-type.rs:11:5
+ |
+LL | struct Foo<const N: usize>;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ = note: ...which requires computing the variances for items in this crate...
+ = note: ...which again requires computing type of `Foo`, completing the cycle
+note: cycle used when collecting item types in top-level module
+ --> $DIR/nested-type.rs:3:1
+ |
+LL | / #![cfg_attr(full, feature(const_generics))]
+LL | | #![cfg_attr(full, allow(incomplete_features))]
+LL | | #![cfg_attr(min, feature(min_const_generics))]
+LL | |
+... |
+LL | |
+LL | | fn main() {}
+ | |____________^
+
+error[E0391]: cycle detected when computing type of `Foo`
+ --> $DIR/nested-type.rs:7:1
+ |
+LL | struct Foo<const N: [u8; {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+note: ...which requires computing type of `Foo::N`...
+ --> $DIR/nested-type.rs:7:18
+ |
+LL | struct Foo<const N: [u8; {
+ | ^
+note: ...which requires const-evaluating + checking `Foo::{{constant}}#0`...
+ --> $DIR/nested-type.rs:7:26
+ |
+LL | struct Foo<const N: [u8; {
+ | __________________________^
+LL | |
+LL | |
+LL | |
+... |
+LL | | Foo::<17>::value()
+LL | | }]>;
+ | |_^
+note: ...which requires const-evaluating + checking `Foo::{{constant}}#0`...
+ --> $DIR/nested-type.rs:7:26
+ |
+LL | struct Foo<const N: [u8; {
+ | __________________________^
+LL | |
+LL | |
+LL | |
+... |
+LL | | Foo::<17>::value()
+LL | | }]>;
+ | |_^
+note: ...which requires const-evaluating `Foo::{{constant}}#0`...
+ --> $DIR/nested-type.rs:7:26
+ |
+LL | struct Foo<const N: [u8; {
+ | __________________________^
+LL | |
+LL | |
+LL | |
+... |
+LL | | Foo::<17>::value()
+LL | | }]>;
+ | |_^
+note: ...which requires type-checking `Foo::{{constant}}#0`...
+ --> $DIR/nested-type.rs:7:26
+ |
+LL | struct Foo<const N: [u8; {
+ | __________________________^
+LL | |
+LL | |
+LL | |
+... |
+LL | | Foo::<17>::value()
+LL | | }]>;
+ | |_^
+note: ...which requires computing the variances of `Foo::{{constant}}#0::Foo`...
+ --> $DIR/nested-type.rs:11:5
+ |
+LL | struct Foo<const N: usize>;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ = note: ...which requires computing the variances for items in this crate...
+ = note: ...which again requires computing type of `Foo`, completing the cycle
+note: cycle used when collecting item types in top-level module
+ --> $DIR/nested-type.rs:3:1
+ |
+LL | / #![cfg_attr(full, feature(const_generics))]
+LL | | #![cfg_attr(full, allow(incomplete_features))]
+LL | | #![cfg_attr(min, feature(min_const_generics))]
+LL | |
+... |
+LL | |
+LL | | fn main() {}
+ | |____________^
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0391`.
-#![feature(const_generics)]
-#![allow(incomplete_features)]
+// revisions: full min
+
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
struct Foo<const N: [u8; {
//~^ ERROR cycle detected
//~| ERROR cycle detected
+//[min]~| ERROR using `[u8; _]` as const generic
struct Foo<const N: usize>;
impl<const N: usize> Foo<N> {
+++ /dev/null
-error[E0391]: cycle detected when computing type of `Foo`
- --> $DIR/nested-type.rs:4:1
- |
-LL | struct Foo<const N: [u8; {
- | ^^^^^^^^^^^^^^^^^^^^^^^^
- |
-note: ...which requires computing type of `Foo::N`...
- --> $DIR/nested-type.rs:4:18
- |
-LL | struct Foo<const N: [u8; {
- | ^
-note: ...which requires const-evaluating + checking `Foo::{{constant}}#0`...
- --> $DIR/nested-type.rs:4:26
- |
-LL | struct Foo<const N: [u8; {
- | __________________________^
-LL | |
-LL | |
-LL | | struct Foo<const N: usize>;
-... |
-LL | | Foo::<17>::value()
-LL | | }]>;
- | |_^
-note: ...which requires const-evaluating + checking `Foo::{{constant}}#0`...
- --> $DIR/nested-type.rs:4:26
- |
-LL | struct Foo<const N: [u8; {
- | __________________________^
-LL | |
-LL | |
-LL | | struct Foo<const N: usize>;
-... |
-LL | | Foo::<17>::value()
-LL | | }]>;
- | |_^
-note: ...which requires const-evaluating `Foo::{{constant}}#0`...
- --> $DIR/nested-type.rs:4:26
- |
-LL | struct Foo<const N: [u8; {
- | __________________________^
-LL | |
-LL | |
-LL | | struct Foo<const N: usize>;
-... |
-LL | | Foo::<17>::value()
-LL | | }]>;
- | |_^
-note: ...which requires type-checking `Foo::{{constant}}#0`...
- --> $DIR/nested-type.rs:4:26
- |
-LL | struct Foo<const N: [u8; {
- | __________________________^
-LL | |
-LL | |
-LL | | struct Foo<const N: usize>;
-... |
-LL | | Foo::<17>::value()
-LL | | }]>;
- | |_^
-note: ...which requires computing the variances of `Foo::{{constant}}#0::Foo`...
- --> $DIR/nested-type.rs:7:5
- |
-LL | struct Foo<const N: usize>;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
- = note: ...which requires computing the variances for items in this crate...
- = note: ...which again requires computing type of `Foo`, completing the cycle
-note: cycle used when collecting item types in top-level module
- --> $DIR/nested-type.rs:1:1
- |
-LL | / #![feature(const_generics)]
-LL | | #![allow(incomplete_features)]
-LL | |
-LL | | struct Foo<const N: [u8; {
-... |
-LL | |
-LL | | fn main() {}
- | |____________^
-
-error[E0391]: cycle detected when computing type of `Foo`
- --> $DIR/nested-type.rs:4:1
- |
-LL | struct Foo<const N: [u8; {
- | ^^^^^^^^^^^^^^^^^^^^^^^^
- |
-note: ...which requires computing type of `Foo::N`...
- --> $DIR/nested-type.rs:4:18
- |
-LL | struct Foo<const N: [u8; {
- | ^
-note: ...which requires const-evaluating + checking `Foo::{{constant}}#0`...
- --> $DIR/nested-type.rs:4:26
- |
-LL | struct Foo<const N: [u8; {
- | __________________________^
-LL | |
-LL | |
-LL | | struct Foo<const N: usize>;
-... |
-LL | | Foo::<17>::value()
-LL | | }]>;
- | |_^
-note: ...which requires const-evaluating + checking `Foo::{{constant}}#0`...
- --> $DIR/nested-type.rs:4:26
- |
-LL | struct Foo<const N: [u8; {
- | __________________________^
-LL | |
-LL | |
-LL | | struct Foo<const N: usize>;
-... |
-LL | | Foo::<17>::value()
-LL | | }]>;
- | |_^
-note: ...which requires const-evaluating `Foo::{{constant}}#0`...
- --> $DIR/nested-type.rs:4:26
- |
-LL | struct Foo<const N: [u8; {
- | __________________________^
-LL | |
-LL | |
-LL | | struct Foo<const N: usize>;
-... |
-LL | | Foo::<17>::value()
-LL | | }]>;
- | |_^
-note: ...which requires type-checking `Foo::{{constant}}#0`...
- --> $DIR/nested-type.rs:4:26
- |
-LL | struct Foo<const N: [u8; {
- | __________________________^
-LL | |
-LL | |
-LL | | struct Foo<const N: usize>;
-... |
-LL | | Foo::<17>::value()
-LL | | }]>;
- | |_^
-note: ...which requires computing the variances of `Foo::{{constant}}#0::Foo`...
- --> $DIR/nested-type.rs:7:5
- |
-LL | struct Foo<const N: usize>;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
- = note: ...which requires computing the variances for items in this crate...
- = note: ...which again requires computing type of `Foo`, completing the cycle
-note: cycle used when collecting item types in top-level module
- --> $DIR/nested-type.rs:1:1
- |
-LL | / #![feature(const_generics)]
-LL | | #![allow(incomplete_features)]
-LL | |
-LL | | struct Foo<const N: [u8; {
-... |
-LL | |
-LL | | fn main() {}
- | |____________^
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0391`.
--- /dev/null
+error: type parameters with a default must be trailing
+ --> $DIR/params-in-ct-in-ty-param-lazy-norm.rs:12:12
+ |
+LL | struct Bar<T = [u8; N], const N: usize>(T);
+ | ^
+ |
+ = note: using type defaults and const parameters in the same parameter list is currently not permitted
+
+error: constant values inside of type parameter defaults must not depend on generic parameters
+ --> $DIR/params-in-ct-in-ty-param-lazy-norm.rs:7:44
+ |
+LL | struct Foo<T, U = [u8; std::mem::size_of::<T>()]>(T, U);
+ | ^ the anonymous constant must not depend on the parameter `T`
+
+error: constant values inside of type parameter defaults must not depend on generic parameters
+ --> $DIR/params-in-ct-in-ty-param-lazy-norm.rs:12:21
+ |
+LL | struct Bar<T = [u8; N], const N: usize>(T);
+ | ^ the anonymous constant must not depend on the parameter `N`
+
+error: aborting due to 3 previous errors
+
--- /dev/null
+error: type parameters with a default must be trailing
+ --> $DIR/params-in-ct-in-ty-param-lazy-norm.rs:12:12
+ |
+LL | struct Bar<T = [u8; N], const N: usize>(T);
+ | ^
+ |
+ = note: using type defaults and const parameters in the same parameter list is currently not permitted
+
+error: generic parameters must not be used inside of non trivial constant values
+ --> $DIR/params-in-ct-in-ty-param-lazy-norm.rs:7:44
+ |
+LL | struct Foo<T, U = [u8; std::mem::size_of::<T>()]>(T, U);
+ | ^ non-trivial anonymous constants must not depend on the parameter `T`
+ |
+ = help: it is currently only allowed to use either `T` or `{ T }` as generic constants
+
+error: constant values inside of type parameter defaults must not depend on generic parameters
+ --> $DIR/params-in-ct-in-ty-param-lazy-norm.rs:12:21
+ |
+LL | struct Bar<T = [u8; N], const N: usize>(T);
+ | ^ the anonymous constant must not depend on the parameter `N`
+
+error: aborting due to 3 previous errors
+
-#![feature(const_generics)] //~ WARN the feature `const_generics` is incomplete
+// revisions: full min
+
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
struct Foo<T, U = [u8; std::mem::size_of::<T>()]>(T, U);
-//~^ ERROR constant values inside of type parameter defaults
+//[full]~^ ERROR constant values inside of type parameter defaults
+//[min]~^^ ERROR generic parameters must not be used inside of non trivial
// FIXME(const_generics:defaults): We still don't know how to we deal with type defaults.
struct Bar<T = [u8; N], const N: usize>(T);
+++ /dev/null
-error: type parameters with a default must be trailing
- --> $DIR/params-in-ct-in-ty-param-lazy-norm.rs:7:12
- |
-LL | struct Bar<T = [u8; N], const N: usize>(T);
- | ^
- |
- = note: using type defaults and const parameters in the same parameter list is currently not permitted
-
-error: constant values inside of type parameter defaults must not depend on generic parameters
- --> $DIR/params-in-ct-in-ty-param-lazy-norm.rs:3:44
- |
-LL | struct Foo<T, U = [u8; std::mem::size_of::<T>()]>(T, U);
- | ^ the anonymous constant must not depend on the parameter `T`
-
-error: constant values inside of type parameter defaults must not depend on generic parameters
- --> $DIR/params-in-ct-in-ty-param-lazy-norm.rs:7:21
- |
-LL | struct Bar<T = [u8; N], const N: usize>(T);
- | ^ the anonymous constant must not depend on the parameter `N`
-
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/params-in-ct-in-ty-param-lazy-norm.rs:1:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-error: aborting due to 3 previous errors; 1 warning emitted
-
--- /dev/null
+error: using raw pointers as const generic parameters is forbidden
+ --> $DIR/raw-ptr-const-param-deref.rs:10:23
+ |
+LL | struct Const<const P: *const u32>;
+ | ^^^^^^^^^^
+
+error: using raw pointers as const generic parameters is forbidden
+ --> $DIR/raw-ptr-const-param-deref.rs:12:15
+ |
+LL | impl<const P: *const u32> Const<P> {
+ | ^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
--- /dev/null
+error: using raw pointers as const generic parameters is forbidden
+ --> $DIR/raw-ptr-const-param-deref.rs:10:23
+ |
+LL | struct Const<const P: *const u32>;
+ | ^^^^^^^^^^
+ |
+ = note: the only supported types are integers, `bool` and `char`
+ = note: more complex types are supported with `#[feature(const_generics)]`
+
+error: using raw pointers as const generic parameters is forbidden
+ --> $DIR/raw-ptr-const-param-deref.rs:12:15
+ |
+LL | impl<const P: *const u32> Const<P> {
+ | ^^^^^^^^^^
+ |
+ = note: the only supported types are integers, `bool` and `char`
+ = note: more complex types are supported with `#[feature(const_generics)]`
+
+error: aborting due to 2 previous errors
+
-#![feature(const_generics)]
-//~^ WARN the feature `const_generics` is incomplete
+// Checks that pointers must not be used as the type of const params.
+// revisions: full min
+
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
const A: u32 = 3;
+++ /dev/null
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/raw-ptr-const-param-deref.rs:1:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-error: using raw pointers as const generic parameters is forbidden
- --> $DIR/raw-ptr-const-param-deref.rs:6:23
- |
-LL | struct Const<const P: *const u32>;
- | ^^^^^^^^^^
-
-error: using raw pointers as const generic parameters is forbidden
- --> $DIR/raw-ptr-const-param-deref.rs:8:15
- |
-LL | impl<const P: *const u32> Const<P> {
- | ^^^^^^^^^^
-
-error: aborting due to 2 previous errors; 1 warning emitted
-
--- /dev/null
+error: using raw pointers as const generic parameters is forbidden
+ --> $DIR/raw-ptr-const-param.rs:7:23
+ |
+LL | struct Const<const P: *const u32>;
+ | ^^^^^^^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+error: using raw pointers as const generic parameters is forbidden
+ --> $DIR/raw-ptr-const-param.rs:7:23
+ |
+LL | struct Const<const P: *const u32>;
+ | ^^^^^^^^^^
+ |
+ = note: the only supported types are integers, `bool` and `char`
+ = note: more complex types are supported with `#[feature(const_generics)]`
+
+error: aborting due to previous error
+
-#![feature(const_generics)]
-//~^ WARN the feature `const_generics` is incomplete
+// revisions: full min
+
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
struct Const<const P: *const u32>; //~ ERROR: using raw pointers as const generic parameters
+++ /dev/null
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/raw-ptr-const-param.rs:1:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-error: using raw pointers as const generic parameters is forbidden
- --> $DIR/raw-ptr-const-param.rs:4:23
- |
-LL | struct Const<const P: *const u32>;
- | ^^^^^^^^^^
-
-error: aborting due to previous error; 1 warning emitted
-
--- /dev/null
+error[E0308]: mismatched types
+ --> $DIR/slice-const-param-mismatch.rs:15:35
+ |
+LL | let _: ConstString<"Hello"> = ConstString::<"World">;
+ | -------------------- ^^^^^^^^^^^^^^^^^^^^^^ expected `"Hello"`, found `"World"`
+ | |
+ | expected due to this
+ |
+ = note: expected struct `ConstString<"Hello">`
+ found struct `ConstString<"World">`
+
+error[E0308]: mismatched types
+ --> $DIR/slice-const-param-mismatch.rs:17:33
+ |
+LL | let _: ConstString<"ℇ㇈↦"> = ConstString::<"ℇ㇈↥">;
+ | ------------------- ^^^^^^^^^^^^^^^^^^^^^ expected `"ℇ㇈↦"`, found `"ℇ㇈↥"`
+ | |
+ | expected due to this
+ |
+ = note: expected struct `ConstString<"ℇ㇈↦">`
+ found struct `ConstString<"ℇ㇈↥">`
+
+error[E0308]: mismatched types
+ --> $DIR/slice-const-param-mismatch.rs:19:33
+ |
+LL | let _: ConstBytes<b"AAA"> = ConstBytes::<b"BBB">;
+ | ------------------ ^^^^^^^^^^^^^^^^^^^^ expected `b"AAA"`, found `b"BBB"`
+ | |
+ | expected due to this
+ |
+ = note: expected struct `ConstBytes<b"AAA">`
+ found struct `ConstBytes<b"BBB">`
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0308`.
--- /dev/null
+error: using `&'static str` as const generic parameters is forbidden
+ --> $DIR/slice-const-param-mismatch.rs:8:29
+ |
+LL | struct ConstString<const T: &'static str>;
+ | ^^^^^^^^^^^^
+ |
+ = note: the only supported types are integers, `bool` and `char`
+ = note: more complex types are supported with `#[feature(const_generics)]`
+
+error: using `&'static [u8]` as const generic parameters is forbidden
+ --> $DIR/slice-const-param-mismatch.rs:10:28
+ |
+LL | struct ConstBytes<const T: &'static [u8]>;
+ | ^^^^^^^^^^^^^
+ |
+ = note: the only supported types are integers, `bool` and `char`
+ = note: more complex types are supported with `#[feature(const_generics)]`
+
+error: aborting due to 2 previous errors
+
-#![feature(const_generics)]
-//~^ WARN the feature `const_generics` is incomplete
+// revisions: full min
+
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
+
struct ConstString<const T: &'static str>;
+//[min]~^ ERROR
struct ConstBytes<const T: &'static [u8]>;
+//[min]~^ ERROR
pub fn main() {
let _: ConstString<"Hello"> = ConstString::<"Hello">;
- let _: ConstString<"Hello"> = ConstString::<"World">; //~ ERROR mismatched types
+ let _: ConstString<"Hello"> = ConstString::<"World">; //[full]~ ERROR mismatched types
let _: ConstString<"ℇ㇈↦"> = ConstString::<"ℇ㇈↦">;
- let _: ConstString<"ℇ㇈↦"> = ConstString::<"ℇ㇈↥">; //~ ERROR mismatched types
+ let _: ConstString<"ℇ㇈↦"> = ConstString::<"ℇ㇈↥">; //[full]~ ERROR mismatched types
let _: ConstBytes<b"AAA"> = ConstBytes::<{&[0x41, 0x41, 0x41]}>;
- let _: ConstBytes<b"AAA"> = ConstBytes::<b"BBB">; //~ ERROR mismatched types
+ let _: ConstBytes<b"AAA"> = ConstBytes::<b"BBB">; //[full]~ ERROR mismatched types
}
+++ /dev/null
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/slice-const-param-mismatch.rs:1:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-error[E0308]: mismatched types
- --> $DIR/slice-const-param-mismatch.rs:9:35
- |
-LL | let _: ConstString<"Hello"> = ConstString::<"World">;
- | -------------------- ^^^^^^^^^^^^^^^^^^^^^^ expected `"Hello"`, found `"World"`
- | |
- | expected due to this
- |
- = note: expected struct `ConstString<"Hello">`
- found struct `ConstString<"World">`
-
-error[E0308]: mismatched types
- --> $DIR/slice-const-param-mismatch.rs:11:33
- |
-LL | let _: ConstString<"ℇ㇈↦"> = ConstString::<"ℇ㇈↥">;
- | ------------------- ^^^^^^^^^^^^^^^^^^^^^ expected `"ℇ㇈↦"`, found `"ℇ㇈↥"`
- | |
- | expected due to this
- |
- = note: expected struct `ConstString<"ℇ㇈↦">`
- found struct `ConstString<"ℇ㇈↥">`
-
-error[E0308]: mismatched types
- --> $DIR/slice-const-param-mismatch.rs:13:33
- |
-LL | let _: ConstBytes<b"AAA"> = ConstBytes::<b"BBB">;
- | ------------------ ^^^^^^^^^^^^^^^^^^^^ expected `b"AAA"`, found `b"BBB"`
- | |
- | expected due to this
- |
- = note: expected struct `ConstBytes<b"AAA">`
- found struct `ConstBytes<b"BBB">`
-
-error: aborting due to 3 previous errors; 1 warning emitted
-
-For more information about this error, try `rustc --explain E0308`.
--- /dev/null
+error: using `&'static str` as const generic parameters is forbidden
+ --> $DIR/slice-const-param.rs:8:40
+ |
+LL | pub fn function_with_str<const STRING: &'static str>() -> &'static str {
+ | ^^^^^^^^^^^^
+ |
+ = note: the only supported types are integers, `bool` and `char`
+ = note: more complex types are supported with `#[feature(const_generics)]`
+
+error: using `&'static [u8]` as const generic parameters is forbidden
+ --> $DIR/slice-const-param.rs:13:41
+ |
+LL | pub fn function_with_bytes<const BYTES: &'static [u8]>() -> &'static [u8] {
+ | ^^^^^^^^^^^^^
+ |
+ = note: the only supported types are integers, `bool` and `char`
+ = note: more complex types are supported with `#[feature(const_generics)]`
+
+error: aborting due to 2 previous errors
+
-// run-pass
+//[full] run-pass
+// revisions: min full
-#![feature(const_generics)]
-//~^ WARN the feature `const_generics` is incomplete
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
pub fn function_with_str<const STRING: &'static str>() -> &'static str {
+ //[min]~^ ERROR using `&'static str` as const
STRING
}
pub fn function_with_bytes<const BYTES: &'static [u8]>() -> &'static [u8] {
+ //[min]~^ ERROR using `&'static [u8]` as const
BYTES
}
+++ /dev/null
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/slice-const-param.rs:3:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-warning: 1 warning emitted
-
--- /dev/null
+error[E0573]: expected type, found const parameter `C`
+ --> $DIR/struct-with-invalid-const-param.rs:8:23
+ |
+LL | struct S<const C: u8>(C);
+ | ^ not a type
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0573`.
--- /dev/null
+error[E0573]: expected type, found const parameter `C`
+ --> $DIR/struct-with-invalid-const-param.rs:8:23
+ |
+LL | struct S<const C: u8>(C);
+ | ^ not a type
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0573`.
-#![feature(const_generics)]
-//~^ WARN the feature `const_generics` is incomplete
+// Checks that a const param cannot be stored in a struct.
+// revisions: full min
+
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
struct S<const C: u8>(C); //~ ERROR expected type, found const parameter
// check-pass
-#![allow(incomplete_features)]
-#![feature(const_generics)]
+// revisions: full min
+
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
struct Const<const N: usize>;
trait Foo<const N: usize> {}
// run-pass
+// revisions: full min
-#![feature(const_generics)]
-//~^ WARN the feature `const_generics` is incomplete
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
use std::mem::MaybeUninit;
+++ /dev/null
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/transparent-maybeunit-array-wrapper.rs:3:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-warning: 1 warning emitted
-
// run-pass
+// revisions: full min
-#![feature(const_generics)]
-//~^ WARN the feature `const_generics` is incomplete
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
trait T<const A: usize> {
fn l<const N: bool>() -> usize;
+++ /dev/null
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/type_of_anon_const.rs:3:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-warning: 1 warning emitted
-
--- /dev/null
+error[E0282]: type annotations needed
+ --> $DIR/uninferred-consts.rs:14:5
+ |
+LL | Foo.foo();
+ | ^^^^^^^^^
+ |
+ = note: unable to infer the value of a const parameter
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0282`.
--- /dev/null
+error[E0282]: type annotations needed
+ --> $DIR/uninferred-consts.rs:14:5
+ |
+LL | Foo.foo();
+ | ^^^^^^^^^
+ |
+ = note: unable to infer the value of a const parameter
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0282`.
-#![feature(const_generics)]
-//~^ WARN the feature `const_generics` is incomplete
+// Test that we emit an error if we cannot properly infer a constant.
+// revisions: full min
+
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
// taken from https://github.com/rust-lang/rust/issues/70507#issuecomment-615268893
struct Foo;
+++ /dev/null
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/uninferred-consts.rs:1:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-error[E0282]: type annotations needed
- --> $DIR/uninferred-consts.rs:10:5
- |
-LL | Foo.foo();
- | ^^^^^^^^^
- |
- = note: unable to infer the value of a const parameter
-
-error: aborting due to previous error; 1 warning emitted
-
-For more information about this error, try `rustc --explain E0282`.
--- /dev/null
+error[E0412]: cannot find type `UnknownStruct` in this scope
+ --> $DIR/unknown_adt.rs:8:12
+ |
+LL | let _: UnknownStruct<7>;
+ | ^^^^^^^^^^^^^ not found in this scope
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0412`.
--- /dev/null
+error[E0412]: cannot find type `UnknownStruct` in this scope
+ --> $DIR/unknown_adt.rs:8:12
+ |
+LL | let _: UnknownStruct<7>;
+ | ^^^^^^^^^^^^^ not found in this scope
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0412`.
-#![feature(const_generics)]
-#![allow(incomplete_features)]
+// revisions: full min
+
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
fn main() {
let _: UnknownStruct<7>;
+++ /dev/null
-error[E0412]: cannot find type `UnknownStruct` in this scope
- --> $DIR/unknown_adt.rs:5:12
- |
-LL | let _: UnknownStruct<7>;
- | ^^^^^^^^^^^^^ not found in this scope
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0412`.
// check-pass
+// revisions: full min
-#![feature(const_generics)]
-//~^ WARN the feature `const_generics` is incomplete
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
struct A<const N: usize>; // ok
+++ /dev/null
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/unused-const-param.rs:3:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-warning: 1 warning emitted
-
--- /dev/null
+// check-pass
+// run-rustfix
+// revisions: full min
+
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
+#![warn(unused_braces)]
+
+
+struct A<const N: usize>;
+
+fn main() {
+ let _: A<7>; // ok
+ let _: A<7>; //~ WARN unnecessary braces
+ let _: A<{ 3 + 5 }>; // ok
+}
--- /dev/null
+warning: unnecessary braces around const expression
+ --> $DIR/unused_braces.rs:15:14
+ |
+LL | let _: A<{ 7 }>;
+ | ^^^^^ help: remove these braces
+ |
+note: the lint level is defined here
+ --> $DIR/unused_braces.rs:8:9
+ |
+LL | #![warn(unused_braces)]
+ | ^^^^^^^^^^^^^
+
+warning: 1 warning emitted
+
--- /dev/null
+// check-pass
+// run-rustfix
+// revisions: full min
+
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
+#![warn(unused_braces)]
+
+
+struct A<const N: usize>;
+
+fn main() {
+ let _: A<7>; // ok
+ let _: A<7>; //~ WARN unnecessary braces
+ let _: A<{ 3 + 5 }>; // ok
+}
--- /dev/null
+warning: unnecessary braces around const expression
+ --> $DIR/unused_braces.rs:15:14
+ |
+LL | let _: A<{ 7 }>;
+ | ^^^^^ help: remove these braces
+ |
+note: the lint level is defined here
+ --> $DIR/unused_braces.rs:8:9
+ |
+LL | #![warn(unused_braces)]
+ | ^^^^^^^^^^^^^
+
+warning: 1 warning emitted
+
// check-pass
// run-rustfix
+// revisions: full min
-#![allow(incomplete_features)]
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
#![warn(unused_braces)]
-#![feature(const_generics)]
struct A<const N: usize>;
+++ /dev/null
-warning: unnecessary braces around const expression
- --> $DIR/unused_braces.rs:13:14
- |
-LL | let _: A<{ 7 }>;
- | ^^^^^ help: remove these braces
- |
-note: the lint level is defined here
- --> $DIR/unused_braces.rs:5:9
- |
-LL | #![warn(unused_braces)]
- | ^^^^^^^^^^^^^
-
-warning: 1 warning emitted
-
--- /dev/null
+error: constant expression depends on a generic parameter
+ --> $DIR/wf-misc.rs:9:12
+ |
+LL | let _: [u8; N + 1];
+ | ^^^^^^^^^^^
+ |
+ = note: this may fail depending on what value the parameter takes
+
+error: constant expression depends on a generic parameter
+ --> $DIR/wf-misc.rs:17:12
+ |
+LL | let _: Const::<{N + 1}>;
+ | ^^^^^^^^^^^^^^^^
+ |
+ = note: this may fail depending on what value the parameter takes
+
+error: aborting due to 2 previous errors
+
--- /dev/null
+error: generic parameters must not be used inside of non trivial constant values
+ --> $DIR/wf-misc.rs:9:17
+ |
+LL | let _: [u8; N + 1];
+ | ^ non-trivial anonymous constants must not depend on the parameter `N`
+ |
+ = help: it is currently only allowed to use either `N` or `{ N }` as generic constants
+
+error: generic parameters must not be used inside of non trivial constant values
+ --> $DIR/wf-misc.rs:17:21
+ |
+LL | let _: Const::<{N + 1}>;
+ | ^ non-trivial anonymous constants must not depend on the parameter `N`
+ |
+ = help: it is currently only allowed to use either `N` or `{ N }` as generic constants
+
+error: aborting due to 2 previous errors
+
-#![feature(const_generics)]
-//~^ WARN the feature `const_generics` is incomplete
+// Tests miscellaneous well-formedness examples.
+// revisions: full min
+
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(min, feature(min_const_generics))]
pub fn arr_len<const N: usize>() {
let _: [u8; N + 1];
- //~^ ERROR constant expression depends on a generic parameter
+ //[full]~^ ERROR constant expression depends on a generic parameter
+ //[min]~^^ ERROR generic parameters must not be used inside of non trivial
}
struct Const<const N: usize>;
pub fn func_call<const N: usize>() {
let _: Const::<{N + 1}>;
- //~^ ERROR constant expression depends on a generic parameter
+ //[full]~^ ERROR constant expression depends on a generic parameter
+ //[min]~^^ ERROR generic parameters must not be used inside of non trivial
}
fn main() {}
+++ /dev/null
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/wf-misc.rs:1:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-error: constant expression depends on a generic parameter
- --> $DIR/wf-misc.rs:5:12
- |
-LL | let _: [u8; N + 1];
- | ^^^^^^^^^^^
- |
- = note: this may fail depending on what value the parameter takes
-
-error: constant expression depends on a generic parameter
- --> $DIR/wf-misc.rs:12:12
- |
-LL | let _: Const::<{N + 1}>;
- | ^^^^^^^^^^^^^^^^
- |
- = note: this may fail depending on what value the parameter takes
-
-error: aborting due to 2 previous errors; 1 warning emitted
-
|
LL | buzz: Buzz,
| ^^^^ expected 2 lifetime parameters
+ |
+help: consider introducing a named lifetime parameter
+ |
+LL | struct Quux<'a> {
+LL | baz: Baz,
+LL |
+LL |
+LL | buzz: Buzz<'a, 'a>,
+ |
error: aborting due to 5 previous errors
--- /dev/null
+// compile-flags: -O
+// run-pass
+
+struct Foo {
+ x: i32,
+}
+
+pub fn main() {
+ let mut foo = Foo { x: 42 };
+ let x = &mut foo.x;
+ *x = 13;
+ let y = foo;
+ assert_eq!(y.x, 13); // used to print 42 due to mir-opt bug
+}
|
help: consider introducing a named lifetime parameter
|
-LL | type Item<'a> = IteratorChunk<<'a>T, S>;
- | ^^^^ ^^^^
+LL | type Item<'a> = IteratorChunk<'a, T, S>;
+ | ^^^^ ^^^
error: `impl` item signature doesn't match `trait` item signature
--> $DIR/issue-74918-missing-lifetime.rs:11:5
--- /dev/null
+trait ZstAssert: Sized {
+ const A: &str = ""; //~ ERROR missing lifetime specifier
+ const B: S = S { s: &() }; //~ ERROR missing lifetime specifier
+ const C: &'_ str = ""; //~ ERROR missing lifetime specifier
+ const D: T = T { a: &(), b: &() }; //~ ERROR missing lifetime specifier
+}
+
+struct S<'a> {
+ s: &'a (),
+}
+struct T<'a, 'b> {
+ a: &'a (),
+ b: &'b (),
+}
+
+fn main() {}
--- /dev/null
+error[E0106]: missing lifetime specifier
+ --> $DIR/missing-lifetime-in-assoc-const-type.rs:2:14
+ |
+LL | const A: &str = "";
+ | ^ expected named lifetime parameter
+ |
+help: consider using the `'static` lifetime
+ |
+LL | const A: &'static str = "";
+ | ^^^^^^^
+help: consider introducing a named lifetime parameter
+ |
+LL | trait ZstAssert<'a>: Sized {
+LL | const A: &'a str = "";
+ |
+
+error[E0106]: missing lifetime specifier
+ --> $DIR/missing-lifetime-in-assoc-const-type.rs:3:14
+ |
+LL | const B: S = S { s: &() };
+ | ^ expected named lifetime parameter
+ |
+help: consider using the `'static` lifetime
+ |
+LL | const B: S<'static> = S { s: &() };
+ | ^^^^^^^^^
+help: consider introducing a named lifetime parameter
+ |
+LL | trait ZstAssert<'a>: Sized {
+LL | const A: &str = "";
+LL | const B: S<'a> = S { s: &() };
+ |
+
+error[E0106]: missing lifetime specifier
+ --> $DIR/missing-lifetime-in-assoc-const-type.rs:4:15
+ |
+LL | const C: &'_ str = "";
+ | ^^ expected named lifetime parameter
+ |
+help: consider using the `'static` lifetime
+ |
+LL | const C: &'static str = "";
+ | ^^^^^^^
+help: consider introducing a named lifetime parameter
+ |
+LL | trait ZstAssert<'a>: Sized {
+LL | const A: &str = "";
+LL | const B: S = S { s: &() };
+LL | const C: &'a str = "";
+ |
+
+error[E0106]: missing lifetime specifiers
+ --> $DIR/missing-lifetime-in-assoc-const-type.rs:5:14
+ |
+LL | const D: T = T { a: &(), b: &() };
+ | ^ expected 2 lifetime parameters
+ |
+help: consider using the `'static` lifetime
+ |
+LL | const D: T<'static, 'static> = T { a: &(), b: &() };
+ | ^^^^^^^^^^^^^^^^^^
+help: consider introducing a named lifetime parameter
+ |
+LL | trait ZstAssert<'a>: Sized {
+LL | const A: &str = "";
+LL | const B: S = S { s: &() };
+LL | const C: &'_ str = "";
+LL | const D: T<'a, 'a> = T { a: &(), b: &() };
+ |
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0106`.
--- /dev/null
+struct X<'a>(&'a ());
+struct S<'a>(&'a dyn Fn(&X) -> &X);
+//~^ ERROR missing lifetime specifier
+//~| ERROR missing lifetime specifier
+struct V<'a>(&'a dyn for<'b> Fn(&X) -> &X);
+//~^ ERROR missing lifetime specifier
+//~| ERROR missing lifetime specifier
+
+fn main() {
+ let x = S(&|x| {
+ println!("hi");
+ x
+ });
+ x.0(&X(&()));
+}
--- /dev/null
+error[E0106]: missing lifetime specifier
+ --> $DIR/missing-lt-for-hrtb.rs:2:32
+ |
+LL | struct S<'a>(&'a dyn Fn(&X) -> &X);
+ | -- ^ expected named lifetime parameter
+ |
+ = help: this function's return type contains a borrowed value, but the signature does not say which one of argument 1's 2 lifetimes it is borrowed from
+ = note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html
+help: consider making the bound lifetime-generic with a new `'b` lifetime
+ |
+LL | struct S<'a>(&'a dyn for<'b> Fn(&'b X) -> &'b X);
+ | ^^^^^^^ ^^^^^ ^^^
+help: consider using the `'a` lifetime
+ |
+LL | struct S<'a>(&'a dyn Fn(&X) -> &'a X);
+ | ^^^
+
+error[E0106]: missing lifetime specifier
+ --> $DIR/missing-lt-for-hrtb.rs:2:33
+ |
+LL | struct S<'a>(&'a dyn Fn(&X) -> &X);
+ | -- ^ expected named lifetime parameter
+ |
+ = help: this function's return type contains a borrowed value, but the signature does not say which one of argument 1's 2 lifetimes it is borrowed from
+ = note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html
+help: consider making the bound lifetime-generic with a new `'b` lifetime
+ |
+LL | struct S<'a>(&'a dyn for<'b> Fn(&'b X) -> &X<'b>);
+ | ^^^^^^^ ^^^^^ ^^^^^
+help: consider using the `'a` lifetime
+ |
+LL | struct S<'a>(&'a dyn Fn(&X) -> &X<'a>);
+ | ^^^^^
+
+error[E0106]: missing lifetime specifier
+ --> $DIR/missing-lt-for-hrtb.rs:5:40
+ |
+LL | struct V<'a>(&'a dyn for<'b> Fn(&X) -> &X);
+ | -- ^ expected named lifetime parameter
+ |
+ = help: this function's return type contains a borrowed value, but the signature does not say which one of argument 1's 2 lifetimes it is borrowed from
+note: these named lifetimes are available to use
+ --> $DIR/missing-lt-for-hrtb.rs:5:10
+ |
+LL | struct V<'a>(&'a dyn for<'b> Fn(&X) -> &X);
+ | ^^ ^^
+
+error[E0106]: missing lifetime specifier
+ --> $DIR/missing-lt-for-hrtb.rs:5:41
+ |
+LL | struct V<'a>(&'a dyn for<'b> Fn(&X) -> &X);
+ | -- ^ expected named lifetime parameter
+ |
+ = help: this function's return type contains a borrowed value, but the signature does not say which one of argument 1's 2 lifetimes it is borrowed from
+note: these named lifetimes are available to use
+ --> $DIR/missing-lt-for-hrtb.rs:5:10
+ |
+LL | struct V<'a>(&'a dyn for<'b> Fn(&X) -> &X);
+ | ^^ ^^
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0106`.
-Subproject commit 1653f354644834073d6d2541e27fae94588e685e
+Subproject commit ab32ee88dade1b50c77347599e82ca2de3fb8a51
-Subproject commit 1edd231065c8eb75abf42bb375adda2120c9a6bf
+Subproject commit 1bfb26d6cae6f535ac1034877635fc0cef87fe64
--- /dev/null
+[package]
+name = "tier-check"
+version = "0.1.0"
+authors = ["Eric Huss"]
+edition = "2018"
+license = "MIT OR Apache-2.0"
+
+[dependencies]
--- /dev/null
+//! This is a script for validating the platform support page in the rustc book.
+//!
+//! The script takes two arguments, the path to the Platform Support source
+//! page, and the second argument is the path to `rustc`.
+
+use std::collections::HashSet;
+
+fn main() {
+ let mut args = std::env::args().skip(1);
+ let src = args.next().expect("expected source file as first argument");
+ let filename = std::path::Path::new(&src).file_name().unwrap().to_str().unwrap();
+ let rustc = args.next().expect("expected rustc as second argument");
+ let output = std::process::Command::new(rustc)
+ .arg("--print=target-list")
+ .output()
+ .expect("rustc should run");
+ if !output.status.success() {
+ eprintln!("rustc failed to run");
+ std::process::exit(0);
+ }
+ let stdout = std::str::from_utf8(&output.stdout).expect("utf8");
+ let target_list: HashSet<_> = stdout.lines().collect();
+
+ let doc_targets_md = std::fs::read_to_string(&src).expect("failed to read input source");
+ let doc_targets: HashSet<_> = doc_targets_md
+ .lines()
+ .filter(|line| line.starts_with('`') && line.contains('|'))
+ // These platforms only exist on macos.
+ .filter(|line| !line.contains("[^apple]") || cfg!(target_os = "macos"))
+ .map(|line| line.split('`').skip(1).next().expect("expected target code span"))
+ .collect();
+
+ let missing: Vec<_> = target_list.difference(&doc_targets).collect();
+ let extra: Vec<_> = doc_targets.difference(&target_list).collect();
+ for target in &missing {
+ eprintln!(
+ "error: target `{}` is missing from {}\n\
+ If this is a new target, please add it to {}.",
+ target, filename, src
+ );
+ }
+ for target in &extra {
+ eprintln!(
+ "error: target `{}` is in {}, but does not appear in the rustc target list\n\
+ If the target has been removed, please edit {} and remove the target.",
+ target, filename, src
+ );
+ }
+ if !missing.is_empty() || !extra.is_empty() {
+ std::process::exit(1);
+ }
+}