From 4f550f1f930b9201bbeeb9fa10d42392a66cc9f2 Mon Sep 17 00:00:00 2001 From: Rich Kadel Date: Mon, 14 Dec 2020 00:25:29 -0800 Subject: Improve warnings on incompatible options involving -Zinstrument-coverage Adds checks for: * `no_core` attribute * explicitly-enabled `legacy` symbol mangling * mir_opt_level > 1 (which enables inlining) I removed code from the `Inline` MIR pass that forcibly disabled inlining if `-Zinstrument-coverage` was set. The default `mir_opt_level` does not enable inlining anyway. But if the level is explicitly set and is greater than 1, I issue a warning. The new warnings show up in tests, which is much better for diagnosing potential option conflicts in these cases. --- compiler/rustc_interface/src/tests.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'compiler/rustc_interface/src') diff --git a/compiler/rustc_interface/src/tests.rs b/compiler/rustc_interface/src/tests.rs index 2273266a3ff..7a7def0696d 100644 --- a/compiler/rustc_interface/src/tests.rs +++ b/compiler/rustc_interface/src/tests.rs @@ -561,7 +561,7 @@ fn test_debugging_options_tracking_hash() { tracked!(link_only, true); tracked!(merge_functions, Some(MergeFunctions::Disabled)); tracked!(mir_emit_retag, true); - tracked!(mir_opt_level, 3); + tracked!(mir_opt_level, Some(3)); tracked!(mutable_noalias, true); tracked!(new_llvm_pass_manager, true); tracked!(no_codegen, true); @@ -587,7 +587,7 @@ fn test_debugging_options_tracking_hash() { tracked!(share_generics, Some(true)); tracked!(show_span, Some(String::from("abc"))); tracked!(src_hash_algorithm, Some(SourceFileHashAlgorithm::Sha1)); - tracked!(symbol_mangling_version, SymbolManglingVersion::V0); + tracked!(symbol_mangling_version, Some(SymbolManglingVersion::V0)); tracked!(teach, true); tracked!(thinlto, Some(true)); tracked!(tune_cpu, Some(String::from("abc"))); -- cgit 1.4.1-3-g733a5 From 36c639a2ce2808c2c95cacf0856026235ad6350f Mon Sep 17 00:00:00 2001 From: Rich Kadel Date: Mon, 14 Dec 2020 13:12:15 -0800 Subject: Convenience funcs for `some_option.unwrap_or(...)` This ensures consistent handling of default values for options that are None if not specified on the command line. --- compiler/rustc_interface/src/tests.rs | 2 +- compiler/rustc_metadata/src/rmeta/encoder.rs | 7 +---- compiler/rustc_mir/src/transform/const_prop.rs | 8 ++---- compiler/rustc_mir/src/transform/dest_prop.rs | 3 +- .../src/transform/early_otherwise_branch.rs | 3 +- compiler/rustc_mir/src/transform/inline.rs | 3 +- compiler/rustc_mir/src/transform/match_branches.rs | 3 +- compiler/rustc_mir/src/transform/mod.rs | 3 +- .../src/transform/multiple_return_terminators.rs | 3 +- compiler/rustc_mir/src/transform/nrvo.rs | 3 +- .../rustc_mir/src/transform/unreachable_prop.rs | 3 +- compiler/rustc_session/src/config.rs | 33 +++++++++------------- compiler/rustc_session/src/options.rs | 2 +- compiler/rustc_symbol_mangling/src/lib.rs | 6 +--- src/tools/clippy/src/driver.rs | 2 +- 15 files changed, 29 insertions(+), 55 deletions(-) (limited to 'compiler/rustc_interface/src') diff --git a/compiler/rustc_interface/src/tests.rs b/compiler/rustc_interface/src/tests.rs index 7a7def0696d..3e94f163773 100644 --- a/compiler/rustc_interface/src/tests.rs +++ b/compiler/rustc_interface/src/tests.rs @@ -561,7 +561,7 @@ fn test_debugging_options_tracking_hash() { tracked!(link_only, true); tracked!(merge_functions, Some(MergeFunctions::Disabled)); tracked!(mir_emit_retag, true); - tracked!(mir_opt_level, Some(3)); + tracked!(mir_opt_level, 3); tracked!(mutable_noalias, true); tracked!(new_llvm_pass_manager, true); tracked!(no_codegen, true); diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index b0c75c1de9d..7b67d15f64a 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -663,12 +663,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { no_builtins: tcx.sess.contains_name(&attrs, sym::no_builtins), panic_runtime: tcx.sess.contains_name(&attrs, sym::panic_runtime), profiler_runtime: tcx.sess.contains_name(&attrs, sym::profiler_runtime), - symbol_mangling_version: tcx - .sess - .opts - .debugging_opts - .symbol_mangling_version - .unwrap_or(SymbolManglingVersion::default()), + symbol_mangling_version: tcx.sess.opts.debugging_opts.get_symbol_mangling_version(), crate_deps, dylib_dependency_formats, diff --git a/compiler/rustc_mir/src/transform/const_prop.rs b/compiler/rustc_mir/src/transform/const_prop.rs index 49b1cf92600..1d949e020ed 100644 --- a/compiler/rustc_mir/src/transform/const_prop.rs +++ b/compiler/rustc_mir/src/transform/const_prop.rs @@ -22,7 +22,6 @@ use rustc_middle::ty::subst::{InternalSubsts, Subst}; use rustc_middle::ty::{ self, ConstInt, ConstKind, Instance, ParamEnv, ScalarInt, Ty, TyCtxt, TypeFoldable, }; -use rustc_session::config::MIR_OPT_LEVEL_DEFAULT; use rustc_session::lint; use rustc_span::{def_id::DefId, Span}; use rustc_target::abi::{HasDataLayout, LayoutOf, Size, TargetDataLayout}; @@ -709,7 +708,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { return None; } - if self.tcx.sess.opts.debugging_opts.mir_opt_level.unwrap_or(MIR_OPT_LEVEL_DEFAULT) >= 3 { + if self.tcx.sess.opts.debugging_opts.mir_opt_level >= 3 { self.eval_rvalue_with_identities(rvalue, place) } else { self.use_ecx(|this| this.ecx.eval_rvalue_into_place(rvalue, place)) @@ -887,8 +886,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { /// Returns `true` if and only if this `op` should be const-propagated into. fn should_const_prop(&mut self, op: OpTy<'tcx>) -> bool { - let mir_opt_level = - self.tcx.sess.opts.debugging_opts.mir_opt_level.unwrap_or(MIR_OPT_LEVEL_DEFAULT); + let mir_opt_level = self.tcx.sess.opts.debugging_opts.mir_opt_level; if mir_opt_level == 0 { return false; @@ -1058,7 +1056,7 @@ impl<'mir, 'tcx> MutVisitor<'tcx> for ConstPropagator<'mir, 'tcx> { // Only const prop copies and moves on `mir_opt_level=2` as doing so // currently slightly increases compile time in some cases. - if self.tcx.sess.opts.debugging_opts.mir_opt_level.unwrap_or(MIR_OPT_LEVEL_DEFAULT) >= 2 { + if self.tcx.sess.opts.debugging_opts.mir_opt_level >= 2 { self.propagate_operand(operand) } } diff --git a/compiler/rustc_mir/src/transform/dest_prop.rs b/compiler/rustc_mir/src/transform/dest_prop.rs index 2363b6d58e1..46de5dba6e0 100644 --- a/compiler/rustc_mir/src/transform/dest_prop.rs +++ b/compiler/rustc_mir/src/transform/dest_prop.rs @@ -115,7 +115,6 @@ use rustc_middle::mir::{ Rvalue, Statement, StatementKind, Terminator, TerminatorKind, }; use rustc_middle::ty::{self, Ty, TyCtxt}; -use rustc_session::config::MIR_OPT_LEVEL_DEFAULT; // Empirical measurements have resulted in some observations: // - Running on a body with a single block and 500 locals takes barely any time @@ -130,7 +129,7 @@ impl<'tcx> MirPass<'tcx> for DestinationPropagation { fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { // Only run at mir-opt-level=2 or higher for now (we don't fix up debuginfo and remove // storage statements at the moment). - if tcx.sess.opts.debugging_opts.mir_opt_level.unwrap_or(MIR_OPT_LEVEL_DEFAULT) <= 1 { + if tcx.sess.opts.debugging_opts.mir_opt_level <= 1 { return; } diff --git a/compiler/rustc_mir/src/transform/early_otherwise_branch.rs b/compiler/rustc_mir/src/transform/early_otherwise_branch.rs index 023561923ee..f91477911a4 100644 --- a/compiler/rustc_mir/src/transform/early_otherwise_branch.rs +++ b/compiler/rustc_mir/src/transform/early_otherwise_branch.rs @@ -1,7 +1,6 @@ use crate::{transform::MirPass, util::patch::MirPatch}; use rustc_middle::mir::*; use rustc_middle::ty::{Ty, TyCtxt}; -use rustc_session::config::MIR_OPT_LEVEL_DEFAULT; use std::fmt::Debug; use super::simplify::simplify_cfg; @@ -27,7 +26,7 @@ pub struct EarlyOtherwiseBranch; impl<'tcx> MirPass<'tcx> for EarlyOtherwiseBranch { fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { - if tcx.sess.opts.debugging_opts.mir_opt_level.unwrap_or(MIR_OPT_LEVEL_DEFAULT) < 2 { + if tcx.sess.opts.debugging_opts.mir_opt_level < 2 { return; } trace!("running EarlyOtherwiseBranch on {:?}", body.source); diff --git a/compiler/rustc_mir/src/transform/inline.rs b/compiler/rustc_mir/src/transform/inline.rs index 1a927f9bf50..6e7575c1d71 100644 --- a/compiler/rustc_mir/src/transform/inline.rs +++ b/compiler/rustc_mir/src/transform/inline.rs @@ -9,7 +9,6 @@ use rustc_middle::mir::visit::*; use rustc_middle::mir::*; use rustc_middle::ty::subst::Subst; use rustc_middle::ty::{self, ConstKind, Instance, InstanceDef, ParamEnv, Ty, TyCtxt}; -use rustc_session::config::MIR_OPT_LEVEL_DEFAULT; use rustc_span::{hygiene::ExpnKind, ExpnData, Span}; use rustc_target::spec::abi::Abi; @@ -38,7 +37,7 @@ struct CallSite<'tcx> { impl<'tcx> MirPass<'tcx> for Inline { fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { - if tcx.sess.opts.debugging_opts.mir_opt_level.unwrap_or(MIR_OPT_LEVEL_DEFAULT) < 2 { + if tcx.sess.opts.debugging_opts.mir_opt_level < 2 { return; } diff --git a/compiler/rustc_mir/src/transform/match_branches.rs b/compiler/rustc_mir/src/transform/match_branches.rs index e28e3f59a5e..53eeecc780f 100644 --- a/compiler/rustc_mir/src/transform/match_branches.rs +++ b/compiler/rustc_mir/src/transform/match_branches.rs @@ -1,7 +1,6 @@ use crate::transform::MirPass; use rustc_middle::mir::*; use rustc_middle::ty::TyCtxt; -use rustc_session::config::MIR_OPT_LEVEL_DEFAULT; pub struct MatchBranchSimplification; @@ -39,7 +38,7 @@ pub struct MatchBranchSimplification; impl<'tcx> MirPass<'tcx> for MatchBranchSimplification { fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { - if tcx.sess.opts.debugging_opts.mir_opt_level.unwrap_or(MIR_OPT_LEVEL_DEFAULT) <= 1 { + if tcx.sess.opts.debugging_opts.mir_opt_level <= 1 { return; } diff --git a/compiler/rustc_mir/src/transform/mod.rs b/compiler/rustc_mir/src/transform/mod.rs index 039dfe2c0d5..e86d11e248f 100644 --- a/compiler/rustc_mir/src/transform/mod.rs +++ b/compiler/rustc_mir/src/transform/mod.rs @@ -10,7 +10,6 @@ use rustc_middle::mir::visit::Visitor as _; use rustc_middle::mir::{traversal, Body, ConstQualifs, MirPhase, Promoted}; use rustc_middle::ty::query::Providers; use rustc_middle::ty::{self, TyCtxt, TypeFoldable}; -use rustc_session::config::MIR_OPT_LEVEL_DEFAULT; use rustc_span::{Span, Symbol}; use std::borrow::Cow; @@ -374,7 +373,7 @@ fn run_post_borrowck_cleanup_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tc } fn run_optimization_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { - let mir_opt_level = tcx.sess.opts.debugging_opts.mir_opt_level.unwrap_or(MIR_OPT_LEVEL_DEFAULT); + let mir_opt_level = tcx.sess.opts.debugging_opts.mir_opt_level; // Lowering generator control-flow and variables has to happen before we do anything else // to them. We run some optimizations before that, because they may be harder to do on the state diff --git a/compiler/rustc_mir/src/transform/multiple_return_terminators.rs b/compiler/rustc_mir/src/transform/multiple_return_terminators.rs index de4aee7ddbc..617086622cc 100644 --- a/compiler/rustc_mir/src/transform/multiple_return_terminators.rs +++ b/compiler/rustc_mir/src/transform/multiple_return_terminators.rs @@ -5,13 +5,12 @@ use crate::transform::{simplify, MirPass}; use rustc_index::bit_set::BitSet; use rustc_middle::mir::*; use rustc_middle::ty::TyCtxt; -use rustc_session::config::MIR_OPT_LEVEL_DEFAULT; pub struct MultipleReturnTerminators; impl<'tcx> MirPass<'tcx> for MultipleReturnTerminators { fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { - if tcx.sess.opts.debugging_opts.mir_opt_level.unwrap_or(MIR_OPT_LEVEL_DEFAULT) < 3 { + if tcx.sess.opts.debugging_opts.mir_opt_level < 3 { return; } diff --git a/compiler/rustc_mir/src/transform/nrvo.rs b/compiler/rustc_mir/src/transform/nrvo.rs index 6e1dc03b9cb..ce02fb261df 100644 --- a/compiler/rustc_mir/src/transform/nrvo.rs +++ b/compiler/rustc_mir/src/transform/nrvo.rs @@ -5,7 +5,6 @@ use rustc_index::bit_set::HybridBitSet; use rustc_middle::mir::visit::{MutVisitor, NonUseContext, PlaceContext, Visitor}; use rustc_middle::mir::{self, BasicBlock, Local, Location}; use rustc_middle::ty::TyCtxt; -use rustc_session::config::MIR_OPT_LEVEL_DEFAULT; use crate::transform::MirPass; @@ -35,7 +34,7 @@ pub struct RenameReturnPlace; impl<'tcx> MirPass<'tcx> for RenameReturnPlace { fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut mir::Body<'tcx>) { - if tcx.sess.opts.debugging_opts.mir_opt_level.unwrap_or(MIR_OPT_LEVEL_DEFAULT) == 0 { + if tcx.sess.opts.debugging_opts.mir_opt_level == 0 { return; } diff --git a/compiler/rustc_mir/src/transform/unreachable_prop.rs b/compiler/rustc_mir/src/transform/unreachable_prop.rs index c9053ce81cd..e39c8656021 100644 --- a/compiler/rustc_mir/src/transform/unreachable_prop.rs +++ b/compiler/rustc_mir/src/transform/unreachable_prop.rs @@ -7,13 +7,12 @@ use crate::transform::MirPass; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_middle::mir::*; use rustc_middle::ty::TyCtxt; -use rustc_session::config::MIR_OPT_LEVEL_DEFAULT; pub struct UnreachablePropagation; impl MirPass<'_> for UnreachablePropagation { fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { - if tcx.sess.opts.debugging_opts.mir_opt_level.unwrap_or(MIR_OPT_LEVEL_DEFAULT) < 3 { + if tcx.sess.opts.debugging_opts.mir_opt_level < 3 { // Enable only under -Zmir-opt-level=3 as in some cases (check the deeply-nested-opt // perf benchmark) LLVM may spend quite a lot of time optimizing the generated code. return; diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 47e494b78c7..b77a8b631e0 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -174,8 +174,6 @@ pub enum MirSpanview { Block, } -pub const MIR_OPT_LEVEL_DEFAULT: usize = 1; - #[derive(Clone, PartialEq, Hash)] pub enum LinkerPluginLto { LinkerPlugin(PathBuf), @@ -214,12 +212,6 @@ pub enum SymbolManglingVersion { V0, } -impl SymbolManglingVersion { - pub fn default() -> Self { - SymbolManglingVersion::Legacy - } -} - impl_stable_hash_via_hash!(SymbolManglingVersion); #[derive(Clone, Copy, Debug, PartialEq, Hash)] @@ -700,6 +692,10 @@ impl DebuggingOptions { deduplicate_diagnostics: self.deduplicate_diagnostics, } } + + pub fn get_symbol_mangling_version(&self) -> SymbolManglingVersion { + self.symbol_mangling_version.unwrap_or(SymbolManglingVersion::Legacy) + } } // The type of entry function, so users can have their own entry functions @@ -1779,18 +1775,15 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options { Some(SymbolManglingVersion::V0) => {} } - match debugging_opts.mir_opt_level { - Some(level) if level > 1 => { - early_warn( - error_format, - &format!( - "`-Z mir-opt-level={}` (any level > 1) enables function inlining, which \ - limits the effectiveness of `-Z instrument-coverage`.", - level, - ), - ); - } - _ => {} + if debugging_opts.mir_opt_level > 1 { + early_warn( + error_format, + &format!( + "`-Z mir-opt-level={}` (any level > 1) enables function inlining, which \ + limits the effectiveness of `-Z instrument-coverage`.", + debugging_opts.mir_opt_level, + ), + ); } } diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index 1909550aca4..49a7888fd6a 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -970,7 +970,7 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options, mir_emit_retag: bool = (false, parse_bool, [TRACKED], "emit Retagging MIR statements, interpreted e.g., by miri; implies -Zmir-opt-level=0 \ (default: no)"), - mir_opt_level: Option = (None, parse_opt_uint, [TRACKED], + mir_opt_level: usize = (1, parse_uint, [TRACKED], "MIR optimization level (0-3; default: 1)"), mutable_noalias: bool = (false, parse_bool, [TRACKED], "emit noalias metadata for mutable references (default: no)"), diff --git a/compiler/rustc_symbol_mangling/src/lib.rs b/compiler/rustc_symbol_mangling/src/lib.rs index 945e788a146..7f8cded0ac0 100644 --- a/compiler/rustc_symbol_mangling/src/lib.rs +++ b/compiler/rustc_symbol_mangling/src/lib.rs @@ -245,11 +245,7 @@ fn compute_symbol_name( // 2. we favor `instantiating_crate` where possible (i.e. when `Some`) let mangling_version_crate = instantiating_crate.unwrap_or(def_id.krate); let mangling_version = if mangling_version_crate == LOCAL_CRATE { - tcx.sess - .opts - .debugging_opts - .symbol_mangling_version - .unwrap_or(SymbolManglingVersion::default()) + tcx.sess.opts.debugging_opts.get_symbol_mangling_version() } else { tcx.symbol_mangling_version(mangling_version_crate) }; diff --git a/src/tools/clippy/src/driver.rs b/src/tools/clippy/src/driver.rs index 9e5ae21f702..87dd19c5d4d 100644 --- a/src/tools/clippy/src/driver.rs +++ b/src/tools/clippy/src/driver.rs @@ -85,7 +85,7 @@ impl rustc_driver::Callbacks for ClippyCallbacks { // run on the unoptimized MIR. On the other hand this results in some false negatives. If // MIR passes can be enabled / disabled separately, we should figure out, what passes to // use for Clippy. - config.opts.debugging_opts.mir_opt_level = Some(0); + config.opts.debugging_opts.mir_opt_level = 0; } } -- cgit 1.4.1-3-g733a5 From 2c0dccb7f2affb0013b00ebeb35ad12fcffa99a6 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 3 Dec 2020 14:11:35 +0100 Subject: Move some code out of CodegenBackend::{codegen_crate,link} --- compiler/rustc_codegen_llvm/src/lib.rs | 24 +++++++++++------------- compiler/rustc_codegen_ssa/src/base.rs | 21 --------------------- compiler/rustc_interface/src/passes.rs | 14 ++++++++++++++ compiler/rustc_interface/src/queries.rs | 1 + 4 files changed, 26 insertions(+), 34 deletions(-) (limited to 'compiler/rustc_interface/src') diff --git a/compiler/rustc_codegen_llvm/src/lib.rs b/compiler/rustc_codegen_llvm/src/lib.rs index a58c2fbd8ab..f33464f83da 100644 --- a/compiler/rustc_codegen_llvm/src/lib.rs +++ b/compiler/rustc_codegen_llvm/src/lib.rs @@ -298,21 +298,19 @@ impl CodegenBackend for LlvmCodegenBackend { codegen_results: CodegenResults, outputs: &OutputFilenames, ) -> Result<(), ErrorReported> { + use crate::back::archive::LlvmArchiveBuilder; + use rustc_codegen_ssa::back::link::link_binary; + // Run the linker on any artifacts that resulted from the LLVM run. // This should produce either a finished executable or library. - sess.time("link_crate", || { - use crate::back::archive::LlvmArchiveBuilder; - use rustc_codegen_ssa::back::link::link_binary; - - let target_cpu = crate::llvm_util::target_cpu(sess); - link_binary::>( - sess, - &codegen_results, - outputs, - &codegen_results.crate_name.as_str(), - target_cpu, - ); - }); + let target_cpu = crate::llvm_util::target_cpu(sess); + link_binary::>( + sess, + &codegen_results, + outputs, + &codegen_results.crate_name.as_str(), + target_cpu, + ); Ok(()) } diff --git a/compiler/rustc_codegen_ssa/src/base.rs b/compiler/rustc_codegen_ssa/src/base.rs index 21138f967a2..048a353e5fc 100644 --- a/compiler/rustc_codegen_ssa/src/base.rs +++ b/compiler/rustc_codegen_ssa/src/base.rs @@ -46,7 +46,6 @@ use rustc_session::cgu_reuse_tracker::CguReuse; use rustc_session::config::{self, EntryFnType}; use rustc_session::utils::NativeLibKind; use rustc_session::Session; -use rustc_symbol_mangling::test as symbol_names_test; use rustc_target::abi::{Align, LayoutOf, VariantIdx}; use std::cmp; @@ -486,8 +485,6 @@ pub fn codegen_crate( ongoing_codegen.codegen_finished(tcx); - finalize_tcx(tcx); - ongoing_codegen.check_for_errors(tcx.sess); return ongoing_codegen; @@ -688,14 +685,8 @@ pub fn codegen_crate( total_codegen_time.into_inner(), ); - rustc_incremental::assert_module_sources::assert_module_sources(tcx); - - symbol_names_test::report_symbol_names(tcx); - ongoing_codegen.check_for_errors(tcx.sess); - finalize_tcx(tcx); - ongoing_codegen.into_inner() } @@ -746,18 +737,6 @@ impl Drop for AbortCodegenOnDrop { } } -fn finalize_tcx(tcx: TyCtxt<'_>) { - tcx.sess.time("assert_dep_graph", || rustc_incremental::assert_dep_graph(tcx)); - tcx.sess.time("serialize_dep_graph", || rustc_incremental::save_dep_graph(tcx)); - - // We assume that no queries are run past here. If there are new queries - // after this point, they'll show up as "" in self-profiling data. - { - let _prof_timer = tcx.prof.generic_activity("self_profile_alloc_query_strings"); - tcx.alloc_self_profile_query_strings(); - } -} - impl CrateInfo { pub fn new(tcx: TyCtxt<'_>) -> CrateInfo { let mut info = CrateInfo { diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index c13d26c79d7..3f30b7e69e4 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -996,6 +996,20 @@ pub fn start_codegen<'tcx>( codegen_backend.codegen_crate(tcx, metadata, need_metadata_module) }); + rustc_incremental::assert_module_sources::assert_module_sources(tcx); + + rustc_symbol_mangling::test::report_symbol_names(tcx); + + tcx.sess.time("assert_dep_graph", || rustc_incremental::assert_dep_graph(tcx)); + tcx.sess.time("serialize_dep_graph", || rustc_incremental::save_dep_graph(tcx)); + + // We assume that no queries are run past here. If there are new queries + // after this point, they'll show up as "" in self-profiling data. + { + let _prof_timer = tcx.prof.generic_activity("self_profile_alloc_query_strings"); + tcx.alloc_self_profile_query_strings(); + } + info!("Post-codegen\n{:?}", tcx.debug_stats()); if tcx.sess.opts.output_types.contains_key(&OutputType::Mir) { diff --git a/compiler/rustc_interface/src/queries.rs b/compiler/rustc_interface/src/queries.rs index 4c340b3fc1f..c671751bf90 100644 --- a/compiler/rustc_interface/src/queries.rs +++ b/compiler/rustc_interface/src/queries.rs @@ -399,6 +399,7 @@ impl Linker { return Ok(()); } + let _timer = sess.prof.verbose_generic_activity("link_crate"); self.codegen_backend.link(&self.sess, codegen_results, &self.prepare_outputs) } } -- cgit 1.4.1-3-g733a5 From 3a3a23ffc5742885187c84e7db320610c8b352fb Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 17 Dec 2020 10:05:39 +0100 Subject: Fix tests --- compiler/rustc_interface/src/passes.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'compiler/rustc_interface/src') diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index 3f30b7e69e4..8b9bf17f3f4 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -996,9 +996,12 @@ pub fn start_codegen<'tcx>( codegen_backend.codegen_crate(tcx, metadata, need_metadata_module) }); - rustc_incremental::assert_module_sources::assert_module_sources(tcx); - - rustc_symbol_mangling::test::report_symbol_names(tcx); + // Don't run these test assertions when not doing codegen. Compiletest tries to build + // build-fail tests in check mode first and expects it to not give an error in that case. + if tcx.sess.opts.output_types.should_codegen() { + rustc_incremental::assert_module_sources::assert_module_sources(tcx); + rustc_symbol_mangling::test::report_symbol_names(tcx); + } tcx.sess.time("assert_dep_graph", || rustc_incremental::assert_dep_graph(tcx)); tcx.sess.time("serialize_dep_graph", || rustc_incremental::save_dep_graph(tcx)); -- cgit 1.4.1-3-g733a5 From f1eb88b28a84b0533ddd036a60bb5b8acbffabb2 Mon Sep 17 00:00:00 2001 From: Wesley Wiser Date: Sat, 19 Dec 2020 16:30:56 -0500 Subject: Revert "Promote missing_fragment_specifier to hard error" This reverts commit 02eae432e7476a0686633a8c2b7cb1d5aab1bd2c. --- compiler/rustc_expand/src/mbe.rs | 2 +- compiler/rustc_expand/src/mbe/macro_parser.rs | 20 +++++++++++++++++--- compiler/rustc_expand/src/mbe/macro_rules.rs | 15 ++++++++------- compiler/rustc_expand/src/mbe/quoted.rs | 11 +++++++---- compiler/rustc_interface/src/passes.rs | 19 ++++++++++++++++++- compiler/rustc_session/src/parse.rs | 2 ++ src/test/ui/lint/expansion-time.rs | 4 ++++ src/test/ui/lint/expansion-time.stderr | 22 ++++++++++++++++++---- src/test/ui/macros/issue-39404.rs | 1 + src/test/ui/macros/issue-39404.stderr | 4 ++++ src/test/ui/macros/macro-match-nonterminal.rs | 1 + src/test/ui/macros/macro-match-nonterminal.stderr | 4 ++++ src/test/ui/parser/macro/issue-33569.rs | 1 - src/test/ui/parser/macro/issue-33569.stderr | 16 +++++----------- 14 files changed, 90 insertions(+), 32 deletions(-) (limited to 'compiler/rustc_interface/src') diff --git a/compiler/rustc_expand/src/mbe.rs b/compiler/rustc_expand/src/mbe.rs index eb4aab116f0..cbc4d14a65a 100644 --- a/compiler/rustc_expand/src/mbe.rs +++ b/compiler/rustc_expand/src/mbe.rs @@ -84,7 +84,7 @@ enum TokenTree { /// e.g., `$var` MetaVar(Span, Ident), /// e.g., `$var:expr`. This is only used in the left hand side of MBE macros. - MetaVarDecl(Span, Ident /* name to bind */, NonterminalKind), + MetaVarDecl(Span, Ident /* name to bind */, Option), } impl TokenTree { diff --git a/compiler/rustc_expand/src/mbe/macro_parser.rs b/compiler/rustc_expand/src/mbe/macro_parser.rs index 3cf2d8f8ac1..0c44f5fe9e1 100644 --- a/compiler/rustc_expand/src/mbe/macro_parser.rs +++ b/compiler/rustc_expand/src/mbe/macro_parser.rs @@ -378,6 +378,11 @@ fn nameize>( n_rec(sess, next_m, res.by_ref(), ret_val)?; } } + TokenTree::MetaVarDecl(span, _, None) => { + if sess.missing_fragment_specifiers.borrow_mut().remove(&span).is_some() { + return Err((span, "missing fragment specifier".to_string())); + } + } TokenTree::MetaVarDecl(sp, bind_name, _) => match ret_val .entry(MacroRulesNormalizedIdent::new(bind_name)) { @@ -446,6 +451,7 @@ fn or_pat_mode(edition: Edition) -> OrPatNonterminalMode { /// /// A `ParseResult`. Note that matches are kept track of through the items generated. fn inner_parse_loop<'root, 'tt>( + sess: &ParseSess, cur_items: &mut SmallVec<[MatcherPosHandle<'root, 'tt>; 1]>, next_items: &mut Vec>, eof_items: &mut SmallVec<[MatcherPosHandle<'root, 'tt>; 1]>, @@ -563,9 +569,16 @@ fn inner_parse_loop<'root, 'tt>( }))); } + // We need to match a metavar (but the identifier is invalid)... this is an error + TokenTree::MetaVarDecl(span, _, None) => { + if sess.missing_fragment_specifiers.borrow_mut().remove(&span).is_some() { + return Error(span, "missing fragment specifier".to_string()); + } + } + // We need to match a metavar with a valid ident... call out to the black-box // parser by adding an item to `bb_items`. - TokenTree::MetaVarDecl(span, _, kind) => { + TokenTree::MetaVarDecl(span, _, Some(kind)) => { // Built-in nonterminals never start with these tokens, so we can eliminate // them from consideration. // @@ -640,6 +653,7 @@ pub(super) fn parse_tt(parser: &mut Cow<'_, Parser<'_>>, ms: &[TokenTree]) -> Na // parsing from the black-box parser done. The result is that `next_items` will contain a // bunch of possible next matcher positions in `next_items`. match inner_parse_loop( + parser.sess, &mut cur_items, &mut next_items, &mut eof_items, @@ -701,7 +715,7 @@ pub(super) fn parse_tt(parser: &mut Cow<'_, Parser<'_>>, ms: &[TokenTree]) -> Na let nts = bb_items .iter() .map(|item| match item.top_elts.get_tt(item.idx) { - TokenTree::MetaVarDecl(_, bind, kind) => format!("{} ('{}')", kind, bind), + TokenTree::MetaVarDecl(_, bind, Some(kind)) => format!("{} ('{}')", kind, bind), _ => panic!(), }) .collect::>() @@ -731,7 +745,7 @@ pub(super) fn parse_tt(parser: &mut Cow<'_, Parser<'_>>, ms: &[TokenTree]) -> Na assert_eq!(bb_items.len(), 1); let mut item = bb_items.pop().unwrap(); - if let TokenTree::MetaVarDecl(span, _, kind) = item.top_elts.get_tt(item.idx) { + if let TokenTree::MetaVarDecl(span, _, Some(kind)) = item.top_elts.get_tt(item.idx) { let match_cur = item.match_cur; // We use the span of the metavariable declaration to determine any // edition-specific matching behavior for non-terminals. diff --git a/compiler/rustc_expand/src/mbe/macro_rules.rs b/compiler/rustc_expand/src/mbe/macro_rules.rs index 66463eeb907..89d375b257d 100644 --- a/compiler/rustc_expand/src/mbe/macro_rules.rs +++ b/compiler/rustc_expand/src/mbe/macro_rules.rs @@ -401,7 +401,7 @@ pub fn compile_declarative_macro( let diag = &sess.parse_sess.span_diagnostic; let lhs_nm = Ident::new(sym::lhs, def.span); let rhs_nm = Ident::new(sym::rhs, def.span); - let tt_spec = NonterminalKind::TT; + let tt_spec = Some(NonterminalKind::TT); // Parse the macro_rules! invocation let (macro_rules, body) = match &def.kind { @@ -578,7 +578,7 @@ fn check_lhs_no_empty_seq(sess: &ParseSess, tts: &[mbe::TokenTree]) -> bool { TokenTree::Sequence(span, ref seq) => { if seq.separator.is_none() && seq.tts.iter().all(|seq_tt| match *seq_tt { - TokenTree::MetaVarDecl(_, _, NonterminalKind::Vis) => true, + TokenTree::MetaVarDecl(_, _, Some(NonterminalKind::Vis)) => true, TokenTree::Sequence(_, ref sub_seq) => { sub_seq.kleene.op == mbe::KleeneOp::ZeroOrMore || sub_seq.kleene.op == mbe::KleeneOp::ZeroOrOne @@ -961,7 +961,7 @@ fn check_matcher_core( // Now `last` holds the complete set of NT tokens that could // end the sequence before SUFFIX. Check that every one works with `suffix`. for token in &last.tokens { - if let TokenTree::MetaVarDecl(_, name, kind) = *token { + if let TokenTree::MetaVarDecl(_, name, Some(kind)) = *token { for next_token in &suffix_first.tokens { match is_in_follow(next_token, kind) { IsInFollow::Yes => {} @@ -1019,7 +1019,7 @@ fn check_matcher_core( } fn token_can_be_followed_by_any(tok: &mbe::TokenTree) -> bool { - if let mbe::TokenTree::MetaVarDecl(_, _, kind) = *tok { + if let mbe::TokenTree::MetaVarDecl(_, _, Some(kind)) = *tok { frag_can_be_followed_by_any(kind) } else { // (Non NT's can always be followed by anything in matchers.) @@ -1123,7 +1123,7 @@ fn is_in_follow(tok: &mbe::TokenTree, kind: NonterminalKind) -> IsInFollow { } _ => IsInFollow::No(TOKENS), }, - TokenTree::MetaVarDecl(_, _, NonterminalKind::Block) => IsInFollow::Yes, + TokenTree::MetaVarDecl(_, _, Some(NonterminalKind::Block)) => IsInFollow::Yes, _ => IsInFollow::No(TOKENS), } } @@ -1158,7 +1158,7 @@ fn is_in_follow(tok: &mbe::TokenTree, kind: NonterminalKind) -> IsInFollow { TokenTree::MetaVarDecl( _, _, - NonterminalKind::Ident | NonterminalKind::Ty | NonterminalKind::Path, + Some(NonterminalKind::Ident | NonterminalKind::Ty | NonterminalKind::Path), ) => IsInFollow::Yes, _ => IsInFollow::No(TOKENS), } @@ -1171,7 +1171,8 @@ fn quoted_tt_to_string(tt: &mbe::TokenTree) -> String { match *tt { mbe::TokenTree::Token(ref token) => pprust::token_to_string(&token), mbe::TokenTree::MetaVar(_, name) => format!("${}", name), - mbe::TokenTree::MetaVarDecl(_, name, kind) => format!("${}:{}", name, kind), + mbe::TokenTree::MetaVarDecl(_, name, Some(kind)) => format!("${}:{}", name, kind), + mbe::TokenTree::MetaVarDecl(_, name, None) => format!("${}:", name), _ => panic!( "{}", "unexpected mbe::TokenTree::{Sequence or Delimited} \ diff --git a/compiler/rustc_expand/src/mbe/quoted.rs b/compiler/rustc_expand/src/mbe/quoted.rs index 48db532c78f..01b11bb979d 100644 --- a/compiler/rustc_expand/src/mbe/quoted.rs +++ b/compiler/rustc_expand/src/mbe/quoted.rs @@ -3,7 +3,7 @@ use crate::mbe::{Delimited, KleeneOp, KleeneToken, SequenceRepetition, TokenTree use rustc_ast::token::{self, Token}; use rustc_ast::tokenstream; -use rustc_ast::NodeId; +use rustc_ast::{NodeId, DUMMY_NODE_ID}; use rustc_ast_pretty::pprust; use rustc_session::parse::ParseSess; use rustc_span::symbol::{kw, Ident}; @@ -73,7 +73,7 @@ pub(super) fn parse( .emit(); token::NonterminalKind::Ident }); - result.push(TokenTree::MetaVarDecl(span, ident, kind)); + result.push(TokenTree::MetaVarDecl(span, ident, Some(kind))); continue; } _ => token.span, @@ -83,8 +83,11 @@ pub(super) fn parse( } tree => tree.as_ref().map(tokenstream::TokenTree::span).unwrap_or(start_sp), }; - sess.span_diagnostic.struct_span_err(span, "missing fragment specifier").emit(); - continue; + if node_id != DUMMY_NODE_ID { + // Macros loaded from other crates have dummy node ids. + sess.missing_fragment_specifiers.borrow_mut().insert(span, node_id); + } + result.push(TokenTree::MetaVarDecl(span, ident, None)); } // Not a metavar or no matchers allowed, so just return the tree diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index c13d26c79d7..a8c8690b9e7 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -29,6 +29,7 @@ use rustc_passes::{self, hir_stats, layout_test}; use rustc_plugin_impl as plugin; use rustc_resolve::{Resolver, ResolverArenas}; use rustc_session::config::{CrateType, Input, OutputFilenames, OutputType, PpMode, PpSourceMode}; +use rustc_session::lint; use rustc_session::output::{filename_for_input, filename_for_metadata}; use rustc_session::search_paths::PathKind; use rustc_session::Session; @@ -306,11 +307,27 @@ fn configure_and_expand_inner<'a>( ecx.check_unused_macros(); }); + let mut missing_fragment_specifiers: Vec<_> = ecx + .sess + .parse_sess + .missing_fragment_specifiers + .borrow() + .iter() + .map(|(span, node_id)| (*span, *node_id)) + .collect(); + missing_fragment_specifiers.sort_unstable_by_key(|(span, _)| *span); + + let recursion_limit_hit = ecx.reduced_recursion_limit.is_some(); + + for (span, node_id) in missing_fragment_specifiers { + let lint = lint::builtin::MISSING_FRAGMENT_SPECIFIER; + let msg = "missing fragment specifier"; + resolver.lint_buffer().buffer_lint(lint, node_id, span, msg); + } if cfg!(windows) { env::set_var("PATH", &old_path); } - let recursion_limit_hit = ecx.reduced_recursion_limit.is_some(); if recursion_limit_hit { // If we hit a recursion limit, exit early to avoid later passes getting overwhelmed // with a large AST diff --git a/compiler/rustc_session/src/parse.rs b/compiler/rustc_session/src/parse.rs index 66c3738fb5b..b1a48342417 100644 --- a/compiler/rustc_session/src/parse.rs +++ b/compiler/rustc_session/src/parse.rs @@ -119,6 +119,7 @@ pub struct ParseSess { pub unstable_features: UnstableFeatures, pub config: CrateConfig, pub edition: Edition, + pub missing_fragment_specifiers: Lock>, /// Places where raw identifiers were used. This is used for feature-gating raw identifiers. pub raw_identifier_spans: Lock>, /// Used to determine and report recursive module inclusions. @@ -152,6 +153,7 @@ impl ParseSess { unstable_features: UnstableFeatures::from_environment(None), config: FxHashSet::default(), edition: ExpnId::root().expn_data().edition, + missing_fragment_specifiers: Default::default(), raw_identifier_spans: Lock::new(Vec::new()), included_mod_stack: Lock::new(vec![]), source_map, diff --git a/src/test/ui/lint/expansion-time.rs b/src/test/ui/lint/expansion-time.rs index a9c7ac363b0..f23c7cb0dca 100644 --- a/src/test/ui/lint/expansion-time.rs +++ b/src/test/ui/lint/expansion-time.rs @@ -5,6 +5,10 @@ macro_rules! foo { ( $($i:ident)* ) => { $($i)+ }; //~ WARN meta-variable repeats with different Kleene operator } +#[warn(missing_fragment_specifier)] +macro_rules! m { ($i) => {} } //~ WARN missing fragment specifier + //~| WARN this was previously accepted + #[warn(soft_unstable)] mod benches { #[bench] //~ WARN use of unstable library feature 'test' diff --git a/src/test/ui/lint/expansion-time.stderr b/src/test/ui/lint/expansion-time.stderr index 24e2733064e..b0fc1f8e5ee 100644 --- a/src/test/ui/lint/expansion-time.stderr +++ b/src/test/ui/lint/expansion-time.stderr @@ -12,14 +12,28 @@ note: the lint level is defined here LL | #[warn(meta_variable_misuse)] | ^^^^^^^^^^^^^^^^^^^^ +warning: missing fragment specifier + --> $DIR/expansion-time.rs:9:19 + | +LL | macro_rules! m { ($i) => {} } + | ^^ + | +note: the lint level is defined here + --> $DIR/expansion-time.rs:8:8 + | +LL | #[warn(missing_fragment_specifier)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #40107 + warning: use of unstable library feature 'test': `bench` is a part of custom test frameworks which are unstable - --> $DIR/expansion-time.rs:10:7 + --> $DIR/expansion-time.rs:14:7 | LL | #[bench] | ^^^^^ | note: the lint level is defined here - --> $DIR/expansion-time.rs:8:8 + --> $DIR/expansion-time.rs:12:8 | LL | #[warn(soft_unstable)] | ^^^^^^^^^^^^^ @@ -33,10 +47,10 @@ LL | 2 | ^ | note: the lint level is defined here - --> $DIR/expansion-time.rs:25:8 + --> $DIR/expansion-time.rs:29:8 | LL | #[warn(incomplete_include)] | ^^^^^^^^^^^^^^^^^^ -warning: 3 warnings emitted +warning: 4 warnings emitted diff --git a/src/test/ui/macros/issue-39404.rs b/src/test/ui/macros/issue-39404.rs index 054958ba00b..2229f2c3900 100644 --- a/src/test/ui/macros/issue-39404.rs +++ b/src/test/ui/macros/issue-39404.rs @@ -2,5 +2,6 @@ macro_rules! m { ($i) => {} } //~^ ERROR missing fragment specifier +//~| WARN previously accepted fn main() {} diff --git a/src/test/ui/macros/issue-39404.stderr b/src/test/ui/macros/issue-39404.stderr index 645f06e59d8..d2f2a823c2a 100644 --- a/src/test/ui/macros/issue-39404.stderr +++ b/src/test/ui/macros/issue-39404.stderr @@ -3,6 +3,10 @@ error: missing fragment specifier | LL | macro_rules! m { ($i) => {} } | ^^ + | + = note: `#[deny(missing_fragment_specifier)]` on by default + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #40107 error: aborting due to previous error diff --git a/src/test/ui/macros/macro-match-nonterminal.rs b/src/test/ui/macros/macro-match-nonterminal.rs index 6b023e41372..b23e5c71c03 100644 --- a/src/test/ui/macros/macro-match-nonterminal.rs +++ b/src/test/ui/macros/macro-match-nonterminal.rs @@ -2,6 +2,7 @@ macro_rules! test { ($a, $b) => { //~^ ERROR missing fragment //~| ERROR missing fragment + //~| WARN this was previously accepted () }; } diff --git a/src/test/ui/macros/macro-match-nonterminal.stderr b/src/test/ui/macros/macro-match-nonterminal.stderr index 334d62812cd..674ce3434aa 100644 --- a/src/test/ui/macros/macro-match-nonterminal.stderr +++ b/src/test/ui/macros/macro-match-nonterminal.stderr @@ -9,6 +9,10 @@ error: missing fragment specifier | LL | ($a, $b) => { | ^^ + | + = note: `#[deny(missing_fragment_specifier)]` on by default + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #40107 error: aborting due to 2 previous errors diff --git a/src/test/ui/parser/macro/issue-33569.rs b/src/test/ui/parser/macro/issue-33569.rs index cf81f0480a2..80e2d7c6545 100644 --- a/src/test/ui/parser/macro/issue-33569.rs +++ b/src/test/ui/parser/macro/issue-33569.rs @@ -2,7 +2,6 @@ macro_rules! foo { { $+ } => { //~ ERROR expected identifier, found `+` //~^ ERROR missing fragment specifier $(x)(y) //~ ERROR expected one of: `*`, `+`, or `?` - //~^ ERROR attempted to repeat an expression containing no syntax variables } } diff --git a/src/test/ui/parser/macro/issue-33569.stderr b/src/test/ui/parser/macro/issue-33569.stderr index f54efaa6996..b4d38d3ce48 100644 --- a/src/test/ui/parser/macro/issue-33569.stderr +++ b/src/test/ui/parser/macro/issue-33569.stderr @@ -4,23 +4,17 @@ error: expected identifier, found `+` LL | { $+ } => { | ^ -error: missing fragment specifier - --> $DIR/issue-33569.rs:2:8 - | -LL | { $+ } => { - | ^ - error: expected one of: `*`, `+`, or `?` --> $DIR/issue-33569.rs:4:13 | LL | $(x)(y) | ^^^ -error: attempted to repeat an expression containing no syntax variables matched as repeating at this depth - --> $DIR/issue-33569.rs:4:10 +error: missing fragment specifier + --> $DIR/issue-33569.rs:2:8 | -LL | $(x)(y) - | ^^^ +LL | { $+ } => { + | ^ -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors -- cgit 1.4.1-3-g733a5 From 9cd992f394de0ba9d7990c0159bea8855329e6b0 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Tue, 22 Dec 2020 09:54:23 -0500 Subject: Add some intra-doc links to compiler docs --- compiler/rustc_builtin_macros/src/deriving/generic/mod.rs | 5 ++++- compiler/rustc_interface/src/interface.rs | 3 ++- compiler/rustc_interface/src/passes.rs | 2 +- compiler/rustc_interface/src/queries.rs | 6 +++++- compiler/rustc_span/src/symbol.rs | 2 +- 5 files changed, 13 insertions(+), 5 deletions(-) (limited to 'compiler/rustc_interface/src') diff --git a/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs b/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs index 68c11868af8..6531e68be9c 100644 --- a/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs +++ b/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs @@ -257,7 +257,10 @@ pub struct Substructure<'a> { pub type_ident: Ident, /// ident of the method pub method_ident: Ident, - /// dereferenced access to any `Self_` or `Ptr(Self_, _)` arguments + /// dereferenced access to any [`Self_`] or [`Ptr(Self_, _)][ptr]` arguments + /// + /// [`Self_`]: ty::Ty::Self_ + /// [ptr]: ty::Ty::Ptr pub self_args: &'a [P], /// verbatim access to any other arguments pub nonself_args: &'a [P], diff --git a/compiler/rustc_interface/src/interface.rs b/compiler/rustc_interface/src/interface.rs index acd49d86c2c..28eb1fed6a0 100644 --- a/compiler/rustc_interface/src/interface.rs +++ b/compiler/rustc_interface/src/interface.rs @@ -25,8 +25,9 @@ use std::sync::{Arc, Mutex}; pub type Result = result::Result; /// Represents a compiler session. +/// /// Can be used to run `rustc_interface` queries. -/// Created by passing `Config` to `run_compiler`. +/// Created by passing [`Config`] to [`run_compiler`]. pub struct Compiler { pub(crate) sess: Lrc, codegen_backend: Lrc>, diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index c13d26c79d7..3398da024c9 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -95,7 +95,7 @@ declare_box_region_type!( /// harness if one is to be provided, injection of a dependency on the /// standard library and prelude, and name resolution. /// -/// Returns `None` if we're aborting after handling -W help. +/// Returns [`None`] if we're aborting after handling -W help. pub fn configure_and_expand( sess: Lrc, lint_store: Lrc, diff --git a/compiler/rustc_interface/src/queries.rs b/compiler/rustc_interface/src/queries.rs index 4c340b3fc1f..6ea0828cea0 100644 --- a/compiler/rustc_interface/src/queries.rs +++ b/compiler/rustc_interface/src/queries.rs @@ -23,7 +23,11 @@ use std::cell::{Ref, RefCell, RefMut}; use std::rc::Rc; /// Represent the result of a query. -/// This result can be stolen with the `take` method and generated with the `compute` method. +/// +/// This result can be stolen with the [`take`] method and generated with the [`compute`] method. +/// +/// [`take`]: Self::take +/// [`compute`]: Self::compute pub struct Query { result: RefCell>>, } diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 4d14763825c..1af7fa81cbb 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -1681,7 +1681,7 @@ fn with_interner T>(f: F) -> T { SESSION_GLOBALS.with(|session_globals| f(&mut *session_globals.symbol_interner.lock())) } -/// An alternative to `Symbol`, useful when the chars within the symbol need to +/// An alternative to [`Symbol`], useful when the chars within the symbol need to /// be accessed. It deliberately has limited functionality and should only be /// used for temporary values. /// -- cgit 1.4.1-3-g733a5 From 4d2d0bad4e51d0d14d21b4e21cdb61b55dd11349 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Mon, 28 Dec 2020 20:15:16 +0300 Subject: Remove `compile-fail` test suite --- compiler/rustc_hir/src/hir.rs | 2 +- compiler/rustc_incremental/src/assert_dep_graph.rs | 2 +- compiler/rustc_interface/src/passes.rs | 2 +- compiler/rustc_interface/src/queries.rs | 4 +- compiler/rustc_mir/src/transform/rustc_peek.rs | 2 +- compiler/rustc_resolve/src/build_reduced_graph.rs | 2 +- compiler/rustc_trait_selection/src/infer.rs | 2 +- .../src/traits/select/candidate_assembly.rs | 2 +- compiler/rustc_typeck/src/collect.rs | 3 +- src/bootstrap/README.md | 1 - src/bootstrap/builder.rs | 1 - src/bootstrap/mk/Makefile.in | 4 +- src/bootstrap/test.rs | 6 --- src/ci/docker/host-x86_64/test-various/Dockerfile | 1 - src/etc/generate-deriving-span-tests.py | 2 +- src/test/compile-fail/asm-src-loc-codegen-units.rs | 10 ---- src/test/compile-fail/asm-src-loc.rs | 9 ---- src/test/compile-fail/auxiliary/crateresolve1-1.rs | 5 -- src/test/compile-fail/auxiliary/crateresolve1-2.rs | 5 -- src/test/compile-fail/auxiliary/crateresolve1-3.rs | 5 -- src/test/compile-fail/auxiliary/depends.rs | 8 --- .../compile-fail/auxiliary/needs-panic-runtime.rs | 6 --- .../auxiliary/panic-runtime-lang-items.rs | 15 ------ .../compile-fail/auxiliary/panic-runtime-unwind.rs | 17 ------ .../auxiliary/panic-runtime-unwind2.rs | 17 ------ src/test/compile-fail/auxiliary/some-panic-impl.rs | 11 ---- .../auxiliary/wants-panic-runtime-unwind.rs | 6 --- src/test/compile-fail/auxiliary/weak-lang-items.rs | 22 -------- .../coerce-unsafe-closure-to-unsafe-fn-ptr.rs | 5 -- src/test/compile-fail/coerce-unsafe-to-closure.rs | 4 -- src/test/compile-fail/consts/const-fn-error.rs | 21 -------- src/test/compile-fail/consts/issue-55878.rs | 7 --- src/test/compile-fail/crateresolve1.rs | 9 ---- src/test/compile-fail/empty-extern-arg.rs | 4 -- src/test/compile-fail/invalid-link-args.rs | 12 ----- src/test/compile-fail/issue-10755.rs | 5 -- src/test/compile-fail/issue-23595-1.rs | 14 ----- .../compile-fail/issue-27675-unchecked-bounds.rs | 19 ------- src/test/compile-fail/issue-43733-2.rs | 28 ---------- src/test/compile-fail/issue-44415.rs | 11 ---- .../issue-46209-private-enum-variant-reexport.rs | 41 --------------- src/test/compile-fail/issue-52443.rs | 14 ----- .../compile-fail/meta-expected-error-wrong-rev.rs | 16 ------ src/test/compile-fail/must_use-in-stdlib-traits.rs | 47 ----------------- src/test/compile-fail/not-utf8.bin | Bin 3036 -> 0 bytes src/test/compile-fail/not-utf8.rs | 5 -- src/test/compile-fail/panic-handler-missing.rs | 8 --- src/test/compile-fail/panic-handler-twice.rs | 18 ------- .../runtime-depend-on-needs-runtime.rs | 7 --- .../runtime-depend-on-needs-runtime.stderr | 4 -- .../compile-fail/specialization/issue-50452.rs | 22 -------- src/test/compile-fail/two-panic-runtimes.rs | 14 ----- .../compile-fail/unwind-tables-panic-required.rs | 10 ---- .../compile-fail/unwind-tables-target-required.rs | 11 ---- src/test/compile-fail/want-abort-got-unwind.rs | 7 --- src/test/compile-fail/want-abort-got-unwind2.rs | 8 --- src/test/compile-fail/weak-lang-item.rs | 11 ---- .../many-crates-but-no-match/Makefile | 7 ++- .../type-mismatch-same-crate-name/crateC.rs | 2 +- .../ui-fulldeps/dropck-tarena-cycle-checked.rs | 4 +- src/test/ui-fulldeps/dropck_tarena_sound_drop.rs | 2 +- src/test/ui/array-slice-vec/copy-out-of-array-1.rs | 2 +- ...sociated-types-projection-to-unrelated-trait.rs | 2 +- src/test/ui/associated-types/issue-23595-1.rs | 14 +++++ src/test/ui/associated-types/issue-23595-1.stderr | 16 ++++++ .../issue-27675-unchecked-bounds.rs | 19 +++++++ .../issue-27675-unchecked-bounds.stderr | 17 ++++++ .../coerce-unsafe-closure-to-unsafe-fn-ptr.rs | 5 ++ .../coerce-unsafe-closure-to-unsafe-fn-ptr.stderr | 11 ++++ src/test/ui/closures/coerce-unsafe-to-closure.rs | 4 ++ .../ui/closures/coerce-unsafe-to-closure.stderr | 11 ++++ src/test/ui/consts/const-fn-error.rs | 21 ++++++++ src/test/ui/consts/const-fn-error.stderr | 49 ++++++++++++++++++ src/test/ui/consts/issue-44415.rs | 11 ++++ src/test/ui/consts/issue-44415.stderr | 28 ++++++++++ src/test/ui/consts/issue-55878.rs | 8 +++ src/test/ui/consts/issue-55878.stderr | 25 +++++++++ .../ui/crate-loading/auxiliary/crateresolve1-1.rs | 5 ++ .../ui/crate-loading/auxiliary/crateresolve1-2.rs | 5 ++ .../ui/crate-loading/auxiliary/crateresolve1-3.rs | 5 ++ src/test/ui/crate-loading/crateresolve1.rs | 10 ++++ src/test/ui/dropck/dropck_trait_cycle_checked.rs | 2 +- src/test/ui/extern-flag/empty-extern-arg.rs | 4 ++ src/test/ui/extern-flag/empty-extern-arg.stderr | 4 ++ src/test/ui/fsu-moves-and-copies.rs | 2 +- .../closure-expected-type/README.md | 2 +- src/test/ui/issues/issue-26996.rs | 2 +- src/test/ui/issues/issue-27021.rs | 2 +- .../issues/issue-28498-ugeh-with-lifetime-param.rs | 2 +- .../issues/issue-28498-ugeh-with-passed-to-fn.rs | 2 +- .../ui/issues/issue-28498-ugeh-with-trait-bound.rs | 2 +- src/test/ui/issues/issue-43733.rs | 31 ----------- src/test/ui/issues/issue-43733.stderr | 19 ------- src/test/ui/issues/issue-49298.rs | 2 +- src/test/ui/linkage-attr/invalid-link-args.rs | 14 +++++ src/test/ui/linkage-attr/issue-10755.rs | 7 +++ src/test/ui/lint/must_use-in-stdlib-traits.rs | 47 +++++++++++++++++ src/test/ui/lint/must_use-in-stdlib-traits.stderr | 47 +++++++++++++++++ src/test/ui/llvm-asm/asm-src-loc-codegen-units.rs | 12 +++++ src/test/ui/llvm-asm/asm-src-loc.rs | 11 ++++ src/test/ui/macros/macro-comma-behavior-rpass.rs | 28 +++++----- .../ui/macros/macro-comma-behavior.core.stderr | 14 +++-- src/test/ui/macros/macro-comma-behavior.rs | 20 +++----- src/test/ui/macros/macro-comma-behavior.std.stderr | 30 ++++++++--- src/test/ui/macros/macro-comma-support-rpass.rs | 2 +- src/test/ui/macros/not-utf8.bin | Bin 0 -> 3036 bytes src/test/ui/macros/not-utf8.rs | 5 ++ src/test/ui/macros/not-utf8.stderr | 10 ++++ .../ui/meta/meta-expected-error-wrong-rev.a.stderr | 16 ++++++ src/test/ui/meta/meta-expected-error-wrong-rev.rs | 16 ++++++ src/test/ui/never_type/issue-52443.rs | 14 +++++ src/test/ui/never_type/issue-52443.stderr | 57 +++++++++++++++++++++ .../ui/object-lifetime-default-from-rptr-box.rs | 2 +- .../ui/panic-handler/auxiliary/weak-lang-items.rs | 22 ++++++++ src/test/ui/panic-handler/panic-handler-missing.rs | 9 ++++ src/test/ui/panic-handler/panic-handler-twice.rs | 19 +++++++ src/test/ui/panic-handler/weak-lang-item.rs | 11 ++++ src/test/ui/panic-handler/weak-lang-item.stderr | 19 +++++++ src/test/ui/panic-runtime/auxiliary/depends.rs | 8 +++ .../panic-runtime/auxiliary/needs-panic-runtime.rs | 6 +++ .../runtime-depend-on-needs-runtime.rs | 8 +++ src/test/ui/panic-runtime/two-panic-runtimes.rs | 16 ++++++ .../panic-runtime/unwind-tables-panic-required.rs | 11 ++++ .../panic-runtime/unwind-tables-target-required.rs | 11 ++++ src/test/ui/panic-runtime/want-abort-got-unwind.rs | 9 ++++ .../ui/panic-runtime/want-abort-got-unwind2.rs | 10 ++++ .../issue-46209-private-enum-variant-reexport.rs | 41 +++++++++++++++ ...ssue-46209-private-enum-variant-reexport.stderr | 44 ++++++++++++++++ .../ui/regions/regions-early-bound-trait-param.rs | 2 +- ...ons-variance-contravariant-use-contravariant.rs | 2 +- .../regions-variance-covariant-use-covariant.rs | 2 +- src/test/ui/span/dropck_arr_cycle_checked.rs | 2 +- src/test/ui/span/dropck_vec_cycle_checked.rs | 2 +- .../ui/specialization/defaultimpl/projection.rs | 2 +- src/test/ui/specialization/issue-50452-fail.rs | 21 ++++++++ src/test/ui/specialization/issue-50452-fail.stderr | 26 ++++++++++ .../ui/specialization/specialization-projection.rs | 2 +- .../ui/structs-enums/discrim-explicit-23030.rs | 2 +- .../object-lifetime-default-from-rptr-struct.rs | 2 +- src/test/ui/svh/auxiliary/svh-uta-base.rs | 2 +- .../ui/svh/auxiliary/svh-uta-change-use-trait.rs | 2 +- src/test/ui/svh/auxiliary/svh-utb.rs | 2 +- src/test/ui/svh/svh-use-trait.rs | 2 +- src/test/ui/threads-sendsync/issue-43733-2.rs | 30 +++++++++++ src/test/ui/threads-sendsync/issue-43733.rs | 31 +++++++++++ src/test/ui/threads-sendsync/issue-43733.stderr | 19 +++++++ src/test/ui/traits/traits-repeated-supertrait.rs | 2 +- src/test/ui/unsafe-fn-called-from-unsafe-blk.rs | 2 +- src/test/ui/unsafe-fn-called-from-unsafe-fn.rs | 2 +- src/tools/compiletest/src/common.rs | 8 +-- src/tools/compiletest/src/header.rs | 5 +- src/tools/compiletest/src/main.rs | 2 +- src/tools/compiletest/src/runtest.rs | 17 +++--- src/tools/tidy/src/features.rs | 6 +-- 154 files changed, 1013 insertions(+), 693 deletions(-) delete mode 100644 src/test/compile-fail/asm-src-loc-codegen-units.rs delete mode 100644 src/test/compile-fail/asm-src-loc.rs delete mode 100644 src/test/compile-fail/auxiliary/crateresolve1-1.rs delete mode 100644 src/test/compile-fail/auxiliary/crateresolve1-2.rs delete mode 100644 src/test/compile-fail/auxiliary/crateresolve1-3.rs delete mode 100644 src/test/compile-fail/auxiliary/depends.rs delete mode 100644 src/test/compile-fail/auxiliary/needs-panic-runtime.rs delete mode 100644 src/test/compile-fail/auxiliary/panic-runtime-lang-items.rs delete mode 100644 src/test/compile-fail/auxiliary/panic-runtime-unwind.rs delete mode 100644 src/test/compile-fail/auxiliary/panic-runtime-unwind2.rs delete mode 100644 src/test/compile-fail/auxiliary/some-panic-impl.rs delete mode 100644 src/test/compile-fail/auxiliary/wants-panic-runtime-unwind.rs delete mode 100644 src/test/compile-fail/auxiliary/weak-lang-items.rs delete mode 100644 src/test/compile-fail/coerce-unsafe-closure-to-unsafe-fn-ptr.rs delete mode 100644 src/test/compile-fail/coerce-unsafe-to-closure.rs delete mode 100644 src/test/compile-fail/consts/const-fn-error.rs delete mode 100644 src/test/compile-fail/consts/issue-55878.rs delete mode 100644 src/test/compile-fail/crateresolve1.rs delete mode 100644 src/test/compile-fail/empty-extern-arg.rs delete mode 100644 src/test/compile-fail/invalid-link-args.rs delete mode 100644 src/test/compile-fail/issue-10755.rs delete mode 100644 src/test/compile-fail/issue-23595-1.rs delete mode 100644 src/test/compile-fail/issue-27675-unchecked-bounds.rs delete mode 100644 src/test/compile-fail/issue-43733-2.rs delete mode 100644 src/test/compile-fail/issue-44415.rs delete mode 100644 src/test/compile-fail/issue-46209-private-enum-variant-reexport.rs delete mode 100644 src/test/compile-fail/issue-52443.rs delete mode 100644 src/test/compile-fail/meta-expected-error-wrong-rev.rs delete mode 100644 src/test/compile-fail/must_use-in-stdlib-traits.rs delete mode 100644 src/test/compile-fail/not-utf8.bin delete mode 100644 src/test/compile-fail/not-utf8.rs delete mode 100644 src/test/compile-fail/panic-handler-missing.rs delete mode 100644 src/test/compile-fail/panic-handler-twice.rs delete mode 100644 src/test/compile-fail/runtime-depend-on-needs-runtime.rs delete mode 100644 src/test/compile-fail/runtime-depend-on-needs-runtime.stderr delete mode 100644 src/test/compile-fail/specialization/issue-50452.rs delete mode 100644 src/test/compile-fail/two-panic-runtimes.rs delete mode 100644 src/test/compile-fail/unwind-tables-panic-required.rs delete mode 100644 src/test/compile-fail/unwind-tables-target-required.rs delete mode 100644 src/test/compile-fail/want-abort-got-unwind.rs delete mode 100644 src/test/compile-fail/want-abort-got-unwind2.rs delete mode 100644 src/test/compile-fail/weak-lang-item.rs create mode 100644 src/test/ui/associated-types/issue-23595-1.rs create mode 100644 src/test/ui/associated-types/issue-23595-1.stderr create mode 100644 src/test/ui/associated-types/issue-27675-unchecked-bounds.rs create mode 100644 src/test/ui/associated-types/issue-27675-unchecked-bounds.stderr create mode 100644 src/test/ui/closures/coerce-unsafe-closure-to-unsafe-fn-ptr.rs create mode 100644 src/test/ui/closures/coerce-unsafe-closure-to-unsafe-fn-ptr.stderr create mode 100644 src/test/ui/closures/coerce-unsafe-to-closure.rs create mode 100644 src/test/ui/closures/coerce-unsafe-to-closure.stderr create mode 100644 src/test/ui/consts/const-fn-error.rs create mode 100644 src/test/ui/consts/const-fn-error.stderr create mode 100644 src/test/ui/consts/issue-44415.rs create mode 100644 src/test/ui/consts/issue-44415.stderr create mode 100644 src/test/ui/consts/issue-55878.rs create mode 100644 src/test/ui/consts/issue-55878.stderr create mode 100644 src/test/ui/crate-loading/auxiliary/crateresolve1-1.rs create mode 100644 src/test/ui/crate-loading/auxiliary/crateresolve1-2.rs create mode 100644 src/test/ui/crate-loading/auxiliary/crateresolve1-3.rs create mode 100644 src/test/ui/crate-loading/crateresolve1.rs create mode 100644 src/test/ui/extern-flag/empty-extern-arg.rs create mode 100644 src/test/ui/extern-flag/empty-extern-arg.stderr delete mode 100644 src/test/ui/issues/issue-43733.rs delete mode 100644 src/test/ui/issues/issue-43733.stderr create mode 100644 src/test/ui/linkage-attr/invalid-link-args.rs create mode 100644 src/test/ui/linkage-attr/issue-10755.rs create mode 100644 src/test/ui/lint/must_use-in-stdlib-traits.rs create mode 100644 src/test/ui/lint/must_use-in-stdlib-traits.stderr create mode 100644 src/test/ui/llvm-asm/asm-src-loc-codegen-units.rs create mode 100644 src/test/ui/llvm-asm/asm-src-loc.rs create mode 100644 src/test/ui/macros/not-utf8.bin create mode 100644 src/test/ui/macros/not-utf8.rs create mode 100644 src/test/ui/macros/not-utf8.stderr create mode 100644 src/test/ui/meta/meta-expected-error-wrong-rev.a.stderr create mode 100644 src/test/ui/meta/meta-expected-error-wrong-rev.rs create mode 100644 src/test/ui/never_type/issue-52443.rs create mode 100644 src/test/ui/never_type/issue-52443.stderr create mode 100644 src/test/ui/panic-handler/auxiliary/weak-lang-items.rs create mode 100644 src/test/ui/panic-handler/panic-handler-missing.rs create mode 100644 src/test/ui/panic-handler/panic-handler-twice.rs create mode 100644 src/test/ui/panic-handler/weak-lang-item.rs create mode 100644 src/test/ui/panic-handler/weak-lang-item.stderr create mode 100644 src/test/ui/panic-runtime/auxiliary/depends.rs create mode 100644 src/test/ui/panic-runtime/auxiliary/needs-panic-runtime.rs create mode 100644 src/test/ui/panic-runtime/runtime-depend-on-needs-runtime.rs create mode 100644 src/test/ui/panic-runtime/two-panic-runtimes.rs create mode 100644 src/test/ui/panic-runtime/unwind-tables-panic-required.rs create mode 100644 src/test/ui/panic-runtime/unwind-tables-target-required.rs create mode 100644 src/test/ui/panic-runtime/want-abort-got-unwind.rs create mode 100644 src/test/ui/panic-runtime/want-abort-got-unwind2.rs create mode 100644 src/test/ui/privacy/issue-46209-private-enum-variant-reexport.rs create mode 100644 src/test/ui/privacy/issue-46209-private-enum-variant-reexport.stderr create mode 100644 src/test/ui/specialization/issue-50452-fail.rs create mode 100644 src/test/ui/specialization/issue-50452-fail.stderr create mode 100644 src/test/ui/threads-sendsync/issue-43733-2.rs create mode 100644 src/test/ui/threads-sendsync/issue-43733.rs create mode 100644 src/test/ui/threads-sendsync/issue-43733.stderr (limited to 'compiler/rustc_interface/src') diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index 2abebbd0303..23999a8dca0 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -607,7 +607,7 @@ pub struct Crate<'hir> { // over the ids in increasing order. In principle it should not // matter what order we visit things in, but in *practice* it // does, because it can affect the order in which errors are - // detected, which in turn can make compile-fail tests yield + // detected, which in turn can make UI tests yield // slightly different results. pub items: BTreeMap>, diff --git a/compiler/rustc_incremental/src/assert_dep_graph.rs b/compiler/rustc_incremental/src/assert_dep_graph.rs index e17396422f1..9b4388c911f 100644 --- a/compiler/rustc_incremental/src/assert_dep_graph.rs +++ b/compiler/rustc_incremental/src/assert_dep_graph.rs @@ -12,7 +12,7 @@ //! In this code, we report errors on each `rustc_if_this_changed` //! annotation. If a path exists in all cases, then we would report //! "all path(s) exist". Otherwise, we report: "no path to `foo`" for -//! each case where no path exists. `compile-fail` tests can then be +//! each case where no path exists. `ui` tests can then be //! used to check when paths exist or do not. //! //! The full form of the `rustc_if_this_changed` annotation is diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index 1a2af48b38d..461ee085922 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -889,7 +889,7 @@ fn analysis(tcx: TyCtxt<'_>, cnum: CrateNum) -> Result<()> { // Avoid overwhelming user with errors if borrow checking failed. // I'm not sure how helpful this is, to be honest, but it avoids a - // lot of annoying errors in the compile-fail tests (basically, + // lot of annoying errors in the ui tests (basically, // lint warnings and so on -- kindck used to do this abort, but // kindck is gone now). -nmatsakis if sess.has_errors() { diff --git a/compiler/rustc_interface/src/queries.rs b/compiler/rustc_interface/src/queries.rs index 2384927b301..9c49f926d41 100644 --- a/compiler/rustc_interface/src/queries.rs +++ b/compiler/rustc_interface/src/queries.rs @@ -280,7 +280,7 @@ impl<'tcx> Queries<'tcx> { // Don't do code generation if there were any errors self.session().compile_status()?; - // Hook for compile-fail tests. + // Hook for UI tests. Self::check_for_rustc_errors_attr(tcx); Ok(passes::start_codegen(&***self.codegen_backend(), tcx, &*outputs.peek())) @@ -289,7 +289,7 @@ impl<'tcx> Queries<'tcx> { } /// Check for the `#[rustc_error]` annotation, which forces an error in codegen. This is used - /// to write compile-fail tests that actually test that compilation succeeds without reporting + /// to write UI tests that actually test that compilation succeeds without reporting /// an error. fn check_for_rustc_errors_attr(tcx: TyCtxt<'_>) { let def_id = match tcx.entry_fn(LOCAL_CRATE) { diff --git a/compiler/rustc_mir/src/transform/rustc_peek.rs b/compiler/rustc_mir/src/transform/rustc_peek.rs index 205f718d6e4..7598be4e4a1 100644 --- a/compiler/rustc_mir/src/transform/rustc_peek.rs +++ b/compiler/rustc_mir/src/transform/rustc_peek.rs @@ -92,7 +92,7 @@ impl<'tcx> MirPass<'tcx> for SanityCheck { /// "rustc_peek: bit not set". /// /// The intention is that one can write unit tests for dataflow by -/// putting code into a compile-fail test and using `rustc_peek` to +/// putting code into an UI test and using `rustc_peek` to /// make observations about the results of dataflow static analyses. /// /// (If there are any calls to `rustc_peek` that do not match the diff --git a/compiler/rustc_resolve/src/build_reduced_graph.rs b/compiler/rustc_resolve/src/build_reduced_graph.rs index 06e9969697d..a5adfb27e93 100644 --- a/compiler/rustc_resolve/src/build_reduced_graph.rs +++ b/compiler/rustc_resolve/src/build_reduced_graph.rs @@ -525,7 +525,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> { ModuleKind::Block(..) => unreachable!(), }; // HACK(eddyb) unclear how good this is, but keeping `$crate` - // in `source` breaks `src/test/compile-fail/import-crate-var.rs`, + // in `source` breaks `src/test/ui/imports/import-crate-var.rs`, // while the current crate doesn't have a valid `crate_name`. if crate_name != kw::Invalid { // `crate_name` should not be interpreted as relative. diff --git a/compiler/rustc_trait_selection/src/infer.rs b/compiler/rustc_trait_selection/src/infer.rs index 41184ce2116..da66fbc8587 100644 --- a/compiler/rustc_trait_selection/src/infer.rs +++ b/compiler/rustc_trait_selection/src/infer.rs @@ -162,7 +162,7 @@ impl<'tcx> OutlivesEnvironmentExt<'tcx> for OutlivesEnvironment<'tcx> { /// 'b` (and hence, transitively, that `T: 'a`). This method would /// add those assumptions into the outlives-environment. /// - /// Tests: `src/test/compile-fail/regions-free-region-ordering-*.rs` + /// Tests: `src/test/ui/regions/regions-free-region-ordering-*.rs` fn add_implied_bounds( &mut self, infcx: &InferCtxt<'a, 'tcx>, diff --git a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs index ca3369b8f1e..12029f7bc75 100644 --- a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs +++ b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs @@ -558,7 +558,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { // where-clause or, in the case of an object type, // it could be that the object type lists the // trait (e.g., `Foo+Send : Send`). See - // `compile-fail/typeck-default-trait-impl-send-param.rs` + // `ui/typeck/typeck-default-trait-impl-send-param.rs` // for an example of a test case that exercises // this path. } diff --git a/compiler/rustc_typeck/src/collect.rs b/compiler/rustc_typeck/src/collect.rs index 29b03d118e2..3e40f5ba28a 100644 --- a/compiler/rustc_typeck/src/collect.rs +++ b/compiler/rustc_typeck/src/collect.rs @@ -1767,8 +1767,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP const NO_GENERICS: &hir::Generics<'_> = &hir::Generics::empty(); // We use an `IndexSet` to preserves order of insertion. - // Preserving the order of insertion is important here so as not to break - // compile-fail UI tests. + // Preserving the order of insertion is important here so as not to break UI tests. let mut predicates: FxIndexSet<(ty::Predicate<'_>, Span)> = FxIndexSet::default(); let ast_generics = match node { diff --git a/src/bootstrap/README.md b/src/bootstrap/README.md index 84ed9446ae7..a2e596bf4e9 100644 --- a/src/bootstrap/README.md +++ b/src/bootstrap/README.md @@ -201,7 +201,6 @@ build/ # Output for all compiletest-based test suites test/ ui/ - compile-fail/ debuginfo/ ... diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 0fdafa39386..c271608a6b6 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -384,7 +384,6 @@ impl<'a> Builder<'a> { test::ExpandYamlAnchors, test::Tidy, test::Ui, - test::CompileFail, test::RunPassValgrind, test::MirOpt, test::Codegen, diff --git a/src/bootstrap/mk/Makefile.in b/src/bootstrap/mk/Makefile.in index 1564cfb0619..fd39944e176 100644 --- a/src/bootstrap/mk/Makefile.in +++ b/src/bootstrap/mk/Makefile.in @@ -66,7 +66,6 @@ check-stage2-T-x86_64-unknown-linux-musl-H-x86_64-unknown-linux-gnu: TESTS_IN_2 := \ src/test/ui \ - src/test/compile-fail \ src/tools/linkchecker ci-subset-1: @@ -75,8 +74,7 @@ ci-subset-2: $(Q)$(BOOTSTRAP) test --stage 2 $(TESTS_IN_2) TESTS_IN_MINGW_2 := \ - src/test/ui \ - src/test/compile-fail + src/test/ui ci-mingw-subset-1: $(Q)$(BOOTSTRAP) test --stage 2 $(TESTS_IN_MINGW_2:%=--exclude %) diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index b99692e8ba5..859236804d3 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -869,12 +869,6 @@ default_test_with_compare_mode!(Ui { compare_mode: "nll" }); -default_test!(CompileFail { - path: "src/test/compile-fail", - mode: "compile-fail", - suite: "compile-fail" -}); - default_test!(RunPassValgrind { path: "src/test/run-pass-valgrind", mode: "run-pass-valgrind", diff --git a/src/ci/docker/host-x86_64/test-various/Dockerfile b/src/ci/docker/host-x86_64/test-various/Dockerfile index 8653aecc12c..147de5f8015 100644 --- a/src/ci/docker/host-x86_64/test-various/Dockerfile +++ b/src/ci/docker/host-x86_64/test-various/Dockerfile @@ -44,7 +44,6 @@ ENV WASM_TARGETS=wasm32-unknown-unknown ENV WASM_SCRIPT python3 /checkout/x.py --stage 2 test --host='' --target $WASM_TARGETS \ src/test/run-make \ src/test/ui \ - src/test/compile-fail \ src/test/mir-opt \ src/test/codegen-units \ library/core diff --git a/src/etc/generate-deriving-span-tests.py b/src/etc/generate-deriving-span-tests.py index a0ba47e1dbe..d38f5add747 100755 --- a/src/etc/generate-deriving-span-tests.py +++ b/src/etc/generate-deriving-span-tests.py @@ -1,7 +1,7 @@ #!/usr/bin/env python """ -This script creates a pile of compile-fail tests check that all the +This script creates a pile of UI tests check that all the derives have spans that point to the fields, rather than the #[derive(...)] line. diff --git a/src/test/compile-fail/asm-src-loc-codegen-units.rs b/src/test/compile-fail/asm-src-loc-codegen-units.rs deleted file mode 100644 index 5b8690c3b98..00000000000 --- a/src/test/compile-fail/asm-src-loc-codegen-units.rs +++ /dev/null @@ -1,10 +0,0 @@ -// compile-flags: -C codegen-units=2 -// ignore-emscripten - -#![feature(llvm_asm)] - -fn main() { - unsafe { - llvm_asm!("nowayisthisavalidinstruction"); //~ ERROR instruction - } -} diff --git a/src/test/compile-fail/asm-src-loc.rs b/src/test/compile-fail/asm-src-loc.rs deleted file mode 100644 index 7c87f370d4f..00000000000 --- a/src/test/compile-fail/asm-src-loc.rs +++ /dev/null @@ -1,9 +0,0 @@ -// ignore-emscripten - -#![feature(llvm_asm)] - -fn main() { - unsafe { - llvm_asm!("nowayisthisavalidinstruction"); //~ ERROR instruction - } -} diff --git a/src/test/compile-fail/auxiliary/crateresolve1-1.rs b/src/test/compile-fail/auxiliary/crateresolve1-1.rs deleted file mode 100644 index a00a19e46d5..00000000000 --- a/src/test/compile-fail/auxiliary/crateresolve1-1.rs +++ /dev/null @@ -1,5 +0,0 @@ -// compile-flags:-C extra-filename=-1 -#![crate_name = "crateresolve1"] -#![crate_type = "lib"] - -pub fn f() -> isize { 10 } diff --git a/src/test/compile-fail/auxiliary/crateresolve1-2.rs b/src/test/compile-fail/auxiliary/crateresolve1-2.rs deleted file mode 100644 index 71cc0a12ea3..00000000000 --- a/src/test/compile-fail/auxiliary/crateresolve1-2.rs +++ /dev/null @@ -1,5 +0,0 @@ -// compile-flags:-C extra-filename=-2 -#![crate_name = "crateresolve1"] -#![crate_type = "lib"] - -pub fn f() -> isize { 20 } diff --git a/src/test/compile-fail/auxiliary/crateresolve1-3.rs b/src/test/compile-fail/auxiliary/crateresolve1-3.rs deleted file mode 100644 index 921687d4c3b..00000000000 --- a/src/test/compile-fail/auxiliary/crateresolve1-3.rs +++ /dev/null @@ -1,5 +0,0 @@ -// compile-flags:-C extra-filename=-3 -#![crate_name = "crateresolve1"] -#![crate_type = "lib"] - -pub fn f() -> isize { 30 } diff --git a/src/test/compile-fail/auxiliary/depends.rs b/src/test/compile-fail/auxiliary/depends.rs deleted file mode 100644 index e9bc2f4893e..00000000000 --- a/src/test/compile-fail/auxiliary/depends.rs +++ /dev/null @@ -1,8 +0,0 @@ -// no-prefer-dynamic - -#![feature(panic_runtime)] -#![crate_type = "rlib"] -#![panic_runtime] -#![no_std] - -extern crate needs_panic_runtime; diff --git a/src/test/compile-fail/auxiliary/needs-panic-runtime.rs b/src/test/compile-fail/auxiliary/needs-panic-runtime.rs deleted file mode 100644 index 3f030c169f6..00000000000 --- a/src/test/compile-fail/auxiliary/needs-panic-runtime.rs +++ /dev/null @@ -1,6 +0,0 @@ -// no-prefer-dynamic - -#![feature(needs_panic_runtime)] -#![crate_type = "rlib"] -#![needs_panic_runtime] -#![no_std] diff --git a/src/test/compile-fail/auxiliary/panic-runtime-lang-items.rs b/src/test/compile-fail/auxiliary/panic-runtime-lang-items.rs deleted file mode 100644 index b9ef2f32941..00000000000 --- a/src/test/compile-fail/auxiliary/panic-runtime-lang-items.rs +++ /dev/null @@ -1,15 +0,0 @@ -// no-prefer-dynamic - -#![crate_type = "rlib"] - -#![no_std] -#![feature(lang_items)] - -use core::panic::PanicInfo; - -#[lang = "panic_impl"] -fn panic_impl(info: &PanicInfo) -> ! { loop {} } -#[lang = "eh_personality"] -fn eh_personality() {} -#[lang = "eh_catch_typeinfo"] -static EH_CATCH_TYPEINFO: u8 = 0; diff --git a/src/test/compile-fail/auxiliary/panic-runtime-unwind.rs b/src/test/compile-fail/auxiliary/panic-runtime-unwind.rs deleted file mode 100644 index 97452a342ab..00000000000 --- a/src/test/compile-fail/auxiliary/panic-runtime-unwind.rs +++ /dev/null @@ -1,17 +0,0 @@ -// compile-flags:-C panic=unwind -// no-prefer-dynamic - -#![feature(panic_runtime)] -#![crate_type = "rlib"] - -#![no_std] -#![panic_runtime] - -#[no_mangle] -pub extern fn __rust_maybe_catch_panic() {} - -#[no_mangle] -pub extern fn __rust_start_panic() {} - -#[no_mangle] -pub extern fn rust_eh_personality() {} diff --git a/src/test/compile-fail/auxiliary/panic-runtime-unwind2.rs b/src/test/compile-fail/auxiliary/panic-runtime-unwind2.rs deleted file mode 100644 index 97452a342ab..00000000000 --- a/src/test/compile-fail/auxiliary/panic-runtime-unwind2.rs +++ /dev/null @@ -1,17 +0,0 @@ -// compile-flags:-C panic=unwind -// no-prefer-dynamic - -#![feature(panic_runtime)] -#![crate_type = "rlib"] - -#![no_std] -#![panic_runtime] - -#[no_mangle] -pub extern fn __rust_maybe_catch_panic() {} - -#[no_mangle] -pub extern fn __rust_start_panic() {} - -#[no_mangle] -pub extern fn rust_eh_personality() {} diff --git a/src/test/compile-fail/auxiliary/some-panic-impl.rs b/src/test/compile-fail/auxiliary/some-panic-impl.rs deleted file mode 100644 index 0348b3a2d76..00000000000 --- a/src/test/compile-fail/auxiliary/some-panic-impl.rs +++ /dev/null @@ -1,11 +0,0 @@ -// no-prefer-dynamic - -#![crate_type = "rlib"] -#![no_std] - -use core::panic::PanicInfo; - -#[panic_handler] -fn panic(info: &PanicInfo) -> ! { - loop {} -} diff --git a/src/test/compile-fail/auxiliary/wants-panic-runtime-unwind.rs b/src/test/compile-fail/auxiliary/wants-panic-runtime-unwind.rs deleted file mode 100644 index d5f0102196f..00000000000 --- a/src/test/compile-fail/auxiliary/wants-panic-runtime-unwind.rs +++ /dev/null @@ -1,6 +0,0 @@ -// no-prefer-dynamic - -#![crate_type = "rlib"] -#![no_std] - -extern crate panic_runtime_unwind; diff --git a/src/test/compile-fail/auxiliary/weak-lang-items.rs b/src/test/compile-fail/auxiliary/weak-lang-items.rs deleted file mode 100644 index 7a698cf76ae..00000000000 --- a/src/test/compile-fail/auxiliary/weak-lang-items.rs +++ /dev/null @@ -1,22 +0,0 @@ -// no-prefer-dynamic - -// This aux-file will require the eh_personality function to be codegen'd, but -// it hasn't been defined just yet. Make sure we don't explode. - -#![no_std] -#![crate_type = "rlib"] - -struct A; - -impl core::ops::Drop for A { - fn drop(&mut self) {} -} - -pub fn foo() { - let _a = A; - panic!("wut"); -} - -mod std { - pub use core::{option, fmt}; -} diff --git a/src/test/compile-fail/coerce-unsafe-closure-to-unsafe-fn-ptr.rs b/src/test/compile-fail/coerce-unsafe-closure-to-unsafe-fn-ptr.rs deleted file mode 100644 index 36777693fab..00000000000 --- a/src/test/compile-fail/coerce-unsafe-closure-to-unsafe-fn-ptr.rs +++ /dev/null @@ -1,5 +0,0 @@ -fn main() { - let _: unsafe fn() = || { ::std::pin::Pin::new_unchecked(&0_u8); }; - //~^ ERROR E0133 - let _: unsafe fn() = || unsafe { ::std::pin::Pin::new_unchecked(&0_u8); }; // OK -} diff --git a/src/test/compile-fail/coerce-unsafe-to-closure.rs b/src/test/compile-fail/coerce-unsafe-to-closure.rs deleted file mode 100644 index 78bdd36f9cc..00000000000 --- a/src/test/compile-fail/coerce-unsafe-to-closure.rs +++ /dev/null @@ -1,4 +0,0 @@ -fn main() { - let x: Option<&[u8]> = Some("foo").map(std::mem::transmute); - //~^ ERROR E0277 -} diff --git a/src/test/compile-fail/consts/const-fn-error.rs b/src/test/compile-fail/consts/const-fn-error.rs deleted file mode 100644 index 68a4d414ff3..00000000000 --- a/src/test/compile-fail/consts/const-fn-error.rs +++ /dev/null @@ -1,21 +0,0 @@ -#![feature(const_fn)] - -const X : usize = 2; - -const fn f(x: usize) -> usize { - let mut sum = 0; - for i in 0..x { - //~^ ERROR mutable references - //~| ERROR calls in constant functions - //~| ERROR calls in constant functions - //~| ERROR E0080 - //~| ERROR E0744 - sum += i; - } - sum -} - -#[allow(unused_variables)] -fn main() { - let a : [i32; f(X)]; -} diff --git a/src/test/compile-fail/consts/issue-55878.rs b/src/test/compile-fail/consts/issue-55878.rs deleted file mode 100644 index fee664caa17..00000000000 --- a/src/test/compile-fail/consts/issue-55878.rs +++ /dev/null @@ -1,7 +0,0 @@ -// normalize-stderr-64bit "18446744073709551615" -> "SIZE" -// normalize-stderr-32bit "4294967295" -> "SIZE" - -// error-pattern: are too big for the current architecture -fn main() { - println!("Size: {}", std::mem::size_of::<[u8; u64::MAX as usize]>()); -} diff --git a/src/test/compile-fail/crateresolve1.rs b/src/test/compile-fail/crateresolve1.rs deleted file mode 100644 index 453c8d97622..00000000000 --- a/src/test/compile-fail/crateresolve1.rs +++ /dev/null @@ -1,9 +0,0 @@ -// aux-build:crateresolve1-1.rs -// aux-build:crateresolve1-2.rs -// aux-build:crateresolve1-3.rs -// error-pattern:multiple matching crates for `crateresolve1` - -extern crate crateresolve1; - -fn main() { -} diff --git a/src/test/compile-fail/empty-extern-arg.rs b/src/test/compile-fail/empty-extern-arg.rs deleted file mode 100644 index d3cb5aaaeba..00000000000 --- a/src/test/compile-fail/empty-extern-arg.rs +++ /dev/null @@ -1,4 +0,0 @@ -// compile-flags: --extern std= -// error-pattern: extern location for std does not exist - -fn main() {} diff --git a/src/test/compile-fail/invalid-link-args.rs b/src/test/compile-fail/invalid-link-args.rs deleted file mode 100644 index 1e68b4f8b70..00000000000 --- a/src/test/compile-fail/invalid-link-args.rs +++ /dev/null @@ -1,12 +0,0 @@ -// 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/issue-10755.rs b/src/test/compile-fail/issue-10755.rs deleted file mode 100644 index 3c6fcddc0d2..00000000000 --- a/src/test/compile-fail/issue-10755.rs +++ /dev/null @@ -1,5 +0,0 @@ -// compile-flags: -C linker=llllll -C linker-flavor=ld -// error-pattern: linker `llllll` not found - -fn main() { -} diff --git a/src/test/compile-fail/issue-23595-1.rs b/src/test/compile-fail/issue-23595-1.rs deleted file mode 100644 index 483c205f42d..00000000000 --- a/src/test/compile-fail/issue-23595-1.rs +++ /dev/null @@ -1,14 +0,0 @@ -#![feature(associated_type_defaults)] - -use std::ops::Index; - -trait Hierarchy { - type Value; - type ChildKey; - type Children = dyn Index; - //~^ ERROR: the value of the associated types - - fn data(&self) -> Option<(Self::Value, Self::Children)>; -} - -fn main() {} diff --git a/src/test/compile-fail/issue-27675-unchecked-bounds.rs b/src/test/compile-fail/issue-27675-unchecked-bounds.rs deleted file mode 100644 index 1cfc2304531..00000000000 --- a/src/test/compile-fail/issue-27675-unchecked-bounds.rs +++ /dev/null @@ -1,19 +0,0 @@ -/// The compiler previously did not properly check the bound of `From` when it was used from type -/// of the dyn trait object (use in `copy_any` below). Since the associated type is under user -/// control in this usage, the compiler could be tricked to believe any type implemented any trait. -/// This would ICE, except for pure marker traits like `Copy`. It did not require providing an -/// instance of the dyn trait type, only name said type. -trait Setup { - type From: Copy; -} - -fn copy(from: &U::From) -> U::From { - *from -} - -pub fn copy_any(t: &T) -> T { - copy::>(t) - //~^ ERROR the trait bound `T: Copy` is not satisfied -} - -fn main() {} diff --git a/src/test/compile-fail/issue-43733-2.rs b/src/test/compile-fail/issue-43733-2.rs deleted file mode 100644 index 61dd3a923f2..00000000000 --- a/src/test/compile-fail/issue-43733-2.rs +++ /dev/null @@ -1,28 +0,0 @@ -#![feature(cfg_target_thread_local, thread_local_internals)] - -// On platforms *without* `#[thread_local]`, use -// a custom non-`Sync` type to fake the same error. -#[cfg(not(target_thread_local))] -struct Key { - _data: std::cell::UnsafeCell>, - _flag: std::cell::Cell<()>, -} - -#[cfg(not(target_thread_local))] -impl Key { - const fn new() -> Self { - Key { - _data: std::cell::UnsafeCell::new(None), - _flag: std::cell::Cell::new(()), - } - } -} - -#[cfg(target_thread_local)] -use std::thread::__FastLocalKeyInner as Key; - -static __KEY: Key<()> = Key::new(); -//~^ ERROR `UnsafeCell>` cannot be shared between threads -//~| ERROR cannot be shared between threads safely [E0277] - -fn main() {} diff --git a/src/test/compile-fail/issue-44415.rs b/src/test/compile-fail/issue-44415.rs deleted file mode 100644 index 71e764620d1..00000000000 --- a/src/test/compile-fail/issue-44415.rs +++ /dev/null @@ -1,11 +0,0 @@ -#![feature(core_intrinsics)] - -use std::intrinsics; - -struct Foo { - bytes: [u8; unsafe { intrinsics::size_of::() }], - //~^ ERROR cycle detected when simplifying constant for the type system - x: usize, -} - -fn main() {} diff --git a/src/test/compile-fail/issue-46209-private-enum-variant-reexport.rs b/src/test/compile-fail/issue-46209-private-enum-variant-reexport.rs deleted file mode 100644 index d54c9931479..00000000000 --- a/src/test/compile-fail/issue-46209-private-enum-variant-reexport.rs +++ /dev/null @@ -1,41 +0,0 @@ -#![feature(crate_visibility_modifier)] - -mod rank { - pub use self::Professor::*; - //~^ ERROR enum is private and its variants cannot be re-exported - pub use self::Lieutenant::{JuniorGrade, Full}; - //~^ ERROR variant `JuniorGrade` is private and cannot be re-exported - //~| ERROR variant `Full` is private and cannot be re-exported - pub use self::PettyOfficer::*; - //~^ ERROR enum is private and its variants cannot be re-exported - pub use self::Crewman::*; - //~^ ERROR enum is private and its variants cannot be re-exported - - enum Professor { - Adjunct, - Assistant, - Associate, - Full - } - - enum Lieutenant { - JuniorGrade, - Full, - } - - pub(in rank) enum PettyOfficer { - SecondClass, - FirstClass, - Chief, - MasterChief - } - - crate enum Crewman { - Recruit, - Apprentice, - Full - } - -} - -fn main() {} diff --git a/src/test/compile-fail/issue-52443.rs b/src/test/compile-fail/issue-52443.rs deleted file mode 100644 index 4519833b864..00000000000 --- a/src/test/compile-fail/issue-52443.rs +++ /dev/null @@ -1,14 +0,0 @@ -fn main() { - [(); & { loop { continue } } ]; //~ ERROR mismatched types - - [(); loop { break }]; //~ ERROR mismatched types - - [(); {while true {break}; 0}]; - //~^ WARN denote infinite loops with - - [(); { for _ in 0usize.. {}; 0}]; - //~^ ERROR `for` is not allowed in a `const` - //~| ERROR calls in constants are limited to constant functions - //~| ERROR mutable references are not allowed in constants - //~| ERROR calls in constants are limited to constant functions -} diff --git a/src/test/compile-fail/meta-expected-error-wrong-rev.rs b/src/test/compile-fail/meta-expected-error-wrong-rev.rs deleted file mode 100644 index 7e49434142b..00000000000 --- a/src/test/compile-fail/meta-expected-error-wrong-rev.rs +++ /dev/null @@ -1,16 +0,0 @@ -// ignore-compare-mode-nll - -// revisions: a -// should-fail - -// This is a "meta-test" of the compilertest framework itself. In -// particular, it includes the right error message, but the message -// targets the wrong revision, so we expect the execution to fail. -// See also `meta-expected-error-correct-rev.rs`. - -#[cfg(a)] -fn foo() { - let x: u32 = 22_usize; //[b]~ ERROR mismatched types -} - -fn main() { } diff --git a/src/test/compile-fail/must_use-in-stdlib-traits.rs b/src/test/compile-fail/must_use-in-stdlib-traits.rs deleted file mode 100644 index 70dddf61fb7..00000000000 --- a/src/test/compile-fail/must_use-in-stdlib-traits.rs +++ /dev/null @@ -1,47 +0,0 @@ -#![deny(unused_must_use)] -#![feature(arbitrary_self_types)] - -use std::iter::Iterator; -use std::future::Future; - -use std::task::{Context, Poll}; -use std::pin::Pin; -use std::unimplemented; - -struct MyFuture; - -impl Future for MyFuture { - type Output = u32; - - fn poll(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll { - Poll::Pending - } -} - -fn iterator() -> impl Iterator { - std::iter::empty::() -} - -fn future() -> impl Future { - MyFuture -} - -fn square_fn_once() -> impl FnOnce(u32) -> u32 { - |x| x * x -} - -fn square_fn_mut() -> impl FnMut(u32) -> u32 { - |x| x * x -} - -fn square_fn() -> impl Fn(u32) -> u32 { - |x| x * x -} - -fn main() { - iterator(); //~ ERROR unused implementer of `Iterator` that must be used - future(); //~ ERROR unused implementer of `Future` that must be used - square_fn_once(); //~ ERROR unused implementer of `FnOnce` that must be used - square_fn_mut(); //~ ERROR unused implementer of `FnMut` that must be used - square_fn(); //~ ERROR unused implementer of `Fn` that must be used -} diff --git a/src/test/compile-fail/not-utf8.bin b/src/test/compile-fail/not-utf8.bin deleted file mode 100644 index 4148e5b88fe..00000000000 Binary files a/src/test/compile-fail/not-utf8.bin and /dev/null differ diff --git a/src/test/compile-fail/not-utf8.rs b/src/test/compile-fail/not-utf8.rs deleted file mode 100644 index 1cb1fdcb8c9..00000000000 --- a/src/test/compile-fail/not-utf8.rs +++ /dev/null @@ -1,5 +0,0 @@ -// error-pattern: did not contain valid UTF-8 - -fn foo() { - include!("not-utf8.bin") -} diff --git a/src/test/compile-fail/panic-handler-missing.rs b/src/test/compile-fail/panic-handler-missing.rs deleted file mode 100644 index 1c380c99c18..00000000000 --- a/src/test/compile-fail/panic-handler-missing.rs +++ /dev/null @@ -1,8 +0,0 @@ -// error-pattern: `#[panic_handler]` function required, but not found - -#![feature(lang_items)] -#![no_main] -#![no_std] - -#[lang = "eh_personality"] -fn eh() {} diff --git a/src/test/compile-fail/panic-handler-twice.rs b/src/test/compile-fail/panic-handler-twice.rs deleted file mode 100644 index 0c5359b9bd8..00000000000 --- a/src/test/compile-fail/panic-handler-twice.rs +++ /dev/null @@ -1,18 +0,0 @@ -// aux-build:some-panic-impl.rs - -#![feature(lang_items)] -#![no_std] -#![no_main] - -extern crate some_panic_impl; - -use core::panic::PanicInfo; - -#[panic_handler] -fn panic(info: &PanicInfo) -> ! { - //~^ ERROR found duplicate lang item `panic_impl` - loop {} -} - -#[lang = "eh_personality"] -fn eh() {} diff --git a/src/test/compile-fail/runtime-depend-on-needs-runtime.rs b/src/test/compile-fail/runtime-depend-on-needs-runtime.rs deleted file mode 100644 index 866c5b2e34b..00000000000 --- a/src/test/compile-fail/runtime-depend-on-needs-runtime.rs +++ /dev/null @@ -1,7 +0,0 @@ -// aux-build:needs-panic-runtime.rs -// aux-build:depends.rs -// error-pattern:cannot depend on a crate that needs a panic runtime - -extern crate depends; - -fn main() {} diff --git a/src/test/compile-fail/runtime-depend-on-needs-runtime.stderr b/src/test/compile-fail/runtime-depend-on-needs-runtime.stderr deleted file mode 100644 index 27e27dda5ef..00000000000 --- a/src/test/compile-fail/runtime-depend-on-needs-runtime.stderr +++ /dev/null @@ -1,4 +0,0 @@ -error: the crate `depends` cannot depend on a crate that needs a panic runtime, but it depends on `needs_panic_runtime` - -error: aborting due to previous error - diff --git a/src/test/compile-fail/specialization/issue-50452.rs b/src/test/compile-fail/specialization/issue-50452.rs deleted file mode 100644 index 958f0eb2668..00000000000 --- a/src/test/compile-fail/specialization/issue-50452.rs +++ /dev/null @@ -1,22 +0,0 @@ -// compile-fail -#![feature(specialization)] -//~^ WARN the feature `specialization` is incomplete - -pub trait Foo { - fn foo(); -} - -impl Foo for i32 {} -impl Foo for i64 { - fn foo() {} - //~^ERROR `foo` specializes an item from a parent `impl` -} -impl Foo for T { - fn foo() {} -} - -fn main() { - i32::foo(); - i64::foo(); - u8::foo(); -} diff --git a/src/test/compile-fail/two-panic-runtimes.rs b/src/test/compile-fail/two-panic-runtimes.rs deleted file mode 100644 index 671d44564e6..00000000000 --- a/src/test/compile-fail/two-panic-runtimes.rs +++ /dev/null @@ -1,14 +0,0 @@ -// error-pattern:cannot link together two panic runtimes: panic_runtime_unwind and panic_runtime_unwind2 -// ignore-tidy-linelength -// aux-build:panic-runtime-unwind.rs -// aux-build:panic-runtime-unwind2.rs -// aux-build:panic-runtime-lang-items.rs - -#![no_std] -#![no_main] - -extern crate panic_runtime_unwind; -extern crate panic_runtime_unwind2; -extern crate panic_runtime_lang_items; - -fn main() {} diff --git a/src/test/compile-fail/unwind-tables-panic-required.rs b/src/test/compile-fail/unwind-tables-panic-required.rs deleted file mode 100644 index 314d9e778d5..00000000000 --- a/src/test/compile-fail/unwind-tables-panic-required.rs +++ /dev/null @@ -1,10 +0,0 @@ -// Tests that the compiler errors if the user tries to turn off unwind tables -// when they are required. -// -// compile-flags: -C panic=unwind -C force-unwind-tables=no -// ignore-tidy-linelength -// -// error-pattern: panic=unwind requires unwind tables, they cannot be disabled with `-C force-unwind-tables=no`. - -pub fn main() { -} diff --git a/src/test/compile-fail/unwind-tables-target-required.rs b/src/test/compile-fail/unwind-tables-target-required.rs deleted file mode 100644 index 14c17893764..00000000000 --- a/src/test/compile-fail/unwind-tables-target-required.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Tests that the compiler errors if the user tries to turn off unwind tables -// when they are required. -// -// only-x86_64-windows-msvc -// compile-flags: -C force-unwind-tables=no -// ignore-tidy-linelength -// -// error-pattern: target requires unwind tables, they cannot be disabled with `-C force-unwind-tables=no`. - -pub fn main() { -} diff --git a/src/test/compile-fail/want-abort-got-unwind.rs b/src/test/compile-fail/want-abort-got-unwind.rs deleted file mode 100644 index 30782e18229..00000000000 --- a/src/test/compile-fail/want-abort-got-unwind.rs +++ /dev/null @@ -1,7 +0,0 @@ -// error-pattern:is not compiled with this crate's panic strategy `abort` -// aux-build:panic-runtime-unwind.rs -// compile-flags:-C panic=abort - -extern crate panic_runtime_unwind; - -fn main() {} diff --git a/src/test/compile-fail/want-abort-got-unwind2.rs b/src/test/compile-fail/want-abort-got-unwind2.rs deleted file mode 100644 index 35d8d46b55e..00000000000 --- a/src/test/compile-fail/want-abort-got-unwind2.rs +++ /dev/null @@ -1,8 +0,0 @@ -// error-pattern:is not compiled with this crate's panic strategy `abort` -// aux-build:panic-runtime-unwind.rs -// aux-build:wants-panic-runtime-unwind.rs -// compile-flags:-C panic=abort - -extern crate wants_panic_runtime_unwind; - -fn main() {} diff --git a/src/test/compile-fail/weak-lang-item.rs b/src/test/compile-fail/weak-lang-item.rs deleted file mode 100644 index 3fa3822831b..00000000000 --- a/src/test/compile-fail/weak-lang-item.rs +++ /dev/null @@ -1,11 +0,0 @@ -// aux-build:weak-lang-items.rs -// error-pattern: `#[panic_handler]` function required, but not found -// error-pattern: language item required, but not found: `eh_personality` -// ignore-emscripten compiled with panic=abort, personality not required - -#![no_std] - -extern crate core; -extern crate weak_lang_items; - -fn main() {} diff --git a/src/test/run-make-fulldeps/many-crates-but-no-match/Makefile b/src/test/run-make-fulldeps/many-crates-but-no-match/Makefile index 03a797d95f9..e7268311b13 100644 --- a/src/test/run-make-fulldeps/many-crates-but-no-match/Makefile +++ b/src/test/run-make-fulldeps/many-crates-but-no-match/Makefile @@ -1,9 +1,8 @@ -include ../tools.mk -# Modelled after compile-fail/changing-crates test, but this one puts +# Modelled after ui/changing-crates.rs test, but this one puts # more than one (mismatching) candidate crate into the search path, -# which did not appear directly expressible in compile-fail/aux-build -# infrastructure. +# which did not appear directly expressible in UI testing infrastructure. # # Note that we move the built libraries into target direcrtories rather than # use the `--out-dir` option because the `../tools.mk` file already bakes a @@ -33,4 +32,4 @@ all: 'crate `crateA`:' \ 'crate `crateB`:' \ < $(LOG) - # the 'crate `crateA`' will match two entries. \ No newline at end of file + # the 'crate `crateA`' will match two entries. diff --git a/src/test/run-make-fulldeps/type-mismatch-same-crate-name/crateC.rs b/src/test/run-make-fulldeps/type-mismatch-same-crate-name/crateC.rs index 12898aa5c74..71b38a9f8ca 100644 --- a/src/test/run-make-fulldeps/type-mismatch-same-crate-name/crateC.rs +++ b/src/test/run-make-fulldeps/type-mismatch-same-crate-name/crateC.rs @@ -5,7 +5,7 @@ // causing a type mismatch. // The test is nearly the same as the one in -// compile-fail/type-mismatch-same-crate-name.rs +// ui/type/type-mismatch-same-crate-name.rs // but deals with the case where one of the crates // is only introduced as an indirect dependency. // and the type is accessed via a re-export. diff --git a/src/test/ui-fulldeps/dropck-tarena-cycle-checked.rs b/src/test/ui-fulldeps/dropck-tarena-cycle-checked.rs index fabcd727482..cc97971a0dd 100644 --- a/src/test/ui-fulldeps/dropck-tarena-cycle-checked.rs +++ b/src/test/ui-fulldeps/dropck-tarena-cycle-checked.rs @@ -1,8 +1,8 @@ // Reject mixing cyclic structure and Drop when using TypedArena. // -// (Compare against compile-fail/dropck_vec_cycle_checked.rs) +// (Compare against dropck-vec-cycle-checked.rs) // -// (Also compare against compile-fail/dropck_tarena_unsound_drop.rs, +// (Also compare against ui-fulldeps/dropck-tarena-unsound-drop.rs, // which is a reduction of this code to more directly show the reason // for the error message we see here.) diff --git a/src/test/ui-fulldeps/dropck_tarena_sound_drop.rs b/src/test/ui-fulldeps/dropck_tarena_sound_drop.rs index c5b9efee8e7..187f9a24a90 100644 --- a/src/test/ui-fulldeps/dropck_tarena_sound_drop.rs +++ b/src/test/ui-fulldeps/dropck_tarena_sound_drop.rs @@ -5,7 +5,7 @@ // methods might access borrowed data, as long as the borrowed data // has lifetime that strictly outlives the arena itself. // -// Compare against compile-fail/dropck_tarena_unsound_drop.rs, which +// Compare against ui-fulldeps/dropck-tarena-unsound-drop.rs, which // shows a similar setup, but restricts `f` so that the struct `C<'a>` // is force-fed a lifetime equal to that of the borrowed arena. diff --git a/src/test/ui/array-slice-vec/copy-out-of-array-1.rs b/src/test/ui/array-slice-vec/copy-out-of-array-1.rs index e64985ae3f6..c6d311148d0 100644 --- a/src/test/ui/array-slice-vec/copy-out-of-array-1.rs +++ b/src/test/ui/array-slice-vec/copy-out-of-array-1.rs @@ -2,7 +2,7 @@ // Ensure that we can copy out of a fixed-size array. // -// (Compare with compile-fail/move-out-of-array-1.rs) +// (Compare with ui/moves/move-out-of-array-1.rs) #[derive(Copy, Clone)] struct C { _x: u8 } diff --git a/src/test/ui/associated-types/associated-types-projection-to-unrelated-trait.rs b/src/test/ui/associated-types/associated-types-projection-to-unrelated-trait.rs index 5f06a829600..3b8c8c019e5 100644 --- a/src/test/ui/associated-types/associated-types-projection-to-unrelated-trait.rs +++ b/src/test/ui/associated-types/associated-types-projection-to-unrelated-trait.rs @@ -3,7 +3,7 @@ // the trait definition if there is no default method and for every impl, // `Self` does implement `Get`. // -// See also compile-fail tests associated-types-no-suitable-supertrait +// See also tests associated-types-no-suitable-supertrait // and associated-types-no-suitable-supertrait-2, which show how small // variants of the code below can fail. diff --git a/src/test/ui/associated-types/issue-23595-1.rs b/src/test/ui/associated-types/issue-23595-1.rs new file mode 100644 index 00000000000..483c205f42d --- /dev/null +++ b/src/test/ui/associated-types/issue-23595-1.rs @@ -0,0 +1,14 @@ +#![feature(associated_type_defaults)] + +use std::ops::Index; + +trait Hierarchy { + type Value; + type ChildKey; + type Children = dyn Index; + //~^ ERROR: the value of the associated types + + fn data(&self) -> Option<(Self::Value, Self::Children)>; +} + +fn main() {} diff --git a/src/test/ui/associated-types/issue-23595-1.stderr b/src/test/ui/associated-types/issue-23595-1.stderr new file mode 100644 index 00000000000..bb455684ee3 --- /dev/null +++ b/src/test/ui/associated-types/issue-23595-1.stderr @@ -0,0 +1,16 @@ +error[E0191]: the value of the associated types `ChildKey` (from trait `Hierarchy`), `Children` (from trait `Hierarchy`), `Value` (from trait `Hierarchy`) must be specified + --> $DIR/issue-23595-1.rs:8:58 + | +LL | type Value; + | ----------- `Value` defined here +LL | type ChildKey; + | -------------- `ChildKey` defined here +LL | type Children = dyn Index; + | -----------------------------------------------------^^^^^^^^^-- + | | | + | | help: specify the associated types: `Hierarchy` + | `Children` defined here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0191`. diff --git a/src/test/ui/associated-types/issue-27675-unchecked-bounds.rs b/src/test/ui/associated-types/issue-27675-unchecked-bounds.rs new file mode 100644 index 00000000000..1cfc2304531 --- /dev/null +++ b/src/test/ui/associated-types/issue-27675-unchecked-bounds.rs @@ -0,0 +1,19 @@ +/// The compiler previously did not properly check the bound of `From` when it was used from type +/// of the dyn trait object (use in `copy_any` below). Since the associated type is under user +/// control in this usage, the compiler could be tricked to believe any type implemented any trait. +/// This would ICE, except for pure marker traits like `Copy`. It did not require providing an +/// instance of the dyn trait type, only name said type. +trait Setup { + type From: Copy; +} + +fn copy(from: &U::From) -> U::From { + *from +} + +pub fn copy_any(t: &T) -> T { + copy::>(t) + //~^ ERROR the trait bound `T: Copy` is not satisfied +} + +fn main() {} diff --git a/src/test/ui/associated-types/issue-27675-unchecked-bounds.stderr b/src/test/ui/associated-types/issue-27675-unchecked-bounds.stderr new file mode 100644 index 00000000000..02396bd00a5 --- /dev/null +++ b/src/test/ui/associated-types/issue-27675-unchecked-bounds.stderr @@ -0,0 +1,17 @@ +error[E0277]: the trait bound `T: Copy` is not satisfied + --> $DIR/issue-27675-unchecked-bounds.rs:15:31 + | +LL | fn copy(from: &U::From) -> U::From { + | ----- required by this bound in `copy` +... +LL | copy::>(t) + | ^ the trait `Copy` is not implemented for `T` + | +help: consider restricting type parameter `T` + | +LL | pub fn copy_any(t: &T) -> T { + | ^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/closures/coerce-unsafe-closure-to-unsafe-fn-ptr.rs b/src/test/ui/closures/coerce-unsafe-closure-to-unsafe-fn-ptr.rs new file mode 100644 index 00000000000..36777693fab --- /dev/null +++ b/src/test/ui/closures/coerce-unsafe-closure-to-unsafe-fn-ptr.rs @@ -0,0 +1,5 @@ +fn main() { + let _: unsafe fn() = || { ::std::pin::Pin::new_unchecked(&0_u8); }; + //~^ ERROR E0133 + let _: unsafe fn() = || unsafe { ::std::pin::Pin::new_unchecked(&0_u8); }; // OK +} diff --git a/src/test/ui/closures/coerce-unsafe-closure-to-unsafe-fn-ptr.stderr b/src/test/ui/closures/coerce-unsafe-closure-to-unsafe-fn-ptr.stderr new file mode 100644 index 00000000000..a1fb1c02e46 --- /dev/null +++ b/src/test/ui/closures/coerce-unsafe-closure-to-unsafe-fn-ptr.stderr @@ -0,0 +1,11 @@ +error[E0133]: call to unsafe function is unsafe and requires unsafe function or block + --> $DIR/coerce-unsafe-closure-to-unsafe-fn-ptr.rs:2:31 + | +LL | let _: unsafe fn() = || { ::std::pin::Pin::new_unchecked(&0_u8); }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function + | + = note: consult the function's documentation for information on how to avoid undefined behavior + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0133`. diff --git a/src/test/ui/closures/coerce-unsafe-to-closure.rs b/src/test/ui/closures/coerce-unsafe-to-closure.rs new file mode 100644 index 00000000000..78bdd36f9cc --- /dev/null +++ b/src/test/ui/closures/coerce-unsafe-to-closure.rs @@ -0,0 +1,4 @@ +fn main() { + let x: Option<&[u8]> = Some("foo").map(std::mem::transmute); + //~^ ERROR E0277 +} diff --git a/src/test/ui/closures/coerce-unsafe-to-closure.stderr b/src/test/ui/closures/coerce-unsafe-to-closure.stderr new file mode 100644 index 00000000000..ab035d03b05 --- /dev/null +++ b/src/test/ui/closures/coerce-unsafe-to-closure.stderr @@ -0,0 +1,11 @@ +error[E0277]: expected a `FnOnce<(&str,)>` closure, found `unsafe extern "rust-intrinsic" fn(_) -> _ {transmute::<_, _>}` + --> $DIR/coerce-unsafe-to-closure.rs:2:44 + | +LL | let x: Option<&[u8]> = Some("foo").map(std::mem::transmute); + | ^^^^^^^^^^^^^^^^^^^ expected an `FnOnce<(&str,)>` closure, found `unsafe extern "rust-intrinsic" fn(_) -> _ {transmute::<_, _>}` + | + = help: the trait `FnOnce<(&str,)>` is not implemented for `unsafe extern "rust-intrinsic" fn(_) -> _ {transmute::<_, _>}` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/consts/const-fn-error.rs b/src/test/ui/consts/const-fn-error.rs new file mode 100644 index 00000000000..68a4d414ff3 --- /dev/null +++ b/src/test/ui/consts/const-fn-error.rs @@ -0,0 +1,21 @@ +#![feature(const_fn)] + +const X : usize = 2; + +const fn f(x: usize) -> usize { + let mut sum = 0; + for i in 0..x { + //~^ ERROR mutable references + //~| ERROR calls in constant functions + //~| ERROR calls in constant functions + //~| ERROR E0080 + //~| ERROR E0744 + sum += i; + } + sum +} + +#[allow(unused_variables)] +fn main() { + let a : [i32; f(X)]; +} diff --git a/src/test/ui/consts/const-fn-error.stderr b/src/test/ui/consts/const-fn-error.stderr new file mode 100644 index 00000000000..86b1eebcb2c --- /dev/null +++ b/src/test/ui/consts/const-fn-error.stderr @@ -0,0 +1,49 @@ +error[E0744]: `for` is not allowed in a `const fn` + --> $DIR/const-fn-error.rs:7:5 + | +LL | / for i in 0..x { +LL | | +LL | | +LL | | +... | +LL | | sum += i; +LL | | } + | |_____^ + +error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants + --> $DIR/const-fn-error.rs:7:14 + | +LL | for i in 0..x { + | ^^^^ + +error[E0658]: mutable references are not allowed in constant functions + --> $DIR/const-fn-error.rs:7:14 + | +LL | for i in 0..x { + | ^^^^ + | + = note: see issue #57349 for more information + = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable + +error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants + --> $DIR/const-fn-error.rs:7:14 + | +LL | for i in 0..x { + | ^^^^ + +error[E0080]: evaluation of constant value failed + --> $DIR/const-fn-error.rs:7:14 + | +LL | for i in 0..x { + | ^^^^ + | | + | calling non-const function ` as IntoIterator>::into_iter` + | inside `f` at $DIR/const-fn-error.rs:7:14 +... +LL | let a : [i32; f(X)]; + | ---- inside `main::{constant#0}` at $DIR/const-fn-error.rs:20:19 + +error: aborting due to 5 previous errors + +Some errors have detailed explanations: E0015, E0080, E0658, E0744. +For more information about an error, try `rustc --explain E0015`. diff --git a/src/test/ui/consts/issue-44415.rs b/src/test/ui/consts/issue-44415.rs new file mode 100644 index 00000000000..71e764620d1 --- /dev/null +++ b/src/test/ui/consts/issue-44415.rs @@ -0,0 +1,11 @@ +#![feature(core_intrinsics)] + +use std::intrinsics; + +struct Foo { + bytes: [u8; unsafe { intrinsics::size_of::() }], + //~^ ERROR cycle detected when simplifying constant for the type system + x: usize, +} + +fn main() {} diff --git a/src/test/ui/consts/issue-44415.stderr b/src/test/ui/consts/issue-44415.stderr new file mode 100644 index 00000000000..38841e99a72 --- /dev/null +++ b/src/test/ui/consts/issue-44415.stderr @@ -0,0 +1,28 @@ +error[E0391]: cycle detected when simplifying constant for the type system `Foo::bytes::{constant#0}` + --> $DIR/issue-44415.rs:6:17 + | +LL | bytes: [u8; unsafe { intrinsics::size_of::() }], + | ^^^^^^ + | +note: ...which requires simplifying constant for the type system `Foo::bytes::{constant#0}`... + --> $DIR/issue-44415.rs:6:17 + | +LL | bytes: [u8; unsafe { intrinsics::size_of::() }], + | ^^^^^^ +note: ...which requires const-evaluating + checking `Foo::bytes::{constant#0}`... + --> $DIR/issue-44415.rs:6:17 + | +LL | bytes: [u8; unsafe { intrinsics::size_of::() }], + | ^^^^^^ + = note: ...which requires computing layout of `Foo`... + = note: ...which requires normalizing `[u8; _]`... + = note: ...which again requires simplifying constant for the type system `Foo::bytes::{constant#0}`, completing the cycle +note: cycle used when checking that `Foo` is well-formed + --> $DIR/issue-44415.rs:5:1 + | +LL | struct Foo { + | ^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0391`. diff --git a/src/test/ui/consts/issue-55878.rs b/src/test/ui/consts/issue-55878.rs new file mode 100644 index 00000000000..c1c54646db8 --- /dev/null +++ b/src/test/ui/consts/issue-55878.rs @@ -0,0 +1,8 @@ +// build-fail +// normalize-stderr-64bit "18446744073709551615" -> "SIZE" +// normalize-stderr-32bit "4294967295" -> "SIZE" + +// error-pattern: are too big for the current architecture +fn main() { + println!("Size: {}", std::mem::size_of::<[u8; u64::MAX as usize]>()); +} diff --git a/src/test/ui/consts/issue-55878.stderr b/src/test/ui/consts/issue-55878.stderr new file mode 100644 index 00000000000..924910e9cb6 --- /dev/null +++ b/src/test/ui/consts/issue-55878.stderr @@ -0,0 +1,25 @@ +error[E0080]: values of the type `[u8; SIZE]` are too big for the current architecture + --> $SRC_DIR/core/src/mem/mod.rs:LL:COL + | +LL | intrinsics::size_of::() + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | inside `std::mem::size_of::<[u8; SIZE]>` at $SRC_DIR/core/src/mem/mod.rs:LL:COL + | inside `main` at $DIR/issue-55878.rs:7:26 + | + ::: $DIR/issue-55878.rs:7:26 + | +LL | println!("Size: {}", std::mem::size_of::<[u8; u64::MAX as usize]>()); + | ---------------------------------------------- + +error: erroneous constant used + --> $DIR/issue-55878.rs:7:26 + | +LL | println!("Size: {}", std::mem::size_of::<[u8; u64::MAX as usize]>()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors + | + = note: `#[deny(const_err)]` on by default + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/crate-loading/auxiliary/crateresolve1-1.rs b/src/test/ui/crate-loading/auxiliary/crateresolve1-1.rs new file mode 100644 index 00000000000..a00a19e46d5 --- /dev/null +++ b/src/test/ui/crate-loading/auxiliary/crateresolve1-1.rs @@ -0,0 +1,5 @@ +// compile-flags:-C extra-filename=-1 +#![crate_name = "crateresolve1"] +#![crate_type = "lib"] + +pub fn f() -> isize { 10 } diff --git a/src/test/ui/crate-loading/auxiliary/crateresolve1-2.rs b/src/test/ui/crate-loading/auxiliary/crateresolve1-2.rs new file mode 100644 index 00000000000..71cc0a12ea3 --- /dev/null +++ b/src/test/ui/crate-loading/auxiliary/crateresolve1-2.rs @@ -0,0 +1,5 @@ +// compile-flags:-C extra-filename=-2 +#![crate_name = "crateresolve1"] +#![crate_type = "lib"] + +pub fn f() -> isize { 20 } diff --git a/src/test/ui/crate-loading/auxiliary/crateresolve1-3.rs b/src/test/ui/crate-loading/auxiliary/crateresolve1-3.rs new file mode 100644 index 00000000000..921687d4c3b --- /dev/null +++ b/src/test/ui/crate-loading/auxiliary/crateresolve1-3.rs @@ -0,0 +1,5 @@ +// compile-flags:-C extra-filename=-3 +#![crate_name = "crateresolve1"] +#![crate_type = "lib"] + +pub fn f() -> isize { 30 } diff --git a/src/test/ui/crate-loading/crateresolve1.rs b/src/test/ui/crate-loading/crateresolve1.rs new file mode 100644 index 00000000000..49e47dacc3d --- /dev/null +++ b/src/test/ui/crate-loading/crateresolve1.rs @@ -0,0 +1,10 @@ +// dont-check-compiler-stderr +// aux-build:crateresolve1-1.rs +// aux-build:crateresolve1-2.rs +// aux-build:crateresolve1-3.rs +// error-pattern:multiple matching crates for `crateresolve1` + +extern crate crateresolve1; + +fn main() { +} diff --git a/src/test/ui/dropck/dropck_trait_cycle_checked.rs b/src/test/ui/dropck/dropck_trait_cycle_checked.rs index bea77dc9f5c..be6ec3e4ed1 100644 --- a/src/test/ui/dropck/dropck_trait_cycle_checked.rs +++ b/src/test/ui/dropck/dropck_trait_cycle_checked.rs @@ -1,7 +1,7 @@ // Reject mixing cyclic structure and Drop when using trait // objects to hide the cross-references. // -// (Compare against compile-fail/dropck_vec_cycle_checked.rs) +// (Compare against ui/span/dropck_vec_cycle_checked.rs) use std::cell::Cell; use id::Id; diff --git a/src/test/ui/extern-flag/empty-extern-arg.rs b/src/test/ui/extern-flag/empty-extern-arg.rs new file mode 100644 index 00000000000..d3cb5aaaeba --- /dev/null +++ b/src/test/ui/extern-flag/empty-extern-arg.rs @@ -0,0 +1,4 @@ +// compile-flags: --extern std= +// error-pattern: extern location for std does not exist + +fn main() {} diff --git a/src/test/ui/extern-flag/empty-extern-arg.stderr b/src/test/ui/extern-flag/empty-extern-arg.stderr new file mode 100644 index 00000000000..199c4fb616b --- /dev/null +++ b/src/test/ui/extern-flag/empty-extern-arg.stderr @@ -0,0 +1,4 @@ +error: extern location for std does not exist: + +error: aborting due to previous error + diff --git a/src/test/ui/fsu-moves-and-copies.rs b/src/test/ui/fsu-moves-and-copies.rs index c41bcc73fa5..6a0b4ed17b9 100644 --- a/src/test/ui/fsu-moves-and-copies.rs +++ b/src/test/ui/fsu-moves-and-copies.rs @@ -36,7 +36,7 @@ impl Drop for DropMoveFoo { fn drop(&mut self) { } } fn test0() { // just copy implicitly copyable fields from `f`, no moves // (and thus it is okay that these are Drop; compare against - // compile-fail test: borrowck-struct-update-with-dtor.rs). + // test ui/borrowck/borrowck-struct-update-with-dtor.rs). // Case 1: Nocopyable let f = DropNoFoo::new(1, 2); diff --git a/src/test/ui/functions-closures/closure-expected-type/README.md b/src/test/ui/functions-closures/closure-expected-type/README.md index fd493e1ff37..11d2c9b7fb7 100644 --- a/src/test/ui/functions-closures/closure-expected-type/README.md +++ b/src/test/ui/functions-closures/closure-expected-type/README.md @@ -5,4 +5,4 @@ inputs. This investigation was kicked off by #38714, which revealed some pretty deep flaws in the ad-hoc way that we were doing things before. -See also `src/test/compile-fail/closure-expected-type`. +See also `src/test/ui/closure-expected-type`. diff --git a/src/test/ui/issues/issue-26996.rs b/src/test/ui/issues/issue-26996.rs index 04382be27d7..84037b72a27 100644 --- a/src/test/ui/issues/issue-26996.rs +++ b/src/test/ui/issues/issue-26996.rs @@ -1,6 +1,6 @@ // run-pass -// This test is bogus (i.e., should be compile-fail) during the period +// This test is bogus (i.e., should be check-fail) during the period // where #54986 is implemented and #54987 is *not* implemented. For // now: just ignore it // diff --git a/src/test/ui/issues/issue-27021.rs b/src/test/ui/issues/issue-27021.rs index 30551375450..ef3b114a5fa 100644 --- a/src/test/ui/issues/issue-27021.rs +++ b/src/test/ui/issues/issue-27021.rs @@ -1,6 +1,6 @@ // run-pass -// This test is bogus (i.e., should be compile-fail) during the period +// This test is bogus (i.e., should be check-fail) during the period // where #54986 is implemented and #54987 is *not* implemented. For // now: just ignore it // diff --git a/src/test/ui/issues/issue-28498-ugeh-with-lifetime-param.rs b/src/test/ui/issues/issue-28498-ugeh-with-lifetime-param.rs index aea9fde5309..43c0bfb26cd 100644 --- a/src/test/ui/issues/issue-28498-ugeh-with-lifetime-param.rs +++ b/src/test/ui/issues/issue-28498-ugeh-with-lifetime-param.rs @@ -3,7 +3,7 @@ // Demonstrate the use of the unguarded escape hatch with a lifetime param // to assert that destructor will not access any dead data. // -// Compare with compile-fail/issue28498-reject-lifetime-param.rs +// Compare with ui/span/issue28498-reject-lifetime-param.rs #![feature(dropck_eyepatch)] diff --git a/src/test/ui/issues/issue-28498-ugeh-with-passed-to-fn.rs b/src/test/ui/issues/issue-28498-ugeh-with-passed-to-fn.rs index 91ef5a7c98d..23fd86a093b 100644 --- a/src/test/ui/issues/issue-28498-ugeh-with-passed-to-fn.rs +++ b/src/test/ui/issues/issue-28498-ugeh-with-passed-to-fn.rs @@ -3,7 +3,7 @@ // Demonstrate the use of the unguarded escape hatch with a type param in negative position // to assert that destructor will not access any dead data. // -// Compare with compile-fail/issue28498-reject-lifetime-param.rs +// Compare with ui/span/issue28498-reject-lifetime-param.rs // Demonstrate that a type param in negative position causes dropck to reject code // that might indirectly access previously dropped value. diff --git a/src/test/ui/issues/issue-28498-ugeh-with-trait-bound.rs b/src/test/ui/issues/issue-28498-ugeh-with-trait-bound.rs index 808f3b6e81e..61d11cf3834 100644 --- a/src/test/ui/issues/issue-28498-ugeh-with-trait-bound.rs +++ b/src/test/ui/issues/issue-28498-ugeh-with-trait-bound.rs @@ -3,7 +3,7 @@ // Demonstrate the use of the unguarded escape hatch with a trait bound // to assert that destructor will not access any dead data. // -// Compare with compile-fail/issue28498-reject-trait-bound.rs +// Compare with ui/span/issue28498-reject-trait-bound.rs #![feature(dropck_eyepatch)] diff --git a/src/test/ui/issues/issue-43733.rs b/src/test/ui/issues/issue-43733.rs deleted file mode 100644 index a602d7667c4..00000000000 --- a/src/test/ui/issues/issue-43733.rs +++ /dev/null @@ -1,31 +0,0 @@ -#![feature(const_fn)] -#![feature(thread_local)] -#![feature(cfg_target_thread_local, thread_local_internals)] - -type Foo = std::cell::RefCell; - -#[cfg(target_thread_local)] -#[thread_local] -static __KEY: std::thread::__FastLocalKeyInner = - std::thread::__FastLocalKeyInner::new(); - -#[cfg(not(target_thread_local))] -static __KEY: std::thread::__OsLocalKeyInner = - std::thread::__OsLocalKeyInner::new(); - -fn __getit() -> std::option::Option<&'static Foo> -{ - __KEY.get(Default::default) //~ ERROR call to unsafe function is unsafe -} - -static FOO: std::thread::LocalKey = - std::thread::LocalKey::new(__getit); -//~^ ERROR call to unsafe function is unsafe - -fn main() { - FOO.with(|foo| println!("{}", foo.borrow())); - std::thread::spawn(|| { - FOO.with(|foo| *foo.borrow_mut() += "foo"); - }).join().unwrap(); - FOO.with(|foo| println!("{}", foo.borrow())); -} diff --git a/src/test/ui/issues/issue-43733.stderr b/src/test/ui/issues/issue-43733.stderr deleted file mode 100644 index ee6a3b065d6..00000000000 --- a/src/test/ui/issues/issue-43733.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0133]: call to unsafe function is unsafe and requires unsafe function or block - --> $DIR/issue-43733.rs:18:5 - | -LL | __KEY.get(Default::default) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function - | - = note: consult the function's documentation for information on how to avoid undefined behavior - -error[E0133]: call to unsafe function is unsafe and requires unsafe function or block - --> $DIR/issue-43733.rs:22:5 - | -LL | std::thread::LocalKey::new(__getit); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function - | - = note: consult the function's documentation for information on how to avoid undefined behavior - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0133`. diff --git a/src/test/ui/issues/issue-49298.rs b/src/test/ui/issues/issue-49298.rs index 697a160b4ec..e3ffa8e7c6e 100644 --- a/src/test/ui/issues/issue-49298.rs +++ b/src/test/ui/issues/issue-49298.rs @@ -2,7 +2,7 @@ #![feature(test)] #![allow(unused_mut)] // under NLL we get warning about `x` below: rust-lang/rust#54499 -// This test is bogus (i.e., should be compile-fail) during the period +// This test is bogus (i.e., should be check-fail) during the period // where #54986 is implemented and #54987 is *not* implemented. For // now: just ignore it // diff --git a/src/test/ui/linkage-attr/invalid-link-args.rs b/src/test/ui/linkage-attr/invalid-link-args.rs new file mode 100644 index 00000000000..5eb1c637f09 --- /dev/null +++ b/src/test/ui/linkage-attr/invalid-link-args.rs @@ -0,0 +1,14 @@ +// build-fail +// dont-check-compiler-stderr +// 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/ui/linkage-attr/issue-10755.rs b/src/test/ui/linkage-attr/issue-10755.rs new file mode 100644 index 00000000000..5ce69bceed3 --- /dev/null +++ b/src/test/ui/linkage-attr/issue-10755.rs @@ -0,0 +1,7 @@ +// build-fail +// dont-check-compiler-stderr +// compile-flags: -C linker=llllll -C linker-flavor=ld +// error-pattern: linker `llllll` not found + +fn main() { +} diff --git a/src/test/ui/lint/must_use-in-stdlib-traits.rs b/src/test/ui/lint/must_use-in-stdlib-traits.rs new file mode 100644 index 00000000000..70dddf61fb7 --- /dev/null +++ b/src/test/ui/lint/must_use-in-stdlib-traits.rs @@ -0,0 +1,47 @@ +#![deny(unused_must_use)] +#![feature(arbitrary_self_types)] + +use std::iter::Iterator; +use std::future::Future; + +use std::task::{Context, Poll}; +use std::pin::Pin; +use std::unimplemented; + +struct MyFuture; + +impl Future for MyFuture { + type Output = u32; + + fn poll(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll { + Poll::Pending + } +} + +fn iterator() -> impl Iterator { + std::iter::empty::() +} + +fn future() -> impl Future { + MyFuture +} + +fn square_fn_once() -> impl FnOnce(u32) -> u32 { + |x| x * x +} + +fn square_fn_mut() -> impl FnMut(u32) -> u32 { + |x| x * x +} + +fn square_fn() -> impl Fn(u32) -> u32 { + |x| x * x +} + +fn main() { + iterator(); //~ ERROR unused implementer of `Iterator` that must be used + future(); //~ ERROR unused implementer of `Future` that must be used + square_fn_once(); //~ ERROR unused implementer of `FnOnce` that must be used + square_fn_mut(); //~ ERROR unused implementer of `FnMut` that must be used + square_fn(); //~ ERROR unused implementer of `Fn` that must be used +} diff --git a/src/test/ui/lint/must_use-in-stdlib-traits.stderr b/src/test/ui/lint/must_use-in-stdlib-traits.stderr new file mode 100644 index 00000000000..76978d29dc8 --- /dev/null +++ b/src/test/ui/lint/must_use-in-stdlib-traits.stderr @@ -0,0 +1,47 @@ +error: unused implementer of `Iterator` that must be used + --> $DIR/must_use-in-stdlib-traits.rs:42:4 + | +LL | iterator(); + | ^^^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/must_use-in-stdlib-traits.rs:1:9 + | +LL | #![deny(unused_must_use)] + | ^^^^^^^^^^^^^^^ + = note: iterators are lazy and do nothing unless consumed + +error: unused implementer of `Future` that must be used + --> $DIR/must_use-in-stdlib-traits.rs:43:4 + | +LL | future(); + | ^^^^^^^^^ + | + = note: futures do nothing unless you `.await` or poll them + +error: unused implementer of `FnOnce` that must be used + --> $DIR/must_use-in-stdlib-traits.rs:44:4 + | +LL | square_fn_once(); + | ^^^^^^^^^^^^^^^^^ + | + = note: closures are lazy and do nothing unless called + +error: unused implementer of `FnMut` that must be used + --> $DIR/must_use-in-stdlib-traits.rs:45:4 + | +LL | square_fn_mut(); + | ^^^^^^^^^^^^^^^^ + | + = note: closures are lazy and do nothing unless called + +error: unused implementer of `Fn` that must be used + --> $DIR/must_use-in-stdlib-traits.rs:46:4 + | +LL | square_fn(); + | ^^^^^^^^^^^^ + | + = note: closures are lazy and do nothing unless called + +error: aborting due to 5 previous errors + diff --git a/src/test/ui/llvm-asm/asm-src-loc-codegen-units.rs b/src/test/ui/llvm-asm/asm-src-loc-codegen-units.rs new file mode 100644 index 00000000000..387822d00f6 --- /dev/null +++ b/src/test/ui/llvm-asm/asm-src-loc-codegen-units.rs @@ -0,0 +1,12 @@ +// build-fail +// dont-check-compiler-stderr +// compile-flags: -C codegen-units=2 +// ignore-emscripten + +#![feature(llvm_asm)] + +fn main() { + unsafe { + llvm_asm!("nowayisthisavalidinstruction"); //~ ERROR instruction + } +} diff --git a/src/test/ui/llvm-asm/asm-src-loc.rs b/src/test/ui/llvm-asm/asm-src-loc.rs new file mode 100644 index 00000000000..063066df11c --- /dev/null +++ b/src/test/ui/llvm-asm/asm-src-loc.rs @@ -0,0 +1,11 @@ +// build-fail +// dont-check-compiler-stderr +// ignore-emscripten + +#![feature(llvm_asm)] + +fn main() { + unsafe { + llvm_asm!("nowayisthisavalidinstruction"); //~ ERROR instruction + } +} diff --git a/src/test/ui/macros/macro-comma-behavior-rpass.rs b/src/test/ui/macros/macro-comma-behavior-rpass.rs index e5e656de6fa..c46274d59b6 100644 --- a/src/test/ui/macros/macro-comma-behavior-rpass.rs +++ b/src/test/ui/macros/macro-comma-behavior-rpass.rs @@ -8,7 +8,7 @@ // to it being e.g., a place where the addition of an argument // causes it to go down a code path with subtly different behavior). // -// There is a companion test in compile-fail. +// There is a companion failing test. // compile-flags: --test -C debug_assertions=yes // revisions: std core @@ -68,26 +68,26 @@ fn to_format_or_not_to_format() { assert!(true, "{}",); - // assert_eq!(1, 1, "{}",); // see compile-fail - // assert_ne!(1, 2, "{}",); // see compile-fail + // assert_eq!(1, 1, "{}",); // see check-fail + // assert_ne!(1, 2, "{}",); // see check-fail debug_assert!(true, "{}",); - // debug_assert_eq!(1, 1, "{}",); // see compile-fail - // debug_assert_ne!(1, 2, "{}",); // see compile-fail - // eprint!("{}",); // see compile-fail - // eprintln!("{}",); // see compile-fail - // format!("{}",); // see compile-fail - // format_args!("{}",); // see compile-fail + // debug_assert_eq!(1, 1, "{}",); // see check-fail + // debug_assert_ne!(1, 2, "{}",); // see check-fail + // eprint!("{}",); // see check-fail + // eprintln!("{}",); // see check-fail + // format!("{}",); // see check-fail + // format_args!("{}",); // see check-fail if falsum() { panic!("{}",); } - // print!("{}",); // see compile-fail - // println!("{}",); // see compile-fail - // unimplemented!("{}",); // see compile-fail + // print!("{}",); // see check-fail + // println!("{}",); // see check-fail + // unimplemented!("{}",); // see check-fail if falsum() { unreachable!("{}",); } - // write!(&mut stdout, "{}",); // see compile-fail - // writeln!(&mut stdout, "{}",); // see compile-fail + // write!(&mut stdout, "{}",); // see check-fail + // writeln!(&mut stdout, "{}",); // see check-fail } diff --git a/src/test/ui/macros/macro-comma-behavior.core.stderr b/src/test/ui/macros/macro-comma-behavior.core.stderr index dd0cac659fd..ac15e9fa8ea 100644 --- a/src/test/ui/macros/macro-comma-behavior.core.stderr +++ b/src/test/ui/macros/macro-comma-behavior.core.stderr @@ -23,22 +23,28 @@ LL | debug_assert_ne!(1, 2, "{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:54:19 + --> $DIR/macro-comma-behavior.rs:52:19 | LL | format_args!("{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:72:21 + --> $DIR/macro-comma-behavior.rs:68:21 | LL | unimplemented!("{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:81:24 + --> $DIR/macro-comma-behavior.rs:77:24 | LL | write!(f, "{}",)?; | ^^ -error: aborting due to 7 previous errors +error: 1 positional argument in format string, but no arguments were given + --> $DIR/macro-comma-behavior.rs:81:26 + | +LL | writeln!(f, "{}",)?; + | ^^ + +error: aborting due to 8 previous errors diff --git a/src/test/ui/macros/macro-comma-behavior.rs b/src/test/ui/macros/macro-comma-behavior.rs index 0bfe0683078..27d50ff3d57 100644 --- a/src/test/ui/macros/macro-comma-behavior.rs +++ b/src/test/ui/macros/macro-comma-behavior.rs @@ -40,10 +40,8 @@ fn to_format_or_not_to_format() { } #[cfg(std)] { - // FIXME: compile-fail says "expected error not found" even though - // rustc does emit an error - // eprintln!("{}",); - // [std]~^ ERROR no arguments + eprintln!("{}",); + //[std]~^ ERROR no arguments } #[cfg(std)] { @@ -63,10 +61,8 @@ fn to_format_or_not_to_format() { } #[cfg(std)] { - // FIXME: compile-fail says "expected error not found" even though - // rustc does emit an error - // println!("{}",); - // [std]~^ ERROR no arguments + println!("{}",); + //[std]~^ ERROR no arguments } unimplemented!("{}",); @@ -82,11 +78,9 @@ fn to_format_or_not_to_format() { //[core]~^ ERROR no arguments //[std]~^^ ERROR no arguments - // FIXME: compile-fail says "expected error not found" even though - // rustc does emit an error - // writeln!(f, "{}",)?; - // [core]~^ ERROR no arguments - // [std]~^^ ERROR no arguments + writeln!(f, "{}",)?; + //[core]~^ ERROR no arguments + //[std]~^^ ERROR no arguments Ok(()) } } diff --git a/src/test/ui/macros/macro-comma-behavior.std.stderr b/src/test/ui/macros/macro-comma-behavior.std.stderr index 4372d89fbf5..7fd060e2224 100644 --- a/src/test/ui/macros/macro-comma-behavior.std.stderr +++ b/src/test/ui/macros/macro-comma-behavior.std.stderr @@ -29,34 +29,52 @@ LL | eprint!("{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:50:18 + --> $DIR/macro-comma-behavior.rs:43:20 + | +LL | eprintln!("{}",); + | ^^ + +error: 1 positional argument in format string, but no arguments were given + --> $DIR/macro-comma-behavior.rs:48:18 | LL | format!("{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:54:19 + --> $DIR/macro-comma-behavior.rs:52:19 | LL | format_args!("{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:61:17 + --> $DIR/macro-comma-behavior.rs:59:17 | LL | print!("{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:72:21 + --> $DIR/macro-comma-behavior.rs:64:19 + | +LL | println!("{}",); + | ^^ + +error: 1 positional argument in format string, but no arguments were given + --> $DIR/macro-comma-behavior.rs:68:21 | LL | unimplemented!("{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:81:24 + --> $DIR/macro-comma-behavior.rs:77:24 | LL | write!(f, "{}",)?; | ^^ -error: aborting due to 10 previous errors +error: 1 positional argument in format string, but no arguments were given + --> $DIR/macro-comma-behavior.rs:81:26 + | +LL | writeln!(f, "{}",)?; + | ^^ + +error: aborting due to 13 previous errors diff --git a/src/test/ui/macros/macro-comma-support-rpass.rs b/src/test/ui/macros/macro-comma-support-rpass.rs index 50c0ef3451d..f6c4f896d67 100644 --- a/src/test/ui/macros/macro-comma-support-rpass.rs +++ b/src/test/ui/macros/macro-comma-support-rpass.rs @@ -68,7 +68,7 @@ fn column() { let _ = column!(); } -// compile_error! is in a companion to this test in compile-fail +// compile_error! is in a check-fail companion to this test #[test] fn concat() { diff --git a/src/test/ui/macros/not-utf8.bin b/src/test/ui/macros/not-utf8.bin new file mode 100644 index 00000000000..4148e5b88fe Binary files /dev/null and b/src/test/ui/macros/not-utf8.bin differ diff --git a/src/test/ui/macros/not-utf8.rs b/src/test/ui/macros/not-utf8.rs new file mode 100644 index 00000000000..1cb1fdcb8c9 --- /dev/null +++ b/src/test/ui/macros/not-utf8.rs @@ -0,0 +1,5 @@ +// error-pattern: did not contain valid UTF-8 + +fn foo() { + include!("not-utf8.bin") +} diff --git a/src/test/ui/macros/not-utf8.stderr b/src/test/ui/macros/not-utf8.stderr new file mode 100644 index 00000000000..f47be14fae3 --- /dev/null +++ b/src/test/ui/macros/not-utf8.stderr @@ -0,0 +1,10 @@ +error: couldn't read $DIR/not-utf8.bin: stream did not contain valid UTF-8 + --> $DIR/not-utf8.rs:4:5 + | +LL | include!("not-utf8.bin") + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to previous error + diff --git a/src/test/ui/meta/meta-expected-error-wrong-rev.a.stderr b/src/test/ui/meta/meta-expected-error-wrong-rev.a.stderr new file mode 100644 index 00000000000..583b2c4cfe0 --- /dev/null +++ b/src/test/ui/meta/meta-expected-error-wrong-rev.a.stderr @@ -0,0 +1,16 @@ +error[E0308]: mismatched types + --> $DIR/meta-expected-error-wrong-rev.rs:13:18 + | +LL | let x: u32 = 22_usize; + | --- ^^^^^^^^ expected `u32`, found `usize` + | | + | expected due to this + | +help: change the type of the numeric literal from `usize` to `u32` + | +LL | let x: u32 = 22_u32; + | ^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/meta/meta-expected-error-wrong-rev.rs b/src/test/ui/meta/meta-expected-error-wrong-rev.rs new file mode 100644 index 00000000000..7e49434142b --- /dev/null +++ b/src/test/ui/meta/meta-expected-error-wrong-rev.rs @@ -0,0 +1,16 @@ +// ignore-compare-mode-nll + +// revisions: a +// should-fail + +// This is a "meta-test" of the compilertest framework itself. In +// particular, it includes the right error message, but the message +// targets the wrong revision, so we expect the execution to fail. +// See also `meta-expected-error-correct-rev.rs`. + +#[cfg(a)] +fn foo() { + let x: u32 = 22_usize; //[b]~ ERROR mismatched types +} + +fn main() { } diff --git a/src/test/ui/never_type/issue-52443.rs b/src/test/ui/never_type/issue-52443.rs new file mode 100644 index 00000000000..4519833b864 --- /dev/null +++ b/src/test/ui/never_type/issue-52443.rs @@ -0,0 +1,14 @@ +fn main() { + [(); & { loop { continue } } ]; //~ ERROR mismatched types + + [(); loop { break }]; //~ ERROR mismatched types + + [(); {while true {break}; 0}]; + //~^ WARN denote infinite loops with + + [(); { for _ in 0usize.. {}; 0}]; + //~^ ERROR `for` is not allowed in a `const` + //~| ERROR calls in constants are limited to constant functions + //~| ERROR mutable references are not allowed in constants + //~| ERROR calls in constants are limited to constant functions +} diff --git a/src/test/ui/never_type/issue-52443.stderr b/src/test/ui/never_type/issue-52443.stderr new file mode 100644 index 00000000000..051896cb89c --- /dev/null +++ b/src/test/ui/never_type/issue-52443.stderr @@ -0,0 +1,57 @@ +warning: denote infinite loops with `loop { ... }` + --> $DIR/issue-52443.rs:6:11 + | +LL | [(); {while true {break}; 0}]; + | ^^^^^^^^^^ help: use `loop` + | + = note: `#[warn(while_true)]` on by default + +error[E0744]: `for` is not allowed in a `const` + --> $DIR/issue-52443.rs:9:12 + | +LL | [(); { for _ in 0usize.. {}; 0}]; + | ^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/issue-52443.rs:2:10 + | +LL | [(); & { loop { continue } } ]; + | ^^^^^^^^^^^^^^^^^^^^^^^ + | | + | expected `usize`, found reference + | help: consider removing the borrow: `{ loop { continue } }` + | + = note: expected type `usize` + found reference `&_` + +error[E0308]: mismatched types + --> $DIR/issue-52443.rs:4:17 + | +LL | [(); loop { break }]; + | ^^^^^ + | | + | expected `usize`, found `()` + | help: give it a value of the expected type: `break 42` + +error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants + --> $DIR/issue-52443.rs:9:21 + | +LL | [(); { for _ in 0usize.. {}; 0}]; + | ^^^^^^^^ + +error[E0764]: mutable references are not allowed in constants + --> $DIR/issue-52443.rs:9:21 + | +LL | [(); { for _ in 0usize.. {}; 0}]; + | ^^^^^^^^ `&mut` is only allowed in `const fn` + +error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants + --> $DIR/issue-52443.rs:9:21 + | +LL | [(); { for _ in 0usize.. {}; 0}]; + | ^^^^^^^^ + +error: aborting due to 6 previous errors; 1 warning emitted + +Some errors have detailed explanations: E0015, E0308, E0744, E0764. +For more information about an error, try `rustc --explain E0015`. diff --git a/src/test/ui/object-lifetime-default-from-rptr-box.rs b/src/test/ui/object-lifetime-default-from-rptr-box.rs index 8ac45b3db71..b61083078cc 100644 --- a/src/test/ui/object-lifetime-default-from-rptr-box.rs +++ b/src/test/ui/object-lifetime-default-from-rptr-box.rs @@ -23,7 +23,7 @@ fn b<'a>(t: &'a Box, mut ss: SomeStruct<'a>) { ss.u = t; } -// see also compile-fail/object-lifetime-default-from-rptr-box-error.rs +// see also ui/object-lifetime/object-lifetime-default-from-rptr-box-error.rs fn d<'a>(t: &'a Box, mut ss: SomeStruct<'a>) { ss.u = t; diff --git a/src/test/ui/panic-handler/auxiliary/weak-lang-items.rs b/src/test/ui/panic-handler/auxiliary/weak-lang-items.rs new file mode 100644 index 00000000000..7a698cf76ae --- /dev/null +++ b/src/test/ui/panic-handler/auxiliary/weak-lang-items.rs @@ -0,0 +1,22 @@ +// no-prefer-dynamic + +// This aux-file will require the eh_personality function to be codegen'd, but +// it hasn't been defined just yet. Make sure we don't explode. + +#![no_std] +#![crate_type = "rlib"] + +struct A; + +impl core::ops::Drop for A { + fn drop(&mut self) {} +} + +pub fn foo() { + let _a = A; + panic!("wut"); +} + +mod std { + pub use core::{option, fmt}; +} diff --git a/src/test/ui/panic-handler/panic-handler-missing.rs b/src/test/ui/panic-handler/panic-handler-missing.rs new file mode 100644 index 00000000000..6bb062ba657 --- /dev/null +++ b/src/test/ui/panic-handler/panic-handler-missing.rs @@ -0,0 +1,9 @@ +// dont-check-compiler-stderr +// error-pattern: `#[panic_handler]` function required, but not found + +#![feature(lang_items)] +#![no_main] +#![no_std] + +#[lang = "eh_personality"] +fn eh() {} diff --git a/src/test/ui/panic-handler/panic-handler-twice.rs b/src/test/ui/panic-handler/panic-handler-twice.rs new file mode 100644 index 00000000000..05bef66d849 --- /dev/null +++ b/src/test/ui/panic-handler/panic-handler-twice.rs @@ -0,0 +1,19 @@ +// dont-check-compiler-stderr +// aux-build:some-panic-impl.rs + +#![feature(lang_items)] +#![no_std] +#![no_main] + +extern crate some_panic_impl; + +use core::panic::PanicInfo; + +#[panic_handler] +fn panic(info: &PanicInfo) -> ! { + //~^ ERROR found duplicate lang item `panic_impl` + loop {} +} + +#[lang = "eh_personality"] +fn eh() {} diff --git a/src/test/ui/panic-handler/weak-lang-item.rs b/src/test/ui/panic-handler/weak-lang-item.rs new file mode 100644 index 00000000000..3fa3822831b --- /dev/null +++ b/src/test/ui/panic-handler/weak-lang-item.rs @@ -0,0 +1,11 @@ +// aux-build:weak-lang-items.rs +// error-pattern: `#[panic_handler]` function required, but not found +// error-pattern: language item required, but not found: `eh_personality` +// ignore-emscripten compiled with panic=abort, personality not required + +#![no_std] + +extern crate core; +extern crate weak_lang_items; + +fn main() {} diff --git a/src/test/ui/panic-handler/weak-lang-item.stderr b/src/test/ui/panic-handler/weak-lang-item.stderr new file mode 100644 index 00000000000..b7c040c7a85 --- /dev/null +++ b/src/test/ui/panic-handler/weak-lang-item.stderr @@ -0,0 +1,19 @@ +error[E0259]: the name `core` is defined multiple times + --> $DIR/weak-lang-item.rs:8:1 + | +LL | extern crate core; + | ^^^^^^^^^^^^^^^^^^ `core` reimported here + | + = note: `core` must be defined only once in the type namespace of this module +help: you can use `as` to change the binding name of the import + | +LL | extern crate core as other_core; + | + +error: `#[panic_handler]` function required, but not found + +error: language item required, but not found: `eh_personality` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0259`. diff --git a/src/test/ui/panic-runtime/auxiliary/depends.rs b/src/test/ui/panic-runtime/auxiliary/depends.rs new file mode 100644 index 00000000000..e9bc2f4893e --- /dev/null +++ b/src/test/ui/panic-runtime/auxiliary/depends.rs @@ -0,0 +1,8 @@ +// no-prefer-dynamic + +#![feature(panic_runtime)] +#![crate_type = "rlib"] +#![panic_runtime] +#![no_std] + +extern crate needs_panic_runtime; diff --git a/src/test/ui/panic-runtime/auxiliary/needs-panic-runtime.rs b/src/test/ui/panic-runtime/auxiliary/needs-panic-runtime.rs new file mode 100644 index 00000000000..3f030c169f6 --- /dev/null +++ b/src/test/ui/panic-runtime/auxiliary/needs-panic-runtime.rs @@ -0,0 +1,6 @@ +// no-prefer-dynamic + +#![feature(needs_panic_runtime)] +#![crate_type = "rlib"] +#![needs_panic_runtime] +#![no_std] diff --git a/src/test/ui/panic-runtime/runtime-depend-on-needs-runtime.rs b/src/test/ui/panic-runtime/runtime-depend-on-needs-runtime.rs new file mode 100644 index 00000000000..d57f1643e98 --- /dev/null +++ b/src/test/ui/panic-runtime/runtime-depend-on-needs-runtime.rs @@ -0,0 +1,8 @@ +// dont-check-compiler-stderr +// aux-build:needs-panic-runtime.rs +// aux-build:depends.rs +// error-pattern:cannot depend on a crate that needs a panic runtime + +extern crate depends; + +fn main() {} diff --git a/src/test/ui/panic-runtime/two-panic-runtimes.rs b/src/test/ui/panic-runtime/two-panic-runtimes.rs new file mode 100644 index 00000000000..c968b5ea1e1 --- /dev/null +++ b/src/test/ui/panic-runtime/two-panic-runtimes.rs @@ -0,0 +1,16 @@ +// build-fail +// dont-check-compiler-stderr +// error-pattern:cannot link together two panic runtimes: panic_runtime_unwind and panic_runtime_unwind2 +// ignore-tidy-linelength +// aux-build:panic-runtime-unwind.rs +// aux-build:panic-runtime-unwind2.rs +// aux-build:panic-runtime-lang-items.rs + +#![no_std] +#![no_main] + +extern crate panic_runtime_unwind; +extern crate panic_runtime_unwind2; +extern crate panic_runtime_lang_items; + +fn main() {} diff --git a/src/test/ui/panic-runtime/unwind-tables-panic-required.rs b/src/test/ui/panic-runtime/unwind-tables-panic-required.rs new file mode 100644 index 00000000000..6393a27046b --- /dev/null +++ b/src/test/ui/panic-runtime/unwind-tables-panic-required.rs @@ -0,0 +1,11 @@ +// Tests that the compiler errors if the user tries to turn off unwind tables +// when they are required. +// +// dont-check-compiler-stderr +// compile-flags: -C panic=unwind -C force-unwind-tables=no +// ignore-tidy-linelength +// +// error-pattern: panic=unwind requires unwind tables, they cannot be disabled with `-C force-unwind-tables=no`. + +pub fn main() { +} diff --git a/src/test/ui/panic-runtime/unwind-tables-target-required.rs b/src/test/ui/panic-runtime/unwind-tables-target-required.rs new file mode 100644 index 00000000000..14c17893764 --- /dev/null +++ b/src/test/ui/panic-runtime/unwind-tables-target-required.rs @@ -0,0 +1,11 @@ +// Tests that the compiler errors if the user tries to turn off unwind tables +// when they are required. +// +// only-x86_64-windows-msvc +// compile-flags: -C force-unwind-tables=no +// ignore-tidy-linelength +// +// error-pattern: target requires unwind tables, they cannot be disabled with `-C force-unwind-tables=no`. + +pub fn main() { +} diff --git a/src/test/ui/panic-runtime/want-abort-got-unwind.rs b/src/test/ui/panic-runtime/want-abort-got-unwind.rs new file mode 100644 index 00000000000..e33c3bcc3f0 --- /dev/null +++ b/src/test/ui/panic-runtime/want-abort-got-unwind.rs @@ -0,0 +1,9 @@ +// build-fail +// dont-check-compiler-stderr +// error-pattern:is not compiled with this crate's panic strategy `abort` +// aux-build:panic-runtime-unwind.rs +// compile-flags:-C panic=abort + +extern crate panic_runtime_unwind; + +fn main() {} diff --git a/src/test/ui/panic-runtime/want-abort-got-unwind2.rs b/src/test/ui/panic-runtime/want-abort-got-unwind2.rs new file mode 100644 index 00000000000..438f1d85a28 --- /dev/null +++ b/src/test/ui/panic-runtime/want-abort-got-unwind2.rs @@ -0,0 +1,10 @@ +// build-fail +// dont-check-compiler-stderr +// error-pattern:is not compiled with this crate's panic strategy `abort` +// aux-build:panic-runtime-unwind.rs +// aux-build:wants-panic-runtime-unwind.rs +// compile-flags:-C panic=abort + +extern crate wants_panic_runtime_unwind; + +fn main() {} diff --git a/src/test/ui/privacy/issue-46209-private-enum-variant-reexport.rs b/src/test/ui/privacy/issue-46209-private-enum-variant-reexport.rs new file mode 100644 index 00000000000..d54c9931479 --- /dev/null +++ b/src/test/ui/privacy/issue-46209-private-enum-variant-reexport.rs @@ -0,0 +1,41 @@ +#![feature(crate_visibility_modifier)] + +mod rank { + pub use self::Professor::*; + //~^ ERROR enum is private and its variants cannot be re-exported + pub use self::Lieutenant::{JuniorGrade, Full}; + //~^ ERROR variant `JuniorGrade` is private and cannot be re-exported + //~| ERROR variant `Full` is private and cannot be re-exported + pub use self::PettyOfficer::*; + //~^ ERROR enum is private and its variants cannot be re-exported + pub use self::Crewman::*; + //~^ ERROR enum is private and its variants cannot be re-exported + + enum Professor { + Adjunct, + Assistant, + Associate, + Full + } + + enum Lieutenant { + JuniorGrade, + Full, + } + + pub(in rank) enum PettyOfficer { + SecondClass, + FirstClass, + Chief, + MasterChief + } + + crate enum Crewman { + Recruit, + Apprentice, + Full + } + +} + +fn main() {} diff --git a/src/test/ui/privacy/issue-46209-private-enum-variant-reexport.stderr b/src/test/ui/privacy/issue-46209-private-enum-variant-reexport.stderr new file mode 100644 index 00000000000..b876bab6c54 --- /dev/null +++ b/src/test/ui/privacy/issue-46209-private-enum-variant-reexport.stderr @@ -0,0 +1,44 @@ +error: variant `JuniorGrade` is private and cannot be re-exported + --> $DIR/issue-46209-private-enum-variant-reexport.rs:6:32 + | +LL | pub use self::Lieutenant::{JuniorGrade, Full}; + | ^^^^^^^^^^^ +... +LL | enum Lieutenant { + | --------------- help: consider making the enum public: `pub enum Lieutenant` + +error: variant `Full` is private and cannot be re-exported + --> $DIR/issue-46209-private-enum-variant-reexport.rs:6:45 + | +LL | pub use self::Lieutenant::{JuniorGrade, Full}; + | ^^^^ + +error: enum is private and its variants cannot be re-exported + --> $DIR/issue-46209-private-enum-variant-reexport.rs:4:13 + | +LL | pub use self::Professor::*; + | ^^^^^^^^^^^^^^^^^^ +... +LL | enum Professor { + | -------------- help: consider making the enum public: `pub enum Professor` + +error: enum is private and its variants cannot be re-exported + --> $DIR/issue-46209-private-enum-variant-reexport.rs:9:13 + | +LL | pub use self::PettyOfficer::*; + | ^^^^^^^^^^^^^^^^^^^^^ +... +LL | pub(in rank) enum PettyOfficer { + | ------------------------------ help: consider making the enum public: `pub enum PettyOfficer` + +error: enum is private and its variants cannot be re-exported + --> $DIR/issue-46209-private-enum-variant-reexport.rs:11:13 + | +LL | pub use self::Crewman::*; + | ^^^^^^^^^^^^^^^^ +... +LL | crate enum Crewman { + | ------------------ help: consider making the enum public: `pub enum Crewman` + +error: aborting due to 5 previous errors + diff --git a/src/test/ui/regions/regions-early-bound-trait-param.rs b/src/test/ui/regions/regions-early-bound-trait-param.rs index cc2bde78d85..276a64b8e9a 100644 --- a/src/test/ui/regions/regions-early-bound-trait-param.rs +++ b/src/test/ui/regions/regions-early-bound-trait-param.rs @@ -117,7 +117,7 @@ pub fn main() { let m : Box = make_val(); // assert_eq!(object_invoke1(&*m), (4,5)); // ~~~~~~~~~~~~~~~~~~~ - // this call yields a compilation error; see compile-fail/dropck-object-cycle.rs + // this call yields a compilation error; see ui/span/dropck-object-cycle.rs // for details. assert_eq!(object_invoke2(&*m), 5); diff --git a/src/test/ui/regions/regions-variance-contravariant-use-contravariant.rs b/src/test/ui/regions/regions-variance-contravariant-use-contravariant.rs index f10d5a25f16..e6377867018 100644 --- a/src/test/ui/regions/regions-variance-contravariant-use-contravariant.rs +++ b/src/test/ui/regions/regions-variance-contravariant-use-contravariant.rs @@ -4,7 +4,7 @@ // Test that a type which is contravariant with respect to its region // parameter compiles successfully when used in a contravariant way. // -// Note: see compile-fail/variance-regions-*.rs for the tests that check that the +// Note: see ui/variance/variance-regions-*.rs for the tests that check that the // variance inference works in the first place. // pretty-expanded FIXME #23616 diff --git a/src/test/ui/regions/regions-variance-covariant-use-covariant.rs b/src/test/ui/regions/regions-variance-covariant-use-covariant.rs index 9316aa15d32..c5c80ce54f1 100644 --- a/src/test/ui/regions/regions-variance-covariant-use-covariant.rs +++ b/src/test/ui/regions/regions-variance-covariant-use-covariant.rs @@ -3,7 +3,7 @@ // Test that a type which is covariant with respect to its region // parameter is successful when used in a covariant way. // -// Note: see compile-fail/variance-regions-*.rs for the tests that +// Note: see ui/variance/variance-regions-*.rs for the tests that // check that the variance inference works in the first place. // This is covariant with respect to 'a, meaning that diff --git a/src/test/ui/span/dropck_arr_cycle_checked.rs b/src/test/ui/span/dropck_arr_cycle_checked.rs index ac31e4910d5..a14db5ff089 100644 --- a/src/test/ui/span/dropck_arr_cycle_checked.rs +++ b/src/test/ui/span/dropck_arr_cycle_checked.rs @@ -1,7 +1,7 @@ // Reject mixing cyclic structure and Drop when using fixed length // arrays. // -// (Compare against compile-fail/dropck_vec_cycle_checked.rs) +// (Compare against ui/span/dropck_vec_cycle_checked.rs) diff --git a/src/test/ui/span/dropck_vec_cycle_checked.rs b/src/test/ui/span/dropck_vec_cycle_checked.rs index bacd99c6825..c5d21507d76 100644 --- a/src/test/ui/span/dropck_vec_cycle_checked.rs +++ b/src/test/ui/span/dropck_vec_cycle_checked.rs @@ -1,6 +1,6 @@ // Reject mixing cyclic structure and Drop when using Vec. // -// (Compare against compile-fail/dropck_arr_cycle_checked.rs) +// (Compare against ui/span/dropck_arr_cycle_checked.rs) use std::cell::Cell; use id::Id; diff --git a/src/test/ui/specialization/defaultimpl/projection.rs b/src/test/ui/specialization/defaultimpl/projection.rs index 4a914096932..f19c55b043b 100644 --- a/src/test/ui/specialization/defaultimpl/projection.rs +++ b/src/test/ui/specialization/defaultimpl/projection.rs @@ -4,7 +4,7 @@ #![feature(specialization)] //~ WARN the feature `specialization` is incomplete // Make sure we *can* project non-defaulted associated types -// cf compile-fail/specialization-default-projection.rs +// cf ui/specialization/specialization-default-projection.rs // First, do so without any use of specialization diff --git a/src/test/ui/specialization/issue-50452-fail.rs b/src/test/ui/specialization/issue-50452-fail.rs new file mode 100644 index 00000000000..fe21e9b6ede --- /dev/null +++ b/src/test/ui/specialization/issue-50452-fail.rs @@ -0,0 +1,21 @@ +#![feature(specialization)] +//~^ WARN the feature `specialization` is incomplete + +pub trait Foo { + fn foo(); +} + +impl Foo for i32 {} +impl Foo for i64 { + fn foo() {} + //~^ERROR `foo` specializes an item from a parent `impl` +} +impl Foo for T { + fn foo() {} +} + +fn main() { + i32::foo(); + i64::foo(); + u8::foo(); +} diff --git a/src/test/ui/specialization/issue-50452-fail.stderr b/src/test/ui/specialization/issue-50452-fail.stderr new file mode 100644 index 00000000000..8e7c5037eff --- /dev/null +++ b/src/test/ui/specialization/issue-50452-fail.stderr @@ -0,0 +1,26 @@ +warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/issue-50452-fail.rs:1:12 + | +LL | #![feature(specialization)] + | ^^^^^^^^^^^^^^ + | + = note: `#[warn(incomplete_features)]` on by default + = note: see issue #31844 for more information + = help: consider using `min_specialization` instead, which is more stable and complete + +error[E0520]: `foo` specializes an item from a parent `impl`, but that item is not marked `default` + --> $DIR/issue-50452-fail.rs:10:5 + | +LL | fn foo() {} + | ^^^^^^^^^^^ cannot specialize default item `foo` +... +LL | / impl Foo for T { +LL | | fn foo() {} +LL | | } + | |_- parent `impl` is here + | + = note: to specialize, `foo` in the parent `impl` must be marked `default` + +error: aborting due to previous error; 1 warning emitted + +For more information about this error, try `rustc --explain E0520`. diff --git a/src/test/ui/specialization/specialization-projection.rs b/src/test/ui/specialization/specialization-projection.rs index 700975e3b82..78afe7a9495 100644 --- a/src/test/ui/specialization/specialization-projection.rs +++ b/src/test/ui/specialization/specialization-projection.rs @@ -4,7 +4,7 @@ #![feature(specialization)] //~ WARN the feature `specialization` is incomplete // Make sure we *can* project non-defaulted associated types -// cf compile-fail/specialization-default-projection.rs +// cf ui/specialization/specialization-default-projection.rs // First, do so without any use of specialization diff --git a/src/test/ui/structs-enums/discrim-explicit-23030.rs b/src/test/ui/structs-enums/discrim-explicit-23030.rs index af7ab865e32..e17025e9e88 100644 --- a/src/test/ui/structs-enums/discrim-explicit-23030.rs +++ b/src/test/ui/structs-enums/discrim-explicit-23030.rs @@ -2,7 +2,7 @@ // Issue 23030: Workaround overflowing discriminant // with explicit assignments. -// See also compile-fail/overflow-discrim.rs, which shows what +// See also ui/discrim/discrim-overflow.rs, which shows what // happens if you leave the OhNo explicit cases out here. fn f_i8() { diff --git a/src/test/ui/structs-enums/object-lifetime-default-from-rptr-struct.rs b/src/test/ui/structs-enums/object-lifetime-default-from-rptr-struct.rs index 1fc52ead48e..d3e92e16246 100644 --- a/src/test/ui/structs-enums/object-lifetime-default-from-rptr-struct.rs +++ b/src/test/ui/structs-enums/object-lifetime-default-from-rptr-struct.rs @@ -27,7 +27,7 @@ fn b<'a>(t: &'a MyBox, mut ss: SomeStruct<'a>) { ss.u = t; } -// see also compile-fail/object-lifetime-default-from-rptr-box-error.rs +// see also ui/object-lifetime/object-lifetime-default-from-rptr-box-error.rs fn d<'a>(t: &'a MyBox, mut ss: SomeStruct<'a>) { ss.u = t; diff --git a/src/test/ui/svh/auxiliary/svh-uta-base.rs b/src/test/ui/svh/auxiliary/svh-uta-base.rs index c138f1a5ba8..221a096e083 100644 --- a/src/test/ui/svh/auxiliary/svh-uta-base.rs +++ b/src/test/ui/svh/auxiliary/svh-uta-base.rs @@ -1,4 +1,4 @@ -//! "compile-fail/svh-uta-trait.rs" is checking that we detect a +//! "svh-uta-trait.rs" is checking that we detect a //! change from `use foo::TraitB` to use `foo::TraitB` in the hash //! (SVH) computation (#14132), since that will affect method //! resolution. diff --git a/src/test/ui/svh/auxiliary/svh-uta-change-use-trait.rs b/src/test/ui/svh/auxiliary/svh-uta-change-use-trait.rs index 76a472b5b26..823d29571aa 100644 --- a/src/test/ui/svh/auxiliary/svh-uta-change-use-trait.rs +++ b/src/test/ui/svh/auxiliary/svh-uta-change-use-trait.rs @@ -1,4 +1,4 @@ -//! "compile-fail/svh-uta-trait.rs" is checking that we detect a +//! "svh-uta-trait.rs" is checking that we detect a //! change from `use foo::TraitB` to use `foo::TraitB` in the hash //! (SVH) computation (#14132), since that will affect method //! resolution. diff --git a/src/test/ui/svh/auxiliary/svh-utb.rs b/src/test/ui/svh/auxiliary/svh-utb.rs index 2f27e99a961..a03e29dcedc 100644 --- a/src/test/ui/svh/auxiliary/svh-utb.rs +++ b/src/test/ui/svh/auxiliary/svh-utb.rs @@ -1,4 +1,4 @@ -//! "compile-fail/svh-uta-trait.rs" is checking that we detect a +//! "svh-uta-trait.rs" is checking that we detect a //! change from `use foo::TraitB` to use `foo::TraitB` in the hash //! (SVH) computation (#14132), since that will affect method //! resolution. diff --git a/src/test/ui/svh/svh-use-trait.rs b/src/test/ui/svh/svh-use-trait.rs index 93daca034c0..e5c427e096a 100644 --- a/src/test/ui/svh/svh-use-trait.rs +++ b/src/test/ui/svh/svh-use-trait.rs @@ -6,7 +6,7 @@ // aux-build:svh-uta-change-use-trait.rs // normalize-stderr-test: "(crate `(\w+)`:) .*" -> "$1 $$PATH_$2" -//! "compile-fail/svh-uta-trait.rs" is checking that we detect a +//! "svh-uta-trait.rs" is checking that we detect a //! change from `use foo::TraitB` to use `foo::TraitB` in the hash //! (SVH) computation (#14132), since that will affect method //! resolution. diff --git a/src/test/ui/threads-sendsync/issue-43733-2.rs b/src/test/ui/threads-sendsync/issue-43733-2.rs new file mode 100644 index 00000000000..21ea8e9a209 --- /dev/null +++ b/src/test/ui/threads-sendsync/issue-43733-2.rs @@ -0,0 +1,30 @@ +// dont-check-compiler-stderr + +#![feature(cfg_target_thread_local, thread_local_internals)] + +// On platforms *without* `#[thread_local]`, use +// a custom non-`Sync` type to fake the same error. +#[cfg(not(target_thread_local))] +struct Key { + _data: std::cell::UnsafeCell>, + _flag: std::cell::Cell<()>, +} + +#[cfg(not(target_thread_local))] +impl Key { + const fn new() -> Self { + Key { + _data: std::cell::UnsafeCell::new(None), + _flag: std::cell::Cell::new(()), + } + } +} + +#[cfg(target_thread_local)] +use std::thread::__FastLocalKeyInner as Key; + +static __KEY: Key<()> = Key::new(); +//~^ ERROR `UnsafeCell>` cannot be shared between threads +//~| ERROR cannot be shared between threads safely [E0277] + +fn main() {} diff --git a/src/test/ui/threads-sendsync/issue-43733.rs b/src/test/ui/threads-sendsync/issue-43733.rs new file mode 100644 index 00000000000..a602d7667c4 --- /dev/null +++ b/src/test/ui/threads-sendsync/issue-43733.rs @@ -0,0 +1,31 @@ +#![feature(const_fn)] +#![feature(thread_local)] +#![feature(cfg_target_thread_local, thread_local_internals)] + +type Foo = std::cell::RefCell; + +#[cfg(target_thread_local)] +#[thread_local] +static __KEY: std::thread::__FastLocalKeyInner = + std::thread::__FastLocalKeyInner::new(); + +#[cfg(not(target_thread_local))] +static __KEY: std::thread::__OsLocalKeyInner = + std::thread::__OsLocalKeyInner::new(); + +fn __getit() -> std::option::Option<&'static Foo> +{ + __KEY.get(Default::default) //~ ERROR call to unsafe function is unsafe +} + +static FOO: std::thread::LocalKey = + std::thread::LocalKey::new(__getit); +//~^ ERROR call to unsafe function is unsafe + +fn main() { + FOO.with(|foo| println!("{}", foo.borrow())); + std::thread::spawn(|| { + FOO.with(|foo| *foo.borrow_mut() += "foo"); + }).join().unwrap(); + FOO.with(|foo| println!("{}", foo.borrow())); +} diff --git a/src/test/ui/threads-sendsync/issue-43733.stderr b/src/test/ui/threads-sendsync/issue-43733.stderr new file mode 100644 index 00000000000..ee6a3b065d6 --- /dev/null +++ b/src/test/ui/threads-sendsync/issue-43733.stderr @@ -0,0 +1,19 @@ +error[E0133]: call to unsafe function is unsafe and requires unsafe function or block + --> $DIR/issue-43733.rs:18:5 + | +LL | __KEY.get(Default::default) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function + | + = note: consult the function's documentation for information on how to avoid undefined behavior + +error[E0133]: call to unsafe function is unsafe and requires unsafe function or block + --> $DIR/issue-43733.rs:22:5 + | +LL | std::thread::LocalKey::new(__getit); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function + | + = note: consult the function's documentation for information on how to avoid undefined behavior + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0133`. diff --git a/src/test/ui/traits/traits-repeated-supertrait.rs b/src/test/ui/traits/traits-repeated-supertrait.rs index 391d19c4385..339f9c37eea 100644 --- a/src/test/ui/traits/traits-repeated-supertrait.rs +++ b/src/test/ui/traits/traits-repeated-supertrait.rs @@ -2,7 +2,7 @@ // Test a case of a trait which extends the same supertrait twice, but // with difference type parameters. Test that we can invoke the // various methods in various ways successfully. -// See also `compile-fail/trait-repeated-supertrait-ambig.rs`. +// See also `ui/traits/trait-repeated-supertrait-ambig.rs`. trait CompareTo { diff --git a/src/test/ui/unsafe-fn-called-from-unsafe-blk.rs b/src/test/ui/unsafe-fn-called-from-unsafe-blk.rs index 38271cc3c78..3713a7065f5 100644 --- a/src/test/ui/unsafe-fn-called-from-unsafe-blk.rs +++ b/src/test/ui/unsafe-fn-called-from-unsafe-blk.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] // -// See also: compile-fail/unsafe-fn-called-from-safe.rs +// See also: ui/unsafe/unsafe-fn-called-from-safe.rs // pretty-expanded FIXME #23616 diff --git a/src/test/ui/unsafe-fn-called-from-unsafe-fn.rs b/src/test/ui/unsafe-fn-called-from-unsafe-fn.rs index 26acc913e87..5e953107686 100644 --- a/src/test/ui/unsafe-fn-called-from-unsafe-fn.rs +++ b/src/test/ui/unsafe-fn-called-from-unsafe-fn.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] // -// See also: compile-fail/unsafe-fn-called-from-safe.rs +// See also: ui/unsafe/unsafe-fn-called-from-safe.rs // pretty-expanded FIXME #23616 diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index 80fbb06b946..43dbaeb4655 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -10,8 +10,6 @@ use test::ColorConfig; #[derive(Clone, Copy, PartialEq, Debug)] pub enum Mode { - CompileFail, - RunFail, RunPassValgrind, Pretty, DebugInfo, @@ -42,8 +40,6 @@ impl FromStr for Mode { type Err = (); fn from_str(s: &str) -> Result { match s { - "compile-fail" => Ok(CompileFail), - "run-fail" => Ok(RunFail), "run-pass-valgrind" => Ok(RunPassValgrind), "pretty" => Ok(Pretty), "debuginfo" => Ok(DebugInfo), @@ -65,8 +61,6 @@ impl FromStr for Mode { impl fmt::Display for Mode { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let s = match *self { - CompileFail => "compile-fail", - RunFail => "run-fail", RunPassValgrind => "run-pass-valgrind", Pretty => "pretty", DebugInfo => "debuginfo", @@ -230,7 +224,7 @@ pub struct Config { /// The name of the stage being built (stage1, etc) pub stage_id: String, - /// The test mode, compile-fail, run-fail, ui + /// The test mode, e.g. ui or debuginfo. pub mode: Mode, /// The test suite (essentially which directory is running, but without the diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index a1be0a19f68..2eba91fd1f4 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -542,10 +542,7 @@ impl TestProps { } if self.failure_status == -1 { - self.failure_status = match config.mode { - Mode::RunFail => 101, - _ => 1, - }; + self.failure_status = 1; } if self.should_ice { self.failure_status = 101; diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs index c63bbaf70d3..aefcfe222e5 100644 --- a/src/tools/compiletest/src/main.rs +++ b/src/tools/compiletest/src/main.rs @@ -71,7 +71,7 @@ pub fn parse_config(args: Vec) -> Config { "", "mode", "which sort of compile tests to run", - "compile-fail | run-fail | run-pass-valgrind | pretty | debug-info | codegen | rustdoc \ + "run-pass-valgrind | pretty | debug-info | codegen | rustdoc \ | rustdoc-json | codegen-units | incremental | run-make | ui | js-doc-test | mir-opt | assembly", ) .reqopt( diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 828c4e89f0b..9f31b3ae1b1 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -5,8 +5,8 @@ use crate::common::{output_base_dir, output_base_name, output_testname_unique}; use crate::common::{Assembly, Incremental, JsDocTest, MirOpt, RunMake, RustdocJson, Ui}; use crate::common::{Codegen, CodegenUnits, DebugInfo, Debugger, Rustdoc}; use crate::common::{CompareMode, FailMode, PassMode}; -use crate::common::{CompileFail, Pretty, RunFail, RunPassValgrind}; use crate::common::{Config, TestPaths}; +use crate::common::{Pretty, RunPassValgrind}; use crate::common::{UI_RUN_STDERR, UI_RUN_STDOUT}; use crate::errors::{self, Error, ErrorKind}; use crate::header::TestProps; @@ -330,13 +330,11 @@ impl<'test> TestCx<'test> { /// revisions, exactly once, with revision == None). fn run_revision(&self) { if self.props.should_ice { - if self.config.mode != CompileFail && self.config.mode != Incremental { + if self.config.mode != Incremental { self.fatal("cannot use should-ice in a test that is not cfail"); } } match self.config.mode { - CompileFail => self.run_cfail_test(), - RunFail => self.run_rfail_test(), RunPassValgrind => self.run_valgrind_test(), Pretty => self.run_pretty_test(), DebugInfo => self.run_debuginfo_test(), @@ -377,7 +375,6 @@ impl<'test> TestCx<'test> { fn should_compile_successfully(&self, pm: Option) -> bool { match self.config.mode { - CompileFail => false, JsDocTest => true, Ui => pm.is_some() || self.props.fail_mode > Some(FailMode::Build), Incremental => { @@ -1537,8 +1534,8 @@ impl<'test> TestCx<'test> { }; let allow_unused = match self.config.mode { - CompileFail | Ui => { - // compile-fail and ui tests tend to have tons of unused code as + Ui => { + // UI tests tend to have tons of unused code as // it's just testing various pieces of the compile, but we don't // want to actually assert warnings about all this code. Instead // let's just ignore unused code warnings by defaults and tests @@ -1940,7 +1937,7 @@ impl<'test> TestCx<'test> { } match self.config.mode { - CompileFail | Incremental => { + Incremental => { // If we are extracting and matching errors in the new // fashion, then you want JSON mode. Old-skool error // patterns still match the raw compiler output. @@ -1975,8 +1972,8 @@ impl<'test> TestCx<'test> { rustc.arg(dir_opt); } - RunFail | RunPassValgrind | Pretty | DebugInfo | Codegen | Rustdoc | RustdocJson - | RunMake | CodegenUnits | JsDocTest | Assembly => { + RunPassValgrind | Pretty | DebugInfo | Codegen | Rustdoc | RustdocJson | RunMake + | CodegenUnits | JsDocTest | Assembly => { // do not use JSON output } } diff --git a/src/tools/tidy/src/features.rs b/src/tools/tidy/src/features.rs index d78af2cd616..384a291a777 100644 --- a/src/tools/tidy/src/features.rs +++ b/src/tools/tidy/src/features.rs @@ -85,11 +85,7 @@ pub fn check( assert!(!lib_features.is_empty()); super::walk_many( - &[ - &src_path.join("test/ui"), - &src_path.join("test/ui-fulldeps"), - &src_path.join("test/compile-fail"), - ], + &[&src_path.join("test/ui"), &src_path.join("test/ui-fulldeps")], &mut |path| super::filter_dirs(path), &mut |entry, contents| { let file = entry.path(); -- cgit 1.4.1-3-g733a5