From 48fff6f9ada2de37ad05db1084641323e7085d7d Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Wed, 9 Oct 2019 08:50:39 -0400 Subject: [PATCH 01/11] don't assume we can *always* find a return type hint in async fn In particular, we sometimes cannot if there is an earlier error. --- src/librustc_typeck/check/closure.rs | 15 ++++++++++++--- src/test/ui/async-await/issues/issue-65159.rs | 10 ++++++++++ src/test/ui/async-await/issues/issue-65159.stderr | 9 +++++++++ 3 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 src/test/ui/async-await/issues/issue-65159.rs create mode 100644 src/test/ui/async-await/issues/issue-65159.stderr diff --git a/src/librustc_typeck/check/closure.rs b/src/librustc_typeck/check/closure.rs index 8b97bf643e9bb..4f4133954cf1d 100644 --- a/src/librustc_typeck/check/closure.rs +++ b/src/librustc_typeck/check/closure.rs @@ -611,6 +611,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { Some(hir::GeneratorKind::Async(hir::AsyncGeneratorKind::Fn)) => { debug!("supplied_sig_of_closure: closure is async fn body"); self.deduce_future_output_from_obligations(expr_def_id) + .unwrap_or_else(|| { + // AFAIK, deducing the future output + // always succeeds *except* in error cases + // like #65159. I'd like to return Error + // here, but I can't because I can't + // easily (and locally) prove that we + // *have* reported an + // error. --nikomatsakis + astconv.ty_infer(None, decl.output.span()) + }) } _ => astconv.ty_infer(None, decl.output.span()), @@ -645,7 +655,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { fn deduce_future_output_from_obligations( &self, expr_def_id: DefId, - ) -> Ty<'tcx> { + ) -> Option> { debug!("deduce_future_output_from_obligations(expr_def_id={:?})", expr_def_id); let ret_coercion = @@ -688,8 +698,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } else { None } - }) - .unwrap(); + }); debug!("deduce_future_output_from_obligations: output_ty={:?}", output_ty); output_ty diff --git a/src/test/ui/async-await/issues/issue-65159.rs b/src/test/ui/async-await/issues/issue-65159.rs new file mode 100644 index 0000000000000..b5fee061f277e --- /dev/null +++ b/src/test/ui/async-await/issues/issue-65159.rs @@ -0,0 +1,10 @@ +// Regression test for #65159. We used to ICE. +// +// edition:2018 + +async fn copy() -> Result<()> //~ ERROR wrong number of type arguments +{ + Ok(()) +} + +fn main() { } diff --git a/src/test/ui/async-await/issues/issue-65159.stderr b/src/test/ui/async-await/issues/issue-65159.stderr new file mode 100644 index 0000000000000..56d2c38b302e9 --- /dev/null +++ b/src/test/ui/async-await/issues/issue-65159.stderr @@ -0,0 +1,9 @@ +error[E0107]: wrong number of type arguments: expected 2, found 1 + --> $DIR/issue-65159.rs:5:20 + | +LL | async fn copy() -> Result<()> + | ^^^^^^^^^^ expected 2 type arguments + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0107`. From 061b906683eccd01b59f848a7941f3fd7aff8b00 Mon Sep 17 00:00:00 2001 From: Dylan MacKenzie Date: Sun, 13 Oct 2019 12:27:11 -0700 Subject: [PATCH 02/11] Return `false` from `needs_drop` for all zero-sized arrays --- src/librustc/ty/util.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/librustc/ty/util.rs b/src/librustc/ty/util.rs index 5ddf15317a31c..b6e8b8b92e6c6 100644 --- a/src/librustc/ty/util.rs +++ b/src/librustc/ty/util.rs @@ -1096,6 +1096,9 @@ fn needs_drop_raw<'tcx>(tcx: TyCtxt<'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<'tcx> ty::UnnormalizedProjection(..) => bug!("only used with chalk-engine"), + // Zero-length arrays never contain anything to drop. + ty::Array(_, len) if len.try_eval_usize(tcx, param_env) == Some(0) => false, + // Structural recursion. ty::Array(ty, _) | ty::Slice(ty) => needs_drop(ty), From 8fd16baa57aafd4959bda052dad261da997e6862 Mon Sep 17 00:00:00 2001 From: Dylan MacKenzie Date: Sun, 13 Oct 2019 12:27:45 -0700 Subject: [PATCH 03/11] Remove special case for zero-sized arrays from indirectly mut locals --- .../dataflow/impls/indirect_mutation.rs | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/librustc_mir/dataflow/impls/indirect_mutation.rs b/src/librustc_mir/dataflow/impls/indirect_mutation.rs index 990425c3252e0..bc09e32717926 100644 --- a/src/librustc_mir/dataflow/impls/indirect_mutation.rs +++ b/src/librustc_mir/dataflow/impls/indirect_mutation.rs @@ -104,25 +104,16 @@ impl<'tcx> TransferFunction<'_, '_, 'tcx> { kind: mir::BorrowKind, borrowed_place: &mir::Place<'tcx>, ) -> bool { - let borrowed_ty = borrowed_place.ty(self.body, self.tcx).ty; - - // Zero-sized types cannot be mutated, since there is nothing inside to mutate. - // - // FIXME: For now, we only exempt arrays of length zero. We need to carefully - // consider the effects before extending this to all ZSTs. - if let ty::Array(_, len) = borrowed_ty.kind { - if len.try_eval_usize(self.tcx, self.param_env) == Some(0) { - return false; - } - } - match kind { mir::BorrowKind::Mut { .. } => true, | mir::BorrowKind::Shared | mir::BorrowKind::Shallow | mir::BorrowKind::Unique - => !borrowed_ty.is_freeze(self.tcx, self.param_env, DUMMY_SP), + => !borrowed_place + .ty(self.body, self.tcx) + .ty + .is_freeze(self.tcx, self.param_env, DUMMY_SP), } } } From c08a8713381ed67caea826a793145240cd873081 Mon Sep 17 00:00:00 2001 From: Dylan MacKenzie Date: Sun, 13 Oct 2019 16:00:49 -0700 Subject: [PATCH 04/11] Add regression test for #65348 --- src/test/ui/consts/issue-65348.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/test/ui/consts/issue-65348.rs diff --git a/src/test/ui/consts/issue-65348.rs b/src/test/ui/consts/issue-65348.rs new file mode 100644 index 0000000000000..5eafa831d6317 --- /dev/null +++ b/src/test/ui/consts/issue-65348.rs @@ -0,0 +1,23 @@ +// check-pass + +struct Generic(T); + +impl Generic { + const ARRAY: [T; 0] = []; + const NEWTYPE_ARRAY: Generic<[T; 0]> = Generic([]); + const ARRAY_FIELD: Generic<(i32, [T; 0])> = Generic((0, [])); +} + +pub const fn array() -> &'static T { + &Generic::::ARRAY[0] +} + +pub const fn newtype_array() -> &'static T { + &Generic::::NEWTYPE_ARRAY.0[0] +} + +pub const fn array_field() -> &'static T { + &(Generic::::ARRAY_FIELD.0).1[0] +} + +fn main() {} From f81b1548ddf886449d8ea95f82b56274b60fbac7 Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Mon, 14 Oct 2019 10:34:21 +0200 Subject: [PATCH 05/11] Add troubleshooting section to PGO chapter in rustc book. --- src/doc/rustc/src/profile-guided-optimization.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/doc/rustc/src/profile-guided-optimization.md b/src/doc/rustc/src/profile-guided-optimization.md index 38be07a6440da..d066f4a9cf59c 100644 --- a/src/doc/rustc/src/profile-guided-optimization.md +++ b/src/doc/rustc/src/profile-guided-optimization.md @@ -125,6 +125,17 @@ RUSTFLAGS="-Cprofile-use=/tmp/pgo-data/merged.profdata" \ cargo build --release --target=x86_64-unknown-linux-gnu ``` +### Troubleshooting + +- It is recommended to pass `-Cllvm-args=-pgo-warn-missing-function` during the + `-Cprofile-use` phase. LLVM by default does not warn if it cannot find + profiling data for a given function. Enabling this warning will make it + easier to spot errors in your setup. + +- There is a [known issue](https://github.com/rust-lang/cargo/issues/7416) in + Cargo prior to version 1.39 that will prevent PGO from working correctly. Be + sure to use Cargo 1.39 or newer when doing PGO. + ## Further Reading `rustc`'s PGO support relies entirely on LLVM's implementation of the feature From 7528234be8be9e6b39d9ba78d0b6819e45c2aa06 Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Mon, 14 Oct 2019 18:04:00 +0200 Subject: [PATCH 06/11] Add regression test for issue #64153. --- .../run-make-fulldeps/issue-64153/Makefile | 20 +++++++++++++++++++ .../issue-64153/downstream.rs | 6 ++++++ .../run-make-fulldeps/issue-64153/upstream.rs | 6 ++++++ 3 files changed, 32 insertions(+) create mode 100644 src/test/run-make-fulldeps/issue-64153/Makefile create mode 100644 src/test/run-make-fulldeps/issue-64153/downstream.rs create mode 100644 src/test/run-make-fulldeps/issue-64153/upstream.rs diff --git a/src/test/run-make-fulldeps/issue-64153/Makefile b/src/test/run-make-fulldeps/issue-64153/Makefile new file mode 100644 index 0000000000000..d6848f4043bdf --- /dev/null +++ b/src/test/run-make-fulldeps/issue-64153/Makefile @@ -0,0 +1,20 @@ +-include ../tools.mk + +# Staticlibs don't include Rust object files from upstream crates if the same +# code was already pulled into the lib via LTO. However, the bug described in +# https://github.com/rust-lang/rust/issues/64153 lead to this exclusion not +# working properly if the upstream crate was compiled with an explicit filename +# (via `-o`). +# +# This test makes sure that functions defined in the upstream crates do not +# appear twice in the final staticlib when listing all the symbols from it. + +all: + $(RUSTC) --crate-type rlib upstream.rs -o $(TMPDIR)/libupstream.rlib -Ccodegen-units=1 + $(RUSTC) --crate-type staticlib downstream.rs -Clto -Ccodegen-units=1 -o $(TMPDIR)/libdownstream.a + # Dump all the symbols from the staticlib into `syms` + nm $(TMPDIR)/libdownstream.a > $(TMPDIR)/syms + # Count the global instances of `issue64153_test_function`. There'll be 2 + # if the `upstream` object file got erronously included twice. + grep -c -e "[[:space:]]T[[:space:]]issue64153_test_function" $(TMPDIR)/syms > $(TMPDIR)/count + [ "$$(cat $(TMPDIR)/count)" -eq "1" ] diff --git a/src/test/run-make-fulldeps/issue-64153/downstream.rs b/src/test/run-make-fulldeps/issue-64153/downstream.rs new file mode 100644 index 0000000000000..e03704665d46c --- /dev/null +++ b/src/test/run-make-fulldeps/issue-64153/downstream.rs @@ -0,0 +1,6 @@ +extern crate upstream; + +#[no_mangle] +pub extern "C" fn foo() { + print!("1 + 1 = {}", upstream::issue64153_test_function(1)); +} diff --git a/src/test/run-make-fulldeps/issue-64153/upstream.rs b/src/test/run-make-fulldeps/issue-64153/upstream.rs new file mode 100644 index 0000000000000..861a00298ea39 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-64153/upstream.rs @@ -0,0 +1,6 @@ +// Make this function extern "C", public, and no-mangle, so that it gets +// exported from the downstream staticlib. +#[no_mangle] +pub extern "C" fn issue64153_test_function(x: u32) -> u32 { + x + 1 +} From af05b235249738c2a155d3ade22670070bf5787a Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Tue, 15 Oct 2019 13:42:27 +0200 Subject: [PATCH 07/11] Fix issue #64153 by checking for .rcgu.o suffix when trying to identify Rust generated object files. --- src/librustc_codegen_llvm/back/archive.rs | 6 ++++-- src/librustc_codegen_ssa/back/link.rs | 21 ++++---------------- src/librustc_codegen_ssa/lib.rs | 24 +++++++++++++++++++++-- 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/src/librustc_codegen_llvm/back/archive.rs b/src/librustc_codegen_llvm/back/archive.rs index 68d3f90cd3991..e169cfc4cc829 100644 --- a/src/librustc_codegen_llvm/back/archive.rs +++ b/src/librustc_codegen_llvm/back/archive.rs @@ -9,7 +9,9 @@ use std::str; use crate::llvm::archive_ro::{ArchiveRO, Child}; use crate::llvm::{self, ArchiveKind}; -use rustc_codegen_ssa::{METADATA_FILENAME, RLIB_BYTECODE_EXTENSION}; +use rustc_codegen_ssa::{ + METADATA_FILENAME, RLIB_BYTECODE_EXTENSION, looks_like_rust_object_file +}; use rustc_codegen_ssa::back::archive::{ArchiveBuilder, find_library}; use rustc::session::Session; use syntax::symbol::Symbol; @@ -141,7 +143,7 @@ impl<'a> ArchiveBuilder<'a> for LlvmArchiveBuilder<'a> { } // Don't include Rust objects if LTO is enabled - if lto && fname.starts_with(&obj_start) && fname.ends_with(".o") { + if lto && looks_like_rust_object_file(fname) { return true } diff --git a/src/librustc_codegen_ssa/back/link.rs b/src/librustc_codegen_ssa/back/link.rs index 1c5d3b1a890ee..a2b50ea8e2bf7 100644 --- a/src/librustc_codegen_ssa/back/link.rs +++ b/src/librustc_codegen_ssa/back/link.rs @@ -3,7 +3,7 @@ use rustc::session::{Session, filesearch}; use rustc::session::config::{ - self, RUST_CGU_EXT, DebugInfo, OutputFilenames, OutputType, PrintRequest, Sanitizer + self, DebugInfo, OutputFilenames, OutputType, PrintRequest, Sanitizer }; use rustc::session::search_paths::PathKind; use rustc::middle::dependency_format::Linkage; @@ -15,7 +15,8 @@ use rustc_fs_util::fix_windows_verbatim_for_gcc; use rustc_target::spec::{PanicStrategy, RelroLevel, LinkerFlavor}; use syntax::symbol::Symbol; -use crate::{METADATA_FILENAME, RLIB_BYTECODE_EXTENSION, CrateInfo, CodegenResults}; +use crate::{METADATA_FILENAME, RLIB_BYTECODE_EXTENSION, CrateInfo, + looks_like_rust_object_file, CodegenResults}; use super::archive::ArchiveBuilder; use super::command::Command; use super::linker::Linker; @@ -1549,23 +1550,9 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>( let canonical = f.replace("-", "_"); let canonical_name = name.replace("-", "_"); - // Look for `.rcgu.o` at the end of the filename to conclude - // that this is a Rust-related object file. - fn looks_like_rust(s: &str) -> bool { - let path = Path::new(s); - let ext = path.extension().and_then(|s| s.to_str()); - if ext != Some(OutputType::Object.extension()) { - return false - } - let ext2 = path.file_stem() - .and_then(|s| Path::new(s).extension()) - .and_then(|s| s.to_str()); - ext2 == Some(RUST_CGU_EXT) - } - let is_rust_object = canonical.starts_with(&canonical_name) && - looks_like_rust(&f); + looks_like_rust_object_file(&f); // If we've been requested to skip all native object files // (those not generated by the rust compiler) then we can skip diff --git a/src/librustc_codegen_ssa/lib.rs b/src/librustc_codegen_ssa/lib.rs index 0221a04b04518..dd75883f97deb 100644 --- a/src/librustc_codegen_ssa/lib.rs +++ b/src/librustc_codegen_ssa/lib.rs @@ -22,9 +22,9 @@ #[macro_use] extern crate rustc; #[macro_use] extern crate syntax; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use rustc::dep_graph::WorkProduct; -use rustc::session::config::{OutputFilenames, OutputType}; +use rustc::session::config::{OutputFilenames, OutputType, RUST_CGU_EXT}; use rustc::middle::lang_items::LangItem; use rustc::hir::def_id::CrateNum; use rustc::ty::query::Providers; @@ -62,6 +62,7 @@ pub struct ModuleCodegen { pub const METADATA_FILENAME: &str = "rust.metadata.bin"; pub const RLIB_BYTECODE_EXTENSION: &str = "bc.z"; + impl ModuleCodegen { pub fn into_compiled_module(self, emit_obj: bool, @@ -166,3 +167,22 @@ pub fn provide_extern(providers: &mut Providers<'_>) { crate::back::symbol_export::provide_extern(providers); crate::base::provide_both(providers); } + +/// Checks if the given filename ends with the `.rcgu.o` extension that `rustc` +/// uses for the object files it generates. +pub fn looks_like_rust_object_file(filename: &str) -> bool { + let path = Path::new(filename); + let ext = path.extension().and_then(|s| s.to_str()); + if ext != Some(OutputType::Object.extension()) { + // The file name does not end with ".o", so it can't be an object file. + return false + } + + // Strip the ".o" at the end + let ext2 = path.file_stem() + .and_then(|s| Path::new(s).extension()) + .and_then(|s| s.to_str()); + + // Check if the "inner" extension + ext2 == Some(RUST_CGU_EXT) +} From 53187c5753e09006f0e03799ab01d7cb7ec676c7 Mon Sep 17 00:00:00 2001 From: phosphorus Date: Fri, 11 Oct 2019 20:16:09 +0800 Subject: [PATCH 08/11] Slides path lifetime to the lifetime resolver add test to for the fix add descriptive text for the fix simplified code logics update descriptive comments update to cope with the tidyness requirement merged commit suggestions Co-Authored-By: varkor truncated redundant comments update to cope with tidy-check --- src/librustc/hir/lowering.rs | 12 +++++++---- ...incorrect-explicit-lifetime-name-needed.rs | 14 +++++++++++++ ...rrect-explicit-lifetime-name-needed.stderr | 21 +++++++++++++++++++ 3 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 src/test/ui/generics/issue-65285-incorrect-explicit-lifetime-name-needed.rs create mode 100644 src/test/ui/generics/issue-65285-incorrect-explicit-lifetime-name-needed.stderr diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index 72fd054ee8a20..ecf16d9443055 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -3281,10 +3281,14 @@ impl<'a> LoweringContext<'a> { let id = self.sess.next_node_id(); self.new_named_lifetime(id, span, hir::LifetimeName::Error) } - // This is the normal case. - AnonymousLifetimeMode::PassThrough => self.new_implicit_lifetime(span), - - AnonymousLifetimeMode::ReportError => self.new_error_lifetime(None, span), + // `PassThrough` is the normal case. + // `new_error_lifetime`, which would usually be used in the case of `ReportError`, + // is unsuitable here, as these can occur from missing lifetime parameters in a + // `PathSegment`, for which there is no associated `'_` or `&T` with no explicit + // lifetime. Instead, we simply create an implicit lifetime, which will be checked + // later, at which point a suitable error will be emitted. + | AnonymousLifetimeMode::PassThrough + | AnonymousLifetimeMode::ReportError => self.new_implicit_lifetime(span), } } diff --git a/src/test/ui/generics/issue-65285-incorrect-explicit-lifetime-name-needed.rs b/src/test/ui/generics/issue-65285-incorrect-explicit-lifetime-name-needed.rs new file mode 100644 index 0000000000000..54b483f53d4cb --- /dev/null +++ b/src/test/ui/generics/issue-65285-incorrect-explicit-lifetime-name-needed.rs @@ -0,0 +1,14 @@ +#![crate_type="lib"] + +struct Nested(K); + +fn should_error() where T : Into<&u32> {} +//~^ ERROR `&` without an explicit lifetime name cannot be used here [E0637] + +trait X<'a, K: 'a> { + fn foo<'b, L: X<&'b Nested>>(); + //~^ ERROR missing lifetime specifier [E0106] +} + +fn bar<'b, L: X<&'b Nested>>(){} +//~^ ERROR missing lifetime specifier [E0106] diff --git a/src/test/ui/generics/issue-65285-incorrect-explicit-lifetime-name-needed.stderr b/src/test/ui/generics/issue-65285-incorrect-explicit-lifetime-name-needed.stderr new file mode 100644 index 0000000000000..8720288b53e58 --- /dev/null +++ b/src/test/ui/generics/issue-65285-incorrect-explicit-lifetime-name-needed.stderr @@ -0,0 +1,21 @@ +error[E0637]: `&` without an explicit lifetime name cannot be used here + --> $DIR/issue-65285-incorrect-explicit-lifetime-name-needed.rs:5:37 + | +LL | fn should_error() where T : Into<&u32> {} + | ^ explicit lifetime name needed here + +error[E0106]: missing lifetime specifier + --> $DIR/issue-65285-incorrect-explicit-lifetime-name-needed.rs:9:19 + | +LL | fn foo<'b, L: X<&'b Nested>>(); + | ^^^^^^^^^^^^^^^^ expected lifetime parameter + +error[E0106]: missing lifetime specifier + --> $DIR/issue-65285-incorrect-explicit-lifetime-name-needed.rs:13:15 + | +LL | fn bar<'b, L: X<&'b Nested>>(){} + | ^^^^^^^^^^^^^^^^^^ expected lifetime parameter + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0106`. From 1fb8cfb4815f99148cd94182accc99866de9a6d8 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Tue, 15 Oct 2019 15:28:42 +0200 Subject: [PATCH 09/11] Organize `never_type` tests Also move {run-fail -> ui}/never_type --- src/test/ui/coercion/coerce-issue-49593-box-never.rs | 2 +- .../ui/feature-gates/feature-gate-exhaustive-patterns.rs | 1 + .../feature-gates/feature-gate-exhaustive-patterns.stderr | 2 +- src/test/ui/for-loop-while/loop-break-value.rs | 1 + src/test/ui/lint/must_use-unit.rs | 1 - src/test/ui/lint/must_use-unit.stderr | 6 +++--- src/test/{run-fail => ui/never_type}/adjust_never.rs | 1 + .../ui/{ => never_type}/call-fn-never-arg-wrong-type.rs | 0 .../ui/{ => never_type}/call-fn-never-arg-wrong-type.stderr | 0 src/test/{run-fail => ui/never_type}/call-fn-never-arg.rs | 1 + src/test/{run-fail => ui/never_type}/cast-never.rs | 1 + src/test/ui/{ => never_type}/defaulted-never-note.rs | 0 src/test/ui/{ => never_type}/defaulted-never-note.stderr | 0 src/test/ui/{ => never_type}/dispatch_from_dyn_zst.rs | 0 .../ui/{ => never_type}/diverging-fallback-control-flow.rs | 1 + src/test/ui/{ => never_type}/impl-for-never.rs | 3 ++- src/test/ui/{issues => never_type}/issue-13352.rs | 0 src/test/ui/{issues => never_type}/issue-13352.stderr | 0 src/test/ui/{issues => never_type}/issue-2149.rs | 0 src/test/ui/{issues => never_type}/issue-2149.stderr | 0 src/test/ui/{issues => never_type}/issue-44402.rs | 3 ++- src/test/ui/{ => never_type}/never-assign-dead-code.rs | 4 ++-- src/test/ui/{ => never_type}/never-assign-dead-code.stderr | 4 ++-- src/test/ui/{ => never_type}/never-assign-wrong-type.rs | 0 src/test/ui/{ => never_type}/never-assign-wrong-type.stderr | 0 .../{run-fail => ui/never_type}/never-associated-type.rs | 1 + src/test/ui/{ => never_type}/never-from-impl-is-reserved.rs | 0 .../ui/{ => never_type}/never-from-impl-is-reserved.stderr | 0 src/test/ui/{ => never_type}/never-result.rs | 1 + src/test/{run-fail => ui/never_type}/never-type-arg.rs | 1 + src/test/ui/{ => never_type}/never-type-rvalues.rs | 0 src/test/ui/{ => never_type}/never_coercions.rs | 0 src/test/ui/{ => never_type}/never_transmute_never.rs | 2 +- src/test/ui/{ => never_type}/panic-uninitialized-zeroed.rs | 0 src/test/ui/{ => never_type}/try_from.rs | 0 .../auxiliary/unreachable_variant.rs | 0 src/test/ui/{unreachable => reachable}/unreachable-arm.rs | 0 .../ui/{unreachable => reachable}/unreachable-arm.stderr | 0 src/test/ui/{unreachable => reachable}/unreachable-code.rs | 0 .../ui/{unreachable => reachable}/unreachable-code.stderr | 0 .../ui/{unreachable => reachable}/unreachable-in-call.rs | 0 .../{unreachable => reachable}/unreachable-in-call.stderr | 0 .../{unreachable => reachable}/unreachable-loop-patterns.rs | 2 -- .../unreachable-loop-patterns.stderr | 6 +++--- .../{unreachable => reachable}/unreachable-try-pattern.rs | 2 +- .../unreachable-try-pattern.stderr | 0 .../ui/{unreachable => reachable}/unreachable-variant.rs | 0 .../{unreachable => reachable}/unreachable-variant.stderr | 0 .../{unreachable => reachable}/unwarned-match-on-never.rs | 0 .../unwarned-match-on-never.stderr | 0 src/test/ui/{ => uninhabited}/always-inhabited-union-ref.rs | 0 .../ui/{ => uninhabited}/always-inhabited-union-ref.stderr | 0 52 files changed, 27 insertions(+), 19 deletions(-) rename src/test/{run-fail => ui/never_type}/adjust_never.rs (93%) rename src/test/ui/{ => never_type}/call-fn-never-arg-wrong-type.rs (100%) rename src/test/ui/{ => never_type}/call-fn-never-arg-wrong-type.stderr (100%) rename src/test/{run-fail => ui/never_type}/call-fn-never-arg.rs (94%) rename src/test/{run-fail => ui/never_type}/cast-never.rs (93%) rename src/test/ui/{ => never_type}/defaulted-never-note.rs (100%) rename src/test/ui/{ => never_type}/defaulted-never-note.stderr (100%) rename src/test/ui/{ => never_type}/dispatch_from_dyn_zst.rs (100%) rename src/test/ui/{ => never_type}/diverging-fallback-control-flow.rs (99%) rename src/test/ui/{ => never_type}/impl-for-never.rs (99%) rename src/test/ui/{issues => never_type}/issue-13352.rs (100%) rename src/test/ui/{issues => never_type}/issue-13352.stderr (100%) rename src/test/ui/{issues => never_type}/issue-2149.rs (100%) rename src/test/ui/{issues => never_type}/issue-2149.stderr (100%) rename src/test/ui/{issues => never_type}/issue-44402.rs (90%) rename src/test/ui/{ => never_type}/never-assign-dead-code.rs (82%) rename src/test/ui/{ => never_type}/never-assign-dead-code.stderr (92%) rename src/test/ui/{ => never_type}/never-assign-wrong-type.rs (100%) rename src/test/ui/{ => never_type}/never-assign-wrong-type.stderr (100%) rename src/test/{run-fail => ui/never_type}/never-associated-type.rs (96%) rename src/test/ui/{ => never_type}/never-from-impl-is-reserved.rs (100%) rename src/test/ui/{ => never_type}/never-from-impl-is-reserved.stderr (100%) rename src/test/ui/{ => never_type}/never-result.rs (99%) rename src/test/{run-fail => ui/never_type}/never-type-arg.rs (95%) rename src/test/ui/{ => never_type}/never-type-rvalues.rs (100%) rename src/test/ui/{ => never_type}/never_coercions.rs (100%) rename src/test/ui/{ => never_type}/never_transmute_never.rs (87%) rename src/test/ui/{ => never_type}/panic-uninitialized-zeroed.rs (100%) rename src/test/ui/{ => never_type}/try_from.rs (100%) rename src/test/ui/{unreachable => reachable}/auxiliary/unreachable_variant.rs (100%) rename src/test/ui/{unreachable => reachable}/unreachable-arm.rs (100%) rename src/test/ui/{unreachable => reachable}/unreachable-arm.stderr (100%) rename src/test/ui/{unreachable => reachable}/unreachable-code.rs (100%) rename src/test/ui/{unreachable => reachable}/unreachable-code.stderr (100%) rename src/test/ui/{unreachable => reachable}/unreachable-in-call.rs (100%) rename src/test/ui/{unreachable => reachable}/unreachable-in-call.stderr (100%) rename src/test/ui/{unreachable => reachable}/unreachable-loop-patterns.rs (95%) rename src/test/ui/{unreachable => reachable}/unreachable-loop-patterns.stderr (73%) rename src/test/ui/{unreachable => reachable}/unreachable-try-pattern.rs (94%) rename src/test/ui/{unreachable => reachable}/unreachable-try-pattern.stderr (100%) rename src/test/ui/{unreachable => reachable}/unreachable-variant.rs (100%) rename src/test/ui/{unreachable => reachable}/unreachable-variant.stderr (100%) rename src/test/ui/{unreachable => reachable}/unwarned-match-on-never.rs (100%) rename src/test/ui/{unreachable => reachable}/unwarned-match-on-never.stderr (100%) rename src/test/ui/{ => uninhabited}/always-inhabited-union-ref.rs (100%) rename src/test/ui/{ => uninhabited}/always-inhabited-union-ref.stderr (100%) diff --git a/src/test/ui/coercion/coerce-issue-49593-box-never.rs b/src/test/ui/coercion/coerce-issue-49593-box-never.rs index f005245e6dcb9..5038eb3ebf458 100644 --- a/src/test/ui/coercion/coerce-issue-49593-box-never.rs +++ b/src/test/ui/coercion/coerce-issue-49593-box-never.rs @@ -1,4 +1,4 @@ -// build-pass (FIXME(62277): could be check-pass?) +// check-pass #![feature(never_type)] #![allow(unreachable_code)] diff --git a/src/test/ui/feature-gates/feature-gate-exhaustive-patterns.rs b/src/test/ui/feature-gates/feature-gate-exhaustive-patterns.rs index 27ff5ace25ddc..f0cc9ea70550e 100644 --- a/src/test/ui/feature-gates/feature-gate-exhaustive-patterns.rs +++ b/src/test/ui/feature-gates/feature-gate-exhaustive-patterns.rs @@ -1,4 +1,5 @@ #![feature(never_type)] + fn foo() -> Result { Ok(123) } diff --git a/src/test/ui/feature-gates/feature-gate-exhaustive-patterns.stderr b/src/test/ui/feature-gates/feature-gate-exhaustive-patterns.stderr index d77fbc1e8239d..08c36cece4cf9 100644 --- a/src/test/ui/feature-gates/feature-gate-exhaustive-patterns.stderr +++ b/src/test/ui/feature-gates/feature-gate-exhaustive-patterns.stderr @@ -1,5 +1,5 @@ error[E0005]: refutable pattern in local binding: `Err(_)` not covered - --> $DIR/feature-gate-exhaustive-patterns.rs:7:9 + --> $DIR/feature-gate-exhaustive-patterns.rs:8:9 | LL | let Ok(_x) = foo(); | ^^^^^^ pattern `Err(_)` not covered diff --git a/src/test/ui/for-loop-while/loop-break-value.rs b/src/test/ui/for-loop-while/loop-break-value.rs index e1edbbb929e6a..d7209fc4de867 100644 --- a/src/test/ui/for-loop-while/loop-break-value.rs +++ b/src/test/ui/for-loop-while/loop-break-value.rs @@ -1,4 +1,5 @@ // run-pass + #![allow(unreachable_code)] #![feature(never_type)] diff --git a/src/test/ui/lint/must_use-unit.rs b/src/test/ui/lint/must_use-unit.rs index 92568252164f6..4dd4798abb7ce 100644 --- a/src/test/ui/lint/must_use-unit.rs +++ b/src/test/ui/lint/must_use-unit.rs @@ -1,5 +1,4 @@ #![feature(never_type)] - #![deny(unused_must_use)] #[must_use] diff --git a/src/test/ui/lint/must_use-unit.stderr b/src/test/ui/lint/must_use-unit.stderr index f6229c0442f99..0a9939b2015b7 100644 --- a/src/test/ui/lint/must_use-unit.stderr +++ b/src/test/ui/lint/must_use-unit.stderr @@ -1,17 +1,17 @@ error: unused return value of `foo` that must be used - --> $DIR/must_use-unit.rs:14:5 + --> $DIR/must_use-unit.rs:13:5 | LL | foo(); | ^^^^^^ | note: lint level defined here - --> $DIR/must_use-unit.rs:3:9 + --> $DIR/must_use-unit.rs:2:9 | LL | #![deny(unused_must_use)] | ^^^^^^^^^^^^^^^ error: unused return value of `bar` that must be used - --> $DIR/must_use-unit.rs:16:5 + --> $DIR/must_use-unit.rs:15:5 | LL | bar(); | ^^^^^^ diff --git a/src/test/run-fail/adjust_never.rs b/src/test/ui/never_type/adjust_never.rs similarity index 93% rename from src/test/run-fail/adjust_never.rs rename to src/test/ui/never_type/adjust_never.rs index 8661a2f80a7ba..3aa5866ebfbeb 100644 --- a/src/test/run-fail/adjust_never.rs +++ b/src/test/ui/never_type/adjust_never.rs @@ -1,5 +1,6 @@ // Test that a variable of type ! can coerce to another type. +// run-fail // error-pattern:explicit #![feature(never_type)] diff --git a/src/test/ui/call-fn-never-arg-wrong-type.rs b/src/test/ui/never_type/call-fn-never-arg-wrong-type.rs similarity index 100% rename from src/test/ui/call-fn-never-arg-wrong-type.rs rename to src/test/ui/never_type/call-fn-never-arg-wrong-type.rs diff --git a/src/test/ui/call-fn-never-arg-wrong-type.stderr b/src/test/ui/never_type/call-fn-never-arg-wrong-type.stderr similarity index 100% rename from src/test/ui/call-fn-never-arg-wrong-type.stderr rename to src/test/ui/never_type/call-fn-never-arg-wrong-type.stderr diff --git a/src/test/run-fail/call-fn-never-arg.rs b/src/test/ui/never_type/call-fn-never-arg.rs similarity index 94% rename from src/test/run-fail/call-fn-never-arg.rs rename to src/test/ui/never_type/call-fn-never-arg.rs index f5b2cfaefe022..6218572f8a756 100644 --- a/src/test/run-fail/call-fn-never-arg.rs +++ b/src/test/ui/never_type/call-fn-never-arg.rs @@ -1,5 +1,6 @@ // Test that we can use a ! for an argument of type ! +// run-fail // error-pattern:wowzers! #![feature(never_type)] diff --git a/src/test/run-fail/cast-never.rs b/src/test/ui/never_type/cast-never.rs similarity index 93% rename from src/test/run-fail/cast-never.rs rename to src/test/ui/never_type/cast-never.rs index 0b05a4b911284..46072e186e0f2 100644 --- a/src/test/run-fail/cast-never.rs +++ b/src/test/ui/never_type/cast-never.rs @@ -1,5 +1,6 @@ // Test that we can explicitly cast ! to another type +// run-fail // error-pattern:explicit #![feature(never_type)] diff --git a/src/test/ui/defaulted-never-note.rs b/src/test/ui/never_type/defaulted-never-note.rs similarity index 100% rename from src/test/ui/defaulted-never-note.rs rename to src/test/ui/never_type/defaulted-never-note.rs diff --git a/src/test/ui/defaulted-never-note.stderr b/src/test/ui/never_type/defaulted-never-note.stderr similarity index 100% rename from src/test/ui/defaulted-never-note.stderr rename to src/test/ui/never_type/defaulted-never-note.stderr diff --git a/src/test/ui/dispatch_from_dyn_zst.rs b/src/test/ui/never_type/dispatch_from_dyn_zst.rs similarity index 100% rename from src/test/ui/dispatch_from_dyn_zst.rs rename to src/test/ui/never_type/dispatch_from_dyn_zst.rs diff --git a/src/test/ui/diverging-fallback-control-flow.rs b/src/test/ui/never_type/diverging-fallback-control-flow.rs similarity index 99% rename from src/test/ui/diverging-fallback-control-flow.rs rename to src/test/ui/never_type/diverging-fallback-control-flow.rs index 0f0f787b407d2..c68e6364ed406 100644 --- a/src/test/ui/diverging-fallback-control-flow.rs +++ b/src/test/ui/never_type/diverging-fallback-control-flow.rs @@ -4,6 +4,7 @@ #![allow(unused_assignments)] #![allow(unused_variables)] #![allow(unreachable_code)] + // Test various cases where we permit an unconstrained variable // to fallback based on control-flow. // diff --git a/src/test/ui/impl-for-never.rs b/src/test/ui/never_type/impl-for-never.rs similarity index 99% rename from src/test/ui/impl-for-never.rs rename to src/test/ui/never_type/impl-for-never.rs index c5f12981ecc26..9423f08858b9b 100644 --- a/src/test/ui/impl-for-never.rs +++ b/src/test/ui/never_type/impl-for-never.rs @@ -1,8 +1,9 @@ // run-pass -// Test that we can call static methods on ! both directly and when it appears in a generic #![feature(never_type)] +// Test that we can call static methods on ! both directly and when it appears in a generic + trait StringifyType { fn stringify_type() -> &'static str; } diff --git a/src/test/ui/issues/issue-13352.rs b/src/test/ui/never_type/issue-13352.rs similarity index 100% rename from src/test/ui/issues/issue-13352.rs rename to src/test/ui/never_type/issue-13352.rs diff --git a/src/test/ui/issues/issue-13352.stderr b/src/test/ui/never_type/issue-13352.stderr similarity index 100% rename from src/test/ui/issues/issue-13352.stderr rename to src/test/ui/never_type/issue-13352.stderr diff --git a/src/test/ui/issues/issue-2149.rs b/src/test/ui/never_type/issue-2149.rs similarity index 100% rename from src/test/ui/issues/issue-2149.rs rename to src/test/ui/never_type/issue-2149.rs diff --git a/src/test/ui/issues/issue-2149.stderr b/src/test/ui/never_type/issue-2149.stderr similarity index 100% rename from src/test/ui/issues/issue-2149.stderr rename to src/test/ui/never_type/issue-2149.stderr diff --git a/src/test/ui/issues/issue-44402.rs b/src/test/ui/never_type/issue-44402.rs similarity index 90% rename from src/test/ui/issues/issue-44402.rs rename to src/test/ui/never_type/issue-44402.rs index 29b7eb5ee49c7..699e480dfe7e5 100644 --- a/src/test/ui/issues/issue-44402.rs +++ b/src/test/ui/never_type/issue-44402.rs @@ -1,4 +1,5 @@ -// build-pass (FIXME(62277): could be check-pass?) +// check-pass + #![allow(dead_code)] #![feature(never_type)] #![feature(exhaustive_patterns)] diff --git a/src/test/ui/never-assign-dead-code.rs b/src/test/ui/never_type/never-assign-dead-code.rs similarity index 82% rename from src/test/ui/never-assign-dead-code.rs rename to src/test/ui/never_type/never-assign-dead-code.rs index fd5fbc30611a9..7bb7c87097c50 100644 --- a/src/test/ui/never-assign-dead-code.rs +++ b/src/test/ui/never_type/never-assign-dead-code.rs @@ -1,10 +1,10 @@ // Test that an assignment of type ! makes the rest of the block dead code. +// check-pass + #![feature(never_type)] -// build-pass (FIXME(62277): could be check-pass?) #![warn(unused)] - fn main() { let x: ! = panic!("aah"); //~ WARN unused drop(x); //~ WARN unreachable diff --git a/src/test/ui/never-assign-dead-code.stderr b/src/test/ui/never_type/never-assign-dead-code.stderr similarity index 92% rename from src/test/ui/never-assign-dead-code.stderr rename to src/test/ui/never_type/never-assign-dead-code.stderr index b887d580e68a9..1860150fa8bc6 100644 --- a/src/test/ui/never-assign-dead-code.stderr +++ b/src/test/ui/never_type/never-assign-dead-code.stderr @@ -7,7 +7,7 @@ LL | drop(x); | ^^^^^^^^ unreachable statement | note: lint level defined here - --> $DIR/never-assign-dead-code.rs:5:9 + --> $DIR/never-assign-dead-code.rs:6:9 | LL | #![warn(unused)] | ^^^^^^ @@ -29,7 +29,7 @@ LL | let x: ! = panic!("aah"); | ^ help: consider prefixing with an underscore: `_x` | note: lint level defined here - --> $DIR/never-assign-dead-code.rs:5:9 + --> $DIR/never-assign-dead-code.rs:6:9 | LL | #![warn(unused)] | ^^^^^^ diff --git a/src/test/ui/never-assign-wrong-type.rs b/src/test/ui/never_type/never-assign-wrong-type.rs similarity index 100% rename from src/test/ui/never-assign-wrong-type.rs rename to src/test/ui/never_type/never-assign-wrong-type.rs diff --git a/src/test/ui/never-assign-wrong-type.stderr b/src/test/ui/never_type/never-assign-wrong-type.stderr similarity index 100% rename from src/test/ui/never-assign-wrong-type.stderr rename to src/test/ui/never_type/never-assign-wrong-type.stderr diff --git a/src/test/run-fail/never-associated-type.rs b/src/test/ui/never_type/never-associated-type.rs similarity index 96% rename from src/test/run-fail/never-associated-type.rs rename to src/test/ui/never_type/never-associated-type.rs index 587f0f72d5a62..7f0a3fef6a99a 100644 --- a/src/test/run-fail/never-associated-type.rs +++ b/src/test/ui/never_type/never-associated-type.rs @@ -1,5 +1,6 @@ // Test that we can use ! as an associated type. +// run-fail // error-pattern:kapow! #![feature(never_type)] diff --git a/src/test/ui/never-from-impl-is-reserved.rs b/src/test/ui/never_type/never-from-impl-is-reserved.rs similarity index 100% rename from src/test/ui/never-from-impl-is-reserved.rs rename to src/test/ui/never_type/never-from-impl-is-reserved.rs diff --git a/src/test/ui/never-from-impl-is-reserved.stderr b/src/test/ui/never_type/never-from-impl-is-reserved.stderr similarity index 100% rename from src/test/ui/never-from-impl-is-reserved.stderr rename to src/test/ui/never_type/never-from-impl-is-reserved.stderr diff --git a/src/test/ui/never-result.rs b/src/test/ui/never_type/never-result.rs similarity index 99% rename from src/test/ui/never-result.rs rename to src/test/ui/never_type/never-result.rs index 98ce326aa6631..35af37910ef3e 100644 --- a/src/test/ui/never-result.rs +++ b/src/test/ui/never_type/never-result.rs @@ -2,6 +2,7 @@ #![allow(unused_variables)] #![allow(unreachable_code)] + // Test that we can extract a ! through pattern matching then use it as several different types. #![feature(never_type)] diff --git a/src/test/run-fail/never-type-arg.rs b/src/test/ui/never_type/never-type-arg.rs similarity index 95% rename from src/test/run-fail/never-type-arg.rs rename to src/test/ui/never_type/never-type-arg.rs index 1747e96eef4e3..a82d351f6cf2b 100644 --- a/src/test/run-fail/never-type-arg.rs +++ b/src/test/ui/never_type/never-type-arg.rs @@ -1,5 +1,6 @@ // Test that we can use ! as an argument to a trait impl. +// run-fail // error-pattern:oh no! #![feature(never_type)] diff --git a/src/test/ui/never-type-rvalues.rs b/src/test/ui/never_type/never-type-rvalues.rs similarity index 100% rename from src/test/ui/never-type-rvalues.rs rename to src/test/ui/never_type/never-type-rvalues.rs diff --git a/src/test/ui/never_coercions.rs b/src/test/ui/never_type/never_coercions.rs similarity index 100% rename from src/test/ui/never_coercions.rs rename to src/test/ui/never_type/never_coercions.rs diff --git a/src/test/ui/never_transmute_never.rs b/src/test/ui/never_type/never_transmute_never.rs similarity index 87% rename from src/test/ui/never_transmute_never.rs rename to src/test/ui/never_type/never_transmute_never.rs index 5bad756b8762f..fce3ced9aac7f 100644 --- a/src/test/ui/never_transmute_never.rs +++ b/src/test/ui/never_type/never_transmute_never.rs @@ -1,4 +1,4 @@ -// build-pass (FIXME(62277): could be check-pass?) +// check-pass #![crate_type="lib"] diff --git a/src/test/ui/panic-uninitialized-zeroed.rs b/src/test/ui/never_type/panic-uninitialized-zeroed.rs similarity index 100% rename from src/test/ui/panic-uninitialized-zeroed.rs rename to src/test/ui/never_type/panic-uninitialized-zeroed.rs diff --git a/src/test/ui/try_from.rs b/src/test/ui/never_type/try_from.rs similarity index 100% rename from src/test/ui/try_from.rs rename to src/test/ui/never_type/try_from.rs diff --git a/src/test/ui/unreachable/auxiliary/unreachable_variant.rs b/src/test/ui/reachable/auxiliary/unreachable_variant.rs similarity index 100% rename from src/test/ui/unreachable/auxiliary/unreachable_variant.rs rename to src/test/ui/reachable/auxiliary/unreachable_variant.rs diff --git a/src/test/ui/unreachable/unreachable-arm.rs b/src/test/ui/reachable/unreachable-arm.rs similarity index 100% rename from src/test/ui/unreachable/unreachable-arm.rs rename to src/test/ui/reachable/unreachable-arm.rs diff --git a/src/test/ui/unreachable/unreachable-arm.stderr b/src/test/ui/reachable/unreachable-arm.stderr similarity index 100% rename from src/test/ui/unreachable/unreachable-arm.stderr rename to src/test/ui/reachable/unreachable-arm.stderr diff --git a/src/test/ui/unreachable/unreachable-code.rs b/src/test/ui/reachable/unreachable-code.rs similarity index 100% rename from src/test/ui/unreachable/unreachable-code.rs rename to src/test/ui/reachable/unreachable-code.rs diff --git a/src/test/ui/unreachable/unreachable-code.stderr b/src/test/ui/reachable/unreachable-code.stderr similarity index 100% rename from src/test/ui/unreachable/unreachable-code.stderr rename to src/test/ui/reachable/unreachable-code.stderr diff --git a/src/test/ui/unreachable/unreachable-in-call.rs b/src/test/ui/reachable/unreachable-in-call.rs similarity index 100% rename from src/test/ui/unreachable/unreachable-in-call.rs rename to src/test/ui/reachable/unreachable-in-call.rs diff --git a/src/test/ui/unreachable/unreachable-in-call.stderr b/src/test/ui/reachable/unreachable-in-call.stderr similarity index 100% rename from src/test/ui/unreachable/unreachable-in-call.stderr rename to src/test/ui/reachable/unreachable-in-call.stderr diff --git a/src/test/ui/unreachable/unreachable-loop-patterns.rs b/src/test/ui/reachable/unreachable-loop-patterns.rs similarity index 95% rename from src/test/ui/unreachable/unreachable-loop-patterns.rs rename to src/test/ui/reachable/unreachable-loop-patterns.rs index 56ab1a270a75d..6f1d2efa1b200 100644 --- a/src/test/ui/unreachable/unreachable-loop-patterns.rs +++ b/src/test/ui/reachable/unreachable-loop-patterns.rs @@ -1,5 +1,3 @@ -// compile-fail - #![feature(never_type)] #![feature(exhaustive_patterns)] diff --git a/src/test/ui/unreachable/unreachable-loop-patterns.stderr b/src/test/ui/reachable/unreachable-loop-patterns.stderr similarity index 73% rename from src/test/ui/unreachable/unreachable-loop-patterns.stderr rename to src/test/ui/reachable/unreachable-loop-patterns.stderr index 254d1178d142e..bb5103320d2cf 100644 --- a/src/test/ui/unreachable/unreachable-loop-patterns.stderr +++ b/src/test/ui/reachable/unreachable-loop-patterns.stderr @@ -1,17 +1,17 @@ error: unreachable pattern - --> $DIR/unreachable-loop-patterns.rs:20:9 + --> $DIR/unreachable-loop-patterns.rs:18:9 | LL | for _ in unimplemented!() as Void {} | ^ | note: lint level defined here - --> $DIR/unreachable-loop-patterns.rs:7:9 + --> $DIR/unreachable-loop-patterns.rs:5:9 | LL | #![deny(unreachable_patterns)] | ^^^^^^^^^^^^^^^^^^^^ error: unreachable pattern - --> $DIR/unreachable-loop-patterns.rs:20:14 + --> $DIR/unreachable-loop-patterns.rs:18:14 | LL | for _ in unimplemented!() as Void {} | ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/unreachable/unreachable-try-pattern.rs b/src/test/ui/reachable/unreachable-try-pattern.rs similarity index 94% rename from src/test/ui/unreachable/unreachable-try-pattern.rs rename to src/test/ui/reachable/unreachable-try-pattern.rs index cbc5fcee2f035..23360e73f4a3a 100644 --- a/src/test/ui/unreachable/unreachable-try-pattern.rs +++ b/src/test/ui/reachable/unreachable-try-pattern.rs @@ -1,4 +1,4 @@ -// build-pass (FIXME(62277): could be check-pass?) +// check-pass #![feature(never_type, exhaustive_patterns)] #![warn(unreachable_code)] #![warn(unreachable_patterns)] diff --git a/src/test/ui/unreachable/unreachable-try-pattern.stderr b/src/test/ui/reachable/unreachable-try-pattern.stderr similarity index 100% rename from src/test/ui/unreachable/unreachable-try-pattern.stderr rename to src/test/ui/reachable/unreachable-try-pattern.stderr diff --git a/src/test/ui/unreachable/unreachable-variant.rs b/src/test/ui/reachable/unreachable-variant.rs similarity index 100% rename from src/test/ui/unreachable/unreachable-variant.rs rename to src/test/ui/reachable/unreachable-variant.rs diff --git a/src/test/ui/unreachable/unreachable-variant.stderr b/src/test/ui/reachable/unreachable-variant.stderr similarity index 100% rename from src/test/ui/unreachable/unreachable-variant.stderr rename to src/test/ui/reachable/unreachable-variant.stderr diff --git a/src/test/ui/unreachable/unwarned-match-on-never.rs b/src/test/ui/reachable/unwarned-match-on-never.rs similarity index 100% rename from src/test/ui/unreachable/unwarned-match-on-never.rs rename to src/test/ui/reachable/unwarned-match-on-never.rs diff --git a/src/test/ui/unreachable/unwarned-match-on-never.stderr b/src/test/ui/reachable/unwarned-match-on-never.stderr similarity index 100% rename from src/test/ui/unreachable/unwarned-match-on-never.stderr rename to src/test/ui/reachable/unwarned-match-on-never.stderr diff --git a/src/test/ui/always-inhabited-union-ref.rs b/src/test/ui/uninhabited/always-inhabited-union-ref.rs similarity index 100% rename from src/test/ui/always-inhabited-union-ref.rs rename to src/test/ui/uninhabited/always-inhabited-union-ref.rs diff --git a/src/test/ui/always-inhabited-union-ref.stderr b/src/test/ui/uninhabited/always-inhabited-union-ref.stderr similarity index 100% rename from src/test/ui/always-inhabited-union-ref.stderr rename to src/test/ui/uninhabited/always-inhabited-union-ref.stderr From d82c1c546df10f07b854a2e5b088404d80ec22c9 Mon Sep 17 00:00:00 2001 From: Giles Cope Date: Tue, 15 Oct 2019 18:05:13 +0100 Subject: [PATCH 10/11] Avoid unused lifetime warning for lifetimes introduced when desugering async. --- src/librustc/middle/resolve_lifetime.rs | 8 +++- src/test/ui/async-await/unused-lifetime.rs | 42 +++++++++++++++++++ .../ui/async-await/unused-lifetime.stderr | 32 ++++++++++++++ 3 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 src/test/ui/async-await/unused-lifetime.rs create mode 100644 src/test/ui/async-await/unused-lifetime.stderr diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index 8836a632a7ca8..86afde16dc804 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -709,15 +709,22 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { match param.kind { GenericParamKind::Lifetime { .. } => { let (name, reg) = Region::early(&self.tcx.hir(), &mut index, ¶m); + let def_id = if let Region::EarlyBound(_ ,def_id , _) = reg { + def_id + } else { + bug!(); + }; if let hir::ParamName::Plain(param_name) = name { if param_name.name == kw::UnderscoreLifetime { // Pick the elided lifetime "definition" if one exists // and use it to make an elision scope. + self.lifetime_uses.insert(def_id.clone(), LifetimeUseSet::Many); elision = Some(reg); } else { lifetimes.insert(name, reg); } } else { + self.lifetime_uses.insert(def_id.clone(), LifetimeUseSet::Many); lifetimes.insert(name, reg); } } @@ -1623,7 +1630,6 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { _ => None, } { debug!("id = {:?} span = {:?} name = {:?}", id, span, name); - if name.name == kw::UnderscoreLifetime { continue; } diff --git a/src/test/ui/async-await/unused-lifetime.rs b/src/test/ui/async-await/unused-lifetime.rs new file mode 100644 index 0000000000000..1cf546bcb4266 --- /dev/null +++ b/src/test/ui/async-await/unused-lifetime.rs @@ -0,0 +1,42 @@ +// edition:2018 + +// Avoid spurious warnings of unused lifetime. The below async functions +// are desugered to have an unused lifetime +// but we don't want to warn about that as there's nothing they can do about it. + +#![deny(unused_lifetimes)] +#![allow(dead_code)] + +pub async fn october(s: &str) { + println!("{}", s); +} + +pub async fn async_fn(&mut ref s: &mut[i32]) { + println!("{:?}", s); +} + +macro_rules! foo_macro { + () => { + pub async fn async_fn_in_macro(&mut ref _s: &mut[i32]) {} + }; +} + +foo_macro!(); + +pub async fn func_with_unused_lifetime<'a>(s: &'a str) { + //~^ ERROR lifetime parameter `'a` never used + println!("{}", s); +} + +pub async fn func_with_two_unused_lifetime<'a, 'b>(s: &'a str, t: &'b str) { + //~^ ERROR lifetime parameter `'a` never used + //~^^ ERROR lifetime parameter `'b` never used + println!("{}", s); +} + +pub async fn func_with_unused_lifetime_in_two_params<'c>(s: &'c str, t: &'c str) { + //~^ ERROR lifetime parameter `'c` never used + println!("{}", s); +} + +fn main() {} diff --git a/src/test/ui/async-await/unused-lifetime.stderr b/src/test/ui/async-await/unused-lifetime.stderr new file mode 100644 index 0000000000000..885cdc04cfa4c --- /dev/null +++ b/src/test/ui/async-await/unused-lifetime.stderr @@ -0,0 +1,32 @@ +error: lifetime parameter `'a` never used + --> $DIR/unused-lifetime.rs:26:40 + | +LL | pub async fn func_with_unused_lifetime<'a>(s: &'a str) { + | ^^ + | +note: lint level defined here + --> $DIR/unused-lifetime.rs:7:9 + | +LL | #![deny(unused_lifetimes)] + | ^^^^^^^^^^^^^^^^ + +error: lifetime parameter `'a` never used + --> $DIR/unused-lifetime.rs:31:44 + | +LL | pub async fn func_with_two_unused_lifetime<'a, 'b>(s: &'a str, t: &'b str) { + | ^^ + +error: lifetime parameter `'b` never used + --> $DIR/unused-lifetime.rs:31:48 + | +LL | pub async fn func_with_two_unused_lifetime<'a, 'b>(s: &'a str, t: &'b str) { + | ^^ + +error: lifetime parameter `'c` never used + --> $DIR/unused-lifetime.rs:37:54 + | +LL | pub async fn func_with_unused_lifetime_in_two_params<'c>(s: &'c str, t: &'c str) { + | ^^ + +error: aborting due to 4 previous errors + From fa3a4aeae5f3a4c403bf07038c56e74df3d9df70 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Tue, 15 Oct 2019 12:55:39 -0300 Subject: [PATCH 11/11] Implement AsRef<[T]> for List --- src/librustc/ty/mod.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 3692caada577c..e74f8fb074f74 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -700,6 +700,13 @@ impl Deref for List { type Target = [T]; #[inline(always)] fn deref(&self) -> &[T] { + self.as_ref() + } +} + +impl AsRef<[T]> for List { + #[inline(always)] + fn as_ref(&self) -> &[T] { unsafe { slice::from_raw_parts(self.data.as_ptr(), self.len) }