diff --git a/COPYRIGHT b/COPYRIGHT index e2d0ed77224e3..6596c5a3d9aff 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -229,35 +229,3 @@ their own copyright notices and license terms: NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - -* jemalloc, under src/jemalloc: - - Copyright (C) 2002-2014 Jason Evans - . All rights reserved. - Copyright (C) 2007-2012 Mozilla Foundation. - All rights reserved. - Copyright (C) 2009-2014 Facebook, Inc. - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - 1. Redistributions of source code must retain the above copyright notice(s), - this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright notice(s), - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) - BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - OF SUCH DAMAGE. diff --git a/Cargo.lock b/Cargo.lock index 041a24aae6c53..426a6bab1eb4f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -15,7 +15,7 @@ dependencies = [ name = "alloc" version = "0.0.0" dependencies = [ - "compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "core 0.0.0", "rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_xorshift 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -98,7 +98,7 @@ version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", - "compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-std-workspace-core 1.0.0", ] @@ -409,7 +409,7 @@ dependencies = [ [[package]] name = "compiler_builtins" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", @@ -665,7 +665,7 @@ name = "dlmalloc" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-std-workspace-core 1.0.0", ] @@ -823,7 +823,7 @@ name = "fortanix-sgx-abi" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-std-workspace-core 1.0.0", ] @@ -1516,7 +1516,7 @@ dependencies = [ name = "panic_abort" version = "0.0.0" dependencies = [ - "compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "core 0.0.0", "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1526,7 +1526,7 @@ name = "panic_unwind" version = "0.0.0" dependencies = [ "alloc 0.0.0", - "compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "core 0.0.0", "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", "unwind 0.0.0", @@ -1679,7 +1679,7 @@ name = "profiler_builtins" version = "0.0.0" dependencies = [ "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", - "compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "core 0.0.0", ] @@ -1810,7 +1810,7 @@ name = "rand_chacha" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1832,7 +1832,7 @@ name = "rand_hc" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1857,7 +1857,7 @@ name = "rand_xorshift" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2198,7 +2198,7 @@ name = "rustc-demangle" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-std-workspace-core 1.0.0", ] @@ -2296,7 +2296,7 @@ dependencies = [ "alloc 0.0.0", "build_helper 0.1.0", "cmake 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)", - "compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "core 0.0.0", ] @@ -2490,7 +2490,7 @@ dependencies = [ "alloc 0.0.0", "build_helper 0.1.0", "cmake 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)", - "compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "core 0.0.0", ] @@ -2542,7 +2542,7 @@ dependencies = [ "alloc 0.0.0", "build_helper 0.1.0", "cmake 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)", - "compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "core 0.0.0", ] @@ -2655,7 +2655,7 @@ dependencies = [ "alloc 0.0.0", "build_helper 0.1.0", "cmake 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)", - "compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "core 0.0.0", ] @@ -2891,7 +2891,7 @@ dependencies = [ "alloc 0.0.0", "backtrace-sys 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", - "compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "core 0.0.0", "dlmalloc 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "fortanix-sgx-abi 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3232,7 +3232,7 @@ dependencies = [ name = "unwind" version = "0.0.0" dependencies = [ - "compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "core 0.0.0", "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3412,7 +3412,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum colored 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b0aa3473e85a3161b59845d6096b289bb577874cafeaf75ea1b1beaa6572c7fc" "checksum commoncrypto 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d056a8586ba25a1e4d61cb090900e495952c7886786fc55f909ab2f819b69007" "checksum commoncrypto-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1fed34f46747aa73dfaa578069fd8279d2818ade2b55f38f22a9401c7f4083e2" -"checksum compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8ad611263b9f31bdb66e66227d3b781600fd1e68d5deee29b23f5e2ac9cb4892" +"checksum compiler_builtins 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e066bf05ea052f9891699abcf8c3025256e3f29b50b741441be1e614b10d9c4a" "checksum compiletest_rs 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)" = "89747fe073b7838343bd2c2445e7a7c2e0d415598f8925f0fa9205b9cdfc48cb" "checksum core-foundation 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4e2640d6d0bf22e82bed1b73c6aef8d5dd31e5abe6666c57e6d45e2649f4f887" "checksum core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e7ca8a5221364ef15ce201e8ed2f609fc312682a8f4e0e3d4aa5879764e0fa3b" diff --git a/config.toml.example b/config.toml.example index f75e220de47e7..f5a348593699f 100644 --- a/config.toml.example +++ b/config.toml.example @@ -171,7 +171,7 @@ # Installs chosen set of extended tools if enables. By default builds all. # If chosen tool failed to build the installation fails. -#tools = ["cargo", "rls", "rustfmt", "analysis", "src"] +#tools = ["cargo", "rls", "clippy", "rustfmt", "analysis", "src"] # Verbosity level: 0 == not verbose, 1 == verbose, 2 == very verbose #verbose = 0 diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs index 050db936daab1..cc539d4c89571 100644 --- a/src/bootstrap/check.rs +++ b/src/bootstrap/check.rs @@ -38,7 +38,6 @@ impl Step for Std { builder.info(&format!("Checking std artifacts ({} -> {})", &compiler.host, target)); run_cargo(builder, &mut cargo, - vec![], &libstd_stamp(builder, compiler, target), true); @@ -85,7 +84,6 @@ impl Step for Rustc { builder.info(&format!("Checking compiler artifacts ({} -> {})", &compiler.host, target)); run_cargo(builder, &mut cargo, - vec![], &librustc_stamp(builder, compiler, target), true); @@ -136,7 +134,6 @@ impl Step for CodegenBackend { let _folder = builder.fold_output(|| format!("stage{}-rustc_codegen_llvm", compiler.stage)); run_cargo(builder, &mut cargo, - vec![], &codegen_backend_stamp(builder, compiler, target, backend), true); } @@ -174,7 +171,6 @@ impl Step for Test { builder.info(&format!("Checking test artifacts ({} -> {})", &compiler.host, target)); run_cargo(builder, &mut cargo, - vec![], &libtest_stamp(builder, compiler, target), true); @@ -222,7 +218,6 @@ impl Step for Rustdoc { println!("Checking rustdoc artifacts ({} -> {})", &compiler.host, target); run_cargo(builder, &mut cargo, - vec![], &rustdoc_stamp(builder, compiler, target), true); diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 821bd002e95b3..0d2546a0e9ca9 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -19,6 +19,7 @@ use build_helper::{output, mtime, up_to_date}; use filetime::FileTime; use serde_json; +use crate::dist; use crate::util::{exe, libdir, is_dylib}; use crate::{Compiler, Mode, GitRepo}; use crate::native; @@ -104,7 +105,6 @@ impl Step for Std { &compiler.host, target)); run_cargo(builder, &mut cargo, - vec![], &libstd_stamp(builder, compiler, target), false); @@ -365,7 +365,6 @@ impl Step for Test { &compiler.host, target)); run_cargo(builder, &mut cargo, - vec![], &libtest_stamp(builder, compiler, target), false); @@ -493,7 +492,6 @@ impl Step for Rustc { compiler.stage, &compiler.host, target)); run_cargo(builder, &mut cargo, - vec![], &librustc_stamp(builder, compiler, target), false); @@ -636,47 +634,18 @@ impl Step for CodegenBackend { let out_dir = builder.cargo_out(compiler, Mode::Codegen, target); - let mut cargo = builder.cargo(compiler, Mode::Codegen, target, "rustc"); + let mut cargo = builder.cargo(compiler, Mode::Codegen, target, "build"); cargo.arg("--manifest-path") .arg(builder.src.join("src/librustc_codegen_llvm/Cargo.toml")); rustc_cargo_env(builder, &mut cargo); let features = build_codegen_backend(&builder, &mut cargo, &compiler, target, backend); - let mut cargo_tails_args = vec![]; - - if builder.config.llvm_thin_lto { - cargo_tails_args.push("--".to_string()); - - let num_jobs = builder.jobs(); - - if !target.contains("msvc") { - // Here we assume that the linker is clang. If it's not, there'll - // be linker errors. - cargo_tails_args.push("-Clink-arg=-fuse-ld=lld".to_string()); - cargo_tails_args.push("-Clink-arg=-flto=thin".to_string()); - - if builder.config.llvm_optimize { - cargo_tails_args.push("-Clink-arg=-O2".to_string()); - } - - // Let's make LLD respect the `-j` option. - let num_jobs_arg = format!("-Clink-arg=-Wl,--thinlto-jobs={}", num_jobs); - cargo_tails_args.push(num_jobs_arg); - } else { - // Here we assume that the linker is lld-link.exe. lld-link.exe - // does not need the extra arguments except for num_jobs - let num_jobs_arg = format!("-Clink-arg=/opt:lldltojobs={}", num_jobs); - cargo_tails_args.push(num_jobs_arg); - } - } - let tmp_stamp = out_dir.join(".tmp.stamp"); let _folder = builder.fold_output(|| format!("stage{}-rustc_codegen_llvm", compiler.stage)); let files = run_cargo(builder, cargo.arg("--features").arg(features), - cargo_tails_args, &tmp_stamp, false); if builder.config.dry_run { @@ -749,7 +718,9 @@ pub fn build_codegen_backend(builder: &Builder, "libstdc++.a"); cargo.env("LLVM_STATIC_STDCPP", file); } - if builder.config.llvm_link_shared { + if builder.config.llvm_link_shared || + (builder.config.llvm_thin_lto && backend != "emscripten") + { cargo.env("LLVM_LINK_SHARED", "1"); } } @@ -989,6 +960,8 @@ impl Step for Assemble { copy_lld_to_sysroot(builder, target_compiler, &lld_install); } + dist::maybe_install_llvm_dylib(builder, target_compiler.host, &sysroot); + // Link the compiler binary itself into place let out_dir = builder.cargo_out(build_compiler, Mode::Rustc, host); let rustc = out_dir.join(exe("rustc_binary", &*host)); @@ -1015,7 +988,6 @@ pub fn add_to_sysroot(builder: &Builder, sysroot_dst: &Path, stamp: &Path) { pub fn run_cargo(builder: &Builder, cargo: &mut Command, - tail_args: Vec, stamp: &Path, is_check: bool) -> Vec @@ -1038,7 +1010,7 @@ pub fn run_cargo(builder: &Builder, // files we need to probe for later. let mut deps = Vec::new(); let mut toplevel = Vec::new(); - let ok = stream_cargo(builder, cargo, tail_args, &mut |msg| { + let ok = stream_cargo(builder, cargo, &mut |msg| { let filenames = match msg { CargoMessage::CompilerArtifact { filenames, .. } => filenames, _ => return, @@ -1163,7 +1135,6 @@ pub fn run_cargo(builder: &Builder, pub fn stream_cargo( builder: &Builder, cargo: &mut Command, - tail_args: Vec, cb: &mut dyn FnMut(CargoMessage), ) -> bool { if builder.config.dry_run { @@ -1174,10 +1145,6 @@ pub fn stream_cargo( cargo.arg("--message-format").arg("json") .stdout(Stdio::piped()); - for arg in tail_args { - cargo.arg(arg); - } - builder.verbose(&format!("running: {:?}", cargo)); let mut child = match cargo.spawn() { Ok(child) => child, diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 9f97e57b4562e..38869bf441a82 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -671,10 +671,18 @@ impl Step for Std { let mut src = builder.sysroot_libdir(compiler, target).to_path_buf(); src.pop(); // Remove the trailing /lib folder from the sysroot_libdir builder.cp_filtered(&src, &dst, &|path| { - let name = path.file_name().and_then(|s| s.to_str()); - name != Some(builder.config.rust_codegen_backends_dir.as_str()) && - name != Some("bin") - + if let Some(name) = path.file_name().and_then(|s| s.to_str()) { + if name == builder.config.rust_codegen_backends_dir.as_str() { + return false + } + if name == "bin" { + return false + } + if name.contains("LLVM") { + return false + } + } + true }); let mut cmd = rust_installer(builder); @@ -1877,13 +1885,13 @@ impl Step for HashSign { // LLVM tools are linked dynamically. // Note: This function does no yet support Windows but we also don't support // linking LLVM tools dynamically on Windows yet. -fn maybe_install_llvm_dylib(builder: &Builder, - target: Interned, - image: &Path) { +pub fn maybe_install_llvm_dylib(builder: &Builder, + target: Interned, + sysroot: &Path) { let src_libdir = builder .llvm_out(target) .join("lib"); - let dst_libdir = image.join("lib/rustlib").join(&*target).join("lib"); + let dst_libdir = sysroot.join("lib/rustlib").join(&*target).join("lib"); t!(fs::create_dir_all(&dst_libdir)); if target.contains("apple-darwin") { diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index 7782351a552d4..d31ea0f845873 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -77,7 +77,7 @@ impl Step for ToolBuild { let _folder = builder.fold_output(|| format!("stage{}-{}", compiler.stage, tool)); builder.info(&format!("Building stage{} tool {} ({})", compiler.stage, tool, target)); let mut duplicates = Vec::new(); - let is_expected = compile::stream_cargo(builder, &mut cargo, vec![], &mut |msg| { + let is_expected = compile::stream_cargo(builder, &mut cargo, &mut |msg| { // Only care about big things like the RLS/Cargo for now match tool { | "rls" diff --git a/src/doc/unstable-book/src/language-features/re-rebalance-coherence.md b/src/doc/unstable-book/src/language-features/re-rebalance-coherence.md new file mode 100644 index 0000000000000..1e74652a890f6 --- /dev/null +++ b/src/doc/unstable-book/src/language-features/re-rebalance-coherence.md @@ -0,0 +1,23 @@ +# `re_rebalance_coherence` + +The tracking issue for this feature is: [#55437] + +[#55437]: https://github.com/rust-lang/rust/issues/55437 + +------------------------ + +The `re_rebalance_coherence` feature tweaks the rules regarding which trait +impls are allowed in crates. +The following rule is used: + +Given `impl Trait for T0`, an impl is valid only if at +least one of the following is true: +- `Trait` is a local trait +- All of + - At least one of the types `T0..=Tn` must be a local type. Let `Ti` be the + first such type. + - No uncovered type parameters `P1..=Pn` may appear in `T0..Ti` (excluding + `Ti`) + + +See the [RFC](https://github.com/rust-lang/rfcs/blob/master/text/2451-re-rebalancing-coherence.md) for details. diff --git a/src/libarena/lib.rs b/src/libarena/lib.rs index b40e905620de9..9f9ded51e37ee 100644 --- a/src/libarena/lib.rs +++ b/src/libarena/lib.rs @@ -119,6 +119,11 @@ impl Default for TypedArena { } impl TypedArena { + pub fn in_arena(&self, ptr: *const T) -> bool { + let ptr = ptr as *const T as *mut T; + + self.chunks.borrow().iter().any(|chunk| chunk.start() <= ptr && ptr < chunk.end()) + } /// Allocates an object in the `TypedArena`, returning a reference to it. #[inline] pub fn alloc(&self, object: T) -> &mut T { diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs index 7508257f7806f..4f5310f5285c9 100644 --- a/src/libcore/intrinsics.rs +++ b/src/libcore/intrinsics.rs @@ -690,6 +690,11 @@ extern "rust-intrinsic" { /// crate it is invoked in. pub fn type_id() -> u64; + /// A guard for unsafe functions that cannot ever be executed if `T` is uninhabited: + /// This will statically either panic, or do nothing. + #[cfg(not(stage0))] + pub fn panic_if_uninhabited(); + /// Creates a value initialized to zero. /// /// `init` is unsafe because it returns a zeroed-out datum, diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index 5ea765d3585a2..1c3088edc0e62 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -24,7 +24,7 @@ //! often generated by LLVM. Additionally, this library can make explicit //! calls to these functions. Their signatures are the same as found in C. //! These functions are often provided by the system libc, but can also be -//! provided by the [rlibc crate](https://crates.io/crates/rlibc). +//! provided by the [compiler-builtins crate](https://crates.io/crates/compiler_builtins). //! //! * `rust_begin_panic` - This function takes four arguments, a //! `fmt::Arguments`, a `&'static str`, and two `u32`'s. These four arguments @@ -110,6 +110,7 @@ #![feature(aarch64_target_feature)] #![feature(wasm_target_feature)] #![feature(avx512_target_feature)] +#![cfg_attr(not(stage0), feature(cmpxchg16b_target_feature))] #![feature(const_slice_len)] #![feature(const_str_as_bytes)] #![feature(const_str_len)] diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs index 53af924376b9d..65752ba032104 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs @@ -85,7 +85,7 @@ impl !Send for *mut T { } on(parent_trait="std::path::Path", label="borrow the `Path` instead"), message="the size for values of type `{Self}` cannot be known at compilation time", label="doesn't have a size known at compile-time", - note="to learn more, visit () -> bool { #[rustc_deprecated(since = "2.0.0", reason = "use `mem::MaybeUninit::zeroed` instead")] #[stable(feature = "rust1", since = "1.0.0")] pub unsafe fn zeroed() -> T { + #[cfg(not(stage0))] + intrinsics::panic_if_uninhabited::(); intrinsics::init() } @@ -624,6 +626,8 @@ pub unsafe fn zeroed() -> T { #[rustc_deprecated(since = "2.0.0", reason = "use `mem::MaybeUninit::uninitialized` instead")] #[stable(feature = "rust1", since = "1.0.0")] pub unsafe fn uninitialized() -> T { + #[cfg(not(stage0))] + intrinsics::panic_if_uninhabited::(); intrinsics::uninit() } @@ -1128,6 +1132,8 @@ impl MaybeUninit { #[unstable(feature = "maybe_uninit", issue = "53491")] #[inline(always)] pub unsafe fn into_inner(self) -> T { + #[cfg(not(stage0))] + intrinsics::panic_if_uninhabited::(); ManuallyDrop::into_inner(self.value) } diff --git a/src/libcore/ops/deref.rs b/src/libcore/ops/deref.rs index f2187bd66869e..075c3a084f41d 100644 --- a/src/libcore/ops/deref.rs +++ b/src/libcore/ops/deref.rs @@ -27,7 +27,7 @@ /// [book] as well as the reference sections on [the dereference operator] /// [ref-deref-op], [method resolution] and [type coercions]. /// -/// [book]: ../../book/second-edition/ch15-02-deref.html +/// [book]: ../../book/ch15-02-deref.html /// [`DerefMut`]: trait.DerefMut.html /// [more]: #more-on-deref-coercion /// [ref-deref-op]: ../../reference/expressions/operator-expr.html#the-dereference-operator @@ -117,7 +117,7 @@ impl Deref for &mut T { /// [book] as well as the reference sections on [the dereference operator] /// [ref-deref-op], [method resolution] and [type coercions]. /// -/// [book]: ../../book/second-edition/ch15-02-deref.html +/// [book]: ../../book/ch15-02-deref.html /// [`Deref`]: trait.Deref.html /// [more]: #more-on-deref-coercion /// [ref-deref-op]: ../../reference/expressions/operator-expr.html#the-dereference-operator diff --git a/src/libcore/ops/drop.rs b/src/libcore/ops/drop.rs index 8d16fdebb3e73..eae63ea2390a8 100644 --- a/src/libcore/ops/drop.rs +++ b/src/libcore/ops/drop.rs @@ -11,7 +11,7 @@ /// Refer to [the chapter on `Drop` in *The Rust Programming Language*][book] /// for some more elaboration. /// -/// [book]: ../../book/second-edition/ch15-03-drop.html +/// [book]: ../../book/ch15-03-drop.html /// /// # Examples /// diff --git a/src/libcore/ops/function.rs b/src/libcore/ops/function.rs index ec2e53412a0a5..3a1d765f7b816 100644 --- a/src/libcore/ops/function.rs +++ b/src/libcore/ops/function.rs @@ -27,7 +27,7 @@ /// `Fn(usize, bool) -> usize`). Those interested in the technical details of /// this can refer to [the relevant section in the *Rustonomicon*][nomicon]. /// -/// [book]: ../../book/second-edition/ch13-01-closures.html +/// [book]: ../../book/ch13-01-closures.html /// [`FnMut`]: trait.FnMut.html /// [`FnOnce`]: trait.FnOnce.html /// [function pointers]: ../../std/primitive.fn.html @@ -95,7 +95,7 @@ pub trait Fn : FnMut { /// `Fn(usize, bool) -> usize`). Those interested in the technical details of /// this can refer to [the relevant section in the *Rustonomicon*][nomicon]. /// -/// [book]: ../../book/second-edition/ch13-01-closures.html +/// [book]: ../../book/ch13-01-closures.html /// [`Fn`]: trait.Fn.html /// [`FnOnce`]: trait.FnOnce.html /// [function pointers]: ../../std/primitive.fn.html @@ -173,7 +173,7 @@ pub trait FnMut : FnOnce { /// `Fn(usize, bool) -> usize`). Those interested in the technical details of /// this can refer to [the relevant section in the *Rustonomicon*][nomicon]. /// -/// [book]: ../../book/second-edition/ch13-01-closures.html +/// [book]: ../../book/ch13-01-closures.html /// [`Fn`]: trait.Fn.html /// [`FnMut`]: trait.FnMut.html /// [function pointers]: ../../std/primitive.fn.html diff --git a/src/librustc/ich/impls_ty.rs b/src/librustc/ich/impls_ty.rs index b2fe4b7561c5a..ef7fb0128ef4b 100644 --- a/src/librustc/ich/impls_ty.rs +++ b/src/librustc/ich/impls_ty.rs @@ -301,7 +301,6 @@ impl_stable_hash_for!(struct ty::FieldDef { impl_stable_hash_for!( impl<'tcx> for enum mir::interpret::ConstValue<'tcx> [ mir::interpret::ConstValue ] { - Unevaluated(def_id, substs), Scalar(val), ScalarPair(a, b), ByRef(id, alloc, offset), @@ -378,6 +377,11 @@ impl_stable_hash_for!(struct ty::Const<'tcx> { val }); +impl_stable_hash_for!(impl<'tcx> for enum ty::LazyConst<'tcx> [ty::LazyConst] { + Unevaluated(did, substs), + Evaluated(c) +}); + impl_stable_hash_for!(enum mir::interpret::ErrorHandled { Reported, TooGeneric @@ -473,22 +477,6 @@ impl_stable_hash_for!(enum mir::interpret::InboundsCheck { MaybeDead }); -impl_stable_hash_for!(enum mir::interpret::Lock { - NoLock, - WriteLock(dl), - ReadLock(v) -}); - -impl_stable_hash_for!(struct mir::interpret::DynamicLifetime { - frame, - region -}); - -impl_stable_hash_for!(enum mir::interpret::AccessKind { - Read, - Write -}); - impl_stable_hash_for!(enum ty::Variance { Covariant, Invariant, diff --git a/src/librustc/lint/levels.rs b/src/librustc/lint/levels.rs index 1ae12fec50661..fe113494316b4 100644 --- a/src/librustc/lint/levels.rs +++ b/src/librustc/lint/levels.rs @@ -173,8 +173,8 @@ impl<'a> LintLevelsBuilder<'a> { /// Pushes a list of AST lint attributes onto this context. /// - /// This function will return a `BuilderPush` object which should be be - /// passed to `pop` when this scope for the attributes provided is exited. + /// This function will return a `BuilderPush` object which should be passed + /// to `pop` when this scope for the attributes provided is exited. /// /// This function will perform a number of tasks: /// diff --git a/src/librustc/mir/interpret/error.rs b/src/librustc/mir/interpret/error.rs index 19be0c08ef13b..c3fe5d773ab16 100644 --- a/src/librustc/mir/interpret/error.rs +++ b/src/librustc/mir/interpret/error.rs @@ -37,7 +37,7 @@ impl ErrorHandled { } pub type ConstEvalRawResult<'tcx> = Result, ErrorHandled>; -pub type ConstEvalResult<'tcx> = Result<&'tcx ty::Const<'tcx>, ErrorHandled>; +pub type ConstEvalResult<'tcx> = Result, ErrorHandled>; #[derive(Clone, Debug, RustcEncodable, RustcDecodable)] pub struct ConstEvalErr<'tcx> { diff --git a/src/librustc/mir/interpret/mod.rs b/src/librustc/mir/interpret/mod.rs index 25a0f0ba489d1..e6a560b2ad7b6 100644 --- a/src/librustc/mir/interpret/mod.rs +++ b/src/librustc/mir/interpret/mod.rs @@ -29,7 +29,6 @@ use mir; use hir::def_id::DefId; use ty::{self, TyCtxt, Instance}; use ty::layout::{self, Size}; -use middle::region; use std::io; use rustc_serialize::{Encoder, Decodable, Encodable}; use rustc_data_structures::fx::FxHashMap; @@ -40,27 +39,6 @@ use ty::codec::TyDecoder; use std::sync::atomic::{AtomicU32, Ordering}; use std::num::NonZeroU32; -#[derive(Clone, Debug, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)] -pub enum Lock { - NoLock, - WriteLock(DynamicLifetime), - /// This should never be empty -- that would be a read lock held and nobody - /// there to release it... - ReadLock(Vec), -} - -#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)] -pub struct DynamicLifetime { - pub frame: usize, - pub region: Option, // "None" indicates "until the function ends" -} - -#[derive(Copy, Clone, Debug, PartialEq, Eq, RustcEncodable, RustcDecodable)] -pub enum AccessKind { - Read, - Write, -} - /// Uniquely identifies a specific constant or static. #[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, RustcEncodable, RustcDecodable)] pub struct GlobalId<'tcx> { diff --git a/src/librustc/mir/interpret/value.rs b/src/librustc/mir/interpret/value.rs index 1e4cfedc2a6ae..26a8e63254008 100644 --- a/src/librustc/mir/interpret/value.rs +++ b/src/librustc/mir/interpret/value.rs @@ -1,7 +1,6 @@ use std::fmt; -use crate::ty::{Ty, subst::Substs, layout::{HasDataLayout, Size}}; -use crate::hir::def_id::DefId; +use crate::ty::{Ty, layout::{HasDataLayout, Size}}; use super::{EvalResult, Pointer, PointerArithmetic, Allocation, AllocId, sign_extend, truncate}; @@ -18,12 +17,6 @@ pub struct RawConst<'tcx> { /// matches the LocalValue optimizations for easy conversions between Value and ConstValue. #[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord, RustcEncodable, RustcDecodable, Hash)] pub enum ConstValue<'tcx> { - /// Never returned from the `const_eval` query, but the HIR contains these frequently in order - /// to allow HIR creation to happen for everything before needing to be able to run constant - /// evaluation - /// FIXME: The query should then return a type that does not even have this variant. - Unevaluated(DefId, &'tcx Substs<'tcx>), - /// Used only for types with layout::abi::Scalar ABI and ZSTs /// /// Not using the enum `Value` to encode that this must not be `Undef` @@ -43,7 +36,6 @@ impl<'tcx> ConstValue<'tcx> { #[inline] pub fn try_to_scalar(&self) -> Option { match *self { - ConstValue::Unevaluated(..) | ConstValue::ByRef(..) | ConstValue::ScalarPair(..) => None, ConstValue::Scalar(val) => Some(val), diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index 2936405ebd0b7..a1a6e890b1292 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -1666,7 +1666,7 @@ impl<'tcx> TerminatorKind<'tcx> { ), ty: switch_ty, }; - fmt_const_val(&mut s, &c).unwrap(); + fmt_const_val(&mut s, c).unwrap(); s.into() }).chain(iter::once("otherwise".into())) .collect() @@ -2154,7 +2154,9 @@ impl<'tcx> Operand<'tcx> { span, ty, user_ty: None, - literal: ty::Const::zero_sized(tcx, ty), + literal: tcx.intern_lazy_const( + ty::LazyConst::Evaluated(ty::Const::zero_sized(ty)), + ), }) } @@ -2457,7 +2459,7 @@ pub struct Constant<'tcx> { /// Needed for NLL to impose user-given type constraints. pub user_ty: Option, - pub literal: &'tcx ty::Const<'tcx>, + pub literal: &'tcx ty::LazyConst<'tcx>, } /// A collection of projections into user types. @@ -2655,12 +2657,20 @@ newtype_index! { impl<'tcx> Debug for Constant<'tcx> { fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result { write!(fmt, "const ")?; - fmt_const_val(fmt, self.literal) + fmt_lazy_const_val(fmt, self.literal) + } +} + +/// Write a `ConstValue` in a way closer to the original source code than the `Debug` output. +pub fn fmt_lazy_const_val(f: &mut impl Write, const_val: &ty::LazyConst<'_>) -> fmt::Result { + match *const_val { + ty::LazyConst::Unevaluated(..) => write!(f, "{:?}", const_val), + ty::LazyConst::Evaluated(c) => fmt_const_val(f, c), } } /// Write a `ConstValue` in a way closer to the original source code than the `Debug` output. -pub fn fmt_const_val(f: &mut impl Write, const_val: &ty::Const<'_>) -> fmt::Result { +pub fn fmt_const_val(f: &mut impl Write, const_val: ty::Const<'_>) -> fmt::Result { use ty::TyKind::*; let value = const_val.val; let ty = const_val.ty; diff --git a/src/librustc/mir/visit.rs b/src/librustc/mir/visit.rs index 67f85fbc8679e..a0fae3aa927ce 100644 --- a/src/librustc/mir/visit.rs +++ b/src/librustc/mir/visit.rs @@ -233,7 +233,7 @@ macro_rules! make_mir_visitor { } fn visit_const(&mut self, - constant: & $($mutability)* &'tcx ty::Const<'tcx>, + constant: & $($mutability)* &'tcx ty::LazyConst<'tcx>, _: Location) { self.super_const(constant); } @@ -892,7 +892,7 @@ macro_rules! make_mir_visitor { fn super_region(&mut self, _region: & $($mutability)* ty::Region<'tcx>) { } - fn super_const(&mut self, _const: & $($mutability)* &'tcx ty::Const<'tcx>) { + fn super_const(&mut self, _const: & $($mutability)* &'tcx ty::LazyConst<'tcx>) { } fn super_substs(&mut self, _substs: & $($mutability)* &'tcx Substs<'tcx>) { diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 33409f9b4a74f..42adc6a87fdba 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -1311,12 +1311,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options, "Disable the instrumentation pre-inliner, useful for profiling / PGO."), relro_level: Option = (None, parse_relro_level, [TRACKED], "choose which RELRO level to use"), - nll_subminimal_causes: bool = (false, parse_bool, [UNTRACKED], - "when tracking region error causes, accept subminimal results for faster execution."), nll_facts: bool = (false, parse_bool, [UNTRACKED], "dump facts from NLL analysis into side files"), - disable_nll_user_type_assert: bool = (false, parse_bool, [UNTRACKED], - "disable user provided type assertion in NLL"), nll_dont_emit_read_for_match: bool = (false, parse_bool, [UNTRACKED], "in match codegen, do not include FakeRead statements (used by mir-borrowck)"), dont_buffer_diagnostics: bool = (false, parse_bool, [UNTRACKED], diff --git a/src/librustc/session/filesearch.rs b/src/librustc/session/filesearch.rs index 19f1c7a18fad1..c6e68ba379ec3 100644 --- a/src/librustc/session/filesearch.rs +++ b/src/librustc/session/filesearch.rs @@ -114,6 +114,13 @@ pub fn make_target_lib_path(sysroot: &Path, target_triple: &str) -> PathBuf { sysroot.join(&relative_target_lib_path(sysroot, target_triple)) } +pub fn target_lib_path(target_triple: &str) -> PathBuf { + let mut p = PathBuf::from(RUST_LIB_DIR); + p.push(target_triple); + p.push("lib"); + p +} + pub fn get_or_default_sysroot() -> PathBuf { // Follow symlinks. If the resolved path is relative, make it absolute. fn canonicalize(path: Option) -> Option { diff --git a/src/librustc/traits/coherence.rs b/src/librustc/traits/coherence.rs index 980c98d2a2d50..2050dbc91c93e 100644 --- a/src/librustc/traits/coherence.rs +++ b/src/librustc/traits/coherence.rs @@ -344,43 +344,68 @@ fn orphan_check_trait_ref<'tcx>(tcx: TyCtxt<'_, '_, '_>, trait_ref); } - // First, create an ordered iterator over all the type parameters to the trait, with the self - // type appearing first. - // Find the first input type that either references a type parameter OR - // some local type. - for input_ty in trait_ref.input_types() { - if ty_is_local(tcx, input_ty, in_crate) { - debug!("orphan_check_trait_ref: ty_is_local `{:?}`", input_ty); - - // First local input type. Check that there are no - // uncovered type parameters. - let uncovered_tys = uncovered_tys(tcx, input_ty, in_crate); - for uncovered_ty in uncovered_tys { - if let Some(param) = uncovered_ty.walk() - .find(|t| is_possibly_remote_type(t, in_crate)) - { - debug!("orphan_check_trait_ref: uncovered type `{:?}`", param); - return Err(OrphanCheckErr::UncoveredTy(param)); - } + if tcx.features().re_rebalance_coherence { + // Given impl Trait for T0, an impl is valid only + // if at least one of the following is true: + // + // - Trait is a local trait + // (already checked in orphan_check prior to calling this function) + // - All of + // - At least one of the types T0..=Tn must be a local type. + // Let Ti be the first such type. + // - No uncovered type parameters P1..=Pn may appear in T0..Ti (excluding Ti) + // + for input_ty in trait_ref.input_types() { + debug!("orphan_check_trait_ref: check ty `{:?}`", input_ty); + if ty_is_local(tcx, input_ty, in_crate) { + debug!("orphan_check_trait_ref: ty_is_local `{:?}`", input_ty); + return Ok(()); + } else if let ty::Param(_) = input_ty.sty { + debug!("orphan_check_trait_ref: uncovered ty: `{:?}`", input_ty); + return Err(OrphanCheckErr::UncoveredTy(input_ty)) } - - // OK, found local type, all prior types upheld invariant. - return Ok(()); } + // If we exit above loop, never found a local type. + debug!("orphan_check_trait_ref: no local type"); + Err(OrphanCheckErr::NoLocalInputType) + } else { + // First, create an ordered iterator over all the type + // parameters to the trait, with the self type appearing + // first. Find the first input type that either references a + // type parameter OR some local type. + for input_ty in trait_ref.input_types() { + if ty_is_local(tcx, input_ty, in_crate) { + debug!("orphan_check_trait_ref: ty_is_local `{:?}`", input_ty); + + // First local input type. Check that there are no + // uncovered type parameters. + let uncovered_tys = uncovered_tys(tcx, input_ty, in_crate); + for uncovered_ty in uncovered_tys { + if let Some(param) = uncovered_ty.walk() + .find(|t| is_possibly_remote_type(t, in_crate)) + { + debug!("orphan_check_trait_ref: uncovered type `{:?}`", param); + return Err(OrphanCheckErr::UncoveredTy(param)); + } + } - // Otherwise, enforce invariant that there are no type - // parameters reachable. - if let Some(param) = input_ty.walk() - .find(|t| is_possibly_remote_type(t, in_crate)) - { - debug!("orphan_check_trait_ref: uncovered type `{:?}`", param); - return Err(OrphanCheckErr::UncoveredTy(param)); + // OK, found local type, all prior types upheld invariant. + return Ok(()); + } + + // Otherwise, enforce invariant that there are no type + // parameters reachable. + if let Some(param) = input_ty.walk() + .find(|t| is_possibly_remote_type(t, in_crate)) + { + debug!("orphan_check_trait_ref: uncovered type `{:?}`", param); + return Err(OrphanCheckErr::UncoveredTy(param)); + } } + // If we exit above loop, never found a local type. + debug!("orphan_check_trait_ref: no local type"); + Err(OrphanCheckErr::NoLocalInputType) } - - // If we exit above loop, never found a local type. - debug!("orphan_check_trait_ref: no local type"); - return Err(OrphanCheckErr::NoLocalInputType); } fn uncovered_tys<'tcx>(tcx: TyCtxt<'_, '_, '_>, ty: Ty<'tcx>, in_crate: InCrate) diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index 0e63ef666c75a..bac2251013564 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -418,9 +418,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { Some(format!("[{}]", self.tcx.type_of(def.did).to_string())), )); let tcx = self.tcx; - if let Some(len) = len.val.try_to_scalar().and_then(|scalar| { - scalar.to_usize(&tcx).ok() - }) { + if let Some(len) = len.assert_usize(tcx) { flags.push(( "_Self".to_owned(), Some(format!("[{}; {}]", self.tcx.type_of(def.did).to_string(), len)), diff --git a/src/librustc/traits/project.rs b/src/librustc/traits/project.rs index 952b37b89f2d4..87e9c3b2c888a 100644 --- a/src/librustc/traits/project.rs +++ b/src/librustc/traits/project.rs @@ -15,7 +15,6 @@ use super::util; use hir::def_id::DefId; use infer::{InferCtxt, InferOk}; use infer::type_variable::TypeVariableOrigin; -use mir::interpret::ConstValue; use mir::interpret::{GlobalId}; use rustc_data_structures::snapshot_map::{Snapshot, SnapshotMap}; use syntax::ast::Ident; @@ -410,8 +409,8 @@ impl<'a, 'b, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for AssociatedTypeNormalizer<'a, } } - fn fold_const(&mut self, constant: &'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx> { - if let ConstValue::Unevaluated(def_id, substs) = constant.val { + fn fold_const(&mut self, constant: &'tcx ty::LazyConst<'tcx>) -> &'tcx ty::LazyConst<'tcx> { + if let ty::LazyConst::Unevaluated(def_id, substs) = *constant { let tcx = self.selcx.tcx().global_tcx(); if let Some(param_env) = self.tcx().lift_to_global(&self.param_env) { if substs.needs_infer() || substs.has_placeholders() { @@ -423,8 +422,9 @@ impl<'a, 'b, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for AssociatedTypeNormalizer<'a, promoted: None }; if let Ok(evaluated) = tcx.const_eval(param_env.and(cid)) { - let evaluated = evaluated.subst(self.tcx(), substs); - return self.fold_const(evaluated); + let substs = tcx.lift_to_global(&substs).unwrap(); + let evaluated = evaluated.subst(tcx, substs); + return tcx.intern_lazy_const(ty::LazyConst::Evaluated(evaluated)); } } } else { @@ -436,7 +436,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for AssociatedTypeNormalizer<'a, promoted: None }; if let Ok(evaluated) = tcx.const_eval(param_env.and(cid)) { - return self.fold_const(evaluated) + return tcx.intern_lazy_const(ty::LazyConst::Evaluated(evaluated)); } } } diff --git a/src/librustc/traits/query/normalize.rs b/src/librustc/traits/query/normalize.rs index 0d126d37546d6..be05445cfc61a 100644 --- a/src/librustc/traits/query/normalize.rs +++ b/src/librustc/traits/query/normalize.rs @@ -5,7 +5,7 @@ use infer::at::At; use infer::canonical::OriginalQueryValues; use infer::{InferCtxt, InferOk}; -use mir::interpret::{ConstValue, GlobalId}; +use mir::interpret::GlobalId; use traits::project::Normalized; use traits::{Obligation, ObligationCause, PredicateObligation, Reveal}; use ty::fold::{TypeFoldable, TypeFolder}; @@ -188,8 +188,8 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for QueryNormalizer<'cx, 'gcx, 'tcx } } - fn fold_const(&mut self, constant: &'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx> { - if let ConstValue::Unevaluated(def_id, substs) = constant.val { + fn fold_const(&mut self, constant: &'tcx ty::LazyConst<'tcx>) -> &'tcx ty::LazyConst<'tcx> { + if let ty::LazyConst::Unevaluated(def_id, substs) = *constant { let tcx = self.infcx.tcx.global_tcx(); if let Some(param_env) = self.tcx().lift_to_global(&self.param_env) { if substs.needs_infer() || substs.has_placeholders() { @@ -201,8 +201,9 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for QueryNormalizer<'cx, 'gcx, 'tcx promoted: None, }; if let Ok(evaluated) = tcx.const_eval(param_env.and(cid)) { - let evaluated = evaluated.subst(self.tcx(), substs); - return self.fold_const(evaluated); + let substs = tcx.lift_to_global(&substs).unwrap(); + let evaluated = evaluated.subst(tcx, substs); + return tcx.intern_lazy_const(ty::LazyConst::Evaluated(evaluated)); } } } else { @@ -214,7 +215,7 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for QueryNormalizer<'cx, 'gcx, 'tcx promoted: None, }; if let Ok(evaluated) = tcx.const_eval(param_env.and(cid)) { - return self.fold_const(evaluated) + return tcx.intern_lazy_const(ty::LazyConst::Evaluated(evaluated)); } } } diff --git a/src/librustc/ty/codec.rs b/src/librustc/ty/codec.rs index 6429e3249c4c5..e0e4d9c362a6c 100644 --- a/src/librustc/ty/codec.rs +++ b/src/librustc/ty/codec.rs @@ -247,12 +247,12 @@ pub fn decode_canonical_var_infos<'a, 'tcx, D>(decoder: &mut D) } #[inline] -pub fn decode_const<'a, 'tcx, D>(decoder: &mut D) - -> Result<&'tcx ty::Const<'tcx>, D::Error> +pub fn decode_lazy_const<'a, 'tcx, D>(decoder: &mut D) + -> Result<&'tcx ty::LazyConst<'tcx>, D::Error> where D: TyDecoder<'a, 'tcx>, 'tcx: 'a, { - Ok(decoder.tcx().mk_const(Decodable::decode(decoder)?)) + Ok(decoder.tcx().intern_lazy_const(Decodable::decode(decoder)?)) } #[inline] @@ -389,10 +389,10 @@ macro_rules! implement_ty_decoder { } } - impl<$($typaram),*> SpecializedDecoder<&'tcx $crate::ty::Const<'tcx>> + impl<$($typaram),*> SpecializedDecoder<&'tcx $crate::ty::LazyConst<'tcx>> for $DecoderName<$($typaram),*> { - fn specialized_decode(&mut self) -> Result<&'tcx ty::Const<'tcx>, Self::Error> { - decode_const(self) + fn specialized_decode(&mut self) -> Result<&'tcx ty::LazyConst<'tcx>, Self::Error> { + decode_lazy_const(self) } } diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 32348e2e5046d..6c377941dad19 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -29,7 +29,7 @@ use traits; use traits::{Clause, Clauses, GoalKind, Goal, Goals}; use ty::{self, Ty, TypeAndMut}; use ty::{TyS, TyKind, List}; -use ty::{AdtKind, AdtDef, ClosureSubsts, GeneratorSubsts, Region, Const}; +use ty::{AdtKind, AdtDef, ClosureSubsts, GeneratorSubsts, Region, Const, LazyConst}; use ty::{PolyFnSig, InferTy, ParamTy, ProjectionTy, ExistentialPredicate, Predicate}; use ty::RegionKind; use ty::{TyVar, TyVid, IntVar, IntVid, FloatVar, FloatVid}; @@ -122,7 +122,6 @@ pub struct CtxtInterners<'tcx> { region: InternedSet<'tcx, RegionKind>, existential_predicates: InternedSet<'tcx, List>>, predicates: InternedSet<'tcx, List>>, - const_: InternedSet<'tcx, Const<'tcx>>, clauses: InternedSet<'tcx, List>>, goal: InternedSet<'tcx, GoalKind<'tcx>>, goal_list: InternedSet<'tcx, List>>, @@ -140,7 +139,6 @@ impl<'gcx: 'tcx, 'tcx> CtxtInterners<'tcx> { existential_predicates: Default::default(), canonical_var_infos: Default::default(), predicates: Default::default(), - const_: Default::default(), clauses: Default::default(), goal: Default::default(), goal_list: Default::default(), @@ -1063,32 +1061,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { self.global_arenas.adt_def.alloc(def) } - pub fn alloc_byte_array(self, bytes: &[u8]) -> &'gcx [u8] { - if bytes.is_empty() { - &[] - } else { - self.global_interners.arena.alloc_slice(bytes) - } - } - - pub fn alloc_const_slice(self, values: &[&'tcx ty::Const<'tcx>]) - -> &'tcx [&'tcx ty::Const<'tcx>] { - if values.is_empty() { - &[] - } else { - self.interners.arena.alloc_slice(values) - } - } - - pub fn alloc_name_const_slice(self, values: &[(ast::Name, &'tcx ty::Const<'tcx>)]) - -> &'tcx [(ast::Name, &'tcx ty::Const<'tcx>)] { - if values.is_empty() { - &[] - } else { - self.interners.arena.alloc_slice(values) - } - } - pub fn intern_const_alloc( self, alloc: Allocation, @@ -1112,6 +1084,10 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { }) } + pub fn intern_lazy_const(self, c: ty::LazyConst<'tcx>) -> &'tcx ty::LazyConst<'tcx> { + self.global_interners.arena.alloc(c) + } + pub fn intern_layout(self, layout: LayoutDetails) -> &'gcx LayoutDetails { self.layout_interner.borrow_mut().intern(layout, |layout| { self.global_arenas.layout.alloc(layout) @@ -1725,218 +1701,69 @@ pub trait Lift<'tcx>: fmt::Debug { fn lift_to_tcx<'a, 'gcx>(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Option; } -impl<'a, 'tcx> Lift<'tcx> for Ty<'a> { - type Lifted = Ty<'tcx>; - fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option> { - if tcx.interners.arena.in_arena(*self as *const _) { - return Some(unsafe { mem::transmute(*self) }); - } - // Also try in the global tcx if we're not that. - if !tcx.is_global() { - self.lift_to_tcx(tcx.global_tcx()) - } else { - None - } - } -} - -impl<'a, 'tcx> Lift<'tcx> for Region<'a> { - type Lifted = Region<'tcx>; - fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option> { - if tcx.interners.arena.in_arena(*self as *const _) { - return Some(unsafe { mem::transmute(*self) }); - } - // Also try in the global tcx if we're not that. - if !tcx.is_global() { - self.lift_to_tcx(tcx.global_tcx()) - } else { - None - } - } -} - -impl<'a, 'tcx> Lift<'tcx> for Goal<'a> { - type Lifted = Goal<'tcx>; - fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option> { - if tcx.interners.arena.in_arena(*self as *const _) { - return Some(unsafe { mem::transmute(*self) }); - } - // Also try in the global tcx if we're not that. - if !tcx.is_global() { - self.lift_to_tcx(tcx.global_tcx()) - } else { - None - } - } -} - -impl<'a, 'tcx> Lift<'tcx> for &'a List> { - type Lifted = &'tcx List>; - fn lift_to_tcx<'b, 'gcx>( - &self, - tcx: TyCtxt<'b, 'gcx, 'tcx>, - ) -> Option<&'tcx List>> { - if self.is_empty() { - return Some(List::empty()); - } - - if tcx.interners.arena.in_arena(*self as *const _) { - return Some(unsafe { mem::transmute(*self) }); - } - // Also try in the global tcx if we're not that. - if !tcx.is_global() { - self.lift_to_tcx(tcx.global_tcx()) - } else { - None - } - } -} - -impl<'a, 'tcx> Lift<'tcx> for &'a List> { - type Lifted = &'tcx List>; - fn lift_to_tcx<'b, 'gcx>( - &self, - tcx: TyCtxt<'b, 'gcx, 'tcx>, - ) -> Option<&'tcx List>> { - if self.is_empty() { - return Some(List::empty()); - } - - if tcx.interners.arena.in_arena(*self as *const _) { - return Some(unsafe { mem::transmute(*self) }); - } - // Also try in the global tcx if we're not that. - if !tcx.is_global() { - self.lift_to_tcx(tcx.global_tcx()) - } else { - None - } - } -} -impl<'a, 'tcx> Lift<'tcx> for &'a Const<'a> { - type Lifted = &'tcx Const<'tcx>; - fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<&'tcx Const<'tcx>> { - if tcx.interners.arena.in_arena(*self as *const _) { - return Some(unsafe { mem::transmute(*self) }); - } - // Also try in the global tcx if we're not that. - if !tcx.is_global() { - self.lift_to_tcx(tcx.global_tcx()) - } else { - None +macro_rules! nop_lift { + ($ty:ty => $lifted:ty) => { + impl<'a, 'tcx> Lift<'tcx> for $ty { + type Lifted = $lifted; + fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option { + if tcx.interners.arena.in_arena(*self as *const _) { + return Some(unsafe { mem::transmute(*self) }); + } + // Also try in the global tcx if we're not that. + if !tcx.is_global() { + self.lift_to_tcx(tcx.global_tcx()) + } else { + None + } + } } - } + }; } -impl<'a, 'tcx> Lift<'tcx> for &'a Substs<'a> { - type Lifted = &'tcx Substs<'tcx>; - fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<&'tcx Substs<'tcx>> { - if self.len() == 0 { - return Some(List::empty()); - } - if tcx.interners.arena.in_arena(&self[..] as *const _) { - return Some(unsafe { mem::transmute(*self) }); - } - // Also try in the global tcx if we're not that. - if !tcx.is_global() { - self.lift_to_tcx(tcx.global_tcx()) - } else { - None +macro_rules! nop_list_lift { + ($ty:ty => $lifted:ty) => { + impl<'a, 'tcx> Lift<'tcx> for &'a List<$ty> { + type Lifted = &'tcx List<$lifted>; + fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option { + if self.is_empty() { + return Some(List::empty()); + } + if tcx.interners.arena.in_arena(*self as *const _) { + return Some(unsafe { mem::transmute(*self) }); + } + // Also try in the global tcx if we're not that. + if !tcx.is_global() { + self.lift_to_tcx(tcx.global_tcx()) + } else { + None + } + } } - } + }; } -impl<'a, 'tcx> Lift<'tcx> for &'a List> { - type Lifted = &'tcx List>; - fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) - -> Option<&'tcx List>> { - if self.len() == 0 { - return Some(List::empty()); - } - if tcx.interners.arena.in_arena(*self as *const _) { - return Some(unsafe { mem::transmute(*self) }); - } - // Also try in the global tcx if we're not that. - if !tcx.is_global() { - self.lift_to_tcx(tcx.global_tcx()) - } else { - None - } - } -} +nop_lift!{Ty<'a> => Ty<'tcx>} +nop_lift!{Region<'a> => Region<'tcx>} +nop_lift!{Goal<'a> => Goal<'tcx>} +nop_lift!{&'a LazyConst<'a> => &'tcx LazyConst<'tcx>} -impl<'a, 'tcx> Lift<'tcx> for &'a List> { - type Lifted = &'tcx List>; - fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) - -> Option<&'tcx List>> { - if self.is_empty() { - return Some(List::empty()); - } - if tcx.interners.arena.in_arena(*self as *const _) { - return Some(unsafe { mem::transmute(*self) }); - } - // Also try in the global tcx if we're not that. - if !tcx.is_global() { - self.lift_to_tcx(tcx.global_tcx()) - } else { - None - } - } -} +nop_list_lift!{Goal<'a> => Goal<'tcx>} +nop_list_lift!{Clause<'a> => Clause<'tcx>} +nop_list_lift!{Ty<'a> => Ty<'tcx>} +nop_list_lift!{ExistentialPredicate<'a> => ExistentialPredicate<'tcx>} +nop_list_lift!{Predicate<'a> => Predicate<'tcx>} +nop_list_lift!{CanonicalVarInfo => CanonicalVarInfo} +nop_list_lift!{ProjectionKind<'a> => ProjectionKind<'tcx>} -impl<'a, 'tcx> Lift<'tcx> for &'a List> { - type Lifted = &'tcx List>; - fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) - -> Option<&'tcx List>> { - if self.is_empty() { - return Some(List::empty()); - } - if tcx.interners.arena.in_arena(*self as *const _) { - return Some(unsafe { mem::transmute(*self) }); - } - // Also try in the global tcx if we're not that. - if !tcx.is_global() { - self.lift_to_tcx(tcx.global_tcx()) - } else { - None - } - } -} +// this is the impl for `&'a Substs<'a>` +nop_list_lift!{Kind<'a> => Kind<'tcx>} -impl<'a, 'tcx> Lift<'tcx> for &'a List { - type Lifted = &'tcx List; +impl<'a, 'tcx> Lift<'tcx> for &'a mir::interpret::Allocation { + type Lifted = &'tcx mir::interpret::Allocation; fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option { - if self.len() == 0 { - return Some(List::empty()); - } - if tcx.interners.arena.in_arena(*self as *const _) { - return Some(unsafe { mem::transmute(*self) }); - } - // Also try in the global tcx if we're not that. - if !tcx.is_global() { - self.lift_to_tcx(tcx.global_tcx()) - } else { - None - } - } -} - -impl<'a, 'tcx> Lift<'tcx> for &'a List> { - type Lifted = &'tcx List>; - fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option { - if self.len() == 0 { - return Some(List::empty()); - } - if tcx.interners.arena.in_arena(*self as *const _) { - return Some(unsafe { mem::transmute(*self) }); - } - // Also try in the global tcx if we're not that. - if !tcx.is_global() { - self.lift_to_tcx(tcx.global_tcx()) - } else { - None - } + assert!(tcx.global_arenas.const_allocs.in_arena(*self as *const _)); + Some(unsafe { mem::transmute(*self) }) } } @@ -2497,7 +2324,6 @@ pub fn keep_local<'tcx, T: ty::TypeFoldable<'tcx>>(x: &T) -> bool { direct_interners!('tcx, region: mk_region(|r: &RegionKind| r.keep_in_local_tcx()) -> RegionKind, - const_: mk_const(|c: &Const<'_>| keep_local(&c.ty) || keep_local(&c.val)) -> Const<'tcx>, goal: mk_goal(|c: &GoalKind<'_>| keep_local(c)) -> GoalKind<'tcx> ); @@ -2683,7 +2509,9 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { #[inline] pub fn mk_array(self, ty: Ty<'tcx>, n: u64) -> Ty<'tcx> { - self.mk_ty(Array(ty, ty::Const::from_usize(self, n))) + self.mk_ty(Array(ty, self.intern_lazy_const( + ty::LazyConst::Evaluated(ty::Const::from_usize(self.global_tcx(), n)) + ))) } #[inline] diff --git a/src/librustc/ty/error.rs b/src/librustc/ty/error.rs index 6b931e39a05da..ea2f1e53a3881 100644 --- a/src/librustc/ty/error.rs +++ b/src/librustc/ty/error.rs @@ -167,11 +167,12 @@ impl<'a, 'gcx, 'lcx, 'tcx> ty::TyS<'tcx> { ty::Adt(def, _) => format!("{} `{}`", def.descr(), tcx.item_path_str(def.did)).into(), ty::Foreign(def_id) => format!("extern type `{}`", tcx.item_path_str(def_id)).into(), - ty::Array(_, n) => { - match n.assert_usize(tcx) { + ty::Array(_, n) => match n { + ty::LazyConst::Evaluated(n) => match n.assert_usize(tcx) { Some(n) => format!("array of {} elements", n).into(), None => "array".into(), - } + }, + ty::LazyConst::Unevaluated(..) => "array".into(), } ty::Slice(_) => "slice".into(), ty::RawPtr(_) => "*-ptr".into(), diff --git a/src/librustc/ty/flags.rs b/src/librustc/ty/flags.rs index 6ee24187e3326..4fa13a01d5a92 100644 --- a/src/librustc/ty/flags.rs +++ b/src/librustc/ty/flags.rs @@ -1,4 +1,3 @@ -use mir::interpret::ConstValue; use ty::subst::Substs; use ty::{self, Ty, TypeFlags, TypeFoldable}; @@ -173,7 +172,10 @@ impl FlagComputation { &ty::Array(tt, len) => { self.add_ty(tt); - self.add_const(len); + if let ty::LazyConst::Unevaluated(_, substs) = len { + self.add_flags(TypeFlags::HAS_PROJECTION); + self.add_substs(substs); + } } &ty::Slice(tt) => { @@ -230,14 +232,6 @@ impl FlagComputation { } } - fn add_const(&mut self, constant: &ty::Const<'_>) { - self.add_ty(constant.ty); - if let ConstValue::Unevaluated(_, substs) = constant.val { - self.add_flags(TypeFlags::HAS_PROJECTION); - self.add_substs(substs); - } - } - fn add_existential_projection(&mut self, projection: &ty::ExistentialProjection<'_>) { self.add_substs(projection.substs); self.add_ty(projection.ty); diff --git a/src/librustc/ty/fold.rs b/src/librustc/ty/fold.rs index 0a72f733b51e5..4495e9654c984 100644 --- a/src/librustc/ty/fold.rs +++ b/src/librustc/ty/fold.rs @@ -29,7 +29,6 @@ //! These methods return true to indicate that the visitor has found what it is looking for //! and does not need to visit anything else. -use mir::interpret::ConstValue; use hir::def_id::DefId; use ty::{self, Binder, Ty, TyCtxt, TypeFlags}; @@ -164,7 +163,7 @@ pub trait TypeFolder<'gcx: 'tcx, 'tcx> : Sized { r.super_fold_with(self) } - fn fold_const(&mut self, c: &'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx> { + fn fold_const(&mut self, c: &'tcx ty::LazyConst<'tcx>) -> &'tcx ty::LazyConst<'tcx> { c.super_fold_with(self) } } @@ -182,7 +181,7 @@ pub trait TypeVisitor<'tcx> : Sized { r.super_visit_with(self) } - fn visit_const(&mut self, c: &'tcx ty::Const<'tcx>) -> bool { + fn visit_const(&mut self, c: &'tcx ty::LazyConst<'tcx>) -> bool { c.super_visit_with(self) } } @@ -864,8 +863,8 @@ impl<'tcx> TypeVisitor<'tcx> for HasTypeFlagsVisitor { flags.intersects(self.flags) } - fn visit_const(&mut self, c: &'tcx ty::Const<'tcx>) -> bool { - if let ConstValue::Unevaluated(..) = c.val { + fn visit_const(&mut self, c: &'tcx ty::LazyConst<'tcx>) -> bool { + if let ty::LazyConst::Unevaluated(..) = c { let projection_flags = TypeFlags::HAS_NORMALIZABLE_PROJECTION | TypeFlags::HAS_PROJECTION; if projection_flags.intersects(self.flags) { diff --git a/src/librustc/ty/inhabitedness/mod.rs b/src/librustc/ty/inhabitedness/mod.rs index 29d201c1179e5..6dfc9681cfd86 100644 --- a/src/librustc/ty/inhabitedness/mod.rs +++ b/src/librustc/ty/inhabitedness/mod.rs @@ -1,6 +1,6 @@ use ty::context::TyCtxt; use ty::{AdtDef, VariantDef, FieldDef, Ty, TyS}; -use ty::{DefId, Substs}; +use ty::{self, DefId, Substs}; use ty::{AdtKind, Visibility}; use ty::TyKind::*; @@ -213,11 +213,14 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> { } Array(ty, len) => { - match len.assert_usize(tcx) { - // If the array is definitely non-empty, it's uninhabited if - // the type of its elements is uninhabited. - Some(n) if n != 0 => ty.uninhabited_from(tcx), - _ => DefIdForest::empty() + match len { + ty::LazyConst::Unevaluated(..) => DefIdForest::empty(), + ty::LazyConst::Evaluated(len) => match len.assert_usize(tcx) { + // If the array is definitely non-empty, it's uninhabited if + // the type of its elements is uninhabited. + Some(n) if n != 0 => ty.uninhabited_from(tcx), + _ => DefIdForest::empty() + }, } } diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index d40dd830e9fb9..10fb2f2d03953 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -59,7 +59,7 @@ pub use self::sty::{InferTy, ParamTy, ProjectionTy, ExistentialPredicate}; pub use self::sty::{ClosureSubsts, GeneratorSubsts, UpvarSubsts, TypeAndMut}; pub use self::sty::{TraitRef, TyKind, PolyTraitRef}; pub use self::sty::{ExistentialTraitRef, PolyExistentialTraitRef}; -pub use self::sty::{ExistentialProjection, PolyExistentialProjection, Const}; +pub use self::sty::{ExistentialProjection, PolyExistentialProjection, Const, LazyConst}; pub use self::sty::{BoundRegion, EarlyBoundRegion, FreeRegion, Region}; pub use self::sty::RegionKind; pub use self::sty::{TyVid, IntVid, FloatVid, RegionVid}; @@ -2801,7 +2801,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { self.impl_polarity(def_id1) == self.impl_polarity(def_id2) && trait1_is_empty && trait2_is_empty - } else if self.features().marker_trait_attr { + } else { let is_marker_impl = |def_id: DefId| -> bool { let trait_ref = self.impl_trait_ref(def_id); trait_ref.map_or(false, |tr| self.trait_def(tr.def_id).is_marker) @@ -2809,8 +2809,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { self.impl_polarity(def_id1) == self.impl_polarity(def_id2) && is_marker_impl(def_id1) && is_marker_impl(def_id2) - } else { - false } } diff --git a/src/librustc/ty/query/keys.rs b/src/librustc/ty/query/keys.rs index 959a5ff5767a3..af6f5a00dee5c 100644 --- a/src/librustc/ty/query/keys.rs +++ b/src/librustc/ty/query/keys.rs @@ -136,7 +136,7 @@ impl<'tcx> Key for ty::PolyTraitRef<'tcx>{ } } -impl<'tcx> Key for &'tcx ty::Const<'tcx> { +impl<'tcx> Key for ty::Const<'tcx> { fn query_crate(&self) -> CrateNum { LOCAL_CRATE } diff --git a/src/librustc/ty/query/plumbing.rs b/src/librustc/ty/query/plumbing.rs index 6887f480f72e0..2f23f1e30295b 100644 --- a/src/librustc/ty/query/plumbing.rs +++ b/src/librustc/ty/query/plumbing.rs @@ -974,7 +974,7 @@ macro_rules! define_queries_inner { // HACK(eddyb) it's possible crates may be loaded after // the query engine is created, and because crate loading // is not yet integrated with the query engine, such crates - // would be be missing appropriate entries in `providers`. + // would be missing appropriate entries in `providers`. .unwrap_or(&tcx.queries.fallback_extern_providers) .$name; provider(tcx.global_tcx(), key) diff --git a/src/librustc/ty/relate.rs b/src/librustc/ty/relate.rs index 84e15a751353e..6d310a9500a62 100644 --- a/src/librustc/ty/relate.rs +++ b/src/librustc/ty/relate.rs @@ -5,7 +5,6 @@ //! subtyping, type equality, etc. use hir::def_id::DefId; -use mir::interpret::ConstValue; use ty::subst::{Kind, UnpackedKind, Substs}; use ty::{self, Ty, TyCtxt, TypeFoldable}; use ty::error::{ExpectedFound, TypeError}; @@ -480,14 +479,9 @@ pub fn super_relate_tys<'a, 'gcx, 'tcx, R>(relation: &mut R, (&ty::Array(a_t, sz_a), &ty::Array(b_t, sz_b)) => { let t = relation.relate(&a_t, &b_t)?; - assert_eq!(sz_a.ty, tcx.types.usize); - assert_eq!(sz_b.ty, tcx.types.usize); - let to_u64 = |x: &'tcx ty::Const<'tcx>| -> Result { - if let Some(s) = x.assert_usize(tcx) { - return Ok(s); - } - match x.val { - ConstValue::Unevaluated(def_id, substs) => { + let to_u64 = |x: ty::LazyConst<'tcx>| -> Result { + match x { + ty::LazyConst::Unevaluated(def_id, substs) => { // FIXME(eddyb) get the right param_env. let param_env = ty::ParamEnv::empty(); if let Some(substs) = tcx.lift_to_global(&substs) { @@ -513,14 +507,14 @@ pub fn super_relate_tys<'a, 'gcx, 'tcx, R>(relation: &mut R, "array length could not be evaluated"); Err(ErrorReported) } - _ => { + ty::LazyConst::Evaluated(c) => c.assert_usize(tcx).ok_or_else(|| { tcx.sess.delay_span_bug(DUMMY_SP, - &format!("arrays should not have {:?} as length", x)); - Err(ErrorReported) - } + "array length could not be evaluated"); + ErrorReported + }) } }; - match (to_u64(sz_a), to_u64(sz_b)) { + match (to_u64(*sz_a), to_u64(*sz_b)) { (Ok(sz_a_u64), Ok(sz_b_u64)) => { if sz_a_u64 == sz_b_u64 { Ok(tcx.mk_ty(ty::Array(t, sz_a))) diff --git a/src/librustc/ty/structural_impls.rs b/src/librustc/ty/structural_impls.rs index 4755adc4cd10d..6e599531f25ee 100644 --- a/src/librustc/ty/structural_impls.rs +++ b/src/librustc/ty/structural_impls.rs @@ -491,6 +491,26 @@ BraceStructLiftImpl! { } } +BraceStructLiftImpl! { + impl<'a, 'tcx> Lift<'tcx> for ty::Const<'a> { + type Lifted = ty::Const<'tcx>; + val, ty + } +} + +impl<'a, 'tcx> Lift<'tcx> for ConstValue<'a> { + type Lifted = ConstValue<'tcx>; + fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option { + match *self { + ConstValue::Scalar(x) => Some(ConstValue::Scalar(x)), + ConstValue::ScalarPair(x, y) => Some(ConstValue::ScalarPair(x, y)), + ConstValue::ByRef(x, alloc, z) => Some(ConstValue::ByRef( + x, alloc.lift_to_tcx(tcx)?, z, + )), + } + } +} + /////////////////////////////////////////////////////////////////////////// // TypeFoldable implementations. // @@ -1020,47 +1040,54 @@ EnumTypeFoldableImpl! { } } -impl<'tcx> TypeFoldable<'tcx> for ConstValue<'tcx> { +impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::LazyConst<'tcx> { fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { - match *self { - ConstValue::Scalar(v) => ConstValue::Scalar(v), - ConstValue::ScalarPair(a, b) => ConstValue::ScalarPair(a, b), - ConstValue::ByRef(id, alloc, offset) => ConstValue::ByRef(id, alloc, offset), - ConstValue::Unevaluated(def_id, substs) => { - ConstValue::Unevaluated(def_id, substs.fold_with(folder)) + let new = match self { + ty::LazyConst::Evaluated(v) => ty::LazyConst::Evaluated(v.fold_with(folder)), + ty::LazyConst::Unevaluated(def_id, substs) => { + ty::LazyConst::Unevaluated(*def_id, substs.fold_with(folder)) } - } + }; + folder.tcx().intern_lazy_const(new) + } + + fn fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { + folder.fold_const(*self) } fn super_visit_with>(&self, visitor: &mut V) -> bool { match *self { - ConstValue::Scalar(_) | - ConstValue::ScalarPair(_, _) | - ConstValue::ByRef(_, _, _) => false, - ConstValue::Unevaluated(_, substs) => substs.visit_with(visitor), + ty::LazyConst::Evaluated(c) => c.visit_with(visitor), + ty::LazyConst::Unevaluated(_, substs) => substs.visit_with(visitor), } } + + fn visit_with>(&self, visitor: &mut V) -> bool { + visitor.visit_const(self) + } } -impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::Const<'tcx> { +impl<'tcx> TypeFoldable<'tcx> for ty::Const<'tcx> { fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { let ty = self.ty.fold_with(folder); let val = self.val.fold_with(folder); - folder.tcx().mk_const(ty::Const { + ty::Const { ty, val - }) - } - - fn fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { - folder.fold_const(*self) + } } fn super_visit_with>(&self, visitor: &mut V) -> bool { self.ty.visit_with(visitor) || self.val.visit_with(visitor) } +} - fn visit_with>(&self, visitor: &mut V) -> bool { - visitor.visit_const(self) +impl<'tcx> TypeFoldable<'tcx> for ConstValue<'tcx> { + fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, _folder: &mut F) -> Self { + *self + } + + fn super_visit_with>(&self, _visitor: &mut V) -> bool { + false } } diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index f7adb83f8eb18..be33911d4849c 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -113,7 +113,7 @@ pub enum TyKind<'tcx> { Str, /// An array with the given length. Written as `[T; n]`. - Array(Ty<'tcx>, &'tcx ty::Const<'tcx>), + Array(Ty<'tcx>, &'tcx ty::LazyConst<'tcx>), /// The pointee of an array slice. Written as `[T]`. Slice(Ty<'tcx>), @@ -2013,6 +2013,32 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> { } } +#[derive(Copy, Clone, Debug, Hash, RustcEncodable, RustcDecodable, Eq, PartialEq, Ord, PartialOrd)] +/// Used in the HIR by using `Unevaluated` everywhere and later normalizing to `Evaluated` if the +/// code is monomorphic enough for that. +pub enum LazyConst<'tcx> { + Unevaluated(DefId, &'tcx Substs<'tcx>), + Evaluated(Const<'tcx>), +} + +impl<'tcx> LazyConst<'tcx> { + pub fn map_evaluated(self, f: impl FnOnce(Const<'tcx>) -> Option) -> Option { + match self { + LazyConst::Evaluated(c) => f(c), + LazyConst::Unevaluated(..) => None, + } + } + + pub fn assert_usize(self, tcx: TyCtxt<'_, '_, '_>) -> Option { + self.map_evaluated(|c| c.assert_usize(tcx)) + } + + #[inline] + pub fn unwrap_usize(&self, tcx: TyCtxt<'_, '_, '_>) -> u64 { + self.assert_usize(tcx).expect("expected `LazyConst` to contain a usize") + } +} + /// Typed constant value. #[derive(Copy, Clone, Debug, Hash, RustcEncodable, RustcDecodable, Eq, PartialEq, Ord, PartialOrd)] pub struct Const<'tcx> { @@ -2022,37 +2048,15 @@ pub struct Const<'tcx> { } impl<'tcx> Const<'tcx> { - pub fn unevaluated( - tcx: TyCtxt<'_, '_, 'tcx>, - def_id: DefId, - substs: &'tcx Substs<'tcx>, - ty: Ty<'tcx>, - ) -> &'tcx Self { - tcx.mk_const(Const { - val: ConstValue::Unevaluated(def_id, substs), - ty, - }) - } - - #[inline] - pub fn from_const_value( - tcx: TyCtxt<'_, '_, 'tcx>, - val: ConstValue<'tcx>, - ty: Ty<'tcx>, - ) -> &'tcx Self { - tcx.mk_const(Const { - val, - ty, - }) - } - #[inline] pub fn from_scalar( - tcx: TyCtxt<'_, '_, 'tcx>, val: Scalar, ty: Ty<'tcx>, - ) -> &'tcx Self { - Self::from_const_value(tcx, ConstValue::Scalar(val), ty) + ) -> Self { + Self { + val: ConstValue::Scalar(val), + ty, + } } #[inline] @@ -2060,7 +2064,7 @@ impl<'tcx> Const<'tcx> { tcx: TyCtxt<'_, '_, 'tcx>, bits: u128, ty: ParamEnvAnd<'tcx, Ty<'tcx>>, - ) -> &'tcx Self { + ) -> Self { let ty = tcx.lift_to_global(&ty).unwrap(); let size = tcx.layout_of(ty).unwrap_or_else(|e| { panic!("could not compute layout for {:?}: {:?}", ty, e) @@ -2068,21 +2072,21 @@ impl<'tcx> Const<'tcx> { let shift = 128 - size.bits(); let truncated = (bits << shift) >> shift; assert_eq!(truncated, bits, "from_bits called with untruncated value"); - Self::from_scalar(tcx, Scalar::Bits { bits, size: size.bytes() as u8 }, ty.value) + Self::from_scalar(Scalar::Bits { bits, size: size.bytes() as u8 }, ty.value) } #[inline] - pub fn zero_sized(tcx: TyCtxt<'_, '_, 'tcx>, ty: Ty<'tcx>) -> &'tcx Self { - Self::from_scalar(tcx, Scalar::Bits { bits: 0, size: 0 }, ty) + pub fn zero_sized(ty: Ty<'tcx>) -> Self { + Self::from_scalar(Scalar::Bits { bits: 0, size: 0 }, ty) } #[inline] - pub fn from_bool(tcx: TyCtxt<'_, '_, 'tcx>, v: bool) -> &'tcx Self { + pub fn from_bool(tcx: TyCtxt<'_, '_, 'tcx>, v: bool) -> Self { Self::from_bits(tcx, v as u128, ParamEnv::empty().and(tcx.types.bool)) } #[inline] - pub fn from_usize(tcx: TyCtxt<'_, '_, 'tcx>, n: u64) -> &'tcx Self { + pub fn from_usize(tcx: TyCtxt<'_, '_, 'tcx>, n: u64) -> Self { Self::from_bits(tcx, n as u128, ParamEnv::empty().and(tcx.types.usize)) } @@ -2148,4 +2152,4 @@ impl<'tcx> Const<'tcx> { } } -impl<'tcx> serialize::UseSpecializedDecodable for &'tcx Const<'tcx> {} +impl<'tcx> serialize::UseSpecializedDecodable for &'tcx LazyConst<'tcx> {} diff --git a/src/librustc/ty/walk.rs b/src/librustc/ty/walk.rs index a2cc859e4a82d..6887d092fcd62 100644 --- a/src/librustc/ty/walk.rs +++ b/src/librustc/ty/walk.rs @@ -1,7 +1,6 @@ //! An iterator over the type substructure. //! WARNING: this does not keep track of the region depth. -use mir::interpret::ConstValue; use ty::{self, Ty}; use smallvec::{self, SmallVec}; @@ -75,7 +74,9 @@ fn push_subtypes<'tcx>(stack: &mut TypeWalkerStack<'tcx>, parent_ty: Ty<'tcx>) { ty::Placeholder(..) | ty::Bound(..) | ty::Foreign(..) => { } ty::Array(ty, len) => { - push_const(stack, len); + if let ty::LazyConst::Unevaluated(_, substs) = len { + stack.extend(substs.types().rev()); + } stack.push(ty); } ty::Slice(ty) => { @@ -128,10 +129,3 @@ fn push_subtypes<'tcx>(stack: &mut TypeWalkerStack<'tcx>, parent_ty: Ty<'tcx>) { } } } - -fn push_const<'tcx>(stack: &mut TypeWalkerStack<'tcx>, constant: &'tcx ty::Const<'tcx>) { - if let ConstValue::Unevaluated(_, substs) = constant.val { - stack.extend(substs.types().rev()); - } - stack.push(constant.ty); -} diff --git a/src/librustc/ty/wf.rs b/src/librustc/ty/wf.rs index aacc63c47de61..517cfd9edfaf9 100644 --- a/src/librustc/ty/wf.rs +++ b/src/librustc/ty/wf.rs @@ -1,5 +1,4 @@ use hir::def_id::DefId; -use mir::interpret::ConstValue; use infer::InferCtxt; use ty::subst::Substs; use traits; @@ -202,11 +201,10 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> { } } - /// Pushes the obligations required for a constant value to be WF + /// Pushes the obligations required for an array length to be WF /// into `self.out`. - fn compute_const(&mut self, constant: &'tcx ty::Const<'tcx>) { - self.require_sized(constant.ty, traits::ConstSized); - if let ConstValue::Unevaluated(def_id, substs) = constant.val { + fn compute_array_len(&mut self, constant: ty::LazyConst<'tcx>) { + if let ty::LazyConst::Unevaluated(def_id, substs) = constant { let obligations = self.nominal_obligations(def_id, substs); self.out.extend(obligations); @@ -260,8 +258,7 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> { ty::Array(subty, len) => { self.require_sized(subty, traits::SliceOrArrayElem); - assert_eq!(len.ty, self.infcx.tcx.types.usize); - self.compute_const(len); + self.compute_array_len(*len); } ty::Tuple(ref tys) => { diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 318d7adb19011..1356fbb6489cc 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -1,6 +1,5 @@ use hir::def_id::DefId; use hir::map::definitions::DefPathData; -use mir::interpret::ConstValue; use middle::region; use ty::subst::{self, Subst}; use ty::{BrAnon, BrEnv, BrFresh, BrNamed}; @@ -1272,12 +1271,12 @@ define_print! { }), Array(ty, sz) => { print!(f, cx, write("["), print(ty), write("; "))?; - match sz.val { - ConstValue::Unevaluated(_def_id, _substs) => { + match sz { + ty::LazyConst::Unevaluated(_def_id, _substs) => { write!(f, "_")?; } - _ => ty::tls::with(|tcx| { - write!(f, "{}", sz.unwrap_usize(tcx)) + ty::LazyConst::Evaluated(c) => ty::tls::with(|tcx| { + write!(f, "{}", c.unwrap_usize(tcx)) })?, } write!(f, "]") diff --git a/src/librustc_codegen_ssa/mir/block.rs b/src/librustc_codegen_ssa/mir/block.rs index 7397c722df6c9..aa82c853257a3 100644 --- a/src/librustc_codegen_ssa/mir/block.rs +++ b/src/librustc_codegen_ssa/mir/block.rs @@ -500,53 +500,57 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { _ => bx.new_fn_type(sig, &extra_args) }; - // emit a panic instead of instantiating an uninhabited type - if (intrinsic == Some("init") || intrinsic == Some("uninit")) && - fn_ty.ret.layout.abi.is_uninhabited() - { - let loc = bx.sess().source_map().lookup_char_pos(span.lo()); - let filename = Symbol::intern(&loc.file.name.to_string()).as_str(); - let filename = bx.const_str_slice(filename); - let line = bx.const_u32(loc.line as u32); - let col = bx.const_u32(loc.col.to_usize() as u32 + 1); - let align = tcx.data_layout.aggregate_align.abi - .max(tcx.data_layout.i32_align.abi) - .max(tcx.data_layout.pointer_align.abi); - - let str = format!( - "Attempted to instantiate uninhabited type {} using mem::{}", - sig.output(), - if intrinsic == Some("init") { "zeroed" } else { "uninitialized" } - ); - let msg_str = Symbol::intern(&str).as_str(); - let msg_str = bx.const_str_slice(msg_str); - let msg_file_line_col = bx.const_struct( - &[msg_str, filename, line, col], - false, - ); - let msg_file_line_col = bx.static_addr_of( - msg_file_line_col, - align, - Some("panic_loc"), - ); + // emit a panic or a NOP for `panic_if_uninhabited` + if intrinsic == Some("panic_if_uninhabited") { + let ty = instance.unwrap().substs.type_at(0); + let layout = bx.layout_of(ty); + if layout.abi.is_uninhabited() { + let loc = bx.sess().source_map().lookup_char_pos(span.lo()); + let filename = Symbol::intern(&loc.file.name.to_string()).as_str(); + let filename = bx.const_str_slice(filename); + let line = bx.const_u32(loc.line as u32); + let col = bx.const_u32(loc.col.to_usize() as u32 + 1); + let align = tcx.data_layout.aggregate_align.abi + .max(tcx.data_layout.i32_align.abi) + .max(tcx.data_layout.pointer_align.abi); + + let str = format!( + "Attempted to instantiate uninhabited type {}", + ty + ); + let msg_str = Symbol::intern(&str).as_str(); + let msg_str = bx.const_str_slice(msg_str); + let msg_file_line_col = bx.const_struct( + &[msg_str, filename, line, col], + false, + ); + let msg_file_line_col = bx.static_addr_of( + msg_file_line_col, + align, + Some("panic_loc"), + ); - // Obtain the panic entry point. - let def_id = - common::langcall(bx.tcx(), Some(span), "", lang_items::PanicFnLangItem); - let instance = ty::Instance::mono(bx.tcx(), def_id); - let fn_ty = bx.fn_type_of_instance(&instance); - let llfn = bx.get_fn(instance); - - // Codegen the actual panic invoke/call. - do_call( - self, - &mut bx, - fn_ty, - llfn, - &[msg_file_line_col], - destination.as_ref().map(|(_, bb)| (ReturnDest::Nothing, *bb)), - cleanup, - ); + // Obtain the panic entry point. + let def_id = + common::langcall(bx.tcx(), Some(span), "", lang_items::PanicFnLangItem); + let instance = ty::Instance::mono(bx.tcx(), def_id); + let fn_ty = bx.fn_type_of_instance(&instance); + let llfn = bx.get_fn(instance); + + // Codegen the actual panic invoke/call. + do_call( + self, + &mut bx, + fn_ty, + llfn, + &[msg_file_line_col], + destination.as_ref().map(|(_, bb)| (ReturnDest::Nothing, *bb)), + cleanup, + ); + } else { + // a NOP + funclet_br(self, &mut bx, destination.as_ref().unwrap().1); + } return; } diff --git a/src/librustc_codegen_ssa/mir/constant.rs b/src/librustc_codegen_ssa/mir/constant.rs index 1a48ad87a6e15..e6d6ef1d7a38b 100644 --- a/src/librustc_codegen_ssa/mir/constant.rs +++ b/src/librustc_codegen_ssa/mir/constant.rs @@ -2,7 +2,7 @@ use rustc::mir::interpret::ErrorHandled; use rustc_mir::const_eval::const_field; use rustc::mir; use rustc_data_structures::indexed_vec::Idx; -use rustc::mir::interpret::{GlobalId, ConstValue}; +use rustc::mir::interpret::GlobalId; use rustc::ty::{self, Ty}; use rustc::ty::layout; use syntax::source_map::Span; @@ -14,10 +14,10 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { fn fully_evaluate( &mut self, bx: &Bx, - constant: &'tcx ty::Const<'tcx>, - ) -> Result<&'tcx ty::Const<'tcx>, ErrorHandled> { - match constant.val { - ConstValue::Unevaluated(def_id, ref substs) => { + constant: &'tcx ty::LazyConst<'tcx>, + ) -> Result, ErrorHandled> { + match *constant { + ty::LazyConst::Unevaluated(def_id, ref substs) => { let tcx = bx.tcx(); let param_env = ty::ParamEnv::reveal_all(); let instance = ty::Instance::resolve(tcx, param_env, def_id, substs).unwrap(); @@ -27,7 +27,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { }; tcx.const_eval(param_env.and(cid)) }, - _ => Ok(constant), + ty::LazyConst::Evaluated(constant) => Ok(constant), } } @@ -35,7 +35,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { &mut self, bx: &Bx, constant: &mir::Constant<'tcx>, - ) -> Result<&'tcx ty::Const<'tcx>, ErrorHandled> { + ) -> Result, ErrorHandled> { let c = self.monomorphize(&constant.literal); self.fully_evaluate(bx, c) } @@ -46,7 +46,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { bx: &Bx, span: Span, ty: Ty<'tcx>, - constant: Result<&'tcx ty::Const<'tcx>, ErrorHandled>, + constant: Result, ErrorHandled>, ) -> (Bx::Value, Ty<'tcx>) { constant .and_then(|c| { diff --git a/src/librustc_codegen_ssa/mir/operand.rs b/src/librustc_codegen_ssa/mir/operand.rs index 1dbed30842a82..2026e042ef0eb 100644 --- a/src/librustc_codegen_ssa/mir/operand.rs +++ b/src/librustc_codegen_ssa/mir/operand.rs @@ -67,7 +67,7 @@ impl<'a, 'tcx: 'a, V: CodegenObject> OperandRef<'tcx, V> { pub fn from_const>( bx: &mut Bx, - val: &'tcx ty::Const<'tcx> + val: ty::Const<'tcx> ) -> Result { let layout = bx.cx().layout_of(val.ty); @@ -76,7 +76,6 @@ impl<'a, 'tcx: 'a, V: CodegenObject> OperandRef<'tcx, V> { } let val = match val.val { - ConstValue::Unevaluated(..) => bug!(), ConstValue::Scalar(x) => { let scalar = match layout.abi { layout::Abi::Scalar(ref x) => x, diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 9b232edc11d4a..9bb5747665600 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -1101,23 +1101,20 @@ where ast_validation::check_crate(sess, &krate) }); - time(sess, "name resolution", || -> CompileResult { + time(sess, "name resolution", || { resolver.resolve_crate(&krate); - Ok(()) - })?; + }); // Needs to go *after* expansion to be able to check the results of macro expansion. time(sess, "complete gated feature checking", || { - sess.track_errors(|| { - syntax::feature_gate::check_crate( - &krate, - &sess.parse_sess, - &sess.features_untracked(), - &attributes, - sess.opts.unstable_features, - ); - }) - })?; + syntax::feature_gate::check_crate( + &krate, + &sess.parse_sess, + &sess.features_untracked(), + &attributes, + sess.opts.unstable_features, + ); + }); // Lower ast -> hir. // First, we need to collect the dep_graph. diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index e9f309373008b..20a3009378d37 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -200,14 +200,7 @@ pub fn run(run_compiler: F) -> isize } fn load_backend_from_dylib(path: &Path) -> fn() -> Box { - // Note that we're specifically using `open_global_now` here rather than - // `open`, namely we want the behavior on Unix of RTLD_GLOBAL and RTLD_NOW, - // where NOW means "bind everything right now" because we don't want - // surprises later on and RTLD_GLOBAL allows the symbols to be made - // available for future dynamic libraries opened. This is currently used by - // loading LLVM and then making its symbols available for other dynamic - // libraries. - let lib = DynamicLibrary::open_global_now(path).unwrap_or_else(|err| { + let lib = DynamicLibrary::open(Some(path)).unwrap_or_else(|err| { let err = format!("couldn't load codegen backend {:?}: {:?}", path, err); early_error(ErrorOutputType::default(), &err); }); @@ -276,37 +269,35 @@ fn get_codegen_sysroot(backend_name: &str) -> fn() -> Box { } let target = session::config::host_triple(); - let mut sysroot_candidates = vec![filesearch::get_or_default_sysroot()]; + // get target libdir path based on executable binary path + let sysroot = filesearch::get_or_default_sysroot(); + let mut libdir_candidates = vec![filesearch::make_target_lib_path(&sysroot, &target)]; let path = current_dll_path() .and_then(|s| s.canonicalize().ok()); if let Some(dll) = path { - // use `parent` twice to chop off the file name and then also the - // directory containing the dll which should be either `lib` or `bin`. - if let Some(path) = dll.parent().and_then(|p| p.parent()) { + // use `parent` once to chop off the file name + if let Some(path) = dll.parent() { // The original `path` pointed at the `rustc_driver` crate's dll. // Now that dll should only be in one of two locations. The first is - // in the compiler's libdir, for example `$sysroot/lib/*.dll`. The + // in the compiler's libdir, for example `$sysroot/$libdir/*.dll`. The // other is the target's libdir, for example - // `$sysroot/lib/rustlib/$target/lib/*.dll`. + // `$sysroot/$libdir/rustlib/$target/lib/*.dll`. // // We don't know which, so let's assume that if our `path` above - // ends in `$target` we *could* be in the target libdir, and always - // assume that we may be in the main libdir. - sysroot_candidates.push(path.to_owned()); - - if path.ends_with(target) { - sysroot_candidates.extend(path.parent() // chop off `$target` - .and_then(|p| p.parent()) // chop off `rustlib` - .and_then(|p| p.parent()) // chop off `lib` - .map(|s| s.to_owned())); + // doesn't end in `$target` we *could* be in the main libdir, and always + // assume that we may be in the target libdir. + libdir_candidates.push(path.to_owned()); + + if !path.parent().map_or(false, |p| p.ends_with(target)) { + libdir_candidates.push(path.join(filesearch::target_lib_path(target))); } } } - let sysroot = sysroot_candidates.iter() - .map(|sysroot| { - let libdir = filesearch::relative_target_lib_path(&sysroot, &target); - sysroot.join(libdir).with_file_name( + let sysroot = libdir_candidates.iter() + .map(|libdir| { + debug!("Trying target libdir: {}", libdir.display()); + libdir.with_file_name( option_env!("CFG_CODEGEN_BACKENDS_DIR").unwrap_or("codegen-backends")) }) .filter(|f| { @@ -315,12 +306,12 @@ fn get_codegen_sysroot(backend_name: &str) -> fn() -> Box { }) .next(); let sysroot = sysroot.unwrap_or_else(|| { - let candidates = sysroot_candidates.iter() + let candidates = libdir_candidates.iter() .map(|p| p.display().to_string()) .collect::>() .join("\n* "); let err = format!("failed to find a `codegen-backends` folder \ - in the sysroot candidates:\n* {}", candidates); + in the libdir candidates:\n* {}", candidates); early_error(ErrorOutputType::default(), &err); }); info!("probing {} for a codegen backend", sysroot.display()); diff --git a/src/librustc_llvm/build.rs b/src/librustc_llvm/build.rs index 238e79dfd22e1..98cf20a7ba7f4 100644 --- a/src/librustc_llvm/build.rs +++ b/src/librustc_llvm/build.rs @@ -132,6 +132,10 @@ fn main() { continue; } + if flag.starts_with("-flto") { + continue; + } + // -Wdate-time is not supported by the netbsd cross compiler if is_crossed && target.contains("netbsd") && flag.contains("date-time") { continue; diff --git a/src/librustc_mir/borrow_check/error_reporting.rs b/src/librustc_mir/borrow_check/error_reporting.rs index 6a5b5d172bbe4..c4d2cce66d965 100644 --- a/src/librustc_mir/borrow_check/error_reporting.rs +++ b/src/librustc_mir/borrow_check/error_reporting.rs @@ -123,7 +123,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { Origin::Mir, ); - self.add_closure_invoked_twice_with_moved_variable_suggestion( + self.add_moved_or_invoked_closure_note( context.loc, used_place, &mut err, @@ -723,7 +723,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { functions can only return borrows to data passed as arguments", ); err.note( - "to learn more, visit ", ); } else { @@ -1329,7 +1329,8 @@ enum StorageDeadOrDrop<'tcx> { impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { - /// Adds a suggestion when a closure is invoked twice with a moved variable. + /// Adds a suggestion when a closure is invoked twice with a moved variable or when a closure + /// is moved after being invoked. /// /// ```text /// note: closure cannot be invoked more than once because it moves the variable `dict` out of @@ -1339,30 +1340,18 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { /// LL | for (key, value) in dict { /// | ^^^^ /// ``` - pub(super) fn add_closure_invoked_twice_with_moved_variable_suggestion( + pub(super) fn add_moved_or_invoked_closure_note( &self, location: Location, place: &Place<'tcx>, diag: &mut DiagnosticBuilder<'_>, ) { + debug!("add_moved_or_invoked_closure_note: location={:?} place={:?}", location, place); let mut target = place.local(); - debug!( - "add_closure_invoked_twice_with_moved_variable_suggestion: location={:?} place={:?} \ - target={:?}", - location, place, target, - ); for stmt in &self.mir[location.block].statements[location.statement_index..] { - debug!( - "add_closure_invoked_twice_with_moved_variable_suggestion: stmt={:?} \ - target={:?}", - stmt, target, - ); + debug!("add_moved_or_invoked_closure_note: stmt={:?} target={:?}", stmt, target); if let StatementKind::Assign(into, box Rvalue::Use(from)) = &stmt.kind { - debug!( - "add_closure_invoked_twice_with_moved_variable_suggestion: into={:?} \ - from={:?}", - into, from, - ); + debug!("add_fnonce_closure_note: into={:?} from={:?}", into, from); match from { Operand::Copy(ref place) | Operand::Move(ref place) if target == place.local() => @@ -1372,21 +1361,21 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { } } - + // Check if we are attempting to call a closure after it has been invoked. let terminator = self.mir[location.block].terminator(); - debug!( - "add_closure_invoked_twice_with_moved_variable_suggestion: terminator={:?}", - terminator, - ); + debug!("add_moved_or_invoked_closure_note: terminator={:?}", terminator); if let TerminatorKind::Call { func: Operand::Constant(box Constant { - literal: ty::Const { ty: &ty::TyS { sty: ty::TyKind::FnDef(id, _), .. }, .. }, + literal: ty::LazyConst::Evaluated(ty::Const { + ty: &ty::TyS { sty: ty::TyKind::FnDef(id, _), .. }, + .. + }), .. }), args, .. } = &terminator.kind { - debug!("add_closure_invoked_twice_with_moved_variable_suggestion: id={:?}", id); + debug!("add_moved_or_invoked_closure_note: id={:?}", id); if self.infcx.tcx.parent(id) == self.infcx.tcx.lang_items().fn_once_trait() { let closure = match args.first() { Some(Operand::Copy(ref place)) | @@ -1394,33 +1383,51 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { place.local().unwrap(), _ => return, }; - debug!( - "add_closure_invoked_twice_with_moved_variable_suggestion: closure={:?}", - closure, - ); - if let ty::TyKind::Closure(did, _substs) = self.mir.local_decls[closure].ty.sty { - let node_id = match self.infcx.tcx.hir().as_local_node_id(did) { - Some(node_id) => node_id, - _ => return, - }; + debug!("add_moved_or_invoked_closure_note: closure={:?}", closure); + if let ty::TyKind::Closure(did, _) = self.mir.local_decls[closure].ty.sty { + let node_id = self.infcx.tcx.hir().as_local_node_id(did).unwrap(); let hir_id = self.infcx.tcx.hir().node_to_hir_id(node_id); - if let Some(( - span, name - )) = self.infcx.tcx.typeck_tables_of(did).closure_kind_origins().get(hir_id) { + if let Some((span, name)) = self.infcx.tcx.typeck_tables_of(did) + .closure_kind_origins() + .get(hir_id) + { diag.span_note( *span, &format!( - "closure cannot be invoked more than once because it \ - moves the variable `{}` out of its environment", - name, + "closure cannot be invoked more than once because it moves the \ + variable `{}` out of its environment", + name, ), ); + return; } } } } + + // Check if we are just moving a closure after it has been invoked. + if let Some(target) = target { + if let ty::TyKind::Closure(did, _) = self.mir.local_decls[target].ty.sty { + let node_id = self.infcx.tcx.hir().as_local_node_id(did).unwrap(); + let hir_id = self.infcx.tcx.hir().node_to_hir_id(node_id); + + if let Some((span, name)) = self.infcx.tcx.typeck_tables_of(did) + .closure_kind_origins() + .get(hir_id) + { + diag.span_note( + *span, + &format!( + "closure cannot be moved more than once as it is not `Copy` due to \ + moving the variable `{}` out of its environment", + name + ), + ); + } + } + } } /// End-user visible description of `place` if one can be found. If the @@ -2132,7 +2139,7 @@ impl<'tcx> AnnotatedBorrowFnSignature<'tcx> { "argument and return type have the same lifetime due to lifetime elision rules", ); diag.note( - "to learn more, visit ", ); diff --git a/src/librustc_mir/borrow_check/mutability_errors.rs b/src/librustc_mir/borrow_check/mutability_errors.rs index 0be8ecffcdf38..63bf6faed40d4 100644 --- a/src/librustc_mir/borrow_check/mutability_errors.rs +++ b/src/librustc_mir/borrow_check/mutability_errors.rs @@ -468,13 +468,13 @@ impl<'a, 'gcx, 'tcx> MirBorrowckCtxt<'a, 'gcx, 'tcx> { Terminator { kind: TerminatorKind::Call { func: Operand::Constant(box Constant { - literal: Const { + literal: ty::LazyConst::Evaluated(Const { ty: &TyS { sty: TyKind::FnDef(id, substs), .. }, .. - }, + }), .. }), .. diff --git a/src/librustc_mir/borrow_check/nll/renumber.rs b/src/librustc_mir/borrow_check/nll/renumber.rs index 55af7399aab8f..5c24da7621b2d 100644 --- a/src/librustc_mir/borrow_check/nll/renumber.rs +++ b/src/librustc_mir/borrow_check/nll/renumber.rs @@ -88,7 +88,7 @@ impl<'a, 'gcx, 'tcx> MutVisitor<'tcx> for NLLVisitor<'a, 'gcx, 'tcx> { debug!("visit_region: region={:?}", region); } - fn visit_const(&mut self, constant: &mut &'tcx ty::Const<'tcx>, _location: Location) { + fn visit_const(&mut self, constant: &mut &'tcx ty::LazyConst<'tcx>, _location: Location) { *constant = self.renumber_regions(&*constant); } diff --git a/src/librustc_mir/borrow_check/nll/type_check/mod.rs b/src/librustc_mir/borrow_check/nll/type_check/mod.rs index 8bb67521f4431..c8be9ee993db0 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/mod.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/mod.rs @@ -382,6 +382,11 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> { constant, location ); + let literal = match constant.literal { + ty::LazyConst::Evaluated(lit) => lit, + ty::LazyConst::Unevaluated(..) => return, + }; + // FIXME(#46702) -- We need some way to get the predicates // associated with the "pre-evaluated" form of the // constant. For example, consider that the constant @@ -390,7 +395,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> { // constraints on `'a` and `'b`. These constraints // would be lost if we just look at the normalized // value. - if let ty::FnDef(def_id, substs) = constant.literal.ty.sty { + if let ty::FnDef(def_id, substs) = literal.ty.sty { let tcx = self.tcx(); let type_checker = &mut self.cx; @@ -411,10 +416,10 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> { ); } - debug!("sanitize_constant: expected_ty={:?}", constant.literal.ty); + debug!("sanitize_constant: expected_ty={:?}", literal.ty); if let Err(terr) = self.cx.eq_types( - constant.literal.ty, + literal.ty, constant.ty, location.to_locations(), ConstraintCategory::Boring, @@ -424,7 +429,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> { constant, "constant {:?} should have type {:?} but has {:?} ({:?})", constant, - constant.literal.ty, + literal.ty, constant.ty, terr, ); diff --git a/src/librustc_mir/build/expr/as_rvalue.rs b/src/librustc_mir/build/expr/as_rvalue.rs index 7dcac05e702a3..a66da50c48437 100644 --- a/src/librustc_mir/build/expr/as_rvalue.rs +++ b/src/librustc_mir/build/expr/as_rvalue.rs @@ -270,11 +270,13 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { span: expr_span, ty: this.hir.tcx().types.u32, user_ty: None, - literal: ty::Const::from_bits( - this.hir.tcx(), - 0, - ty::ParamEnv::empty().and(this.hir.tcx().types.u32), - ), + literal: this.hir.tcx().intern_lazy_const(ty::LazyConst::Evaluated( + ty::Const::from_bits( + this.hir.tcx(), + 0, + ty::ParamEnv::empty().and(this.hir.tcx().types.u32), + ), + )), })); box AggregateKind::Generator(closure_id, substs, movability) } diff --git a/src/librustc_mir/build/matches/mod.rs b/src/librustc_mir/build/matches/mod.rs index fe5bc6e19db65..409b6c038ab69 100644 --- a/src/librustc_mir/build/matches/mod.rs +++ b/src/librustc_mir/build/matches/mod.rs @@ -658,12 +658,12 @@ enum TestKind<'tcx> { SwitchInt { switch_ty: Ty<'tcx>, options: Vec, - indices: FxHashMap<&'tcx ty::Const<'tcx>, usize>, + indices: FxHashMap, usize>, }, // test for equality Eq { - value: &'tcx ty::Const<'tcx>, + value: ty::Const<'tcx>, ty: Ty<'tcx>, }, diff --git a/src/librustc_mir/build/matches/test.rs b/src/librustc_mir/build/matches/test.rs index 21109a223bf77..aae3de68aaae0 100644 --- a/src/librustc_mir/build/matches/test.rs +++ b/src/librustc_mir/build/matches/test.rs @@ -101,7 +101,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { candidate: &Candidate<'pat, 'tcx>, switch_ty: Ty<'tcx>, options: &mut Vec, - indices: &mut FxHashMap<&'tcx ty::Const<'tcx>, usize>) + indices: &mut FxHashMap, usize>) -> bool { let match_pair = match candidate.match_pairs.iter().find(|mp| mp.place == *test_place) { @@ -302,6 +302,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { } let eq_def_id = self.hir.tcx().lang_items().eq_trait().unwrap(); let (mty, method) = self.hir.trait_method(eq_def_id, "eq", ty, &[ty.into()]); + let method = self.hir.tcx().intern_lazy_const(ty::LazyConst::Evaluated(method)); // take the argument by reference let region_scope = self.topmost_scope(); @@ -657,7 +658,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { } } - (&TestKind::Range(range), &PatternKind::Constant { ref value }) => { + (&TestKind::Range(range), &PatternKind::Constant { value }) => { if self.const_range_contains(range, value) == Some(false) { // `value` is not contained in the testing range, // so `value` can be matched only if this test fails. @@ -786,7 +787,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { fn const_range_contains( &self, range: PatternRange<'tcx>, - value: &'tcx ty::Const<'tcx>, + value: ty::Const<'tcx>, ) -> Option { use std::cmp::Ordering::*; @@ -806,9 +807,9 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { fn values_not_contained_in_range( &self, range: PatternRange<'tcx>, - indices: &FxHashMap<&'tcx ty::Const<'tcx>, usize>, + indices: &FxHashMap, usize>, ) -> Option { - for val in indices.keys() { + for &val in indices.keys() { if self.const_range_contains(range, val)? { return Some(false); } diff --git a/src/librustc_mir/build/misc.rs b/src/librustc_mir/build/misc.rs index 472f05a101f9e..b4887dada7aeb 100644 --- a/src/librustc_mir/build/misc.rs +++ b/src/librustc_mir/build/misc.rs @@ -27,13 +27,13 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { pub fn literal_operand(&mut self, span: Span, ty: Ty<'tcx>, - literal: &'tcx ty::Const<'tcx>) + literal: ty::Const<'tcx>) -> Operand<'tcx> { let constant = box Constant { span, ty, user_ty: None, - literal, + literal: self.hir.tcx().intern_lazy_const(ty::LazyConst::Evaluated(literal)), }; Operand::Constant(constant) } diff --git a/src/librustc_mir/build/mod.rs b/src/librustc_mir/build/mod.rs index 8acdecf6fa248..727b769cf4d44 100644 --- a/src/librustc_mir/build/mod.rs +++ b/src/librustc_mir/build/mod.rs @@ -202,7 +202,7 @@ impl<'a, 'gcx: 'tcx, 'tcx> MutVisitor<'tcx> for GlobalizeMir<'a, 'gcx> { } } - fn visit_const(&mut self, constant: &mut &'tcx ty::Const<'tcx>, _: Location) { + fn visit_const(&mut self, constant: &mut &'tcx ty::LazyConst<'tcx>, _: Location) { if let Some(lifted) = self.tcx.lift(constant) { *constant = lifted; } else { diff --git a/src/librustc_mir/const_eval.rs b/src/librustc_mir/const_eval.rs index b9432997b7e19..01177e5e49a0e 100644 --- a/src/librustc_mir/const_eval.rs +++ b/src/librustc_mir/const_eval.rs @@ -95,7 +95,7 @@ pub fn op_to_const<'tcx>( ecx: &CompileTimeEvalContext<'_, '_, 'tcx>, op: OpTy<'tcx>, may_normalize: bool, -) -> EvalResult<'tcx, &'tcx ty::Const<'tcx>> { +) -> EvalResult<'tcx, ty::Const<'tcx>> { // We do not normalize just any data. Only scalar layout and fat pointers. let normalize = may_normalize && match op.layout.abi { @@ -134,14 +134,16 @@ pub fn op_to_const<'tcx>( Ok(Immediate::ScalarPair(a, b)) => ConstValue::ScalarPair(a.not_undef()?, b.not_undef()?), }; - Ok(ty::Const::from_const_value(ecx.tcx.tcx, val, op.layout.ty)) + Ok(ty::Const { val, ty: op.layout.ty }) } -pub fn const_to_op<'tcx>( + +pub fn lazy_const_to_op<'tcx>( ecx: &CompileTimeEvalContext<'_, '_, 'tcx>, - cnst: &ty::Const<'tcx>, + cnst: ty::LazyConst<'tcx>, + ty: ty::Ty<'tcx>, ) -> EvalResult<'tcx, OpTy<'tcx>> { - let op = ecx.const_value_to_op(cnst.val)?; - Ok(OpTy { op, layout: ecx.layout_of(cnst.ty)? }) + let op = ecx.const_value_to_op(cnst)?; + Ok(OpTy { op, layout: ecx.layout_of(ty)? }) } fn eval_body_and_ecx<'a, 'mir, 'tcx>( @@ -508,13 +510,13 @@ pub fn const_field<'a, 'tcx>( instance: ty::Instance<'tcx>, variant: Option, field: mir::Field, - value: &'tcx ty::Const<'tcx>, + value: ty::Const<'tcx>, ) -> ::rustc::mir::interpret::ConstEvalResult<'tcx> { trace!("const_field: {:?}, {:?}, {:?}", instance, field, value); let ecx = mk_eval_cx(tcx, instance, param_env).unwrap(); let result = (|| { // get the operand again - let op = const_to_op(&ecx, value)?; + let op = lazy_const_to_op(&ecx, ty::LazyConst::Evaluated(value), value.ty)?; // downcast let down = match variant { None => op, @@ -537,11 +539,11 @@ pub fn const_variant_index<'a, 'tcx>( tcx: TyCtxt<'a, 'tcx, 'tcx>, param_env: ty::ParamEnv<'tcx>, instance: ty::Instance<'tcx>, - val: &'tcx ty::Const<'tcx>, + val: ty::Const<'tcx>, ) -> EvalResult<'tcx, VariantIdx> { trace!("const_variant_index: {:?}, {:?}", instance, val); let ecx = mk_eval_cx(tcx, instance, param_env).unwrap(); - let op = const_to_op(&ecx, val)?; + let op = lazy_const_to_op(&ecx, ty::LazyConst::Evaluated(val), val.ty)?; Ok(ecx.read_discriminant(op)?.1) } diff --git a/src/librustc_mir/dataflow/impls/borrows.rs b/src/librustc_mir/dataflow/impls/borrows.rs index 518fbaae6271f..0ceff4aa04898 100644 --- a/src/librustc_mir/dataflow/impls/borrows.rs +++ b/src/librustc_mir/dataflow/impls/borrows.rs @@ -279,20 +279,6 @@ impl<'a, 'gcx, 'tcx> BitDenotation<'tcx> for Borrows<'a, 'gcx, 'tcx> { }); sets.gen(*index); - - // Issue #46746: Two-phase borrows handles - // stmts of form `Tmp = &mut Borrow` ... - match lhs { - Place::Promoted(_) | - Place::Local(..) | Place::Static(..) => {} // okay - Place::Projection(..) => { - // ... can assign into projections, - // e.g., `box (&mut _)`. Current - // conservative solution: force - // immediate activation here. - sets.gen(*index); - } - } } } diff --git a/src/librustc_mir/hair/constant.rs b/src/librustc_mir/hair/constant.rs index c98ef31c2bae2..37d741d2606d5 100644 --- a/src/librustc_mir/hair/constant.rs +++ b/src/librustc_mir/hair/constant.rs @@ -14,7 +14,7 @@ crate fn lit_to_const<'a, 'gcx, 'tcx>( tcx: TyCtxt<'a, 'gcx, 'tcx>, ty: Ty<'tcx>, neg: bool, -) -> Result<&'tcx ty::Const<'tcx>, LitToConstError> { +) -> Result, LitToConstError> { use syntax::ast::*; let trunc = |n| { @@ -64,7 +64,7 @@ crate fn lit_to_const<'a, 'gcx, 'tcx>( LitKind::Bool(b) => ConstValue::Scalar(Scalar::from_bool(b)), LitKind::Char(c) => ConstValue::Scalar(Scalar::from_char(c)), }; - Ok(ty::Const::from_const_value(tcx, lit, ty)) + Ok(ty::Const { val: lit, ty }) } fn parse_float<'tcx>( diff --git a/src/librustc_mir/hair/cx/expr.rs b/src/librustc_mir/hair/cx/expr.rs index 293058a0f26f5..532e6783f2f2b 100644 --- a/src/librustc_mir/hair/cx/expr.rs +++ b/src/librustc_mir/hair/cx/expr.rs @@ -356,7 +356,9 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, } hir::ExprKind::Lit(ref lit) => ExprKind::Literal { - literal: cx.const_eval_literal(&lit.node, expr_ty, lit.span, false), + literal: cx.tcx.intern_lazy_const(ty::LazyConst::Evaluated( + cx.const_eval_literal(&lit.node, expr_ty, lit.span, false) + )), user_ty: None, }, @@ -454,7 +456,9 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, } else { if let hir::ExprKind::Lit(ref lit) = arg.node { ExprKind::Literal { - literal: cx.const_eval_literal(&lit.node, expr_ty, lit.span, true), + literal: cx.tcx.intern_lazy_const(ty::LazyConst::Evaluated( + cx.const_eval_literal(&lit.node, expr_ty, lit.span, true) + )), user_ty: None, } } else { @@ -711,24 +715,22 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, temp_lifetime, ty: var_ty, span: expr.span, - kind: ExprKind::Literal { literal, user_ty: None }, + kind: ExprKind::Literal { + literal: cx.tcx.intern_lazy_const(literal), + user_ty: None + }, }.to_ref(); - let offset = mk_const(ty::Const::from_bits( + let offset = mk_const(ty::LazyConst::Evaluated(ty::Const::from_bits( cx.tcx, offset as u128, cx.param_env.and(var_ty), - )); + ))); match did { Some(did) => { // in case we are offsetting from a computed discriminant // and not the beginning of discriminants (which is always `0`) let substs = Substs::identity_for_item(cx.tcx(), did); - let lhs = mk_const(ty::Const::unevaluated( - cx.tcx(), - did, - substs, - var_ty, - )); + let lhs = mk_const(ty::LazyConst::Unevaluated(did, substs)); let bin = ExprKind::Binary { op: BinOp::Add, lhs, @@ -868,7 +870,9 @@ fn method_callee<'a, 'gcx, 'tcx>( ty, span, kind: ExprKind::Literal { - literal: ty::Const::zero_sized(cx.tcx(), ty), + literal: cx.tcx().intern_lazy_const(ty::LazyConst::Evaluated( + ty::Const::zero_sized(ty) + )), user_ty, }, } @@ -928,10 +932,9 @@ fn convert_path_expr<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, let user_ty = user_substs_applied_to_def(cx, expr.hir_id, &def); debug!("convert_path_expr: user_ty={:?}", user_ty); ExprKind::Literal { - literal: ty::Const::zero_sized( - cx.tcx, + literal: cx.tcx.intern_lazy_const(ty::LazyConst::Evaluated(ty::Const::zero_sized( cx.tables().node_id_to_type(expr.hir_id), - ), + ))), user_ty, } }, @@ -941,12 +944,7 @@ fn convert_path_expr<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, let user_ty = user_substs_applied_to_def(cx, expr.hir_id, &def); debug!("convert_path_expr: (const) user_ty={:?}", user_ty); ExprKind::Literal { - literal: ty::Const::unevaluated( - cx.tcx, - def_id, - substs, - cx.tables().node_id_to_type(expr.hir_id), - ), + literal: cx.tcx.intern_lazy_const(ty::LazyConst::Unevaluated(def_id, substs)), user_ty, } }, diff --git a/src/librustc_mir/hair/cx/mod.rs b/src/librustc_mir/hair/cx/mod.rs index 60c8022a374be..25c5498b5f1e4 100644 --- a/src/librustc_mir/hair/cx/mod.rs +++ b/src/librustc_mir/hair/cx/mod.rs @@ -108,8 +108,8 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> { self.tcx.types.usize } - pub fn usize_literal(&mut self, value: u64) -> &'tcx ty::Const<'tcx> { - ty::Const::from_usize(self.tcx, value) + pub fn usize_literal(&mut self, value: u64) -> &'tcx ty::LazyConst<'tcx> { + self.tcx.intern_lazy_const(ty::LazyConst::Evaluated(ty::Const::from_usize(self.tcx, value))) } pub fn bool_ty(&mut self) -> Ty<'tcx> { @@ -120,12 +120,12 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> { self.tcx.mk_unit() } - pub fn true_literal(&mut self) -> &'tcx ty::Const<'tcx> { - ty::Const::from_bool(self.tcx, true) + pub fn true_literal(&mut self) -> &'tcx ty::LazyConst<'tcx> { + self.tcx.intern_lazy_const(ty::LazyConst::Evaluated(ty::Const::from_bool(self.tcx, true))) } - pub fn false_literal(&mut self) -> &'tcx ty::Const<'tcx> { - ty::Const::from_bool(self.tcx, false) + pub fn false_literal(&mut self) -> &'tcx ty::LazyConst<'tcx> { + self.tcx.intern_lazy_const(ty::LazyConst::Evaluated(ty::Const::from_bool(self.tcx, false))) } pub fn const_eval_literal( @@ -134,7 +134,7 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> { ty: Ty<'tcx>, sp: Span, neg: bool, - ) -> &'tcx ty::Const<'tcx> { + ) -> ty::Const<'tcx> { trace!("const_eval_literal: {:#?}, {:?}, {:?}, {:?}", lit, ty, sp, neg); match lit_to_const(lit, self.tcx, ty, neg) { @@ -169,14 +169,14 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> { method_name: &str, self_ty: Ty<'tcx>, params: &[Kind<'tcx>]) - -> (Ty<'tcx>, &'tcx ty::Const<'tcx>) { + -> (Ty<'tcx>, ty::Const<'tcx>) { let method_name = Symbol::intern(method_name); let substs = self.tcx.mk_substs_trait(self_ty, params); for item in self.tcx.associated_items(trait_def_id) { if item.kind == ty::AssociatedKind::Method && item.ident.name == method_name { let method_ty = self.tcx.type_of(item.def_id); let method_ty = method_ty.subst(self.tcx, substs); - return (method_ty, ty::Const::zero_sized(self.tcx, method_ty)); + return (method_ty, ty::Const::zero_sized(method_ty)); } } diff --git a/src/librustc_mir/hair/mod.rs b/src/librustc_mir/hair/mod.rs index b56e3d4e77395..676b98457489f 100644 --- a/src/librustc_mir/hair/mod.rs +++ b/src/librustc_mir/hair/mod.rs @@ -9,7 +9,7 @@ use rustc::hir::def_id::DefId; use rustc::infer::canonical::Canonical; use rustc::middle::region; use rustc::ty::subst::Substs; -use rustc::ty::{AdtDef, UpvarSubsts, Region, Ty, Const, UserTypeAnnotation}; +use rustc::ty::{AdtDef, UpvarSubsts, Region, Ty, Const, LazyConst, UserTypeAnnotation}; use rustc::ty::layout::VariantIdx; use rustc::hir; use syntax::ast; @@ -288,7 +288,7 @@ pub enum ExprKind<'tcx> { movability: Option, }, Literal { - literal: &'tcx Const<'tcx>, + literal: &'tcx LazyConst<'tcx>, user_ty: Option>>, }, InlineAsm { diff --git a/src/librustc_mir/hair/pattern/_match.rs b/src/librustc_mir/hair/pattern/_match.rs index 13838e5d85dda..b25d47b390175 100644 --- a/src/librustc_mir/hair/pattern/_match.rs +++ b/src/librustc_mir/hair/pattern/_match.rs @@ -223,7 +223,7 @@ impl<'a, 'tcx> LiteralExpander<'a, 'tcx> { assert_eq!(t, u); ConstValue::ScalarPair( Scalar::Ptr(p), - n.val.try_to_scalar().unwrap(), + n.map_evaluated(|val| val.val.try_to_scalar()).unwrap(), ) }, // fat pointers stay the same @@ -251,11 +251,10 @@ impl<'a, 'tcx> PatternFolder<'tcx> for LiteralExpander<'a, 'tcx> { subpattern: Pattern { ty: rty, span: pat.span, - kind: box PatternKind::Constant { value: Const::from_const_value( - self.tcx, - self.fold_const_value_deref(*val, rty, crty), - rty, - ) }, + kind: box PatternKind::Constant { value: Const { + val: self.fold_const_value_deref(val, rty, crty), + ty: rty, + } }, } } } @@ -420,7 +419,7 @@ pub enum Constructor<'tcx> { /// Enum variants. Variant(DefId), /// Literal values. - ConstantValue(&'tcx ty::Const<'tcx>), + ConstantValue(ty::Const<'tcx>), /// Ranges of literal values (`2...5` and `2..5`). ConstantRange(u128, u128, Ty<'tcx>, RangeEnd), /// Array patterns of length n. @@ -1396,7 +1395,7 @@ fn constructor_sub_pattern_tys<'a, 'tcx: 'a>(cx: &MatchCheckCtxt<'a, 'tcx>, fn slice_pat_covered_by_const<'tcx>( tcx: TyCtxt<'_, 'tcx, '_>, _span: Span, - const_val: &ty::Const<'tcx>, + const_val: ty::Const<'tcx>, prefix: &[Pattern<'tcx>], slice: &Option>, suffix: &[Pattern<'tcx>] @@ -1751,23 +1750,37 @@ fn specialize<'p, 'a: 'p, 'tcx: 'a>( // necessarily point to memory, they are usually just integers. The only time // they should be pointing to memory is when they are subslices of nonzero // slices - let (opt_ptr, n, ty) = match (value.val, &value.ty.sty) { - (ConstValue::ByRef(id, alloc, offset), ty::TyKind::Array(t, n)) => ( - Some(( - Pointer::new(id, offset), - alloc, - )), - n.unwrap_usize(cx.tcx), - t, - ), - (ConstValue::ScalarPair(ptr, n), ty::TyKind::Slice(t)) => ( - ptr.to_ptr().ok().map(|ptr| ( - ptr, - cx.tcx.alloc_map.lock().unwrap_memory(ptr.alloc_id), - )), - n.to_bits(cx.tcx.data_layout.pointer_size).unwrap() as u64, - t, - ), + let (opt_ptr, n, ty) = match value.ty.sty { + ty::TyKind::Array(t, n) => { + match value.val { + ConstValue::ByRef(id, alloc, offset) => ( + Some((Pointer::new(id, offset), alloc)), + n.unwrap_usize(cx.tcx), + t, + ), + _ => span_bug!( + pat.span, + "array pattern is {:?}", value, + ), + } + }, + ty::TyKind::Slice(t) => { + match value.val { + ConstValue::ScalarPair(ptr, n) => ( + ptr.to_ptr().ok().map(|ptr| ( + ptr, + cx.tcx.alloc_map.lock().unwrap_memory(ptr.alloc_id), + )), + n.to_bits(cx.tcx.data_layout.pointer_size).unwrap() as u64, + t, + ), + _ => span_bug!( + pat.span, + "slice pattern constant must be scalar pair but is {:?}", + value, + ), + } + }, _ => span_bug!( pat.span, "unexpected const-val {:?} with ctor {:?}", @@ -1787,7 +1800,7 @@ fn specialize<'p, 'a: 'p, 'tcx: 'a>( &cx.tcx, ptr, layout.size, ).ok()?; let scalar = scalar.not_undef().ok()?; - let value = ty::Const::from_scalar(cx.tcx, scalar, ty); + let value = ty::Const::from_scalar(scalar, ty); let pattern = Pattern { ty, span: pat.span, diff --git a/src/librustc_mir/hair/pattern/mod.rs b/src/librustc_mir/hair/pattern/mod.rs index 10d2d7bc1b18b..f52aeded19ae7 100644 --- a/src/librustc_mir/hair/pattern/mod.rs +++ b/src/librustc_mir/hair/pattern/mod.rs @@ -123,7 +123,7 @@ pub enum PatternKind<'tcx> { }, Constant { - value: &'tcx ty::Const<'tcx>, + value: ty::Const<'tcx>, }, Range(PatternRange<'tcx>), @@ -147,8 +147,8 @@ pub enum PatternKind<'tcx> { #[derive(Clone, Copy, Debug, PartialEq)] pub struct PatternRange<'tcx> { - pub lo: &'tcx ty::Const<'tcx>, - pub hi: &'tcx ty::Const<'tcx>, + pub lo: ty::Const<'tcx>, + pub hi: ty::Const<'tcx>, pub ty: Ty<'tcx>, pub end: RangeEnd, } @@ -857,7 +857,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { fn const_to_pat( &self, instance: ty::Instance<'tcx>, - cv: &'tcx ty::Const<'tcx>, + cv: ty::Const<'tcx>, id: hir::HirId, span: Span, ) -> Pattern<'tcx> { @@ -1018,7 +1018,7 @@ macro_rules! CloneImpls { } CloneImpls!{ <'tcx> - Span, Field, Mutability, ast::Name, ast::NodeId, usize, &'tcx ty::Const<'tcx>, + Span, Field, Mutability, ast::Name, ast::NodeId, usize, ty::Const<'tcx>, Region<'tcx>, Ty<'tcx>, BindingMode<'tcx>, &'tcx AdtDef, &'tcx Substs<'tcx>, &'tcx Kind<'tcx>, UserTypeAnnotation<'tcx>, UserTypeProjection<'tcx>, PatternTypeProjection<'tcx> @@ -1140,8 +1140,8 @@ impl<'tcx> PatternFoldable<'tcx> for PatternKind<'tcx> { pub fn compare_const_vals<'a, 'gcx, 'tcx>( tcx: TyCtxt<'a, 'gcx, 'tcx>, - a: &'tcx ty::Const<'tcx>, - b: &'tcx ty::Const<'tcx>, + a: ty::Const<'tcx>, + b: ty::Const<'tcx>, ty: ty::ParamEnvAnd<'tcx, Ty<'tcx>>, ) -> Option { trace!("compare_const_vals: {:?}, {:?}", a, b); diff --git a/src/librustc_mir/interpret/operand.rs b/src/librustc_mir/interpret/operand.rs index 1ea3f78c2104f..04e0955ad6172 100644 --- a/src/librustc_mir/interpret/operand.rs +++ b/src/librustc_mir/interpret/operand.rs @@ -3,7 +3,7 @@ use std::convert::TryInto; -use rustc::mir; +use rustc::{mir, ty}; use rustc::ty::layout::{self, Size, LayoutOf, TyLayout, HasDataLayout, IntegerExt, VariantIdx}; use rustc::mir::interpret::{ @@ -517,7 +517,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> let ty = self.monomorphize(mir_op.ty(self.mir(), *self.tcx), self.substs()); self.layout_of(ty) })?; - let op = self.const_value_to_op(constant.literal.val)?; + let op = self.const_value_to_op(*constant.literal)?; OpTy { op, layout } } }; @@ -540,17 +540,20 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> // `eval_operand`, ideally). pub(crate) fn const_value_to_op( &self, - val: ConstValue<'tcx>, + val: ty::LazyConst<'tcx>, ) -> EvalResult<'tcx, Operand> { trace!("const_value_to_op: {:?}", val); - match val { - ConstValue::Unevaluated(def_id, substs) => { + let val = match val { + ty::LazyConst::Unevaluated(def_id, substs) => { let instance = self.resolve(def_id, substs)?; - Ok(*OpTy::from(self.const_eval_raw(GlobalId { + return Ok(*OpTy::from(self.const_eval_raw(GlobalId { instance, promoted: None, - })?)) - } + })?)); + }, + ty::LazyConst::Evaluated(c) => c, + }; + match val.val { ConstValue::ByRef(id, alloc, offset) => { // We rely on mutability being set correctly in that allocation to prevent writes // where none should happen -- and for `static mut`, we copy on demand anyway. diff --git a/src/librustc_mir/monomorphize/collector.rs b/src/librustc_mir/monomorphize/collector.rs index d81a4d6a4bc84..eabfd47c9fb90 100644 --- a/src/librustc_mir/monomorphize/collector.rs +++ b/src/librustc_mir/monomorphize/collector.rs @@ -381,7 +381,7 @@ fn collect_items_rec<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let param_env = ty::ParamEnv::reveal_all(); if let Ok(val) = tcx.const_eval(param_env.and(cid)) { - collect_const(tcx, val, instance.substs, &mut neighbors); + collect_const(tcx, val, &mut neighbors); } } MonoItem::Fn(instance) => { @@ -583,10 +583,10 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> { self.super_rvalue(rvalue, location); } - fn visit_const(&mut self, constant: &&'tcx ty::Const<'tcx>, location: Location) { + fn visit_const(&mut self, constant: &&'tcx ty::LazyConst<'tcx>, location: Location) { debug!("visiting const {:?} @ {:?}", *constant, location); - collect_const(self.tcx, constant, self.param_substs, self.output); + collect_lazy_const(self.tcx, constant, self.param_substs, self.output); self.super_const(constant); } @@ -987,7 +987,7 @@ impl<'b, 'a, 'v> ItemLikeVisitor<'v> for RootCollector<'b, 'a, 'v> { let param_env = ty::ParamEnv::reveal_all(); if let Ok(val) = self.tcx.const_eval(param_env.and(cid)) { - collect_const(self.tcx, val, instance.substs, &mut self.output); + collect_const(self.tcx, val, &mut self.output); } } hir::ItemKind::Fn(..) => { @@ -1198,7 +1198,7 @@ fn collect_neighbours<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, promoted: Some(i), }; match tcx.const_eval(param_env.and(cid)) { - Ok(val) => collect_const(tcx, val, instance.substs, output), + Ok(val) => collect_const(tcx, val, output), Err(ErrorHandled::Reported) => {}, Err(ErrorHandled::TooGeneric) => span_bug!( mir.promoted[i].span, "collection encountered polymorphic constant", @@ -1216,43 +1216,48 @@ fn def_id_to_string<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, output } -fn collect_const<'a, 'tcx>( +fn collect_lazy_const<'a, 'tcx>( tcx: TyCtxt<'a, 'tcx, 'tcx>, - constant: &ty::Const<'tcx>, + constant: &ty::LazyConst<'tcx>, param_substs: &'tcx Substs<'tcx>, output: &mut Vec>, ) { - debug!("visiting const {:?}", *constant); + let (def_id, substs) = match *constant { + ty::LazyConst::Evaluated(c) => return collect_const(tcx, c, output), + ty::LazyConst::Unevaluated(did, substs) => (did, substs), + }; + let param_env = ty::ParamEnv::reveal_all(); + let substs = tcx.subst_and_normalize_erasing_regions( + param_substs, + param_env, + &substs, + ); + let instance = ty::Instance::resolve(tcx, + param_env, + def_id, + substs).unwrap(); + + let cid = GlobalId { + instance, + promoted: None, + }; + match tcx.const_eval(param_env.and(cid)) { + Ok(val) => collect_const(tcx, val, output), + Err(ErrorHandled::Reported) => {}, + Err(ErrorHandled::TooGeneric) => span_bug!( + tcx.def_span(def_id), "collection encountered polymorphic constant", + ), + } +} - let val = match constant.val { - ConstValue::Unevaluated(def_id, substs) => { - let param_env = ty::ParamEnv::reveal_all(); - let substs = tcx.subst_and_normalize_erasing_regions( - param_substs, - param_env, - &substs, - ); - let instance = ty::Instance::resolve(tcx, - param_env, - def_id, - substs).unwrap(); +fn collect_const<'a, 'tcx>( + tcx: TyCtxt<'a, 'tcx, 'tcx>, + constant: ty::Const<'tcx>, + output: &mut Vec>, +) { + debug!("visiting const {:?}", constant); - let cid = GlobalId { - instance, - promoted: None, - }; - match tcx.const_eval(param_env.and(cid)) { - Ok(val) => val.val, - Err(ErrorHandled::Reported) => return, - Err(ErrorHandled::TooGeneric) => span_bug!( - tcx.def_span(def_id), "collection encountered polymorphic constant", - ), - } - }, - _ => constant.val, - }; - match val { - ConstValue::Unevaluated(..) => bug!("const eval yielded unevaluated const"), + match constant.val { ConstValue::ScalarPair(Scalar::Ptr(a), Scalar::Ptr(b)) => { collect_miri(tcx, a.alloc_id, output); collect_miri(tcx, b.alloc_id, output); diff --git a/src/librustc_mir/shim.rs b/src/librustc_mir/shim.rs index 4c123d4a44b05..8710a09c209cf 100644 --- a/src/librustc_mir/shim.rs +++ b/src/librustc_mir/shim.rs @@ -459,7 +459,9 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> { span: self.span, ty: func_ty, user_ty: None, - literal: ty::Const::zero_sized(self.tcx, func_ty), + literal: tcx.intern_lazy_const(ty::LazyConst::Evaluated( + ty::Const::zero_sized(func_ty), + )), }); let ref_loc = self.make_place( @@ -519,7 +521,9 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> { span: self.span, ty: self.tcx.types.usize, user_ty: None, - literal: ty::Const::from_usize(self.tcx, value), + literal: self.tcx.intern_lazy_const(ty::LazyConst::Evaluated( + ty::Const::from_usize(self.tcx, value), + )), } } @@ -755,7 +759,9 @@ fn build_call_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, span, ty, user_ty: None, - literal: ty::Const::zero_sized(tcx, ty), + literal: tcx.intern_lazy_const(ty::LazyConst::Evaluated( + ty::Const::zero_sized(ty) + )), }), vec![rcvr]) } diff --git a/src/librustc_mir/transform/const_prop.rs b/src/librustc_mir/transform/const_prop.rs index 34f544745a787..03d6d3868c9f0 100644 --- a/src/librustc_mir/transform/const_prop.rs +++ b/src/librustc_mir/transform/const_prop.rs @@ -20,7 +20,8 @@ use rustc::ty::layout::{ use interpret::{self, EvalContext, ScalarMaybeUndef, Immediate, OpTy, MemoryKind}; use const_eval::{ - CompileTimeInterpreter, const_to_op, error_to_const_error, eval_promoted, mk_borrowck_eval_cx + CompileTimeInterpreter, error_to_const_error, eval_promoted, mk_borrowck_eval_cx, + lazy_const_to_op, }; use transform::{MirPass, MirSource}; @@ -255,7 +256,7 @@ impl<'a, 'mir, 'tcx> ConstPropagator<'a, 'mir, 'tcx> { source_info: SourceInfo, ) -> Option> { self.ecx.tcx.span = source_info.span; - match const_to_op(&self.ecx, c.literal) { + match lazy_const_to_op(&self.ecx, *c.literal, c.ty) { Ok(op) => { Some((op, c.span)) }, diff --git a/src/librustc_mir/transform/elaborate_drops.rs b/src/librustc_mir/transform/elaborate_drops.rs index b98e3d7d8bb7a..06e16de8b43bc 100644 --- a/src/librustc_mir/transform/elaborate_drops.rs +++ b/src/librustc_mir/transform/elaborate_drops.rs @@ -533,7 +533,9 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> { span, ty: self.tcx.types.bool, user_ty: None, - literal: ty::Const::from_bool(self.tcx, val), + literal: self.tcx.intern_lazy_const(ty::LazyConst::Evaluated( + ty::Const::from_bool(self.tcx, val), + )), }))) } diff --git a/src/librustc_mir/transform/erase_regions.rs b/src/librustc_mir/transform/erase_regions.rs index 009570c378ad2..b464b7d65e466 100644 --- a/src/librustc_mir/transform/erase_regions.rs +++ b/src/librustc_mir/transform/erase_regions.rs @@ -32,7 +32,7 @@ impl<'a, 'tcx> MutVisitor<'tcx> for EraseRegionsVisitor<'a, 'tcx> { *region = self.tcx.types.re_erased; } - fn visit_const(&mut self, constant: &mut &'tcx ty::Const<'tcx>, _: Location) { + fn visit_const(&mut self, constant: &mut &'tcx ty::LazyConst<'tcx>, _: Location) { *constant = self.tcx.erase_regions(constant); } diff --git a/src/librustc_mir/transform/generator.rs b/src/librustc_mir/transform/generator.rs index b43e839271863..808c3aad29201 100644 --- a/src/librustc_mir/transform/generator.rs +++ b/src/librustc_mir/transform/generator.rs @@ -171,11 +171,11 @@ impl<'a, 'tcx> TransformVisitor<'a, 'tcx> { span: source_info.span, ty: self.tcx.types.u32, user_ty: None, - literal: ty::Const::from_bits( + literal: self.tcx.intern_lazy_const(ty::LazyConst::Evaluated(ty::Const::from_bits( self.tcx, state_disc.into(), ty::ParamEnv::empty().and(self.tcx.types.u32) - ), + ))), }); Statement { source_info, @@ -717,7 +717,9 @@ fn insert_panic_block<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, span: mir.span, ty: tcx.types.bool, user_ty: None, - literal: ty::Const::from_bool(tcx, false), + literal: tcx.intern_lazy_const(ty::LazyConst::Evaluated( + ty::Const::from_bool(tcx, false), + )), }), expected: true, msg: message, diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs index 7b04af62fe6cc..a04dd5bb5970f 100644 --- a/src/librustc_mir/transform/qualify_consts.rs +++ b/src/librustc_mir/transform/qualify_consts.rs @@ -11,7 +11,6 @@ use rustc_data_structures::sync::Lrc; use rustc_target::spec::abi::Abi; use rustc::hir; use rustc::hir::def_id::DefId; -use rustc::mir::interpret::ConstValue; use rustc::traits::{self, TraitEngine}; use rustc::ty::{self, TyCtxt, Ty, TypeFoldable}; use rustc::ty::cast::CastTy; @@ -625,12 +624,12 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> { } } Operand::Constant(ref constant) => { - if let ConstValue::Unevaluated(def_id, _) = constant.literal.val { + if let ty::LazyConst::Unevaluated(def_id, _) = constant.literal { // Don't peek inside trait associated constants. - if self.tcx.trait_of_item(def_id).is_some() { - self.add_type(constant.literal.ty); + if self.tcx.trait_of_item(*def_id).is_some() { + self.add_type(constant.ty); } else { - let (bits, _) = self.tcx.at(constant.span).mir_const_qualif(def_id); + let (bits, _) = self.tcx.at(constant.span).mir_const_qualif(*def_id); let qualif = Qualif::from_bits(bits).expect("invalid mir_const_qualif"); self.add(qualif); @@ -638,7 +637,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> { // Just in case the type is more specific than // the definition, e.g., impl associated const // with type parameters, take it into account. - self.qualif.restrict(constant.literal.ty, self.tcx, self.param_env); + self.qualif.restrict(constant.ty, self.tcx, self.param_env); } } } diff --git a/src/librustc_mir/transform/simplify_branches.rs b/src/librustc_mir/transform/simplify_branches.rs index 6cf9f43877b17..abaea70946383 100644 --- a/src/librustc_mir/transform/simplify_branches.rs +++ b/src/librustc_mir/transform/simplify_branches.rs @@ -30,11 +30,12 @@ impl MirPass for SimplifyBranches { discr: Operand::Constant(ref c), switch_ty, ref values, ref targets, .. } => { let switch_ty = ParamEnv::empty().and(switch_ty); - if let Some(constint) = c.literal.assert_bits(tcx, switch_ty) { + let constant = c.literal.map_evaluated(|c| c.assert_bits(tcx, switch_ty)); + if let Some(constant) = constant { let (otherwise, targets) = targets.split_last().unwrap(); let mut ret = TerminatorKind::Goto { target: *otherwise }; for (&v, t) in values.iter().zip(targets.iter()) { - if v == constint { + if v == constant { ret = TerminatorKind::Goto { target: *t }; break; } @@ -46,9 +47,8 @@ impl MirPass for SimplifyBranches { }, TerminatorKind::Assert { target, cond: Operand::Constant(ref c), expected, .. - } if (c.literal.assert_bool(tcx) == Some(true)) == expected => { - TerminatorKind::Goto { target } - }, + } if (c.literal.map_evaluated(|e| e.assert_bool(tcx)) == Some(true)) == expected => + TerminatorKind::Goto { target }, TerminatorKind::FalseEdges { real_target, .. } => { TerminatorKind::Goto { target: real_target } }, diff --git a/src/librustc_mir/util/elaborate_drops.rs b/src/librustc_mir/util/elaborate_drops.rs index 5a2f4be71cc2f..8b55a4424ae29 100644 --- a/src/librustc_mir/util/elaborate_drops.rs +++ b/src/librustc_mir/util/elaborate_drops.rs @@ -963,7 +963,9 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D> span: self.source_info.span, ty: self.tcx().types.usize, user_ty: None, - literal: ty::Const::from_usize(self.tcx(), val.into()), + literal: self.tcx().intern_lazy_const(ty::LazyConst::Evaluated( + ty::Const::from_usize(self.tcx(), val.into()) + )), }) } diff --git a/src/librustc_mir/util/pretty.rs b/src/librustc_mir/util/pretty.rs index 6353eab6f6553..fca208b340d2a 100644 --- a/src/librustc_mir/util/pretty.rs +++ b/src/librustc_mir/util/pretty.rs @@ -399,12 +399,21 @@ impl<'cx, 'gcx, 'tcx> Visitor<'tcx> for ExtraComments<'cx, 'gcx, 'tcx> { self.push(&format!("+ literal: {:?}", literal)); } - fn visit_const(&mut self, constant: &&'tcx ty::Const<'tcx>, _: Location) { + fn visit_const(&mut self, constant: &&'tcx ty::LazyConst<'tcx>, _: Location) { self.super_const(constant); - let ty::Const { ty, val, .. } = constant; - self.push("ty::Const"); - self.push(&format!("+ ty: {:?}", ty)); - self.push(&format!("+ val: {:?}", val)); + match constant { + ty::LazyConst::Evaluated(constant) => { + let ty::Const { ty, val, .. } = constant; + self.push("ty::Const"); + self.push(&format!("+ ty: {:?}", ty)); + self.push(&format!("+ val: {:?}", val)); + }, + ty::LazyConst::Unevaluated(did, substs) => { + self.push("ty::LazyConst::Unevaluated"); + self.push(&format!("+ did: {:?}", did)); + self.push(&format!("+ substs: {:?}", substs)); + }, + } } fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, location: Location) { diff --git a/src/librustc_traits/chalk_context/program_clauses.rs b/src/librustc_traits/chalk_context/program_clauses.rs index 98a2f4bf0a15b..71f4945fd648d 100644 --- a/src/librustc_traits/chalk_context/program_clauses.rs +++ b/src/librustc_traits/chalk_context/program_clauses.rs @@ -239,7 +239,7 @@ fn wf_clause_for_slice<'tcx>(tcx: ty::TyCtxt<'_, '_, 'tcx>) -> Clauses<'tcx> { fn wf_clause_for_array<'tcx>( tcx: ty::TyCtxt<'_, '_, 'tcx>, - length: &'tcx ty::Const<'tcx> + length: &'tcx ty::LazyConst<'tcx> ) -> Clauses<'tcx> { let ty = generic_types::bound(tcx, 0); let array_ty = tcx.mk_ty(ty::Array(ty, length)); diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 1db7141917f98..e018aa3b26d91 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -1772,7 +1772,8 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o { hir::TyKind::Array(ref ty, ref length) => { let length_def_id = tcx.hir().local_def_id(length.id); let substs = Substs::identity_for_item(tcx, length_def_id); - let length = ty::Const::unevaluated(tcx, length_def_id, substs, tcx.types.usize); + let length = ty::LazyConst::Unevaluated(length_def_id, substs); + let length = tcx.intern_lazy_const(length); let array_ty = tcx.mk_ty(ty::Array(self.ast_ty_to_ty(&ty), length)); self.normalize_ty(ast_ty.span, array_ty) } diff --git a/src/librustc_typeck/check/callee.rs b/src/librustc_typeck/check/callee.rs index d4f639c070de3..c59c143f74b62 100644 --- a/src/librustc_typeck/check/callee.rs +++ b/src/librustc_typeck/check/callee.rs @@ -1,16 +1,17 @@ -use super::{Expectation, FnCtxt, Needs, TupleArgumentsFlag}; use super::autoderef::Autoderef; use super::method::MethodCallee; +use super::{Expectation, FnCtxt, Needs, TupleArgumentsFlag}; +use errors::Applicability; use hir::def::Def; use hir::def_id::{DefId, LOCAL_CRATE}; +use rustc::ty::adjustment::{Adjust, Adjustment, AllowTwoPhase, AutoBorrow, AutoBorrowMutability}; +use rustc::ty::{self, Ty, TyCtxt, TypeFoldable}; use rustc::{infer, traits}; -use rustc::ty::{self, TyCtxt, TypeFoldable, Ty}; -use rustc::ty::adjustment::{Adjustment, Adjust, AllowTwoPhase, AutoBorrow, AutoBorrowMutability}; +use rustc::infer::type_variable::TypeVariableOrigin; use rustc_target::spec::abi; use syntax::ast::Ident; use syntax_pos::Span; -use errors::Applicability; use rustc::hir; @@ -33,19 +34,20 @@ enum CallStep<'tcx> { } impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { - pub fn check_call(&self, - call_expr: &'gcx hir::Expr, - callee_expr: &'gcx hir::Expr, - arg_exprs: &'gcx [hir::Expr], - expected: Expectation<'tcx>) - -> Ty<'tcx> { + pub fn check_call( + &self, + call_expr: &'gcx hir::Expr, + callee_expr: &'gcx hir::Expr, + arg_exprs: &'gcx [hir::Expr], + expected: Expectation<'tcx>, + ) -> Ty<'tcx> { let original_callee_ty = self.check_expr(callee_expr); let expr_ty = self.structurally_resolved_type(call_expr.span, original_callee_ty); let mut autoderef = self.autoderef(callee_expr.span, expr_ty); let mut result = None; while result.is_none() && autoderef.next().is_some() { - result = self.try_overloaded_call_step(call_expr, callee_expr, &autoderef); + result = self.try_overloaded_call_step(call_expr, callee_expr, arg_exprs, &autoderef); } autoderef.finalize(self); @@ -74,15 +76,18 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { output } - fn try_overloaded_call_step(&self, - call_expr: &'gcx hir::Expr, - callee_expr: &'gcx hir::Expr, - autoderef: &Autoderef<'a, 'gcx, 'tcx>) - -> Option> { + fn try_overloaded_call_step( + &self, + call_expr: &'gcx hir::Expr, + callee_expr: &'gcx hir::Expr, + arg_exprs: &'gcx [hir::Expr], + autoderef: &Autoderef<'a, 'gcx, 'tcx>, + ) -> Option> { let adjusted_ty = autoderef.unambiguous_final_ty(self); - debug!("try_overloaded_call_step(call_expr={:?}, adjusted_ty={:?})", - call_expr, - adjusted_ty); + debug!( + "try_overloaded_call_step(call_expr={:?}, adjusted_ty={:?})", + call_expr, adjusted_ty + ); // If the callee is a bare function or a closure, then we're all set. match adjusted_ty.sty { @@ -100,21 +105,26 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // fnmut vs fnonce. If so, we have to defer further processing. if self.closure_kind(def_id, substs).is_none() { let closure_ty = self.closure_sig(def_id, substs); - let fn_sig = self.replace_bound_vars_with_fresh_vars( - call_expr.span, - infer::FnCall, - &closure_ty - ).0; + let fn_sig = self + .replace_bound_vars_with_fresh_vars( + call_expr.span, + infer::FnCall, + &closure_ty, + ) + .0; let adjustments = autoderef.adjust_steps(self, Needs::None); - self.record_deferred_call_resolution(def_id, DeferredCallResolution { - call_expr, - callee_expr, - adjusted_ty, - adjustments, - fn_sig, - closure_def_id: def_id, - closure_substs: substs, - }); + self.record_deferred_call_resolution( + def_id, + DeferredCallResolution { + call_expr, + callee_expr, + adjusted_ty, + adjustments, + fn_sig, + closure_def_id: def_id, + closure_substs: substs, + }, + ); return Some(CallStep::DeferredClosure(fn_sig)); } } @@ -134,34 +144,68 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { _ => {} } - self.try_overloaded_call_traits(call_expr, adjusted_ty).map(|(autoref, method)| { - let mut adjustments = autoderef.adjust_steps(self, Needs::None); - adjustments.extend(autoref); - self.apply_adjustments(callee_expr, adjustments); - CallStep::Overloaded(method) - }) + // Now, we look for the implementation of a Fn trait on the object's type. + // We first do it with the explicit instruction to look for an impl of + // `Fn`, with the tuple `Tuple` having an arity corresponding + // to the number of call parameters. + // If that fails (or_else branch), we try again without specifying the + // shape of the tuple (hence the None). This allows to detect an Fn trait + // is implemented, and use this information for diagnostic. + self.try_overloaded_call_traits(call_expr, adjusted_ty, Some(arg_exprs)) + .or_else(|| self.try_overloaded_call_traits(call_expr, adjusted_ty, None)) + .map(|(autoref, method)| { + let mut adjustments = autoderef.adjust_steps(self, Needs::None); + adjustments.extend(autoref); + self.apply_adjustments(callee_expr, adjustments); + CallStep::Overloaded(method) + }) } - fn try_overloaded_call_traits(&self, - call_expr: &hir::Expr, - adjusted_ty: Ty<'tcx>) - -> Option<(Option>, - MethodCallee<'tcx>)> { + fn try_overloaded_call_traits( + &self, + call_expr: &hir::Expr, + adjusted_ty: Ty<'tcx>, + opt_arg_exprs: Option<&'gcx [hir::Expr]>, + ) -> Option<(Option>, MethodCallee<'tcx>)> { // Try the options that are least restrictive on the caller first. - for &(opt_trait_def_id, method_name, borrow) in - &[(self.tcx.lang_items().fn_trait(), Ident::from_str("call"), true), - (self.tcx.lang_items().fn_mut_trait(), Ident::from_str("call_mut"), true), - (self.tcx.lang_items().fn_once_trait(), Ident::from_str("call_once"), false)] { + for &(opt_trait_def_id, method_name, borrow) in &[ + ( + self.tcx.lang_items().fn_trait(), + Ident::from_str("call"), + true, + ), + ( + self.tcx.lang_items().fn_mut_trait(), + Ident::from_str("call_mut"), + true, + ), + ( + self.tcx.lang_items().fn_once_trait(), + Ident::from_str("call_once"), + false, + ), + ] { let trait_def_id = match opt_trait_def_id { Some(def_id) => def_id, None => continue, }; - if let Some(ok) = self.lookup_method_in_trait(call_expr.span, - method_name, - trait_def_id, - adjusted_ty, - None) { + let opt_input_types = opt_arg_exprs.map(|arg_exprs| [self.tcx.mk_tup( + arg_exprs + .iter() + .map(|e| self.next_ty_var( + TypeVariableOrigin::TypeInference(e.span) + )) + )]); + let opt_input_types = opt_input_types.as_ref().map(AsRef::as_ref); + + if let Some(ok) = self.lookup_method_in_trait( + call_expr.span, + method_name, + trait_def_id, + adjusted_ty, + opt_input_types, + ) { let method = self.register_infer_ok_obligations(ok); let mut autoref = None; if borrow { @@ -173,11 +217,11 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // deployment, conservatively omit // overloaded function call ops. allow_two_phase_borrow: AllowTwoPhase::No, - } + }, }; autoref = Some(Adjustment { kind: Adjust::Borrow(AutoBorrow::Ref(region, mutbl)), - target: method.sig.inputs()[0] + target: method.sig.inputs()[0], }); } } @@ -188,16 +232,18 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { None } - fn confirm_builtin_call(&self, - call_expr: &hir::Expr, - callee_ty: Ty<'tcx>, - arg_exprs: &'gcx [hir::Expr], - expected: Expectation<'tcx>) - -> Ty<'tcx> { + fn confirm_builtin_call( + &self, + call_expr: &hir::Expr, + callee_ty: Ty<'tcx>, + arg_exprs: &'gcx [hir::Expr], + expected: Expectation<'tcx>, + ) -> Ty<'tcx> { let (fn_sig, def_span) = match callee_ty.sty { - ty::FnDef(def_id, _) => { - (callee_ty.fn_sig(self.tcx), self.tcx.hir().span_if_local(def_id)) - } + ty::FnDef(def_id, _) => ( + callee_ty.fn_sig(self.tcx), + self.tcx.hir().span_if_local(def_id), + ), ty::FnPtr(sig) => (sig, None), ref t => { let mut unit_variant = None; @@ -219,15 +265,19 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { match unit_variant { Some(ref path) => format!("enum variant `{}`", path), None => format!("`{}`", callee_ty), - }); + } + ); if let Some(ref path) = unit_variant { err.span_suggestion_with_applicability( call_expr.span, - &format!("`{}` is a unit variant, you need to write it \ - without the parenthesis", path), + &format!( + "`{}` is a unit variant, you need to write it \ + without the parenthesis", + path + ), path.to_string(), - Applicability::MachineApplicable + Applicability::MachineApplicable, ); } @@ -235,48 +285,50 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let def = match callee.node { hir::ExprKind::Path(ref qpath) => { self.tables.borrow().qpath_def(qpath, callee.hir_id) - }, + } hir::ExprKind::Call(ref inner_callee, _) => { // If the call spans more than one line and the callee kind is // itself another `ExprCall`, that's a clue that we might just be // missing a semicolon (Issue #51055) - let call_is_multiline = self.tcx.sess.source_map() - .is_multiline(call_expr.span); + let call_is_multiline = + self.tcx.sess.source_map().is_multiline(call_expr.span); if call_is_multiline { let span = self.tcx.sess.source_map().next_point(callee.span); err.span_suggestion_with_applicability( span, "try adding a semicolon", ";".to_owned(), - Applicability::MaybeIncorrect + Applicability::MaybeIncorrect, ); } if let hir::ExprKind::Path(ref inner_qpath) = inner_callee.node { inner_callee_path = Some(inner_qpath); - self.tables.borrow().qpath_def(inner_qpath, inner_callee.hir_id) + self.tables + .borrow() + .qpath_def(inner_qpath, inner_callee.hir_id) } else { Def::Err } - }, - _ => { - Def::Err } + _ => Def::Err, }; err.span_label(call_expr.span, "call expression requires function"); let def_span = match def { Def::Err => None, - Def::Local(id) | Def::Upvar(id, ..) => { - Some(self.tcx.hir().span(id)) - } - _ => def.opt_def_id().and_then(|did| self.tcx.hir().span_if_local(did)), + Def::Local(id) | Def::Upvar(id, ..) => Some(self.tcx.hir().span(id)), + _ => def + .opt_def_id() + .and_then(|did| self.tcx.hir().span_if_local(did)), }; if let Some(span) = def_span { let label = match (unit_variant, inner_callee_path) { (Some(path), _) => format!("`{}` defined here", path), (_, Some(hir::QPath::Resolved(_, path))) => format!( - "`{}` defined here returns `{}`", path, callee_ty.to_string() + "`{}` defined here returns `{}`", + path, + callee_ty.to_string() ), _ => format!("`{}` defined here", callee_ty.to_string()), }; @@ -284,19 +336,25 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } err.emit(); } else { - bug!("call_expr.node should be an ExprKind::Call, got {:?}", call_expr.node); + bug!( + "call_expr.node should be an ExprKind::Call, got {:?}", + call_expr.node + ); } // This is the "default" function signature, used in case of error. // In that case, we check each argument against "error" in order to // set up all the node type bindings. - (ty::Binder::bind(self.tcx.mk_fn_sig( - self.err_args(arg_exprs.len()).into_iter(), - self.tcx.types.err, - false, - hir::Unsafety::Normal, - abi::Abi::Rust - )), None) + ( + ty::Binder::bind(self.tcx.mk_fn_sig( + self.err_args(arg_exprs.len()).into_iter(), + self.tcx.types.err, + false, + hir::Unsafety::Normal, + abi::Abi::Rust, + )), + None, + ) } }; @@ -305,69 +363,80 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // renormalize the associated types at this point, since they // previously appeared within a `Binder<>` and hence would not // have been normalized before. - let fn_sig = - self.replace_bound_vars_with_fresh_vars(call_expr.span, infer::FnCall, &fn_sig) - .0; + let fn_sig = self + .replace_bound_vars_with_fresh_vars(call_expr.span, infer::FnCall, &fn_sig) + .0; let fn_sig = self.normalize_associated_types_in(call_expr.span, &fn_sig); // Call the generic checker. - let expected_arg_tys = - self.expected_inputs_for_expected_output(call_expr.span, - expected, - fn_sig.output(), - fn_sig.inputs()); - self.check_argument_types(call_expr.span, - call_expr.span, - fn_sig.inputs(), - &expected_arg_tys[..], - arg_exprs, - fn_sig.variadic, - TupleArgumentsFlag::DontTupleArguments, - def_span); + let expected_arg_tys = self.expected_inputs_for_expected_output( + call_expr.span, + expected, + fn_sig.output(), + fn_sig.inputs(), + ); + self.check_argument_types( + call_expr.span, + call_expr.span, + fn_sig.inputs(), + &expected_arg_tys[..], + arg_exprs, + fn_sig.variadic, + TupleArgumentsFlag::DontTupleArguments, + def_span, + ); fn_sig.output() } - fn confirm_deferred_closure_call(&self, - call_expr: &hir::Expr, - arg_exprs: &'gcx [hir::Expr], - expected: Expectation<'tcx>, - fn_sig: ty::FnSig<'tcx>) - -> Ty<'tcx> { + fn confirm_deferred_closure_call( + &self, + call_expr: &hir::Expr, + arg_exprs: &'gcx [hir::Expr], + expected: Expectation<'tcx>, + fn_sig: ty::FnSig<'tcx>, + ) -> Ty<'tcx> { // `fn_sig` is the *signature* of the cosure being called. We // don't know the full details yet (`Fn` vs `FnMut` etc), but we // do know the types expected for each argument and the return // type. - let expected_arg_tys = self.expected_inputs_for_expected_output(call_expr.span, - expected, - fn_sig.output().clone(), - fn_sig.inputs()); - - self.check_argument_types(call_expr.span, - call_expr.span, - fn_sig.inputs(), - &expected_arg_tys, - arg_exprs, - fn_sig.variadic, - TupleArgumentsFlag::TupleArguments, - None); + let expected_arg_tys = self.expected_inputs_for_expected_output( + call_expr.span, + expected, + fn_sig.output().clone(), + fn_sig.inputs(), + ); + + self.check_argument_types( + call_expr.span, + call_expr.span, + fn_sig.inputs(), + &expected_arg_tys, + arg_exprs, + fn_sig.variadic, + TupleArgumentsFlag::TupleArguments, + None, + ); fn_sig.output() } - fn confirm_overloaded_call(&self, - call_expr: &hir::Expr, - arg_exprs: &'gcx [hir::Expr], - expected: Expectation<'tcx>, - method_callee: MethodCallee<'tcx>) - -> Ty<'tcx> { - let output_type = self.check_method_argument_types(call_expr.span, - call_expr.span, - Ok(method_callee), - arg_exprs, - TupleArgumentsFlag::TupleArguments, - expected); + fn confirm_overloaded_call( + &self, + call_expr: &hir::Expr, + arg_exprs: &'gcx [hir::Expr], + expected: Expectation<'tcx>, + method_callee: MethodCallee<'tcx>, + ) -> Ty<'tcx> { + let output_type = self.check_method_argument_types( + call_expr.span, + call_expr.span, + Ok(method_callee), + arg_exprs, + TupleArgumentsFlag::TupleArguments, + expected, + ); self.write_method_call(call_expr.hir_id, method_callee); output_type @@ -391,11 +460,12 @@ impl<'a, 'gcx, 'tcx> DeferredCallResolution<'gcx, 'tcx> { // we should not be invoked until the closure kind has been // determined by upvar inference - assert!(fcx.closure_kind(self.closure_def_id, self.closure_substs).is_some()); + assert!(fcx + .closure_kind(self.closure_def_id, self.closure_substs) + .is_some()); // We may now know enough to figure out fn vs fnmut etc. - match fcx.try_overloaded_call_traits(self.call_expr, - self.adjusted_ty) { + match fcx.try_overloaded_call_traits(self.call_expr, self.adjusted_ty, None) { Some((autoref, method_callee)) => { // One problem is that when we get here, we are going // to have a newly instantiated function signature @@ -410,22 +480,28 @@ impl<'a, 'gcx, 'tcx> DeferredCallResolution<'gcx, 'tcx> { debug!("attempt_resolution: method_callee={:?}", method_callee); for (method_arg_ty, self_arg_ty) in - method_sig.inputs().iter().skip(1).zip(self.fn_sig.inputs()) { + method_sig.inputs().iter().skip(1).zip(self.fn_sig.inputs()) + { fcx.demand_eqtype(self.call_expr.span, &self_arg_ty, &method_arg_ty); } - fcx.demand_eqtype(self.call_expr.span, method_sig.output(), self.fn_sig.output()); + fcx.demand_eqtype( + self.call_expr.span, + method_sig.output(), + self.fn_sig.output(), + ); let mut adjustments = self.adjustments; adjustments.extend(autoref); fcx.apply_adjustments(self.callee_expr, adjustments); - fcx.write_method_call(self.call_expr.hir_id, - method_callee); + fcx.write_method_call(self.call_expr.hir_id, method_callee); } None => { - span_bug!(self.call_expr.span, - "failed to find an overloaded call trait for closure call"); + span_bug!( + self.call_expr.span, + "failed to find an overloaded call trait for closure call" + ); } } } diff --git a/src/librustc_typeck/check/closure.rs b/src/librustc_typeck/check/closure.rs index 25b1c0836c28b..5b2550713dbcb 100644 --- a/src/librustc_typeck/check/closure.rs +++ b/src/librustc_typeck/check/closure.rs @@ -494,7 +494,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { self.infcx.commit_if_ok(|_| { let mut all_obligations = vec![]; - // The liberated version of this signature should be be a subtype + // The liberated version of this signature should be a subtype // of the liberated form of the expectation. for ((hir_ty, &supplied_ty), expected_ty) in decl.inputs.iter() .zip(*supplied_sig.inputs().skip_binder()) // binder moved to (*) below diff --git a/src/librustc_typeck/check/intrinsic.rs b/src/librustc_typeck/check/intrinsic.rs index a36b21921436e..821c30b4fa709 100644 --- a/src/librustc_typeck/check/intrinsic.rs +++ b/src/librustc_typeck/check/intrinsic.rs @@ -133,6 +133,7 @@ pub fn check_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ], tcx.types.usize) } "rustc_peek" => (1, vec![param(0)], param(0)), + "panic_if_uninhabited" => (1, Vec::new(), tcx.mk_unit()), "init" => (1, Vec::new(), param(0)), "uninit" => (1, Vec::new(), param(0)), "forget" => (1, vec![param(0)], tcx.mk_unit()), diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index d78d7273a36e6..4865b70687d84 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -4442,7 +4442,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { if element_ty.references_error() { tcx.types.err } else if let Ok(count) = count { - tcx.mk_ty(ty::Array(t, count)) + tcx.mk_ty(ty::Array(t, tcx.intern_lazy_const(ty::LazyConst::Evaluated(count)))) } else { tcx.types.err } diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 38b2452b420e9..3aa752b35adcf 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -13,7 +13,6 @@ use rustc_data_structures::sync::Lrc; use rustc_target::spec::abi::Abi; use rustc_typeck::hir_ty_to_ty; use rustc::infer::region_constraints::{RegionConstraintData, Constraint}; -use rustc::mir::interpret::ConstValue; use rustc::middle::resolve_lifetime as rl; use rustc::middle::lang_items; use rustc::middle::stability; @@ -2420,10 +2419,10 @@ impl Clean for hir::Ty { instance: ty::Instance::new(def_id, substs), promoted: None }; - let length = cx.tcx.const_eval(param_env.and(cid)).unwrap_or_else(|_| { - ty::Const::unevaluated(cx.tcx, def_id, substs, cx.tcx.types.usize) - }); - let length = print_const(cx, length); + let length = match cx.tcx.const_eval(param_env.and(cid)) { + Ok(length) => print_const(cx, ty::LazyConst::Evaluated(length)), + Err(_) => "_".to_string(), + }; Array(box ty.clean(cx), length) }, TyKind::Tup(ref tys) => Tuple(tys.clean(cx)), @@ -2583,15 +2582,15 @@ impl<'tcx> Clean for Ty<'tcx> { ty::Str => Primitive(PrimitiveType::Str), ty::Slice(ty) => Slice(box ty.clean(cx)), ty::Array(ty, n) => { - let mut n = cx.tcx.lift(&n).expect("array lift failed"); - if let ConstValue::Unevaluated(def_id, substs) = n.val { + let mut n = *cx.tcx.lift(&n).expect("array lift failed"); + if let ty::LazyConst::Unevaluated(def_id, substs) = n { let param_env = cx.tcx.param_env(def_id); let cid = GlobalId { instance: ty::Instance::new(def_id, substs), promoted: None }; if let Ok(new_n) = cx.tcx.const_eval(param_env.and(cid)) { - n = new_n; + n = ty::LazyConst::Evaluated(new_n); } }; let n = print_const(cx, n); @@ -3691,16 +3690,16 @@ fn name_from_pat(p: &hir::Pat) -> String { } } -fn print_const(cx: &DocContext, n: &ty::Const) -> String { - match n.val { - ConstValue::Unevaluated(def_id, _) => { +fn print_const(cx: &DocContext, n: ty::LazyConst) -> String { + match n { + ty::LazyConst::Unevaluated(def_id, _) => { if let Some(node_id) = cx.tcx.hir().as_local_node_id(def_id) { print_const_expr(cx, cx.tcx.hir().body_owned_by(node_id)) } else { inline::print_inlined_const(cx, def_id) } }, - _ => { + ty::LazyConst::Evaluated(n) => { let mut s = String::new(); ::rustc::mir::fmt_const_val(&mut s, n).expect("fmt_const_val failed"); // array lengths are obviously usize diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 3fa2d085ece94..032b0fc974845 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -23,7 +23,7 @@ use syntax::json::JsonEmitter; use syntax::ptr::P; use syntax::symbol::keywords; use syntax_pos::DUMMY_SP; -use errors; +use errors::{self, FatalError}; use errors::emitter::{Emitter, EmitterWriter}; use parking_lot::ReentrantMutex; @@ -429,7 +429,13 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt let control = &driver::CompileController::basic(); - let krate = panictry!(driver::phase_1_parse_input(control, &sess, &input)); + let krate = match driver::phase_1_parse_input(control, &sess, &input) { + Ok(krate) => krate, + Err(mut e) => { + e.emit(); + FatalError.raise(); + } + }; let name = match crate_name { Some(ref crate_name) => crate_name.clone(), diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 67d512ed71d37..1b6d7e87192d6 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -32,7 +32,7 @@ extern crate rustc_metadata; extern crate rustc_target; extern crate rustc_typeck; extern crate serialize; -#[macro_use] extern crate syntax; +extern crate syntax; extern crate syntax_pos; extern crate test as testing; #[macro_use] extern crate log; diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index 24bb00f411242..dd9fbbb254662 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -1,4 +1,4 @@ -use errors; +use errors::{self, FatalError}; use errors::emitter::ColorConfig; use rustc_data_structures::sync::Lrc; use rustc_lint; @@ -84,9 +84,14 @@ pub fn run(mut options: Options) -> isize { target_features::add_configuration(&mut cfg, &sess, &*codegen_backend); sess.parse_sess.config = cfg; - let krate = panictry!(driver::phase_1_parse_input(&driver::CompileController::basic(), - &sess, - &input)); + let krate = + match driver::phase_1_parse_input(&driver::CompileController::basic(), &sess, &input) { + Ok(krate) => krate, + Err(mut e) => { + e.emit(); + FatalError.raise(); + } + }; let driver::ExpansionResult { defs, mut hir_forest, .. } = { phase_2_configure_and_expand( &sess, diff --git a/src/libstd/keyword_docs.rs b/src/libstd/keyword_docs.rs index 4ca62cca94bc8..262930e08c004 100644 --- a/src/libstd/keyword_docs.rs +++ b/src/libstd/keyword_docs.rs @@ -169,7 +169,7 @@ mod crate_keyword { } /// /// [Algebraic Data Types]: https://en.wikipedia.org/wiki/Algebraic_data_type /// [`Option`]: option/enum.Option.html -/// [Rust Book]: https://doc.rust-lang.org/book/second-edition/ch06-01-defining-an-enum.html +/// [Rust Book]: https://doc.rust-lang.org/book/ch06-01-defining-an-enum.html /// [Reference]: https://doc.rust-lang.org/reference/items/enumerations.html mod enum_keyword { } @@ -211,7 +211,7 @@ mod enum_keyword { } /// For more information on FFI, check the [Rust book] or the [Reference]. /// /// [Rust book]: -/// https://doc.rust-lang.org/book/second-edition/ch19-01-unsafe-rust.html#using-extern-functions-to-call-external-code +/// https://doc.rust-lang.org/book/ch19-01-unsafe-rust.html#using-extern-functions-to-call-external-code /// [Reference]: https://doc.rust-lang.org/reference/items/external-blocks.html mod extern_keyword { } @@ -278,7 +278,7 @@ mod extern_keyword { } /// /// [`impl`]: keyword.impl.html /// [`extern`]: keyword.extern.html -/// [Rust book]: https://doc.rust-lang.org/book/second-edition/ch03-03-how-functions-work.html +/// [Rust book]: https://doc.rust-lang.org/book/ch03-03-how-functions-work.html /// [Reference]: https://doc.rust-lang.org/reference/items/functions.html mod fn_keyword { } @@ -705,6 +705,6 @@ mod loop_keyword { } /// [Reference][reference]. /// /// [`PhantomData`]: marker/struct.PhantomData.html -/// [book]: https://doc.rust-lang.org/book/second-edition/ch05-01-defining-structs.html +/// [book]: https://doc.rust-lang.org/book/ch05-01-defining-structs.html /// [reference]: https://doc.rust-lang.org/reference/items/structs.html mod struct_keyword { } diff --git a/src/libstd/primitive_docs.rs b/src/libstd/primitive_docs.rs index 7755d9339e6f5..475c9b4aeaa4e 100644 --- a/src/libstd/primitive_docs.rs +++ b/src/libstd/primitive_docs.rs @@ -923,7 +923,7 @@ mod prim_usize { } /// For more information on how to use references, see [the book's section on "References and /// Borrowing"][book-refs]. /// -/// [book-refs]: ../book/second-edition/ch04-02-references-and-borrowing.html +/// [book-refs]: ../book/ch04-02-references-and-borrowing.html /// /// # Trait implementations /// diff --git a/src/libstd/sys/windows/backtrace/mod.rs b/src/libstd/sys/windows/backtrace/mod.rs index a6bd8f8cc51cb..4bda8ac91da62 100644 --- a/src/libstd/sys/windows/backtrace/mod.rs +++ b/src/libstd/sys/windows/backtrace/mod.rs @@ -103,7 +103,7 @@ fn set_frames(StackWalk: W, frames: &mut [Frame]) -> io::Result< frames[i] = Frame { symbol_addr: addr, exact_position: addr, - inline_context: 0, + inline_context: frame.get_inline_context(), }; i += 1 @@ -209,6 +209,7 @@ trait StackFrame { fn new() -> Self; fn init(&mut self, ctx: &c::CONTEXT) -> c::DWORD; fn get_addr(&self) -> *const u8; + fn get_inline_context(&self) -> u32; } impl StackFrame for c::STACKFRAME_EX { @@ -263,6 +264,10 @@ impl StackFrame for c::STACKFRAME_EX { fn get_addr(&self) -> *const u8 { (self.AddrPC.Offset - 1) as *const u8 } + + fn get_inline_context(&self) -> u32 { + self.InlineFrameContext + } } impl StackFrame for c::STACKFRAME64 { @@ -317,6 +322,10 @@ impl StackFrame for c::STACKFRAME64 { fn get_addr(&self) -> *const u8 { (self.AddrPC.Offset - 1) as *const u8 } + + fn get_inline_context(&self) -> u32 { + 0 + } } enum StackWalkVariant { diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 3f2122e24a642..8362c86f8bab9 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -479,6 +479,9 @@ declare_features! ( // Allows paths to enum variants on type aliases. (active, type_alias_enum_variants, "1.31.0", Some(49683), None), + + // Re-Rebalance coherence + (active, re_rebalance_coherence, "1.32.0", Some(55437), None), ); declare_features! ( diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index f1345d0e6f16e..ea943e16a46e8 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -44,8 +44,6 @@ use ast::AttrId; // way towards a non-panic!-prone parser. It should be used for fatal parsing // errors; eventually we plan to convert all code using panictry to just use // normal try. -// Exported for syntax_ext, not meant for general use. -#[macro_export] macro_rules! panictry { ($e:expr) => ({ use std::result::Result::{Ok, Err}; diff --git a/src/libsyntax_ext/asm.rs b/src/libsyntax_ext/asm.rs index a8f3c40db609c..41ee6e91b3dc9 100644 --- a/src/libsyntax_ext/asm.rs +++ b/src/libsyntax_ext/asm.rs @@ -4,6 +4,7 @@ use self::State::*; use rustc_data_structures::thin_vec::ThinVec; +use errors::DiagnosticBuilder; use syntax::ast; use syntax::ext::base; use syntax::ext::base::*; @@ -51,6 +52,34 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, feature_gate::EXPLAIN_ASM); } + let mut inline_asm = match parse_inline_asm(cx, sp, tts) { + Ok(Some(inline_asm)) => inline_asm, + Ok(None) => return DummyResult::expr(sp), + Err(mut err) => { + err.emit(); + return DummyResult::expr(sp); + } + }; + + // If there are no outputs, the inline assembly is executed just for its side effects, + // so ensure that it is volatile + if inline_asm.outputs.is_empty() { + inline_asm.volatile = true; + } + + MacEager::expr(P(ast::Expr { + id: ast::DUMMY_NODE_ID, + node: ast::ExprKind::InlineAsm(P(inline_asm)), + span: sp, + attrs: ThinVec::new(), + })) +} + +fn parse_inline_asm<'a>( + cx: &mut ExtCtxt<'a>, + sp: Span, + tts: &[tokenstream::TokenTree], +) -> Result, DiagnosticBuilder<'a>> { // Split the tts before the first colon, to avoid `asm!("x": y)` being // parsed as `asm!(z)` with `z = "x": y` which is type ascription. let first_colon = tts.iter() @@ -80,22 +109,33 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, if asm_str_style.is_some() { // If we already have a string with instructions, // ending up in Asm state again is an error. - span_err!(cx, sp, E0660, "malformed inline assembly"); - return DummyResult::expr(sp); + return Err(struct_span_err!( + cx.parse_sess.span_diagnostic, + sp, + E0660, + "malformed inline assembly" + )); } // Nested parser, stop before the first colon (see above). let mut p2 = cx.new_parser_from_tts(&tts[..first_colon]); - let (s, style) = match expr_to_string(cx, - panictry!(p2.parse_expr()), - "inline assembly must be a string literal") { - Some((s, st)) => (s, st), - // let compilation continue - None => return DummyResult::expr(sp), - }; + + if p2.token == token::Eof { + let mut err = + cx.struct_span_err(sp, "macro requires a string literal as an argument"); + err.span_label(sp, "string literal required"); + return Err(err); + } + + let expr = p2.parse_expr()?; + let (s, style) = + match expr_to_string(cx, expr, "inline assembly must be a string literal") { + Some((s, st)) => (s, st), + None => return Ok(None), + }; // This is most likely malformed. if p2.token != token::Eof { - let mut extra_tts = panictry!(p2.parse_all_token_trees()); + let mut extra_tts = p2.parse_all_token_trees()?; extra_tts.extend(tts[first_colon..].iter().cloned()); p = parse::stream_to_parser(cx.parse_sess, extra_tts.into_iter().collect()); } @@ -105,18 +145,17 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, } Outputs => { while p.token != token::Eof && p.token != token::Colon && p.token != token::ModSep { - if !outputs.is_empty() { p.eat(&token::Comma); } - let (constraint, _str_style) = panictry!(p.parse_str()); + let (constraint, _) = p.parse_str()?; let span = p.prev_span; - panictry!(p.expect(&token::OpenDelim(token::Paren))); - let out = panictry!(p.parse_expr()); - panictry!(p.expect(&token::CloseDelim(token::Paren))); + p.expect(&token::OpenDelim(token::Paren))?; + let expr = p.parse_expr()?; + p.expect(&token::CloseDelim(token::Paren))?; // Expands a read+write operand into two operands. // @@ -143,7 +182,7 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, let is_indirect = constraint_str.contains("*"); outputs.push(ast::InlineAsmOutput { constraint: output.unwrap_or(constraint), - expr: out, + expr, is_rw, is_indirect, }); @@ -151,12 +190,11 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, } Inputs => { while p.token != token::Eof && p.token != token::Colon && p.token != token::ModSep { - if !inputs.is_empty() { p.eat(&token::Comma); } - let (constraint, _str_style) = panictry!(p.parse_str()); + let (constraint, _) = p.parse_str()?; if constraint.as_str().starts_with("=") { span_err!(cx, p.prev_span, E0662, @@ -166,21 +204,20 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, "input operand constraint contains '+'"); } - panictry!(p.expect(&token::OpenDelim(token::Paren))); - let input = panictry!(p.parse_expr()); - panictry!(p.expect(&token::CloseDelim(token::Paren))); + p.expect(&token::OpenDelim(token::Paren))?; + let input = p.parse_expr()?; + p.expect(&token::CloseDelim(token::Paren))?; inputs.push((constraint, input)); } } Clobbers => { while p.token != token::Eof && p.token != token::Colon && p.token != token::ModSep { - if !clobs.is_empty() { p.eat(&token::Comma); } - let (s, _str_style) = panictry!(p.parse_str()); + let (s, _) = p.parse_str()?; if OPTIONS.iter().any(|&opt| s == opt) { cx.span_warn(p.prev_span, "expected a clobber, found an option"); @@ -193,7 +230,7 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, } } Options => { - let (option, _str_style) = panictry!(p.parse_str()); + let (option, _) = p.parse_str()?; if option == "volatile" { // Indicates that the inline assembly has side effects @@ -234,26 +271,15 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, } } - // If there are no outputs, the inline assembly is executed just for its side effects, - // so ensure that it is volatile - if outputs.is_empty() { - volatile = true; - } - - MacEager::expr(P(ast::Expr { - id: ast::DUMMY_NODE_ID, - node: ast::ExprKind::InlineAsm(P(ast::InlineAsm { - asm, - asm_str_style: asm_str_style.unwrap(), - outputs, - inputs, - clobbers: clobs, - volatile, - alignstack, - dialect, - ctxt: cx.backtrace(), - })), - span: sp, - attrs: ThinVec::new(), + Ok(Some(ast::InlineAsm { + asm, + asm_str_style: asm_str_style.unwrap(), + outputs, + inputs, + clobbers: clobs, + volatile, + alignstack, + dialect, + ctxt: cx.backtrace(), })) } diff --git a/src/libsyntax_ext/assert.rs b/src/libsyntax_ext/assert.rs index 2f5743e5e9b3d..b27f495322a42 100644 --- a/src/libsyntax_ext/assert.rs +++ b/src/libsyntax_ext/assert.rs @@ -1,9 +1,11 @@ -use syntax::ast::*; +use errors::DiagnosticBuilder; +use syntax::ast::{self, *}; use syntax::source_map::Spanned; use syntax::ext::base::*; use syntax::ext::build::AstBuilder; use syntax::parse::token; use syntax::print::pprust; +use syntax::ptr::P; use syntax::symbol::Symbol; use syntax::tokenstream::{TokenStream, TokenTree}; use syntax_pos::{Span, DUMMY_SP}; @@ -13,33 +15,18 @@ pub fn expand_assert<'cx>( sp: Span, tts: &[TokenTree], ) -> Box { - let mut parser = cx.new_parser_from_tts(tts); - - if parser.token == token::Eof { - cx.struct_span_err(sp, "macro requires a boolean expression as an argument") - .span_label(sp, "boolean expression required") - .emit(); - return DummyResult::expr(sp); - } - - let cond_expr = panictry!(parser.parse_expr()); - let custom_msg_args = if parser.eat(&token::Comma) { - let ts = parser.parse_tokens(); - if !ts.is_empty() { - Some(ts) - } else { - None + let Assert { cond_expr, custom_message } = match parse_assert(cx, sp, tts) { + Ok(assert) => assert, + Err(mut err) => { + err.emit(); + return DummyResult::expr(sp); } - } else { - None }; let sp = sp.apply_mark(cx.current_expansion.mark); let panic_call = Mac_ { path: Path::from_ident(Ident::new(Symbol::intern("panic"), sp)), - tts: if let Some(ts) = custom_msg_args { - ts.into() - } else { + tts: custom_message.unwrap_or_else(|| { TokenStream::from(TokenTree::Token( DUMMY_SP, token::Literal( @@ -49,8 +36,8 @@ pub fn expand_assert<'cx>( ))), None, ), - )).into() - }, + )) + }).into(), delim: MacDelimiter::Parenthesis, }; let if_expr = cx.expr_if( @@ -67,3 +54,36 @@ pub fn expand_assert<'cx>( ); MacEager::expr(if_expr) } + +struct Assert { + cond_expr: P, + custom_message: Option, +} + +fn parse_assert<'a>( + cx: &mut ExtCtxt<'a>, + sp: Span, + tts: &[TokenTree] +) -> Result> { + let mut parser = cx.new_parser_from_tts(tts); + + if parser.token == token::Eof { + let mut err = cx.struct_span_err(sp, "macro requires a boolean expression as an argument"); + err.span_label(sp, "boolean expression required"); + return Err(err); + } + + Ok(Assert { + cond_expr: parser.parse_expr()?, + custom_message: if parser.eat(&token::Comma) { + let ts = parser.parse_tokens(); + if !ts.is_empty() { + Some(ts) + } else { + None + } + } else { + None + }, + }) +} diff --git a/src/libsyntax_ext/cfg.rs b/src/libsyntax_ext/cfg.rs index 7e3c1bbddf525..3b47b03cbe8dc 100644 --- a/src/libsyntax_ext/cfg.rs +++ b/src/libsyntax_ext/cfg.rs @@ -2,6 +2,8 @@ /// a literal `true` or `false` based on whether the given cfg matches the /// current compilation environment. +use errors::DiagnosticBuilder; +use syntax::ast; use syntax::ext::base::*; use syntax::ext::base; use syntax::ext::build::AstBuilder; @@ -15,16 +17,39 @@ pub fn expand_cfg<'cx>(cx: &mut ExtCtxt, tts: &[tokenstream::TokenTree]) -> Box { let sp = sp.apply_mark(cx.current_expansion.mark); + + match parse_cfg(cx, sp, tts) { + Ok(cfg) => { + let matches_cfg = attr::cfg_matches(&cfg, cx.parse_sess, cx.ecfg.features); + MacEager::expr(cx.expr_bool(sp, matches_cfg)) + } + Err(mut err) => { + err.emit(); + DummyResult::expr(sp) + } + } +} + +fn parse_cfg<'a>( + cx: &mut ExtCtxt<'a>, + sp: Span, + tts: &[tokenstream::TokenTree], +) -> Result> { let mut p = cx.new_parser_from_tts(tts); - let cfg = panictry!(p.parse_meta_item()); + + if p.token == token::Eof { + let mut err = cx.struct_span_err(sp, "macro requires a cfg-pattern as an argument"); + err.span_label(sp, "cfg-pattern required"); + return Err(err); + } + + let cfg = p.parse_meta_item()?; let _ = p.eat(&token::Comma); if !p.eat(&token::Eof) { - cx.span_err(sp, "expected 1 cfg-pattern"); - return DummyResult::expr(sp); + return Err(cx.struct_span_err(sp, "expected 1 cfg-pattern")); } - let matches_cfg = attr::cfg_matches(&cfg, cx.parse_sess, cx.ecfg.features); - MacEager::expr(cx.expr_bool(sp, matches_cfg)) + Ok(cfg) } diff --git a/src/libsyntax_ext/format.rs b/src/libsyntax_ext/format.rs index c11f27f3ed589..61722ba551653 100644 --- a/src/libsyntax_ext/format.rs +++ b/src/libsyntax_ext/format.rs @@ -3,6 +3,7 @@ use self::Position::*; use fmt_macros as parse; +use errors::DiagnosticBuilder; use syntax::ast; use syntax::ext::base::{self, *}; use syntax::ext::build::AstBuilder; @@ -112,7 +113,7 @@ struct Context<'a, 'b: 'a> { is_literal: bool, } -/// Parses the arguments from the given list of tokens, returning None +/// Parses the arguments from the given list of tokens, returning the diagnostic /// if there's a parse error so we can continue parsing other format! /// expressions. /// @@ -121,27 +122,26 @@ struct Context<'a, 'b: 'a> { /// ```text /// Some((fmtstr, parsed arguments, index map for named arguments)) /// ``` -fn parse_args(ecx: &mut ExtCtxt, - sp: Span, - tts: &[tokenstream::TokenTree]) - -> Option<(P, Vec>, FxHashMap)> { +fn parse_args<'a>( + ecx: &mut ExtCtxt<'a>, + sp: Span, + tts: &[tokenstream::TokenTree] +) -> Result<(P, Vec>, FxHashMap), DiagnosticBuilder<'a>> { let mut args = Vec::>::new(); let mut names = FxHashMap::::default(); let mut p = ecx.new_parser_from_tts(tts); if p.token == token::Eof { - ecx.span_err(sp, "requires at least a format string argument"); - return None; + return Err(ecx.struct_span_err(sp, "requires at least a format string argument")); } - let fmtstr = panictry!(p.parse_expr()); + let fmtstr = p.parse_expr()?; let mut named = false; while p.token != token::Eof { if !p.eat(&token::Comma) { - ecx.span_err(p.span, "expected token: `,`"); - return None; + return Err(ecx.struct_span_err(p.span, "expected token: `,`")); } if p.token == token::Eof { break; @@ -152,16 +152,15 @@ fn parse_args(ecx: &mut ExtCtxt, p.bump(); i } else { - ecx.span_err( + return Err(ecx.struct_span_err( p.span, "expected ident, positional arguments cannot follow named arguments", - ); - return None; + )); }; let name: &str = &ident.as_str(); - panictry!(p.expect(&token::Eq)); - let e = panictry!(p.parse_expr()); + p.expect(&token::Eq).unwrap(); + let e = p.parse_expr()?; if let Some(prev) = names.get(name) { ecx.struct_span_err(e.span, &format!("duplicate argument named `{}`", name)) .span_note(args[*prev].span, "previously here") @@ -177,10 +176,11 @@ fn parse_args(ecx: &mut ExtCtxt, names.insert(name.to_string(), slot); args.push(e); } else { - args.push(panictry!(p.parse_expr())); + let e = p.parse_expr()?; + args.push(e); } } - Some((fmtstr, args, names)) + Ok((fmtstr, args, names)) } impl<'a, 'b> Context<'a, 'b> { @@ -689,10 +689,13 @@ pub fn expand_format_args<'cx>(ecx: &'cx mut ExtCtxt, -> Box { sp = sp.apply_mark(ecx.current_expansion.mark); match parse_args(ecx, sp, tts) { - Some((efmt, args, names)) => { + Ok((efmt, args, names)) => { MacEager::expr(expand_preparsed_format_args(ecx, sp, efmt, args, names, false)) } - None => DummyResult::expr(sp), + Err(mut err) => { + err.emit(); + DummyResult::expr(sp) + } } } @@ -716,10 +719,13 @@ pub fn expand_format_args_nl<'cx>( } sp = sp.apply_mark(ecx.current_expansion.mark); match parse_args(ecx, sp, tts) { - Some((efmt, args, names)) => { + Ok((efmt, args, names)) => { MacEager::expr(expand_preparsed_format_args(ecx, sp, efmt, args, names, true)) } - None => DummyResult::expr(sp), + Err(mut err) => { + err.emit(); + DummyResult::expr(sp) + } } } diff --git a/src/libsyntax_ext/global_asm.rs b/src/libsyntax_ext/global_asm.rs index a58c267ab4fae..0a12e27c4fc21 100644 --- a/src/libsyntax_ext/global_asm.rs +++ b/src/libsyntax_ext/global_asm.rs @@ -8,11 +8,13 @@ /// LLVM's `module asm "some assembly here"`. All of LLVM's caveats /// therefore apply. +use errors::DiagnosticBuilder; use syntax::ast; use syntax::source_map::respan; use syntax::ext::base; use syntax::ext::base::*; use syntax::feature_gate; +use syntax::parse::token; use syntax::ptr::P; use syntax::symbol::Symbol; use syntax_pos::Span; @@ -31,24 +33,47 @@ pub fn expand_global_asm<'cx>(cx: &'cx mut ExtCtxt, feature_gate::EXPLAIN_GLOBAL_ASM); } + match parse_global_asm(cx, sp, tts) { + Ok(Some(global_asm)) => { + MacEager::items(smallvec![P(ast::Item { + ident: ast::Ident::with_empty_ctxt(Symbol::intern("")), + attrs: Vec::new(), + id: ast::DUMMY_NODE_ID, + node: ast::ItemKind::GlobalAsm(P(global_asm)), + vis: respan(sp.shrink_to_lo(), ast::VisibilityKind::Inherited), + span: sp, + tokens: None, + })]) + } + Ok(None) => DummyResult::any(sp), + Err(mut err) => { + err.emit(); + DummyResult::any(sp) + } + } +} + +fn parse_global_asm<'a>( + cx: &mut ExtCtxt<'a>, + sp: Span, + tts: &[tokenstream::TokenTree] +) -> Result, DiagnosticBuilder<'a>> { let mut p = cx.new_parser_from_tts(tts); - let (asm, _) = match expr_to_string(cx, - panictry!(p.parse_expr()), - "inline assembly must be a string literal") { + + if p.token == token::Eof { + let mut err = cx.struct_span_err(sp, "macro requires a string literal as an argument"); + err.span_label(sp, "string literal required"); + return Err(err); + } + + let expr = p.parse_expr()?; + let (asm, _) = match expr_to_string(cx, expr, "inline assembly must be a string literal") { Some((s, st)) => (s, st), - None => return DummyResult::any(sp), + None => return Ok(None), }; - MacEager::items(smallvec![P(ast::Item { - ident: ast::Ident::with_empty_ctxt(Symbol::intern("")), - attrs: Vec::new(), - id: ast::DUMMY_NODE_ID, - node: ast::ItemKind::GlobalAsm(P(ast::GlobalAsm { - asm, - ctxt: cx.backtrace(), - })), - vis: respan(sp.shrink_to_lo(), ast::VisibilityKind::Inherited), - span: sp, - tokens: None, - })]) + Ok(Some(ast::GlobalAsm { + asm, + ctxt: cx.backtrace(), + })) } diff --git a/src/stdsimd b/src/stdsimd index 513e067908f3e..ddb30221d7985 160000 --- a/src/stdsimd +++ b/src/stdsimd @@ -1 +1 @@ -Subproject commit 513e067908f3e2eb8b31ad1c12b2e0a62817e557 +Subproject commit ddb30221d7985e813b4214d14c2a560ed6ee0991 diff --git a/src/test/compile-fail/invalid-link-args.rs b/src/test/compile-fail/invalid-link-args.rs new file mode 100644 index 0000000000000..1e68b4f8b7025 --- /dev/null +++ b/src/test/compile-fail/invalid-link-args.rs @@ -0,0 +1,12 @@ +// ignore-msvc due to linker-flavor=ld +// error-pattern:aFdEfSeVEEE +// compile-flags: -C linker-flavor=ld + +/* Make sure invalid link_args are printed to stderr. */ + +#![feature(link_args)] + +#[link_args = "aFdEfSeVEEE"] +extern {} + +fn main() { } diff --git a/src/test/compile-fail/nolink-with-link-args.rs b/src/test/compile-fail/nolink-with-link-args.rs deleted file mode 100644 index c2ca2f807426f..0000000000000 --- a/src/test/compile-fail/nolink-with-link-args.rs +++ /dev/null @@ -1,13 +0,0 @@ -// error-pattern:aFdEfSeVEE -// compile-flags: -C linker-flavor=ld - -/* We're testing that link_args are indeed passed when nolink is specified. -So we try to compile with junk link_args and make sure they are visible in -the compiler output. */ - -#![feature(link_args)] - -#[link_args = "aFdEfSeVEEE"] -extern {} - -fn main() { } diff --git a/src/test/run-make-fulldeps/llvm-pass/Makefile b/src/test/run-make-fulldeps/llvm-pass/Makefile deleted file mode 100644 index 8a18aadf36a8b..0000000000000 --- a/src/test/run-make-fulldeps/llvm-pass/Makefile +++ /dev/null @@ -1,28 +0,0 @@ --include ../tools.mk - -ifeq ($(UNAME),Darwin) -PLUGIN_FLAGS := -C link-args=-Wl,-undefined,dynamic_lookup -endif - -ifeq ($(findstring stage1,$(RUST_BUILD_STAGE)),stage1) -# ignore stage1 -all: - -else -# Windows doesn't correctly handle include statements with escaping paths, -# so this test will not get run on Windows. -ifdef IS_WINDOWS -all: -else -all: $(call NATIVE_STATICLIB,llvm-function-pass) $(call NATIVE_STATICLIB,llvm-module-pass) - $(RUSTC) plugin.rs -C prefer-dynamic $(PLUGIN_FLAGS) - $(RUSTC) main.rs - -$(TMPDIR)/libllvm-function-pass.o: - $(CXX) $(CFLAGS) $(LLVM_CXXFLAGS) -c llvm-function-pass.so.cc -o $(TMPDIR)/libllvm-function-pass.o - -$(TMPDIR)/libllvm-module-pass.o: - $(CXX) $(CFLAGS) $(LLVM_CXXFLAGS) -c llvm-module-pass.so.cc -o $(TMPDIR)/libllvm-module-pass.o -endif - -endif diff --git a/src/test/run-make-fulldeps/llvm-pass/llvm-function-pass.so.cc b/src/test/run-make-fulldeps/llvm-pass/llvm-function-pass.so.cc deleted file mode 100644 index 267c68853ac43..0000000000000 --- a/src/test/run-make-fulldeps/llvm-pass/llvm-function-pass.so.cc +++ /dev/null @@ -1,46 +0,0 @@ -#include -#include -#include - -#include "llvm/Pass.h" -#include "llvm/IR/Function.h" - -using namespace llvm; - -namespace { - - class TestLLVMPass : public FunctionPass { - - public: - - static char ID; - TestLLVMPass() : FunctionPass(ID) { } - - bool runOnFunction(Function &F) override; - - StringRef getPassName() const override { - return "Some LLVM pass"; - } - - }; - -} - -bool TestLLVMPass::runOnFunction(Function &F) { - // A couple examples of operations that previously caused segmentation faults - // https://github.com/rust-lang/rust/issues/31067 - - for (auto N = F.begin(); N != F.end(); ++N) { - /* code */ - } - - LLVMContext &C = F.getContext(); - IntegerType *Int8Ty = IntegerType::getInt8Ty(C); - PointerType::get(Int8Ty, 0); - return true; -} - -char TestLLVMPass::ID = 0; - -static RegisterPass RegisterAFLPass( - "some-llvm-function-pass", "Some LLVM pass"); diff --git a/src/test/run-make-fulldeps/llvm-pass/llvm-module-pass.so.cc b/src/test/run-make-fulldeps/llvm-pass/llvm-module-pass.so.cc deleted file mode 100644 index b3ee0c1a6c10b..0000000000000 --- a/src/test/run-make-fulldeps/llvm-pass/llvm-module-pass.so.cc +++ /dev/null @@ -1,45 +0,0 @@ -#include -#include -#include - -#include "llvm/IR/Module.h" - -using namespace llvm; - -namespace { - - class TestLLVMPass : public ModulePass { - - public: - - static char ID; - TestLLVMPass() : ModulePass(ID) { } - - bool runOnModule(Module &M) override; - - StringRef getPassName() const override { - return "Some LLVM pass"; - } - - }; - -} - -bool TestLLVMPass::runOnModule(Module &M) { - // A couple examples of operations that previously caused segmentation faults - // https://github.com/rust-lang/rust/issues/31067 - - for (auto F = M.begin(); F != M.end(); ++F) { - /* code */ - } - - LLVMContext &C = M.getContext(); - IntegerType *Int8Ty = IntegerType::getInt8Ty(C); - PointerType::get(Int8Ty, 0); - return true; -} - -char TestLLVMPass::ID = 0; - -static RegisterPass RegisterAFLPass( - "some-llvm-module-pass", "Some LLVM pass"); diff --git a/src/test/run-make-fulldeps/llvm-pass/main.rs b/src/test/run-make-fulldeps/llvm-pass/main.rs deleted file mode 100644 index 0c13b890c6e3a..0000000000000 --- a/src/test/run-make-fulldeps/llvm-pass/main.rs +++ /dev/null @@ -1,4 +0,0 @@ -#![feature(plugin)] -#![plugin(some_plugin)] - -fn main() {} diff --git a/src/test/run-make-fulldeps/llvm-pass/plugin.rs b/src/test/run-make-fulldeps/llvm-pass/plugin.rs deleted file mode 100644 index f0e4800046cf4..0000000000000 --- a/src/test/run-make-fulldeps/llvm-pass/plugin.rs +++ /dev/null @@ -1,18 +0,0 @@ -#![feature(plugin_registrar, rustc_private)] -#![crate_type = "dylib"] -#![crate_name = "some_plugin"] - -extern crate rustc; -extern crate rustc_plugin; - -#[link(name = "llvm-function-pass", kind = "static")] -#[link(name = "llvm-module-pass", kind = "static")] -extern {} - -use rustc_plugin::registry::Registry; - -#[plugin_registrar] -pub fn plugin_registrar(reg: &mut Registry) { - reg.register_llvm_pass("some-llvm-function-pass"); - reg.register_llvm_pass("some-llvm-module-pass"); -} diff --git a/src/test/run-pass/coherence/auxiliary/re_rebalance_coherence_lib.rs b/src/test/run-pass/coherence/auxiliary/re_rebalance_coherence_lib.rs new file mode 100644 index 0000000000000..c8d027b25c748 --- /dev/null +++ b/src/test/run-pass/coherence/auxiliary/re_rebalance_coherence_lib.rs @@ -0,0 +1,23 @@ + +pub trait Backend{} +pub trait SupportsDefaultKeyword {} + +impl SupportsDefaultKeyword for Postgres {} + +pub struct Postgres; + +impl Backend for Postgres {} + +pub struct AstPass(::std::marker::PhantomData); + +pub trait QueryFragment {} + + +#[derive(Debug, Clone, Copy)] +pub struct BatchInsert<'a, T: 'a, Tab> { + _marker: ::std::marker::PhantomData<(&'a T, Tab)>, +} + +impl<'a, T:'a, Tab, DB> QueryFragment for BatchInsert<'a, T, Tab> +where DB: SupportsDefaultKeyword + Backend, +{} diff --git a/src/test/run-pass/coherence/coherence-bigint-int.rs b/src/test/run-pass/coherence/coherence-bigint-int.rs index 02945e9dade3a..0c9abdc15e620 100644 --- a/src/test/run-pass/coherence/coherence-bigint-int.rs +++ b/src/test/run-pass/coherence/coherence-bigint-int.rs @@ -1,5 +1,8 @@ // run-pass // aux-build:coherence_lib.rs +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] // pretty-expanded FIXME #23616 diff --git a/src/test/run-pass/coherence/coherence-bigint-vecint.rs b/src/test/run-pass/coherence/coherence-bigint-vecint.rs index a5dba90be5c59..38e0be0aa9ab9 100644 --- a/src/test/run-pass/coherence/coherence-bigint-vecint.rs +++ b/src/test/run-pass/coherence/coherence-bigint-vecint.rs @@ -1,5 +1,8 @@ // run-pass // aux-build:coherence_lib.rs +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] // pretty-expanded FIXME #23616 diff --git a/src/test/run-pass/coherence/coherence-blanket.rs b/src/test/run-pass/coherence/coherence-blanket.rs index 55fa89d75070a..5d310cc2c6ac5 100644 --- a/src/test/run-pass/coherence/coherence-blanket.rs +++ b/src/test/run-pass/coherence/coherence-blanket.rs @@ -1,6 +1,9 @@ // run-pass #![allow(unused_imports)] // aux-build:coherence_lib.rs +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] // pretty-expanded FIXME #23616 diff --git a/src/test/run-pass/coherence/coherence-covered-type-parameter.rs b/src/test/run-pass/coherence/coherence-covered-type-parameter.rs index bb95c59d183f9..1cf039f0831f5 100644 --- a/src/test/run-pass/coherence/coherence-covered-type-parameter.rs +++ b/src/test/run-pass/coherence/coherence-covered-type-parameter.rs @@ -1,6 +1,9 @@ // run-pass #![allow(dead_code)] // aux-build:coherence_lib.rs +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] // pretty-expanded FIXME #23616 diff --git a/src/test/run-pass/coherence/coherence-impl-in-fn.rs b/src/test/run-pass/coherence/coherence-impl-in-fn.rs index b97197317488c..09e2c1e5a4edd 100644 --- a/src/test/run-pass/coherence/coherence-impl-in-fn.rs +++ b/src/test/run-pass/coherence/coherence-impl-in-fn.rs @@ -1,4 +1,7 @@ // run-pass +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] #![allow(dead_code)] #![allow(non_camel_case_types)] diff --git a/src/test/run-pass/coherence/coherence-iterator-vec-any-elem.rs b/src/test/run-pass/coherence/coherence-iterator-vec-any-elem.rs index 43a0a5c427774..051cc280b2d12 100644 --- a/src/test/run-pass/coherence/coherence-iterator-vec-any-elem.rs +++ b/src/test/run-pass/coherence/coherence-iterator-vec-any-elem.rs @@ -1,4 +1,7 @@ // run-pass +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] #![allow(dead_code)] // aux-build:coherence_lib.rs diff --git a/src/test/run-pass/coherence/coherence-iterator-vec.rs b/src/test/run-pass/coherence/coherence-iterator-vec.rs index 386fe40ac3ca8..df6e808f7dec5 100644 --- a/src/test/run-pass/coherence/coherence-iterator-vec.rs +++ b/src/test/run-pass/coherence/coherence-iterator-vec.rs @@ -1,4 +1,7 @@ // run-pass +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] #![allow(dead_code)] // aux-build:coherence_lib.rs diff --git a/src/test/run-pass/coherence/coherence-multidispatch-tuple.rs b/src/test/run-pass/coherence/coherence-multidispatch-tuple.rs index fa1d4bbb49665..6a816664c4832 100644 --- a/src/test/run-pass/coherence/coherence-multidispatch-tuple.rs +++ b/src/test/run-pass/coherence/coherence-multidispatch-tuple.rs @@ -1,4 +1,7 @@ // run-pass +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] #![allow(unused_imports)] // pretty-expanded FIXME #23616 diff --git a/src/test/run-pass/coherence/coherence-negative-impls-safe.rs b/src/test/run-pass/coherence/coherence-negative-impls-safe.rs index 695a71cbd2d7c..98b04489ac4de 100644 --- a/src/test/run-pass/coherence/coherence-negative-impls-safe.rs +++ b/src/test/run-pass/coherence/coherence-negative-impls-safe.rs @@ -1,4 +1,7 @@ // run-pass +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] #![allow(dead_code)] // pretty-expanded FIXME #23616 diff --git a/src/test/run-pass/coherence/coherence-rfc447-constrained.rs b/src/test/run-pass/coherence/coherence-rfc447-constrained.rs index 9d1d86883259f..4da54d386fd35 100644 --- a/src/test/run-pass/coherence/coherence-rfc447-constrained.rs +++ b/src/test/run-pass/coherence/coherence-rfc447-constrained.rs @@ -1,4 +1,7 @@ // run-pass +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] // check that trait matching can handle impls whose types are only // constrained by a projection. diff --git a/src/test/run-pass/coherence/coherence-subtyping.rs b/src/test/run-pass/coherence/coherence-subtyping.rs index b7aa57b5c31f7..1baecad71752c 100644 --- a/src/test/run-pass/coherence/coherence-subtyping.rs +++ b/src/test/run-pass/coherence/coherence-subtyping.rs @@ -1,4 +1,7 @@ // run-pass +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] // Test that two distinct impls which match subtypes of one another // yield coherence errors (or not) depending on the variance. diff --git a/src/test/run-pass/coherence/coherence-where-clause.rs b/src/test/run-pass/coherence/coherence-where-clause.rs index 9f8a1b9bd1671..283974203858d 100644 --- a/src/test/run-pass/coherence/coherence-where-clause.rs +++ b/src/test/run-pass/coherence/coherence-where-clause.rs @@ -1,4 +1,8 @@ // run-pass +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] + use std::fmt::Debug; use std::default::Default; diff --git a/src/test/run-pass/coherence/coherence_copy_like.rs b/src/test/run-pass/coherence/coherence_copy_like.rs index 92af341ccb529..653f76264c110 100644 --- a/src/test/run-pass/coherence/coherence_copy_like.rs +++ b/src/test/run-pass/coherence/coherence_copy_like.rs @@ -1,4 +1,7 @@ // run-pass +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] #![allow(dead_code)] // Test that we are able to introduce a negative constraint that // `MyType: !MyTrait` along with other "fundamental" wrappers. diff --git a/src/test/run-pass/coherence/re-rebalance-coherence.rs b/src/test/run-pass/coherence/re-rebalance-coherence.rs new file mode 100644 index 0000000000000..bacd3b89fad29 --- /dev/null +++ b/src/test/run-pass/coherence/re-rebalance-coherence.rs @@ -0,0 +1,14 @@ +#![allow(dead_code)] +#![feature(re_rebalance_coherence)] + +// run-pass +// aux-build:re_rebalance_coherence_lib.rs + +extern crate re_rebalance_coherence_lib as lib; +use lib::*; + +struct Oracle; +impl Backend for Oracle {} +impl<'a, T:'a, Tab> QueryFragment for BatchInsert<'a, T, Tab> {} + +fn main() {} diff --git a/src/test/run-pass/generator/yield-subtype.rs b/src/test/run-pass/generator/yield-subtype.rs index c00662e6c0121..c38524857b4a2 100644 --- a/src/test/run-pass/generator/yield-subtype.rs +++ b/src/test/run-pass/generator/yield-subtype.rs @@ -3,7 +3,6 @@ #![allow(dead_code)] // revisions:lexical nll -//[nll]compile-flags: -Z disable-nll-user-type-assert #![cfg_attr(nll, feature(nll))] #![feature(generators)] diff --git a/src/test/run-pass/issue-18952.rs b/src/test/run-pass/issue-18952.rs new file mode 100644 index 0000000000000..56378b59e3642 --- /dev/null +++ b/src/test/run-pass/issue-18952.rs @@ -0,0 +1,56 @@ +// This issue tests fn_traits overloading on arity. +// run-pass + +#![feature(fn_traits)] +#![feature(unboxed_closures)] + +struct Foo; + +impl Fn<(isize, isize)> for Foo { + extern "rust-call" fn call(&self, args: (isize, isize)) -> Self::Output { + println!("{:?}", args); + (args.0 + 1, args.1 + 1) + } +} + +impl FnMut<(isize, isize)> for Foo { + extern "rust-call" fn call_mut(&mut self, args: (isize, isize)) -> Self::Output { + println!("{:?}", args); + (args.0 + 1, args.1 + 1) + } +} + +impl FnOnce<(isize, isize)> for Foo { + type Output = (isize, isize); + extern "rust-call" fn call_once(self, args: (isize, isize)) -> Self::Output { + println!("{:?}", args); + (args.0 + 1, args.1 + 1) + } +} + +impl Fn<(isize, isize, isize)> for Foo { + extern "rust-call" fn call(&self, args: (isize, isize, isize)) -> Self::Output { + println!("{:?}", args); + (args.0 + 3, args.1 + 3, args.2 + 3) + } +} + +impl FnMut<(isize, isize, isize)> for Foo { + extern "rust-call" fn call_mut(&mut self, args: (isize, isize, isize)) -> Self::Output { + println!("{:?}", args); + (args.0 + 3, args.1 + 3, args.2 + 3) + } +} +impl FnOnce<(isize, isize, isize)> for Foo { + type Output = (isize, isize, isize); + extern "rust-call" fn call_once(self, args: (isize, isize, isize)) -> Self::Output { + println!("{:?}", args); + (args.0 + 3, args.1 + 3, args.2 + 3) + } +} + +fn main() { + let foo = Foo; + assert_eq!(foo(1, 1), (2, 2)); + assert_eq!(foo(1, 1, 1), (4, 4, 4)); +} diff --git a/src/test/run-pass/issue-45510.rs b/src/test/run-pass/issue-45510.rs new file mode 100644 index 0000000000000..9e104ce6c4f30 --- /dev/null +++ b/src/test/run-pass/issue-45510.rs @@ -0,0 +1,32 @@ +// Test overloaded resolution of fn_traits. +// run-pass + +#![feature(fn_traits)] +#![feature(unboxed_closures)] + +#[derive(Debug, PartialEq, Eq)] +struct Ishmael; +#[derive(Debug, PartialEq, Eq)] +struct Maybe; +struct CallMe; + +impl FnOnce<(Ishmael,)> for CallMe { + type Output = Ishmael; + extern "rust-call" fn call_once(self, _args: (Ishmael,)) -> Ishmael { + println!("Split your lungs with blood and thunder!"); + Ishmael + } +} + +impl FnOnce<(Maybe,)> for CallMe { + type Output = Maybe; + extern "rust-call" fn call_once(self, _args: (Maybe,)) -> Maybe { + println!("So we just met, and this is crazy"); + Maybe + } +} + +fn main() { + assert_eq!(CallMe(Ishmael), Ishmael); + assert_eq!(CallMe(Maybe), Maybe); +} diff --git a/src/test/run-pass/panic-uninitialized-zeroed.rs b/src/test/run-pass/panic-uninitialized-zeroed.rs index c806bb97c1519..d47ff6c630d11 100644 --- a/src/test/run-pass/panic-uninitialized-zeroed.rs +++ b/src/test/run-pass/panic-uninitialized-zeroed.rs @@ -2,7 +2,7 @@ // This test checks that instantiating an uninhabited type via `mem::{uninitialized,zeroed}` results // in a runtime panic. -#![feature(never_type)] +#![feature(never_type, maybe_uninit)] use std::{mem, panic}; @@ -20,7 +20,7 @@ fn main() { panic::catch_unwind(|| { mem::uninitialized::() }).err().and_then(|a| a.downcast_ref::().map(|s| { - s == "Attempted to instantiate uninhabited type ! using mem::uninitialized" + s == "Attempted to instantiate uninhabited type !" })), Some(true) ); @@ -29,7 +29,16 @@ fn main() { panic::catch_unwind(|| { mem::zeroed::() }).err().and_then(|a| a.downcast_ref::().map(|s| { - s == "Attempted to instantiate uninhabited type ! using mem::zeroed" + s == "Attempted to instantiate uninhabited type !" + })), + Some(true) + ); + + assert_eq!( + panic::catch_unwind(|| { + mem::MaybeUninit::::uninitialized().into_inner() + }).err().and_then(|a| a.downcast_ref::().map(|s| { + s == "Attempted to instantiate uninhabited type !" })), Some(true) ); @@ -38,7 +47,7 @@ fn main() { panic::catch_unwind(|| { mem::uninitialized::() }).err().and_then(|a| a.downcast_ref::().map(|s| { - s == "Attempted to instantiate uninhabited type Foo using mem::uninitialized" + s == "Attempted to instantiate uninhabited type Foo" })), Some(true) ); @@ -47,7 +56,16 @@ fn main() { panic::catch_unwind(|| { mem::zeroed::() }).err().and_then(|a| a.downcast_ref::().map(|s| { - s == "Attempted to instantiate uninhabited type Foo using mem::zeroed" + s == "Attempted to instantiate uninhabited type Foo" + })), + Some(true) + ); + + assert_eq!( + panic::catch_unwind(|| { + mem::MaybeUninit::::uninitialized().into_inner() + }).err().and_then(|a| a.downcast_ref::().map(|s| { + s == "Attempted to instantiate uninhabited type Foo" })), Some(true) ); @@ -56,7 +74,7 @@ fn main() { panic::catch_unwind(|| { mem::uninitialized::() }).err().and_then(|a| a.downcast_ref::().map(|s| { - s == "Attempted to instantiate uninhabited type Bar using mem::uninitialized" + s == "Attempted to instantiate uninhabited type Bar" })), Some(true) ); @@ -65,7 +83,16 @@ fn main() { panic::catch_unwind(|| { mem::zeroed::() }).err().and_then(|a| a.downcast_ref::().map(|s| { - s == "Attempted to instantiate uninhabited type Bar using mem::zeroed" + s == "Attempted to instantiate uninhabited type Bar" + })), + Some(true) + ); + + assert_eq!( + panic::catch_unwind(|| { + mem::MaybeUninit::::uninitialized().into_inner() + }).err().and_then(|a| a.downcast_ref::().map(|s| { + s == "Attempted to instantiate uninhabited type Bar" })), Some(true) ); diff --git a/src/test/rustdoc-ui/failed-doctest-output.stdout b/src/test/rustdoc-ui/failed-doctest-output.stdout index 54830dceb8f17..9fd46e94f030a 100644 --- a/src/test/rustdoc-ui/failed-doctest-output.stdout +++ b/src/test/rustdoc-ui/failed-doctest-output.stdout @@ -12,7 +12,7 @@ error[E0425]: cannot find value `no` in this scope 3 | no | ^^ not found in this scope -thread '$DIR/failed-doctest-output.rs - OtherStruct (line 17)' panicked at 'couldn't compile the test', src/librustdoc/test.rs:316:13 +thread '$DIR/failed-doctest-output.rs - OtherStruct (line 17)' panicked at 'couldn't compile the test', src/librustdoc/test.rs:321:13 note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace. ---- $DIR/failed-doctest-output.rs - SomeStruct (line 11) stdout ---- @@ -21,7 +21,7 @@ thread '$DIR/failed-doctest-output.rs - SomeStruct (line 11)' panicked at 'test thread 'main' panicked at 'oh no', $DIR/failed-doctest-output.rs:3:1 note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace. -', src/librustdoc/test.rs:351:17 +', src/librustdoc/test.rs:356:17 failures: diff --git a/src/test/ui/asm/asm-parse-errors.rs b/src/test/ui/asm/asm-parse-errors.rs new file mode 100644 index 0000000000000..e712ac5826e2c --- /dev/null +++ b/src/test/ui/asm/asm-parse-errors.rs @@ -0,0 +1,15 @@ +#![feature(asm)] + +fn main() { + asm!(); //~ ERROR requires a string literal as an argument + asm!("nop" : struct); //~ ERROR expected string literal + asm!("mov %eax, $$0x2" : struct); //~ ERROR expected string literal + asm!("mov %eax, $$0x2" : "={eax}" struct); //~ ERROR expected `(` + asm!("mov %eax, $$0x2" : "={eax}"(struct)); //~ ERROR expected expression + asm!("in %dx, %al" : "={al}"(result) : struct); //~ ERROR expected string literal + asm!("in %dx, %al" : "={al}"(result) : "{dx}" struct); //~ ERROR expected `(` + asm!("in %dx, %al" : "={al}"(result) : "{dx}"(struct)); //~ ERROR expected expression + asm!("mov $$0x200, %eax" : : : struct); //~ ERROR expected string literal + asm!("mov eax, 2" : "={eax}"(foo) : : : struct); //~ ERROR expected string literal + asm!(123); //~ ERROR inline assembly must be a string literal +} diff --git a/src/test/ui/asm/asm-parse-errors.stderr b/src/test/ui/asm/asm-parse-errors.stderr new file mode 100644 index 0000000000000..37b61b80b2b89 --- /dev/null +++ b/src/test/ui/asm/asm-parse-errors.stderr @@ -0,0 +1,68 @@ +error: macro requires a string literal as an argument + --> $DIR/asm-parse-errors.rs:4:5 + | +LL | asm!(); //~ ERROR requires a string literal as an argument + | ^^^^^^^ string literal required + +error: expected string literal + --> $DIR/asm-parse-errors.rs:5:18 + | +LL | asm!("nop" : struct); //~ ERROR expected string literal + | ^^^^^^ expected string literal + +error: expected string literal + --> $DIR/asm-parse-errors.rs:6:30 + | +LL | asm!("mov %eax, $$0x2" : struct); //~ ERROR expected string literal + | ^^^^^^ expected string literal + +error: expected `(`, found keyword `struct` + --> $DIR/asm-parse-errors.rs:7:39 + | +LL | asm!("mov %eax, $$0x2" : "={eax}" struct); //~ ERROR expected `(` + | ^^^^^^ expected `(` + +error: expected expression, found keyword `struct` + --> $DIR/asm-parse-errors.rs:8:39 + | +LL | asm!("mov %eax, $$0x2" : "={eax}"(struct)); //~ ERROR expected expression + | ^^^^^^ expected expression + +error: expected string literal + --> $DIR/asm-parse-errors.rs:9:44 + | +LL | asm!("in %dx, %al" : "={al}"(result) : struct); //~ ERROR expected string literal + | ^^^^^^ expected string literal + +error: expected `(`, found keyword `struct` + --> $DIR/asm-parse-errors.rs:10:51 + | +LL | asm!("in %dx, %al" : "={al}"(result) : "{dx}" struct); //~ ERROR expected `(` + | ^^^^^^ expected `(` + +error: expected expression, found keyword `struct` + --> $DIR/asm-parse-errors.rs:11:51 + | +LL | asm!("in %dx, %al" : "={al}"(result) : "{dx}"(struct)); //~ ERROR expected expression + | ^^^^^^ expected expression + +error: expected string literal + --> $DIR/asm-parse-errors.rs:12:36 + | +LL | asm!("mov $$0x200, %eax" : : : struct); //~ ERROR expected string literal + | ^^^^^^ expected string literal + +error: expected string literal + --> $DIR/asm-parse-errors.rs:13:45 + | +LL | asm!("mov eax, 2" : "={eax}"(foo) : : : struct); //~ ERROR expected string literal + | ^^^^^^ expected string literal + +error: inline assembly must be a string literal + --> $DIR/asm-parse-errors.rs:14:10 + | +LL | asm!(123); //~ ERROR inline assembly must be a string literal + | ^^^ + +error: aborting due to 11 previous errors + diff --git a/src/test/ui/associated-types/associated-types-unsized.stderr b/src/test/ui/associated-types/associated-types-unsized.stderr index bc85620d1a404..c83b14374f712 100644 --- a/src/test/ui/associated-types/associated-types-unsized.stderr +++ b/src/test/ui/associated-types/associated-types-unsized.stderr @@ -5,7 +5,7 @@ LL | let x = t.get(); //~ ERROR the size for values of type | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `::Value` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where ::Value: std::marker::Sized` bound = note: all local variables must have a statically known size = help: unsized locals are gated as an unstable feature diff --git a/src/test/ui/bad/bad-sized.stderr b/src/test/ui/bad/bad-sized.stderr index 57a204659f145..9565888dcc022 100644 --- a/src/test/ui/bad/bad-sized.stderr +++ b/src/test/ui/bad/bad-sized.stderr @@ -11,7 +11,7 @@ LL | let x: Vec = Vec::new(); | ^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `dyn Trait` - = note: to learn more, visit + = note: to learn more, visit = note: required by `std::vec::Vec` error[E0277]: the size for values of type `dyn Trait` cannot be known at compilation time @@ -21,7 +21,7 @@ LL | let x: Vec = Vec::new(); | ^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `dyn Trait` - = note: to learn more, visit + = note: to learn more, visit = note: required by `>::new` error: aborting due to 3 previous errors diff --git a/src/test/ui/coherence/auxiliary/re_rebalance_coherence_lib.rs b/src/test/ui/coherence/auxiliary/re_rebalance_coherence_lib.rs new file mode 100644 index 0000000000000..c8d027b25c748 --- /dev/null +++ b/src/test/ui/coherence/auxiliary/re_rebalance_coherence_lib.rs @@ -0,0 +1,23 @@ + +pub trait Backend{} +pub trait SupportsDefaultKeyword {} + +impl SupportsDefaultKeyword for Postgres {} + +pub struct Postgres; + +impl Backend for Postgres {} + +pub struct AstPass(::std::marker::PhantomData); + +pub trait QueryFragment {} + + +#[derive(Debug, Clone, Copy)] +pub struct BatchInsert<'a, T: 'a, Tab> { + _marker: ::std::marker::PhantomData<(&'a T, Tab)>, +} + +impl<'a, T:'a, Tab, DB> QueryFragment for BatchInsert<'a, T, Tab> +where DB: SupportsDefaultKeyword + Backend, +{} diff --git a/src/test/ui/coherence/coherence-all-remote.stderr b/src/test/ui/coherence/coherence-all-remote.old.stderr similarity index 92% rename from src/test/ui/coherence/coherence-all-remote.stderr rename to src/test/ui/coherence/coherence-all-remote.old.stderr index 3d8afc418ead9..0389a6228efcd 100644 --- a/src/test/ui/coherence/coherence-all-remote.stderr +++ b/src/test/ui/coherence/coherence-all-remote.old.stderr @@ -1,5 +1,5 @@ error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/coherence-all-remote.rs:6:1 + --> $DIR/coherence-all-remote.rs:9:1 | LL | impl Remote1 for isize { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type diff --git a/src/test/ui/coherence/coherence-all-remote.re.stderr b/src/test/ui/coherence/coherence-all-remote.re.stderr new file mode 100644 index 0000000000000..0389a6228efcd --- /dev/null +++ b/src/test/ui/coherence/coherence-all-remote.re.stderr @@ -0,0 +1,11 @@ +error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) + --> $DIR/coherence-all-remote.rs:9:1 + | +LL | impl Remote1 for isize { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | + = note: only traits defined in the current crate can be implemented for a type parameter + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0210`. diff --git a/src/test/ui/coherence/coherence-all-remote.rs b/src/test/ui/coherence/coherence-all-remote.rs index 5c3bfee822f1c..68c924ee27403 100644 --- a/src/test/ui/coherence/coherence-all-remote.rs +++ b/src/test/ui/coherence/coherence-all-remote.rs @@ -1,9 +1,13 @@ // aux-build:coherence_lib.rs +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] extern crate coherence_lib as lib; use lib::Remote1; impl Remote1 for isize { } -//~^ ERROR E0210 +//[old]~^ ERROR E0210 +//[re]~^^ ERROR E0210 fn main() { } diff --git a/src/test/ui/coherence/coherence-bigint-param.stderr b/src/test/ui/coherence/coherence-bigint-param.old.stderr similarity index 91% rename from src/test/ui/coherence/coherence-bigint-param.stderr rename to src/test/ui/coherence/coherence-bigint-param.old.stderr index 81d56349a9e6c..54fec07e65a0d 100644 --- a/src/test/ui/coherence/coherence-bigint-param.stderr +++ b/src/test/ui/coherence/coherence-bigint-param.old.stderr @@ -1,5 +1,5 @@ error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/coherence-bigint-param.rs:8:1 + --> $DIR/coherence-bigint-param.rs:11:1 | LL | impl Remote1 for T { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type diff --git a/src/test/ui/coherence/coherence-bigint-param.re.stderr b/src/test/ui/coherence/coherence-bigint-param.re.stderr new file mode 100644 index 0000000000000..54fec07e65a0d --- /dev/null +++ b/src/test/ui/coherence/coherence-bigint-param.re.stderr @@ -0,0 +1,11 @@ +error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) + --> $DIR/coherence-bigint-param.rs:11:1 + | +LL | impl Remote1 for T { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | + = note: only traits defined in the current crate can be implemented for a type parameter + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0210`. diff --git a/src/test/ui/coherence/coherence-bigint-param.rs b/src/test/ui/coherence/coherence-bigint-param.rs index d199c1c216946..24106b4b348d4 100644 --- a/src/test/ui/coherence/coherence-bigint-param.rs +++ b/src/test/ui/coherence/coherence-bigint-param.rs @@ -1,4 +1,7 @@ // aux-build:coherence_lib.rs +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] extern crate coherence_lib as lib; use lib::Remote1; @@ -6,6 +9,7 @@ use lib::Remote1; pub struct BigInt; impl Remote1 for T { } -//~^ ERROR type parameter `T` must be used as the type parameter for some local type +//[old]~^ ERROR type parameter `T` must be used as the type parameter for some local type +//[re]~^^ ERROR E0210 fn main() { } diff --git a/src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-implemented.stderr b/src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-implemented.old.stderr similarity index 87% rename from src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-implemented.stderr rename to src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-implemented.old.stderr index 9dd08b9e5583a..a6d29048b4d8c 100644 --- a/src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-implemented.stderr +++ b/src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-implemented.old.stderr @@ -1,10 +1,10 @@ error[E0119]: conflicting implementations of trait `MyTrait`: - --> $DIR/coherence-blanket-conflicts-with-blanket-implemented.rs:24:1 + --> $DIR/coherence-blanket-conflicts-with-blanket-implemented.rs:28:1 | LL | impl MyTrait for T { | -------------------------- first implementation here ... -LL | impl MyTrait for T { //~ ERROR E0119 +LL | impl MyTrait for T { | ^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation error: aborting due to previous error diff --git a/src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-implemented.re.stderr b/src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-implemented.re.stderr new file mode 100644 index 0000000000000..a6d29048b4d8c --- /dev/null +++ b/src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-implemented.re.stderr @@ -0,0 +1,12 @@ +error[E0119]: conflicting implementations of trait `MyTrait`: + --> $DIR/coherence-blanket-conflicts-with-blanket-implemented.rs:28:1 + | +LL | impl MyTrait for T { + | -------------------------- first implementation here +... +LL | impl MyTrait for T { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-implemented.rs b/src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-implemented.rs index 46d878859e0e6..098a13e54bfb4 100644 --- a/src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-implemented.rs +++ b/src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-implemented.rs @@ -1,3 +1,7 @@ +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] + use std::fmt::Debug; use std::default::Default; @@ -21,7 +25,10 @@ impl MyTrait for T { fn get(&self) -> usize { 0 } } -impl MyTrait for T { //~ ERROR E0119 +impl MyTrait for T { +//[old]~^ ERROR E0119 +//[re]~^^ ERROR E0119 + fn get(&self) -> usize { 0 } } diff --git a/src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-unimplemented.stderr b/src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-unimplemented.old.stderr similarity index 86% rename from src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-unimplemented.stderr rename to src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-unimplemented.old.stderr index 1719bc60a04de..1f3ddd1dc42c6 100644 --- a/src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-unimplemented.stderr +++ b/src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-unimplemented.old.stderr @@ -1,10 +1,10 @@ error[E0119]: conflicting implementations of trait `MyTrait`: - --> $DIR/coherence-blanket-conflicts-with-blanket-unimplemented.rs:20:1 + --> $DIR/coherence-blanket-conflicts-with-blanket-unimplemented.rs:24:1 | LL | impl MyTrait for T { | -------------------------- first implementation here ... -LL | impl MyTrait for T { //~ ERROR E0119 +LL | impl MyTrait for T { | ^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation error: aborting due to previous error diff --git a/src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-unimplemented.re.stderr b/src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-unimplemented.re.stderr new file mode 100644 index 0000000000000..1f3ddd1dc42c6 --- /dev/null +++ b/src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-unimplemented.re.stderr @@ -0,0 +1,12 @@ +error[E0119]: conflicting implementations of trait `MyTrait`: + --> $DIR/coherence-blanket-conflicts-with-blanket-unimplemented.rs:24:1 + | +LL | impl MyTrait for T { + | -------------------------- first implementation here +... +LL | impl MyTrait for T { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-unimplemented.rs b/src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-unimplemented.rs index 0044760161e5c..5b76fc0174b30 100644 --- a/src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-unimplemented.rs +++ b/src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-unimplemented.rs @@ -1,3 +1,7 @@ +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] + use std::fmt::Debug; use std::default::Default; @@ -17,7 +21,9 @@ impl MyTrait for T { fn get(&self) -> usize { 0 } } -impl MyTrait for T { //~ ERROR E0119 +impl MyTrait for T { +//[old]~^ ERROR E0119 +//[re]~^^ ERROR E0119 fn get(&self) -> usize { 0 } } diff --git a/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-cross-crate.stderr b/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-cross-crate.old.stderr similarity index 84% rename from src/test/ui/coherence/coherence-blanket-conflicts-with-specific-cross-crate.stderr rename to src/test/ui/coherence/coherence-blanket-conflicts-with-specific-cross-crate.old.stderr index 5872f609e90c0..298ac6d1f2169 100644 --- a/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-cross-crate.stderr +++ b/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-cross-crate.old.stderr @@ -1,7 +1,7 @@ error[E0119]: conflicting implementations of trait `go_trait::GoMut` for type `MyThingy`: - --> $DIR/coherence-blanket-conflicts-with-specific-cross-crate.rs:15:1 + --> $DIR/coherence-blanket-conflicts-with-specific-cross-crate.rs:18:1 | -LL | impl GoMut for MyThingy { //~ ERROR conflicting implementations +LL | impl GoMut for MyThingy { | ^^^^^^^^^^^^^^^^^^^^^^^ | = note: conflicting implementation in crate `go_trait`: diff --git a/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-cross-crate.re.stderr b/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-cross-crate.re.stderr new file mode 100644 index 0000000000000..298ac6d1f2169 --- /dev/null +++ b/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-cross-crate.re.stderr @@ -0,0 +1,13 @@ +error[E0119]: conflicting implementations of trait `go_trait::GoMut` for type `MyThingy`: + --> $DIR/coherence-blanket-conflicts-with-specific-cross-crate.rs:18:1 + | +LL | impl GoMut for MyThingy { + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: conflicting implementation in crate `go_trait`: + - impl go_trait::GoMut for G + where G: go_trait::Go; + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-cross-crate.rs b/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-cross-crate.rs index 4c62741d2e4b4..b0aaf57e2a942 100644 --- a/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-cross-crate.rs +++ b/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-cross-crate.rs @@ -1,4 +1,7 @@ // aux-build:go_trait.rs +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] extern crate go_trait; @@ -12,7 +15,9 @@ impl Go for MyThingy { fn go(&self, arg: isize) { } } -impl GoMut for MyThingy { //~ ERROR conflicting implementations +impl GoMut for MyThingy { +//[old]~^ ERROR conflicting implementations +//[re]~^^ ERROR E0119 fn go_mut(&mut self, arg: isize) { } } diff --git a/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-multidispatch.stderr b/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-multidispatch.old.stderr similarity index 86% rename from src/test/ui/coherence/coherence-blanket-conflicts-with-specific-multidispatch.stderr rename to src/test/ui/coherence/coherence-blanket-conflicts-with-specific-multidispatch.old.stderr index 9de354d8cf67f..94bbbdbe0a404 100644 --- a/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-multidispatch.stderr +++ b/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-multidispatch.old.stderr @@ -1,10 +1,10 @@ error[E0119]: conflicting implementations of trait `MyTrait` for type `MyType`: - --> $DIR/coherence-blanket-conflicts-with-specific-multidispatch.rs:22:1 + --> $DIR/coherence-blanket-conflicts-with-specific-multidispatch.rs:26:1 | LL | impl MyTrait for T { | ------------------------ first implementation here ... -LL | impl MyTrait for MyType { //~ ERROR E0119 +LL | impl MyTrait for MyType { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `MyType` error: aborting due to previous error diff --git a/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-multidispatch.re.stderr b/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-multidispatch.re.stderr new file mode 100644 index 0000000000000..94bbbdbe0a404 --- /dev/null +++ b/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-multidispatch.re.stderr @@ -0,0 +1,12 @@ +error[E0119]: conflicting implementations of trait `MyTrait` for type `MyType`: + --> $DIR/coherence-blanket-conflicts-with-specific-multidispatch.rs:26:1 + | +LL | impl MyTrait for T { + | ------------------------ first implementation here +... +LL | impl MyTrait for MyType { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `MyType` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-multidispatch.rs b/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-multidispatch.rs index 42ce638f13705..9192d123514ab 100644 --- a/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-multidispatch.rs +++ b/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-multidispatch.rs @@ -1,3 +1,7 @@ +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] + use std::fmt::Debug; use std::default::Default; @@ -19,7 +23,9 @@ struct MyType { dummy: usize } -impl MyTrait for MyType { //~ ERROR E0119 +impl MyTrait for MyType { +//[old]~^ ERROR E0119 +//[re]~^^ ERROR E0119 fn get(&self) -> usize { (*self).clone() } } diff --git a/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-trait.stderr b/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-trait.old.stderr similarity index 77% rename from src/test/ui/coherence/coherence-blanket-conflicts-with-specific-trait.stderr rename to src/test/ui/coherence/coherence-blanket-conflicts-with-specific-trait.old.stderr index c3f06a952c4b7..cf799c20cb49c 100644 --- a/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-trait.stderr +++ b/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-trait.old.stderr @@ -1,10 +1,10 @@ error[E0119]: conflicting implementations of trait `MyTrait` for type `MyType`: - --> $DIR/coherence-blanket-conflicts-with-specific-trait.rs:20:1 + --> $DIR/coherence-blanket-conflicts-with-specific-trait.rs:24:1 | LL | impl MyTrait for T { | -------------------------------- first implementation here ... -LL | impl MyTrait for MyType { //~ ERROR E0119 +LL | impl MyTrait for MyType { | ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `MyType` error: aborting due to previous error diff --git a/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-trait.re.stderr b/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-trait.re.stderr new file mode 100644 index 0000000000000..cf799c20cb49c --- /dev/null +++ b/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-trait.re.stderr @@ -0,0 +1,12 @@ +error[E0119]: conflicting implementations of trait `MyTrait` for type `MyType`: + --> $DIR/coherence-blanket-conflicts-with-specific-trait.rs:24:1 + | +LL | impl MyTrait for T { + | -------------------------------- first implementation here +... +LL | impl MyTrait for MyType { + | ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `MyType` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-trait.rs b/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-trait.rs index 78da8330ba3c5..51cb10e618556 100644 --- a/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-trait.rs +++ b/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-trait.rs @@ -1,6 +1,10 @@ // Test that a blank impl for all T:PartialEq conflicts with an impl for some // specific T when T:PartialEq. +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] + trait OtherTrait { fn noop(&self); } @@ -17,7 +21,9 @@ struct MyType { dummy: usize } -impl MyTrait for MyType { //~ ERROR E0119 +impl MyTrait for MyType { +//[old]~^ ERROR E0119 +//[re]~^^ ERROR E0119 fn get(&self) -> usize { self.dummy } } diff --git a/src/test/ui/coherence/coherence-blanket-conflicts-with-specific.stderr b/src/test/ui/coherence/coherence-blanket-conflicts-with-specific.old.stderr similarity index 76% rename from src/test/ui/coherence/coherence-blanket-conflicts-with-specific.stderr rename to src/test/ui/coherence/coherence-blanket-conflicts-with-specific.old.stderr index 0b04c5fd0bddf..0807b11a434f9 100644 --- a/src/test/ui/coherence/coherence-blanket-conflicts-with-specific.stderr +++ b/src/test/ui/coherence/coherence-blanket-conflicts-with-specific.old.stderr @@ -1,10 +1,10 @@ error[E0119]: conflicting implementations of trait `MyTrait` for type `MyType`: - --> $DIR/coherence-blanket-conflicts-with-specific.rs:19:1 + --> $DIR/coherence-blanket-conflicts-with-specific.rs:23:1 | LL | impl MyTrait for T { | --------------------- first implementation here ... -LL | impl MyTrait for MyType { //~ ERROR E0119 +LL | impl MyTrait for MyType { | ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `MyType` error: aborting due to previous error diff --git a/src/test/ui/coherence/coherence-blanket-conflicts-with-specific.re.stderr b/src/test/ui/coherence/coherence-blanket-conflicts-with-specific.re.stderr new file mode 100644 index 0000000000000..0807b11a434f9 --- /dev/null +++ b/src/test/ui/coherence/coherence-blanket-conflicts-with-specific.re.stderr @@ -0,0 +1,12 @@ +error[E0119]: conflicting implementations of trait `MyTrait` for type `MyType`: + --> $DIR/coherence-blanket-conflicts-with-specific.rs:23:1 + | +LL | impl MyTrait for T { + | --------------------- first implementation here +... +LL | impl MyTrait for MyType { + | ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `MyType` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/coherence/coherence-blanket-conflicts-with-specific.rs b/src/test/ui/coherence/coherence-blanket-conflicts-with-specific.rs index db5f83c865a6f..3ecb613188ae4 100644 --- a/src/test/ui/coherence/coherence-blanket-conflicts-with-specific.rs +++ b/src/test/ui/coherence/coherence-blanket-conflicts-with-specific.rs @@ -1,3 +1,7 @@ +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] + use std::fmt::Debug; use std::default::Default; @@ -16,7 +20,9 @@ struct MyType { dummy: usize } -impl MyTrait for MyType { //~ ERROR E0119 +impl MyTrait for MyType { +//[old]~^ ERROR E0119 +//[re]~^^ ERROR E0119 fn get(&self) -> usize { self.dummy } } diff --git a/src/test/ui/coherence/coherence-conflicting-negative-trait-impl.stderr b/src/test/ui/coherence/coherence-conflicting-negative-trait-impl.old.stderr similarity index 87% rename from src/test/ui/coherence/coherence-conflicting-negative-trait-impl.stderr rename to src/test/ui/coherence/coherence-conflicting-negative-trait-impl.old.stderr index 0a8bbc4bc50a8..bb3641f224780 100644 --- a/src/test/ui/coherence/coherence-conflicting-negative-trait-impl.stderr +++ b/src/test/ui/coherence/coherence-conflicting-negative-trait-impl.old.stderr @@ -1,5 +1,5 @@ error[E0119]: conflicting implementations of trait `std::marker::Send` for type `TestType<_>`: - --> $DIR/coherence-conflicting-negative-trait-impl.rs:10:1 + --> $DIR/coherence-conflicting-negative-trait-impl.rs:13:1 | LL | unsafe impl Send for TestType {} | ---------------------------------------------------- first implementation here @@ -8,7 +8,7 @@ LL | impl !Send for TestType {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `TestType<_>` error[E0119]: conflicting implementations of trait `std::marker::Send` for type `TestType`: - --> $DIR/coherence-conflicting-negative-trait-impl.rs:15:1 + --> $DIR/coherence-conflicting-negative-trait-impl.rs:19:1 | LL | unsafe impl Send for TestType {} | ------------------------------------------- first implementation here diff --git a/src/test/ui/coherence/coherence-conflicting-negative-trait-impl.re.stderr b/src/test/ui/coherence/coherence-conflicting-negative-trait-impl.re.stderr new file mode 100644 index 0000000000000..bb3641f224780 --- /dev/null +++ b/src/test/ui/coherence/coherence-conflicting-negative-trait-impl.re.stderr @@ -0,0 +1,21 @@ +error[E0119]: conflicting implementations of trait `std::marker::Send` for type `TestType<_>`: + --> $DIR/coherence-conflicting-negative-trait-impl.rs:13:1 + | +LL | unsafe impl Send for TestType {} + | ---------------------------------------------------- first implementation here +LL | +LL | impl !Send for TestType {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `TestType<_>` + +error[E0119]: conflicting implementations of trait `std::marker::Send` for type `TestType`: + --> $DIR/coherence-conflicting-negative-trait-impl.rs:19:1 + | +LL | unsafe impl Send for TestType {} + | ------------------------------------------- first implementation here +LL | +LL | impl !Send for TestType {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `TestType` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/coherence/coherence-conflicting-negative-trait-impl.rs b/src/test/ui/coherence/coherence-conflicting-negative-trait-impl.rs index 2165fdee5e08c..e05fecb11ed4b 100644 --- a/src/test/ui/coherence/coherence-conflicting-negative-trait-impl.rs +++ b/src/test/ui/coherence/coherence-conflicting-negative-trait-impl.rs @@ -1,3 +1,6 @@ +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] #![feature(optin_builtin_traits)] #![feature(overlapping_marker_traits)] @@ -8,11 +11,13 @@ struct TestType(::std::marker::PhantomData); unsafe impl Send for TestType {} impl !Send for TestType {} -//~^ ERROR conflicting implementations of trait `std::marker::Send` +//[old]~^ ERROR conflicting implementations of trait `std::marker::Send` +//[re]~^^ ERROR E0119 unsafe impl Send for TestType {} impl !Send for TestType {} -//~^ ERROR conflicting implementations of trait `std::marker::Send` +//[old]~^ ERROR conflicting implementations of trait `std::marker::Send` +//[re]~^^ ERROR E0119 fn main() {} diff --git a/src/test/ui/coherence/coherence-cow.a.stderr b/src/test/ui/coherence/coherence-cow.a.stderr index 6692e1ce17441..dd9cfab503f72 100644 --- a/src/test/ui/coherence/coherence-cow.a.stderr +++ b/src/test/ui/coherence/coherence-cow.a.stderr @@ -1,7 +1,7 @@ error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/coherence-cow.rs:16:1 + --> $DIR/coherence-cow.rs:18:1 | -LL | impl Remote for Pair> { } //[a]~ ERROR E0210 +LL | impl Remote for Pair> { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type | = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/src/test/ui/coherence/coherence-cow.b.stderr b/src/test/ui/coherence/coherence-cow.b.stderr index a148b6898fdc4..fb3ca3fc6b777 100644 --- a/src/test/ui/coherence/coherence-cow.b.stderr +++ b/src/test/ui/coherence/coherence-cow.b.stderr @@ -1,7 +1,7 @@ error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/coherence-cow.rs:19:1 + --> $DIR/coherence-cow.rs:23:1 | -LL | impl Remote for Pair,T> { } //[b]~ ERROR E0210 +LL | impl Remote for Pair,T> { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type | = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/src/test/ui/coherence/coherence-cow.c.stderr b/src/test/ui/coherence/coherence-cow.c.stderr index b575dd64e87a5..f17823b7f8954 100644 --- a/src/test/ui/coherence/coherence-cow.c.stderr +++ b/src/test/ui/coherence/coherence-cow.c.stderr @@ -1,5 +1,5 @@ error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/coherence-cow.rs:22:1 + --> $DIR/coherence-cow.rs:28:1 | LL | impl Remote for Pair,U> { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type diff --git a/src/test/ui/coherence/coherence-cow.re_a.stderr b/src/test/ui/coherence/coherence-cow.re_a.stderr new file mode 100644 index 0000000000000..ed627600b0f5d --- /dev/null +++ b/src/test/ui/coherence/coherence-cow.re_a.stderr @@ -0,0 +1,12 @@ +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-cow.rs:18:1 + | +LL | impl Remote for Pair> { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/coherence/coherence-cow.re_b.stderr b/src/test/ui/coherence/coherence-cow.re_b.stderr new file mode 100644 index 0000000000000..1a85887ae7bc4 --- /dev/null +++ b/src/test/ui/coherence/coherence-cow.re_b.stderr @@ -0,0 +1,12 @@ +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-cow.rs:23:1 + | +LL | impl Remote for Pair,T> { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/coherence/coherence-cow.re_c.stderr b/src/test/ui/coherence/coherence-cow.re_c.stderr new file mode 100644 index 0000000000000..8043b6702b07e --- /dev/null +++ b/src/test/ui/coherence/coherence-cow.re_c.stderr @@ -0,0 +1,12 @@ +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-cow.rs:28:1 + | +LL | impl Remote for Pair,U> { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/coherence/coherence-cow.rs b/src/test/ui/coherence/coherence-cow.rs index d72adf7a5319f..956b073414861 100644 --- a/src/test/ui/coherence/coherence-cow.rs +++ b/src/test/ui/coherence/coherence-cow.rs @@ -1,4 +1,6 @@ -// revisions: a b c +// revisions: a b c re_a re_b re_c + +#![cfg_attr(any(re_a, re_b, re_c), feature(re_rebalance_coherence))] // aux-build:coherence_lib.rs @@ -12,14 +14,19 @@ use lib::{Remote,Pair}; pub struct Cover(T); -#[cfg(a)] -impl Remote for Pair> { } //[a]~ ERROR E0210 +#[cfg(any(a, re_a))] +impl Remote for Pair> { } +//[a]~^ ERROR E0210 +//[re_a]~^^ ERROR E0117 -#[cfg(b)] -impl Remote for Pair,T> { } //[b]~ ERROR E0210 +#[cfg(any(b, re_b))] +impl Remote for Pair,T> { } +//[b]~^ ERROR E0210 +//[re_b]~^^ ERROR E0117 -#[cfg(c)] +#[cfg(any(c, re_c))] impl Remote for Pair,U> { } //[c]~^ ERROR type parameter `T` must be used as the type parameter for some local type +//[re_c]~^^ ERROR E0117 fn main() { } diff --git a/src/test/ui/coherence/coherence-cross-crate-conflict.stderr b/src/test/ui/coherence/coherence-cross-crate-conflict.old.stderr similarity index 88% rename from src/test/ui/coherence/coherence-cross-crate-conflict.stderr rename to src/test/ui/coherence/coherence-cross-crate-conflict.old.stderr index 4a73aa357d076..3ba32a528354e 100644 --- a/src/test/ui/coherence/coherence-cross-crate-conflict.stderr +++ b/src/test/ui/coherence/coherence-cross-crate-conflict.old.stderr @@ -1,5 +1,5 @@ error[E0119]: conflicting implementations of trait `trait_impl_conflict::Foo` for type `isize`: - --> $DIR/coherence-cross-crate-conflict.rs:8:1 + --> $DIR/coherence-cross-crate-conflict.rs:12:1 | LL | impl Foo for A { | ^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | impl Foo for A { - impl trait_impl_conflict::Foo for isize; error[E0210]: type parameter `A` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/coherence-cross-crate-conflict.rs:8:1 + --> $DIR/coherence-cross-crate-conflict.rs:12:1 | LL | impl Foo for A { | ^^^^^^^^^^^^^^^^^ type parameter `A` must be used as the type parameter for some local type diff --git a/src/test/ui/coherence/coherence-cross-crate-conflict.re.stderr b/src/test/ui/coherence/coherence-cross-crate-conflict.re.stderr new file mode 100644 index 0000000000000..3ba32a528354e --- /dev/null +++ b/src/test/ui/coherence/coherence-cross-crate-conflict.re.stderr @@ -0,0 +1,21 @@ +error[E0119]: conflicting implementations of trait `trait_impl_conflict::Foo` for type `isize`: + --> $DIR/coherence-cross-crate-conflict.rs:12:1 + | +LL | impl Foo for A { + | ^^^^^^^^^^^^^^^^^ + | + = note: conflicting implementation in crate `trait_impl_conflict`: + - impl trait_impl_conflict::Foo for isize; + +error[E0210]: type parameter `A` must be used as the type parameter for some local type (e.g., `MyStruct`) + --> $DIR/coherence-cross-crate-conflict.rs:12:1 + | +LL | impl Foo for A { + | ^^^^^^^^^^^^^^^^^ type parameter `A` must be used as the type parameter for some local type + | + = note: only traits defined in the current crate can be implemented for a type parameter + +error: aborting due to 2 previous errors + +Some errors occurred: E0119, E0210. +For more information about an error, try `rustc --explain E0119`. diff --git a/src/test/ui/coherence/coherence-cross-crate-conflict.rs b/src/test/ui/coherence/coherence-cross-crate-conflict.rs index 07dd585e8c48b..9643ab643dfe5 100644 --- a/src/test/ui/coherence/coherence-cross-crate-conflict.rs +++ b/src/test/ui/coherence/coherence-cross-crate-conflict.rs @@ -2,12 +2,18 @@ // generalizes the one upstream // aux-build:trait_impl_conflict.rs +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] + extern crate trait_impl_conflict; use trait_impl_conflict::Foo; impl Foo for A { - //~^ ERROR type parameter `A` must be used as the type parameter for some local type - //~| ERROR conflicting implementations of trait `trait_impl_conflict::Foo` for type `isize` + //[old]~^ ERROR type parameter `A` must be used as the type parameter for some local type + //[old]~| ERROR conflicting implementations of trait `trait_impl_conflict::Foo` for type `isize` + //[re]~^^^ ERROR E0119 + //[re]~| ERROR E0210 } fn main() { diff --git a/src/test/ui/coherence/coherence-default-trait-impl.stderr b/src/test/ui/coherence/coherence-default-trait-impl.old.stderr similarity index 82% rename from src/test/ui/coherence/coherence-default-trait-impl.stderr rename to src/test/ui/coherence/coherence-default-trait-impl.old.stderr index 6309d60dd9675..534f4b0dcdb3c 100644 --- a/src/test/ui/coherence/coherence-default-trait-impl.stderr +++ b/src/test/ui/coherence/coherence-default-trait-impl.old.stderr @@ -1,11 +1,11 @@ error[E0199]: implementing the trait `MySafeTrait` is not unsafe - --> $DIR/coherence-default-trait-impl.rs:7:1 + --> $DIR/coherence-default-trait-impl.rs:10:1 | LL | unsafe impl MySafeTrait for Foo {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0200]: the trait `MyUnsafeTrait` requires an `unsafe impl` declaration - --> $DIR/coherence-default-trait-impl.rs:12:1 + --> $DIR/coherence-default-trait-impl.rs:16:1 | LL | impl MyUnsafeTrait for Foo {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/coherence/coherence-default-trait-impl.re.stderr b/src/test/ui/coherence/coherence-default-trait-impl.re.stderr new file mode 100644 index 0000000000000..534f4b0dcdb3c --- /dev/null +++ b/src/test/ui/coherence/coherence-default-trait-impl.re.stderr @@ -0,0 +1,16 @@ +error[E0199]: implementing the trait `MySafeTrait` is not unsafe + --> $DIR/coherence-default-trait-impl.rs:10:1 + | +LL | unsafe impl MySafeTrait for Foo {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0200]: the trait `MyUnsafeTrait` requires an `unsafe impl` declaration + --> $DIR/coherence-default-trait-impl.rs:16:1 + | +LL | impl MyUnsafeTrait for Foo {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +Some errors occurred: E0199, E0200. +For more information about an error, try `rustc --explain E0199`. diff --git a/src/test/ui/coherence/coherence-default-trait-impl.rs b/src/test/ui/coherence/coherence-default-trait-impl.rs index df267ca7bd93d..606b4947b5f09 100644 --- a/src/test/ui/coherence/coherence-default-trait-impl.rs +++ b/src/test/ui/coherence/coherence-default-trait-impl.rs @@ -1,3 +1,6 @@ +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] #![feature(optin_builtin_traits)] auto trait MySafeTrait {} @@ -5,11 +8,13 @@ auto trait MySafeTrait {} struct Foo; unsafe impl MySafeTrait for Foo {} -//~^ ERROR implementing the trait `MySafeTrait` is not unsafe +//[old]~^ ERROR implementing the trait `MySafeTrait` is not unsafe +//[re]~^^ ERROR E0199 unsafe auto trait MyUnsafeTrait {} impl MyUnsafeTrait for Foo {} -//~^ ERROR the trait `MyUnsafeTrait` requires an `unsafe impl` declaration +//[old]~^ ERROR the trait `MyUnsafeTrait` requires an `unsafe impl` declaration +//[re]~^^ ERROR E0200 fn main() {} diff --git a/src/test/ui/coherence/coherence-error-suppression.stderr b/src/test/ui/coherence/coherence-error-suppression.old.stderr similarity index 62% rename from src/test/ui/coherence/coherence-error-suppression.stderr rename to src/test/ui/coherence/coherence-error-suppression.old.stderr index 17a3c62772005..b81f75533176f 100644 --- a/src/test/ui/coherence/coherence-error-suppression.stderr +++ b/src/test/ui/coherence/coherence-error-suppression.old.stderr @@ -1,7 +1,7 @@ error[E0412]: cannot find type `DoesNotExist` in this scope - --> $DIR/coherence-error-suppression.rs:9:14 + --> $DIR/coherence-error-suppression.rs:13:14 | -LL | impl Foo for DoesNotExist {} //~ ERROR cannot find type `DoesNotExist` in this scope +LL | impl Foo for DoesNotExist {} | ^^^^^^^^^^^^ not found in this scope error: aborting due to previous error diff --git a/src/test/ui/coherence/coherence-error-suppression.re.stderr b/src/test/ui/coherence/coherence-error-suppression.re.stderr new file mode 100644 index 0000000000000..b81f75533176f --- /dev/null +++ b/src/test/ui/coherence/coherence-error-suppression.re.stderr @@ -0,0 +1,9 @@ +error[E0412]: cannot find type `DoesNotExist` in this scope + --> $DIR/coherence-error-suppression.rs:13:14 + | +LL | impl Foo for DoesNotExist {} + | ^^^^^^^^^^^^ not found in this scope + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0412`. diff --git a/src/test/ui/coherence/coherence-error-suppression.rs b/src/test/ui/coherence/coherence-error-suppression.rs index f48652e3499a0..60b88fb80e44f 100644 --- a/src/test/ui/coherence/coherence-error-suppression.rs +++ b/src/test/ui/coherence/coherence-error-suppression.rs @@ -1,12 +1,18 @@ // check that error types in coherence do not cause error cascades. +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] + trait Foo {} impl Foo for i8 {} impl Foo for i16 {} impl Foo for i32 {} impl Foo for i64 {} -impl Foo for DoesNotExist {} //~ ERROR cannot find type `DoesNotExist` in this scope +impl Foo for DoesNotExist {} +//[old]~^ ERROR cannot find type `DoesNotExist` in this scope +//[re]~^^ ERROR E0412 impl Foo for u8 {} impl Foo for u16 {} impl Foo for u32 {} diff --git a/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.stderr b/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.old.stderr similarity index 73% rename from src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.stderr rename to src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.old.stderr index a19b00194c341..b48f6bbfb9417 100644 --- a/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.stderr +++ b/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.old.stderr @@ -1,7 +1,7 @@ error[E0038]: the trait `NotObjectSafe` cannot be made into an object - --> $DIR/coherence-impl-trait-for-trait-object-safe.rs:7:6 + --> $DIR/coherence-impl-trait-for-trait-object-safe.rs:11:6 | -LL | impl NotObjectSafe for NotObjectSafe { } //~ ERROR E0038 +LL | impl NotObjectSafe for NotObjectSafe { } | ^^^^^^^^^^^^^ the trait `NotObjectSafe` cannot be made into an object | = note: method `eq` references the `Self` type in its arguments or return type diff --git a/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.re.stderr b/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.re.stderr new file mode 100644 index 0000000000000..b48f6bbfb9417 --- /dev/null +++ b/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.re.stderr @@ -0,0 +1,11 @@ +error[E0038]: the trait `NotObjectSafe` cannot be made into an object + --> $DIR/coherence-impl-trait-for-trait-object-safe.rs:11:6 + | +LL | impl NotObjectSafe for NotObjectSafe { } + | ^^^^^^^^^^^^^ the trait `NotObjectSafe` cannot be made into an object + | + = note: method `eq` references the `Self` type in its arguments or return type + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0038`. diff --git a/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.rs b/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.rs index e5a7250872f4b..803e8fc6bca64 100644 --- a/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.rs +++ b/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.rs @@ -1,9 +1,15 @@ // Test that we give suitable error messages when the user attempts to // impl a trait `Trait` for its own object type. +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] + // If the trait is not object-safe, we give a more tailored message // because we're such schnuckels: trait NotObjectSafe { fn eq(&self, other: Self); } -impl NotObjectSafe for NotObjectSafe { } //~ ERROR E0038 +impl NotObjectSafe for NotObjectSafe { } +//[old]~^ ERROR E0038 +//[re]~^^ ERROR E0038 fn main() { } diff --git a/src/test/ui/coherence/coherence-impl-trait-for-trait.stderr b/src/test/ui/coherence/coherence-impl-trait-for-trait.old.stderr similarity index 69% rename from src/test/ui/coherence/coherence-impl-trait-for-trait.stderr rename to src/test/ui/coherence/coherence-impl-trait-for-trait.old.stderr index 05abef145b7e3..324747603f911 100644 --- a/src/test/ui/coherence/coherence-impl-trait-for-trait.stderr +++ b/src/test/ui/coherence/coherence-impl-trait-for-trait.old.stderr @@ -1,19 +1,19 @@ error[E0371]: the object type `(dyn Baz + 'static)` automatically implements the trait `Foo` - --> $DIR/coherence-impl-trait-for-trait.rs:9:1 + --> $DIR/coherence-impl-trait-for-trait.rs:13:1 | -LL | impl Foo for Baz { } //~ ERROR E0371 +LL | impl Foo for Baz { } | ^^^^^^^^^^^^^^^^ `(dyn Baz + 'static)` automatically implements trait `Foo` error[E0371]: the object type `(dyn Baz + 'static)` automatically implements the trait `Bar` - --> $DIR/coherence-impl-trait-for-trait.rs:10:1 + --> $DIR/coherence-impl-trait-for-trait.rs:16:1 | -LL | impl Bar for Baz { } //~ ERROR E0371 +LL | impl Bar for Baz { } | ^^^^^^^^^^^^^^^^ `(dyn Baz + 'static)` automatically implements trait `Bar` error[E0371]: the object type `(dyn Baz + 'static)` automatically implements the trait `Baz` - --> $DIR/coherence-impl-trait-for-trait.rs:11:1 + --> $DIR/coherence-impl-trait-for-trait.rs:19:1 | -LL | impl Baz for Baz { } //~ ERROR E0371 +LL | impl Baz for Baz { } | ^^^^^^^^^^^^^^^^ `(dyn Baz + 'static)` automatically implements trait `Baz` error: aborting due to 3 previous errors diff --git a/src/test/ui/coherence/coherence-impl-trait-for-trait.re.stderr b/src/test/ui/coherence/coherence-impl-trait-for-trait.re.stderr new file mode 100644 index 0000000000000..324747603f911 --- /dev/null +++ b/src/test/ui/coherence/coherence-impl-trait-for-trait.re.stderr @@ -0,0 +1,21 @@ +error[E0371]: the object type `(dyn Baz + 'static)` automatically implements the trait `Foo` + --> $DIR/coherence-impl-trait-for-trait.rs:13:1 + | +LL | impl Foo for Baz { } + | ^^^^^^^^^^^^^^^^ `(dyn Baz + 'static)` automatically implements trait `Foo` + +error[E0371]: the object type `(dyn Baz + 'static)` automatically implements the trait `Bar` + --> $DIR/coherence-impl-trait-for-trait.rs:16:1 + | +LL | impl Bar for Baz { } + | ^^^^^^^^^^^^^^^^ `(dyn Baz + 'static)` automatically implements trait `Bar` + +error[E0371]: the object type `(dyn Baz + 'static)` automatically implements the trait `Baz` + --> $DIR/coherence-impl-trait-for-trait.rs:19:1 + | +LL | impl Baz for Baz { } + | ^^^^^^^^^^^^^^^^ `(dyn Baz + 'static)` automatically implements trait `Baz` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0371`. diff --git a/src/test/ui/coherence/coherence-impl-trait-for-trait.rs b/src/test/ui/coherence/coherence-impl-trait-for-trait.rs index e4d59eedcabd0..dcaf564fdecfe 100644 --- a/src/test/ui/coherence/coherence-impl-trait-for-trait.rs +++ b/src/test/ui/coherence/coherence-impl-trait-for-trait.rs @@ -1,14 +1,24 @@ // Test that we give suitable error messages when the user attempts to // impl a trait `Trait` for its own object type. +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] + trait Foo { fn dummy(&self) { } } trait Bar: Foo { } trait Baz: Bar { } // Supertraits of Baz are not legal: -impl Foo for Baz { } //~ ERROR E0371 -impl Bar for Baz { } //~ ERROR E0371 -impl Baz for Baz { } //~ ERROR E0371 +impl Foo for Baz { } +//[old]~^ ERROR E0371 +//[re]~^^ ERROR E0371 +impl Bar for Baz { } +//[old]~^ ERROR E0371 +//[re]~^^ ERROR E0371 +impl Baz for Baz { } +//[old]~^ ERROR E0371 +//[re]~^^ ERROR E0371 // But other random traits are: trait Other { } diff --git a/src/test/ui/coherence/coherence-impls-copy.stderr b/src/test/ui/coherence/coherence-impls-copy.old.stderr similarity index 89% rename from src/test/ui/coherence/coherence-impls-copy.stderr rename to src/test/ui/coherence/coherence-impls-copy.old.stderr index b528bf8fa5991..defbbbadd5598 100644 --- a/src/test/ui/coherence/coherence-impls-copy.stderr +++ b/src/test/ui/coherence/coherence-impls-copy.old.stderr @@ -1,5 +1,5 @@ error[E0119]: conflicting implementations of trait `std::marker::Copy` for type `i32`: - --> $DIR/coherence-impls-copy.rs:5:1 + --> $DIR/coherence-impls-copy.rs:8:1 | LL | impl Copy for i32 {} | ^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | impl Copy for i32 {} - impl std::marker::Copy for i32; error[E0119]: conflicting implementations of trait `std::marker::Copy` for type `&NotSync`: - --> $DIR/coherence-impls-copy.rs:31:1 + --> $DIR/coherence-impls-copy.rs:37:1 | LL | impl Copy for &'static NotSync {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -18,7 +18,7 @@ LL | impl Copy for &'static NotSync {} where T: ?Sized; error[E0119]: conflicting implementations of trait `std::marker::Copy` for type `&[NotSync]`: - --> $DIR/coherence-impls-copy.rs:38:1 + --> $DIR/coherence-impls-copy.rs:45:1 | LL | impl Copy for &'static [NotSync] {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -28,25 +28,25 @@ LL | impl Copy for &'static [NotSync] {} where T: ?Sized; error[E0206]: the trait `Copy` may not be implemented for this type - --> $DIR/coherence-impls-copy.rs:23:15 + --> $DIR/coherence-impls-copy.rs:27:15 | LL | impl Copy for &'static mut MyType {} | ^^^^^^^^^^^^^^^^^^^ type is not a structure or enumeration error[E0206]: the trait `Copy` may not be implemented for this type - --> $DIR/coherence-impls-copy.rs:27:15 + --> $DIR/coherence-impls-copy.rs:32:15 | LL | impl Copy for (MyType, MyType) {} | ^^^^^^^^^^^^^^^^ type is not a structure or enumeration error[E0206]: the trait `Copy` may not be implemented for this type - --> $DIR/coherence-impls-copy.rs:34:15 + --> $DIR/coherence-impls-copy.rs:40:15 | LL | impl Copy for [MyType] {} | ^^^^^^^^ type is not a structure or enumeration error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/coherence-impls-copy.rs:5:1 + --> $DIR/coherence-impls-copy.rs:8:1 | LL | impl Copy for i32 {} | ^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate @@ -55,7 +55,7 @@ LL | impl Copy for i32 {} = note: define and implement a trait or new type instead error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/coherence-impls-copy.rs:27:1 + --> $DIR/coherence-impls-copy.rs:32:1 | LL | impl Copy for (MyType, MyType) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate @@ -64,7 +64,7 @@ LL | impl Copy for (MyType, MyType) {} = note: define and implement a trait or new type instead error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/coherence-impls-copy.rs:34:1 + --> $DIR/coherence-impls-copy.rs:40:1 | LL | impl Copy for [MyType] {} | ^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate @@ -73,7 +73,7 @@ LL | impl Copy for [MyType] {} = note: define and implement a trait or new type instead error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/coherence-impls-copy.rs:38:1 + --> $DIR/coherence-impls-copy.rs:45:1 | LL | impl Copy for &'static [NotSync] {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate diff --git a/src/test/ui/coherence/coherence-impls-copy.re.stderr b/src/test/ui/coherence/coherence-impls-copy.re.stderr new file mode 100644 index 0000000000000..defbbbadd5598 --- /dev/null +++ b/src/test/ui/coherence/coherence-impls-copy.re.stderr @@ -0,0 +1,87 @@ +error[E0119]: conflicting implementations of trait `std::marker::Copy` for type `i32`: + --> $DIR/coherence-impls-copy.rs:8:1 + | +LL | impl Copy for i32 {} + | ^^^^^^^^^^^^^^^^^ + | + = note: conflicting implementation in crate `core`: + - impl std::marker::Copy for i32; + +error[E0119]: conflicting implementations of trait `std::marker::Copy` for type `&NotSync`: + --> $DIR/coherence-impls-copy.rs:37:1 + | +LL | impl Copy for &'static NotSync {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: conflicting implementation in crate `core`: + - impl std::marker::Copy for &T + where T: ?Sized; + +error[E0119]: conflicting implementations of trait `std::marker::Copy` for type `&[NotSync]`: + --> $DIR/coherence-impls-copy.rs:45:1 + | +LL | impl Copy for &'static [NotSync] {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: conflicting implementation in crate `core`: + - impl std::marker::Copy for &T + where T: ?Sized; + +error[E0206]: the trait `Copy` may not be implemented for this type + --> $DIR/coherence-impls-copy.rs:27:15 + | +LL | impl Copy for &'static mut MyType {} + | ^^^^^^^^^^^^^^^^^^^ type is not a structure or enumeration + +error[E0206]: the trait `Copy` may not be implemented for this type + --> $DIR/coherence-impls-copy.rs:32:15 + | +LL | impl Copy for (MyType, MyType) {} + | ^^^^^^^^^^^^^^^^ type is not a structure or enumeration + +error[E0206]: the trait `Copy` may not be implemented for this type + --> $DIR/coherence-impls-copy.rs:40:15 + | +LL | impl Copy for [MyType] {} + | ^^^^^^^^ type is not a structure or enumeration + +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-impls-copy.rs:8:1 + | +LL | impl Copy for i32 {} + | ^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-impls-copy.rs:32:1 + | +LL | impl Copy for (MyType, MyType) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-impls-copy.rs:40:1 + | +LL | impl Copy for [MyType] {} + | ^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-impls-copy.rs:45:1 + | +LL | impl Copy for &'static [NotSync] {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to 10 previous errors + +Some errors occurred: E0117, E0119, E0206. +For more information about an error, try `rustc --explain E0117`. diff --git a/src/test/ui/coherence/coherence-impls-copy.rs b/src/test/ui/coherence/coherence-impls-copy.rs index 5bfdfc8f40aec..97133bc33ce0d 100644 --- a/src/test/ui/coherence/coherence-impls-copy.rs +++ b/src/test/ui/coherence/coherence-impls-copy.rs @@ -1,11 +1,15 @@ +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] #![feature(optin_builtin_traits)] use std::marker::Copy; impl Copy for i32 {} -//~^ ERROR conflicting implementations of trait `std::marker::Copy` for type `i32`: -//~| ERROR only traits defined in the current crate can be implemented for arbitrary types - +//[old]~^ ERROR conflicting implementations of trait `std::marker::Copy` for type `i32`: +//[old]~| ERROR only traits defined in the current crate can be implemented for arbitrary types +//[re]~^^^ ERROR E0119 +//[re]~| ERROR E0117 enum TestE { A } @@ -21,23 +25,27 @@ impl Clone for TestE { fn clone(&self) -> Self { *self } } impl Copy for MyType {} impl Copy for &'static mut MyType {} -//~^ ERROR the trait `Copy` may not be implemented for this type +//[old]~^ ERROR the trait `Copy` may not be implemented for this type +//[re]~^^ ERROR E0206 impl Clone for MyType { fn clone(&self) -> Self { *self } } impl Copy for (MyType, MyType) {} -//~^ ERROR the trait `Copy` may not be implemented for this type -//~| ERROR only traits defined in the current crate can be implemented for arbitrary types - +//[old]~^ ERROR the trait `Copy` may not be implemented for this type +//[old]~| ERROR only traits defined in the current crate can be implemented for arbitrary types +//[re]~^^^ ERROR E0206 +//[re]~| ERROR E0117 impl Copy for &'static NotSync {} -//~^ ERROR conflicting implementations of trait `std::marker::Copy` for type `&NotSync`: - +//[old]~^ ERROR conflicting implementations of trait `std::marker::Copy` for type `&NotSync`: +//[re]~^^ ERROR E0119 impl Copy for [MyType] {} -//~^ ERROR the trait `Copy` may not be implemented for this type -//~| ERROR only traits defined in the current crate can be implemented for arbitrary types - +//[old]~^ ERROR the trait `Copy` may not be implemented for this type +//[old]~| ERROR only traits defined in the current crate can be implemented for arbitrary types +//[re]~^^^ ERROR E0206 +//[re]~| ERROR E0117 impl Copy for &'static [NotSync] {} -//~^ ERROR conflicting implementations of trait `std::marker::Copy` for type `&[NotSync]`: -//~| ERROR only traits defined in the current crate can be implemented for arbitrary types - +//[old]~^ ERROR conflicting implementations of trait `std::marker::Copy` for type `&[NotSync]`: +//[old]~| ERROR only traits defined in the current crate can be implemented for arbitrary types +//[re]~^^^ ERROR E0119 +//[re]~| ERROR E0117 fn main() { } diff --git a/src/test/ui/coherence/coherence-impls-send.stderr b/src/test/ui/coherence/coherence-impls-send.old.stderr similarity index 92% rename from src/test/ui/coherence/coherence-impls-send.stderr rename to src/test/ui/coherence/coherence-impls-send.old.stderr index 02d90eea8fe6a..ca45c28ec2d74 100644 --- a/src/test/ui/coherence/coherence-impls-send.stderr +++ b/src/test/ui/coherence/coherence-impls-send.old.stderr @@ -1,5 +1,5 @@ error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/coherence-impls-send.rs:17:1 + --> $DIR/coherence-impls-send.rs:20:1 | LL | unsafe impl Send for (MyType, MyType) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate @@ -8,13 +8,13 @@ LL | unsafe impl Send for (MyType, MyType) {} = note: define and implement a trait or new type instead error[E0321]: cross-crate traits with a default impl, like `std::marker::Send`, can only be implemented for a struct/enum type, not `&'static NotSync` - --> $DIR/coherence-impls-send.rs:20:1 + --> $DIR/coherence-impls-send.rs:24:1 | LL | unsafe impl Send for &'static NotSync {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't implement cross-crate trait with a default impl for non-struct/enum type error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/coherence-impls-send.rs:23:1 + --> $DIR/coherence-impls-send.rs:28:1 | LL | unsafe impl Send for [MyType] {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate @@ -23,7 +23,7 @@ LL | unsafe impl Send for [MyType] {} = note: define and implement a trait or new type instead error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/coherence-impls-send.rs:26:1 + --> $DIR/coherence-impls-send.rs:32:1 | LL | unsafe impl Send for &'static [NotSync] {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate diff --git a/src/test/ui/coherence/coherence-impls-send.re.stderr b/src/test/ui/coherence/coherence-impls-send.re.stderr new file mode 100644 index 0000000000000..ca45c28ec2d74 --- /dev/null +++ b/src/test/ui/coherence/coherence-impls-send.re.stderr @@ -0,0 +1,37 @@ +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-impls-send.rs:20:1 + | +LL | unsafe impl Send for (MyType, MyType) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error[E0321]: cross-crate traits with a default impl, like `std::marker::Send`, can only be implemented for a struct/enum type, not `&'static NotSync` + --> $DIR/coherence-impls-send.rs:24:1 + | +LL | unsafe impl Send for &'static NotSync {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't implement cross-crate trait with a default impl for non-struct/enum type + +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-impls-send.rs:28:1 + | +LL | unsafe impl Send for [MyType] {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-impls-send.rs:32:1 + | +LL | unsafe impl Send for &'static [NotSync] {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to 4 previous errors + +Some errors occurred: E0117, E0321. +For more information about an error, try `rustc --explain E0117`. diff --git a/src/test/ui/coherence/coherence-impls-send.rs b/src/test/ui/coherence/coherence-impls-send.rs index b2a9c5be65843..ef13e9caa6678 100644 --- a/src/test/ui/coherence/coherence-impls-send.rs +++ b/src/test/ui/coherence/coherence-impls-send.rs @@ -1,3 +1,6 @@ +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] #![feature(optin_builtin_traits)] #![feature(overlapping_marker_traits)] @@ -15,16 +18,20 @@ impl !Sync for NotSync {} unsafe impl Send for TestE {} unsafe impl Send for MyType {} unsafe impl Send for (MyType, MyType) {} -//~^ ERROR E0117 +//[old]~^ ERROR E0117 +//[re]~^^ ERROR E0117 unsafe impl Send for &'static NotSync {} -//~^ ERROR E0321 +//[old]~^ ERROR E0321 +//[re]~^^ ERROR E0321 unsafe impl Send for [MyType] {} -//~^ ERROR E0117 +//[old]~^ ERROR E0117 +//[re]~^^ ERROR E0117 unsafe impl Send for &'static [NotSync] {} -//~^ ERROR E0117 +//[old]~^ ERROR E0117 +//[re]~^^ ERROR E0117 fn main() { } diff --git a/src/test/ui/coherence/coherence-impls-sized.stderr b/src/test/ui/coherence/coherence-impls-sized.old.stderr similarity index 73% rename from src/test/ui/coherence/coherence-impls-sized.stderr rename to src/test/ui/coherence/coherence-impls-sized.old.stderr index fbe08a59f5258..c9c7dd0ed6688 100644 --- a/src/test/ui/coherence/coherence-impls-sized.stderr +++ b/src/test/ui/coherence/coherence-impls-sized.old.stderr @@ -1,61 +1,61 @@ error[E0322]: explicit impls for the `Sized` trait are not permitted - --> $DIR/coherence-impls-sized.rs:14:1 + --> $DIR/coherence-impls-sized.rs:17:1 | -LL | impl Sized for TestE {} //~ ERROR E0322 +LL | impl Sized for TestE {} | ^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed error[E0322]: explicit impls for the `Sized` trait are not permitted - --> $DIR/coherence-impls-sized.rs:17:1 + --> $DIR/coherence-impls-sized.rs:22:1 | -LL | impl Sized for MyType {} //~ ERROR E0322 +LL | impl Sized for MyType {} | ^^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed error[E0322]: explicit impls for the `Sized` trait are not permitted - --> $DIR/coherence-impls-sized.rs:20:1 + --> $DIR/coherence-impls-sized.rs:27:1 | -LL | impl Sized for (MyType, MyType) {} //~ ERROR E0322 +LL | impl Sized for (MyType, MyType) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed error[E0322]: explicit impls for the `Sized` trait are not permitted - --> $DIR/coherence-impls-sized.rs:24:1 + --> $DIR/coherence-impls-sized.rs:34:1 | -LL | impl Sized for &'static NotSync {} //~ ERROR E0322 +LL | impl Sized for &'static NotSync {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed error[E0322]: explicit impls for the `Sized` trait are not permitted - --> $DIR/coherence-impls-sized.rs:27:1 + --> $DIR/coherence-impls-sized.rs:39:1 | -LL | impl Sized for [MyType] {} //~ ERROR E0322 +LL | impl Sized for [MyType] {} | ^^^^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed error[E0322]: explicit impls for the `Sized` trait are not permitted - --> $DIR/coherence-impls-sized.rs:31:1 + --> $DIR/coherence-impls-sized.rs:46:1 | -LL | impl Sized for &'static [NotSync] {} //~ ERROR E0322 +LL | impl Sized for &'static [NotSync] {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/coherence-impls-sized.rs:20:1 + --> $DIR/coherence-impls-sized.rs:27:1 | -LL | impl Sized for (MyType, MyType) {} //~ ERROR E0322 +LL | impl Sized for (MyType, MyType) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | = note: the impl does not reference any types defined in this crate = note: define and implement a trait or new type instead error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/coherence-impls-sized.rs:27:1 + --> $DIR/coherence-impls-sized.rs:39:1 | -LL | impl Sized for [MyType] {} //~ ERROR E0322 +LL | impl Sized for [MyType] {} | ^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | = note: the impl does not reference any types defined in this crate = note: define and implement a trait or new type instead error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/coherence-impls-sized.rs:31:1 + --> $DIR/coherence-impls-sized.rs:46:1 | -LL | impl Sized for &'static [NotSync] {} //~ ERROR E0322 +LL | impl Sized for &'static [NotSync] {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | = note: the impl does not reference any types defined in this crate diff --git a/src/test/ui/coherence/coherence-impls-sized.re.stderr b/src/test/ui/coherence/coherence-impls-sized.re.stderr new file mode 100644 index 0000000000000..c9c7dd0ed6688 --- /dev/null +++ b/src/test/ui/coherence/coherence-impls-sized.re.stderr @@ -0,0 +1,67 @@ +error[E0322]: explicit impls for the `Sized` trait are not permitted + --> $DIR/coherence-impls-sized.rs:17:1 + | +LL | impl Sized for TestE {} + | ^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed + +error[E0322]: explicit impls for the `Sized` trait are not permitted + --> $DIR/coherence-impls-sized.rs:22:1 + | +LL | impl Sized for MyType {} + | ^^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed + +error[E0322]: explicit impls for the `Sized` trait are not permitted + --> $DIR/coherence-impls-sized.rs:27:1 + | +LL | impl Sized for (MyType, MyType) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed + +error[E0322]: explicit impls for the `Sized` trait are not permitted + --> $DIR/coherence-impls-sized.rs:34:1 + | +LL | impl Sized for &'static NotSync {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed + +error[E0322]: explicit impls for the `Sized` trait are not permitted + --> $DIR/coherence-impls-sized.rs:39:1 + | +LL | impl Sized for [MyType] {} + | ^^^^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed + +error[E0322]: explicit impls for the `Sized` trait are not permitted + --> $DIR/coherence-impls-sized.rs:46:1 + | +LL | impl Sized for &'static [NotSync] {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed + +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-impls-sized.rs:27:1 + | +LL | impl Sized for (MyType, MyType) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-impls-sized.rs:39:1 + | +LL | impl Sized for [MyType] {} + | ^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-impls-sized.rs:46:1 + | +LL | impl Sized for &'static [NotSync] {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to 9 previous errors + +Some errors occurred: E0117, E0322. +For more information about an error, try `rustc --explain E0117`. diff --git a/src/test/ui/coherence/coherence-impls-sized.rs b/src/test/ui/coherence/coherence-impls-sized.rs index 7af1344f95d9e..84ae2dd291b60 100644 --- a/src/test/ui/coherence/coherence-impls-sized.rs +++ b/src/test/ui/coherence/coherence-impls-sized.rs @@ -1,3 +1,6 @@ +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] #![feature(optin_builtin_traits)] use std::marker::Copy; @@ -11,26 +14,41 @@ struct MyType; struct NotSync; impl !Sync for NotSync {} -impl Sized for TestE {} //~ ERROR E0322 -//~^ impl of 'Sized' not allowed - -impl Sized for MyType {} //~ ERROR E0322 -//~^ impl of 'Sized' not allowed - -impl Sized for (MyType, MyType) {} //~ ERROR E0322 -//~^ impl of 'Sized' not allowed -//~| ERROR E0117 - -impl Sized for &'static NotSync {} //~ ERROR E0322 -//~^ impl of 'Sized' not allowed - -impl Sized for [MyType] {} //~ ERROR E0322 -//~^ impl of 'Sized' not allowed -//~| ERROR E0117 - -impl Sized for &'static [NotSync] {} //~ ERROR E0322 -//~^ impl of 'Sized' not allowed -//~| ERROR E0117 +impl Sized for TestE {} +//[old]~^ ERROR E0322 +//[old]~| impl of 'Sized' not allowed +//[re]~^^^ ERROR E0322 + +impl Sized for MyType {} +//[old]~^ ERROR E0322 +//[old]~| impl of 'Sized' not allowed +//[re]~^^^ ERROR E0322 + +impl Sized for (MyType, MyType) {} +//[old]~^ ERROR E0322 +//[old]~| impl of 'Sized' not allowed +//[old]~| ERROR E0117 +//[re]~^^^^ ERROR E0322 +//[re]~| ERROR E0117 + +impl Sized for &'static NotSync {} +//[old]~^ ERROR E0322 +//[old]~| impl of 'Sized' not allowed +//[re]~^^^ ERROR E0322 + +impl Sized for [MyType] {} +//[old]~^ ERROR E0322 +//[old]~| impl of 'Sized' not allowed +//[old]~| ERROR E0117 +//[re]~^^^^ ERROR E0322 +//[re]~| ERROR E0117 + +impl Sized for &'static [NotSync] {} +//[old]~^ ERROR E0322 +//[old]~| impl of 'Sized' not allowed +//[old]~| ERROR E0117 +//[re]~^^^^ ERROR E0322 +//[re]~| ERROR E0117 fn main() { } diff --git a/src/test/ui/coherence/coherence-inherited-assoc-ty-cycle-err.stderr b/src/test/ui/coherence/coherence-inherited-assoc-ty-cycle-err.old.stderr similarity index 78% rename from src/test/ui/coherence/coherence-inherited-assoc-ty-cycle-err.stderr rename to src/test/ui/coherence/coherence-inherited-assoc-ty-cycle-err.old.stderr index 0b9f03db5c6b7..a2fa49acd2c90 100644 --- a/src/test/ui/coherence/coherence-inherited-assoc-ty-cycle-err.stderr +++ b/src/test/ui/coherence/coherence-inherited-assoc-ty-cycle-err.old.stderr @@ -1,12 +1,12 @@ error[E0391]: cycle detected when processing `Trait` - --> $DIR/coherence-inherited-assoc-ty-cycle-err.rs:9:1 + --> $DIR/coherence-inherited-assoc-ty-cycle-err.rs:12:1 | LL | trait Trait { type Assoc; } | ^^^^^^^^^^^^^^ | = note: ...which again requires processing `Trait`, completing the cycle note: cycle used when coherence checking all impls of trait `Trait` - --> $DIR/coherence-inherited-assoc-ty-cycle-err.rs:9:1 + --> $DIR/coherence-inherited-assoc-ty-cycle-err.rs:12:1 | LL | trait Trait { type Assoc; } | ^^^^^^^^^^^^^^ diff --git a/src/test/ui/coherence/coherence-inherited-assoc-ty-cycle-err.re.stderr b/src/test/ui/coherence/coherence-inherited-assoc-ty-cycle-err.re.stderr new file mode 100644 index 0000000000000..a2fa49acd2c90 --- /dev/null +++ b/src/test/ui/coherence/coherence-inherited-assoc-ty-cycle-err.re.stderr @@ -0,0 +1,16 @@ +error[E0391]: cycle detected when processing `Trait` + --> $DIR/coherence-inherited-assoc-ty-cycle-err.rs:12:1 + | +LL | trait Trait { type Assoc; } + | ^^^^^^^^^^^^^^ + | + = note: ...which again requires processing `Trait`, completing the cycle +note: cycle used when coherence checking all impls of trait `Trait` + --> $DIR/coherence-inherited-assoc-ty-cycle-err.rs:12:1 + | +LL | trait Trait { type Assoc; } + | ^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0391`. diff --git a/src/test/ui/coherence/coherence-inherited-assoc-ty-cycle-err.rs b/src/test/ui/coherence/coherence-inherited-assoc-ty-cycle-err.rs index 92bfeb1bf8afb..5a6b8fb7316d8 100644 --- a/src/test/ui/coherence/coherence-inherited-assoc-ty-cycle-err.rs +++ b/src/test/ui/coherence/coherence-inherited-assoc-ty-cycle-err.rs @@ -4,10 +4,14 @@ // // No we expect to run into a more user-friendly cycle error instead. +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] #![feature(specialization)] trait Trait { type Assoc; } -//~^ cycle detected +//[old]~^ cycle detected +//[re]~^^ ERROR E0391 impl Trait for Vec { type Assoc = (); diff --git a/src/test/ui/coherence/coherence-lone-type-parameter.stderr b/src/test/ui/coherence/coherence-lone-type-parameter.old.stderr similarity index 90% rename from src/test/ui/coherence/coherence-lone-type-parameter.stderr rename to src/test/ui/coherence/coherence-lone-type-parameter.old.stderr index 68e2dae095fa9..ac77241e9e791 100644 --- a/src/test/ui/coherence/coherence-lone-type-parameter.stderr +++ b/src/test/ui/coherence/coherence-lone-type-parameter.old.stderr @@ -1,5 +1,5 @@ error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/coherence-lone-type-parameter.rs:6:1 + --> $DIR/coherence-lone-type-parameter.rs:9:1 | LL | impl Remote for T { } | ^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type diff --git a/src/test/ui/coherence/coherence-lone-type-parameter.re.stderr b/src/test/ui/coherence/coherence-lone-type-parameter.re.stderr new file mode 100644 index 0000000000000..ac77241e9e791 --- /dev/null +++ b/src/test/ui/coherence/coherence-lone-type-parameter.re.stderr @@ -0,0 +1,11 @@ +error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) + --> $DIR/coherence-lone-type-parameter.rs:9:1 + | +LL | impl Remote for T { } + | ^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | + = note: only traits defined in the current crate can be implemented for a type parameter + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0210`. diff --git a/src/test/ui/coherence/coherence-lone-type-parameter.rs b/src/test/ui/coherence/coherence-lone-type-parameter.rs index 7d52945b9dd64..63b38bf1cc138 100644 --- a/src/test/ui/coherence/coherence-lone-type-parameter.rs +++ b/src/test/ui/coherence/coherence-lone-type-parameter.rs @@ -1,9 +1,14 @@ // aux-build:coherence_lib.rs +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] extern crate coherence_lib as lib; use lib::Remote; impl Remote for T { } -//~^ ERROR type parameter `T` must be used as the type parameter for some local type +//[old]~^ ERROR type parameter `T` must be used as the type parameter for some local type +//[re]~^^ ERROR E0210 + fn main() { } diff --git a/src/test/ui/coherence/coherence-negative-impls-safe.stderr b/src/test/ui/coherence/coherence-negative-impls-safe.old.stderr similarity index 82% rename from src/test/ui/coherence/coherence-negative-impls-safe.stderr rename to src/test/ui/coherence/coherence-negative-impls-safe.old.stderr index c47c9d25e3614..7ed47dca4972d 100644 --- a/src/test/ui/coherence/coherence-negative-impls-safe.stderr +++ b/src/test/ui/coherence/coherence-negative-impls-safe.old.stderr @@ -1,5 +1,5 @@ error[E0198]: negative impls cannot be unsafe - --> $DIR/coherence-negative-impls-safe.rs:7:1 + --> $DIR/coherence-negative-impls-safe.rs:10:1 | LL | unsafe impl !Send for TestType {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/coherence/coherence-negative-impls-safe.re.stderr b/src/test/ui/coherence/coherence-negative-impls-safe.re.stderr new file mode 100644 index 0000000000000..7ed47dca4972d --- /dev/null +++ b/src/test/ui/coherence/coherence-negative-impls-safe.re.stderr @@ -0,0 +1,9 @@ +error[E0198]: negative impls cannot be unsafe + --> $DIR/coherence-negative-impls-safe.rs:10:1 + | +LL | unsafe impl !Send for TestType {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0198`. diff --git a/src/test/ui/coherence/coherence-negative-impls-safe.rs b/src/test/ui/coherence/coherence-negative-impls-safe.rs index 050e47fd6a892..b6658d5bfa414 100644 --- a/src/test/ui/coherence/coherence-negative-impls-safe.rs +++ b/src/test/ui/coherence/coherence-negative-impls-safe.rs @@ -1,3 +1,6 @@ +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] #![feature(optin_builtin_traits)] use std::marker::Send; @@ -5,6 +8,7 @@ use std::marker::Send; struct TestType; unsafe impl !Send for TestType {} -//~^ ERROR negative impls cannot be unsafe +//[old]~^ ERROR negative impls cannot be unsafe +//[re]~^^ ERROR E0198 fn main() {} diff --git a/src/test/ui/coherence/coherence-no-direct-lifetime-dispatch.stderr b/src/test/ui/coherence/coherence-no-direct-lifetime-dispatch.old.stderr similarity index 74% rename from src/test/ui/coherence/coherence-no-direct-lifetime-dispatch.stderr rename to src/test/ui/coherence/coherence-no-direct-lifetime-dispatch.old.stderr index f1cc0088cf1ef..81465e7185676 100644 --- a/src/test/ui/coherence/coherence-no-direct-lifetime-dispatch.stderr +++ b/src/test/ui/coherence/coherence-no-direct-lifetime-dispatch.old.stderr @@ -1,9 +1,9 @@ error[E0119]: conflicting implementations of trait `MyTrait`: - --> $DIR/coherence-no-direct-lifetime-dispatch.rs:6:1 + --> $DIR/coherence-no-direct-lifetime-dispatch.rs:10:1 | LL | impl MyTrait for T {} | --------------------- first implementation here -LL | impl MyTrait for T {} //~ ERROR E0119 +LL | impl MyTrait for T {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation error: aborting due to previous error diff --git a/src/test/ui/coherence/coherence-no-direct-lifetime-dispatch.re.stderr b/src/test/ui/coherence/coherence-no-direct-lifetime-dispatch.re.stderr new file mode 100644 index 0000000000000..81465e7185676 --- /dev/null +++ b/src/test/ui/coherence/coherence-no-direct-lifetime-dispatch.re.stderr @@ -0,0 +1,11 @@ +error[E0119]: conflicting implementations of trait `MyTrait`: + --> $DIR/coherence-no-direct-lifetime-dispatch.rs:10:1 + | +LL | impl MyTrait for T {} + | --------------------- first implementation here +LL | impl MyTrait for T {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/coherence/coherence-no-direct-lifetime-dispatch.rs b/src/test/ui/coherence/coherence-no-direct-lifetime-dispatch.rs index 0a648c28ec658..9717f1ed0510e 100644 --- a/src/test/ui/coherence/coherence-no-direct-lifetime-dispatch.rs +++ b/src/test/ui/coherence/coherence-no-direct-lifetime-dispatch.rs @@ -1,8 +1,14 @@ // Test that you cannot *directly* dispatch on lifetime requirements +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] + trait MyTrait { fn foo() {} } impl MyTrait for T {} -impl MyTrait for T {} //~ ERROR E0119 +impl MyTrait for T {} +//[old]~^ ERROR E0119 +//[re]~^^ ERROR E0119 fn main() {} diff --git a/src/test/ui/coherence/coherence-orphan.stderr b/src/test/ui/coherence/coherence-orphan.old.stderr similarity index 91% rename from src/test/ui/coherence/coherence-orphan.stderr rename to src/test/ui/coherence/coherence-orphan.old.stderr index 1b32faf970cb7..da5de461bf41b 100644 --- a/src/test/ui/coherence/coherence-orphan.stderr +++ b/src/test/ui/coherence/coherence-orphan.old.stderr @@ -1,5 +1,5 @@ error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/coherence-orphan.rs:11:1 + --> $DIR/coherence-orphan.rs:13:1 | LL | impl TheTrait for isize { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate @@ -8,7 +8,7 @@ LL | impl TheTrait for isize { } = note: define and implement a trait or new type instead error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/coherence-orphan.rs:18:1 + --> $DIR/coherence-orphan.rs:21:1 | LL | impl !Send for Vec { } | ^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate diff --git a/src/test/ui/coherence/coherence-orphan.re.stderr b/src/test/ui/coherence/coherence-orphan.re.stderr new file mode 100644 index 0000000000000..da5de461bf41b --- /dev/null +++ b/src/test/ui/coherence/coherence-orphan.re.stderr @@ -0,0 +1,21 @@ +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-orphan.rs:13:1 + | +LL | impl TheTrait for isize { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-orphan.rs:21:1 + | +LL | impl !Send for Vec { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/coherence/coherence-orphan.rs b/src/test/ui/coherence/coherence-orphan.rs index ace3ebcc9e8b0..18f50e46021f9 100644 --- a/src/test/ui/coherence/coherence-orphan.rs +++ b/src/test/ui/coherence/coherence-orphan.rs @@ -1,5 +1,7 @@ // aux-build:coherence_orphan_lib.rs +// revisions: old re +#![cfg_attr(re, feature(re_rebalance_coherence))] #![feature(optin_builtin_traits)] extern crate coherence_orphan_lib as lib; @@ -9,13 +11,15 @@ use lib::TheTrait; struct TheType; impl TheTrait for isize { } -//~^ ERROR E0117 +//[old]~^ ERROR E0117 +//[re]~^^ ERROR E0117 impl TheTrait for isize { } impl TheTrait for TheType { } impl !Send for Vec { } -//~^ ERROR E0117 +//[old]~^ ERROR E0117 +//[re]~^^ ERROR E0117 fn main() { } diff --git a/src/test/ui/coherence/coherence-overlap-all-t-and-tuple.stderr b/src/test/ui/coherence/coherence-overlap-all-t-and-tuple.old.stderr similarity index 75% rename from src/test/ui/coherence/coherence-overlap-all-t-and-tuple.stderr rename to src/test/ui/coherence/coherence-overlap-all-t-and-tuple.old.stderr index 2bb3031edce09..c7f85b0b59078 100644 --- a/src/test/ui/coherence/coherence-overlap-all-t-and-tuple.stderr +++ b/src/test/ui/coherence/coherence-overlap-all-t-and-tuple.old.stderr @@ -1,10 +1,10 @@ error[E0119]: conflicting implementations of trait `From<(_,)>` for type `(_,)`: - --> $DIR/coherence-overlap-all-t-and-tuple.rs:16:1 + --> $DIR/coherence-overlap-all-t-and-tuple.rs:20:1 | LL | impl From for T { | ---------------------- first implementation here ... -LL | impl From<(U11,)> for (T11,) { //~ ERROR E0119 +LL | impl From<(U11,)> for (T11,) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(_,)` error: aborting due to previous error diff --git a/src/test/ui/coherence/coherence-overlap-all-t-and-tuple.re.stderr b/src/test/ui/coherence/coherence-overlap-all-t-and-tuple.re.stderr new file mode 100644 index 0000000000000..c7f85b0b59078 --- /dev/null +++ b/src/test/ui/coherence/coherence-overlap-all-t-and-tuple.re.stderr @@ -0,0 +1,12 @@ +error[E0119]: conflicting implementations of trait `From<(_,)>` for type `(_,)`: + --> $DIR/coherence-overlap-all-t-and-tuple.rs:20:1 + | +LL | impl From for T { + | ---------------------- first implementation here +... +LL | impl From<(U11,)> for (T11,) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(_,)` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/coherence/coherence-overlap-all-t-and-tuple.rs b/src/test/ui/coherence/coherence-overlap-all-t-and-tuple.rs index 19aad6927ba56..bf3ce89f70bba 100644 --- a/src/test/ui/coherence/coherence-overlap-all-t-and-tuple.rs +++ b/src/test/ui/coherence/coherence-overlap-all-t-and-tuple.rs @@ -6,6 +6,10 @@ // // Seems pretty basic, but then there was issue #24241. :) +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] + trait From { fn foo() {} } @@ -13,7 +17,9 @@ trait From { impl From for T { } -impl From<(U11,)> for (T11,) { //~ ERROR E0119 +impl From<(U11,)> for (T11,) { +//[old]~^ ERROR E0119 +//[re]~^^ ERROR E0119 } fn main() { } diff --git a/src/test/ui/coherence/coherence-overlap-downstream-inherent.stderr b/src/test/ui/coherence/coherence-overlap-downstream-inherent.old.stderr similarity index 83% rename from src/test/ui/coherence/coherence-overlap-downstream-inherent.stderr rename to src/test/ui/coherence/coherence-overlap-downstream-inherent.old.stderr index 9a060edb5b1bf..dcfc017f1b038 100644 --- a/src/test/ui/coherence/coherence-overlap-downstream-inherent.stderr +++ b/src/test/ui/coherence/coherence-overlap-downstream-inherent.old.stderr @@ -1,18 +1,18 @@ error[E0592]: duplicate definitions with name `dummy` - --> $DIR/coherence-overlap-downstream-inherent.rs:7:26 + --> $DIR/coherence-overlap-downstream-inherent.rs:11:26 | LL | impl Sweet { fn dummy(&self) { } } | ^^^^^^^^^^^^^^^^^^^ duplicate definitions for `dummy` -LL | //~^ ERROR E0592 +... LL | impl Sweet { fn dummy(&self) { } } | ------------------- other definition for `dummy` error[E0592]: duplicate definitions with name `f` - --> $DIR/coherence-overlap-downstream-inherent.rs:13:38 + --> $DIR/coherence-overlap-downstream-inherent.rs:18:38 | LL | impl A where T: Bar { fn f(&self) {} } | ^^^^^^^^^^^^^^ duplicate definitions for `f` -LL | //~^ ERROR E0592 +... LL | impl A { fn f(&self) {} } | -------------- other definition for `f` | diff --git a/src/test/ui/coherence/coherence-overlap-downstream-inherent.re.stderr b/src/test/ui/coherence/coherence-overlap-downstream-inherent.re.stderr new file mode 100644 index 0000000000000..dcfc017f1b038 --- /dev/null +++ b/src/test/ui/coherence/coherence-overlap-downstream-inherent.re.stderr @@ -0,0 +1,23 @@ +error[E0592]: duplicate definitions with name `dummy` + --> $DIR/coherence-overlap-downstream-inherent.rs:11:26 + | +LL | impl Sweet { fn dummy(&self) { } } + | ^^^^^^^^^^^^^^^^^^^ duplicate definitions for `dummy` +... +LL | impl Sweet { fn dummy(&self) { } } + | ------------------- other definition for `dummy` + +error[E0592]: duplicate definitions with name `f` + --> $DIR/coherence-overlap-downstream-inherent.rs:18:38 + | +LL | impl A where T: Bar { fn f(&self) {} } + | ^^^^^^^^^^^^^^ duplicate definitions for `f` +... +LL | impl A { fn f(&self) {} } + | -------------- other definition for `f` + | + = note: downstream crates may implement trait `Bar<_>` for type `i32` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0592`. diff --git a/src/test/ui/coherence/coherence-overlap-downstream-inherent.rs b/src/test/ui/coherence/coherence-overlap-downstream-inherent.rs index 5dea33e330b62..ad54d247f918d 100644 --- a/src/test/ui/coherence/coherence-overlap-downstream-inherent.rs +++ b/src/test/ui/coherence/coherence-overlap-downstream-inherent.rs @@ -1,17 +1,23 @@ // Tests that we consider `T: Sugar + Fruit` to be ambiguous, even // though no impls are found. +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] + struct Sweet(X); pub trait Sugar {} pub trait Fruit {} impl Sweet { fn dummy(&self) { } } -//~^ ERROR E0592 +//[old]~^ ERROR E0592 +//[re]~^^ ERROR E0592 impl Sweet { fn dummy(&self) { } } trait Bar {} struct A(T, X); impl A where T: Bar { fn f(&self) {} } -//~^ ERROR E0592 +//[old]~^ ERROR E0592 +//[re]~^^ ERROR E0592 impl A { fn f(&self) {} } fn main() {} diff --git a/src/test/ui/coherence/coherence-overlap-downstream.stderr b/src/test/ui/coherence/coherence-overlap-downstream.old.stderr similarity index 88% rename from src/test/ui/coherence/coherence-overlap-downstream.stderr rename to src/test/ui/coherence/coherence-overlap-downstream.old.stderr index 6fb398562d6be..b4847c03d4179 100644 --- a/src/test/ui/coherence/coherence-overlap-downstream.stderr +++ b/src/test/ui/coherence/coherence-overlap-downstream.old.stderr @@ -1,5 +1,5 @@ error[E0119]: conflicting implementations of trait `Sweet`: - --> $DIR/coherence-overlap-downstream.rs:8:1 + --> $DIR/coherence-overlap-downstream.rs:12:1 | LL | impl Sweet for T { } | ------------------------- first implementation here @@ -7,7 +7,7 @@ LL | impl Sweet for T { } | ^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation error[E0119]: conflicting implementations of trait `Foo<_>` for type `i32`: - --> $DIR/coherence-overlap-downstream.rs:14:1 + --> $DIR/coherence-overlap-downstream.rs:19:1 | LL | impl Foo for T where T: Bar {} | --------------------------------------- first implementation here diff --git a/src/test/ui/coherence/coherence-overlap-downstream.re.stderr b/src/test/ui/coherence/coherence-overlap-downstream.re.stderr new file mode 100644 index 0000000000000..b4847c03d4179 --- /dev/null +++ b/src/test/ui/coherence/coherence-overlap-downstream.re.stderr @@ -0,0 +1,21 @@ +error[E0119]: conflicting implementations of trait `Sweet`: + --> $DIR/coherence-overlap-downstream.rs:12:1 + | +LL | impl Sweet for T { } + | ------------------------- first implementation here +LL | impl Sweet for T { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation + +error[E0119]: conflicting implementations of trait `Foo<_>` for type `i32`: + --> $DIR/coherence-overlap-downstream.rs:19:1 + | +LL | impl Foo for T where T: Bar {} + | --------------------------------------- first implementation here +LL | impl Foo for i32 {} + | ^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `i32` + | + = note: downstream crates may implement trait `Bar<_>` for type `i32` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/coherence/coherence-overlap-downstream.rs b/src/test/ui/coherence/coherence-overlap-downstream.rs index 738ec0e3d4550..c6ced7b80fd9d 100644 --- a/src/test/ui/coherence/coherence-overlap-downstream.rs +++ b/src/test/ui/coherence/coherence-overlap-downstream.rs @@ -1,17 +1,23 @@ // Tests that we consider `T: Sugar + Fruit` to be ambiguous, even // though no impls are found. +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] + pub trait Sugar {} pub trait Fruit {} pub trait Sweet {} impl Sweet for T { } impl Sweet for T { } -//~^ ERROR E0119 +//[old]~^ ERROR E0119 +//[re]~^^ ERROR E0119 pub trait Foo {} pub trait Bar {} impl Foo for T where T: Bar {} impl Foo for i32 {} -//~^ ERROR E0119 +//[old]~^ ERROR E0119 +//[re]~^^ ERROR E0119 fn main() { } diff --git a/src/test/ui/coherence/coherence-overlap-issue-23516-inherent.stderr b/src/test/ui/coherence/coherence-overlap-issue-23516-inherent.old.stderr similarity index 86% rename from src/test/ui/coherence/coherence-overlap-issue-23516-inherent.stderr rename to src/test/ui/coherence/coherence-overlap-issue-23516-inherent.old.stderr index 6e5d116bce243..6fd9307754033 100644 --- a/src/test/ui/coherence/coherence-overlap-issue-23516-inherent.stderr +++ b/src/test/ui/coherence/coherence-overlap-issue-23516-inherent.old.stderr @@ -1,9 +1,9 @@ error[E0592]: duplicate definitions with name `dummy` - --> $DIR/coherence-overlap-issue-23516-inherent.rs:9:25 + --> $DIR/coherence-overlap-issue-23516-inherent.rs:13:25 | LL | impl Cake { fn dummy(&self) { } } | ^^^^^^^^^^^^^^^^^^^ duplicate definitions for `dummy` -LL | //~^ ERROR E0592 +... LL | impl Cake> { fn dummy(&self) { } } | ------------------- other definition for `dummy` | diff --git a/src/test/ui/coherence/coherence-overlap-issue-23516-inherent.re.stderr b/src/test/ui/coherence/coherence-overlap-issue-23516-inherent.re.stderr new file mode 100644 index 0000000000000..6fd9307754033 --- /dev/null +++ b/src/test/ui/coherence/coherence-overlap-issue-23516-inherent.re.stderr @@ -0,0 +1,14 @@ +error[E0592]: duplicate definitions with name `dummy` + --> $DIR/coherence-overlap-issue-23516-inherent.rs:13:25 + | +LL | impl Cake { fn dummy(&self) { } } + | ^^^^^^^^^^^^^^^^^^^ duplicate definitions for `dummy` +... +LL | impl Cake> { fn dummy(&self) { } } + | ------------------- other definition for `dummy` + | + = note: downstream crates may implement trait `Sugar` for type `std::boxed::Box<_>` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0592`. diff --git a/src/test/ui/coherence/coherence-overlap-issue-23516-inherent.rs b/src/test/ui/coherence/coherence-overlap-issue-23516-inherent.rs index a272e620fcab3..969366e29cc35 100644 --- a/src/test/ui/coherence/coherence-overlap-issue-23516-inherent.rs +++ b/src/test/ui/coherence/coherence-overlap-issue-23516-inherent.rs @@ -2,12 +2,17 @@ // though we see no impl of `Sugar` for `Box`. Therefore, an overlap // error is reported for the following pair of impls (#23516). +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] + pub trait Sugar {} struct Cake(X); impl Cake { fn dummy(&self) { } } -//~^ ERROR E0592 +//[old]~^ ERROR E0592 +//[re]~^^ ERROR E0592 impl Cake> { fn dummy(&self) { } } fn main() { } diff --git a/src/test/ui/coherence/coherence-overlap-issue-23516.stderr b/src/test/ui/coherence/coherence-overlap-issue-23516.old.stderr similarity index 91% rename from src/test/ui/coherence/coherence-overlap-issue-23516.stderr rename to src/test/ui/coherence/coherence-overlap-issue-23516.old.stderr index fe4c5cf3490dd..d17d67adf0eae 100644 --- a/src/test/ui/coherence/coherence-overlap-issue-23516.stderr +++ b/src/test/ui/coherence/coherence-overlap-issue-23516.old.stderr @@ -1,5 +1,5 @@ error[E0119]: conflicting implementations of trait `Sweet` for type `std::boxed::Box<_>`: - --> $DIR/coherence-overlap-issue-23516.rs:8:1 + --> $DIR/coherence-overlap-issue-23516.rs:12:1 | LL | impl Sweet for T { } | ------------------------- first implementation here diff --git a/src/test/ui/coherence/coherence-overlap-issue-23516.re.stderr b/src/test/ui/coherence/coherence-overlap-issue-23516.re.stderr new file mode 100644 index 0000000000000..d17d67adf0eae --- /dev/null +++ b/src/test/ui/coherence/coherence-overlap-issue-23516.re.stderr @@ -0,0 +1,13 @@ +error[E0119]: conflicting implementations of trait `Sweet` for type `std::boxed::Box<_>`: + --> $DIR/coherence-overlap-issue-23516.rs:12:1 + | +LL | impl Sweet for T { } + | ------------------------- first implementation here +LL | impl Sweet for Box { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `std::boxed::Box<_>` + | + = note: downstream crates may implement trait `Sugar` for type `std::boxed::Box<_>` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/coherence/coherence-overlap-issue-23516.rs b/src/test/ui/coherence/coherence-overlap-issue-23516.rs index 63e42e8f412dd..e3c15e149f8b5 100644 --- a/src/test/ui/coherence/coherence-overlap-issue-23516.rs +++ b/src/test/ui/coherence/coherence-overlap-issue-23516.rs @@ -2,10 +2,15 @@ // though we see no impl of `Sugar` for `Box`. Therefore, an overlap // error is reported for the following pair of impls (#23516). +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] + pub trait Sugar { fn dummy(&self) { } } pub trait Sweet { fn dummy(&self) { } } impl Sweet for T { } impl Sweet for Box { } -//~^ ERROR E0119 +//[old]~^ ERROR E0119 +//[re]~^^ ERROR E0119 fn main() { } diff --git a/src/test/ui/coherence/coherence-overlap-messages.stderr b/src/test/ui/coherence/coherence-overlap-messages.old.stderr similarity index 60% rename from src/test/ui/coherence/coherence-overlap-messages.stderr rename to src/test/ui/coherence/coherence-overlap-messages.old.stderr index f78482fc59796..429e67573b59b 100644 --- a/src/test/ui/coherence/coherence-overlap-messages.stderr +++ b/src/test/ui/coherence/coherence-overlap-messages.old.stderr @@ -1,42 +1,42 @@ error[E0119]: conflicting implementations of trait `Foo`: - --> $DIR/coherence-overlap-messages.rs:4:1 + --> $DIR/coherence-overlap-messages.rs:8:1 | LL | impl Foo for T {} | ----------------- first implementation here -LL | impl Foo for U {} //~ ERROR conflicting implementations of trait `Foo`: +LL | impl Foo for U {} | ^^^^^^^^^^^^^^^^^ conflicting implementation error[E0119]: conflicting implementations of trait `Bar` for type `(u8, u8)`: - --> $DIR/coherence-overlap-messages.rs:9:1 + --> $DIR/coherence-overlap-messages.rs:16:1 | LL | impl Bar for (T, u8) {} | ----------------------- first implementation here -LL | impl Bar for (u8, T) {} //~ ERROR conflicting implementations of trait `Bar` for type `(u8, u8)`: +LL | impl Bar for (u8, T) {} | ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(u8, u8)` error[E0119]: conflicting implementations of trait `Baz` for type `u8`: - --> $DIR/coherence-overlap-messages.rs:14:1 + --> $DIR/coherence-overlap-messages.rs:23:1 | LL | impl Baz for T {} | --------------------- first implementation here -LL | impl Baz for u8 {} //~ ERROR conflicting implementations of trait `Baz` for type `u8`: +LL | impl Baz for u8 {} | ^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `u8` error[E0119]: conflicting implementations of trait `Quux<_, _>`: - --> $DIR/coherence-overlap-messages.rs:19:1 + --> $DIR/coherence-overlap-messages.rs:30:1 | LL | impl Quux for T {} | ------------------------------ first implementation here -LL | impl Quux for T {} //~ ERROR conflicting implementations of trait `Quux<_, _>`: +LL | impl Quux for T {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation error[E0119]: conflicting implementations of trait `Quux<_, _>`: - --> $DIR/coherence-overlap-messages.rs:20:1 + --> $DIR/coherence-overlap-messages.rs:33:1 | LL | impl Quux for T {} | ------------------------------ first implementation here -LL | impl Quux for T {} //~ ERROR conflicting implementations of trait `Quux<_, _>`: -LL | impl Quux for T {} //~ ERROR conflicting implementations of trait `Quux<_, _>`: +... +LL | impl Quux for T {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation error: aborting due to 5 previous errors diff --git a/src/test/ui/coherence/coherence-overlap-messages.re.stderr b/src/test/ui/coherence/coherence-overlap-messages.re.stderr new file mode 100644 index 0000000000000..429e67573b59b --- /dev/null +++ b/src/test/ui/coherence/coherence-overlap-messages.re.stderr @@ -0,0 +1,44 @@ +error[E0119]: conflicting implementations of trait `Foo`: + --> $DIR/coherence-overlap-messages.rs:8:1 + | +LL | impl Foo for T {} + | ----------------- first implementation here +LL | impl Foo for U {} + | ^^^^^^^^^^^^^^^^^ conflicting implementation + +error[E0119]: conflicting implementations of trait `Bar` for type `(u8, u8)`: + --> $DIR/coherence-overlap-messages.rs:16:1 + | +LL | impl Bar for (T, u8) {} + | ----------------------- first implementation here +LL | impl Bar for (u8, T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(u8, u8)` + +error[E0119]: conflicting implementations of trait `Baz` for type `u8`: + --> $DIR/coherence-overlap-messages.rs:23:1 + | +LL | impl Baz for T {} + | --------------------- first implementation here +LL | impl Baz for u8 {} + | ^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `u8` + +error[E0119]: conflicting implementations of trait `Quux<_, _>`: + --> $DIR/coherence-overlap-messages.rs:30:1 + | +LL | impl Quux for T {} + | ------------------------------ first implementation here +LL | impl Quux for T {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation + +error[E0119]: conflicting implementations of trait `Quux<_, _>`: + --> $DIR/coherence-overlap-messages.rs:33:1 + | +LL | impl Quux for T {} + | ------------------------------ first implementation here +... +LL | impl Quux for T {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/coherence/coherence-overlap-messages.rs b/src/test/ui/coherence/coherence-overlap-messages.rs index e7ce40dc43aec..e0e2e672e98dd 100644 --- a/src/test/ui/coherence/coherence-overlap-messages.rs +++ b/src/test/ui/coherence/coherence-overlap-messages.rs @@ -1,22 +1,37 @@ +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] + trait Foo { fn foo() {} } impl Foo for T {} -impl Foo for U {} //~ ERROR conflicting implementations of trait `Foo`: +impl Foo for U {} +//[old]~^ ERROR conflicting implementations of trait `Foo`: +//[re]~^^ ERROR E0119 + trait Bar { fn bar() {} } impl Bar for (T, u8) {} -impl Bar for (u8, T) {} //~ ERROR conflicting implementations of trait `Bar` for type `(u8, u8)`: +impl Bar for (u8, T) {} +//[old]~^ ERROR conflicting implementations of trait `Bar` for type `(u8, u8)`: +//[re]~^^ ERROR E0119 trait Baz { fn baz() {} } impl Baz for T {} -impl Baz for u8 {} //~ ERROR conflicting implementations of trait `Baz` for type `u8`: +impl Baz for u8 {} +//[old]~^ ERROR conflicting implementations of trait `Baz` for type `u8`: +//[re]~^^ ERROR E0119 trait Quux { fn quux() {} } impl Quux for T {} -impl Quux for T {} //~ ERROR conflicting implementations of trait `Quux<_, _>`: -impl Quux for T {} //~ ERROR conflicting implementations of trait `Quux<_, _>`: +impl Quux for T {} +//[old]~^ ERROR conflicting implementations of trait `Quux<_, _>`: +//[re]~^^ ERROR E0119 +impl Quux for T {} +//[old]~^ ERROR conflicting implementations of trait `Quux<_, _>`: +//[re]~^^ ERROR E0119 fn main() {} diff --git a/src/test/ui/coherence/coherence-overlap-upstream-inherent.stderr b/src/test/ui/coherence/coherence-overlap-upstream-inherent.old.stderr similarity index 87% rename from src/test/ui/coherence/coherence-overlap-upstream-inherent.stderr rename to src/test/ui/coherence/coherence-overlap-upstream-inherent.old.stderr index 195b7dba74d84..928b65e003918 100644 --- a/src/test/ui/coherence/coherence-overlap-upstream-inherent.stderr +++ b/src/test/ui/coherence/coherence-overlap-upstream-inherent.old.stderr @@ -1,9 +1,9 @@ error[E0592]: duplicate definitions with name `dummy` - --> $DIR/coherence-overlap-upstream-inherent.rs:11:32 + --> $DIR/coherence-overlap-upstream-inherent.rs:15:32 | LL | impl A where T: Remote { fn dummy(&self) { } } | ^^^^^^^^^^^^^^^^^^^ duplicate definitions for `dummy` -LL | //~^ ERROR E0592 +... LL | impl A { fn dummy(&self) { } } | ------------------- other definition for `dummy` | diff --git a/src/test/ui/coherence/coherence-overlap-upstream-inherent.re.stderr b/src/test/ui/coherence/coherence-overlap-upstream-inherent.re.stderr new file mode 100644 index 0000000000000..928b65e003918 --- /dev/null +++ b/src/test/ui/coherence/coherence-overlap-upstream-inherent.re.stderr @@ -0,0 +1,14 @@ +error[E0592]: duplicate definitions with name `dummy` + --> $DIR/coherence-overlap-upstream-inherent.rs:15:32 + | +LL | impl A where T: Remote { fn dummy(&self) { } } + | ^^^^^^^^^^^^^^^^^^^ duplicate definitions for `dummy` +... +LL | impl A { fn dummy(&self) { } } + | ------------------- other definition for `dummy` + | + = note: upstream crates may add new impl of trait `coherence_lib::Remote` for type `i16` in future versions + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0592`. diff --git a/src/test/ui/coherence/coherence-overlap-upstream-inherent.rs b/src/test/ui/coherence/coherence-overlap-upstream-inherent.rs index c5d59c6655abe..92b619af076b9 100644 --- a/src/test/ui/coherence/coherence-overlap-upstream-inherent.rs +++ b/src/test/ui/coherence/coherence-overlap-upstream-inherent.rs @@ -2,6 +2,10 @@ // though the upstream crate doesn't implement it for now. // aux-build:coherence_lib.rs +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] + extern crate coherence_lib; @@ -9,7 +13,8 @@ use coherence_lib::Remote; struct A(X); impl A where T: Remote { fn dummy(&self) { } } -//~^ ERROR E0592 +//[old]~^ ERROR E0592 +//[re]~^^ ERROR E0592 impl A { fn dummy(&self) { } } fn main() {} diff --git a/src/test/ui/coherence/coherence-overlap-upstream.stderr b/src/test/ui/coherence/coherence-overlap-upstream.old.stderr similarity index 91% rename from src/test/ui/coherence/coherence-overlap-upstream.stderr rename to src/test/ui/coherence/coherence-overlap-upstream.old.stderr index 4095949df1344..6c3484c2d8c4d 100644 --- a/src/test/ui/coherence/coherence-overlap-upstream.stderr +++ b/src/test/ui/coherence/coherence-overlap-upstream.old.stderr @@ -1,5 +1,5 @@ error[E0119]: conflicting implementations of trait `Foo` for type `i16`: - --> $DIR/coherence-overlap-upstream.rs:12:1 + --> $DIR/coherence-overlap-upstream.rs:16:1 | LL | impl Foo for T where T: Remote {} | --------------------------------- first implementation here diff --git a/src/test/ui/coherence/coherence-overlap-upstream.re.stderr b/src/test/ui/coherence/coherence-overlap-upstream.re.stderr new file mode 100644 index 0000000000000..6c3484c2d8c4d --- /dev/null +++ b/src/test/ui/coherence/coherence-overlap-upstream.re.stderr @@ -0,0 +1,13 @@ +error[E0119]: conflicting implementations of trait `Foo` for type `i16`: + --> $DIR/coherence-overlap-upstream.rs:16:1 + | +LL | impl Foo for T where T: Remote {} + | --------------------------------- first implementation here +LL | impl Foo for i16 {} + | ^^^^^^^^^^^^^^^^ conflicting implementation for `i16` + | + = note: upstream crates may add new impl of trait `coherence_lib::Remote` for type `i16` in future versions + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/coherence/coherence-overlap-upstream.rs b/src/test/ui/coherence/coherence-overlap-upstream.rs index 47dd7a78fe88f..62f675003f9c4 100644 --- a/src/test/ui/coherence/coherence-overlap-upstream.rs +++ b/src/test/ui/coherence/coherence-overlap-upstream.rs @@ -2,6 +2,10 @@ // though the upstream crate doesn't implement it for now. // aux-build:coherence_lib.rs +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] + extern crate coherence_lib; @@ -10,6 +14,7 @@ use coherence_lib::Remote; trait Foo {} impl Foo for T where T: Remote {} impl Foo for i16 {} -//~^ ERROR E0119 +//[old]~^ ERROR E0119 +//[re]~^^ ERROR E0119 fn main() {} diff --git a/src/test/ui/coherence/coherence-overlapping-pairs.stderr b/src/test/ui/coherence/coherence-overlapping-pairs.old.stderr similarity index 91% rename from src/test/ui/coherence/coherence-overlapping-pairs.stderr rename to src/test/ui/coherence/coherence-overlapping-pairs.old.stderr index 19f283e89d1ac..b275af9668d16 100644 --- a/src/test/ui/coherence/coherence-overlapping-pairs.stderr +++ b/src/test/ui/coherence/coherence-overlapping-pairs.old.stderr @@ -1,5 +1,5 @@ error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/coherence-overlapping-pairs.rs:8:1 + --> $DIR/coherence-overlapping-pairs.rs:11:1 | LL | impl Remote for lib::Pair { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type diff --git a/src/test/ui/coherence/coherence-overlapping-pairs.re.stderr b/src/test/ui/coherence/coherence-overlapping-pairs.re.stderr new file mode 100644 index 0000000000000..0f2ec6f4ce069 --- /dev/null +++ b/src/test/ui/coherence/coherence-overlapping-pairs.re.stderr @@ -0,0 +1,12 @@ +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-overlapping-pairs.rs:11:1 + | +LL | impl Remote for lib::Pair { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/coherence/coherence-overlapping-pairs.rs b/src/test/ui/coherence/coherence-overlapping-pairs.rs index 11b74ebacc5bc..de31a0839405d 100644 --- a/src/test/ui/coherence/coherence-overlapping-pairs.rs +++ b/src/test/ui/coherence/coherence-overlapping-pairs.rs @@ -1,4 +1,7 @@ // aux-build:coherence_lib.rs +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] extern crate coherence_lib as lib; use lib::Remote; @@ -6,6 +9,7 @@ use lib::Remote; struct Foo; impl Remote for lib::Pair { } -//~^ ERROR type parameter `T` must be used as the type parameter for some local type +//[old]~^ ERROR type parameter `T` must be used as the type parameter for some local type +//[re]~^^ ERROR E0117 fn main() { } diff --git a/src/test/ui/coherence/coherence-pair-covered-uncovered-1.stderr b/src/test/ui/coherence/coherence-pair-covered-uncovered-1.old.stderr similarity index 90% rename from src/test/ui/coherence/coherence-pair-covered-uncovered-1.stderr rename to src/test/ui/coherence/coherence-pair-covered-uncovered-1.old.stderr index 072a98cf35848..8b25bee6e2f82 100644 --- a/src/test/ui/coherence/coherence-pair-covered-uncovered-1.stderr +++ b/src/test/ui/coherence/coherence-pair-covered-uncovered-1.old.stderr @@ -1,5 +1,5 @@ error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/coherence-pair-covered-uncovered-1.rs:11:1 + --> $DIR/coherence-pair-covered-uncovered-1.rs:15:1 | LL | impl Remote1>> for i32 { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type diff --git a/src/test/ui/coherence/coherence-pair-covered-uncovered-1.re.stderr b/src/test/ui/coherence/coherence-pair-covered-uncovered-1.re.stderr new file mode 100644 index 0000000000000..0c654ca41835d --- /dev/null +++ b/src/test/ui/coherence/coherence-pair-covered-uncovered-1.re.stderr @@ -0,0 +1,12 @@ +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-pair-covered-uncovered-1.rs:15:1 + | +LL | impl Remote1>> for i32 { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/coherence/coherence-pair-covered-uncovered-1.rs b/src/test/ui/coherence/coherence-pair-covered-uncovered-1.rs index f41e93aa994db..91794b7999b1c 100644 --- a/src/test/ui/coherence/coherence-pair-covered-uncovered-1.rs +++ b/src/test/ui/coherence/coherence-pair-covered-uncovered-1.rs @@ -2,6 +2,10 @@ // list of type parameters, not the self type. // aux-build:coherence_lib.rs +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] + extern crate coherence_lib as lib; use lib::{Remote1, Pair}; @@ -9,6 +13,7 @@ use lib::{Remote1, Pair}; pub struct Local(T); impl Remote1>> for i32 { } -//~^ ERROR type parameter `T` must be used as the type parameter for some local type +//[old]~^ ERROR type parameter `T` must be used as the type parameter for some local type +//[re]~^^ ERROR E0117 fn main() { } diff --git a/src/test/ui/coherence/coherence-pair-covered-uncovered.stderr b/src/test/ui/coherence/coherence-pair-covered-uncovered.old.stderr similarity index 90% rename from src/test/ui/coherence/coherence-pair-covered-uncovered.stderr rename to src/test/ui/coherence/coherence-pair-covered-uncovered.old.stderr index 3ba53829e3494..39558d8dcc037 100644 --- a/src/test/ui/coherence/coherence-pair-covered-uncovered.stderr +++ b/src/test/ui/coherence/coherence-pair-covered-uncovered.old.stderr @@ -1,5 +1,5 @@ error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/coherence-pair-covered-uncovered.rs:8:1 + --> $DIR/coherence-pair-covered-uncovered.rs:11:1 | LL | impl Remote for Pair> { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type diff --git a/src/test/ui/coherence/coherence-pair-covered-uncovered.re.stderr b/src/test/ui/coherence/coherence-pair-covered-uncovered.re.stderr new file mode 100644 index 0000000000000..9bddc15390212 --- /dev/null +++ b/src/test/ui/coherence/coherence-pair-covered-uncovered.re.stderr @@ -0,0 +1,12 @@ +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-pair-covered-uncovered.rs:11:1 + | +LL | impl Remote for Pair> { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/coherence/coherence-pair-covered-uncovered.rs b/src/test/ui/coherence/coherence-pair-covered-uncovered.rs index 2400e9ec67904..49a91412bec71 100644 --- a/src/test/ui/coherence/coherence-pair-covered-uncovered.rs +++ b/src/test/ui/coherence/coherence-pair-covered-uncovered.rs @@ -1,4 +1,7 @@ // aux-build:coherence_lib.rs +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] extern crate coherence_lib as lib; use lib::{Remote, Pair}; @@ -6,6 +9,7 @@ use lib::{Remote, Pair}; struct Local(T); impl Remote for Pair> { } -//~^ ERROR type parameter `T` must be used as the type parameter for some local type +//[old]~^ ERROR type parameter `T` must be used as the type parameter for some local type +//[re]~^^ ERROR E0117 fn main() { } diff --git a/src/test/ui/coherence/coherence-projection-conflict-orphan.stderr b/src/test/ui/coherence/coherence-projection-conflict-orphan.old.stderr similarity index 80% rename from src/test/ui/coherence/coherence-projection-conflict-orphan.stderr rename to src/test/ui/coherence/coherence-projection-conflict-orphan.old.stderr index 6929d9f3312c7..cde9360ddf2c8 100644 --- a/src/test/ui/coherence/coherence-projection-conflict-orphan.stderr +++ b/src/test/ui/coherence/coherence-projection-conflict-orphan.old.stderr @@ -1,10 +1,10 @@ error[E0119]: conflicting implementations of trait `Foo` for type `i32`: - --> $DIR/coherence-projection-conflict-orphan.rs:16:1 + --> $DIR/coherence-projection-conflict-orphan.rs:19:1 | LL | impl Foo for i32 { } | --------------------- first implementation here LL | -LL | impl Foo for A { } //~ ERROR E0119 +LL | impl Foo for A { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `i32` | = note: upstream crates may add new impl of trait `std::iter::Iterator` for type `i32` in future versions diff --git a/src/test/ui/coherence/coherence-projection-conflict-orphan.re.stderr b/src/test/ui/coherence/coherence-projection-conflict-orphan.re.stderr new file mode 100644 index 0000000000000..cde9360ddf2c8 --- /dev/null +++ b/src/test/ui/coherence/coherence-projection-conflict-orphan.re.stderr @@ -0,0 +1,14 @@ +error[E0119]: conflicting implementations of trait `Foo` for type `i32`: + --> $DIR/coherence-projection-conflict-orphan.rs:19:1 + | +LL | impl Foo for i32 { } + | --------------------- first implementation here +LL | +LL | impl Foo for A { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `i32` + | + = note: upstream crates may add new impl of trait `std::iter::Iterator` for type `i32` in future versions + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/coherence/coherence-projection-conflict-orphan.rs b/src/test/ui/coherence/coherence-projection-conflict-orphan.rs index 31325bea7c91b..4f7fc71536ba8 100644 --- a/src/test/ui/coherence/coherence-projection-conflict-orphan.rs +++ b/src/test/ui/coherence/coherence-projection-conflict-orphan.rs @@ -1,3 +1,6 @@ +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] #![feature(rustc_attrs)] // Here we expect a coherence conflict because, even though `i32` does @@ -13,6 +16,8 @@ pub trait Bar { impl Foo for i32 { } -impl Foo for A { } //~ ERROR E0119 +impl Foo for A { } +//[old]~^ ERROR E0119 +//[re]~^^ ERROR E0119 fn main() {} diff --git a/src/test/ui/coherence/coherence-projection-conflict-ty-param.stderr b/src/test/ui/coherence/coherence-projection-conflict-ty-param.old.stderr similarity index 78% rename from src/test/ui/coherence/coherence-projection-conflict-ty-param.stderr rename to src/test/ui/coherence/coherence-projection-conflict-ty-param.old.stderr index 92717e3f67a0e..b53a4c973edac 100644 --- a/src/test/ui/coherence/coherence-projection-conflict-ty-param.stderr +++ b/src/test/ui/coherence/coherence-projection-conflict-ty-param.old.stderr @@ -1,10 +1,10 @@ error[E0119]: conflicting implementations of trait `Foo<_>` for type `std::option::Option<_>`: - --> $DIR/coherence-projection-conflict-ty-param.rs:10:1 + --> $DIR/coherence-projection-conflict-ty-param.rs:14:1 | LL | impl > Foo

for Option {} | ---------------------------------------- first implementation here LL | -LL | impl Foo for Option { } //~ ERROR E0119 +LL | impl Foo for Option { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `std::option::Option<_>` error: aborting due to previous error diff --git a/src/test/ui/coherence/coherence-projection-conflict-ty-param.re.stderr b/src/test/ui/coherence/coherence-projection-conflict-ty-param.re.stderr new file mode 100644 index 0000000000000..b53a4c973edac --- /dev/null +++ b/src/test/ui/coherence/coherence-projection-conflict-ty-param.re.stderr @@ -0,0 +1,12 @@ +error[E0119]: conflicting implementations of trait `Foo<_>` for type `std::option::Option<_>`: + --> $DIR/coherence-projection-conflict-ty-param.rs:14:1 + | +LL | impl > Foo

for Option {} + | ---------------------------------------- first implementation here +LL | +LL | impl Foo for Option { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `std::option::Option<_>` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/coherence/coherence-projection-conflict-ty-param.rs b/src/test/ui/coherence/coherence-projection-conflict-ty-param.rs index 490c7e24f5740..819947fa54756 100644 --- a/src/test/ui/coherence/coherence-projection-conflict-ty-param.rs +++ b/src/test/ui/coherence/coherence-projection-conflict-ty-param.rs @@ -1,12 +1,18 @@ // Coherence error results because we do not know whether `T: Foo

` or not // for the second impl. +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] + use std::marker::PhantomData; pub trait Foo

{ fn foo() {} } impl > Foo

for Option {} -impl Foo for Option { } //~ ERROR E0119 +impl Foo for Option { } +//[old]~^ ERROR E0119 +//[re]~^^ ERROR E0119 fn main() {} diff --git a/src/test/ui/coherence/coherence-projection-conflict.stderr b/src/test/ui/coherence/coherence-projection-conflict.old.stderr similarity index 76% rename from src/test/ui/coherence/coherence-projection-conflict.stderr rename to src/test/ui/coherence/coherence-projection-conflict.old.stderr index 1b0b4e1708f9a..c2e5fc8617512 100644 --- a/src/test/ui/coherence/coherence-projection-conflict.stderr +++ b/src/test/ui/coherence/coherence-projection-conflict.old.stderr @@ -1,10 +1,10 @@ error[E0119]: conflicting implementations of trait `Foo` for type `i32`: - --> $DIR/coherence-projection-conflict.rs:11:1 + --> $DIR/coherence-projection-conflict.rs:15:1 | LL | impl Foo for i32 { } | --------------------- first implementation here LL | -LL | impl Foo for A { } //~ ERROR E0119 +LL | impl Foo for A { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `i32` error: aborting due to previous error diff --git a/src/test/ui/coherence/coherence-projection-conflict.re.stderr b/src/test/ui/coherence/coherence-projection-conflict.re.stderr new file mode 100644 index 0000000000000..c2e5fc8617512 --- /dev/null +++ b/src/test/ui/coherence/coherence-projection-conflict.re.stderr @@ -0,0 +1,12 @@ +error[E0119]: conflicting implementations of trait `Foo` for type `i32`: + --> $DIR/coherence-projection-conflict.rs:15:1 + | +LL | impl Foo for i32 { } + | --------------------- first implementation here +LL | +LL | impl Foo for A { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `i32` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/coherence/coherence-projection-conflict.rs b/src/test/ui/coherence/coherence-projection-conflict.rs index 34f078f9a8c35..4086aeef8c03a 100644 --- a/src/test/ui/coherence/coherence-projection-conflict.rs +++ b/src/test/ui/coherence/coherence-projection-conflict.rs @@ -1,3 +1,7 @@ +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] + use std::marker::PhantomData; pub trait Foo

{ fn foo() {} } @@ -8,7 +12,9 @@ pub trait Bar { impl Foo for i32 { } -impl Foo for A { } //~ ERROR E0119 +impl Foo for A { } +//[old]~^ ERROR E0119 +//[re]~^^ ERROR E0119 impl Bar for i32 { type Output = i32; diff --git a/src/test/ui/coherence/coherence-projection-ok-orphan.rs b/src/test/ui/coherence/coherence-projection-ok-orphan.rs index be7fbfbf1b6d8..652b438feb137 100644 --- a/src/test/ui/coherence/coherence-projection-ok-orphan.rs +++ b/src/test/ui/coherence/coherence-projection-ok-orphan.rs @@ -1,5 +1,8 @@ // compile-pass // skip-codegen +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] #![allow(dead_code)] // Here we do not get a coherence conflict because `Baz: Iterator` // does not hold and (due to the orphan rules), we can rely on that. diff --git a/src/test/ui/coherence/coherence-projection-ok.rs b/src/test/ui/coherence/coherence-projection-ok.rs index 74d44eb14b5b5..f759a9e1b4508 100644 --- a/src/test/ui/coherence/coherence-projection-ok.rs +++ b/src/test/ui/coherence/coherence-projection-ok.rs @@ -1,5 +1,8 @@ // compile-pass // skip-codegen +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] pub trait Foo

{} pub trait Bar { diff --git a/src/test/ui/coherence/coherence-tuple-conflict.stderr b/src/test/ui/coherence/coherence-tuple-conflict.old.stderr similarity index 79% rename from src/test/ui/coherence/coherence-tuple-conflict.stderr rename to src/test/ui/coherence/coherence-tuple-conflict.old.stderr index 4baf71ebf0998..e832bdebbddeb 100644 --- a/src/test/ui/coherence/coherence-tuple-conflict.stderr +++ b/src/test/ui/coherence/coherence-tuple-conflict.old.stderr @@ -1,10 +1,10 @@ error[E0119]: conflicting implementations of trait `MyTrait` for type `(_, _)`: - --> $DIR/coherence-tuple-conflict.rs:15:1 + --> $DIR/coherence-tuple-conflict.rs:19:1 | LL | impl MyTrait for (T,T) { | ------------------------- first implementation here ... -LL | impl MyTrait for (A,B) { //~ ERROR E0119 +LL | impl MyTrait for (A,B) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(_, _)` error: aborting due to previous error diff --git a/src/test/ui/coherence/coherence-tuple-conflict.re.stderr b/src/test/ui/coherence/coherence-tuple-conflict.re.stderr new file mode 100644 index 0000000000000..e832bdebbddeb --- /dev/null +++ b/src/test/ui/coherence/coherence-tuple-conflict.re.stderr @@ -0,0 +1,12 @@ +error[E0119]: conflicting implementations of trait `MyTrait` for type `(_, _)`: + --> $DIR/coherence-tuple-conflict.rs:19:1 + | +LL | impl MyTrait for (T,T) { + | ------------------------- first implementation here +... +LL | impl MyTrait for (A,B) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(_, _)` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/coherence/coherence-tuple-conflict.rs b/src/test/ui/coherence/coherence-tuple-conflict.rs index bece87a9dd95f..130867b22428b 100644 --- a/src/test/ui/coherence/coherence-tuple-conflict.rs +++ b/src/test/ui/coherence/coherence-tuple-conflict.rs @@ -1,3 +1,7 @@ +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] + use std::fmt::Debug; use std::default::Default; @@ -12,7 +16,9 @@ impl MyTrait for (T,T) { fn get(&self) -> usize { 0 } } -impl MyTrait for (A,B) { //~ ERROR E0119 +impl MyTrait for (A,B) { +//[old]~^ ERROR E0119 +//[re]~^^ ERROR E0119 fn get(&self) -> usize { self.dummy } } diff --git a/src/test/ui/coherence/coherence-vec-local-2.stderr b/src/test/ui/coherence/coherence-vec-local-2.old.stderr similarity index 81% rename from src/test/ui/coherence/coherence-vec-local-2.stderr rename to src/test/ui/coherence/coherence-vec-local-2.old.stderr index 3cdcd95770955..1c1118a58c6f0 100644 --- a/src/test/ui/coherence/coherence-vec-local-2.stderr +++ b/src/test/ui/coherence/coherence-vec-local-2.old.stderr @@ -1,7 +1,7 @@ error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/coherence-vec-local-2.rs:11:1 + --> $DIR/coherence-vec-local-2.rs:14:1 | -LL | impl Remote for Vec> { } //~ ERROR E0210 +LL | impl Remote for Vec> { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type | = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/src/test/ui/coherence/coherence-vec-local-2.re.stderr b/src/test/ui/coherence/coherence-vec-local-2.re.stderr new file mode 100644 index 0000000000000..37859f7cfa285 --- /dev/null +++ b/src/test/ui/coherence/coherence-vec-local-2.re.stderr @@ -0,0 +1,12 @@ +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-vec-local-2.rs:14:1 + | +LL | impl Remote for Vec> { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/coherence/coherence-vec-local-2.rs b/src/test/ui/coherence/coherence-vec-local-2.rs index b77b1f2e05443..423543964c20b 100644 --- a/src/test/ui/coherence/coherence-vec-local-2.rs +++ b/src/test/ui/coherence/coherence-vec-local-2.rs @@ -2,12 +2,17 @@ // *non-fundamental* remote type like `Vec` is not considered local. // aux-build:coherence_lib.rs +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] extern crate coherence_lib as lib; use lib::Remote; struct Local(T); -impl Remote for Vec> { } //~ ERROR E0210 +impl Remote for Vec> { } +//[old]~^ ERROR E0210 +//[re]~^^ ERROR E0117 fn main() { } diff --git a/src/test/ui/coherence/coherence-vec-local.stderr b/src/test/ui/coherence/coherence-vec-local.old.stderr similarity index 81% rename from src/test/ui/coherence/coherence-vec-local.stderr rename to src/test/ui/coherence/coherence-vec-local.old.stderr index 319d2ebabd7e8..304aaaf36875c 100644 --- a/src/test/ui/coherence/coherence-vec-local.stderr +++ b/src/test/ui/coherence/coherence-vec-local.old.stderr @@ -1,7 +1,7 @@ error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/coherence-vec-local.rs:11:1 + --> $DIR/coherence-vec-local.rs:14:1 | -LL | impl Remote for Vec { } //~ ERROR E0117 +LL | impl Remote for Vec { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | = note: the impl does not reference any types defined in this crate diff --git a/src/test/ui/coherence/coherence-vec-local.re.stderr b/src/test/ui/coherence/coherence-vec-local.re.stderr new file mode 100644 index 0000000000000..304aaaf36875c --- /dev/null +++ b/src/test/ui/coherence/coherence-vec-local.re.stderr @@ -0,0 +1,12 @@ +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-vec-local.rs:14:1 + | +LL | impl Remote for Vec { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/coherence/coherence-vec-local.rs b/src/test/ui/coherence/coherence-vec-local.rs index de12b43d485df..351ddd2aa6744 100644 --- a/src/test/ui/coherence/coherence-vec-local.rs +++ b/src/test/ui/coherence/coherence-vec-local.rs @@ -2,12 +2,17 @@ // *non-fundamental* remote type like `Vec` is not considered local. // aux-build:coherence_lib.rs +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] extern crate coherence_lib as lib; use lib::Remote; struct Local; -impl Remote for Vec { } //~ ERROR E0117 +impl Remote for Vec { } +//[old]~^ ERROR E0117 +//[re]~^^ ERROR E0117 fn main() { } diff --git a/src/test/ui/coherence/coherence_copy_like_err_fundamental_struct.rs b/src/test/ui/coherence/coherence_copy_like_err_fundamental_struct.rs index 205f5fd1c579d..a030314262270 100644 --- a/src/test/ui/coherence/coherence_copy_like_err_fundamental_struct.rs +++ b/src/test/ui/coherence/coherence_copy_like_err_fundamental_struct.rs @@ -4,6 +4,9 @@ // aux-build:coherence_copy_like_lib.rs // compile-pass // skip-codgen +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] #![allow(dead_code)] extern crate coherence_copy_like_lib as lib; diff --git a/src/test/ui/coherence/coherence_copy_like_err_fundamental_struct_ref.rs b/src/test/ui/coherence/coherence_copy_like_err_fundamental_struct_ref.rs index ac62310fab79d..bd8317e224699 100644 --- a/src/test/ui/coherence/coherence_copy_like_err_fundamental_struct_ref.rs +++ b/src/test/ui/coherence/coherence_copy_like_err_fundamental_struct_ref.rs @@ -4,6 +4,9 @@ // aux-build:coherence_copy_like_lib.rs // compile-pass // skip-codegen +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] #![allow(dead_code)] extern crate coherence_copy_like_lib as lib; diff --git a/src/test/ui/coherence/coherence_copy_like_err_fundamental_struct_tuple.stderr b/src/test/ui/coherence/coherence_copy_like_err_fundamental_struct_tuple.old.stderr similarity index 89% rename from src/test/ui/coherence/coherence_copy_like_err_fundamental_struct_tuple.stderr rename to src/test/ui/coherence/coherence_copy_like_err_fundamental_struct_tuple.old.stderr index 0aa7320bc3343..12c7a1f977c3f 100644 --- a/src/test/ui/coherence/coherence_copy_like_err_fundamental_struct_tuple.stderr +++ b/src/test/ui/coherence/coherence_copy_like_err_fundamental_struct_tuple.old.stderr @@ -1,10 +1,10 @@ error[E0119]: conflicting implementations of trait `MyTrait` for type `lib::MyFundamentalStruct<(MyType,)>`: - --> $DIR/coherence_copy_like_err_fundamental_struct_tuple.rs:17:1 + --> $DIR/coherence_copy_like_err_fundamental_struct_tuple.rs:19:1 | LL | impl MyTrait for T { } | ---------------------------------- first implementation here ... -LL | impl MyTrait for lib::MyFundamentalStruct<(MyType,)> { } //~ ERROR E0119 +LL | impl MyTrait for lib::MyFundamentalStruct<(MyType,)> { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `lib::MyFundamentalStruct<(MyType,)>` | = note: upstream crates may add new impl of trait `lib::MyCopy` for type `lib::MyFundamentalStruct<(MyType,)>` in future versions diff --git a/src/test/ui/coherence/coherence_copy_like_err_fundamental_struct_tuple.re.stderr b/src/test/ui/coherence/coherence_copy_like_err_fundamental_struct_tuple.re.stderr new file mode 100644 index 0000000000000..12c7a1f977c3f --- /dev/null +++ b/src/test/ui/coherence/coherence_copy_like_err_fundamental_struct_tuple.re.stderr @@ -0,0 +1,14 @@ +error[E0119]: conflicting implementations of trait `MyTrait` for type `lib::MyFundamentalStruct<(MyType,)>`: + --> $DIR/coherence_copy_like_err_fundamental_struct_tuple.rs:19:1 + | +LL | impl MyTrait for T { } + | ---------------------------------- first implementation here +... +LL | impl MyTrait for lib::MyFundamentalStruct<(MyType,)> { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `lib::MyFundamentalStruct<(MyType,)>` + | + = note: upstream crates may add new impl of trait `lib::MyCopy` for type `lib::MyFundamentalStruct<(MyType,)>` in future versions + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/coherence/coherence_copy_like_err_fundamental_struct_tuple.rs b/src/test/ui/coherence/coherence_copy_like_err_fundamental_struct_tuple.rs index a3a851f606f28..2a61042c6a03a 100644 --- a/src/test/ui/coherence/coherence_copy_like_err_fundamental_struct_tuple.rs +++ b/src/test/ui/coherence/coherence_copy_like_err_fundamental_struct_tuple.rs @@ -2,7 +2,9 @@ // `MyType: !MyTrait` along with other "fundamental" wrappers. // aux-build:coherence_copy_like_lib.rs +// revisions: old re +#![cfg_attr(re, feature(re_rebalance_coherence))] extern crate coherence_copy_like_lib as lib; @@ -14,7 +16,9 @@ trait MyTrait { fn foo() {} } impl MyTrait for T { } // Tuples are not fundamental. -impl MyTrait for lib::MyFundamentalStruct<(MyType,)> { } //~ ERROR E0119 +impl MyTrait for lib::MyFundamentalStruct<(MyType,)> { } +//[old]~^ ERROR E0119 +//[re]~^^ ERROR E0119 fn main() { } diff --git a/src/test/ui/coherence/coherence_copy_like_err_struct.stderr b/src/test/ui/coherence/coherence_copy_like_err_struct.old.stderr similarity index 82% rename from src/test/ui/coherence/coherence_copy_like_err_struct.stderr rename to src/test/ui/coherence/coherence_copy_like_err_struct.old.stderr index 03b4b7d807236..1b6c62e9bf3a8 100644 --- a/src/test/ui/coherence/coherence_copy_like_err_struct.stderr +++ b/src/test/ui/coherence/coherence_copy_like_err_struct.old.stderr @@ -1,10 +1,10 @@ error[E0119]: conflicting implementations of trait `MyTrait` for type `lib::MyStruct`: - --> $DIR/coherence_copy_like_err_struct.rs:19:1 + --> $DIR/coherence_copy_like_err_struct.rs:22:1 | LL | impl MyTrait for T { } | ---------------------------------- first implementation here ... -LL | impl MyTrait for lib::MyStruct { } //~ ERROR E0119 +LL | impl MyTrait for lib::MyStruct { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `lib::MyStruct` | = note: upstream crates may add new impl of trait `lib::MyCopy` for type `lib::MyStruct` in future versions diff --git a/src/test/ui/coherence/coherence_copy_like_err_struct.re.stderr b/src/test/ui/coherence/coherence_copy_like_err_struct.re.stderr new file mode 100644 index 0000000000000..1b6c62e9bf3a8 --- /dev/null +++ b/src/test/ui/coherence/coherence_copy_like_err_struct.re.stderr @@ -0,0 +1,14 @@ +error[E0119]: conflicting implementations of trait `MyTrait` for type `lib::MyStruct`: + --> $DIR/coherence_copy_like_err_struct.rs:22:1 + | +LL | impl MyTrait for T { } + | ---------------------------------- first implementation here +... +LL | impl MyTrait for lib::MyStruct { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `lib::MyStruct` + | + = note: upstream crates may add new impl of trait `lib::MyCopy` for type `lib::MyStruct` in future versions + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/coherence/coherence_copy_like_err_struct.rs b/src/test/ui/coherence/coherence_copy_like_err_struct.rs index f8c01b4e89eee..38fc2e662d71e 100644 --- a/src/test/ui/coherence/coherence_copy_like_err_struct.rs +++ b/src/test/ui/coherence/coherence_copy_like_err_struct.rs @@ -1,4 +1,7 @@ // aux-build:coherence_copy_like_lib.rs +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] // Test that we are able to introduce a negative constraint that // `MyType: !MyTrait` along with other "fundamental" wrappers. @@ -16,6 +19,8 @@ impl MyTrait for T { } // MyStruct: !MyTrait // // which we cannot approve. -impl MyTrait for lib::MyStruct { } //~ ERROR E0119 +impl MyTrait for lib::MyStruct { } +//[old]~^ ERROR E0119 +//[re]~^^ ERROR E0119 fn main() { } diff --git a/src/test/ui/coherence/coherence_copy_like_err_tuple.stderr b/src/test/ui/coherence/coherence_copy_like_err_tuple.old.stderr similarity index 83% rename from src/test/ui/coherence/coherence_copy_like_err_tuple.stderr rename to src/test/ui/coherence/coherence_copy_like_err_tuple.old.stderr index 71c1a9173af31..11bd788c76153 100644 --- a/src/test/ui/coherence/coherence_copy_like_err_tuple.stderr +++ b/src/test/ui/coherence/coherence_copy_like_err_tuple.old.stderr @@ -1,10 +1,10 @@ error[E0119]: conflicting implementations of trait `MyTrait` for type `(MyType,)`: - --> $DIR/coherence_copy_like_err_tuple.rs:18:1 + --> $DIR/coherence_copy_like_err_tuple.rs:21:1 | LL | impl MyTrait for T { } | ---------------------------------- first implementation here ... -LL | impl MyTrait for (MyType,) { } //~ ERROR E0119 +LL | impl MyTrait for (MyType,) { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(MyType,)` | = note: upstream crates may add new impl of trait `lib::MyCopy` for type `(MyType,)` in future versions diff --git a/src/test/ui/coherence/coherence_copy_like_err_tuple.re.stderr b/src/test/ui/coherence/coherence_copy_like_err_tuple.re.stderr new file mode 100644 index 0000000000000..11bd788c76153 --- /dev/null +++ b/src/test/ui/coherence/coherence_copy_like_err_tuple.re.stderr @@ -0,0 +1,14 @@ +error[E0119]: conflicting implementations of trait `MyTrait` for type `(MyType,)`: + --> $DIR/coherence_copy_like_err_tuple.rs:21:1 + | +LL | impl MyTrait for T { } + | ---------------------------------- first implementation here +... +LL | impl MyTrait for (MyType,) { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(MyType,)` + | + = note: upstream crates may add new impl of trait `lib::MyCopy` for type `(MyType,)` in future versions + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/coherence/coherence_copy_like_err_tuple.rs b/src/test/ui/coherence/coherence_copy_like_err_tuple.rs index 791ea1640f9e7..7234bed1ba0d0 100644 --- a/src/test/ui/coherence/coherence_copy_like_err_tuple.rs +++ b/src/test/ui/coherence/coherence_copy_like_err_tuple.rs @@ -2,6 +2,9 @@ // `MyType: !MyTrait` along with other "fundamental" wrappers. // aux-build:coherence_copy_like_lib.rs +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] extern crate coherence_copy_like_lib as lib; @@ -15,6 +18,8 @@ impl MyTrait for T { } // (MyType,): !MyTrait // // which we cannot approve. -impl MyTrait for (MyType,) { } //~ ERROR E0119 +impl MyTrait for (MyType,) { } +//[old]~^ ERROR E0119 +//[re]~^^ ERROR E0119 fn main() { } diff --git a/src/test/ui/coherence/coherence_inherent.stderr b/src/test/ui/coherence/coherence_inherent.old.stderr similarity index 80% rename from src/test/ui/coherence/coherence_inherent.stderr rename to src/test/ui/coherence/coherence_inherent.old.stderr index 3974cfe94adbe..fa564459b2133 100644 --- a/src/test/ui/coherence/coherence_inherent.stderr +++ b/src/test/ui/coherence/coherence_inherent.old.stderr @@ -1,7 +1,7 @@ error[E0599]: no method named `the_fn` found for type `&Lib::TheStruct` in the current scope - --> $DIR/coherence_inherent.rs:31:11 + --> $DIR/coherence_inherent.rs:35:11 | -LL | s.the_fn(); //~ ERROR no method named `the_fn` found +LL | s.the_fn(); | ^^^^^^ | = help: items from traits can only be used if the trait is in scope diff --git a/src/test/ui/coherence/coherence_inherent.re.stderr b/src/test/ui/coherence/coherence_inherent.re.stderr new file mode 100644 index 0000000000000..fa564459b2133 --- /dev/null +++ b/src/test/ui/coherence/coherence_inherent.re.stderr @@ -0,0 +1,13 @@ +error[E0599]: no method named `the_fn` found for type `&Lib::TheStruct` in the current scope + --> $DIR/coherence_inherent.rs:35:11 + | +LL | s.the_fn(); + | ^^^^^^ + | + = help: items from traits can only be used if the trait is in scope + = note: the following trait is implemented but not in scope, perhaps add a `use` for it: + `use Lib::TheTrait;` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/src/test/ui/coherence/coherence_inherent.rs b/src/test/ui/coherence/coherence_inherent.rs index f77f84bbb0c50..f0d3682adb8ca 100644 --- a/src/test/ui/coherence/coherence_inherent.rs +++ b/src/test/ui/coherence/coherence_inherent.rs @@ -1,6 +1,10 @@ // Tests that methods that implement a trait cannot be invoked // unless the trait is imported. +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] + mod Lib { pub trait TheTrait { fn the_fn(&self); @@ -28,7 +32,9 @@ mod NoImport { use Lib::TheStruct; fn call_the_fn(s: &TheStruct) { - s.the_fn(); //~ ERROR no method named `the_fn` found + s.the_fn(); + //[old]~^ ERROR no method named `the_fn` found + //[re]~^^ ERROR E0599 } } diff --git a/src/test/ui/coherence/coherence_inherent_cc.stderr b/src/test/ui/coherence/coherence_inherent_cc.old.stderr similarity index 81% rename from src/test/ui/coherence/coherence_inherent_cc.stderr rename to src/test/ui/coherence/coherence_inherent_cc.old.stderr index fcb3db711a0e1..4d93e699031f3 100644 --- a/src/test/ui/coherence/coherence_inherent_cc.stderr +++ b/src/test/ui/coherence/coherence_inherent_cc.old.stderr @@ -1,7 +1,7 @@ error[E0599]: no method named `the_fn` found for type `&coherence_inherent_cc_lib::TheStruct` in the current scope - --> $DIR/coherence_inherent_cc.rs:23:11 + --> $DIR/coherence_inherent_cc.rs:26:11 | -LL | s.the_fn(); //~ ERROR no method named `the_fn` found +LL | s.the_fn(); | ^^^^^^ | = help: items from traits can only be used if the trait is in scope diff --git a/src/test/ui/coherence/coherence_inherent_cc.re.stderr b/src/test/ui/coherence/coherence_inherent_cc.re.stderr new file mode 100644 index 0000000000000..4d93e699031f3 --- /dev/null +++ b/src/test/ui/coherence/coherence_inherent_cc.re.stderr @@ -0,0 +1,13 @@ +error[E0599]: no method named `the_fn` found for type `&coherence_inherent_cc_lib::TheStruct` in the current scope + --> $DIR/coherence_inherent_cc.rs:26:11 + | +LL | s.the_fn(); + | ^^^^^^ + | + = help: items from traits can only be used if the trait is in scope + = note: the following trait is implemented but not in scope, perhaps add a `use` for it: + `use coherence_inherent_cc_lib::TheTrait;` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/src/test/ui/coherence/coherence_inherent_cc.rs b/src/test/ui/coherence/coherence_inherent_cc.rs index 7ab10b2aa66b8..2c980d839b94b 100644 --- a/src/test/ui/coherence/coherence_inherent_cc.rs +++ b/src/test/ui/coherence/coherence_inherent_cc.rs @@ -1,4 +1,7 @@ // aux-build:coherence_inherent_cc_lib.rs +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] // Tests that methods that implement a trait cannot be invoked // unless the trait is imported. @@ -20,7 +23,9 @@ mod NoImport { use coherence_inherent_cc_lib::TheStruct; fn call_the_fn(s: &TheStruct) { - s.the_fn(); //~ ERROR no method named `the_fn` found + s.the_fn(); + //[old]~^ ERROR no method named `the_fn` found + //[re]~^^ ERROR E0599 } } diff --git a/src/test/ui/coherence/coherence_local.rs b/src/test/ui/coherence/coherence_local.rs index dc71253e3f78d..cac45b0b9edff 100644 --- a/src/test/ui/coherence/coherence_local.rs +++ b/src/test/ui/coherence/coherence_local.rs @@ -4,6 +4,9 @@ // aux-build:coherence_copy_like_lib.rs // compile-pass // skip-codegen +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] #![allow(dead_code)] extern crate coherence_copy_like_lib as lib; diff --git a/src/test/ui/coherence/coherence_local_err_struct.stderr b/src/test/ui/coherence/coherence_local_err_struct.old.stderr similarity index 78% rename from src/test/ui/coherence/coherence_local_err_struct.stderr rename to src/test/ui/coherence/coherence_local_err_struct.old.stderr index 7ff88c55b062c..61c94c1c7cad7 100644 --- a/src/test/ui/coherence/coherence_local_err_struct.stderr +++ b/src/test/ui/coherence/coherence_local_err_struct.old.stderr @@ -1,7 +1,7 @@ error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/coherence_local_err_struct.rs:16:1 + --> $DIR/coherence_local_err_struct.rs:17:1 | -LL | impl lib::MyCopy for lib::MyStruct { } //~ ERROR E0117 +LL | impl lib::MyCopy for lib::MyStruct { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | = note: the impl does not reference any types defined in this crate diff --git a/src/test/ui/coherence/coherence_local_err_struct.re.stderr b/src/test/ui/coherence/coherence_local_err_struct.re.stderr new file mode 100644 index 0000000000000..61c94c1c7cad7 --- /dev/null +++ b/src/test/ui/coherence/coherence_local_err_struct.re.stderr @@ -0,0 +1,12 @@ +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence_local_err_struct.rs:17:1 + | +LL | impl lib::MyCopy for lib::MyStruct { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/coherence/coherence_local_err_struct.rs b/src/test/ui/coherence/coherence_local_err_struct.rs index b94fc6c6abc0f..d6faaf2977a76 100644 --- a/src/test/ui/coherence/coherence_local_err_struct.rs +++ b/src/test/ui/coherence/coherence_local_err_struct.rs @@ -2,8 +2,9 @@ // `MyType: !MyTrait` along with other "fundamental" wrappers. // aux-build:coherence_copy_like_lib.rs +// revisions: old re - +#![cfg_attr(re, feature(re_rebalance_coherence))] #![allow(dead_code)] extern crate coherence_copy_like_lib as lib; @@ -13,7 +14,9 @@ struct MyType { x: i32 } // These are all legal because they are all fundamental types: // MyStruct is not fundamental. -impl lib::MyCopy for lib::MyStruct { } //~ ERROR E0117 +impl lib::MyCopy for lib::MyStruct { } +//[old]~^ ERROR E0117 +//[re]~^^ ERROR E0117 fn main() { } diff --git a/src/test/ui/coherence/coherence_local_err_tuple.stderr b/src/test/ui/coherence/coherence_local_err_tuple.old.stderr similarity index 80% rename from src/test/ui/coherence/coherence_local_err_tuple.stderr rename to src/test/ui/coherence/coherence_local_err_tuple.old.stderr index eab59579cb638..934e2fcb890e3 100644 --- a/src/test/ui/coherence/coherence_local_err_tuple.stderr +++ b/src/test/ui/coherence/coherence_local_err_tuple.old.stderr @@ -1,7 +1,7 @@ error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/coherence_local_err_tuple.rs:16:1 + --> $DIR/coherence_local_err_tuple.rs:17:1 | -LL | impl lib::MyCopy for (MyType,) { } //~ ERROR E0117 +LL | impl lib::MyCopy for (MyType,) { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | = note: the impl does not reference any types defined in this crate diff --git a/src/test/ui/coherence/coherence_local_err_tuple.re.stderr b/src/test/ui/coherence/coherence_local_err_tuple.re.stderr new file mode 100644 index 0000000000000..934e2fcb890e3 --- /dev/null +++ b/src/test/ui/coherence/coherence_local_err_tuple.re.stderr @@ -0,0 +1,12 @@ +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence_local_err_tuple.rs:17:1 + | +LL | impl lib::MyCopy for (MyType,) { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/coherence/coherence_local_err_tuple.rs b/src/test/ui/coherence/coherence_local_err_tuple.rs index 2e95a0f663d66..2685b2df8cb65 100644 --- a/src/test/ui/coherence/coherence_local_err_tuple.rs +++ b/src/test/ui/coherence/coherence_local_err_tuple.rs @@ -2,8 +2,9 @@ // `MyType: !MyTrait` along with other "fundamental" wrappers. // aux-build:coherence_copy_like_lib.rs +// revisions: old re - +#![cfg_attr(re, feature(re_rebalance_coherence))] #![allow(dead_code)] extern crate coherence_copy_like_lib as lib; @@ -13,7 +14,9 @@ struct MyType { x: i32 } // These are all legal because they are all fundamental types: // Tuples are not fundamental, so this is not a local impl. -impl lib::MyCopy for (MyType,) { } //~ ERROR E0117 +impl lib::MyCopy for (MyType,) { } +//[old]~^ ERROR E0117 +//[re]~^^ ERROR E0117 fn main() { } diff --git a/src/test/ui/coherence/coherence_local_ref.rs b/src/test/ui/coherence/coherence_local_ref.rs index f2978bcd960ab..a52510b8ea9ca 100644 --- a/src/test/ui/coherence/coherence_local_ref.rs +++ b/src/test/ui/coherence/coherence_local_ref.rs @@ -4,6 +4,9 @@ // aux-build:coherence_copy_like_lib.rs // compile-pass // skip-codegen +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] #![allow(dead_code)] extern crate coherence_copy_like_lib as lib; diff --git a/src/test/ui/coherence/re-rebalance-coherence.rs b/src/test/ui/coherence/re-rebalance-coherence.rs new file mode 100644 index 0000000000000..33ad4e9753661 --- /dev/null +++ b/src/test/ui/coherence/re-rebalance-coherence.rs @@ -0,0 +1,13 @@ +#![feature(re_rebalance_coherence)] + +// run-pass +// aux-build:re_rebalance_coherence_lib.rs + +extern crate re_rebalance_coherence_lib as lib; +use lib::*; + +struct Oracle; +impl Backend for Oracle {} +impl<'a, T:'a, Tab> QueryFragment for BatchInsert<'a, T, Tab> {} + +fn main() {} diff --git a/src/test/ui/conditional-compilation/cfg-attr-crate-2.rs b/src/test/ui/conditional-compilation/cfg-attr-crate-2.rs index 9345229704a67..0dceba28b6ec3 100644 --- a/src/test/ui/conditional-compilation/cfg-attr-crate-2.rs +++ b/src/test/ui/conditional-compilation/cfg-attr-crate-2.rs @@ -1,8 +1,8 @@ -// -// compile-flags: --cfg broken - // https://github.com/rust-lang/rust/issues/21833#issuecomment-72353044 +// compile-flags: --cfg broken + +#![crate_type = "lib"] #![cfg_attr(broken, no_core)] //~ ERROR no_core is experimental -fn main() { } +pub struct S {} diff --git a/src/test/ui/conditional-compilation/cfg-attr-multi-invalid-1.rs b/src/test/ui/conditional-compilation/cfg-attr-multi-invalid-1.rs index 0638f481ae569..16813a7623c77 100644 --- a/src/test/ui/conditional-compilation/cfg-attr-multi-invalid-1.rs +++ b/src/test/ui/conditional-compilation/cfg-attr-multi-invalid-1.rs @@ -1,7 +1,7 @@ -// // compile-flags: --cfg broken #![feature(cfg_attr_multi)] +#![crate_type = "lib"] #![cfg_attr(broken, no_core, no_std)] //~ ERROR no_core is experimental -fn main() { } +pub struct S {} diff --git a/src/test/ui/conditional-compilation/cfg-attr-multi-invalid-2.rs b/src/test/ui/conditional-compilation/cfg-attr-multi-invalid-2.rs index 26b4936ac70b2..39f8fc4b8b9f1 100644 --- a/src/test/ui/conditional-compilation/cfg-attr-multi-invalid-2.rs +++ b/src/test/ui/conditional-compilation/cfg-attr-multi-invalid-2.rs @@ -1,7 +1,7 @@ -// // compile-flags: --cfg broken #![feature(cfg_attr_multi)] +#![crate_type = "lib"] #![cfg_attr(broken, no_std, no_core)] //~ ERROR no_core is experimental -fn main() { } +pub struct S {} diff --git a/src/test/ui/consts/const-unsized.stderr b/src/test/ui/consts/const-unsized.stderr index cc00b77114483..0f996fcd94340 100644 --- a/src/test/ui/consts/const-unsized.stderr +++ b/src/test/ui/consts/const-unsized.stderr @@ -5,7 +5,7 @@ LL | const CONST_0: Debug+Sync = *(&0 as &(Debug+Sync)); | ^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn std::fmt::Debug + std::marker::Sync + 'static)` - = note: to learn more, visit + = note: to learn more, visit error[E0277]: the size for values of type `str` cannot be known at compilation time --> $DIR/const-unsized.rs:6:18 @@ -14,7 +14,7 @@ LL | const CONST_FOO: str = *"foo"; | ^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit error[E0277]: the size for values of type `(dyn std::fmt::Debug + std::marker::Sync + 'static)` cannot be known at compilation time --> $DIR/const-unsized.rs:9:18 @@ -23,7 +23,7 @@ LL | static STATIC_1: Debug+Sync = *(&1 as &(Debug+Sync)); | ^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn std::fmt::Debug + std::marker::Sync + 'static)` - = note: to learn more, visit + = note: to learn more, visit error[E0277]: the size for values of type `str` cannot be known at compilation time --> $DIR/const-unsized.rs:12:20 @@ -32,7 +32,7 @@ LL | static STATIC_BAR: str = *"bar"; | ^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit error: aborting due to 4 previous errors diff --git a/src/test/ui/dst/dst-bad-assign-2.stderr b/src/test/ui/dst/dst-bad-assign-2.stderr index 63c95c3154066..4e1e67c7f4809 100644 --- a/src/test/ui/dst/dst-bad-assign-2.stderr +++ b/src/test/ui/dst/dst-bad-assign-2.stderr @@ -5,7 +5,7 @@ LL | f5.ptr = *z; | ^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `dyn ToBar` - = note: to learn more, visit + = note: to learn more, visit = note: the left-hand-side of an assignment must have a statically known size error: aborting due to previous error diff --git a/src/test/ui/dst/dst-bad-assign-3.stderr b/src/test/ui/dst/dst-bad-assign-3.stderr index d0fe27e7bc2d6..0c4f86613196d 100644 --- a/src/test/ui/dst/dst-bad-assign-3.stderr +++ b/src/test/ui/dst/dst-bad-assign-3.stderr @@ -14,7 +14,7 @@ LL | f5.2 = Bar1 {f: 36}; | ^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `dyn ToBar` - = note: to learn more, visit + = note: to learn more, visit = note: the left-hand-side of an assignment must have a statically known size error: aborting due to 2 previous errors diff --git a/src/test/ui/dst/dst-bad-assign.stderr b/src/test/ui/dst/dst-bad-assign.stderr index 2ae732edd6893..a60d9d66f39e6 100644 --- a/src/test/ui/dst/dst-bad-assign.stderr +++ b/src/test/ui/dst/dst-bad-assign.stderr @@ -14,7 +14,7 @@ LL | f5.ptr = Bar1 {f: 36}; | ^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `dyn ToBar` - = note: to learn more, visit + = note: to learn more, visit = note: the left-hand-side of an assignment must have a statically known size error: aborting due to 2 previous errors diff --git a/src/test/ui/dst/dst-bad-deep-2.stderr b/src/test/ui/dst/dst-bad-deep-2.stderr index 6198c7eba57c0..cb2735147a35b 100644 --- a/src/test/ui/dst/dst-bad-deep-2.stderr +++ b/src/test/ui/dst/dst-bad-deep-2.stderr @@ -5,7 +5,7 @@ LL | let h: &(([isize],),) = &(*g,); | ^^^^^ doesn't have a size known at compile-time | = help: within `(([isize],),)`, the trait `std::marker::Sized` is not implemented for `[isize]` - = note: to learn more, visit + = note: to learn more, visit = note: required because it appears within the type `([isize],)` = note: required because it appears within the type `(([isize],),)` = note: tuples must have a statically known size to be initialized diff --git a/src/test/ui/dst/dst-bad-deep.stderr b/src/test/ui/dst/dst-bad-deep.stderr index 509dbfe8f1882..521adf601cc70 100644 --- a/src/test/ui/dst/dst-bad-deep.stderr +++ b/src/test/ui/dst/dst-bad-deep.stderr @@ -5,7 +5,7 @@ LL | let h: &Fat> = &Fat { ptr: *g }; | ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: within `Fat>`, the trait `std::marker::Sized` is not implemented for `[isize]` - = note: to learn more, visit + = note: to learn more, visit = note: required because it appears within the type `Fat<[isize]>` = note: required because it appears within the type `Fat>` = note: structs must have a statically known size to be initialized diff --git a/src/test/ui/dst/dst-object-from-unsized-type.stderr b/src/test/ui/dst/dst-object-from-unsized-type.stderr index 3b333ce5d28f1..4851ca108285f 100644 --- a/src/test/ui/dst/dst-object-from-unsized-type.stderr +++ b/src/test/ui/dst/dst-object-from-unsized-type.stderr @@ -5,7 +5,7 @@ LL | let u: &Foo = t; | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `T` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where T: std::marker::Sized` bound = note: required for the cast to the object type `dyn Foo` @@ -16,7 +16,7 @@ LL | let v: &Foo = t as &Foo; | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `T` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where T: std::marker::Sized` bound = note: required for the cast to the object type `dyn Foo` @@ -27,7 +27,7 @@ LL | let _: &[&Foo] = &["hi"]; | ^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit = note: required for the cast to the object type `dyn Foo` error[E0277]: the size for values of type `[u8]` cannot be known at compilation time @@ -37,7 +37,7 @@ LL | let _: &Foo = x as &Foo; | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[u8]` - = note: to learn more, visit + = note: to learn more, visit = note: required for the cast to the object type `dyn Foo` error: aborting due to 4 previous errors diff --git a/src/test/ui/dst/dst-sized-trait-param.stderr b/src/test/ui/dst/dst-sized-trait-param.stderr index e01bf2499da7e..40dc9978f367b 100644 --- a/src/test/ui/dst/dst-sized-trait-param.stderr +++ b/src/test/ui/dst/dst-sized-trait-param.stderr @@ -5,7 +5,7 @@ LL | impl Foo<[isize]> for usize { } | ^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[isize]` - = note: to learn more, visit + = note: to learn more, visit error[E0277]: the size for values of type `[usize]` cannot be known at compilation time --> $DIR/dst-sized-trait-param.rs:10:6 @@ -14,7 +14,7 @@ LL | impl Foo for [usize] { } | ^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[usize]` - = note: to learn more, visit + = note: to learn more, visit error: aborting due to 2 previous errors diff --git a/src/test/ui/error-codes/E0277.stderr b/src/test/ui/error-codes/E0277.stderr index 0cfe04afa2671..e5e416da883de 100644 --- a/src/test/ui/error-codes/E0277.stderr +++ b/src/test/ui/error-codes/E0277.stderr @@ -5,7 +5,7 @@ LL | fn f(p: Path) { } | ^ borrow the `Path` instead | = help: within `std::path::Path`, the trait `std::marker::Sized` is not implemented for `[u8]` - = note: to learn more, visit + = note: to learn more, visit = note: required because it appears within the type `std::path::Path` = note: all local variables must have a statically known size = help: unsized locals are gated as an unstable feature diff --git a/src/test/ui/extern/extern-types-unsized.stderr b/src/test/ui/extern/extern-types-unsized.stderr index 48d0aa8c601d6..4e4f5550fe833 100644 --- a/src/test/ui/extern/extern-types-unsized.stderr +++ b/src/test/ui/extern/extern-types-unsized.stderr @@ -5,7 +5,7 @@ LL | assert_sized::(); | ^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `A` - = note: to learn more, visit + = note: to learn more, visit note: required by `assert_sized` --> $DIR/extern-types-unsized.rs:19:1 | @@ -19,7 +19,7 @@ LL | assert_sized::(); | ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: within `Foo`, the trait `std::marker::Sized` is not implemented for `A` - = note: to learn more, visit + = note: to learn more, visit = note: required because it appears within the type `Foo` note: required by `assert_sized` --> $DIR/extern-types-unsized.rs:19:1 @@ -34,7 +34,7 @@ LL | assert_sized::>(); | ^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: within `Bar`, the trait `std::marker::Sized` is not implemented for `A` - = note: to learn more, visit + = note: to learn more, visit = note: required because it appears within the type `Bar` note: required by `assert_sized` --> $DIR/extern-types-unsized.rs:19:1 @@ -49,7 +49,7 @@ LL | assert_sized::>>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: within `Bar>`, the trait `std::marker::Sized` is not implemented for `A` - = note: to learn more, visit + = note: to learn more, visit = note: required because it appears within the type `Bar` = note: required because it appears within the type `Bar>` note: required by `assert_sized` diff --git a/src/test/ui/feature-gates/auxiliary/re_rebalance_coherence_lib.rs b/src/test/ui/feature-gates/auxiliary/re_rebalance_coherence_lib.rs new file mode 100644 index 0000000000000..c8d027b25c748 --- /dev/null +++ b/src/test/ui/feature-gates/auxiliary/re_rebalance_coherence_lib.rs @@ -0,0 +1,23 @@ + +pub trait Backend{} +pub trait SupportsDefaultKeyword {} + +impl SupportsDefaultKeyword for Postgres {} + +pub struct Postgres; + +impl Backend for Postgres {} + +pub struct AstPass(::std::marker::PhantomData); + +pub trait QueryFragment {} + + +#[derive(Debug, Clone, Copy)] +pub struct BatchInsert<'a, T: 'a, Tab> { + _marker: ::std::marker::PhantomData<(&'a T, Tab)>, +} + +impl<'a, T:'a, Tab, DB> QueryFragment for BatchInsert<'a, T, Tab> +where DB: SupportsDefaultKeyword + Backend, +{} diff --git a/src/test/ui/feature-gates/feature-gate-alloc-error-handler.rs b/src/test/ui/feature-gates/feature-gate-alloc-error-handler.rs index fbd9291afbe03..daa2bb5d6fafc 100644 --- a/src/test/ui/feature-gates/feature-gate-alloc-error-handler.rs +++ b/src/test/ui/feature-gates/feature-gate-alloc-error-handler.rs @@ -9,3 +9,6 @@ use core::alloc::Layout; fn oom(info: Layout) -> ! { loop {} } + +#[panic_handler] +fn panic(_: &core::panic::PanicInfo) -> ! { loop {} } diff --git a/src/test/ui/feature-gates/feature-gate-allow_fail.rs b/src/test/ui/feature-gates/feature-gate-allow_fail.rs index cd8b096294261..f9ad48551410c 100644 --- a/src/test/ui/feature-gates/feature-gate-allow_fail.rs +++ b/src/test/ui/feature-gates/feature-gate-allow_fail.rs @@ -5,3 +5,4 @@ fn ok_to_fail() { assert!(false); } +fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-async-await-2015-edition.rs b/src/test/ui/feature-gates/feature-gate-async-await-2015-edition.rs index 00a3103af2cbc..84dd1b9f814c2 100644 --- a/src/test/ui/feature-gates/feature-gate-async-await-2015-edition.rs +++ b/src/test/ui/feature-gates/feature-gate-async-await-2015-edition.rs @@ -6,5 +6,5 @@ async fn foo() {} //~ ERROR async fn is unstable fn main() { let _ = async {}; //~ ERROR cannot find struct, variant or union type `async` - let _ = async || {}; //~ ERROR cannot find value `async` in this scope + let _ = async || { true }; //~ ERROR cannot find value `async` in this scope } diff --git a/src/test/ui/feature-gates/feature-gate-async-await-2015-edition.stderr b/src/test/ui/feature-gates/feature-gate-async-await-2015-edition.stderr index 7754dbb3b3736..450b2c42f119d 100644 --- a/src/test/ui/feature-gates/feature-gate-async-await-2015-edition.stderr +++ b/src/test/ui/feature-gates/feature-gate-async-await-2015-edition.stderr @@ -7,7 +7,7 @@ LL | let _ = async {}; //~ ERROR cannot find struct, variant or union type ` error[E0425]: cannot find value `async` in this scope --> $DIR/feature-gate-async-await-2015-edition.rs:9:13 | -LL | let _ = async || {}; //~ ERROR cannot find value `async` in this scope +LL | let _ = async || { true }; //~ ERROR cannot find value `async` in this scope | ^^^^^ not found in this scope error[E0658]: async fn is unstable (see issue #50547) diff --git a/src/test/ui/feature-gates/feature-gate-const_fn.rs b/src/test/ui/feature-gates/feature-gate-const_fn.rs index 5a0a5ac9edc6c..f46d1dc13d3f0 100644 --- a/src/test/ui/feature-gates/feature-gate-const_fn.rs +++ b/src/test/ui/feature-gates/feature-gate-const_fn.rs @@ -9,14 +9,16 @@ trait Foo { //~| ERROR trait fns cannot be declared const } -impl Foo { - const fn baz() -> u32 { 0 } // ok -} - impl Foo for u32 { const fn foo() -> u32 { 0 } //~ ERROR trait fns cannot be declared const } +trait Bar {} + +impl dyn Bar { + const fn baz() -> u32 { 0 } // ok +} + static FOO: usize = foo(); const BAR: usize = foo(); diff --git a/src/test/ui/feature-gates/feature-gate-const_fn.stderr b/src/test/ui/feature-gates/feature-gate-const_fn.stderr index 32a57719edbe5..b3fc587b1cf77 100644 --- a/src/test/ui/feature-gates/feature-gate-const_fn.stderr +++ b/src/test/ui/feature-gates/feature-gate-const_fn.stderr @@ -11,7 +11,7 @@ LL | const fn bar() -> u32 { 0 } //~ ERROR const fn is unstable | ^^^^^ trait fns cannot be const error[E0379]: trait fns cannot be declared const - --> $DIR/feature-gate-const_fn.rs:17:5 + --> $DIR/feature-gate-const_fn.rs:13:5 | LL | const fn foo() -> u32 { 0 } //~ ERROR trait fns cannot be declared const | ^^^^^ trait fns cannot be const diff --git a/src/test/ui/feature-gates/feature-gate-doc_keyword.rs b/src/test/ui/feature-gates/feature-gate-doc_keyword.rs index f417828db15ad..b08940e28f443 100644 --- a/src/test/ui/feature-gates/feature-gate-doc_keyword.rs +++ b/src/test/ui/feature-gates/feature-gate-doc_keyword.rs @@ -1,3 +1,5 @@ #[doc(keyword = "match")] //~ ERROR: #[doc(keyword = "...")] is experimental /// wonderful mod foo{} + +fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-dropck-ugeh.rs b/src/test/ui/feature-gates/feature-gate-dropck-ugeh.rs index 02aa5000661d3..a2377cda9bd66 100644 --- a/src/test/ui/feature-gates/feature-gate-dropck-ugeh.rs +++ b/src/test/ui/feature-gates/feature-gate-dropck-ugeh.rs @@ -1,14 +1,11 @@ // gate-test-dropck_parametricity // Ensure that attempts to use the unsafe attribute are feature-gated. - // Example adapted from RFC 1238 text (just left out the feature gate). // https://github.com/rust-lang/rfcs/blob/master/text/1238-nonparametric-dropck.md // #example-of-the-unguarded-escape-hatch -// #![feature(dropck_parametricity)] - use std::cell::Cell; struct Concrete<'a>(u32, Cell>>); @@ -18,6 +15,7 @@ struct Foo { data: Vec } impl Drop for Foo { #[unsafe_destructor_blind_to_params] // This is the UGEH attribute //~^ ERROR unsafe_destructor_blind_to_params has been replaced + //~| WARN use of deprecated attribute `dropck_parametricity` fn drop(&mut self) { } } @@ -29,4 +27,3 @@ fn main() { foo.data[0].1.set(Some(&foo.data[1])); foo.data[1].1.set(Some(&foo.data[0])); } - diff --git a/src/test/ui/feature-gates/feature-gate-dropck-ugeh.stderr b/src/test/ui/feature-gates/feature-gate-dropck-ugeh.stderr index 99ca454bcabab..bc62fc01b4438 100644 --- a/src/test/ui/feature-gates/feature-gate-dropck-ugeh.stderr +++ b/src/test/ui/feature-gates/feature-gate-dropck-ugeh.stderr @@ -1,11 +1,19 @@ error[E0658]: unsafe_destructor_blind_to_params has been replaced by may_dangle and will be removed in the future (see issue #28498) - --> $DIR/feature-gate-dropck-ugeh.rs:19:5 + --> $DIR/feature-gate-dropck-ugeh.rs:16:5 | LL | #[unsafe_destructor_blind_to_params] // This is the UGEH attribute | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: add #![feature(dropck_parametricity)] to the crate attributes to enable +warning: use of deprecated attribute `dropck_parametricity`: unsafe_destructor_blind_to_params has been replaced by may_dangle and will be removed in the future. See https://github.com/rust-lang/rust/issues/34761 + --> $DIR/feature-gate-dropck-ugeh.rs:16:5 + | +LL | #[unsafe_destructor_blind_to_params] // This is the UGEH attribute + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace this attribute with `#[may_dangle]` + | + = note: #[warn(deprecated)] on by default + error: aborting due to previous error For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/feature-gates/feature-gate-existential-type.rs b/src/test/ui/feature-gates/feature-gate-existential-type.rs index e14467d6c3eb5..6dfd2d10870e0 100644 --- a/src/test/ui/feature-gates/feature-gate-existential-type.rs +++ b/src/test/ui/feature-gates/feature-gate-existential-type.rs @@ -1,15 +1,17 @@ // Check that existential types must be ungated to use the `existential` keyword - - existential type Foo: std::fmt::Debug; //~ ERROR existential types are unstable trait Bar { type Baa: std::fmt::Debug; + fn define() -> Self::Baa; } impl Bar for () { existential type Baa: std::fmt::Debug; //~ ERROR existential types are unstable + fn define() -> Self::Baa { 0 } } +fn define() -> Foo { 0 } + fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-existential-type.stderr b/src/test/ui/feature-gates/feature-gate-existential-type.stderr index e88bdc01fdc19..e83d5cdbde1e6 100644 --- a/src/test/ui/feature-gates/feature-gate-existential-type.stderr +++ b/src/test/ui/feature-gates/feature-gate-existential-type.stderr @@ -1,5 +1,5 @@ error[E0658]: existential types are unstable (see issue #34511) - --> $DIR/feature-gate-existential-type.rs:5:1 + --> $DIR/feature-gate-existential-type.rs:3:1 | LL | existential type Foo: std::fmt::Debug; //~ ERROR existential types are unstable | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | existential type Foo: std::fmt::Debug; //~ ERROR existential types are unst = help: add #![feature(existential_type)] to the crate attributes to enable error[E0658]: existential types are unstable (see issue #34511) - --> $DIR/feature-gate-existential-type.rs:12:5 + --> $DIR/feature-gate-existential-type.rs:11:5 | LL | existential type Baa: std::fmt::Debug; //~ ERROR existential types are unstable | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/feature-gates/feature-gate-generators.rs b/src/test/ui/feature-gates/feature-gate-generators.rs index 88e8781d2b9ba..cee930fd785b9 100644 --- a/src/test/ui/feature-gates/feature-gate-generators.rs +++ b/src/test/ui/feature-gates/feature-gate-generators.rs @@ -1,3 +1,4 @@ fn main() { yield true; //~ ERROR yield syntax is experimental + //~^ ERROR yield statement outside of generator literal } diff --git a/src/test/ui/feature-gates/feature-gate-generators.stderr b/src/test/ui/feature-gates/feature-gate-generators.stderr index 4b90cd1c1f8e4..aea1e00d698a6 100644 --- a/src/test/ui/feature-gates/feature-gate-generators.stderr +++ b/src/test/ui/feature-gates/feature-gate-generators.stderr @@ -6,6 +6,13 @@ LL | yield true; //~ ERROR yield syntax is experimental | = help: add #![feature(generators)] to the crate attributes to enable -error: aborting due to previous error +error[E0627]: yield statement outside of generator literal + --> $DIR/feature-gate-generators.rs:2:5 + | +LL | yield true; //~ ERROR yield syntax is experimental + | ^^^^^^^^^^ + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0658`. +Some errors occurred: E0627, E0658. +For more information about an error, try `rustc --explain E0627`. diff --git a/src/test/ui/feature-gates/feature-gate-generic_associated_types.rs b/src/test/ui/feature-gates/feature-gate-generic_associated_types.rs index 86a1f5ca4d5d5..17548d7b9e88c 100644 --- a/src/test/ui/feature-gates/feature-gate-generic_associated_types.rs +++ b/src/test/ui/feature-gates/feature-gate-generic_associated_types.rs @@ -11,9 +11,9 @@ trait PointerFamily { struct Foo; impl PointerFamily for Foo { - type Pointer = Box; + type Pointer = Box; //~^ ERROR generic associated types are unstable - type Pointer2 = Box; + type Pointer2 = Box; //~^ ERROR generic associated types are unstable } diff --git a/src/test/ui/feature-gates/feature-gate-generic_associated_types.stderr b/src/test/ui/feature-gates/feature-gate-generic_associated_types.stderr index 392d0f1bd7e15..8a207c966cdab 100644 --- a/src/test/ui/feature-gates/feature-gate-generic_associated_types.stderr +++ b/src/test/ui/feature-gates/feature-gate-generic_associated_types.stderr @@ -25,7 +25,7 @@ LL | type Pointer2: Deref where T: Clone, U: Clone; error[E0658]: generic associated types are unstable (see issue #44265) --> $DIR/feature-gate-generic_associated_types.rs:14:5 | -LL | type Pointer = Box; +LL | type Pointer = Box; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: add #![feature(generic_associated_types)] to the crate attributes to enable @@ -33,7 +33,7 @@ LL | type Pointer = Box; error[E0658]: generic associated types are unstable (see issue #44265) --> $DIR/feature-gate-generic_associated_types.rs:16:5 | -LL | type Pointer2 = Box; +LL | type Pointer2 = Box; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: add #![feature(generic_associated_types)] to the crate attributes to enable diff --git a/src/test/ui/feature-gates/feature-gate-intrinsics.rs b/src/test/ui/feature-gates/feature-gate-intrinsics.rs index 0916d7fcd36d3..d1da94338283b 100644 --- a/src/test/ui/feature-gates/feature-gate-intrinsics.rs +++ b/src/test/ui/feature-gates/feature-gate-intrinsics.rs @@ -1,9 +1,7 @@ extern "rust-intrinsic" { //~ ERROR intrinsics are subject to change - fn bar(); + fn bar(); //~ ERROR unrecognized intrinsic function: `bar` } -extern "rust-intrinsic" fn baz() { //~ ERROR intrinsics are subject to change -} +extern "rust-intrinsic" fn baz() {} //~ ERROR intrinsics are subject to change -fn main() { -} +fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-intrinsics.stderr b/src/test/ui/feature-gates/feature-gate-intrinsics.stderr index 034e2b1b588b5..092cb98a2f963 100644 --- a/src/test/ui/feature-gates/feature-gate-intrinsics.stderr +++ b/src/test/ui/feature-gates/feature-gate-intrinsics.stderr @@ -2,7 +2,7 @@ error[E0658]: intrinsics are subject to change --> $DIR/feature-gate-intrinsics.rs:1:1 | LL | / extern "rust-intrinsic" { //~ ERROR intrinsics are subject to change -LL | | fn bar(); +LL | | fn bar(); //~ ERROR unrecognized intrinsic function: `bar` LL | | } | |_^ | @@ -11,12 +11,18 @@ LL | | } error[E0658]: intrinsics are subject to change --> $DIR/feature-gate-intrinsics.rs:5:1 | -LL | / extern "rust-intrinsic" fn baz() { //~ ERROR intrinsics are subject to change -LL | | } - | |_^ +LL | extern "rust-intrinsic" fn baz() {} //~ ERROR intrinsics are subject to change + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: add #![feature(intrinsics)] to the crate attributes to enable -error: aborting due to 2 previous errors +error[E0093]: unrecognized intrinsic function: `bar` + --> $DIR/feature-gate-intrinsics.rs:2:5 + | +LL | fn bar(); //~ ERROR unrecognized intrinsic function: `bar` + | ^^^^^^^^^ unrecognized intrinsic + +error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0658`. +Some errors occurred: E0093, E0658. +For more information about an error, try `rustc --explain E0093`. diff --git a/src/test/ui/feature-gates/feature-gate-lang-items.rs b/src/test/ui/feature-gates/feature-gate-lang-items.rs index 943ca161d678d..93262f2171bfe 100644 --- a/src/test/ui/feature-gates/feature-gate-lang-items.rs +++ b/src/test/ui/feature-gates/feature-gate-lang-items.rs @@ -1,5 +1,5 @@ -#[lang="foo"] //~ ERROR language items are subject to change +#[lang = "foo"] //~ ERROR language items are subject to change + //~^ ERROR definition of an unknown language item: `foo` trait Foo {} -fn main() { -} +fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-lang-items.stderr b/src/test/ui/feature-gates/feature-gate-lang-items.stderr index 3383eaab01f32..ccbb711fe6d43 100644 --- a/src/test/ui/feature-gates/feature-gate-lang-items.stderr +++ b/src/test/ui/feature-gates/feature-gate-lang-items.stderr @@ -1,11 +1,18 @@ error[E0658]: language items are subject to change --> $DIR/feature-gate-lang-items.rs:1:1 | -LL | #[lang="foo"] //~ ERROR language items are subject to change - | ^^^^^^^^^^^^^ +LL | #[lang = "foo"] //~ ERROR language items are subject to change + | ^^^^^^^^^^^^^^^ | = help: add #![feature(lang_items)] to the crate attributes to enable -error: aborting due to previous error +error[E0522]: definition of an unknown language item: `foo` + --> $DIR/feature-gate-lang-items.rs:1:1 + | +LL | #[lang = "foo"] //~ ERROR language items are subject to change + | ^^^^^^^^^^^^^^^ definition of unknown language item `foo` + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0658`. +Some errors occurred: E0522, E0658. +For more information about an error, try `rustc --explain E0522`. diff --git a/src/test/ui/feature-gates/feature-gate-linkage.rs b/src/test/ui/feature-gates/feature-gate-linkage.rs index 282c9a8b843f9..70f33cc0c6cc7 100644 --- a/src/test/ui/feature-gates/feature-gate-linkage.rs +++ b/src/test/ui/feature-gates/feature-gate-linkage.rs @@ -2,3 +2,5 @@ extern { #[linkage = "extern_weak"] static foo: isize; //~^ ERROR: the `linkage` attribute is experimental and not portable } + +fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-may-dangle.rs b/src/test/ui/feature-gates/feature-gate-may-dangle.rs index 45666e90b210a..20896e426f65d 100644 --- a/src/test/ui/feature-gates/feature-gate-may-dangle.rs +++ b/src/test/ui/feature-gates/feature-gate-may-dangle.rs @@ -3,7 +3,9 @@ // Check that `may_dangle` is rejected if `dropck_eyepatch` feature gate is absent. struct Pt(A); -impl<#[may_dangle] A> Drop for Pt { +unsafe impl<#[may_dangle] A> Drop for Pt { //~^ ERROR may_dangle has unstable semantics and may be removed in the future fn drop(&mut self) { } } + +fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-may-dangle.stderr b/src/test/ui/feature-gates/feature-gate-may-dangle.stderr index b537a5815886f..6d21147c9eeb3 100644 --- a/src/test/ui/feature-gates/feature-gate-may-dangle.stderr +++ b/src/test/ui/feature-gates/feature-gate-may-dangle.stderr @@ -1,8 +1,8 @@ error[E0658]: may_dangle has unstable semantics and may be removed in the future (see issue #34761) - --> $DIR/feature-gate-may-dangle.rs:6:6 + --> $DIR/feature-gate-may-dangle.rs:6:13 | -LL | impl<#[may_dangle] A> Drop for Pt { - | ^^^^^^^^^^^^^ +LL | unsafe impl<#[may_dangle] A> Drop for Pt { + | ^^^^^^^^^^^^^ | = help: add #![feature(dropck_eyepatch)] to the crate attributes to enable diff --git a/src/test/ui/feature-gates/feature-gate-min_const_fn.rs b/src/test/ui/feature-gates/feature-gate-min_const_fn.rs index e685b500ff3bb..669631df2ad17 100644 --- a/src/test/ui/feature-gates/feature-gate-min_const_fn.rs +++ b/src/test/ui/feature-gates/feature-gate-min_const_fn.rs @@ -9,14 +9,16 @@ trait Foo { //~| ERROR trait fns cannot be declared const } -impl Foo { - const fn baz() -> u32 { 0 } // stabilized -} - impl Foo for u32 { const fn foo() -> u32 { 0 } //~ ERROR trait fns cannot be declared const } +trait Bar {} + +impl dyn Bar { + const fn baz() -> u32 { 0 } // stabilized +} + static FOO: usize = foo(); const BAR: usize = foo(); diff --git a/src/test/ui/feature-gates/feature-gate-min_const_fn.stderr b/src/test/ui/feature-gates/feature-gate-min_const_fn.stderr index 998a2243edcfa..bcc5b0198c319 100644 --- a/src/test/ui/feature-gates/feature-gate-min_const_fn.stderr +++ b/src/test/ui/feature-gates/feature-gate-min_const_fn.stderr @@ -11,7 +11,7 @@ LL | const fn bar() -> u32 { 0 } //~ ERROR const fn is unstable | ^^^^^ trait fns cannot be const error[E0379]: trait fns cannot be declared const - --> $DIR/feature-gate-min_const_fn.rs:17:5 + --> $DIR/feature-gate-min_const_fn.rs:13:5 | LL | const fn foo() -> u32 { 0 } //~ ERROR trait fns cannot be declared const | ^^^^^ trait fns cannot be const diff --git a/src/test/ui/feature-gates/feature-gate-naked_functions.rs b/src/test/ui/feature-gates/feature-gate-naked_functions.rs index 36bc636b0bb7b..16a51a1e82fc6 100644 --- a/src/test/ui/feature-gates/feature-gate-naked_functions.rs +++ b/src/test/ui/feature-gates/feature-gate-naked_functions.rs @@ -7,3 +7,5 @@ fn naked() {} fn naked_2() -> isize { 0 } + +fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-never_type.rs b/src/test/ui/feature-gates/feature-gate-never_type.rs index 44a3bdd2ca36b..be8c27dbb1b02 100644 --- a/src/test/ui/feature-gates/feature-gate-never_type.rs +++ b/src/test/ui/feature-gates/feature-gate-never_type.rs @@ -6,8 +6,8 @@ trait Foo { type Ma = (u32, !, i32); //~ ERROR type is experimental type Meeshka = Vec; //~ ERROR type is experimental -type Mow = &fn(!) -> !; //~ ERROR type is experimental -type Skwoz = &mut !; //~ ERROR type is experimental +type Mow = &'static fn(!) -> !; //~ ERROR type is experimental +type Skwoz = &'static mut !; //~ ERROR type is experimental impl Foo for Meeshka { type Wub = !; //~ ERROR type is experimental diff --git a/src/test/ui/feature-gates/feature-gate-never_type.stderr b/src/test/ui/feature-gates/feature-gate-never_type.stderr index 927758b67b9cc..c4f8771171e8b 100644 --- a/src/test/ui/feature-gates/feature-gate-never_type.stderr +++ b/src/test/ui/feature-gates/feature-gate-never_type.stderr @@ -15,18 +15,18 @@ LL | type Meeshka = Vec; //~ ERROR type is experimental = help: add #![feature(never_type)] to the crate attributes to enable error[E0658]: The `!` type is experimental (see issue #35121) - --> $DIR/feature-gate-never_type.rs:9:16 + --> $DIR/feature-gate-never_type.rs:9:24 | -LL | type Mow = &fn(!) -> !; //~ ERROR type is experimental - | ^ +LL | type Mow = &'static fn(!) -> !; //~ ERROR type is experimental + | ^ | = help: add #![feature(never_type)] to the crate attributes to enable error[E0658]: The `!` type is experimental (see issue #35121) - --> $DIR/feature-gate-never_type.rs:10:19 + --> $DIR/feature-gate-never_type.rs:10:27 | -LL | type Skwoz = &mut !; //~ ERROR type is experimental - | ^ +LL | type Skwoz = &'static mut !; //~ ERROR type is experimental + | ^ | = help: add #![feature(never_type)] to the crate attributes to enable diff --git a/src/test/ui/feature-gates/feature-gate-no_core.rs b/src/test/ui/feature-gates/feature-gate-no_core.rs index 03b237867aa91..40178edd74b8d 100644 --- a/src/test/ui/feature-gates/feature-gate-no_core.rs +++ b/src/test/ui/feature-gates/feature-gate-no_core.rs @@ -1,3 +1,5 @@ +#![crate_type = "rlib"] + #![no_core] //~ ERROR no_core is experimental -fn main() {} +pub struct S {} diff --git a/src/test/ui/feature-gates/feature-gate-no_core.stderr b/src/test/ui/feature-gates/feature-gate-no_core.stderr index cb8fe25df58a2..7390051b95da2 100644 --- a/src/test/ui/feature-gates/feature-gate-no_core.stderr +++ b/src/test/ui/feature-gates/feature-gate-no_core.stderr @@ -1,5 +1,5 @@ error[E0658]: no_core is experimental (see issue #29639) - --> $DIR/feature-gate-no_core.rs:1:1 + --> $DIR/feature-gate-no_core.rs:3:1 | LL | #![no_core] //~ ERROR no_core is experimental | ^^^^^^^^^^^ diff --git a/src/test/ui/feature-gates/feature-gate-optin-builtin-traits.rs b/src/test/ui/feature-gates/feature-gate-optin-builtin-traits.rs index 9d70cbee53b09..35c05b75d365c 100644 --- a/src/test/ui/feature-gates/feature-gate-optin-builtin-traits.rs +++ b/src/test/ui/feature-gates/feature-gate-optin-builtin-traits.rs @@ -3,14 +3,10 @@ struct DummyStruct; -trait DummyTrait { - fn dummy(&self) {} -} - auto trait AutoDummyTrait {} //~^ ERROR auto traits are experimental and possibly buggy -impl !DummyTrait for DummyStruct {} +impl !AutoDummyTrait for DummyStruct {} //~^ ERROR negative trait bounds are not yet fully implemented; use marker types for now fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-optin-builtin-traits.stderr b/src/test/ui/feature-gates/feature-gate-optin-builtin-traits.stderr index c523147611a81..e5d0a8681fb45 100644 --- a/src/test/ui/feature-gates/feature-gate-optin-builtin-traits.stderr +++ b/src/test/ui/feature-gates/feature-gate-optin-builtin-traits.stderr @@ -1,5 +1,5 @@ error[E0658]: auto traits are experimental and possibly buggy (see issue #13231) - --> $DIR/feature-gate-optin-builtin-traits.rs:10:1 + --> $DIR/feature-gate-optin-builtin-traits.rs:6:1 | LL | auto trait AutoDummyTrait {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -7,10 +7,10 @@ LL | auto trait AutoDummyTrait {} = help: add #![feature(optin_builtin_traits)] to the crate attributes to enable error[E0658]: negative trait bounds are not yet fully implemented; use marker types for now (see issue #13231) - --> $DIR/feature-gate-optin-builtin-traits.rs:13:1 + --> $DIR/feature-gate-optin-builtin-traits.rs:9:1 | -LL | impl !DummyTrait for DummyStruct {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | impl !AutoDummyTrait for DummyStruct {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: add #![feature(optin_builtin_traits)] to the crate attributes to enable diff --git a/src/test/ui/feature-gates/feature-gate-re-rebalance-coherence.rs b/src/test/ui/feature-gates/feature-gate-re-rebalance-coherence.rs new file mode 100644 index 0000000000000..505a45379cdca --- /dev/null +++ b/src/test/ui/feature-gates/feature-gate-re-rebalance-coherence.rs @@ -0,0 +1,13 @@ +// Test that the use of the box syntax is gated by `re-rebalance-coherence` feature gate. + +// aux-build:re_rebalance_coherence_lib.rs + +extern crate re_rebalance_coherence_lib as lib; +use lib::*; + +struct Oracle; +impl Backend for Oracle {} +impl<'a, T:'a, Tab> QueryFragment for BatchInsert<'a, T, Tab> {} +//~^ ERROR E0210 + +fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-re-rebalance-coherence.stderr b/src/test/ui/feature-gates/feature-gate-re-rebalance-coherence.stderr new file mode 100644 index 0000000000000..5972e610e47d6 --- /dev/null +++ b/src/test/ui/feature-gates/feature-gate-re-rebalance-coherence.stderr @@ -0,0 +1,11 @@ +error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) + --> $DIR/feature-gate-re-rebalance-coherence.rs:10:1 + | +LL | impl<'a, T:'a, Tab> QueryFragment for BatchInsert<'a, T, Tab> {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | + = note: only traits defined in the current crate can be implemented for a type parameter + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0210`. diff --git a/src/test/ui/feature-gates/feature-gate-repr-simd.rs b/src/test/ui/feature-gates/feature-gate-repr-simd.rs index 67ae538e22c9d..9d28f437415c9 100644 --- a/src/test/ui/feature-gates/feature-gate-repr-simd.rs +++ b/src/test/ui/feature-gates/feature-gate-repr-simd.rs @@ -1,7 +1,7 @@ #[repr(simd)] //~ error: SIMD types are experimental struct Foo(u64, u64); -#[repr(C)] +#[repr(C)] //~ warn: conflicting representation hints #[repr(simd)] //~ error: SIMD types are experimental struct Bar(u64, u64); diff --git a/src/test/ui/feature-gates/feature-gate-repr-simd.stderr b/src/test/ui/feature-gates/feature-gate-repr-simd.stderr index 161cc67e81344..20cdbceeb689a 100644 --- a/src/test/ui/feature-gates/feature-gate-repr-simd.stderr +++ b/src/test/ui/feature-gates/feature-gate-repr-simd.stderr @@ -14,6 +14,15 @@ LL | #[repr(simd)] //~ error: SIMD types are experimental | = help: add #![feature(repr_simd)] to the crate attributes to enable +warning[E0566]: conflicting representation hints + --> $DIR/feature-gate-repr-simd.rs:4:8 + | +LL | #[repr(C)] //~ warn: conflicting representation hints + | ^ +LL | #[repr(simd)] //~ error: SIMD types are experimental + | ^^^^ + error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0658`. +Some errors occurred: E0566, E0658. +For more information about an error, try `rustc --explain E0566`. diff --git a/src/test/ui/feature-gates/feature-gate-rustc-attrs-1.rs b/src/test/ui/feature-gates/feature-gate-rustc-attrs-1.rs index f7ff3eb3ac9ff..2b23388fdc96d 100644 --- a/src/test/ui/feature-gates/feature-gate-rustc-attrs-1.rs +++ b/src/test/ui/feature-gates/feature-gate-rustc-attrs-1.rs @@ -5,4 +5,4 @@ #[rustc_variance] //~ ERROR the `#[rustc_variance]` attribute is just used for rustc unit tests and will never be stable #[rustc_error] //~ ERROR the `#[rustc_error]` attribute is just used for rustc unit tests and will never be stable -fn main() {} +fn main() {} //~ ERROR [] diff --git a/src/test/ui/feature-gates/feature-gate-rustc-attrs-1.stderr b/src/test/ui/feature-gates/feature-gate-rustc-attrs-1.stderr index 2b90699384b48..31e24f5b99f1e 100644 --- a/src/test/ui/feature-gates/feature-gate-rustc-attrs-1.stderr +++ b/src/test/ui/feature-gates/feature-gate-rustc-attrs-1.stderr @@ -14,6 +14,13 @@ LL | #[rustc_error] //~ ERROR the `#[rustc_error]` attribute is just used for ru | = help: add #![feature(rustc_attrs)] to the crate attributes to enable -error: aborting due to 2 previous errors +error[E0208]: [] + --> $DIR/feature-gate-rustc-attrs-1.rs:8:1 + | +LL | fn main() {} //~ ERROR [] + | ^^^^^^^^^^^^ + +error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0658`. +Some errors occurred: E0208, E0658. +For more information about an error, try `rustc --explain E0208`. diff --git a/src/test/ui/feature-gates/feature-gate-start.rs b/src/test/ui/feature-gates/feature-gate-start.rs index bf097c8203156..46a1279a3fb16 100644 --- a/src/test/ui/feature-gates/feature-gate-start.rs +++ b/src/test/ui/feature-gates/feature-gate-start.rs @@ -1,2 +1,3 @@ #[start] -fn foo() {} //~ ERROR: a #[start] function is an experimental feature +fn foo(_: isize, _: *const *const u8) -> isize { 0 } +//~^ ERROR a #[start] function is an experimental feature diff --git a/src/test/ui/feature-gates/feature-gate-start.stderr b/src/test/ui/feature-gates/feature-gate-start.stderr index 255703d767388..d39e5f3555537 100644 --- a/src/test/ui/feature-gates/feature-gate-start.stderr +++ b/src/test/ui/feature-gates/feature-gate-start.stderr @@ -1,8 +1,8 @@ error[E0658]: a #[start] function is an experimental feature whose signature may change over time (see issue #29633) --> $DIR/feature-gate-start.rs:2:1 | -LL | fn foo() {} //~ ERROR: a #[start] function is an experimental feature - | ^^^^^^^^^^^ +LL | fn foo(_: isize, _: *const *const u8) -> isize { 0 } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: add #![feature(start)] to the crate attributes to enable diff --git a/src/test/ui/feature-gates/feature-gate-thread_local.rs b/src/test/ui/feature-gates/feature-gate-thread_local.rs index c47bdc1006c72..0efae1f6bc356 100644 --- a/src/test/ui/feature-gates/feature-gate-thread_local.rs +++ b/src/test/ui/feature-gates/feature-gate-thread_local.rs @@ -8,8 +8,4 @@ #[thread_local] //~ ERROR `#[thread_local]` is an experimental feature static FOO: i32 = 3; -pub fn main() { - FOO.with(|x| { - println!("x: {}", x); - }); -} +pub fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-trivial_bounds.stderr b/src/test/ui/feature-gates/feature-gate-trivial_bounds.stderr index 34c457875ec16..1f35efa59b690 100644 --- a/src/test/ui/feature-gates/feature-gate-trivial_bounds.stderr +++ b/src/test/ui/feature-gates/feature-gate-trivial_bounds.stderr @@ -95,7 +95,7 @@ LL | struct TwoStrs(str, str) where str: Sized; //~ ERROR | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit = help: see issue #48214 = help: add #![feature(trivial_bounds)] to the crate attributes to enable @@ -108,7 +108,7 @@ LL | | } | |_^ doesn't have a size known at compile-time | = help: within `Dst<(dyn A + 'static)>`, the trait `std::marker::Sized` is not implemented for `(dyn A + 'static)` - = note: to learn more, visit + = note: to learn more, visit = note: required because it appears within the type `Dst<(dyn A + 'static)>` = help: see issue #48214 = help: add #![feature(trivial_bounds)] to the crate attributes to enable @@ -122,7 +122,7 @@ LL | | } | |_^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit = help: see issue #48214 = help: add #![feature(trivial_bounds)] to the crate attributes to enable diff --git a/src/test/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.rs b/src/test/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.rs index fc5902721d788..ff6e2b8290389 100644 --- a/src/test/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.rs +++ b/src/test/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.rs @@ -3,25 +3,29 @@ // never triggers (yet), because they encounter other problems around // angle bracket vs parentheses notation. -#![allow(dead_code)] +#![feature(fn_traits)] struct Foo; impl Fn<()> for Foo { +//~^ ERROR the precise format of `Fn`-family traits' type parameters is subject to change extern "rust-call" fn call(self, args: ()) -> () {} //~^ ERROR rust-call ABI is subject to change } struct Foo1; impl FnOnce() for Foo1 { +//~^ ERROR associated type bindings are not allowed here extern "rust-call" fn call_once(self, args: ()) -> () {} //~^ ERROR rust-call ABI is subject to change } struct Bar; impl FnMut<()> for Bar { +//~^ ERROR the precise format of `Fn`-family traits' type parameters is subject to change extern "rust-call" fn call_mut(&self, args: ()) -> () {} //~^ ERROR rust-call ABI is subject to change } struct Baz; impl FnOnce<()> for Baz { +//~^ ERROR the precise format of `Fn`-family traits' type parameters is subject to change extern "rust-call" fn call_once(&self, args: ()) -> () {} //~^ ERROR rust-call ABI is subject to change } diff --git a/src/test/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr b/src/test/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr index 0e40e1fddb0c7..865b87e7dd5d7 100644 --- a/src/test/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr +++ b/src/test/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr @@ -1,5 +1,5 @@ error[E0658]: rust-call ABI is subject to change (see issue #29625) - --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:10:5 + --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:11:5 | LL | extern "rust-call" fn call(self, args: ()) -> () {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | extern "rust-call" fn call(self, args: ()) -> () {} = help: add #![feature(unboxed_closures)] to the crate attributes to enable error[E0658]: rust-call ABI is subject to change (see issue #29625) - --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:15:5 + --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:17:5 | LL | extern "rust-call" fn call_once(self, args: ()) -> () {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -15,7 +15,7 @@ LL | extern "rust-call" fn call_once(self, args: ()) -> () {} = help: add #![feature(unboxed_closures)] to the crate attributes to enable error[E0658]: rust-call ABI is subject to change (see issue #29625) - --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:20:5 + --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:23:5 | LL | extern "rust-call" fn call_mut(&self, args: ()) -> () {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -23,13 +23,44 @@ LL | extern "rust-call" fn call_mut(&self, args: ()) -> () {} = help: add #![feature(unboxed_closures)] to the crate attributes to enable error[E0658]: rust-call ABI is subject to change (see issue #29625) - --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:25:5 + --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:29:5 | LL | extern "rust-call" fn call_once(&self, args: ()) -> () {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: add #![feature(unboxed_closures)] to the crate attributes to enable -error: aborting due to 4 previous errors +error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change. Use parenthetical notation (Fn(Foo, Bar) -> Baz) instead (see issue #29625) + --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:9:6 + | +LL | impl Fn<()> for Foo { + | ^^^^^^ + | + = help: add #![feature(unboxed_closures)] to the crate attributes to enable + +error[E0229]: associated type bindings are not allowed here + --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:15:12 + | +LL | impl FnOnce() for Foo1 { + | ^^ associated type not allowed here + +error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change. Use parenthetical notation (Fn(Foo, Bar) -> Baz) instead (see issue #29625) + --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:21:6 + | +LL | impl FnMut<()> for Bar { + | ^^^^^^^^^ + | + = help: add #![feature(unboxed_closures)] to the crate attributes to enable + +error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change. Use parenthetical notation (Fn(Foo, Bar) -> Baz) instead (see issue #29625) + --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:27:6 + | +LL | impl FnOnce<()> for Baz { + | ^^^^^^^^^^ + | + = help: add #![feature(unboxed_closures)] to the crate attributes to enable + +error: aborting due to 8 previous errors -For more information about this error, try `rustc --explain E0658`. +Some errors occurred: E0229, E0658. +For more information about an error, try `rustc --explain E0229`. diff --git a/src/test/ui/feature-gates/feature-gate-unboxed-closures.rs b/src/test/ui/feature-gates/feature-gate-unboxed-closures.rs index 4c0d7d14a5064..c3f5c99dcb482 100644 --- a/src/test/ui/feature-gates/feature-gate-unboxed-closures.rs +++ b/src/test/ui/feature-gates/feature-gate-unboxed-closures.rs @@ -1,6 +1,9 @@ +#![feature(fn_traits)] + struct Test; impl FnOnce<(u32, u32)> for Test { +//~^ ERROR the precise format of `Fn`-family traits' type parameters is subject to change type Output = u32; extern "rust-call" fn call_once(self, (a, b): (u32, u32)) -> u32 { diff --git a/src/test/ui/feature-gates/feature-gate-unboxed-closures.stderr b/src/test/ui/feature-gates/feature-gate-unboxed-closures.stderr index 420b331ccccb3..e7b1fc589bb4a 100644 --- a/src/test/ui/feature-gates/feature-gate-unboxed-closures.stderr +++ b/src/test/ui/feature-gates/feature-gate-unboxed-closures.stderr @@ -1,5 +1,5 @@ error[E0658]: rust-call ABI is subject to change (see issue #29625) - --> $DIR/feature-gate-unboxed-closures.rs:6:5 + --> $DIR/feature-gate-unboxed-closures.rs:9:5 | LL | / extern "rust-call" fn call_once(self, (a, b): (u32, u32)) -> u32 { LL | | a + b @@ -8,6 +8,14 @@ LL | | } | = help: add #![feature(unboxed_closures)] to the crate attributes to enable -error: aborting due to previous error +error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change. Use parenthetical notation (Fn(Foo, Bar) -> Baz) instead (see issue #29625) + --> $DIR/feature-gate-unboxed-closures.rs:5:6 + | +LL | impl FnOnce<(u32, u32)> for Test { + | ^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unboxed_closures)] to the crate attributes to enable + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/feature-gates/feature-gate-unsized_locals.stderr b/src/test/ui/feature-gates/feature-gate-unsized_locals.stderr index 77313ed02151f..bde39cbeaeb28 100644 --- a/src/test/ui/feature-gates/feature-gate-unsized_locals.stderr +++ b/src/test/ui/feature-gates/feature-gate-unsized_locals.stderr @@ -5,7 +5,7 @@ LL | fn f(f: FnOnce()) {} | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn std::ops::FnOnce() + 'static)` - = note: to learn more, visit + = note: to learn more, visit = note: all local variables must have a statically known size = help: unsized locals are gated as an unstable feature diff --git a/src/test/ui/generator/sized-yield.stderr b/src/test/ui/generator/sized-yield.stderr index 7e1cd95429cb4..4f59f2c1c6ab3 100644 --- a/src/test/ui/generator/sized-yield.stderr +++ b/src/test/ui/generator/sized-yield.stderr @@ -9,7 +9,7 @@ LL | | }; | |____^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit = note: the yield type of a generator must have a statically known size error[E0277]: the size for values of type `str` cannot be known at compilation time @@ -19,7 +19,7 @@ LL | unsafe { gen.resume(); } | ^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-14366.stderr b/src/test/ui/issues/issue-14366.stderr index b93f5c2588256..a3588bb8ebe12 100644 --- a/src/test/ui/issues/issue-14366.stderr +++ b/src/test/ui/issues/issue-14366.stderr @@ -5,7 +5,7 @@ LL | let _x = "test" as &::std::any::Any; | ^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit = note: required for the cast to the object type `dyn std::any::Any` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-15756.stderr b/src/test/ui/issues/issue-15756.stderr index 9133376f6cfa3..987bc512163d6 100644 --- a/src/test/ui/issues/issue-15756.stderr +++ b/src/test/ui/issues/issue-15756.stderr @@ -5,7 +5,7 @@ LL | &mut something | ^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[T]` - = note: to learn more, visit + = note: to learn more, visit = note: all local variables must have a statically known size = help: unsized locals are gated as an unstable feature diff --git a/src/test/ui/issues/issue-17651.stderr b/src/test/ui/issues/issue-17651.stderr index e2d0d3301b6a1..72c40ff4b3a0c 100644 --- a/src/test/ui/issues/issue-17651.stderr +++ b/src/test/ui/issues/issue-17651.stderr @@ -5,7 +5,7 @@ LL | (|| Box::new(*(&[0][..])))(); | ^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[{integer}]` - = note: to learn more, visit + = note: to learn more, visit = note: required by `>::new` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-18107.stderr b/src/test/ui/issues/issue-18107.stderr index 4bad37df2edfe..23b58c3f6df3d 100644 --- a/src/test/ui/issues/issue-18107.stderr +++ b/src/test/ui/issues/issue-18107.stderr @@ -5,7 +5,7 @@ LL | AbstractRenderer | ^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn AbstractRenderer + 'static)` - = note: to learn more, visit + = note: to learn more, visit = note: the return type of a function must have a statically known size error: aborting due to previous error diff --git a/src/test/ui/issues/issue-18919.stderr b/src/test/ui/issues/issue-18919.stderr index cbad31a40cb6d..ca717a3c49b81 100644 --- a/src/test/ui/issues/issue-18919.stderr +++ b/src/test/ui/issues/issue-18919.stderr @@ -7,7 +7,7 @@ LL | | } | |_^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `dyn for<'r> std::ops::Fn(&'r isize) -> isize` - = note: to learn more, visit + = note: to learn more, visit = note: required by `std::option::Option` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-20005.stderr b/src/test/ui/issues/issue-20005.stderr index c69dfa9d89ca6..672d78f65e9f7 100644 --- a/src/test/ui/issues/issue-20005.stderr +++ b/src/test/ui/issues/issue-20005.stderr @@ -9,7 +9,7 @@ LL | | } | |_____^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `Self` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where Self: std::marker::Sized` bound note: required by `From` --> $DIR/issue-20005.rs:1:1 diff --git a/src/test/ui/issues/issue-20433.stderr b/src/test/ui/issues/issue-20433.stderr index cc98a775092e3..f7cb28edd6216 100644 --- a/src/test/ui/issues/issue-20433.stderr +++ b/src/test/ui/issues/issue-20433.stderr @@ -5,7 +5,7 @@ LL | fn iceman(c: Vec<[i32]>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[i32]` - = note: to learn more, visit + = note: to learn more, visit = note: required by `std::vec::Vec` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-20605.stderr b/src/test/ui/issues/issue-20605.stderr index 472080d1091d4..f779fe51bf2d1 100644 --- a/src/test/ui/issues/issue-20605.stderr +++ b/src/test/ui/issues/issue-20605.stderr @@ -5,7 +5,7 @@ LL | for item in *things { *item = 0 } | ^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `dyn std::iter::Iterator` - = note: to learn more, visit + = note: to learn more, visit = note: required by `std::iter::IntoIterator::into_iter` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-22644.rs b/src/test/ui/issues/issue-22644.rs index c87a927e55008..9244ff5931d3e 100644 --- a/src/test/ui/issues/issue-22644.rs +++ b/src/test/ui/issues/issue-22644.rs @@ -1,5 +1,7 @@ +#![feature(type_ascription)] + fn main() { - let a : u32 = 0; + let a : usize = 0; let long_name : usize = 0; println!("{}", a as usize > long_name); diff --git a/src/test/ui/issues/issue-22644.stderr b/src/test/ui/issues/issue-22644.stderr index ea5c9c5ad239e..de97b2271b10a 100644 --- a/src/test/ui/issues/issue-22644.stderr +++ b/src/test/ui/issues/issue-22644.stderr @@ -1,5 +1,5 @@ error: `<` is interpreted as a start of generic arguments for `usize`, not a comparison - --> $DIR/issue-22644.rs:6:31 + --> $DIR/issue-22644.rs:8:31 | LL | println!("{}", a as usize < long_name); //~ ERROR `<` is interpreted as a start of generic | ---------- ^ --------- interpreted as generic arguments @@ -8,7 +8,7 @@ LL | println!("{}", a as usize < long_name); //~ ERROR `<` is interpreted as | help: try comparing the cast value: `(a as usize)` error: `<` is interpreted as a start of generic arguments for `usize`, not a comparison - --> $DIR/issue-22644.rs:7:33 + --> $DIR/issue-22644.rs:9:33 | LL | println!("{}{}", a as usize < long_name, long_name); | ---------- ^ -------------------- interpreted as generic arguments @@ -17,7 +17,7 @@ LL | println!("{}{}", a as usize < long_name, long_name); | help: try comparing the cast value: `(a as usize)` error: `<` is interpreted as a start of generic arguments for `usize`, not a comparison - --> $DIR/issue-22644.rs:9:31 + --> $DIR/issue-22644.rs:11:31 | LL | println!("{}", a as usize < 4); //~ ERROR `<` is interpreted as a start of generic | ---------- ^ - interpreted as generic arguments @@ -26,7 +26,7 @@ LL | println!("{}", a as usize < 4); //~ ERROR `<` is interpreted as a start | help: try comparing the cast value: `(a as usize)` error: `<` is interpreted as a start of generic arguments for `usize`, not a comparison - --> $DIR/issue-22644.rs:11:31 + --> $DIR/issue-22644.rs:13:31 | LL | println!("{}{}", a: usize < long_name, long_name); | -------- ^ -------------------- interpreted as generic arguments @@ -35,7 +35,7 @@ LL | println!("{}{}", a: usize < long_name, long_name); | help: try comparing the cast value: `(a: usize)` error: `<` is interpreted as a start of generic arguments for `usize`, not a comparison - --> $DIR/issue-22644.rs:13:29 + --> $DIR/issue-22644.rs:15:29 | LL | println!("{}", a: usize < 4); //~ ERROR `<` is interpreted as a start of generic | -------- ^ - interpreted as generic arguments @@ -44,7 +44,7 @@ LL | println!("{}", a: usize < 4); //~ ERROR `<` is interpreted as a start o | help: try comparing the cast value: `(a: usize)` error: `<` is interpreted as a start of generic arguments for `usize`, not a comparison - --> $DIR/issue-22644.rs:18:20 + --> $DIR/issue-22644.rs:20:20 | LL | < //~ ERROR `<` is interpreted as a start of generic | ^ not interpreted as comparison @@ -58,7 +58,7 @@ LL | usize) | error: `<` is interpreted as a start of generic arguments for `usize`, not a comparison - --> $DIR/issue-22644.rs:27:20 + --> $DIR/issue-22644.rs:29:20 | LL | < //~ ERROR `<` is interpreted as a start of generic | ^ not interpreted as comparison @@ -75,7 +75,7 @@ LL | ... error: `<` is interpreted as a start of generic arguments for `usize`, not a shift - --> $DIR/issue-22644.rs:30:31 + --> $DIR/issue-22644.rs:32:31 | LL | println!("{}", a as usize << long_name); //~ ERROR `<` is interpreted as a start of generic | ---------- ^^ --------- interpreted as generic arguments @@ -84,7 +84,7 @@ LL | println!("{}", a as usize << long_name); //~ ERROR `<` is interpreted a | help: try shifting the cast value: `(a as usize)` error: expected type, found `4` - --> $DIR/issue-22644.rs:32:28 + --> $DIR/issue-22644.rs:34:28 | LL | println!("{}", a: &mut 4); //~ ERROR expected type, found `4` | ^ expecting a type here because of type ascription diff --git a/src/test/ui/issues/issue-22874.stderr b/src/test/ui/issues/issue-22874.stderr index 26addd173912f..229f99f90640b 100644 --- a/src/test/ui/issues/issue-22874.stderr +++ b/src/test/ui/issues/issue-22874.stderr @@ -5,7 +5,7 @@ LL | rows: [[String]], | ^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[std::string::String]` - = note: to learn more, visit + = note: to learn more, visit = note: slice and array elements must have `Sized` type error: aborting due to previous error diff --git a/src/test/ui/issues/issue-23281.stderr b/src/test/ui/issues/issue-23281.stderr index adc92ff7d0890..1e57774afe55a 100644 --- a/src/test/ui/issues/issue-23281.stderr +++ b/src/test/ui/issues/issue-23281.stderr @@ -5,7 +5,7 @@ LL | pub fn function(funs: Vec ()>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn std::ops::Fn() + 'static)` - = note: to learn more, visit + = note: to learn more, visit = note: required by `std::vec::Vec` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-24446.stderr b/src/test/ui/issues/issue-24446.stderr index 230ea4d683051..ffec73b1ab4a8 100644 --- a/src/test/ui/issues/issue-24446.stderr +++ b/src/test/ui/issues/issue-24446.stderr @@ -5,7 +5,7 @@ LL | static foo: Fn() -> u32 = || -> u32 { | ^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn std::ops::Fn() -> u32 + 'static)` - = note: to learn more, visit + = note: to learn more, visit error: aborting due to previous error diff --git a/src/test/ui/issues/issue-27060-2.stderr b/src/test/ui/issues/issue-27060-2.stderr index 6141ada5d9ab2..b95c298b6e679 100644 --- a/src/test/ui/issues/issue-27060-2.stderr +++ b/src/test/ui/issues/issue-27060-2.stderr @@ -5,7 +5,7 @@ LL | data: T, //~ ERROR the size for values of type | ^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `T` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where T: std::marker::Sized` bound = note: the last field of a packed struct may only have a dynamically sized type if it does not need drop to be run diff --git a/src/test/ui/issues/issue-27078.stderr b/src/test/ui/issues/issue-27078.stderr index 278c57d146d84..76cc3e7b0a36e 100644 --- a/src/test/ui/issues/issue-27078.stderr +++ b/src/test/ui/issues/issue-27078.stderr @@ -5,7 +5,7 @@ LL | fn foo(self) -> &'static i32 { | ^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `Self` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where Self: std::marker::Sized` bound = note: all local variables must have a statically known size = help: unsized locals are gated as an unstable feature diff --git a/src/test/ui/issues/issue-30355.stderr b/src/test/ui/issues/issue-30355.stderr index 5d1541918e0b7..48b151c73c956 100644 --- a/src/test/ui/issues/issue-30355.stderr +++ b/src/test/ui/issues/issue-30355.stderr @@ -5,7 +5,7 @@ LL | &X(*Y) | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[u8]` - = note: to learn more, visit + = note: to learn more, visit = note: all function arguments must have a statically known size = help: unsized locals are gated as an unstable feature diff --git a/src/test/ui/issues/issue-35988.stderr b/src/test/ui/issues/issue-35988.stderr index a570bd22dcc43..825c0de5e53ea 100644 --- a/src/test/ui/issues/issue-35988.stderr +++ b/src/test/ui/issues/issue-35988.stderr @@ -5,7 +5,7 @@ LL | V([Box]), | ^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[std::boxed::Box]` - = note: to learn more, visit + = note: to learn more, visit = note: no field of an enum variant may have a dynamically sized type error: aborting due to previous error diff --git a/src/test/ui/issues/issue-38954.stderr b/src/test/ui/issues/issue-38954.stderr index 06093ecbc331b..a74d6353c31f4 100644 --- a/src/test/ui/issues/issue-38954.stderr +++ b/src/test/ui/issues/issue-38954.stderr @@ -5,7 +5,7 @@ LL | fn _test(ref _p: str) {} | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit = note: all function arguments must have a statically known size = help: unsized locals are gated as an unstable feature diff --git a/src/test/ui/issues/issue-41229-ref-str.stderr b/src/test/ui/issues/issue-41229-ref-str.stderr index c4fe54e78ed95..bcca911c5a5c8 100644 --- a/src/test/ui/issues/issue-41229-ref-str.stderr +++ b/src/test/ui/issues/issue-41229-ref-str.stderr @@ -5,7 +5,7 @@ LL | pub fn example(ref s: str) {} | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit = note: all function arguments must have a statically known size = help: unsized locals are gated as an unstable feature diff --git a/src/test/ui/issues/issue-42312.stderr b/src/test/ui/issues/issue-42312.stderr index 12a436639dddf..20c8d085cbc62 100644 --- a/src/test/ui/issues/issue-42312.stderr +++ b/src/test/ui/issues/issue-42312.stderr @@ -5,7 +5,7 @@ LL | fn baz(_: Self::Target) where Self: Deref {} | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `::Target` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where ::Target: std::marker::Sized` bound = note: all function arguments must have a statically known size = help: unsized locals are gated as an unstable feature @@ -17,7 +17,7 @@ LL | pub fn f(_: ToString) {} | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn std::string::ToString + 'static)` - = note: to learn more, visit + = note: to learn more, visit = note: all function arguments must have a statically known size = help: unsized locals are gated as an unstable feature diff --git a/src/test/ui/issues/issue-51279.rs b/src/test/ui/issues/issue-51279.rs index ad5438fbd46cb..f8f3626caabe7 100644 --- a/src/test/ui/issues/issue-51279.rs +++ b/src/test/ui/issues/issue-51279.rs @@ -15,7 +15,7 @@ pub struct Y<#[cfg(none)] T>(T); // shouldn't care when the entire item is strip struct M(*const T); -unsafe impl<#[cfg_attr(none, may_dangle)] T> Drop for M { +impl<#[cfg_attr(none, may_dangle)] T> Drop for M { //~^ ERROR #[cfg_attr] cannot be applied on a generic parameter fn drop(&mut self) {} } @@ -23,3 +23,5 @@ unsafe impl<#[cfg_attr(none, may_dangle)] T> Drop for M { type Z<#[ignored] 'a, #[cfg(none)] T> = X<'a, T>; //~^ ERROR #[cfg] cannot be applied on a generic parameter //~| ERROR attribute `ignored` is currently unknown to the compiler + +fn main() {} diff --git a/src/test/ui/issues/issue-51279.stderr b/src/test/ui/issues/issue-51279.stderr index 1706e98e83b63..bc33eacac9994 100644 --- a/src/test/ui/issues/issue-51279.stderr +++ b/src/test/ui/issues/issue-51279.stderr @@ -35,10 +35,10 @@ LL | pub fn f<#[cfg(none)] 'a, #[cfg(none)] T>(_: &'a T) {} | ^^^^^^^^^^^^ error: #[cfg_attr] cannot be applied on a generic parameter - --> $DIR/issue-51279.rs:18:13 + --> $DIR/issue-51279.rs:18:6 | -LL | unsafe impl<#[cfg_attr(none, may_dangle)] T> Drop for M { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | impl<#[cfg_attr(none, may_dangle)] T> Drop for M { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: #[cfg] cannot be applied on a generic parameter --> $DIR/issue-51279.rs:23:23 diff --git a/src/test/ui/issues/issue-54410.stderr b/src/test/ui/issues/issue-54410.stderr index ae6888f067e68..992c691bf21ef 100644 --- a/src/test/ui/issues/issue-54410.stderr +++ b/src/test/ui/issues/issue-54410.stderr @@ -5,7 +5,7 @@ LL | pub static mut symbol: [i8]; | ^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[i8]` - = note: to learn more, visit + = note: to learn more, visit error: aborting due to previous error diff --git a/src/test/ui/issues/issue-5883.stderr b/src/test/ui/issues/issue-5883.stderr index 398d42c94fa48..ad463d4c478ca 100644 --- a/src/test/ui/issues/issue-5883.stderr +++ b/src/test/ui/issues/issue-5883.stderr @@ -5,7 +5,7 @@ LL | fn new_struct(r: A+'static) | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn A + 'static)` - = note: to learn more, visit + = note: to learn more, visit = note: all local variables must have a statically known size = help: unsized locals are gated as an unstable feature @@ -16,7 +16,7 @@ LL | -> Struct { //~^ ERROR the size for values of type | ^^^^^^ doesn't have a size known at compile-time | = help: within `Struct`, the trait `std::marker::Sized` is not implemented for `(dyn A + 'static)` - = note: to learn more, visit + = note: to learn more, visit = note: required because it appears within the type `Struct` = note: the return type of a function must have a statically known size diff --git a/src/test/ui/macros/assert.rs b/src/test/ui/macros/assert.rs index 8732cb58d74a6..71b0dbb19e262 100644 --- a/src/test/ui/macros/assert.rs +++ b/src/test/ui/macros/assert.rs @@ -1,4 +1,6 @@ fn main() { assert!(); //~ ERROR requires a boolean expression + assert!(struct); //~ ERROR expected expression debug_assert!(); //~ ERROR requires a boolean expression + debug_assert!(struct); //~ ERROR expected expression } diff --git a/src/test/ui/macros/assert.stderr b/src/test/ui/macros/assert.stderr index 89faba0cf63dd..2cfcebabcb931 100644 --- a/src/test/ui/macros/assert.stderr +++ b/src/test/ui/macros/assert.stderr @@ -4,13 +4,25 @@ error: macro requires a boolean expression as an argument LL | assert!(); //~ ERROR requires a boolean expression | ^^^^^^^^^^ boolean expression required +error: expected expression, found keyword `struct` + --> $DIR/assert.rs:3:13 + | +LL | assert!(struct); //~ ERROR expected expression + | ^^^^^^ expected expression + error: macro requires a boolean expression as an argument - --> $DIR/assert.rs:3:5 + --> $DIR/assert.rs:4:5 | LL | debug_assert!(); //~ ERROR requires a boolean expression | ^^^^^^^^^^^^^^^^ boolean expression required | = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) -error: aborting due to 2 previous errors +error: expected expression, found keyword `struct` + --> $DIR/assert.rs:5:19 + | +LL | debug_assert!(struct); //~ ERROR expected expression + | ^^^^^^ expected expression + +error: aborting due to 4 previous errors diff --git a/src/test/ui/macros/cfg.rs b/src/test/ui/macros/cfg.rs new file mode 100644 index 0000000000000..222161a8183a2 --- /dev/null +++ b/src/test/ui/macros/cfg.rs @@ -0,0 +1,5 @@ +fn main() { + cfg!(); //~ ERROR macro requires a cfg-pattern + cfg!(123); //~ ERROR expected identifier + cfg!(foo = 123); //~ ERROR literal in `cfg` predicate value must be a string +} diff --git a/src/test/ui/macros/cfg.stderr b/src/test/ui/macros/cfg.stderr new file mode 100644 index 0000000000000..a7aca88f3e56e --- /dev/null +++ b/src/test/ui/macros/cfg.stderr @@ -0,0 +1,21 @@ +error: macro requires a cfg-pattern as an argument + --> $DIR/cfg.rs:2:5 + | +LL | cfg!(); //~ ERROR macro requires a cfg-pattern + | ^^^^^^^ cfg-pattern required + +error: expected identifier, found `123` + --> $DIR/cfg.rs:3:10 + | +LL | cfg!(123); //~ ERROR expected identifier + | ^^^ expected identifier + +error[E0565]: literal in `cfg` predicate value must be a string + --> $DIR/cfg.rs:4:16 + | +LL | cfg!(foo = 123); //~ ERROR literal in `cfg` predicate value must be a string + | ^^^ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0565`. diff --git a/src/test/ui/macros/format-parse-errors.rs b/src/test/ui/macros/format-parse-errors.rs new file mode 100644 index 0000000000000..ba1e441fe339f --- /dev/null +++ b/src/test/ui/macros/format-parse-errors.rs @@ -0,0 +1,10 @@ +fn main() { + format!(); //~ ERROR requires at least a format string argument + format!(struct); //~ ERROR expected expression + format!("s", name =); //~ ERROR expected expression + format!("s", foo = struct); //~ ERROR expected expression + format!("s", struct); //~ ERROR expected expression + + // This error should come after parsing errors to ensure they are non-fatal. + format!(123); //~ ERROR format argument must be a string literal +} diff --git a/src/test/ui/macros/format-parse-errors.stderr b/src/test/ui/macros/format-parse-errors.stderr new file mode 100644 index 0000000000000..0463c54890177 --- /dev/null +++ b/src/test/ui/macros/format-parse-errors.stderr @@ -0,0 +1,44 @@ +error: requires at least a format string argument + --> $DIR/format-parse-errors.rs:2:5 + | +LL | format!(); //~ ERROR requires at least a format string argument + | ^^^^^^^^^^ + | + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error: expected expression, found keyword `struct` + --> $DIR/format-parse-errors.rs:3:13 + | +LL | format!(struct); //~ ERROR expected expression + | ^^^^^^ expected expression + +error: expected expression, found `` + --> $DIR/format-parse-errors.rs:4:23 + | +LL | format!("s", name =); //~ ERROR expected expression + | ^ expected expression + +error: expected expression, found keyword `struct` + --> $DIR/format-parse-errors.rs:5:24 + | +LL | format!("s", foo = struct); //~ ERROR expected expression + | ^^^^^^ expected expression + +error: expected expression, found keyword `struct` + --> $DIR/format-parse-errors.rs:6:18 + | +LL | format!("s", struct); //~ ERROR expected expression + | ^^^^^^ expected expression + +error: format argument must be a string literal + --> $DIR/format-parse-errors.rs:9:13 + | +LL | format!(123); //~ ERROR format argument must be a string literal + | ^^^ +help: you might be missing a string literal to format with + | +LL | format!("{}", 123); //~ ERROR format argument must be a string literal + | ^^^^^ + +error: aborting due to 6 previous errors + diff --git a/src/test/ui/macros/global-asm.rs b/src/test/ui/macros/global-asm.rs new file mode 100644 index 0000000000000..8402afa50857a --- /dev/null +++ b/src/test/ui/macros/global-asm.rs @@ -0,0 +1,7 @@ +#![feature(global_asm)] + +fn main() { + global_asm!(); //~ ERROR requires a string literal as an argument + global_asm!(struct); //~ ERROR expected expression + global_asm!(123); //~ ERROR inline assembly must be a string literal +} diff --git a/src/test/ui/macros/global-asm.stderr b/src/test/ui/macros/global-asm.stderr new file mode 100644 index 0000000000000..94664c96db391 --- /dev/null +++ b/src/test/ui/macros/global-asm.stderr @@ -0,0 +1,20 @@ +error: macro requires a string literal as an argument + --> $DIR/global-asm.rs:4:5 + | +LL | global_asm!(); //~ ERROR requires a string literal as an argument + | ^^^^^^^^^^^^^^ string literal required + +error: expected expression, found keyword `struct` + --> $DIR/global-asm.rs:5:17 + | +LL | global_asm!(struct); //~ ERROR expected expression + | ^^^^^^ expected expression + +error: inline assembly must be a string literal + --> $DIR/global-asm.rs:6:17 + | +LL | global_asm!(123); //~ ERROR inline assembly must be a string literal + | ^^^ + +error: aborting due to 3 previous errors + diff --git a/src/test/ui/mismatched_types/cast-rfc0401.stderr b/src/test/ui/mismatched_types/cast-rfc0401.stderr index e220349c6df12..158d114616979 100644 --- a/src/test/ui/mismatched_types/cast-rfc0401.stderr +++ b/src/test/ui/mismatched_types/cast-rfc0401.stderr @@ -223,7 +223,7 @@ LL | let _ = fat_v as *const Foo; //~ ERROR the size for values of type | ^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[u8]` - = note: to learn more, visit + = note: to learn more, visit = note: required for the cast to the object type `dyn Foo` error[E0277]: the size for values of type `str` cannot be known at compilation time @@ -233,7 +233,7 @@ LL | let _ = a as *const Foo; //~ ERROR the size for values of type | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit = note: required for the cast to the object type `dyn Foo` error[E0606]: casting `&{float}` as `f32` is invalid diff --git a/src/test/ui/nll/issue-52534.stderr b/src/test/ui/nll/issue-52534.stderr index 42387c774a4f7..e83374af3b066 100644 --- a/src/test/ui/nll/issue-52534.stderr +++ b/src/test/ui/nll/issue-52534.stderr @@ -10,7 +10,7 @@ LL | } | - ...but `x` will be dropped here, when the function `bar` returns | = note: functions cannot return a borrow to data owned within the function's scope, functions can only return borrows to data passed as arguments - = note: to learn more, visit + = note: to learn more, visit error[E0597]: `y` does not live long enough --> $DIR/issue-52534.rs:18:26 @@ -24,7 +24,7 @@ LL | } | - ...but `y` will be dropped here, when the function `foobar` returns | = note: functions cannot return a borrow to data owned within the function's scope, functions can only return borrows to data passed as arguments - = note: to learn more, visit + = note: to learn more, visit error: aborting due to 2 previous errors diff --git a/src/test/ui/not-copy-closure.nll.stderr b/src/test/ui/not-copy-closure.nll.stderr index 2f295315a08aa..1a65bcf447317 100644 --- a/src/test/ui/not-copy-closure.nll.stderr +++ b/src/test/ui/not-copy-closure.nll.stderr @@ -5,6 +5,12 @@ LL | let b = hello; | ----- value moved here LL | let c = hello; //~ ERROR use of moved value: `hello` [E0382] | ^^^^^ value used here after move + | +note: closure cannot be moved more than once as it is not `Copy` due to moving the variable `a` out of its environment + --> $DIR/not-copy-closure.rs:6:9 + | +LL | a += 1; + | ^ error: aborting due to previous error diff --git a/src/test/ui/on-unimplemented/expected-comma-found-token.rs b/src/test/ui/on-unimplemented/expected-comma-found-token.rs index a3e6609f98215..a4e2a1754f013 100644 --- a/src/test/ui/on-unimplemented/expected-comma-found-token.rs +++ b/src/test/ui/on-unimplemented/expected-comma-found-token.rs @@ -4,11 +4,10 @@ #![feature(on_unimplemented)] -#[rustc_on_unimplemented( +#[rustc_on_unimplemented( //~ ERROR `#[rustc_on_unimplemented]` requires a value message="the message" - label="the label" + label="the label" //~ ERROR expected one of `)` or `,`, found `label` )] trait T {} -//~^^^ ERROR expected one of `)` or `,`, found `label` fn main() { } diff --git a/src/test/ui/on-unimplemented/expected-comma-found-token.stderr b/src/test/ui/on-unimplemented/expected-comma-found-token.stderr index 5bbdbe29416c1..aa1b520e01529 100644 --- a/src/test/ui/on-unimplemented/expected-comma-found-token.stderr +++ b/src/test/ui/on-unimplemented/expected-comma-found-token.stderr @@ -3,8 +3,20 @@ error: expected one of `)` or `,`, found `label` | LL | message="the message" | - expected one of `)` or `,` here -LL | label="the label" +LL | label="the label" //~ ERROR expected one of `)` or `,`, found `label` | ^^^^^ unexpected token -error: aborting due to previous error +error[E0232]: `#[rustc_on_unimplemented]` requires a value + --> $DIR/expected-comma-found-token.rs:7:1 + | +LL | / #[rustc_on_unimplemented( //~ ERROR `#[rustc_on_unimplemented]` requires a value +LL | | message="the message" +LL | | label="the label" //~ ERROR expected one of `)` or `,`, found `label` +LL | | )] + | |__^ value required here + | + = note: eg `#[rustc_on_unimplemented(message="foo")]` + +error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0232`. diff --git a/src/test/ui/range/range-1.stderr b/src/test/ui/range/range-1.stderr index 8e0e405a8ad03..00c0c80515557 100644 --- a/src/test/ui/range/range-1.stderr +++ b/src/test/ui/range/range-1.stderr @@ -19,7 +19,7 @@ LL | let range = *arr..; | ^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[{integer}]` - = note: to learn more, visit + = note: to learn more, visit = note: required by `std::ops::RangeFrom` error: aborting due to 3 previous errors diff --git a/src/test/ui/resolve/issue-5035-2.stderr b/src/test/ui/resolve/issue-5035-2.stderr index d3e559e0f9366..89eb3d97ce0a5 100644 --- a/src/test/ui/resolve/issue-5035-2.stderr +++ b/src/test/ui/resolve/issue-5035-2.stderr @@ -5,7 +5,7 @@ LL | fn foo(_x: K) {} | ^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn I + 'static)` - = note: to learn more, visit + = note: to learn more, visit = note: all local variables must have a statically known size = help: unsized locals are gated as an unstable feature diff --git a/src/test/ui/span/dropck_vec_cycle_checked.nll.stderr b/src/test/ui/span/dropck_vec_cycle_checked.nll.stderr index 3d9c9354769a4..05692515af846 100644 --- a/src/test/ui/span/dropck_vec_cycle_checked.nll.stderr +++ b/src/test/ui/span/dropck_vec_cycle_checked.nll.stderr @@ -1,5 +1,5 @@ error[E0597]: `c2` does not live long enough - --> $DIR/dropck_vec_cycle_checked.rs:103:24 + --> $DIR/dropck_vec_cycle_checked.rs:98:24 | LL | c1.v[0].v.set(Some(&c2)); | ^^^ borrowed value does not live long enough @@ -13,7 +13,7 @@ LL | } = note: values in a scope are dropped in the opposite order they are defined error[E0597]: `c3` does not live long enough - --> $DIR/dropck_vec_cycle_checked.rs:105:24 + --> $DIR/dropck_vec_cycle_checked.rs:100:24 | LL | c1.v[1].v.set(Some(&c3)); | ^^^ borrowed value does not live long enough @@ -27,7 +27,7 @@ LL | } = note: values in a scope are dropped in the opposite order they are defined error[E0597]: `c1` does not live long enough - --> $DIR/dropck_vec_cycle_checked.rs:111:24 + --> $DIR/dropck_vec_cycle_checked.rs:106:24 | LL | c3.v[0].v.set(Some(&c1)); | ^^^ borrowed value does not live long enough diff --git a/src/test/ui/span/dropck_vec_cycle_checked.rs b/src/test/ui/span/dropck_vec_cycle_checked.rs index 4f627c4270ca5..c80e0386e6a15 100644 --- a/src/test/ui/span/dropck_vec_cycle_checked.rs +++ b/src/test/ui/span/dropck_vec_cycle_checked.rs @@ -1,12 +1,7 @@ -// compile-flags: -Z nll-subminimal-causes -// (Work around rust-lang/rust#49998 by opting into nll-subminimal-causes.) - // Reject mixing cyclic structure and Drop when using Vec. // // (Compare against compile-fail/dropck_arr_cycle_checked.rs) - - use std::cell::Cell; use id::Id; diff --git a/src/test/ui/span/dropck_vec_cycle_checked.stderr b/src/test/ui/span/dropck_vec_cycle_checked.stderr index 3a5214446119a..35e4314d0c66f 100644 --- a/src/test/ui/span/dropck_vec_cycle_checked.stderr +++ b/src/test/ui/span/dropck_vec_cycle_checked.stderr @@ -1,5 +1,5 @@ error[E0597]: `c2` does not live long enough - --> $DIR/dropck_vec_cycle_checked.rs:103:25 + --> $DIR/dropck_vec_cycle_checked.rs:98:25 | LL | c1.v[0].v.set(Some(&c2)); | ^^ borrowed value does not live long enough @@ -10,7 +10,7 @@ LL | } = note: values in a scope are dropped in the opposite order they are created error[E0597]: `c3` does not live long enough - --> $DIR/dropck_vec_cycle_checked.rs:105:25 + --> $DIR/dropck_vec_cycle_checked.rs:100:25 | LL | c1.v[1].v.set(Some(&c3)); | ^^ borrowed value does not live long enough @@ -21,7 +21,7 @@ LL | } = note: values in a scope are dropped in the opposite order they are created error[E0597]: `c2` does not live long enough - --> $DIR/dropck_vec_cycle_checked.rs:107:25 + --> $DIR/dropck_vec_cycle_checked.rs:102:25 | LL | c2.v[0].v.set(Some(&c2)); | ^^ borrowed value does not live long enough @@ -32,7 +32,7 @@ LL | } = note: values in a scope are dropped in the opposite order they are created error[E0597]: `c3` does not live long enough - --> $DIR/dropck_vec_cycle_checked.rs:109:25 + --> $DIR/dropck_vec_cycle_checked.rs:104:25 | LL | c2.v[1].v.set(Some(&c3)); | ^^ borrowed value does not live long enough @@ -43,7 +43,7 @@ LL | } = note: values in a scope are dropped in the opposite order they are created error[E0597]: `c1` does not live long enough - --> $DIR/dropck_vec_cycle_checked.rs:111:25 + --> $DIR/dropck_vec_cycle_checked.rs:106:25 | LL | c3.v[0].v.set(Some(&c1)); | ^^ borrowed value does not live long enough @@ -54,7 +54,7 @@ LL | } = note: values in a scope are dropped in the opposite order they are created error[E0597]: `c2` does not live long enough - --> $DIR/dropck_vec_cycle_checked.rs:113:25 + --> $DIR/dropck_vec_cycle_checked.rs:108:25 | LL | c3.v[1].v.set(Some(&c2)); | ^^ borrowed value does not live long enough diff --git a/src/test/ui/span/gated-features-attr-spans.rs b/src/test/ui/span/gated-features-attr-spans.rs index ff722a5352079..69511ab8e1fc7 100644 --- a/src/test/ui/span/gated-features-attr-spans.rs +++ b/src/test/ui/span/gated-features-attr-spans.rs @@ -1,7 +1,7 @@ #[repr(simd)] //~ ERROR are experimental -struct Weapon { - name: String, - damage: u32 +struct Coord { + x: u32, + y: u32, } fn main() {} diff --git a/src/test/ui/str/str-array-assignment.stderr b/src/test/ui/str/str-array-assignment.stderr index d3bff00872288..24d8db481b468 100644 --- a/src/test/ui/str/str-array-assignment.stderr +++ b/src/test/ui/str/str-array-assignment.stderr @@ -28,7 +28,7 @@ LL | let v = s[..2]; | doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit = note: all local variables must have a statically known size = help: unsized locals are gated as an unstable feature diff --git a/src/test/ui/str/str-mut-idx.stderr b/src/test/ui/str/str-mut-idx.stderr index a8ab38e5ab6a5..a0c7c2c574e4e 100644 --- a/src/test/ui/str/str-mut-idx.stderr +++ b/src/test/ui/str/str-mut-idx.stderr @@ -5,7 +5,7 @@ LL | s[1..2] = bot(); | ^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit note: required by `bot` --> $DIR/str-mut-idx.rs:1:1 | @@ -19,7 +19,7 @@ LL | s[1..2] = bot(); | ^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit = note: the left-hand-side of an assignment must have a statically known size error[E0277]: the type `str` cannot be mutably indexed by `usize` diff --git a/src/test/ui/substs-ppaux.normal.stderr b/src/test/ui/substs-ppaux.normal.stderr index fb9e49eb10f87..567b4d9f4403e 100644 --- a/src/test/ui/substs-ppaux.normal.stderr +++ b/src/test/ui/substs-ppaux.normal.stderr @@ -41,7 +41,7 @@ LL | >::bar; | ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit = note: required because of the requirements on the impl of `Foo<'_, '_, u8>` for `str` note: required by `Foo::bar` --> $DIR/substs-ppaux.rs:7:5 diff --git a/src/test/ui/substs-ppaux.verbose.stderr b/src/test/ui/substs-ppaux.verbose.stderr index 77683c1d91678..9d8a555dffe16 100644 --- a/src/test/ui/substs-ppaux.verbose.stderr +++ b/src/test/ui/substs-ppaux.verbose.stderr @@ -41,7 +41,7 @@ LL | >::bar; | ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit = note: required because of the requirements on the impl of `Foo<'_#0r, '_#1r, u8>` for `str` note: required by `Foo::bar` --> $DIR/substs-ppaux.rs:7:5 diff --git a/src/test/ui/suggestions/path-by-value.stderr b/src/test/ui/suggestions/path-by-value.stderr index 338cfc990dcda..b073e10749cc1 100644 --- a/src/test/ui/suggestions/path-by-value.stderr +++ b/src/test/ui/suggestions/path-by-value.stderr @@ -5,7 +5,7 @@ LL | fn f(p: Path) { } | ^ borrow the `Path` instead | = help: within `std::path::Path`, the trait `std::marker::Sized` is not implemented for `[u8]` - = note: to learn more, visit + = note: to learn more, visit = note: required because it appears within the type `std::path::Path` = note: all local variables must have a statically known size = help: unsized locals are gated as an unstable feature diff --git a/src/test/ui/traits/trait-bounds-not-on-bare-trait.stderr b/src/test/ui/traits/trait-bounds-not-on-bare-trait.stderr index 43d1e1a9d3e45..5aee1e7e982a8 100644 --- a/src/test/ui/traits/trait-bounds-not-on-bare-trait.stderr +++ b/src/test/ui/traits/trait-bounds-not-on-bare-trait.stderr @@ -5,7 +5,7 @@ LL | fn foo(_x: Foo + Send) { | ^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn Foo + std::marker::Send + 'static)` - = note: to learn more, visit + = note: to learn more, visit = note: all local variables must have a statically known size = help: unsized locals are gated as an unstable feature diff --git a/src/test/ui/traits/trait-suggest-where-clause.stderr b/src/test/ui/traits/trait-suggest-where-clause.stderr index 161cf85d258e2..f88dae37e48e5 100644 --- a/src/test/ui/traits/trait-suggest-where-clause.stderr +++ b/src/test/ui/traits/trait-suggest-where-clause.stderr @@ -5,7 +5,7 @@ LL | mem::size_of::(); | ^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `U` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where U: std::marker::Sized` bound = note: required by `std::mem::size_of` @@ -16,7 +16,7 @@ LL | mem::size_of::>(); | ^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: within `Misc`, the trait `std::marker::Sized` is not implemented for `U` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where U: std::marker::Sized` bound = note: required because it appears within the type `Misc` = note: required by `std::mem::size_of` @@ -54,7 +54,7 @@ LL | mem::size_of::<[T]>(); | ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[T]` - = note: to learn more, visit + = note: to learn more, visit = note: required by `std::mem::size_of` error[E0277]: the size for values of type `[&U]` cannot be known at compilation time @@ -64,7 +64,7 @@ LL | mem::size_of::<[&U]>(); | ^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[&U]` - = note: to learn more, visit + = note: to learn more, visit = note: required by `std::mem::size_of` error: aborting due to 7 previous errors diff --git a/src/test/ui/trivial-bounds/trivial-bounds-leak.stderr b/src/test/ui/trivial-bounds/trivial-bounds-leak.stderr index bc94aba667c38..aa055d3dc03f5 100644 --- a/src/test/ui/trivial-bounds/trivial-bounds-leak.stderr +++ b/src/test/ui/trivial-bounds/trivial-bounds-leak.stderr @@ -5,7 +5,7 @@ LL | fn cant_return_str() -> str { //~ ERROR | ^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit = note: the return type of a function must have a statically known size error[E0599]: no method named `test` found for type `i32` in the current scope diff --git a/src/test/ui/union/union-sized-field.stderr b/src/test/ui/union/union-sized-field.stderr index b490be28ebfd0..8914003068385 100644 --- a/src/test/ui/union/union-sized-field.stderr +++ b/src/test/ui/union/union-sized-field.stderr @@ -5,7 +5,7 @@ LL | value: T, | ^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `T` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where T: std::marker::Sized` bound = note: no field of a union may have a dynamically sized type @@ -16,7 +16,7 @@ LL | value: T, | ^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `T` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where T: std::marker::Sized` bound = note: only the last field of a struct may have a dynamically sized type @@ -27,7 +27,7 @@ LL | Value(T), | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `T` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where T: std::marker::Sized` bound = note: no field of an enum variant may have a dynamically sized type diff --git a/src/test/ui/union/union-unsized.stderr b/src/test/ui/union/union-unsized.stderr index cd65172c23f80..e702f2c61bee3 100644 --- a/src/test/ui/union/union-unsized.stderr +++ b/src/test/ui/union/union-unsized.stderr @@ -5,7 +5,7 @@ LL | a: str, | ^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit = note: no field of a union may have a dynamically sized type error[E0277]: the size for values of type `str` cannot be known at compilation time @@ -15,7 +15,7 @@ LL | b: str, | ^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit = note: no field of a union may have a dynamically sized type error: aborting due to 2 previous errors diff --git a/src/test/ui/unsized-locals/issue-50940-with-feature.stderr b/src/test/ui/unsized-locals/issue-50940-with-feature.stderr index f4f015fa19065..7b6c2d11ea169 100644 --- a/src/test/ui/unsized-locals/issue-50940-with-feature.stderr +++ b/src/test/ui/unsized-locals/issue-50940-with-feature.stderr @@ -5,7 +5,7 @@ LL | A as fn(str) -> A; | ^ doesn't have a size known at compile-time | = help: within `main::A`, the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit = note: required because it appears within the type `main::A` = note: the return type of a function must have a statically known size diff --git a/src/test/ui/unsized-locals/issue-50940.stderr b/src/test/ui/unsized-locals/issue-50940.stderr index 9f3669ccf1f15..be006c09d6f5c 100644 --- a/src/test/ui/unsized-locals/issue-50940.stderr +++ b/src/test/ui/unsized-locals/issue-50940.stderr @@ -5,7 +5,7 @@ LL | A as fn(str) -> A; | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit = note: all function arguments must have a statically known size = help: unsized locals are gated as an unstable feature diff --git a/src/test/ui/unsized-locals/unsized-exprs.stderr b/src/test/ui/unsized-locals/unsized-exprs.stderr index 0ca60e8dea0d9..43c35cdd7b5b0 100644 --- a/src/test/ui/unsized-locals/unsized-exprs.stderr +++ b/src/test/ui/unsized-locals/unsized-exprs.stderr @@ -5,7 +5,7 @@ LL | udrop::<(i32, [u8])>((42, *foo())); | ^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: within `({integer}, [u8])`, the trait `std::marker::Sized` is not implemented for `[u8]` - = note: to learn more, visit + = note: to learn more, visit = note: required because it appears within the type `({integer}, [u8])` = note: tuples must have a statically known size to be initialized @@ -16,7 +16,7 @@ LL | udrop::>(A { 0: *foo() }); | ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: within `A<[u8]>`, the trait `std::marker::Sized` is not implemented for `[u8]` - = note: to learn more, visit + = note: to learn more, visit = note: required because it appears within the type `A<[u8]>` = note: structs must have a statically known size to be initialized @@ -27,7 +27,7 @@ LL | udrop::>(A(*foo())); | ^ doesn't have a size known at compile-time | = help: within `A<[u8]>`, the trait `std::marker::Sized` is not implemented for `[u8]` - = note: to learn more, visit + = note: to learn more, visit = note: required because it appears within the type `A<[u8]>` = note: the return type of a function must have a statically known size diff --git a/src/test/ui/unsized-locals/unsized-exprs3.stderr b/src/test/ui/unsized-locals/unsized-exprs3.stderr index 42f91a946a851..f9a7452a5ebf2 100644 --- a/src/test/ui/unsized-locals/unsized-exprs3.stderr +++ b/src/test/ui/unsized-locals/unsized-exprs3.stderr @@ -5,7 +5,7 @@ LL | udrop as fn([u8]); | ^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[u8]` - = note: to learn more, visit + = note: to learn more, visit = note: all function arguments must have a statically known size = help: unsized locals are gated as an unstable feature diff --git a/src/test/ui/unsized/unsized-bare-typaram.stderr b/src/test/ui/unsized/unsized-bare-typaram.stderr index 6f54ac579a374..cee1459c7915d 100644 --- a/src/test/ui/unsized/unsized-bare-typaram.stderr +++ b/src/test/ui/unsized/unsized-bare-typaram.stderr @@ -5,7 +5,7 @@ LL | fn foo() { bar::() } | ^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `T` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where T: std::marker::Sized` bound note: required by `bar` --> $DIR/unsized-bare-typaram.rs:1:1 diff --git a/src/test/ui/unsized/unsized-enum.stderr b/src/test/ui/unsized/unsized-enum.stderr index 7d8c09ebf4050..20857a1d65e75 100644 --- a/src/test/ui/unsized/unsized-enum.stderr +++ b/src/test/ui/unsized/unsized-enum.stderr @@ -5,7 +5,7 @@ LL | fn foo2() { not_sized::>() } | ^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `T` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where T: std::marker::Sized` bound note: required by `Foo` --> $DIR/unsized-enum.rs:4:1 diff --git a/src/test/ui/unsized/unsized-enum2.stderr b/src/test/ui/unsized/unsized-enum2.stderr index 81135c33d1d19..9109366e4fcfd 100644 --- a/src/test/ui/unsized/unsized-enum2.stderr +++ b/src/test/ui/unsized/unsized-enum2.stderr @@ -5,7 +5,7 @@ LL | VA(W), | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `W` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where W: std::marker::Sized` bound = note: no field of an enum variant may have a dynamically sized type @@ -16,7 +16,7 @@ LL | VB{x: X}, | ^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `X` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound = note: no field of an enum variant may have a dynamically sized type @@ -27,7 +27,7 @@ LL | VC(isize, Y), | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `Y` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where Y: std::marker::Sized` bound = note: no field of an enum variant may have a dynamically sized type @@ -38,7 +38,7 @@ LL | VD{u: isize, x: Z}, | ^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `Z` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where Z: std::marker::Sized` bound = note: no field of an enum variant may have a dynamically sized type @@ -49,7 +49,7 @@ LL | VE([u8]), | ^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[u8]` - = note: to learn more, visit + = note: to learn more, visit = note: no field of an enum variant may have a dynamically sized type error[E0277]: the size for values of type `str` cannot be known at compilation time @@ -59,7 +59,7 @@ LL | VF{x: str}, | ^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit = note: no field of an enum variant may have a dynamically sized type error[E0277]: the size for values of type `[f32]` cannot be known at compilation time @@ -69,7 +69,7 @@ LL | VG(isize, [f32]), | ^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[f32]` - = note: to learn more, visit + = note: to learn more, visit = note: no field of an enum variant may have a dynamically sized type error[E0277]: the size for values of type `[u32]` cannot be known at compilation time @@ -79,7 +79,7 @@ LL | VH{u: isize, x: [u32]}, | ^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[u32]` - = note: to learn more, visit + = note: to learn more, visit = note: no field of an enum variant may have a dynamically sized type error[E0277]: the size for values of type `(dyn Foo + 'static)` cannot be known at compilation time @@ -89,7 +89,7 @@ LL | VM(Foo), | ^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn Foo + 'static)` - = note: to learn more, visit + = note: to learn more, visit = note: no field of an enum variant may have a dynamically sized type error[E0277]: the size for values of type `(dyn Bar + 'static)` cannot be known at compilation time @@ -99,7 +99,7 @@ LL | VN{x: Bar}, | ^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn Bar + 'static)` - = note: to learn more, visit + = note: to learn more, visit = note: no field of an enum variant may have a dynamically sized type error[E0277]: the size for values of type `(dyn FooBar + 'static)` cannot be known at compilation time @@ -109,7 +109,7 @@ LL | VO(isize, FooBar), | ^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn FooBar + 'static)` - = note: to learn more, visit + = note: to learn more, visit = note: no field of an enum variant may have a dynamically sized type error[E0277]: the size for values of type `(dyn BarFoo + 'static)` cannot be known at compilation time @@ -119,7 +119,7 @@ LL | VP{u: isize, x: BarFoo}, | ^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn BarFoo + 'static)` - = note: to learn more, visit + = note: to learn more, visit = note: no field of an enum variant may have a dynamically sized type error[E0277]: the size for values of type `[i8]` cannot be known at compilation time @@ -129,7 +129,7 @@ LL | VQ(<&'static [i8] as Deref>::Target), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[i8]` - = note: to learn more, visit + = note: to learn more, visit = note: no field of an enum variant may have a dynamically sized type error[E0277]: the size for values of type `[char]` cannot be known at compilation time @@ -139,7 +139,7 @@ LL | VR{x: <&'static [char] as Deref>::Target}, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[char]` - = note: to learn more, visit + = note: to learn more, visit = note: no field of an enum variant may have a dynamically sized type error[E0277]: the size for values of type `[f64]` cannot be known at compilation time @@ -149,7 +149,7 @@ LL | VS(isize, <&'static [f64] as Deref>::Target), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[f64]` - = note: to learn more, visit + = note: to learn more, visit = note: no field of an enum variant may have a dynamically sized type error[E0277]: the size for values of type `[i32]` cannot be known at compilation time @@ -159,7 +159,7 @@ LL | VT{u: isize, x: <&'static [i32] as Deref>::Target}, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[i32]` - = note: to learn more, visit + = note: to learn more, visit = note: no field of an enum variant may have a dynamically sized type error[E0277]: the size for values of type `(dyn PathHelper1 + 'static)` cannot be known at compilation time @@ -169,7 +169,7 @@ LL | VI(Path1), | ^^^^^ doesn't have a size known at compile-time | = help: within `Path1`, the trait `std::marker::Sized` is not implemented for `(dyn PathHelper1 + 'static)` - = note: to learn more, visit + = note: to learn more, visit = note: required because it appears within the type `Path1` = note: no field of an enum variant may have a dynamically sized type @@ -180,7 +180,7 @@ LL | VJ{x: Path2}, | ^^^^^^^^ doesn't have a size known at compile-time | = help: within `Path2`, the trait `std::marker::Sized` is not implemented for `(dyn PathHelper2 + 'static)` - = note: to learn more, visit + = note: to learn more, visit = note: required because it appears within the type `Path2` = note: no field of an enum variant may have a dynamically sized type @@ -191,7 +191,7 @@ LL | VK(isize, Path3), | ^^^^^ doesn't have a size known at compile-time | = help: within `Path3`, the trait `std::marker::Sized` is not implemented for `(dyn PathHelper3 + 'static)` - = note: to learn more, visit + = note: to learn more, visit = note: required because it appears within the type `Path3` = note: no field of an enum variant may have a dynamically sized type @@ -202,7 +202,7 @@ LL | VL{u: isize, x: Path4}, | ^^^^^^^^ doesn't have a size known at compile-time | = help: within `Path4`, the trait `std::marker::Sized` is not implemented for `(dyn PathHelper4 + 'static)` - = note: to learn more, visit + = note: to learn more, visit = note: required because it appears within the type `Path4` = note: no field of an enum variant may have a dynamically sized type diff --git a/src/test/ui/unsized/unsized-inherent-impl-self-type.stderr b/src/test/ui/unsized/unsized-inherent-impl-self-type.stderr index 1d157bf5b3654..98eecabc84cb8 100644 --- a/src/test/ui/unsized/unsized-inherent-impl-self-type.stderr +++ b/src/test/ui/unsized/unsized-inherent-impl-self-type.stderr @@ -5,7 +5,7 @@ LL | impl S5 { | ^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `X` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound note: required by `S5` --> $DIR/unsized-inherent-impl-self-type.rs:5:1 diff --git a/src/test/ui/unsized/unsized-struct.stderr b/src/test/ui/unsized/unsized-struct.stderr index a72b3cf1783c7..7add65c07866b 100644 --- a/src/test/ui/unsized/unsized-struct.stderr +++ b/src/test/ui/unsized/unsized-struct.stderr @@ -5,7 +5,7 @@ LL | fn foo2() { not_sized::>() } | ^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `T` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where T: std::marker::Sized` bound note: required by `Foo` --> $DIR/unsized-struct.rs:4:1 @@ -20,7 +20,7 @@ LL | fn bar2() { is_sized::>() } | ^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: within `Bar`, the trait `std::marker::Sized` is not implemented for `T` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where T: std::marker::Sized` bound = note: required because it appears within the type `Bar` note: required by `is_sized` diff --git a/src/test/ui/unsized/unsized-trait-impl-self-type.stderr b/src/test/ui/unsized/unsized-trait-impl-self-type.stderr index 53ddad9356240..c39f3652b647c 100644 --- a/src/test/ui/unsized/unsized-trait-impl-self-type.stderr +++ b/src/test/ui/unsized/unsized-trait-impl-self-type.stderr @@ -5,7 +5,7 @@ LL | impl T3 for S5 { | ^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `X` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound note: required by `S5` --> $DIR/unsized-trait-impl-self-type.rs:8:1 diff --git a/src/test/ui/unsized/unsized-trait-impl-trait-arg.stderr b/src/test/ui/unsized/unsized-trait-impl-trait-arg.stderr index e664c1d258128..ee0d5ccccfe11 100644 --- a/src/test/ui/unsized/unsized-trait-impl-trait-arg.stderr +++ b/src/test/ui/unsized/unsized-trait-impl-trait-arg.stderr @@ -5,7 +5,7 @@ LL | impl T2 for S4 { | ^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `X` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound error: aborting due to previous error diff --git a/src/test/ui/unsized3.stderr b/src/test/ui/unsized3.stderr index 8c2d713d4e3bf..2c7b86c5d8284 100644 --- a/src/test/ui/unsized3.stderr +++ b/src/test/ui/unsized3.stderr @@ -5,7 +5,7 @@ LL | f2::(x); | ^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `X` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound note: required by `f2` --> $DIR/unsized3.rs:10:1 @@ -20,7 +20,7 @@ LL | f4::(x); | ^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `X` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound note: required by `f4` --> $DIR/unsized3.rs:21:1 @@ -35,7 +35,7 @@ LL | f5(x1); | ^^ doesn't have a size known at compile-time | = help: within `S`, the trait `std::marker::Sized` is not implemented for `X` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound = note: required because it appears within the type `S` note: required by `f5` @@ -51,7 +51,7 @@ LL | f5(&(*x1, 34)); | ^^ doesn't have a size known at compile-time | = help: within `S`, the trait `std::marker::Sized` is not implemented for `X` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound = note: required because it appears within the type `S` = note: only the last element of a tuple may have a dynamically sized type @@ -63,7 +63,7 @@ LL | f5(&(32, *x1)); | ^^^^^^^^^ doesn't have a size known at compile-time | = help: within `({integer}, S)`, the trait `std::marker::Sized` is not implemented for `X` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound = note: required because it appears within the type `S` = note: required because it appears within the type `({integer}, S)` @@ -76,7 +76,7 @@ LL | f5(&(32, *x1)); | ^^ doesn't have a size known at compile-time | = help: within `({integer}, S)`, the trait `std::marker::Sized` is not implemented for `X` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound = note: required because it appears within the type `S` = note: required because it appears within the type `({integer}, S)` diff --git a/src/test/ui/unsized5.stderr b/src/test/ui/unsized5.stderr index 9dc8c8f6ee14e..6dce9a046066f 100644 --- a/src/test/ui/unsized5.stderr +++ b/src/test/ui/unsized5.stderr @@ -5,7 +5,7 @@ LL | f1: X, | ^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `X` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound = note: only the last field of a struct may have a dynamically sized type @@ -16,7 +16,7 @@ LL | g: X, | ^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `X` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound = note: only the last field of a struct may have a dynamically sized type @@ -27,7 +27,7 @@ LL | f: str, | ^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit = note: only the last field of a struct may have a dynamically sized type error[E0277]: the size for values of type `[u8]` cannot be known at compilation time @@ -37,7 +37,7 @@ LL | f: [u8], | ^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[u8]` - = note: to learn more, visit + = note: to learn more, visit = note: only the last field of a struct may have a dynamically sized type error[E0277]: the size for values of type `X` cannot be known at compilation time @@ -47,7 +47,7 @@ LL | V1(X, isize), | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `X` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound = note: no field of an enum variant may have a dynamically sized type @@ -58,7 +58,7 @@ LL | V2{f1: X, f: isize}, | ^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `X` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound = note: no field of an enum variant may have a dynamically sized type diff --git a/src/test/ui/unsized6.stderr b/src/test/ui/unsized6.stderr index 058c22e2145e4..a6a26573e7c59 100644 --- a/src/test/ui/unsized6.stderr +++ b/src/test/ui/unsized6.stderr @@ -5,7 +5,7 @@ LL | let y: Y; | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `Y` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where Y: std::marker::Sized` bound = note: all local variables must have a statically known size = help: unsized locals are gated as an unstable feature @@ -17,7 +17,7 @@ LL | let _: (isize, (X, isize)); | ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `X` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound = note: only the last element of a tuple may have a dynamically sized type @@ -28,7 +28,7 @@ LL | let y: (isize, (Z, usize)); | ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `Z` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where Z: std::marker::Sized` bound = note: only the last element of a tuple may have a dynamically sized type @@ -39,7 +39,7 @@ LL | let y: X; | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `X` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound = note: all local variables must have a statically known size = help: unsized locals are gated as an unstable feature @@ -51,7 +51,7 @@ LL | let y: (isize, (Y, isize)); | ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `Y` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where Y: std::marker::Sized` bound = note: only the last element of a tuple may have a dynamically sized type @@ -62,7 +62,7 @@ LL | let y: X = *x1; | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `X` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound = note: all local variables must have a statically known size = help: unsized locals are gated as an unstable feature @@ -74,7 +74,7 @@ LL | let y = *x2; | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `X` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound = note: all local variables must have a statically known size = help: unsized locals are gated as an unstable feature @@ -86,7 +86,7 @@ LL | let (y, z) = (*x3, 4); | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `X` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound = note: all local variables must have a statically known size = help: unsized locals are gated as an unstable feature @@ -98,7 +98,7 @@ LL | let y: X = *x1; | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `X` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound = note: all local variables must have a statically known size = help: unsized locals are gated as an unstable feature @@ -110,7 +110,7 @@ LL | let y = *x2; | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `X` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound = note: all local variables must have a statically known size = help: unsized locals are gated as an unstable feature @@ -122,7 +122,7 @@ LL | let (y, z) = (*x3, 4); | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `X` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound = note: all local variables must have a statically known size = help: unsized locals are gated as an unstable feature @@ -134,7 +134,7 @@ LL | fn g1(x: X) {} | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `X` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound = note: all local variables must have a statically known size = help: unsized locals are gated as an unstable feature @@ -146,7 +146,7 @@ LL | fn g2(x: X) {} | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `X` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound = note: all local variables must have a statically known size = help: unsized locals are gated as an unstable feature diff --git a/src/test/ui/unsized7.stderr b/src/test/ui/unsized7.stderr index 90f5a1f02d6c1..bb83b1811844a 100644 --- a/src/test/ui/unsized7.stderr +++ b/src/test/ui/unsized7.stderr @@ -5,7 +5,7 @@ LL | impl T1 for S3 { | ^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `X` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound error: aborting due to previous error diff --git a/src/test/ui/utf8_idents.rs b/src/test/ui/utf8_idents.rs index c9f433c3c3b3d..bed0d9bb2be54 100644 --- a/src/test/ui/utf8_idents.rs +++ b/src/test/ui/utf8_idents.rs @@ -3,6 +3,7 @@ fn foo< 'β, //~ ERROR non-ascii idents are not fully supported γ //~ ERROR non-ascii idents are not fully supported + //~^ WARN type parameter `γ` should have a camel case name such as `Γ` >() {} struct X { diff --git a/src/test/ui/utf8_idents.stderr b/src/test/ui/utf8_idents.stderr index b1bb4a3001557..1ccf767491cdb 100644 --- a/src/test/ui/utf8_idents.stderr +++ b/src/test/ui/utf8_idents.stderr @@ -15,7 +15,7 @@ LL | γ //~ ERROR non-ascii idents are not fully supported = help: add #![feature(non_ascii_idents)] to the crate attributes to enable error[E0658]: non-ascii idents are not fully supported. (see issue #55467) - --> $DIR/utf8_idents.rs:9:5 + --> $DIR/utf8_idents.rs:10:5 | LL | δ: usize //~ ERROR non-ascii idents are not fully supported | ^ @@ -23,13 +23,21 @@ LL | δ: usize //~ ERROR non-ascii idents are not fully supported = help: add #![feature(non_ascii_idents)] to the crate attributes to enable error[E0658]: non-ascii idents are not fully supported. (see issue #55467) - --> $DIR/utf8_idents.rs:13:9 + --> $DIR/utf8_idents.rs:14:9 | LL | let α = 0.00001f64; //~ ERROR non-ascii idents are not fully supported | ^ | = help: add #![feature(non_ascii_idents)] to the crate attributes to enable +warning: type parameter `γ` should have a camel case name such as `Γ` + --> $DIR/utf8_idents.rs:5:5 + | +LL | γ //~ ERROR non-ascii idents are not fully supported + | ^ + | + = note: #[warn(non_camel_case_types)] on by default + error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/wf/wf-array-elem-sized.stderr b/src/test/ui/wf/wf-array-elem-sized.stderr index 249a2d0930598..69df9ea7857d5 100644 --- a/src/test/ui/wf/wf-array-elem-sized.stderr +++ b/src/test/ui/wf/wf-array-elem-sized.stderr @@ -5,7 +5,7 @@ LL | foo: [[u8]], //~ ERROR E0277 | ^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[u8]` - = note: to learn more, visit + = note: to learn more, visit = note: slice and array elements must have `Sized` type error: aborting due to previous error diff --git a/src/test/ui/wf/wf-fn-where-clause.stderr b/src/test/ui/wf/wf-fn-where-clause.stderr index 62305be599e33..594ce7d2f49ca 100644 --- a/src/test/ui/wf/wf-fn-where-clause.stderr +++ b/src/test/ui/wf/wf-fn-where-clause.stderr @@ -20,7 +20,7 @@ LL | fn bar() where Vec:, {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn std::marker::Copy + 'static)` - = note: to learn more, visit + = note: to learn more, visit = note: required by `std::vec::Vec` error[E0038]: the trait `std::marker::Copy` cannot be made into an object