From 3799af3337d748647ca6c4abbad63975275a7a37 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Thu, 21 Sep 2023 17:14:58 -0700 Subject: [PATCH 01/30] diagnostics: avoid mismatch between variance index and hir generic This happens because variances are constructed from ty generics, and ty generics are always constructed with lifetimes first. See compiler/rustc_hir_analysis/src/collect/generics_of.rs:248-269 Fixes #83556 --- .../rustc_hir_analysis/src/check/wfcheck.rs | 27 ++++++++++++++++--- tests/ui/generics/issue-83556.rs | 5 ++++ tests/ui/generics/issue-83556.stderr | 18 +++++++++++++ 3 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 tests/ui/generics/issue-83556.rs create mode 100644 tests/ui/generics/issue-83556.stderr diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs index b97e0a80fe6..412b03b3be3 100644 --- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs +++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs @@ -1755,6 +1755,8 @@ fn check_variances_for_type_defn<'tcx>( .collect::>() }); + let ty_generics = tcx.generics_of(item.owner_id); + for (index, _) in variances.iter().enumerate() { let parameter = Parameter(index as u32); @@ -1762,13 +1764,32 @@ fn check_variances_for_type_defn<'tcx>( continue; } - let param = &hir_generics.params[index]; + let ty_param = &ty_generics.params[index]; + let mut hir_param = &hir_generics.params[index]; - match param.name { + if ty_param.name != hir_param.name.ident().name { + // valid programs always have lifetimes before types in the generic parameter list + // ty_generics are normalized to be in this required order, and variances are built + // from ty generics, not from hir generics. but we need hir generics to get + // a span out + // + // if they aren't in the same order, then the user has written invalid code, and already + // got an error about it (or I'm wrong about this) + tcx.sess + .delay_span_bug(hir_param.span, "hir generics and ty generics in different order"); + for hp in hir_generics.params { + if hp.name.ident().name == ty_param.name { + hir_param = hp; + break; + } + } + } + + match hir_param.name { hir::ParamName::Error => {} _ => { let has_explicit_bounds = explicitly_bounded_params.contains(¶meter); - report_bivariance(tcx, param, has_explicit_bounds); + report_bivariance(tcx, hir_param, has_explicit_bounds); } } } diff --git a/tests/ui/generics/issue-83556.rs b/tests/ui/generics/issue-83556.rs new file mode 100644 index 00000000000..21f801d9d10 --- /dev/null +++ b/tests/ui/generics/issue-83556.rs @@ -0,0 +1,5 @@ +struct Foo(&'a ()); +//~^ ERROR lifetime parameters must be declared prior to +//~| ERROR parameter `T` is never used + +fn main() {} diff --git a/tests/ui/generics/issue-83556.stderr b/tests/ui/generics/issue-83556.stderr new file mode 100644 index 00000000000..2ed999510eb --- /dev/null +++ b/tests/ui/generics/issue-83556.stderr @@ -0,0 +1,18 @@ +error: lifetime parameters must be declared prior to type and const parameters + --> $DIR/issue-83556.rs:1:15 + | +LL | struct Foo(&'a ()); + | ----^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, T>` + +error[E0392]: parameter `T` is never used + --> $DIR/issue-83556.rs:1:12 + | +LL | struct Foo(&'a ()); + | ^ unused parameter + | + = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` + = help: if you intended `T` to be a const parameter, use `const T: usize` instead + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0392`. From 2157f3173161dae18621ccdfb88a1446eb2d41ff Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Fri, 22 Sep 2023 09:14:39 +0000 Subject: [PATCH 02/30] Add a way to decouple the implementation and the declaration of a TyCtxt method. --- compiler/rustc_codegen_gcc/src/lib.rs | 3 +- compiler/rustc_codegen_llvm/src/lib.rs | 3 +- .../rustc_codegen_ssa/src/traits/backend.rs | 3 +- .../rustc_const_eval/src/const_eval/mod.rs | 7 +- compiler/rustc_const_eval/src/lib.rs | 8 +-- compiler/rustc_interface/src/passes.rs | 13 ++-- compiler/rustc_middle/src/hooks/mod.rs | 64 +++++++++++++++++++ compiler/rustc_middle/src/lib.rs | 1 + compiler/rustc_middle/src/mir/pretty.rs | 2 +- compiler/rustc_middle/src/query/mod.rs | 10 --- compiler/rustc_middle/src/ty/context.rs | 6 ++ src/librustdoc/core.rs | 2 +- src/tools/clippy/clippy_utils/src/consts.rs | 2 +- 13 files changed, 96 insertions(+), 28 deletions(-) create mode 100644 compiler/rustc_middle/src/hooks/mod.rs diff --git a/compiler/rustc_codegen_gcc/src/lib.rs b/compiler/rustc_codegen_gcc/src/lib.rs index 697ae015fed..1567fea3e1c 100644 --- a/compiler/rustc_codegen_gcc/src/lib.rs +++ b/compiler/rustc_codegen_gcc/src/lib.rs @@ -82,6 +82,7 @@ use rustc_metadata::EncodedMetadata; use rustc_middle::dep_graph::{WorkProduct, WorkProductId}; use rustc_middle::query::Providers; use rustc_middle::ty::TyCtxt; +use rustc_middle::hooks; use rustc_session::config::{Lto, OptLevel, OutputFilenames}; use rustc_session::Session; use rustc_span::Symbol; @@ -127,7 +128,7 @@ impl CodegenBackend for GccCodegenBackend { *self.supports_128bit_integers.lock().expect("lock") = check_context.get_last_error() == Ok(None); } - fn provide(&self, providers: &mut Providers) { + fn provide(&self, providers: &mut Providers, _: &mut hooks::Providers) { // FIXME(antoyo) compute list of enabled features from cli flags providers.global_backend_features = |_tcx, ()| vec![]; } diff --git a/compiler/rustc_codegen_llvm/src/lib.rs b/compiler/rustc_codegen_llvm/src/lib.rs index ac199624e34..0f2acfd30f7 100644 --- a/compiler/rustc_codegen_llvm/src/lib.rs +++ b/compiler/rustc_codegen_llvm/src/lib.rs @@ -39,6 +39,7 @@ use rustc_errors::{DiagnosticMessage, ErrorGuaranteed, FatalError, Handler, Subd use rustc_fluent_macro::fluent_messages; use rustc_metadata::EncodedMetadata; use rustc_middle::dep_graph::{WorkProduct, WorkProductId}; +use rustc_middle::hooks; use rustc_middle::query::Providers; use rustc_middle::ty::TyCtxt; use rustc_session::config::{OptLevel, OutputFilenames, PrintKind, PrintRequest}; @@ -268,7 +269,7 @@ impl CodegenBackend for LlvmCodegenBackend { llvm_util::init(sess); // Make sure llvm is inited } - fn provide(&self, providers: &mut Providers) { + fn provide(&self, providers: &mut Providers, _hooks: &mut hooks::Providers) { providers.global_backend_features = |tcx, ()| llvm_util::global_llvm_features(tcx.sess, true) } diff --git a/compiler/rustc_codegen_ssa/src/traits/backend.rs b/compiler/rustc_codegen_ssa/src/traits/backend.rs index 0a02ca6b317..e00243075b9 100644 --- a/compiler/rustc_codegen_ssa/src/traits/backend.rs +++ b/compiler/rustc_codegen_ssa/src/traits/backend.rs @@ -11,6 +11,7 @@ use rustc_data_structures::sync::{DynSend, DynSync}; use rustc_errors::ErrorGuaranteed; use rustc_metadata::EncodedMetadata; use rustc_middle::dep_graph::{WorkProduct, WorkProductId}; +use rustc_middle::hooks; use rustc_middle::query::{ExternProviders, Providers}; use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt, LayoutOf, TyAndLayout}; use rustc_middle::ty::{Ty, TyCtxt}; @@ -84,7 +85,7 @@ pub trait CodegenBackend { Box::new(crate::back::metadata::DefaultMetadataLoader) } - fn provide(&self, _providers: &mut Providers) {} + fn provide(&self, _providers: &mut Providers, _hooks: &mut hooks::Providers) {} fn provide_extern(&self, _providers: &mut ExternProviders) {} fn codegen_crate<'tcx>( &self, diff --git a/compiler/rustc_const_eval/src/const_eval/mod.rs b/compiler/rustc_const_eval/src/const_eval/mod.rs index 886d7972a15..bcbe996be7d 100644 --- a/compiler/rustc_const_eval/src/const_eval/mod.rs +++ b/compiler/rustc_const_eval/src/const_eval/mod.rs @@ -4,6 +4,7 @@ use crate::errors::MaxNumNodesInConstErr; use crate::interpret::{intern_const_alloc_recursive, InternKind, InterpCx, Scalar}; use rustc_middle::mir; use rustc_middle::mir::interpret::{EvalToValTreeResult, GlobalId}; +use rustc_middle::query::TyCtxtAt; use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_span::{source_map::DUMMY_SP, symbol::Symbol}; @@ -86,17 +87,17 @@ pub(crate) fn eval_to_valtree<'tcx>( #[instrument(skip(tcx), level = "debug")] pub(crate) fn try_destructure_mir_constant_for_diagnostics<'tcx>( - tcx: TyCtxt<'tcx>, + tcx: TyCtxtAt<'tcx>, val: mir::ConstValue<'tcx>, ty: Ty<'tcx>, ) -> Option> { let param_env = ty::ParamEnv::reveal_all(); - let ecx = mk_eval_cx(tcx, DUMMY_SP, param_env, CanAccessStatics::No); + let ecx = mk_eval_cx(tcx.tcx, tcx.span, param_env, CanAccessStatics::No); let op = ecx.const_val_to_op(val, ty, None).ok()?; // We go to `usize` as we cannot allocate anything bigger anyway. let (field_count, variant, down) = match ty.kind() { - ty::Array(_, len) => (len.eval_target_usize(tcx, param_env) as usize, None, op), + ty::Array(_, len) => (len.eval_target_usize(tcx.tcx, param_env) as usize, None, op), ty::Adt(def, _) if def.variants().is_empty() => { return None; } diff --git a/compiler/rustc_const_eval/src/lib.rs b/compiler/rustc_const_eval/src/lib.rs index c126f749bf3..8ac2b519760 100644 --- a/compiler/rustc_const_eval/src/lib.rs +++ b/compiler/rustc_const_eval/src/lib.rs @@ -39,11 +39,11 @@ pub use errors::ReportErrorExt; use rustc_errors::{DiagnosticMessage, SubdiagnosticMessage}; use rustc_fluent_macro::fluent_messages; use rustc_middle::query::Providers; -use rustc_middle::ty; +use rustc_middle::{hooks, ty}; fluent_messages! { "../messages.ftl" } -pub fn provide(providers: &mut Providers) { +pub fn provide(providers: &mut Providers, hooks: &mut hooks::Providers) { const_eval::provide(providers); providers.eval_to_const_value_raw = const_eval::eval_to_const_value_raw_provider; providers.eval_to_allocation_raw = const_eval::eval_to_allocation_raw_provider; @@ -52,8 +52,8 @@ pub fn provide(providers: &mut Providers) { let (param_env, raw) = param_env_and_value.into_parts(); const_eval::eval_to_valtree(tcx, param_env, raw) }; - providers.try_destructure_mir_constant_for_diagnostics = - |tcx, (cv, ty)| const_eval::try_destructure_mir_constant_for_diagnostics(tcx, cv, ty); + hooks.try_destructure_mir_constant_for_diagnostics = + const_eval::try_destructure_mir_constant_for_diagnostics; providers.valtree_to_const_val = |tcx, (ty, valtree)| { const_eval::valtree_to_const_value(tcx, ty::ParamEnv::empty().and(ty), valtree) }; diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index e5ae6d5b5d6..6de7686fbd9 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -18,6 +18,7 @@ use rustc_lint::{unerased_lint_store, BufferedEarlyLint, EarlyCheckNode, LintSto use rustc_metadata::creader::CStore; use rustc_middle::arena::Arena; use rustc_middle::dep_graph::DepGraph; +use rustc_middle::hooks; use rustc_middle::query::{ExternProviders, Providers}; use rustc_middle::ty::{self, GlobalCtxt, RegisteredTools, TyCtxt}; use rustc_mir_build as mir_build; @@ -645,15 +646,16 @@ fn output_filenames(tcx: TyCtxt<'_>, (): ()) -> Arc { outputs.into() } -pub static DEFAULT_QUERY_PROVIDERS: LazyLock = LazyLock::new(|| { +pub static DEFAULT_QUERY_PROVIDERS: LazyLock<(Providers, hooks::Providers)> = LazyLock::new(|| { let providers = &mut Providers::default(); + let hooks = &mut hooks::Providers::default(); providers.analysis = analysis; providers.hir_crate = rustc_ast_lowering::lower_to_hir; providers.output_filenames = output_filenames; providers.resolver_for_lowering = resolver_for_lowering; providers.early_lint_checks = early_lint_checks; proc_macro_decls::provide(providers); - rustc_const_eval::provide(providers); + rustc_const_eval::provide(providers, hooks); rustc_middle::hir::provide(providers); mir_borrowck::provide(providers); mir_build::provide(providers); @@ -672,7 +674,7 @@ pub static DEFAULT_QUERY_PROVIDERS: LazyLock = LazyLock::new(|| { rustc_lint::provide(providers); rustc_symbol_mangling::provide(providers); rustc_codegen_ssa::provide(providers); - *providers + (*providers, *hooks) }); pub static DEFAULT_EXTERN_QUERY_PROVIDERS: LazyLock = LazyLock::new(|| { @@ -702,8 +704,8 @@ pub fn create_global_ctxt<'tcx>( let query_result_on_disk_cache = rustc_incremental::load_query_result_cache(sess); let codegen_backend = compiler.codegen_backend(); - let mut local_providers = *DEFAULT_QUERY_PROVIDERS; - codegen_backend.provide(&mut local_providers); + let (mut local_providers, mut hooks) = *DEFAULT_QUERY_PROVIDERS; + codegen_backend.provide(&mut local_providers, &mut hooks); let mut extern_providers = *DEFAULT_EXTERN_QUERY_PROVIDERS; codegen_backend.provide_extern(&mut extern_providers); @@ -732,6 +734,7 @@ pub fn create_global_ctxt<'tcx>( query_result_on_disk_cache, incremental, ), + hooks, ) }) }) diff --git a/compiler/rustc_middle/src/hooks/mod.rs b/compiler/rustc_middle/src/hooks/mod.rs new file mode 100644 index 00000000000..cb84a5936b3 --- /dev/null +++ b/compiler/rustc_middle/src/hooks/mod.rs @@ -0,0 +1,64 @@ +use crate::mir; +use crate::query::TyCtxtAt; +use crate::ty::{Ty, TyCtxt}; +use rustc_span::DUMMY_SP; + +macro_rules! declare_hooks { + ($($(#[$attr:meta])*hook $name:ident($($arg:ident: $K:ty),*) -> $V:ty;)*) => { + + impl<'tcx> TyCtxt<'tcx> { + $( + $(#[$attr])* + #[inline(always)] + #[must_use] + pub fn $name(self, $($arg: $K,)*) -> $V + { + self.at(DUMMY_SP).$name($($arg,)*) + } + )* + } + + impl<'tcx> TyCtxtAt<'tcx> { + $( + $(#[$attr])* + #[inline(always)] + #[must_use] + pub fn $name(self, $($arg: $K,)*) -> $V + { + (self.tcx.hooks.$name)(self, $($arg,)*) + } + )* + } + + pub struct Providers { + $(pub $name: for<'tcx> fn( + TyCtxtAt<'tcx>, + $($arg: $K,)* + ) -> $V,)* + } + + impl Default for Providers { + fn default() -> Self { + Providers { + $($name: |_, $($arg,)*| bug!( + "`tcx.{}{:?}` cannot be called as `{}` was never assigned to a provider function.\n", + stringify!($name), + ($($arg,)*), + stringify!($name), + ),)* + } + } + } + + impl Copy for Providers {} + impl Clone for Providers { + fn clone(&self) -> Self { *self } + } + }; +} + +declare_hooks! { + /// Tries to destructure an `mir::Const` ADT or array into its variant index + /// and its field values. This should only be used for pretty printing. + hook try_destructure_mir_constant_for_diagnostics(val: mir::ConstValue<'tcx>, ty: Ty<'tcx>) -> Option>; +} diff --git a/compiler/rustc_middle/src/lib.rs b/compiler/rustc_middle/src/lib.rs index 50b69181d67..fe4fc3761b3 100644 --- a/compiler/rustc_middle/src/lib.rs +++ b/compiler/rustc_middle/src/lib.rs @@ -89,6 +89,7 @@ mod macros; pub mod arena; pub mod error; pub mod hir; +pub mod hooks; pub mod infer; pub mod lint; pub mod metadata; diff --git a/compiler/rustc_middle/src/mir/pretty.rs b/compiler/rustc_middle/src/mir/pretty.rs index cc2a5aa62c8..8488367189f 100644 --- a/compiler/rustc_middle/src/mir/pretty.rs +++ b/compiler/rustc_middle/src/mir/pretty.rs @@ -1691,7 +1691,7 @@ fn pretty_print_const_value_tcx<'tcx>( (_, ty::Array(..) | ty::Tuple(..) | ty::Adt(..)) if !ty.has_non_region_param() => { let ct = tcx.lift(ct).unwrap(); let ty = tcx.lift(ty).unwrap(); - if let Some(contents) = tcx.try_destructure_mir_constant_for_diagnostics((ct, ty)) { + if let Some(contents) = tcx.try_destructure_mir_constant_for_diagnostics(ct, ty) { let fields: Vec<(ConstValue<'_>, Ty<'_>)> = contents.fields.to_vec(); match *ty.kind() { ty::Array(..) => { diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs index d888a2c0fb6..6928f59c3fd 100644 --- a/compiler/rustc_middle/src/query/mod.rs +++ b/compiler/rustc_middle/src/query/mod.rs @@ -1100,16 +1100,6 @@ rustc_queries! { desc { "destructuring type level constant"} } - /// Tries to destructure an `mir::Const` ADT or array into its variant index - /// and its field values. This should only be used for pretty printing. - query try_destructure_mir_constant_for_diagnostics( - key: (mir::ConstValue<'tcx>, Ty<'tcx>) - ) -> Option> { - desc { "destructuring MIR constant"} - no_hash - eval_always - } - query const_caller_location(key: (rustc_span::Symbol, u32, u32)) -> mir::ConstValue<'tcx> { desc { "getting a &core::panic::Location referring to a span" } } diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 9ff4b64f48b..25eafce0d9e 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -554,6 +554,10 @@ pub struct GlobalCtxt<'tcx> { /// Common consts, pre-interned for your convenience. pub consts: CommonConsts<'tcx>, + /// Hooks to be able to register functions in other crates that can then still + /// be called from rustc_middle. + pub(crate) hooks: crate::hooks::Providers, + untracked: Untracked, pub query_system: QuerySystem<'tcx>, @@ -703,6 +707,7 @@ impl<'tcx> TyCtxt<'tcx> { dep_graph: DepGraph, query_kinds: &'tcx [DepKindStruct<'tcx>], query_system: QuerySystem<'tcx>, + hooks: crate::hooks::Providers, ) -> GlobalCtxt<'tcx> { let data_layout = s.target.parse_data_layout().unwrap_or_else(|err| { s.emit_fatal(err); @@ -721,6 +726,7 @@ impl<'tcx> TyCtxt<'tcx> { hir_arena, interners, dep_graph, + hooks, prof: s.prof.clone(), types: common_types, lifetimes: common_lifetimes, diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 7cd25ef444b..cc4d4fd11fa 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -286,7 +286,7 @@ pub(crate) fn create_config( let body = hir.body(hir.body_owned_by(def_id)); debug!("visiting body for {def_id:?}"); EmitIgnoredResolutionErrors::new(tcx).visit_body(body); - (rustc_interface::DEFAULT_QUERY_PROVIDERS.typeck)(tcx, def_id) + (rustc_interface::DEFAULT_QUERY_PROVIDERS.0.typeck)(tcx, def_id) }; }), make_codegen_backend: None, diff --git a/src/tools/clippy/clippy_utils/src/consts.rs b/src/tools/clippy/clippy_utils/src/consts.rs index a136de86240..6b1a738aaa9 100644 --- a/src/tools/clippy/clippy_utils/src/consts.rs +++ b/src/tools/clippy/clippy_utils/src/consts.rs @@ -718,7 +718,7 @@ fn field_of_struct<'tcx>( field: &Ident, ) -> Option> { if let mir::Const::Val(result, ty) = result - && let Some(dc) = lcx.tcx.try_destructure_mir_constant_for_diagnostics((result, ty)) + && let Some(dc) = lcx.tcx.try_destructure_mir_constant_for_diagnostics(result, ty) && let Some(dc_variant) = dc.variant && let Some(variant) = adt_def.variants().get(dc_variant) && let Some(field_idx) = variant.fields.iter().position(|el| el.name == field.name) From 9defc971f1e059e139e8719661560de4741a128e Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Fri, 22 Sep 2023 09:25:38 +0000 Subject: [PATCH 03/30] Add tracing instrumentation, just like queries automatically add it --- compiler/rustc_middle/src/hooks/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/rustc_middle/src/hooks/mod.rs b/compiler/rustc_middle/src/hooks/mod.rs index cb84a5936b3..12aeae17725 100644 --- a/compiler/rustc_middle/src/hooks/mod.rs +++ b/compiler/rustc_middle/src/hooks/mod.rs @@ -23,6 +23,7 @@ macro_rules! declare_hooks { $(#[$attr])* #[inline(always)] #[must_use] + #[instrument(level = "debug", skip(self), ret)] pub fn $name(self, $($arg: $K,)*) -> $V { (self.tcx.hooks.$name)(self, $($arg,)*) From 2ba911c8329a4a8b6697cc6a25c02f0f06d58d8d Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Fri, 22 Sep 2023 16:26:20 +0000 Subject: [PATCH 04/30] Have a single struct for queries and hook --- compiler/rustc_codegen_gcc/src/lib.rs | 5 ++-- compiler/rustc_codegen_llvm/src/lib.rs | 5 ++-- .../rustc_codegen_ssa/src/traits/backend.rs | 6 ++--- compiler/rustc_const_eval/src/lib.rs | 7 +++--- compiler/rustc_interface/src/interface.rs | 3 ++- compiler/rustc_interface/src/passes.rs | 21 ++++++++--------- compiler/rustc_middle/src/util/mod.rs | 23 +++++++++++++++++++ src/librustdoc/core.rs | 2 +- 8 files changed, 46 insertions(+), 26 deletions(-) diff --git a/compiler/rustc_codegen_gcc/src/lib.rs b/compiler/rustc_codegen_gcc/src/lib.rs index 1567fea3e1c..ce7e31682f1 100644 --- a/compiler/rustc_codegen_gcc/src/lib.rs +++ b/compiler/rustc_codegen_gcc/src/lib.rs @@ -80,9 +80,8 @@ use rustc_errors::{DiagnosticMessage, ErrorGuaranteed, Handler, SubdiagnosticMes use rustc_fluent_macro::fluent_messages; use rustc_metadata::EncodedMetadata; use rustc_middle::dep_graph::{WorkProduct, WorkProductId}; -use rustc_middle::query::Providers; +use rustc_middle::util::Providers; use rustc_middle::ty::TyCtxt; -use rustc_middle::hooks; use rustc_session::config::{Lto, OptLevel, OutputFilenames}; use rustc_session::Session; use rustc_span::Symbol; @@ -128,7 +127,7 @@ impl CodegenBackend for GccCodegenBackend { *self.supports_128bit_integers.lock().expect("lock") = check_context.get_last_error() == Ok(None); } - fn provide(&self, providers: &mut Providers, _: &mut hooks::Providers) { + fn provide(&self, providers: &mut Providers) { // FIXME(antoyo) compute list of enabled features from cli flags providers.global_backend_features = |_tcx, ()| vec![]; } diff --git a/compiler/rustc_codegen_llvm/src/lib.rs b/compiler/rustc_codegen_llvm/src/lib.rs index 0f2acfd30f7..fe87446f5c3 100644 --- a/compiler/rustc_codegen_llvm/src/lib.rs +++ b/compiler/rustc_codegen_llvm/src/lib.rs @@ -39,9 +39,8 @@ use rustc_errors::{DiagnosticMessage, ErrorGuaranteed, FatalError, Handler, Subd use rustc_fluent_macro::fluent_messages; use rustc_metadata::EncodedMetadata; use rustc_middle::dep_graph::{WorkProduct, WorkProductId}; -use rustc_middle::hooks; -use rustc_middle::query::Providers; use rustc_middle::ty::TyCtxt; +use rustc_middle::util::Providers; use rustc_session::config::{OptLevel, OutputFilenames, PrintKind, PrintRequest}; use rustc_session::Session; use rustc_span::symbol::Symbol; @@ -269,7 +268,7 @@ impl CodegenBackend for LlvmCodegenBackend { llvm_util::init(sess); // Make sure llvm is inited } - fn provide(&self, providers: &mut Providers, _hooks: &mut hooks::Providers) { + fn provide(&self, providers: &mut Providers) { providers.global_backend_features = |tcx, ()| llvm_util::global_llvm_features(tcx.sess, true) } diff --git a/compiler/rustc_codegen_ssa/src/traits/backend.rs b/compiler/rustc_codegen_ssa/src/traits/backend.rs index e00243075b9..23325ba9fa9 100644 --- a/compiler/rustc_codegen_ssa/src/traits/backend.rs +++ b/compiler/rustc_codegen_ssa/src/traits/backend.rs @@ -11,10 +11,10 @@ use rustc_data_structures::sync::{DynSend, DynSync}; use rustc_errors::ErrorGuaranteed; use rustc_metadata::EncodedMetadata; use rustc_middle::dep_graph::{WorkProduct, WorkProductId}; -use rustc_middle::hooks; -use rustc_middle::query::{ExternProviders, Providers}; +use rustc_middle::query::ExternProviders; use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt, LayoutOf, TyAndLayout}; use rustc_middle::ty::{Ty, TyCtxt}; +use rustc_middle::util::Providers; use rustc_session::{ config::{self, OutputFilenames, PrintRequest}, cstore::MetadataLoaderDyn, @@ -85,7 +85,7 @@ pub trait CodegenBackend { Box::new(crate::back::metadata::DefaultMetadataLoader) } - fn provide(&self, _providers: &mut Providers, _hooks: &mut hooks::Providers) {} + fn provide(&self, _providers: &mut Providers) {} fn provide_extern(&self, _providers: &mut ExternProviders) {} fn codegen_crate<'tcx>( &self, diff --git a/compiler/rustc_const_eval/src/lib.rs b/compiler/rustc_const_eval/src/lib.rs index 8ac2b519760..8bb409cea08 100644 --- a/compiler/rustc_const_eval/src/lib.rs +++ b/compiler/rustc_const_eval/src/lib.rs @@ -38,12 +38,11 @@ pub use errors::ReportErrorExt; use rustc_errors::{DiagnosticMessage, SubdiagnosticMessage}; use rustc_fluent_macro::fluent_messages; -use rustc_middle::query::Providers; -use rustc_middle::{hooks, ty}; +use rustc_middle::{ty, util::Providers}; fluent_messages! { "../messages.ftl" } -pub fn provide(providers: &mut Providers, hooks: &mut hooks::Providers) { +pub fn provide(providers: &mut Providers) { const_eval::provide(providers); providers.eval_to_const_value_raw = const_eval::eval_to_const_value_raw_provider; providers.eval_to_allocation_raw = const_eval::eval_to_allocation_raw_provider; @@ -52,7 +51,7 @@ pub fn provide(providers: &mut Providers, hooks: &mut hooks::Providers) { let (param_env, raw) = param_env_and_value.into_parts(); const_eval::eval_to_valtree(tcx, param_env, raw) }; - hooks.try_destructure_mir_constant_for_diagnostics = + providers.hooks.try_destructure_mir_constant_for_diagnostics = const_eval::try_destructure_mir_constant_for_diagnostics; providers.valtree_to_const_val = |tcx, (ty, valtree)| { const_eval::valtree_to_const_value(tcx, ty::ParamEnv::empty().and(ty), valtree) diff --git a/compiler/rustc_interface/src/interface.rs b/compiler/rustc_interface/src/interface.rs index a0f0b530bae..048d2259187 100644 --- a/compiler/rustc_interface/src/interface.rs +++ b/compiler/rustc_interface/src/interface.rs @@ -9,7 +9,8 @@ use rustc_data_structures::sync::Lrc; use rustc_errors::registry::Registry; use rustc_errors::{ErrorGuaranteed, Handler}; use rustc_lint::LintStore; -use rustc_middle::query::{ExternProviders, Providers}; +use rustc_middle::query::ExternProviders; +use rustc_middle::util::Providers; use rustc_middle::{bug, ty}; use rustc_parse::maybe_new_parser_from_source_str; use rustc_query_impl::QueryCtxt; diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index 6de7686fbd9..d147d579fee 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -18,9 +18,9 @@ use rustc_lint::{unerased_lint_store, BufferedEarlyLint, EarlyCheckNode, LintSto use rustc_metadata::creader::CStore; use rustc_middle::arena::Arena; use rustc_middle::dep_graph::DepGraph; -use rustc_middle::hooks; -use rustc_middle::query::{ExternProviders, Providers}; +use rustc_middle::query::ExternProviders; use rustc_middle::ty::{self, GlobalCtxt, RegisteredTools, TyCtxt}; +use rustc_middle::util::Providers; use rustc_mir_build as mir_build; use rustc_parse::{parse_crate_from_file, parse_crate_from_source_str, validate_attr}; use rustc_passes::{self, abi_test, hir_stats, layout_test}; @@ -646,16 +646,15 @@ fn output_filenames(tcx: TyCtxt<'_>, (): ()) -> Arc { outputs.into() } -pub static DEFAULT_QUERY_PROVIDERS: LazyLock<(Providers, hooks::Providers)> = LazyLock::new(|| { +pub static DEFAULT_QUERY_PROVIDERS: LazyLock = LazyLock::new(|| { let providers = &mut Providers::default(); - let hooks = &mut hooks::Providers::default(); providers.analysis = analysis; providers.hir_crate = rustc_ast_lowering::lower_to_hir; providers.output_filenames = output_filenames; providers.resolver_for_lowering = resolver_for_lowering; providers.early_lint_checks = early_lint_checks; proc_macro_decls::provide(providers); - rustc_const_eval::provide(providers, hooks); + rustc_const_eval::provide(providers); rustc_middle::hir::provide(providers); mir_borrowck::provide(providers); mir_build::provide(providers); @@ -674,7 +673,7 @@ pub static DEFAULT_QUERY_PROVIDERS: LazyLock<(Providers, hooks::Providers)> = La rustc_lint::provide(providers); rustc_symbol_mangling::provide(providers); rustc_codegen_ssa::provide(providers); - (*providers, *hooks) + *providers }); pub static DEFAULT_EXTERN_QUERY_PROVIDERS: LazyLock = LazyLock::new(|| { @@ -704,14 +703,14 @@ pub fn create_global_ctxt<'tcx>( let query_result_on_disk_cache = rustc_incremental::load_query_result_cache(sess); let codegen_backend = compiler.codegen_backend(); - let (mut local_providers, mut hooks) = *DEFAULT_QUERY_PROVIDERS; - codegen_backend.provide(&mut local_providers, &mut hooks); + let mut providers = *DEFAULT_QUERY_PROVIDERS; + codegen_backend.provide(&mut providers); let mut extern_providers = *DEFAULT_EXTERN_QUERY_PROVIDERS; codegen_backend.provide_extern(&mut extern_providers); if let Some(callback) = compiler.override_queries { - callback(sess, &mut local_providers, &mut extern_providers); + callback(sess, &mut providers, &mut extern_providers); } let incremental = dep_graph.is_fully_enabled(); @@ -729,12 +728,12 @@ pub fn create_global_ctxt<'tcx>( dep_graph, rustc_query_impl::query_callbacks(arena), rustc_query_impl::query_system( - local_providers, + providers.queries, extern_providers, query_result_on_disk_cache, incremental, ), - hooks, + providers.hooks, ) }) }) diff --git a/compiler/rustc_middle/src/util/mod.rs b/compiler/rustc_middle/src/util/mod.rs index 53b4257899b..271b3dcb6dc 100644 --- a/compiler/rustc_middle/src/util/mod.rs +++ b/compiler/rustc_middle/src/util/mod.rs @@ -5,3 +5,26 @@ pub mod find_self_call; pub use call_kind::{call_kind, CallDesugaringKind, CallKind}; pub use find_self_call::find_self_call; + +#[derive(Default, Copy, Clone)] +pub struct Providers { + pub queries: rustc_middle::query::Providers, + pub hooks: rustc_middle::hooks::Providers, +} + +/// Backwards compatibility hack to keep the diff small. This +/// gives direct access to the `queries` field's fields, which +/// are what almost everything wants access to. +impl std::ops::DerefMut for Providers { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.queries + } +} + +impl std::ops::Deref for Providers { + type Target = rustc_middle::query::Providers; + + fn deref(&self) -> &Self::Target { + &self.queries + } +} diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index cc4d4fd11fa..7cd25ef444b 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -286,7 +286,7 @@ pub(crate) fn create_config( let body = hir.body(hir.body_owned_by(def_id)); debug!("visiting body for {def_id:?}"); EmitIgnoredResolutionErrors::new(tcx).visit_body(body); - (rustc_interface::DEFAULT_QUERY_PROVIDERS.0.typeck)(tcx, def_id) + (rustc_interface::DEFAULT_QUERY_PROVIDERS.typeck)(tcx, def_id) }; }), make_codegen_backend: None, From 8cfd249198dd0e04558d725452b91f4db3984633 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Fri, 22 Sep 2023 19:47:34 +0000 Subject: [PATCH 05/30] Allow higher-ranked fn sigs in ValuePairs --- .../src/check/compare_impl_item.rs | 5 +++- compiler/rustc_hir_analysis/src/check/mod.rs | 11 ++++----- compiler/rustc_infer/src/infer/at.rs | 23 ++++++++++++++++++- .../src/infer/error_reporting/mod.rs | 9 +++----- .../trait_impl_difference.rs | 6 ++--- compiler/rustc_infer/src/infer/mod.rs | 2 +- compiler/rustc_passes/src/check_attr.rs | 5 +++- .../panic-handler-bad-signature-1.stderr | 4 ++-- .../panic-handler-bad-signature-2.stderr | 4 ++-- .../panic-handler-bad-signature-3.stderr | 2 +- .../panic-handler-bad-signature-5.stderr | 4 ++-- 11 files changed, 48 insertions(+), 27 deletions(-) diff --git a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs index 7be18a36d63..ba58f0d57ad 100644 --- a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs +++ b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs @@ -1134,7 +1134,10 @@ fn report_trait_method_mismatch<'tcx>( &mut diag, &cause, trait_err_span.map(|sp| (sp, Cow::from("type in trait"))), - Some(infer::ValuePairs::Sigs(ExpectedFound { expected: trait_sig, found: impl_sig })), + Some(infer::ValuePairs::PolySigs(ExpectedFound { + expected: ty::Binder::dummy(trait_sig), + found: ty::Binder::dummy(impl_sig), + })), terr, false, false, diff --git a/compiler/rustc_hir_analysis/src/check/mod.rs b/compiler/rustc_hir_analysis/src/check/mod.rs index 0cf3cee66b5..88c98fa979e 100644 --- a/compiler/rustc_hir_analysis/src/check/mod.rs +++ b/compiler/rustc_hir_analysis/src/check/mod.rs @@ -573,10 +573,7 @@ pub fn check_function_signature<'tcx>( let norm_cause = ObligationCause::misc(cause.span, local_id); let actual_sig = ocx.normalize(&norm_cause, param_env, actual_sig); - let expected_ty = Ty::new_fn_ptr(tcx, expected_sig); - let actual_ty = Ty::new_fn_ptr(tcx, actual_sig); - - match ocx.eq(&cause, param_env, expected_ty, actual_ty) { + match ocx.eq(&cause, param_env, expected_sig, actual_sig) { Ok(()) => { let errors = ocx.select_all_or_error(); if !errors.is_empty() { @@ -595,9 +592,9 @@ pub fn check_function_signature<'tcx>( &mut diag, &cause, None, - Some(infer::ValuePairs::Sigs(ExpectedFound { - expected: tcx.liberate_late_bound_regions(fn_id, expected_sig), - found: tcx.liberate_late_bound_regions(fn_id, actual_sig), + Some(infer::ValuePairs::PolySigs(ExpectedFound { + expected: expected_sig, + found: actual_sig, })), err, false, diff --git a/compiler/rustc_infer/src/infer/at.rs b/compiler/rustc_infer/src/infer/at.rs index 6d5db3336cf..2797d079761 100644 --- a/compiler/rustc_infer/src/infer/at.rs +++ b/compiler/rustc_infer/src/infer/at.rs @@ -478,7 +478,28 @@ impl<'tcx> ToTrace<'tcx> for ty::FnSig<'tcx> { a: Self, b: Self, ) -> TypeTrace<'tcx> { - TypeTrace { cause: cause.clone(), values: Sigs(ExpectedFound::new(a_is_expected, a, b)) } + TypeTrace { + cause: cause.clone(), + values: PolySigs(ExpectedFound::new( + a_is_expected, + ty::Binder::dummy(a), + ty::Binder::dummy(b), + )), + } + } +} + +impl<'tcx> ToTrace<'tcx> for ty::PolyFnSig<'tcx> { + fn to_trace( + cause: &ObligationCause<'tcx>, + a_is_expected: bool, + a: Self, + b: Self, + ) -> TypeTrace<'tcx> { + TypeTrace { + cause: cause.clone(), + values: PolySigs(ExpectedFound::new(a_is_expected, a, b)), + } } } diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs index 1beb13cb94c..e418864026f 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs @@ -1660,7 +1660,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { _ => (false, Mismatch::Fixed("type")), } } - ValuePairs::Sigs(infer::ExpectedFound { expected, found }) => { + ValuePairs::PolySigs(infer::ExpectedFound { expected, found }) => { OpaqueTypesVisitor::visit_expected_found(self.tcx, expected, found, span) .report(diag); (false, Mismatch::Fixed("signature")) @@ -2232,15 +2232,12 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { ret => ret, } } - infer::Sigs(exp_found) => { + infer::PolySigs(exp_found) => { let exp_found = self.resolve_vars_if_possible(exp_found); if exp_found.references_error() { return None; } - let (exp, fnd) = self.cmp_fn_sig( - &ty::Binder::dummy(exp_found.expected), - &ty::Binder::dummy(exp_found.found), - ); + let (exp, fnd) = self.cmp_fn_sig(&exp_found.expected, &exp_found.found); Some((exp, fnd, None, None)) } } diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/trait_impl_difference.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/trait_impl_difference.rs index d2ba9966f03..cb51254a14b 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/trait_impl_difference.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/trait_impl_difference.rs @@ -35,14 +35,14 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { && let (Subtype(sup_trace), Subtype(sub_trace)) = (&sup_origin, &sub_origin) && let CompareImplItemObligation { trait_item_def_id, .. } = sub_trace.cause.code() && sub_trace.values == sup_trace.values - && let ValuePairs::Sigs(ExpectedFound { expected, found }) = sub_trace.values + && let ValuePairs::PolySigs(ExpectedFound { expected, found }) = sub_trace.values { // FIXME(compiler-errors): Don't like that this needs `Ty`s, but // all of the region highlighting machinery only deals with those. let guar = self.emit_err( var_origin.span(), - Ty::new_fn_ptr(self.cx.tcx,ty::Binder::dummy(expected)), - Ty::new_fn_ptr(self.cx.tcx,ty::Binder::dummy(found)), + Ty::new_fn_ptr(self.cx.tcx, expected), + Ty::new_fn_ptr(self.cx.tcx, found), *trait_item_def_id, ); return Some(guar); diff --git a/compiler/rustc_infer/src/infer/mod.rs b/compiler/rustc_infer/src/infer/mod.rs index 4cf9d44ed65..aeb3177af02 100644 --- a/compiler/rustc_infer/src/infer/mod.rs +++ b/compiler/rustc_infer/src/infer/mod.rs @@ -383,7 +383,7 @@ pub enum ValuePairs<'tcx> { Aliases(ExpectedFound>), TraitRefs(ExpectedFound>), PolyTraitRefs(ExpectedFound>), - Sigs(ExpectedFound>), + PolySigs(ExpectedFound>), ExistentialTraitRef(ExpectedFound>), ExistentialProjection(ExpectedFound>), } diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index 12118a0268b..afba366a365 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -2333,7 +2333,10 @@ impl CheckAttrVisitor<'_> { &mut diag, &cause, None, - Some(ValuePairs::Sigs(ExpectedFound { expected: expected_sig, found: sig })), + Some(ValuePairs::PolySigs(ExpectedFound { + expected: ty::Binder::dummy(expected_sig), + found: ty::Binder::dummy(sig), + })), terr, false, false, diff --git a/tests/ui/panic-handler/panic-handler-bad-signature-1.stderr b/tests/ui/panic-handler/panic-handler-bad-signature-1.stderr index d12bfbf269e..85555c43906 100644 --- a/tests/ui/panic-handler/panic-handler-bad-signature-1.stderr +++ b/tests/ui/panic-handler/panic-handler-bad-signature-1.stderr @@ -4,8 +4,8 @@ error[E0308]: `#[panic_handler]` function has wrong type LL | fn panic(info: PanicInfo) -> () {} | ^^^^^^^^^ expected `&PanicInfo<'_>`, found `PanicInfo<'_>` | - = note: expected signature `fn(&PanicInfo<'_>) -> !` - found signature `fn(PanicInfo<'_>)` + = note: expected signature `for<'a, 'b> fn(&'a PanicInfo<'b>) -> !` + found signature `for<'a> fn(PanicInfo<'a>)` error: aborting due to previous error diff --git a/tests/ui/panic-handler/panic-handler-bad-signature-2.stderr b/tests/ui/panic-handler/panic-handler-bad-signature-2.stderr index 06e32d5fb84..84eba2a5a63 100644 --- a/tests/ui/panic-handler/panic-handler-bad-signature-2.stderr +++ b/tests/ui/panic-handler/panic-handler-bad-signature-2.stderr @@ -4,8 +4,8 @@ error[E0308]: `#[panic_handler]` function has wrong type LL | fn panic(info: &'static PanicInfo) -> ! | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other | - = note: expected fn pointer `for<'a, 'b> fn(&'a PanicInfo<'b>) -> _` - found fn pointer `for<'a> fn(&'static PanicInfo<'a>) -> _` + = note: expected signature `for<'a, 'b> fn(&'a PanicInfo<'b>) -> _` + found signature `for<'a> fn(&'static PanicInfo<'a>) -> _` error: aborting due to previous error diff --git a/tests/ui/panic-handler/panic-handler-bad-signature-3.stderr b/tests/ui/panic-handler/panic-handler-bad-signature-3.stderr index 8365f5769eb..cdf55ab6534 100644 --- a/tests/ui/panic-handler/panic-handler-bad-signature-3.stderr +++ b/tests/ui/panic-handler/panic-handler-bad-signature-3.stderr @@ -4,7 +4,7 @@ error[E0308]: `#[panic_handler]` function has wrong type LL | fn panic() -> ! { | ^^^^^^^^^^^^^^^ incorrect number of function parameters | - = note: expected signature `fn(&PanicInfo<'_>) -> _` + = note: expected signature `for<'a, 'b> fn(&'a PanicInfo<'b>) -> _` found signature `fn() -> _` error: aborting due to previous error diff --git a/tests/ui/panic-handler/panic-handler-bad-signature-5.stderr b/tests/ui/panic-handler/panic-handler-bad-signature-5.stderr index 22b8d5ca811..20c17587590 100644 --- a/tests/ui/panic-handler/panic-handler-bad-signature-5.stderr +++ b/tests/ui/panic-handler/panic-handler-bad-signature-5.stderr @@ -4,8 +4,8 @@ error[E0308]: `#[panic_handler]` function has wrong type LL | fn panic(info: &PanicInfo<'static>) -> ! | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other | - = note: expected fn pointer `for<'a, 'b> fn(&'a PanicInfo<'b>) -> _` - found fn pointer `for<'a> fn(&'a PanicInfo<'static>) -> _` + = note: expected signature `for<'a, 'b> fn(&'a PanicInfo<'b>) -> _` + found signature `for<'a> fn(&'a PanicInfo<'static>) -> _` error: aborting due to previous error From 4ed4913e67cab329bd3cca92dff1cf558cc3575e Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Fri, 22 Sep 2023 16:38:31 +0000 Subject: [PATCH 06/30] Merge `ExternProviders` into the general `Providers` struct --- .../rustc_codegen_ssa/src/back/symbol_export.rs | 10 ++++------ compiler/rustc_codegen_ssa/src/lib.rs | 6 +----- compiler/rustc_codegen_ssa/src/traits/backend.rs | 2 -- compiler/rustc_interface/src/interface.rs | 5 ++--- compiler/rustc_interface/src/lib.rs | 2 +- compiler/rustc_interface/src/passes.rs | 15 ++------------- compiler/rustc_metadata/src/lib.rs | 2 +- compiler/rustc_metadata/src/rmeta/decoder.rs | 1 - .../src/rmeta/decoder/cstore_impl.rs | 10 ++++++---- compiler/rustc_metadata/src/rmeta/mod.rs | 3 +-- compiler/rustc_middle/src/util/mod.rs | 1 + src/librustdoc/core.rs | 2 +- src/tools/miri/src/bin/miri.rs | 15 ++++++++------- tests/run-make-fulldeps/obtain-borrowck/driver.rs | 4 ++-- 14 files changed, 30 insertions(+), 48 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs index 5b869bed0a0..9cd4394108a 100644 --- a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs +++ b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs @@ -11,10 +11,10 @@ use rustc_middle::middle::exported_symbols::{ metadata_symbol_name, ExportedSymbol, SymbolExportInfo, SymbolExportKind, SymbolExportLevel, }; use rustc_middle::query::LocalCrate; -use rustc_middle::query::{ExternProviders, Providers}; use rustc_middle::ty::Instance; use rustc_middle::ty::{self, SymbolName, TyCtxt}; use rustc_middle::ty::{GenericArgKind, GenericArgsRef}; +use rustc_middle::util::Providers; use rustc_session::config::{CrateType, OomStrategy}; use rustc_target::spec::SanitizerSet; @@ -457,11 +457,9 @@ pub fn provide(providers: &mut Providers) { providers.is_unreachable_local_definition = is_unreachable_local_definition_provider; providers.upstream_drop_glue_for = upstream_drop_glue_for_provider; providers.wasm_import_module_map = wasm_import_module_map; -} - -pub fn provide_extern(providers: &mut ExternProviders) { - providers.is_reachable_non_generic = is_reachable_non_generic_provider_extern; - providers.upstream_monomorphizations_for = upstream_monomorphizations_for_provider; + providers.extern_queries.is_reachable_non_generic = is_reachable_non_generic_provider_extern; + providers.extern_queries.upstream_monomorphizations_for = + upstream_monomorphizations_for_provider; } fn symbol_export_level(tcx: TyCtxt<'_>, sym_def_id: DefId) -> SymbolExportLevel { diff --git a/compiler/rustc_codegen_ssa/src/lib.rs b/compiler/rustc_codegen_ssa/src/lib.rs index 7bed3fa6150..7ebaca9b0bc 100644 --- a/compiler/rustc_codegen_ssa/src/lib.rs +++ b/compiler/rustc_codegen_ssa/src/lib.rs @@ -31,7 +31,7 @@ use rustc_middle::dep_graph::WorkProduct; use rustc_middle::middle::debugger_visualizer::DebuggerVisualizerFile; use rustc_middle::middle::dependency_format::Dependencies; use rustc_middle::middle::exported_symbols::SymbolExportKind; -use rustc_middle::query::{ExternProviders, Providers}; +use rustc_middle::util::Providers; use rustc_serialize::opaque::{FileEncoder, MemDecoder}; use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; use rustc_session::config::{CrateType, OutputFilenames, OutputType, RUST_CGU_EXT}; @@ -190,10 +190,6 @@ pub fn provide(providers: &mut Providers) { crate::codegen_attrs::provide(providers); } -pub fn provide_extern(providers: &mut ExternProviders) { - crate::back::symbol_export::provide_extern(providers); -} - /// Checks if the given filename ends with the `.rcgu.o` extension that `rustc` /// uses for the object files it generates. pub fn looks_like_rust_object_file(filename: &str) -> bool { diff --git a/compiler/rustc_codegen_ssa/src/traits/backend.rs b/compiler/rustc_codegen_ssa/src/traits/backend.rs index 23325ba9fa9..ac8123bc1be 100644 --- a/compiler/rustc_codegen_ssa/src/traits/backend.rs +++ b/compiler/rustc_codegen_ssa/src/traits/backend.rs @@ -11,7 +11,6 @@ use rustc_data_structures::sync::{DynSend, DynSync}; use rustc_errors::ErrorGuaranteed; use rustc_metadata::EncodedMetadata; use rustc_middle::dep_graph::{WorkProduct, WorkProductId}; -use rustc_middle::query::ExternProviders; use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt, LayoutOf, TyAndLayout}; use rustc_middle::ty::{Ty, TyCtxt}; use rustc_middle::util::Providers; @@ -86,7 +85,6 @@ pub trait CodegenBackend { } fn provide(&self, _providers: &mut Providers) {} - fn provide_extern(&self, _providers: &mut ExternProviders) {} fn codegen_crate<'tcx>( &self, tcx: TyCtxt<'tcx>, diff --git a/compiler/rustc_interface/src/interface.rs b/compiler/rustc_interface/src/interface.rs index 048d2259187..1c330c064ab 100644 --- a/compiler/rustc_interface/src/interface.rs +++ b/compiler/rustc_interface/src/interface.rs @@ -9,7 +9,6 @@ use rustc_data_structures::sync::Lrc; use rustc_errors::registry::Registry; use rustc_errors::{ErrorGuaranteed, Handler}; use rustc_lint::LintStore; -use rustc_middle::query::ExternProviders; use rustc_middle::util::Providers; use rustc_middle::{bug, ty}; use rustc_parse::maybe_new_parser_from_source_str; @@ -38,7 +37,7 @@ pub struct Compiler { pub(crate) sess: Lrc, codegen_backend: Lrc, pub(crate) register_lints: Option>, - pub(crate) override_queries: Option, + pub(crate) override_queries: Option, } impl Compiler { @@ -272,7 +271,7 @@ pub struct Config { /// the list of queries. /// /// The second parameter is local providers and the third parameter is external providers. - pub override_queries: Option, + pub override_queries: Option, /// This is a callback from the driver that is called to create a codegen backend. pub make_codegen_backend: diff --git a/compiler/rustc_interface/src/lib.rs b/compiler/rustc_interface/src/lib.rs index 51bd8381e93..76131c1ad69 100644 --- a/compiler/rustc_interface/src/lib.rs +++ b/compiler/rustc_interface/src/lib.rs @@ -25,7 +25,7 @@ pub mod util; pub use callbacks::setup_callbacks; pub use interface::{run_compiler, Config}; -pub use passes::{DEFAULT_EXTERN_QUERY_PROVIDERS, DEFAULT_QUERY_PROVIDERS}; +pub use passes::DEFAULT_QUERY_PROVIDERS; pub use queries::Queries; #[cfg(test)] diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index d147d579fee..ce097922aef 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -18,7 +18,6 @@ use rustc_lint::{unerased_lint_store, BufferedEarlyLint, EarlyCheckNode, LintSto use rustc_metadata::creader::CStore; use rustc_middle::arena::Arena; use rustc_middle::dep_graph::DepGraph; -use rustc_middle::query::ExternProviders; use rustc_middle::ty::{self, GlobalCtxt, RegisteredTools, TyCtxt}; use rustc_middle::util::Providers; use rustc_mir_build as mir_build; @@ -676,13 +675,6 @@ pub static DEFAULT_QUERY_PROVIDERS: LazyLock = LazyLock::new(|| { *providers }); -pub static DEFAULT_EXTERN_QUERY_PROVIDERS: LazyLock = LazyLock::new(|| { - let mut extern_providers = ExternProviders::default(); - rustc_metadata::provide_extern(&mut extern_providers); - rustc_codegen_ssa::provide_extern(&mut extern_providers); - extern_providers -}); - pub fn create_global_ctxt<'tcx>( compiler: &'tcx Compiler, crate_types: Vec, @@ -706,11 +698,8 @@ pub fn create_global_ctxt<'tcx>( let mut providers = *DEFAULT_QUERY_PROVIDERS; codegen_backend.provide(&mut providers); - let mut extern_providers = *DEFAULT_EXTERN_QUERY_PROVIDERS; - codegen_backend.provide_extern(&mut extern_providers); - if let Some(callback) = compiler.override_queries { - callback(sess, &mut providers, &mut extern_providers); + callback(sess, &mut providers); } let incremental = dep_graph.is_fully_enabled(); @@ -729,7 +718,7 @@ pub fn create_global_ctxt<'tcx>( rustc_query_impl::query_callbacks(arena), rustc_query_impl::query_system( providers.queries, - extern_providers, + providers.extern_queries, query_result_on_disk_cache, incremental, ), diff --git a/compiler/rustc_metadata/src/lib.rs b/compiler/rustc_metadata/src/lib.rs index 99fef84931e..fa77b36c4c5 100644 --- a/compiler/rustc_metadata/src/lib.rs +++ b/compiler/rustc_metadata/src/lib.rs @@ -26,7 +26,7 @@ extern crate rustc_middle; #[macro_use] extern crate tracing; -pub use rmeta::{provide, provide_extern}; +pub use rmeta::provide; use rustc_errors::{DiagnosticMessage, SubdiagnosticMessage}; use rustc_fluent_macro::fluent_messages; diff --git a/compiler/rustc_metadata/src/rmeta/decoder.rs b/compiler/rustc_metadata/src/rmeta/decoder.rs index a57bff3730d..8ea9c60e4f2 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder.rs @@ -44,7 +44,6 @@ use std::sync::atomic::Ordering; use std::{io, iter, mem}; pub(super) use cstore_impl::provide; -pub use cstore_impl::provide_extern; use rustc_span::hygiene::HygieneDecodeContext; mod cstore_impl; diff --git a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs index e8c2fe5d178..b682a153c77 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs @@ -14,10 +14,11 @@ use rustc_middle::arena::ArenaAllocatable; use rustc_middle::metadata::ModChild; use rustc_middle::middle::exported_symbols::ExportedSymbol; use rustc_middle::middle::stability::DeprecationEntry; +use rustc_middle::query::ExternProviders; use rustc_middle::query::LocalCrate; -use rustc_middle::query::{ExternProviders, Providers}; use rustc_middle::ty::fast_reject::SimplifiedType; use rustc_middle::ty::{self, TyCtxt}; +use rustc_middle::util::Providers; use rustc_session::cstore::CrateStore; use rustc_session::{Session, StableCrateId}; use rustc_span::hygiene::{ExpnHash, ExpnId}; @@ -147,7 +148,7 @@ macro_rules! provide_one { macro_rules! provide { ($tcx:ident, $def_id:ident, $other:ident, $cdata:ident, $($name:ident => { $($compute:tt)* })*) => { - pub fn provide_extern(providers: &mut ExternProviders) { + fn provide_extern(providers: &mut ExternProviders) { $(provide_one! { $tcx, $def_id, $other, $cdata, $name => { $($compute)* } })* @@ -385,7 +386,7 @@ pub(in crate::rmeta) fn provide(providers: &mut Providers) { // FIXME(#44234) - almost all of these queries have no sub-queries and // therefore no actual inputs, they're just reading tables calculated in // resolve! Does this work? Unsure! That's what the issue is about - *providers = Providers { + providers.queries = rustc_middle::query::Providers { allocator_kind: |tcx, ()| CStore::from_tcx(tcx).allocator_kind(), alloc_error_handler_kind: |tcx, ()| CStore::from_tcx(tcx).alloc_error_handler_kind(), is_private_dep: |_tcx, LocalCrate| false, @@ -513,8 +514,9 @@ pub(in crate::rmeta) fn provide(providers: &mut Providers) { tcx.untracked().cstore.freeze(); tcx.arena.alloc_from_iter(CStore::from_tcx(tcx).iter_crate_data().map(|(cnum, _)| cnum)) }, - ..*providers + ..providers.queries }; + provide_extern(&mut providers.extern_queries); } impl CStore { diff --git a/compiler/rustc_metadata/src/rmeta/mod.rs b/compiler/rustc_metadata/src/rmeta/mod.rs index f2875bb11b1..43d5cf43a81 100644 --- a/compiler/rustc_metadata/src/rmeta/mod.rs +++ b/compiler/rustc_metadata/src/rmeta/mod.rs @@ -21,10 +21,10 @@ use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs; use rustc_middle::middle::exported_symbols::{ExportedSymbol, SymbolExportInfo}; use rustc_middle::middle::resolve_bound_vars::ObjectLifetimeDefault; use rustc_middle::mir; -use rustc_middle::query::Providers; use rustc_middle::ty::fast_reject::SimplifiedType; use rustc_middle::ty::{self, ReprOptions, Ty, UnusedGenericParams}; use rustc_middle::ty::{DeducedParamAttrs, GeneratorDiagnosticData, ParameterizedOverTcx, TyCtxt}; +use rustc_middle::util::Providers; use rustc_serialize::opaque::FileEncoder; use rustc_session::config::SymbolManglingVersion; use rustc_session::cstore::{CrateDepKind, ForeignModule, LinkagePreference, NativeLib}; @@ -38,7 +38,6 @@ use rustc_target::spec::{PanicStrategy, TargetTriple}; use std::marker::PhantomData; use std::num::NonZeroUsize; -pub use decoder::provide_extern; use decoder::DecodeContext; pub(crate) use decoder::{CrateMetadata, CrateNumMap, MetadataBlob}; use encoder::EncodeContext; diff --git a/compiler/rustc_middle/src/util/mod.rs b/compiler/rustc_middle/src/util/mod.rs index 271b3dcb6dc..8c95988477d 100644 --- a/compiler/rustc_middle/src/util/mod.rs +++ b/compiler/rustc_middle/src/util/mod.rs @@ -9,6 +9,7 @@ pub use find_self_call::find_self_call; #[derive(Default, Copy, Clone)] pub struct Providers { pub queries: rustc_middle::query::Providers, + pub extern_queries: rustc_middle::query::ExternProviders, pub hooks: rustc_middle::hooks::Providers, } diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 7cd25ef444b..3e6066c78fb 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -263,7 +263,7 @@ pub(crate) fn create_config( lint_caps, parse_sess_created: None, register_lints: Some(Box::new(crate::lint::register_lints)), - override_queries: Some(|_sess, providers, _external_providers| { + override_queries: Some(|_sess, providers| { // We do not register late module lints, so this only runs `MissingDoc`. // Most lints will require typechecking, so just don't run them. providers.lint_mod = |tcx, module_def_id| late_lint_mod(tcx, module_def_id, MissingDoc); diff --git a/src/tools/miri/src/bin/miri.rs b/src/tools/miri/src/bin/miri.rs index 1e9219d4bb2..50f09584475 100644 --- a/src/tools/miri/src/bin/miri.rs +++ b/src/tools/miri/src/bin/miri.rs @@ -28,7 +28,8 @@ use rustc_middle::{ middle::exported_symbols::{ ExportedSymbol, SymbolExportInfo, SymbolExportKind, SymbolExportLevel, }, - query::{ExternProviders, LocalCrate}, + query::{LocalCrate}, + util::Providers, ty::TyCtxt, }; use rustc_session::config::{CrateType, ErrorOutputType, OptLevel}; @@ -43,11 +44,11 @@ struct MiriCompilerCalls { impl rustc_driver::Callbacks for MiriCompilerCalls { fn config(&mut self, config: &mut Config) { - config.override_queries = Some(|_, _, external_providers| { - external_providers.used_crate_source = |tcx, cnum| { - let mut providers = ExternProviders::default(); - rustc_metadata::provide_extern(&mut providers); - let mut crate_source = (providers.used_crate_source)(tcx, cnum); + config.override_queries = Some(|_, providers| { + providers.extern_queries.used_crate_source = |tcx, cnum| { + let mut providers = Providers::default(); + rustc_metadata::provide(&mut providers); + let mut crate_source = (providers.extern_queries.used_crate_source)(tcx, cnum); // HACK: rustc will emit "crate ... required to be available in rlib format, but // was not found in this form" errors once we use `tcx.dependency_formats()` if // there's no rlib provided, so setting a dummy path here to workaround those errors. @@ -125,7 +126,7 @@ impl rustc_driver::Callbacks for MiriBeRustCompilerCalls { if config.opts.prints.is_empty() && self.target_crate { // Queries overridden here affect the data stored in `rmeta` files of dependencies, // which will be used later in non-`MIRI_BE_RUSTC` mode. - config.override_queries = Some(|_, local_providers, _| { + config.override_queries = Some(|_, local_providers| { // `exported_symbols` and `reachable_non_generics` provided by rustc always returns // an empty result if `tcx.sess.opts.output_types.should_codegen()` is false. local_providers.exported_symbols = |tcx, LocalCrate| { diff --git a/tests/run-make-fulldeps/obtain-borrowck/driver.rs b/tests/run-make-fulldeps/obtain-borrowck/driver.rs index b59a65a713f..5df4c558ee1 100644 --- a/tests/run-make-fulldeps/obtain-borrowck/driver.rs +++ b/tests/run-make-fulldeps/obtain-borrowck/driver.rs @@ -25,8 +25,8 @@ use rustc_hir::def_id::LocalDefId; use rustc_interface::interface::Compiler; use rustc_interface::{Config, Queries}; use rustc_middle::query::queries::mir_borrowck::ProvidedValue; -use rustc_middle::query::{ExternProviders, Providers}; use rustc_middle::ty::TyCtxt; +use rustc_middle::util::Providers; use rustc_session::Session; use std::cell::RefCell; use std::collections::HashMap; @@ -110,7 +110,7 @@ impl rustc_driver::Callbacks for CompilerCalls { } } -fn override_queries(_session: &Session, local: &mut Providers, _external: &mut ExternProviders) { +fn override_queries(_session: &Session, local: &mut Providers) { local.mir_borrowck = mir_borrowck; } From d3dea30cb4c2f035ea8621dc266babb3a7be79b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Fri, 22 Sep 2023 18:42:22 +0000 Subject: [PATCH 07/30] Point at cause of expectation of `break` value when possible Fix #115905. --- compiler/rustc_hir_typeck/src/_match.rs | 23 +++++---- compiler/rustc_hir_typeck/src/demand.rs | 62 +++++++++++++++++++++++++ tests/ui/loops/loop-break-value.rs | 3 ++ tests/ui/loops/loop-break-value.stderr | 22 ++++++++- 4 files changed, 100 insertions(+), 10 deletions(-) diff --git a/compiler/rustc_hir_typeck/src/_match.rs b/compiler/rustc_hir_typeck/src/_match.rs index 3319b52e246..81fe0cc489e 100644 --- a/compiler/rustc_hir_typeck/src/_match.rs +++ b/compiler/rustc_hir_typeck/src/_match.rs @@ -2,6 +2,7 @@ use crate::coercion::{AsCoercionSite, CoerceMany}; use crate::{Diverges, Expectation, FnCtxt, Needs}; use rustc_errors::Diagnostic; use rustc_hir::{self as hir, ExprKind}; +use rustc_hir_pretty::ty_to_string; use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind}; use rustc_infer::traits::Obligation; use rustc_middle::ty::{self, Ty}; @@ -252,7 +253,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { { // If this `if` expr is the parent's function return expr, // the cause of the type coercion is the return type, point at it. (#25228) - let ret_reason = self.maybe_get_coercion_reason(then_expr.hir_id, span); + let hir_id = self.tcx.hir().parent_id(self.tcx.hir().parent_id(then_expr.hir_id)); + let ret_reason = self.maybe_get_coercion_reason(hir_id, span); let cause = self.cause(span, ObligationCauseCode::IfExpressionWithNoElse); let mut error = false; coercion.coerce_forced_unit( @@ -275,11 +277,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { error } - fn maybe_get_coercion_reason(&self, hir_id: hir::HirId, sp: Span) -> Option<(Span, String)> { - let node = { - let rslt = self.tcx.hir().parent_id(self.tcx.hir().parent_id(hir_id)); - self.tcx.hir().get(rslt) - }; + pub fn maybe_get_coercion_reason( + &self, + hir_id: hir::HirId, + sp: Span, + ) -> Option<(Span, String)> { + let node = self.tcx.hir().get(hir_id); if let hir::Node::Block(block) = node { // check that the body's parent is an fn let parent = self.tcx.hir().get_parent(self.tcx.hir().parent_id(block.hir_id)); @@ -289,9 +292,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // check that the `if` expr without `else` is the fn body's expr if expr.span == sp { return self.get_fn_decl(hir_id).and_then(|(_, fn_decl, _)| { - let span = fn_decl.output.span(); - let snippet = self.tcx.sess.source_map().span_to_snippet(span).ok()?; - Some((span, format!("expected `{snippet}` because of this return type"))) + let (ty, span) = match fn_decl.output { + hir::FnRetTy::DefaultReturn(span) => ("()".to_string(), span), + hir::FnRetTy::Return(ty) => (ty_to_string(ty), ty.span), + }; + Some((span, format!("expected `{ty}` because of this return type"))) }); } } diff --git a/compiler/rustc_hir_typeck/src/demand.rs b/compiler/rustc_hir_typeck/src/demand.rs index 2c16f21b491..c08629a5269 100644 --- a/compiler/rustc_hir_typeck/src/demand.rs +++ b/compiler/rustc_hir_typeck/src/demand.rs @@ -83,6 +83,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } self.annotate_expected_due_to_let_ty(err, expr, error); + self.annotate_loop_expected_due_to_inference(err, expr, error); // FIXME(#73154): For now, we do leak check when coercing function // pointers in typeck, instead of only during borrowck. This can lead @@ -527,6 +528,67 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { false } + // When encountering a type error on the value of a `break`, try to point at the reason for the + // expected type. + fn annotate_loop_expected_due_to_inference( + &self, + err: &mut Diagnostic, + expr: &hir::Expr<'_>, + error: Option>, + ) { + let Some(TypeError::Sorts(ExpectedFound { expected, .. })) = error else { + return; + }; + let mut parent_id = self.tcx.hir().parent_id(expr.hir_id); + loop { + // Climb the HIR tree to see if the current `Expr` is part of a `break;` statement. + let Some(hir::Node::Expr(parent)) = self.tcx.hir().find(parent_id) else { + break; + }; + parent_id = self.tcx.hir().parent_id(parent.hir_id); + let hir::ExprKind::Break(destination, _) = parent.kind else { + continue; + }; + let mut parent_id = parent.hir_id; + loop { + // Climb the HIR tree to find the (desugared) `loop` this `break` corresponds to. + let parent = match self.tcx.hir().find(parent_id) { + Some(hir::Node::Expr(&ref parent)) => { + parent_id = self.tcx.hir().parent_id(parent.hir_id); + parent + } + Some(hir::Node::Stmt(hir::Stmt { + hir_id, + kind: hir::StmtKind::Semi(&ref parent) | hir::StmtKind::Expr(&ref parent), + .. + })) => { + parent_id = self.tcx.hir().parent_id(*hir_id); + parent + } + Some(hir::Node::Block(hir::Block { .. })) => { + parent_id = self.tcx.hir().parent_id(parent_id); + parent + } + _ => break, + }; + if let hir::ExprKind::Loop(_, label, _, span) = parent.kind + && destination.label == label + { + if let Some((reason_span, message)) = + self.maybe_get_coercion_reason(parent_id, parent.span) + { + err.span_label(reason_span, message); + err.span_label( + span, + format!("this loop is expected to be of type `{expected}`"), + ); + } + break; + } + } + } + } + fn annotate_expected_due_to_let_ty( &self, err: &mut Diagnostic, diff --git a/tests/ui/loops/loop-break-value.rs b/tests/ui/loops/loop-break-value.rs index 51c9a36a039..f334f9d464a 100644 --- a/tests/ui/loops/loop-break-value.rs +++ b/tests/ui/loops/loop-break-value.rs @@ -95,4 +95,7 @@ fn main() { break LOOP; //~^ ERROR cannot find value `LOOP` in this scope } + loop { // point at the return type + break 2; //~ ERROR mismatched types + } } diff --git a/tests/ui/loops/loop-break-value.stderr b/tests/ui/loops/loop-break-value.stderr index 5525dbb9005..76d12b7c1b3 100644 --- a/tests/ui/loops/loop-break-value.stderr +++ b/tests/ui/loops/loop-break-value.stderr @@ -148,12 +148,21 @@ LL | break 123; error[E0308]: mismatched types --> $DIR/loop-break-value.rs:16:15 | +LL | let _: i32 = loop { + | - ---- this loop is expected to be of type `i32` + | | + | expected because of this assignment LL | break "asdf"; | ^^^^^^ expected `i32`, found `&str` error[E0308]: mismatched types --> $DIR/loop-break-value.rs:21:31 | +LL | let _: i32 = 'outer_loop: loop { + | - ---- this loop is expected to be of type `i32` + | | + | expected because of this assignment +LL | loop { LL | break 'outer_loop "nope"; | ^^^^^^ expected `i32`, found `&str` @@ -187,7 +196,18 @@ LL | break; | expected integer, found `()` | help: give it a value of the expected type: `break value` -error: aborting due to 17 previous errors; 1 warning emitted +error[E0308]: mismatched types + --> $DIR/loop-break-value.rs:99:15 + | +LL | fn main() { + | - expected `()` because of this return type +... +LL | loop { // point at the return type + | ---- this loop is expected to be of type `()` +LL | break 2; + | ^ expected `()`, found integer + +error: aborting due to 18 previous errors; 1 warning emitted Some errors have detailed explanations: E0308, E0425, E0571. For more information about an error, try `rustc --explain E0308`. From 82e7cec16d7143907f145c895f7208c0a3906e03 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Sat, 23 Sep 2023 00:56:43 +0000 Subject: [PATCH 08/30] Tweak expected message to explain what it's actually signifying --- .../src/infer/error_reporting/note_and_explain.rs | 10 +++++++--- .../ui/associated-types/defaults-specialization.stderr | 4 ++-- .../specialization/specialization-default-types.stderr | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/compiler/rustc_infer/src/infer/error_reporting/note_and_explain.rs b/compiler/rustc_infer/src/infer/error_reporting/note_and_explain.rs index 445f68160d2..b34900da83b 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/note_and_explain.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/note_and_explain.rs @@ -616,9 +616,13 @@ fn foo(&self) -> Self::T { String::new() } for item in &items[..] { if let hir::AssocItemKind::Type = item.kind { let assoc_ty = tcx.type_of(item.id.owner_id).instantiate_identity(); - - if self.infcx.can_eq(param_env, assoc_ty, found) { - diag.span_label(item.span, "expected this associated type"); + if let hir::Defaultness::Default { has_value: true } = tcx.defaultness(item.id.owner_id) + && self.infcx.can_eq(param_env, assoc_ty, found) + { + diag.span_label( + item.span, + format!("associated type is `default` and may be overridden"), + ); return true; } } diff --git a/tests/ui/associated-types/defaults-specialization.stderr b/tests/ui/associated-types/defaults-specialization.stderr index 7e21f7fc306..7ef433d859f 100644 --- a/tests/ui/associated-types/defaults-specialization.stderr +++ b/tests/ui/associated-types/defaults-specialization.stderr @@ -29,7 +29,7 @@ error[E0053]: method `make` has an incompatible type for trait --> $DIR/defaults-specialization.rs:35:18 | LL | default type Ty = bool; - | ----------------------- expected this associated type + | ----------------------- associated type is `default` and may be overridden LL | LL | fn make() -> bool { true } | ^^^^ @@ -76,7 +76,7 @@ error[E0308]: mismatched types --> $DIR/defaults-specialization.rs:44:29 | LL | default type Ty = bool; - | ----------------------- expected this associated type + | ----------------------- associated type is `default` and may be overridden LL | LL | fn make() -> Self::Ty { true } | -------- ^^^^ expected associated type, found `bool` diff --git a/tests/ui/specialization/specialization-default-types.stderr b/tests/ui/specialization/specialization-default-types.stderr index ecccf29a107..774ac953617 100644 --- a/tests/ui/specialization/specialization-default-types.stderr +++ b/tests/ui/specialization/specialization-default-types.stderr @@ -12,7 +12,7 @@ error[E0308]: mismatched types --> $DIR/specialization-default-types.rs:15:9 | LL | default type Output = Box; - | ----------------------------- expected this associated type + | ----------------------------- associated type is `default` and may be overridden LL | default fn generate(self) -> Self::Output { | ------------ expected `::Output` because of return type LL | Box::new(self) From c4a4926083e9f0b9aeef549f93cb66cd9d4076d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sat, 23 Sep 2023 01:34:50 +0000 Subject: [PATCH 09/30] More accurate suggestion for `self.` and `Self::` Fix #115992. --- .../rustc_resolve/src/late/diagnostics.rs | 17 +++++-- tests/ui/suggestions/assoc_fn_without_self.rs | 8 ++++ .../suggestions/assoc_fn_without_self.stderr | 46 ++++++++++++++++--- 3 files changed, 60 insertions(+), 11 deletions(-) diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index c34b7df9b46..44dba9b7be7 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -224,14 +224,21 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { && let FnKind::Fn(_, _, sig, ..) = fn_kind && let Some(items) = self.diagnostic_metadata.current_impl_items && let Some(item) = items.iter().find(|i| { - if let AssocItemKind::Fn(..) | AssocItemKind::Const(..) = &i.kind - && i.ident.name == item_str.name - // don't suggest if the item is in Fn signature arguments - // issue #112590 + if i.ident.name == item_str.name + // Don't suggest if the item is in Fn signature arguments (#112590). && !sig.span.contains(item_span) { debug!(?item_str.name); - return true + return match &i.kind { + AssocItemKind::Fn(fn_) + if !sig.decl.has_self() && fn_.sig.decl.has_self() => { + // Ensure that we only suggest `self.` if `self` is available, + // you can't call `fn foo(&self)` from `fn bar()` (#115992). + false + } + AssocItemKind::Fn(_) | AssocItemKind::Const(..) => true, + _ => false + } } false }) diff --git a/tests/ui/suggestions/assoc_fn_without_self.rs b/tests/ui/suggestions/assoc_fn_without_self.rs index 778d9847773..35c16ef3e9f 100644 --- a/tests/ui/suggestions/assoc_fn_without_self.rs +++ b/tests/ui/suggestions/assoc_fn_without_self.rs @@ -17,4 +17,12 @@ impl S { bar(); //~ ERROR cannot find function `bar` in this scope baz(2, 3); //~ ERROR cannot find function `baz` in this scope } + fn d(&self) { + fn c() { + foo(); //~ ERROR cannot find function `foo` in this scope + } + foo(); //~ ERROR cannot find function `foo` in this scope + bar(); //~ ERROR cannot find function `bar` in this scope + baz(2, 3); //~ ERROR cannot find function `baz` in this scope + } } diff --git a/tests/ui/suggestions/assoc_fn_without_self.stderr b/tests/ui/suggestions/assoc_fn_without_self.stderr index febdd67338c..a7fab36bf8d 100644 --- a/tests/ui/suggestions/assoc_fn_without_self.stderr +++ b/tests/ui/suggestions/assoc_fn_without_self.stderr @@ -14,11 +14,6 @@ error[E0425]: cannot find function `bar` in this scope | LL | bar(); | ^^^ not found in this scope - | -help: consider using the associated function - | -LL | self.bar(); - | +++++ error[E0425]: cannot find function `baz` in this scope --> $DIR/assoc_fn_without_self.rs:18:9 @@ -37,6 +32,45 @@ error[E0425]: cannot find function `foo` in this scope LL | foo(); | ^^^ not found in this scope -error: aborting due to 4 previous errors +error[E0425]: cannot find function `foo` in this scope + --> $DIR/assoc_fn_without_self.rs:24:9 + | +LL | foo(); + | ^^^ not found in this scope + | +help: consider using the associated function + | +LL | Self::foo(); + | ++++++ + +error[E0425]: cannot find function `bar` in this scope + --> $DIR/assoc_fn_without_self.rs:25:9 + | +LL | bar(); + | ^^^ not found in this scope + | +help: consider using the associated function + | +LL | self.bar(); + | +++++ + +error[E0425]: cannot find function `baz` in this scope + --> $DIR/assoc_fn_without_self.rs:26:9 + | +LL | baz(2, 3); + | ^^^ not found in this scope + | +help: consider using the associated function + | +LL | Self::baz(2, 3); + | ++++++ + +error[E0425]: cannot find function `foo` in this scope + --> $DIR/assoc_fn_without_self.rs:22:13 + | +LL | foo(); + | ^^^ not found in this scope + +error: aborting due to 8 previous errors For more information about this error, try `rustc --explain E0425`. From 0e986825762edd031bc6bf4a78d9162ac2ed6268 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sat, 23 Sep 2023 01:47:06 +0000 Subject: [PATCH 10/30] When encountering method on `Self` that we can't suggest, mention it --- .../rustc_resolve/src/late/diagnostics.rs | 58 +++++++++---------- .../suggestions/assoc_fn_without_self.stderr | 3 + 2 files changed, 31 insertions(+), 30 deletions(-) diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index 44dba9b7be7..c690ac6c043 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -214,6 +214,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { module: None, } } else { + let mut span_label = None; let item_span = path.last().unwrap().ident.span; let (mod_prefix, mod_str, module, suggestion) = if path.len() == 1 { debug!(?self.diagnostic_metadata.current_impl_items); @@ -224,39 +225,36 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { && let FnKind::Fn(_, _, sig, ..) = fn_kind && let Some(items) = self.diagnostic_metadata.current_impl_items && let Some(item) = items.iter().find(|i| { - if i.ident.name == item_str.name + i.ident.name == item_str.name // Don't suggest if the item is in Fn signature arguments (#112590). && !sig.span.contains(item_span) - { - debug!(?item_str.name); - return match &i.kind { - AssocItemKind::Fn(fn_) - if !sig.decl.has_self() && fn_.sig.decl.has_self() => { - // Ensure that we only suggest `self.` if `self` is available, - // you can't call `fn foo(&self)` from `fn bar()` (#115992). - false - } - AssocItemKind::Fn(_) | AssocItemKind::Const(..) => true, - _ => false - } - } - false }) { - let self_sugg = match &item.kind { - AssocItemKind::Fn(fn_) if fn_.sig.decl.has_self() => "self.", - _ => "Self::", - }; - - Some(( - item_span.shrink_to_lo(), - match &item.kind { - AssocItemKind::Fn(..) => "consider using the associated function", - AssocItemKind::Const(..) => "consider using the associated constant", - _ => unreachable!("item kind was filtered above"), - }, - self_sugg.to_string() - )) + let sp = item_span.shrink_to_lo(); + match &item.kind { + AssocItemKind::Fn(fn_) + if !sig.decl.has_self() && fn_.sig.decl.has_self() => { + // Ensure that we only suggest `self.` if `self` is available, + // you can't call `fn foo(&self)` from `fn bar()` (#115992). + // We also want to mention that the method exists. + span_label = Some(( + item.ident.span, + "a method by that name is available on `Self` here", + )); + None + } + AssocItemKind::Fn(fn_) => Some(( + sp, + "consider using the associated function", + if fn_.sig.decl.has_self() { "self." } else { "Self::" }, + )), + AssocItemKind::Const(..) => Some(( + sp, + "consider using the associated constant", + "Self::", + )), + _ => None + } } else { None }; @@ -321,7 +319,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { msg: format!("cannot find {expected} `{item_str}` in {mod_prefix}{mod_str}"), fallback_label, span: item_span, - span_label: None, + span_label, could_be_expr: false, suggestion, module, diff --git a/tests/ui/suggestions/assoc_fn_without_self.stderr b/tests/ui/suggestions/assoc_fn_without_self.stderr index a7fab36bf8d..26fcc2a0181 100644 --- a/tests/ui/suggestions/assoc_fn_without_self.stderr +++ b/tests/ui/suggestions/assoc_fn_without_self.stderr @@ -12,6 +12,9 @@ LL | Self::foo(); error[E0425]: cannot find function `bar` in this scope --> $DIR/assoc_fn_without_self.rs:17:9 | +LL | fn bar(&self) {} + | --- a method by that name is available on `Self` here +... LL | bar(); | ^^^ not found in this scope From ac5e18756a4f0987c5861e45b82ac6f410fd4734 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sat, 23 Sep 2023 01:54:05 +0000 Subject: [PATCH 11/30] Tweak wording and logic --- compiler/rustc_resolve/src/late/diagnostics.rs | 15 ++++++++++----- tests/ui/resolve/issue-103474.stderr | 2 +- tests/ui/resolve/issue-2356.stderr | 4 ++-- tests/ui/self/class-missing-self.stderr | 2 +- .../suggestions/assoc-const-without-self.stderr | 2 +- tests/ui/suggestions/assoc_fn_without_self.stderr | 10 +++++----- 6 files changed, 20 insertions(+), 15 deletions(-) diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index c690ac6c043..06a08f29a1e 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -243,15 +243,20 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { )); None } - AssocItemKind::Fn(fn_) => Some(( + AssocItemKind::Fn(fn_) if fn_.sig.decl.has_self() => Some(( sp, - "consider using the associated function", - if fn_.sig.decl.has_self() { "self." } else { "Self::" }, + "consider using the method on `Self`", + "self.".to_string(), + )), + AssocItemKind::Fn(_) => Some(( + sp, + "consider using the associated function on `Self`", + "Self::".to_string(), )), AssocItemKind::Const(..) => Some(( sp, - "consider using the associated constant", - "Self::", + "consider using the associated constant on `Self`", + "Self::".to_string(), )), _ => None } diff --git a/tests/ui/resolve/issue-103474.stderr b/tests/ui/resolve/issue-103474.stderr index 415d231552a..e48fb31eccc 100644 --- a/tests/ui/resolve/issue-103474.stderr +++ b/tests/ui/resolve/issue-103474.stderr @@ -19,7 +19,7 @@ error[E0425]: cannot find function `first` in this scope LL | first() | ^^^^^ not found in this scope | -help: consider using the associated function +help: consider using the method on `Self` | LL | self.first() | +++++ diff --git a/tests/ui/resolve/issue-2356.stderr b/tests/ui/resolve/issue-2356.stderr index 30f5f059526..273e8b2a661 100644 --- a/tests/ui/resolve/issue-2356.stderr +++ b/tests/ui/resolve/issue-2356.stderr @@ -73,7 +73,7 @@ error[E0425]: cannot find function `static_method` in this scope LL | static_method(); | ^^^^^^^^^^^^^ not found in this scope | -help: consider using the associated function +help: consider using the associated function on `Self` | LL | Self::static_method(); | ++++++ @@ -102,7 +102,7 @@ error[E0425]: cannot find function `grow_older` in this scope LL | grow_older(); | ^^^^^^^^^^ not found in this scope | -help: consider using the associated function +help: consider using the associated function on `Self` | LL | Self::grow_older(); | ++++++ diff --git a/tests/ui/self/class-missing-self.stderr b/tests/ui/self/class-missing-self.stderr index 3c37d819743..08493b4f9a2 100644 --- a/tests/ui/self/class-missing-self.stderr +++ b/tests/ui/self/class-missing-self.stderr @@ -10,7 +10,7 @@ error[E0425]: cannot find function `sleep` in this scope LL | sleep(); | ^^^^^ not found in this scope | -help: consider using the associated function +help: consider using the method on `Self` | LL | self.sleep(); | +++++ diff --git a/tests/ui/suggestions/assoc-const-without-self.stderr b/tests/ui/suggestions/assoc-const-without-self.stderr index 88d72da70cb..05528d277be 100644 --- a/tests/ui/suggestions/assoc-const-without-self.stderr +++ b/tests/ui/suggestions/assoc-const-without-self.stderr @@ -4,7 +4,7 @@ error[E0425]: cannot find value `A_CONST` in this scope LL | A_CONST | ^^^^^^^ not found in this scope | -help: consider using the associated constant +help: consider using the associated constant on `Self` | LL | Self::A_CONST | ++++++ diff --git a/tests/ui/suggestions/assoc_fn_without_self.stderr b/tests/ui/suggestions/assoc_fn_without_self.stderr index 26fcc2a0181..9cee7c7ee5e 100644 --- a/tests/ui/suggestions/assoc_fn_without_self.stderr +++ b/tests/ui/suggestions/assoc_fn_without_self.stderr @@ -4,7 +4,7 @@ error[E0425]: cannot find function `foo` in this scope LL | foo(); | ^^^ not found in this scope | -help: consider using the associated function +help: consider using the associated function on `Self` | LL | Self::foo(); | ++++++ @@ -24,7 +24,7 @@ error[E0425]: cannot find function `baz` in this scope LL | baz(2, 3); | ^^^ not found in this scope | -help: consider using the associated function +help: consider using the associated function on `Self` | LL | Self::baz(2, 3); | ++++++ @@ -41,7 +41,7 @@ error[E0425]: cannot find function `foo` in this scope LL | foo(); | ^^^ not found in this scope | -help: consider using the associated function +help: consider using the associated function on `Self` | LL | Self::foo(); | ++++++ @@ -52,7 +52,7 @@ error[E0425]: cannot find function `bar` in this scope LL | bar(); | ^^^ not found in this scope | -help: consider using the associated function +help: consider using the method on `Self` | LL | self.bar(); | +++++ @@ -63,7 +63,7 @@ error[E0425]: cannot find function `baz` in this scope LL | baz(2, 3); | ^^^ not found in this scope | -help: consider using the associated function +help: consider using the associated function on `Self` | LL | Self::baz(2, 3); | ++++++ From 7d8559ac9077e35a687d5b16f17f2f493421f3ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sat, 23 Sep 2023 01:59:22 +0000 Subject: [PATCH 12/30] Add test --- ...ethod-in-self-not-available-in-assoc-fn.rs | 15 +++++++++++++ ...d-in-self-not-available-in-assoc-fn.stderr | 21 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 tests/ui/resolve/field-and-method-in-self-not-available-in-assoc-fn.rs create mode 100644 tests/ui/resolve/field-and-method-in-self-not-available-in-assoc-fn.stderr diff --git a/tests/ui/resolve/field-and-method-in-self-not-available-in-assoc-fn.rs b/tests/ui/resolve/field-and-method-in-self-not-available-in-assoc-fn.rs new file mode 100644 index 00000000000..9e72c36151e --- /dev/null +++ b/tests/ui/resolve/field-and-method-in-self-not-available-in-assoc-fn.rs @@ -0,0 +1,15 @@ +struct Foo { + field: u32, +} + +impl Foo { + fn field(&self) -> u32 { + self.field + } + + fn new() -> Foo { + field; //~ ERROR cannot find value `field` in this scope + Foo { field } //~ ERROR cannot find value `field` in this scope + } +} +fn main() {} diff --git a/tests/ui/resolve/field-and-method-in-self-not-available-in-assoc-fn.stderr b/tests/ui/resolve/field-and-method-in-self-not-available-in-assoc-fn.stderr new file mode 100644 index 00000000000..2eb3861e5f1 --- /dev/null +++ b/tests/ui/resolve/field-and-method-in-self-not-available-in-assoc-fn.stderr @@ -0,0 +1,21 @@ +error[E0425]: cannot find value `field` in this scope + --> $DIR/field-and-method-in-self-not-available-in-assoc-fn.rs:11:9 + | +LL | fn field(&self) -> u32 { + | ----- a method by that name is available on `Self` here +... +LL | field; + | ^^^^^ a field by this name exists in `Self` + +error[E0425]: cannot find value `field` in this scope + --> $DIR/field-and-method-in-self-not-available-in-assoc-fn.rs:12:15 + | +LL | fn field(&self) -> u32 { + | ----- a method by that name is available on `Self` here +... +LL | Foo { field } + | ^^^^^ a field by this name exists in `Self` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0425`. From 58ef3a0ec9a3e2151a103964683b5d00932304d8 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Fri, 22 Sep 2023 22:41:01 -0700 Subject: [PATCH 13/30] diagnostics: simpler 83556 handling by bailing out --- compiler/rustc_hir_analysis/src/check/wfcheck.rs | 11 +++-------- tests/ui/generics/issue-83556.rs | 1 - tests/ui/generics/issue-83556.stderr | 12 +----------- 3 files changed, 4 insertions(+), 20 deletions(-) diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs index 412b03b3be3..00a684f2963 100644 --- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs +++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs @@ -1765,9 +1765,9 @@ fn check_variances_for_type_defn<'tcx>( } let ty_param = &ty_generics.params[index]; - let mut hir_param = &hir_generics.params[index]; + let hir_param = &hir_generics.params[index]; - if ty_param.name != hir_param.name.ident().name { + if ty_param.def_id != hir_param.def_id.into() { // valid programs always have lifetimes before types in the generic parameter list // ty_generics are normalized to be in this required order, and variances are built // from ty generics, not from hir generics. but we need hir generics to get @@ -1777,12 +1777,7 @@ fn check_variances_for_type_defn<'tcx>( // got an error about it (or I'm wrong about this) tcx.sess .delay_span_bug(hir_param.span, "hir generics and ty generics in different order"); - for hp in hir_generics.params { - if hp.name.ident().name == ty_param.name { - hir_param = hp; - break; - } - } + continue; } match hir_param.name { diff --git a/tests/ui/generics/issue-83556.rs b/tests/ui/generics/issue-83556.rs index 21f801d9d10..7cea1c8631f 100644 --- a/tests/ui/generics/issue-83556.rs +++ b/tests/ui/generics/issue-83556.rs @@ -1,5 +1,4 @@ struct Foo(&'a ()); //~^ ERROR lifetime parameters must be declared prior to -//~| ERROR parameter `T` is never used fn main() {} diff --git a/tests/ui/generics/issue-83556.stderr b/tests/ui/generics/issue-83556.stderr index 2ed999510eb..93affaffe60 100644 --- a/tests/ui/generics/issue-83556.stderr +++ b/tests/ui/generics/issue-83556.stderr @@ -4,15 +4,5 @@ error: lifetime parameters must be declared prior to type and const parameters LL | struct Foo(&'a ()); | ----^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, T>` -error[E0392]: parameter `T` is never used - --> $DIR/issue-83556.rs:1:12 - | -LL | struct Foo(&'a ()); - | ^ unused parameter - | - = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` - = help: if you intended `T` to be a const parameter, use `const T: usize` instead +error: aborting due to previous error -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0392`. From 9450b75986571785b11d202e68af255a1780f68f Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Tue, 16 May 2023 10:47:50 +0000 Subject: [PATCH 14/30] Do not construct def_path_str for MustNotSuspend. --- compiler/rustc_mir_transform/src/errors.rs | 34 +++++++++++++++---- compiler/rustc_mir_transform/src/generator.rs | 3 +- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_mir_transform/src/errors.rs b/compiler/rustc_mir_transform/src/errors.rs index 35373bcaa41..5879a803946 100644 --- a/compiler/rustc_mir_transform/src/errors.rs +++ b/compiler/rustc_mir_transform/src/errors.rs @@ -4,7 +4,9 @@ use rustc_errors::{ }; use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic}; use rustc_middle::mir::{AssertKind, UnsafetyViolationDetails}; +use rustc_middle::ty::TyCtxt; use rustc_session::lint::{self, Lint}; +use rustc_span::def_id::DefId; use rustc_span::Span; #[derive(LintDiagnostic)] @@ -237,20 +239,38 @@ pub(crate) struct FnItemRef { pub ident: String, } -#[derive(LintDiagnostic)] -#[diag(mir_transform_must_not_suspend)] -pub(crate) struct MustNotSupend<'a> { - #[label] +pub(crate) struct MustNotSupend<'tcx, 'a> { + pub tcx: TyCtxt<'tcx>, pub yield_sp: Span, - #[subdiagnostic] pub reason: Option, - #[help] pub src_sp: Span, pub pre: &'a str, - pub def_path: String, + pub def_id: DefId, pub post: &'a str, } +// Needed for def_path_str +impl<'a> DecorateLint<'a, ()> for MustNotSupend<'_, '_> { + fn decorate_lint<'b>( + self, + diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>, + ) -> &'b mut rustc_errors::DiagnosticBuilder<'a, ()> { + diag.span_label(self.yield_sp, crate::fluent_generated::_subdiag::label); + if let Some(reason) = self.reason { + diag.subdiagnostic(reason); + } + diag.span_help(self.src_sp, crate::fluent_generated::_subdiag::help); + diag.set_arg("pre", self.pre); + diag.set_arg("def_path", self.tcx.def_path_str(self.def_id)); + diag.set_arg("post", self.post); + diag + } + + fn msg(&self) -> rustc_errors::DiagnosticMessage { + crate::fluent_generated::mir_transform_must_not_suspend + } +} + #[derive(Subdiagnostic)] #[note(mir_transform_note)] pub(crate) struct MustNotSuspendReason { diff --git a/compiler/rustc_mir_transform/src/generator.rs b/compiler/rustc_mir_transform/src/generator.rs index 96c60fdf41b..9bcdc7d728d 100644 --- a/compiler/rustc_mir_transform/src/generator.rs +++ b/compiler/rustc_mir_transform/src/generator.rs @@ -1954,11 +1954,12 @@ fn check_must_not_suspend_def( hir_id, data.source_span, errors::MustNotSupend { + tcx, yield_sp: data.yield_span, reason, src_sp: data.source_span, pre: data.descr_pre, - def_path: tcx.def_path_str(def_id), + def_id, post: data.descr_post, }, ); From ff032043653e7aebfbf74ab59572f929aa2beb65 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sat, 3 Jun 2023 08:38:44 +0000 Subject: [PATCH 15/30] Fold lifetimes before substitution. --- .../src/traits/select/mod.rs | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs index dcf41c3774f..d4ca0c8a5c5 100644 --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs @@ -3115,25 +3115,25 @@ fn bind_generator_hidden_types_above<'tcx>( .generator_hidden_types(def_id) // Deduplicate tys to avoid repeated work. .filter(|bty| seen_tys.insert(*bty)) - .map(|bty| { - let mut ty = bty.instantiate(tcx, args); - + .map(|mut bty| { // Only remap erased regions if we use them. if considering_regions { - ty = tcx.fold_regions(ty, |r, current_depth| match r.kind() { - ty::ReErased => { - let br = ty::BoundRegion { - var: ty::BoundVar::from_u32(counter), - kind: ty::BrAnon(None), - }; - counter += 1; - ty::Region::new_late_bound(tcx, current_depth, br) - } - r => bug!("unexpected region: {r:?}"), + bty = bty.map_bound(|ty| { + tcx.fold_regions(ty, |r, current_depth| match r.kind() { + ty::ReErased => { + let br = ty::BoundRegion { + var: ty::BoundVar::from_u32(counter), + kind: ty::BrAnon(None), + }; + counter += 1; + ty::Region::new_late_bound(tcx, current_depth, br) + } + r => bug!("unexpected region: {r:?}"), + }) }) } - ty + bty.instantiate(tcx, args) }) .collect(); if considering_regions { From a626caaad97b7f8733b8c9bd1fe9662cfc1e3ec1 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sun, 7 May 2023 18:38:52 +0000 Subject: [PATCH 16/30] Revert duplication of tests. --- .../async-await-let-else.drop-tracking.stderr | 106 ------ .../async-await-let-else.drop_tracking.stderr | 106 ------ ...nc-await-let-else.drop_tracking_mir.stderr | 100 ------ ...ync-await-let-else.no-drop-tracking.stderr | 90 ----- tests/ui/async-await/async-await-let-else.rs | 3 - ...ing.stderr => async-await-let-else.stderr} | 24 +- .../async-error-span.drop_tracking_mir.stderr | 24 -- .../async-error-span.no_drop_tracking.stderr | 25 -- tests/ui/async-await/async-error-span.rs | 7 +- ...racking.stderr => async-error-span.stderr} | 6 +- .../async-fn-nonsend.drop_tracking_mir.stderr | 43 --- .../async-fn-nonsend.no_drop_tracking.stderr | 120 ------- tests/ui/async-await/async-fn-nonsend.rs | 8 +- ...racking.stderr => async-fn-nonsend.stderr} | 12 +- ...ing-unsized-param.drop_tracking_mir.stderr | 21 -- .../ui/async-await/awaiting-unsized-param.rs | 2 - ...g.stderr => awaiting-unsized-param.stderr} | 4 +- tests/ui/async-await/default-struct-update.rs | 4 +- tests/ui/async-await/drop-and-assign.rs | 4 +- ...-field-assign-nonsend.drop_tracking.stderr | 25 -- ...ld-assign-nonsend.drop_tracking_mir.stderr | 23 -- ...eld-assign-nonsend.no_drop_tracking.stderr | 25 -- .../drop-track-field-assign-nonsend.rs | 4 +- ...=> drop-track-field-assign-nonsend.stderr} | 6 +- .../ui/async-await/drop-track-field-assign.rs | 4 +- ...ld-assign-nonsend.drop_tracking_mir.stderr | 23 -- tests/ui/async-await/field-assign-nonsend.rs | 3 - ...ing.stderr => field-assign-nonsend.stderr} | 6 +- tests/ui/async-await/field-assign.rs | 3 - .../issue-64130-1-sync.drop_tracking.stderr | 25 -- ...ssue-64130-1-sync.drop_tracking_mir.stderr | 22 -- tests/ui/async-await/issue-64130-1-sync.rs | 4 - ...cking.stderr => issue-64130-1-sync.stderr} | 7 +- ...ssue-64130-2-send.drop_tracking_mir.stderr | 26 -- ...issue-64130-2-send.no_drop_tracking.stderr | 28 -- tests/ui/async-await/issue-64130-2-send.rs | 5 +- ...cking.stderr => issue-64130-2-send.stderr} | 16 +- .../issue-64130-3-other.drop_tracking.stderr | 27 -- ...sue-64130-3-other.drop_tracking_mir.stderr | 25 -- tests/ui/async-await/issue-64130-3-other.rs | 5 +- ...king.stderr => issue-64130-3-other.stderr} | 10 +- ...ue-64130-4-async-move.drop-tracking.stderr | 26 -- ...64130-4-async-move.no_drop_tracking.stderr | 26 -- .../async-await/issue-64130-4-async-move.rs | 8 +- ...-67252-unnamed-future.drop_tracking.stderr | 30 -- ...52-unnamed-future.drop_tracking_mir.stderr | 22 -- ...252-unnamed-future.no_drop_tracking.stderr | 30 -- .../async-await/issue-67252-unnamed-future.rs | 6 +- .../issue-67252-unnamed-future.stderr | 28 ++ .../issue-68112.drop_tracking.stderr | 82 ----- .../issue-68112.drop_tracking_mir.stderr | 80 ----- tests/ui/async-await/issue-68112.rs | 5 +- ...rop_tracking.stderr => issue-68112.stderr} | 22 +- .../issue-70818.drop_tracking.stderr | 18 - .../issue-70818.no_drop_tracking.stderr | 18 - tests/ui/async-await/issue-70818.rs | 3 - ...tracking_mir.stderr => issue-70818.stderr} | 4 +- ...e-70935-complex-spans.drop_tracking.stderr | 41 --- ...935-complex-spans.drop_tracking_mir.stderr | 41 --- .../async-await/issue-70935-complex-spans.rs | 6 +- ...tderr => issue-70935-complex-spans.stderr} | 6 +- tests/ui/async-await/issue-73137.rs | 3 - ...ype-err-drop-tracking.drop_tracking.stderr | 11 - ...err-drop-tracking.drop_tracking_mir.stderr | 11 - ...-err-drop-tracking.no_drop_tracking.stderr | 11 - .../issue-73741-type-err-drop-tracking.rs | 17 - .../issue-86507.drop_tracking_mir.stderr | 23 -- .../issue-86507.no_drop_tracking.stderr | 23 -- tests/ui/async-await/issue-86507.rs | 3 - ...rop_tracking.stderr => issue-86507.stderr} | 6 +- tests/ui/async-await/issue-93648.rs | 4 +- .../issues/auxiliary/issue_67893.rs | 3 - ...6-raw-ptr-not-send.no_drop_tracking.stderr | 32 -- .../issues/issue-65436-raw-ptr-not-send.rs | 8 +- .../issues/issue-67611-static-mut-refs.rs | 4 - .../ui/async-await/issues/issue-67893.stderr | 2 +- ...async-impl-trait-type.drop_tracking.stderr | 21 -- ...nc-impl-trait-type.no_drop_tracking.stderr | 21 -- ...utually-recursive-async-impl-trait-type.rs | 4 - ...ly-recursive-async-impl-trait-type.stderr} | 4 +- tests/ui/async-await/non-trivial-drop.rs | 4 +- ...l-drop-partial-reinit.drop_tracking.stderr | 35 -- .../partial-drop-partial-reinit.rs | 3 - ...err => partial-drop-partial-reinit.stderr} | 6 +- ...async-impl-trait-type.drop_tracking.stderr | 12 - ...nc-impl-trait-type.no_drop_tracking.stderr | 12 - .../recursive-async-impl-trait-type.rs | 3 - ...=> recursive-async-impl-trait-type.stderr} | 2 +- ...solved_type_param.drop_tracking_mir.stderr | 14 - ...esolved_type_param.no_drop_tracking.stderr | 63 ---- tests/ui/async-await/unresolved_type_param.rs | 38 +- ...ng.stderr => unresolved_type_param.stderr} | 12 +- ...sized-across-await.no_drop_tracking.stderr | 21 -- tests/ui/async-await/unsized-across-await.rs | 2 - ...mir.stderr => unsized-across-await.stderr} | 4 +- tests/ui/generator/addassign-yield.rs | 3 - .../auto-trait-regions.drop_tracking.stderr | 55 --- ...auto-trait-regions.no_drop_tracking.stderr | 55 --- tests/ui/generator/auto-trait-regions.rs | 3 - ...g_mir.stderr => auto-trait-regions.stderr} | 8 +- .../borrowing.drop_tracking_mir.stderr | 39 -- .../borrowing.no_drop_tracking.stderr | 31 -- tests/ui/generator/borrowing.rs | 4 - ....drop_tracking.stderr => borrowing.stderr} | 4 +- ...parent-expression.drop_tracking_mir.stderr | 122 ------- ...-parent-expression.no_drop_tracking.stderr | 334 ------------------ .../drop-tracking-parent-expression.rs | 12 +- ...=> drop-tracking-parent-expression.stderr} | 24 +- .../drop-tracking-yielding-in-match-guards.rs | 4 +- tests/ui/generator/issue-105084.rs | 12 +- ...racking_mir.stderr => issue-105084.stderr} | 18 +- .../issue-57017.no_drop_tracking.stderr | 248 ------------- tests/ui/generator/issue-57017.rs | 14 +- .../issue-57478.no_drop_tracking.stderr | 31 -- tests/ui/generator/issue-57478.rs | 8 +- .../issue-68112.drop_tracking.stderr | 66 ---- .../issue-68112.drop_tracking_mir.stderr | 61 ---- tests/ui/generator/issue-68112.rs | 9 +- ...rop_tracking.stderr => issue-68112.stderr} | 18 +- tests/ui/generator/issue-93161.rs | 4 +- .../not-send-sync.drop_tracking.stderr | 60 ---- .../not-send-sync.drop_tracking_mir.stderr | 42 --- .../not-send-sync.no_drop_tracking.stderr | 60 ---- tests/ui/generator/not-send-sync.rs | 19 +- tests/ui/generator/not-send-sync.stderr | 58 +++ ...parent-expression.drop_tracking_mir.stderr | 122 ------- .../parent-expression.no_drop_tracking.stderr | 334 ------------------ tests/ui/generator/parent-expression.rs | 9 +- ...acking.stderr => parent-expression.stderr} | 24 +- .../partial-drop.no_drop_tracking.stderr | 61 ---- tests/ui/generator/partial-drop.rs | 21 +- ...op_tracking.stderr => partial-drop.stderr} | 51 ++- ...rator-print-verbose-1.drop_tracking.stderr | 64 ---- ...r-print-verbose-1.drop_tracking_mir.stderr | 60 ---- .../print/generator-print-verbose-1.rs | 5 +- ...tderr => generator-print-verbose-1.stderr} | 18 +- ...rator-print-verbose-2.drop_tracking.stderr | 60 ---- ...r-print-verbose-2.drop_tracking_mir.stderr | 42 --- ...or-print-verbose-2.no_drop_tracking.stderr | 60 ---- .../print/generator-print-verbose-2.rs | 19 +- .../print/generator-print-verbose-2.stderr | 58 +++ ...retain-resume-ref.drop_tracking_mir.stderr | 14 - .../retain-resume-ref.no_drop_tracking.stderr | 13 - tests/ui/generator/retain-resume-ref.rs | 4 - ...acking.stderr => retain-resume-ref.stderr} | 2 +- .../static-mut-reference-across-yield.rs | 4 +- .../unresolved-ct-var-drop-tracking.rs | 15 - .../unresolved-ct-var-drop-tracking.stderr | 78 ---- .../issue-55872-2.drop_tracking.stderr | 8 - .../issue-55872-2.drop_tracking_mir.stderr | 14 - tests/ui/impl-trait/issue-55872-2.rs | 4 - ...p_tracking.stderr => issue-55872-2.stderr} | 2 +- ...ait-type-indirect.drop_tracking_mir.stderr | 147 -------- ...rait-type-indirect.no_drop_tracking.stderr | 152 -------- .../recursive-impl-trait-type-indirect.rs | 4 - ...recursive-impl-trait-type-indirect.stderr} | 40 +-- .../dedup.drop_tracking_mir.stderr | 21 -- .../dedup.no_drop_tracking.stderr | 33 -- tests/ui/lint/must_not_suspend/dedup.rs | 7 +- ...edup.drop_tracking.stderr => dedup.stderr} | 16 +- .../must_not_suspend/ref-drop-tracking.rs | 30 -- .../must_not_suspend/ref-drop-tracking.stderr | 27 -- .../must_not_suspend/ref.drop_tracking.stderr | 27 -- .../ref.drop_tracking_mir.stderr | 27 -- tests/ui/lint/must_not_suspend/ref.rs | 5 - ...ref.no_drop_tracking.stderr => ref.stderr} | 8 +- .../trait.drop_tracking_mir.stderr | 37 -- .../trait.no_drop_tracking.stderr | 37 -- tests/ui/lint/must_not_suspend/trait.rs | 6 - ...rait.drop_tracking.stderr => trait.stderr} | 10 +- .../unit.drop_tracking.stderr | 26 -- .../unit.no_drop_tracking.stderr | 26 -- tests/ui/lint/must_not_suspend/unit.rs | 5 +- ...t.drop_tracking_mir.stderr => unit.stderr} | 8 +- .../warn.drop_tracking.stderr | 26 -- .../warn.no_drop_tracking.stderr | 26 -- tests/ui/lint/must_not_suspend/warn.rs | 4 - ...n.drop_tracking_mir.stderr => warn.stderr} | 8 +- 178 files changed, 439 insertions(+), 4891 deletions(-) delete mode 100644 tests/ui/async-await/async-await-let-else.drop-tracking.stderr delete mode 100644 tests/ui/async-await/async-await-let-else.drop_tracking.stderr delete mode 100644 tests/ui/async-await/async-await-let-else.drop_tracking_mir.stderr delete mode 100644 tests/ui/async-await/async-await-let-else.no-drop-tracking.stderr rename tests/ui/async-await/{async-await-let-else.no_drop_tracking.stderr => async-await-let-else.stderr} (85%) delete mode 100644 tests/ui/async-await/async-error-span.drop_tracking_mir.stderr delete mode 100644 tests/ui/async-await/async-error-span.no_drop_tracking.stderr rename tests/ui/async-await/{async-error-span.drop_tracking.stderr => async-error-span.stderr} (86%) delete mode 100644 tests/ui/async-await/async-fn-nonsend.drop_tracking_mir.stderr delete mode 100644 tests/ui/async-await/async-fn-nonsend.no_drop_tracking.stderr rename tests/ui/async-await/{async-fn-nonsend.drop_tracking.stderr => async-fn-nonsend.stderr} (89%) delete mode 100644 tests/ui/async-await/awaiting-unsized-param.drop_tracking_mir.stderr rename tests/ui/async-await/{awaiting-unsized-param.no_drop_tracking.stderr => awaiting-unsized-param.stderr} (91%) delete mode 100644 tests/ui/async-await/drop-track-field-assign-nonsend.drop_tracking.stderr delete mode 100644 tests/ui/async-await/drop-track-field-assign-nonsend.drop_tracking_mir.stderr delete mode 100644 tests/ui/async-await/drop-track-field-assign-nonsend.no_drop_tracking.stderr rename tests/ui/async-await/{field-assign-nonsend.drop_tracking.stderr => drop-track-field-assign-nonsend.stderr} (84%) delete mode 100644 tests/ui/async-await/field-assign-nonsend.drop_tracking_mir.stderr rename tests/ui/async-await/{field-assign-nonsend.no_drop_tracking.stderr => field-assign-nonsend.stderr} (87%) delete mode 100644 tests/ui/async-await/issue-64130-1-sync.drop_tracking.stderr delete mode 100644 tests/ui/async-await/issue-64130-1-sync.drop_tracking_mir.stderr rename tests/ui/async-await/{issue-64130-1-sync.no_drop_tracking.stderr => issue-64130-1-sync.stderr} (83%) delete mode 100644 tests/ui/async-await/issue-64130-2-send.drop_tracking_mir.stderr delete mode 100644 tests/ui/async-await/issue-64130-2-send.no_drop_tracking.stderr rename tests/ui/async-await/{issue-64130-2-send.drop_tracking.stderr => issue-64130-2-send.stderr} (60%) delete mode 100644 tests/ui/async-await/issue-64130-3-other.drop_tracking.stderr delete mode 100644 tests/ui/async-await/issue-64130-3-other.drop_tracking_mir.stderr rename tests/ui/async-await/{issue-64130-3-other.no_drop_tracking.stderr => issue-64130-3-other.stderr} (77%) delete mode 100644 tests/ui/async-await/issue-64130-4-async-move.drop-tracking.stderr delete mode 100644 tests/ui/async-await/issue-64130-4-async-move.no_drop_tracking.stderr delete mode 100644 tests/ui/async-await/issue-67252-unnamed-future.drop_tracking.stderr delete mode 100644 tests/ui/async-await/issue-67252-unnamed-future.drop_tracking_mir.stderr delete mode 100644 tests/ui/async-await/issue-67252-unnamed-future.no_drop_tracking.stderr create mode 100644 tests/ui/async-await/issue-67252-unnamed-future.stderr delete mode 100644 tests/ui/async-await/issue-68112.drop_tracking.stderr delete mode 100644 tests/ui/async-await/issue-68112.drop_tracking_mir.stderr rename tests/ui/async-await/{issue-68112.no_drop_tracking.stderr => issue-68112.stderr} (90%) delete mode 100644 tests/ui/async-await/issue-70818.drop_tracking.stderr delete mode 100644 tests/ui/async-await/issue-70818.no_drop_tracking.stderr rename tests/ui/async-await/{issue-70818.drop_tracking_mir.stderr => issue-70818.stderr} (90%) delete mode 100644 tests/ui/async-await/issue-70935-complex-spans.drop_tracking.stderr delete mode 100644 tests/ui/async-await/issue-70935-complex-spans.drop_tracking_mir.stderr rename tests/ui/async-await/{issue-70935-complex-spans.no_drop_tracking.stderr => issue-70935-complex-spans.stderr} (84%) delete mode 100644 tests/ui/async-await/issue-73741-type-err-drop-tracking.drop_tracking.stderr delete mode 100644 tests/ui/async-await/issue-73741-type-err-drop-tracking.drop_tracking_mir.stderr delete mode 100644 tests/ui/async-await/issue-73741-type-err-drop-tracking.no_drop_tracking.stderr delete mode 100644 tests/ui/async-await/issue-73741-type-err-drop-tracking.rs delete mode 100644 tests/ui/async-await/issue-86507.drop_tracking_mir.stderr delete mode 100644 tests/ui/async-await/issue-86507.no_drop_tracking.stderr rename tests/ui/async-await/{issue-86507.drop_tracking.stderr => issue-86507.stderr} (86%) delete mode 100644 tests/ui/async-await/issues/issue-65436-raw-ptr-not-send.no_drop_tracking.stderr delete mode 100644 tests/ui/async-await/mutually-recursive-async-impl-trait-type.drop_tracking.stderr delete mode 100644 tests/ui/async-await/mutually-recursive-async-impl-trait-type.no_drop_tracking.stderr rename tests/ui/async-await/{mutually-recursive-async-impl-trait-type.drop_tracking_mir.stderr => mutually-recursive-async-impl-trait-type.stderr} (92%) delete mode 100644 tests/ui/async-await/partial-drop-partial-reinit.drop_tracking.stderr rename tests/ui/async-await/{partial-drop-partial-reinit.no_drop_tracking.stderr => partial-drop-partial-reinit.stderr} (88%) delete mode 100644 tests/ui/async-await/recursive-async-impl-trait-type.drop_tracking.stderr delete mode 100644 tests/ui/async-await/recursive-async-impl-trait-type.no_drop_tracking.stderr rename tests/ui/async-await/{recursive-async-impl-trait-type.drop_tracking_mir.stderr => recursive-async-impl-trait-type.stderr} (90%) delete mode 100644 tests/ui/async-await/unresolved_type_param.drop_tracking_mir.stderr delete mode 100644 tests/ui/async-await/unresolved_type_param.no_drop_tracking.stderr rename tests/ui/async-await/{unresolved_type_param.drop_tracking.stderr => unresolved_type_param.stderr} (80%) delete mode 100644 tests/ui/async-await/unsized-across-await.no_drop_tracking.stderr rename tests/ui/async-await/{unsized-across-await.drop_tracking_mir.stderr => unsized-across-await.stderr} (91%) delete mode 100644 tests/ui/generator/auto-trait-regions.drop_tracking.stderr delete mode 100644 tests/ui/generator/auto-trait-regions.no_drop_tracking.stderr rename tests/ui/generator/{auto-trait-regions.drop_tracking_mir.stderr => auto-trait-regions.stderr} (92%) delete mode 100644 tests/ui/generator/borrowing.drop_tracking_mir.stderr delete mode 100644 tests/ui/generator/borrowing.no_drop_tracking.stderr rename tests/ui/generator/{borrowing.drop_tracking.stderr => borrowing.stderr} (93%) delete mode 100644 tests/ui/generator/drop-tracking-parent-expression.drop_tracking_mir.stderr delete mode 100644 tests/ui/generator/drop-tracking-parent-expression.no_drop_tracking.stderr rename tests/ui/generator/{drop-tracking-parent-expression.drop_tracking.stderr => drop-tracking-parent-expression.stderr} (88%) rename tests/ui/generator/{issue-105084.drop_tracking_mir.stderr => issue-105084.stderr} (81%) delete mode 100644 tests/ui/generator/issue-57017.no_drop_tracking.stderr delete mode 100644 tests/ui/generator/issue-57478.no_drop_tracking.stderr delete mode 100644 tests/ui/generator/issue-68112.drop_tracking.stderr delete mode 100644 tests/ui/generator/issue-68112.drop_tracking_mir.stderr rename tests/ui/generator/{issue-68112.no_drop_tracking.stderr => issue-68112.stderr} (89%) delete mode 100644 tests/ui/generator/not-send-sync.drop_tracking.stderr delete mode 100644 tests/ui/generator/not-send-sync.drop_tracking_mir.stderr delete mode 100644 tests/ui/generator/not-send-sync.no_drop_tracking.stderr create mode 100644 tests/ui/generator/not-send-sync.stderr delete mode 100644 tests/ui/generator/parent-expression.drop_tracking_mir.stderr delete mode 100644 tests/ui/generator/parent-expression.no_drop_tracking.stderr rename tests/ui/generator/{parent-expression.drop_tracking.stderr => parent-expression.stderr} (87%) delete mode 100644 tests/ui/generator/partial-drop.no_drop_tracking.stderr rename tests/ui/generator/{partial-drop.drop_tracking.stderr => partial-drop.stderr} (52%) delete mode 100644 tests/ui/generator/print/generator-print-verbose-1.drop_tracking.stderr delete mode 100644 tests/ui/generator/print/generator-print-verbose-1.drop_tracking_mir.stderr rename tests/ui/generator/print/{generator-print-verbose-1.no_drop_tracking.stderr => generator-print-verbose-1.stderr} (86%) delete mode 100644 tests/ui/generator/print/generator-print-verbose-2.drop_tracking.stderr delete mode 100644 tests/ui/generator/print/generator-print-verbose-2.drop_tracking_mir.stderr delete mode 100644 tests/ui/generator/print/generator-print-verbose-2.no_drop_tracking.stderr create mode 100644 tests/ui/generator/print/generator-print-verbose-2.stderr delete mode 100644 tests/ui/generator/retain-resume-ref.drop_tracking_mir.stderr delete mode 100644 tests/ui/generator/retain-resume-ref.no_drop_tracking.stderr rename tests/ui/generator/{retain-resume-ref.drop_tracking.stderr => retain-resume-ref.stderr} (92%) delete mode 100644 tests/ui/generator/unresolved-ct-var-drop-tracking.rs delete mode 100644 tests/ui/generator/unresolved-ct-var-drop-tracking.stderr delete mode 100644 tests/ui/impl-trait/issue-55872-2.drop_tracking.stderr delete mode 100644 tests/ui/impl-trait/issue-55872-2.drop_tracking_mir.stderr rename tests/ui/impl-trait/{issue-55872-2.no_drop_tracking.stderr => issue-55872-2.stderr} (86%) delete mode 100644 tests/ui/impl-trait/recursive-impl-trait-type-indirect.drop_tracking_mir.stderr delete mode 100644 tests/ui/impl-trait/recursive-impl-trait-type-indirect.no_drop_tracking.stderr rename tests/ui/impl-trait/{recursive-impl-trait-type-indirect.drop_tracking.stderr => recursive-impl-trait-type-indirect.stderr} (80%) delete mode 100644 tests/ui/lint/must_not_suspend/dedup.drop_tracking_mir.stderr delete mode 100644 tests/ui/lint/must_not_suspend/dedup.no_drop_tracking.stderr rename tests/ui/lint/must_not_suspend/{dedup.drop_tracking.stderr => dedup.stderr} (55%) delete mode 100644 tests/ui/lint/must_not_suspend/ref-drop-tracking.rs delete mode 100644 tests/ui/lint/must_not_suspend/ref-drop-tracking.stderr delete mode 100644 tests/ui/lint/must_not_suspend/ref.drop_tracking.stderr delete mode 100644 tests/ui/lint/must_not_suspend/ref.drop_tracking_mir.stderr rename tests/ui/lint/must_not_suspend/{ref.no_drop_tracking.stderr => ref.stderr} (88%) delete mode 100644 tests/ui/lint/must_not_suspend/trait.drop_tracking_mir.stderr delete mode 100644 tests/ui/lint/must_not_suspend/trait.no_drop_tracking.stderr rename tests/ui/lint/must_not_suspend/{trait.drop_tracking.stderr => trait.stderr} (88%) delete mode 100644 tests/ui/lint/must_not_suspend/unit.drop_tracking.stderr delete mode 100644 tests/ui/lint/must_not_suspend/unit.no_drop_tracking.stderr rename tests/ui/lint/must_not_suspend/{unit.drop_tracking_mir.stderr => unit.stderr} (86%) delete mode 100644 tests/ui/lint/must_not_suspend/warn.drop_tracking.stderr delete mode 100644 tests/ui/lint/must_not_suspend/warn.no_drop_tracking.stderr rename tests/ui/lint/must_not_suspend/{warn.drop_tracking_mir.stderr => warn.stderr} (86%) diff --git a/tests/ui/async-await/async-await-let-else.drop-tracking.stderr b/tests/ui/async-await/async-await-let-else.drop-tracking.stderr deleted file mode 100644 index fb83ca90a37..00000000000 --- a/tests/ui/async-await/async-await-let-else.drop-tracking.stderr +++ /dev/null @@ -1,106 +0,0 @@ -error: future cannot be sent between threads safely - --> $DIR/async-await-let-else.rs:48:13 - | -LL | is_send(foo(Some(true))); - | ^^^^^^^^^^^^^^^ future returned by `foo` is not `Send` - | - = help: within `impl Future`, the trait `Send` is not implemented for `Rc<()>` -note: future is not `Send` as this value is used across an await - --> $DIR/async-await-let-else.rs:11:14 - | -LL | let r = Rc::new(()); - | - has type `Rc<()>` which is not `Send` -LL | bar().await - | ^^^^^^ await occurs here, with `r` maybe used later -LL | }; - | - `r` is later dropped here -note: required by a bound in `is_send` - --> $DIR/async-await-let-else.rs:19:15 - | -LL | fn is_send(_: T) {} - | ^^^^ required by this bound in `is_send` - -error[E0277]: `Rc<()>` cannot be sent between threads safely - --> $DIR/async-await-let-else.rs:50:13 - | -LL | async fn foo2(x: Option) { - | - within this `impl Future` -... -LL | is_send(foo2(Some(true))); - | ------- ^^^^^^^^^^^^^^^^ `Rc<()>` cannot be sent between threads safely - | | - | required by a bound introduced by this call - | - = help: within `impl Future`, the trait `Send` is not implemented for `Rc<()>` -note: required because it's used within this `async fn` body - --> $DIR/async-await-let-else.rs:27:29 - | -LL | async fn bar2(_: T) -> ! { - | _____________________________^ -LL | | panic!() -LL | | } - | |_^ - = note: required because it captures the following types: `ResumeTy`, `Option`, `impl Future`, `()` -note: required because it's used within this `async fn` body - --> $DIR/async-await-let-else.rs:21:32 - | -LL | async fn foo2(x: Option) { - | ________________________________^ -LL | | let Some(_) = x else { -LL | | bar2(Rc::new(())).await -LL | | }; -LL | | } - | |_^ -note: required by a bound in `is_send` - --> $DIR/async-await-let-else.rs:19:15 - | -LL | fn is_send(_: T) {} - | ^^^^ required by this bound in `is_send` - -error: future cannot be sent between threads safely - --> $DIR/async-await-let-else.rs:52:13 - | -LL | is_send(foo3(Some(true))); - | ^^^^^^^^^^^^^^^^ future returned by `foo3` is not `Send` - | - = help: within `impl Future`, the trait `Send` is not implemented for `Rc<()>` -note: future is not `Send` as this value is used across an await - --> $DIR/async-await-let-else.rs:33:28 - | -LL | (Rc::new(()), bar().await); - | ----------- ^^^^^^ - `Rc::new(())` is later dropped here - | | | - | | await occurs here, with `Rc::new(())` maybe used later - | has type `Rc<()>` which is not `Send` -note: required by a bound in `is_send` - --> $DIR/async-await-let-else.rs:19:15 - | -LL | fn is_send(_: T) {} - | ^^^^ required by this bound in `is_send` - -error: future cannot be sent between threads safely - --> $DIR/async-await-let-else.rs:54:13 - | -LL | is_send(foo4(Some(true))); - | ^^^^^^^^^^^^^^^^ future returned by `foo4` is not `Send` - | - = help: within `impl Future`, the trait `Send` is not implemented for `Rc<()>` -note: future is not `Send` as this value is used across an await - --> $DIR/async-await-let-else.rs:41:14 - | -LL | let r = Rc::new(()); - | - has type `Rc<()>` which is not `Send` -LL | bar().await; - | ^^^^^^ await occurs here, with `r` maybe used later -... -LL | }; - | - `r` is later dropped here -note: required by a bound in `is_send` - --> $DIR/async-await-let-else.rs:19:15 - | -LL | fn is_send(_: T) {} - | ^^^^ required by this bound in `is_send` - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/async-await/async-await-let-else.drop_tracking.stderr b/tests/ui/async-await/async-await-let-else.drop_tracking.stderr deleted file mode 100644 index dee90262fd4..00000000000 --- a/tests/ui/async-await/async-await-let-else.drop_tracking.stderr +++ /dev/null @@ -1,106 +0,0 @@ -error: future cannot be sent between threads safely - --> $DIR/async-await-let-else.rs:48:13 - | -LL | is_send(foo(Some(true))); - | ^^^^^^^^^^^^^^^ future returned by `foo` is not `Send` - | - = help: within `impl Future`, the trait `Send` is not implemented for `Rc<()>` -note: future is not `Send` as this value is used across an await - --> $DIR/async-await-let-else.rs:11:15 - | -LL | let r = Rc::new(()); - | - has type `Rc<()>` which is not `Send` -LL | bar().await - | ^^^^^ await occurs here, with `r` maybe used later -LL | }; - | - `r` is later dropped here -note: required by a bound in `is_send` - --> $DIR/async-await-let-else.rs:19:15 - | -LL | fn is_send(_: T) {} - | ^^^^ required by this bound in `is_send` - -error[E0277]: `Rc<()>` cannot be sent between threads safely - --> $DIR/async-await-let-else.rs:50:13 - | -LL | async fn foo2(x: Option) { - | - within this `impl Future` -... -LL | is_send(foo2(Some(true))); - | ------- ^^^^^^^^^^^^^^^^ `Rc<()>` cannot be sent between threads safely - | | - | required by a bound introduced by this call - | - = help: within `impl Future`, the trait `Send` is not implemented for `Rc<()>` -note: required because it's used within this `async fn` body - --> $DIR/async-await-let-else.rs:27:29 - | -LL | async fn bar2(_: T) -> ! { - | _____________________________^ -LL | | panic!() -LL | | } - | |_^ - = note: required because it captures the following types: `ResumeTy`, `Option`, `impl Future`, `()` -note: required because it's used within this `async fn` body - --> $DIR/async-await-let-else.rs:21:32 - | -LL | async fn foo2(x: Option) { - | ________________________________^ -LL | | let Some(_) = x else { -LL | | bar2(Rc::new(())).await -LL | | }; -LL | | } - | |_^ -note: required by a bound in `is_send` - --> $DIR/async-await-let-else.rs:19:15 - | -LL | fn is_send(_: T) {} - | ^^^^ required by this bound in `is_send` - -error: future cannot be sent between threads safely - --> $DIR/async-await-let-else.rs:52:13 - | -LL | is_send(foo3(Some(true))); - | ^^^^^^^^^^^^^^^^ future returned by `foo3` is not `Send` - | - = help: within `impl Future`, the trait `Send` is not implemented for `Rc<()>` -note: future is not `Send` as this value is used across an await - --> $DIR/async-await-let-else.rs:33:29 - | -LL | (Rc::new(()), bar().await); - | ----------- ^^^^^ - `Rc::new(())` is later dropped here - | | | - | | await occurs here, with `Rc::new(())` maybe used later - | has type `Rc<()>` which is not `Send` -note: required by a bound in `is_send` - --> $DIR/async-await-let-else.rs:19:15 - | -LL | fn is_send(_: T) {} - | ^^^^ required by this bound in `is_send` - -error: future cannot be sent between threads safely - --> $DIR/async-await-let-else.rs:54:13 - | -LL | is_send(foo4(Some(true))); - | ^^^^^^^^^^^^^^^^ future returned by `foo4` is not `Send` - | - = help: within `impl Future`, the trait `Send` is not implemented for `Rc<()>` -note: future is not `Send` as this value is used across an await - --> $DIR/async-await-let-else.rs:41:15 - | -LL | let r = Rc::new(()); - | - has type `Rc<()>` which is not `Send` -LL | bar().await; - | ^^^^^ await occurs here, with `r` maybe used later -... -LL | }; - | - `r` is later dropped here -note: required by a bound in `is_send` - --> $DIR/async-await-let-else.rs:19:15 - | -LL | fn is_send(_: T) {} - | ^^^^ required by this bound in `is_send` - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/async-await/async-await-let-else.drop_tracking_mir.stderr b/tests/ui/async-await/async-await-let-else.drop_tracking_mir.stderr deleted file mode 100644 index e3fcceaa392..00000000000 --- a/tests/ui/async-await/async-await-let-else.drop_tracking_mir.stderr +++ /dev/null @@ -1,100 +0,0 @@ -error: future cannot be sent between threads safely - --> $DIR/async-await-let-else.rs:48:13 - | -LL | is_send(foo(Some(true))); - | ^^^^^^^^^^^^^^^ future returned by `foo` is not `Send` - | - = help: within `impl Future`, the trait `Send` is not implemented for `Rc<()>` -note: future is not `Send` as this value is used across an await - --> $DIR/async-await-let-else.rs:11:15 - | -LL | let r = Rc::new(()); - | - has type `Rc<()>` which is not `Send` -LL | bar().await - | ^^^^^ await occurs here, with `r` maybe used later -note: required by a bound in `is_send` - --> $DIR/async-await-let-else.rs:19:15 - | -LL | fn is_send(_: T) {} - | ^^^^ required by this bound in `is_send` - -error[E0277]: `Rc<()>` cannot be sent between threads safely - --> $DIR/async-await-let-else.rs:50:13 - | -LL | async fn foo2(x: Option) { - | - within this `impl Future` -... -LL | is_send(foo2(Some(true))); - | ------- ^^^^^^^^^^^^^^^^ `Rc<()>` cannot be sent between threads safely - | | - | required by a bound introduced by this call - | - = help: within `impl Future`, the trait `Send` is not implemented for `Rc<()>` -note: required because it's used within this `async fn` body - --> $DIR/async-await-let-else.rs:27:29 - | -LL | async fn bar2(_: T) -> ! { - | _____________________________^ -LL | | panic!() -LL | | } - | |_^ - = note: required because it captures the following types: `impl Future` -note: required because it's used within this `async fn` body - --> $DIR/async-await-let-else.rs:21:32 - | -LL | async fn foo2(x: Option) { - | ________________________________^ -LL | | let Some(_) = x else { -LL | | bar2(Rc::new(())).await -LL | | }; -LL | | } - | |_^ -note: required by a bound in `is_send` - --> $DIR/async-await-let-else.rs:19:15 - | -LL | fn is_send(_: T) {} - | ^^^^ required by this bound in `is_send` - -error: future cannot be sent between threads safely - --> $DIR/async-await-let-else.rs:52:13 - | -LL | is_send(foo3(Some(true))); - | ^^^^^^^^^^^^^^^^ future returned by `foo3` is not `Send` - | - = help: within `impl Future`, the trait `Send` is not implemented for `Rc<()>` -note: future is not `Send` as this value is used across an await - --> $DIR/async-await-let-else.rs:33:29 - | -LL | (Rc::new(()), bar().await); - | ----------- ^^^^^ await occurs here, with `Rc::new(())` maybe used later - | | - | has type `Rc<()>` which is not `Send` -note: required by a bound in `is_send` - --> $DIR/async-await-let-else.rs:19:15 - | -LL | fn is_send(_: T) {} - | ^^^^ required by this bound in `is_send` - -error: future cannot be sent between threads safely - --> $DIR/async-await-let-else.rs:54:13 - | -LL | is_send(foo4(Some(true))); - | ^^^^^^^^^^^^^^^^ future returned by `foo4` is not `Send` - | - = help: within `impl Future`, the trait `Send` is not implemented for `Rc<()>` -note: future is not `Send` as this value is used across an await - --> $DIR/async-await-let-else.rs:41:15 - | -LL | let r = Rc::new(()); - | - has type `Rc<()>` which is not `Send` -LL | bar().await; - | ^^^^^ await occurs here, with `r` maybe used later -note: required by a bound in `is_send` - --> $DIR/async-await-let-else.rs:19:15 - | -LL | fn is_send(_: T) {} - | ^^^^ required by this bound in `is_send` - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/async-await/async-await-let-else.no-drop-tracking.stderr b/tests/ui/async-await/async-await-let-else.no-drop-tracking.stderr deleted file mode 100644 index d3c5e80a30d..00000000000 --- a/tests/ui/async-await/async-await-let-else.no-drop-tracking.stderr +++ /dev/null @@ -1,90 +0,0 @@ -error: future cannot be sent between threads safely - --> $DIR/async-await-let-else.rs:48:13 - | -LL | is_send(foo(Some(true))); - | ^^^^^^^^^^^^^^^ future returned by `foo` is not `Send` - | - = help: within `impl Future`, the trait `Send` is not implemented for `Rc<()>` -note: future is not `Send` as this value is used across an await - --> $DIR/async-await-let-else.rs:11:14 - | -LL | let r = Rc::new(()); - | - has type `Rc<()>` which is not `Send` -LL | bar().await - | ^^^^^^ await occurs here, with `r` maybe used later -LL | }; - | - `r` is later dropped here -note: required by a bound in `is_send` - --> $DIR/async-await-let-else.rs:19:15 - | -LL | fn is_send(_: T) {} - | ^^^^ required by this bound in `is_send` - -error: future cannot be sent between threads safely - --> $DIR/async-await-let-else.rs:50:13 - | -LL | is_send(foo2(Some(true))); - | ^^^^^^^^^^^^^^^^ future returned by `foo2` is not `Send` - | - = help: within `impl Future`, the trait `Send` is not implemented for `Rc<()>` -note: future is not `Send` as this value is used across an await - --> $DIR/async-await-let-else.rs:23:26 - | -LL | bar2(Rc::new(())).await - | ----------- ^^^^^^ await occurs here, with `Rc::new(())` maybe used later - | | - | has type `Rc<()>` which is not `Send` -LL | }; - | - `Rc::new(())` is later dropped here -note: required by a bound in `is_send` - --> $DIR/async-await-let-else.rs:19:15 - | -LL | fn is_send(_: T) {} - | ^^^^ required by this bound in `is_send` - -error: future cannot be sent between threads safely - --> $DIR/async-await-let-else.rs:52:13 - | -LL | is_send(foo3(Some(true))); - | ^^^^^^^^^^^^^^^^ future returned by `foo3` is not `Send` - | - = help: within `impl Future`, the trait `Send` is not implemented for `Rc<()>` -note: future is not `Send` as this value is used across an await - --> $DIR/async-await-let-else.rs:33:28 - | -LL | (Rc::new(()), bar().await); - | ----------- ^^^^^^ - `Rc::new(())` is later dropped here - | | | - | | await occurs here, with `Rc::new(())` maybe used later - | has type `Rc<()>` which is not `Send` -note: required by a bound in `is_send` - --> $DIR/async-await-let-else.rs:19:15 - | -LL | fn is_send(_: T) {} - | ^^^^ required by this bound in `is_send` - -error: future cannot be sent between threads safely - --> $DIR/async-await-let-else.rs:54:13 - | -LL | is_send(foo4(Some(true))); - | ^^^^^^^^^^^^^^^^ future returned by `foo4` is not `Send` - | - = help: within `impl Future`, the trait `Send` is not implemented for `Rc<()>` -note: future is not `Send` as this value is used across an await - --> $DIR/async-await-let-else.rs:41:14 - | -LL | let r = Rc::new(()); - | - has type `Rc<()>` which is not `Send` -LL | bar().await; - | ^^^^^^ await occurs here, with `r` maybe used later -... -LL | }; - | - `r` is later dropped here -note: required by a bound in `is_send` - --> $DIR/async-await-let-else.rs:19:15 - | -LL | fn is_send(_: T) {} - | ^^^^ required by this bound in `is_send` - -error: aborting due to 4 previous errors - diff --git a/tests/ui/async-await/async-await-let-else.rs b/tests/ui/async-await/async-await-let-else.rs index 113d576b5e7..a3c7226056b 100644 --- a/tests/ui/async-await/async-await-let-else.rs +++ b/tests/ui/async-await/async-await-let-else.rs @@ -1,7 +1,4 @@ // edition:2021 -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir use std::rc::Rc; diff --git a/tests/ui/async-await/async-await-let-else.no_drop_tracking.stderr b/tests/ui/async-await/async-await-let-else.stderr similarity index 85% rename from tests/ui/async-await/async-await-let-else.no_drop_tracking.stderr rename to tests/ui/async-await/async-await-let-else.stderr index ece4e51ecff..b47201502f6 100644 --- a/tests/ui/async-await/async-await-let-else.no_drop_tracking.stderr +++ b/tests/ui/async-await/async-await-let-else.stderr @@ -1,12 +1,12 @@ error: future cannot be sent between threads safely - --> $DIR/async-await-let-else.rs:48:13 + --> $DIR/async-await-let-else.rs:45:13 | LL | is_send(foo(Some(true))); | ^^^^^^^^^^^^^^^ future returned by `foo` is not `Send` | = help: within `impl Future`, the trait `Send` is not implemented for `Rc<()>` note: future is not `Send` as this value is used across an await - --> $DIR/async-await-let-else.rs:11:15 + --> $DIR/async-await-let-else.rs:8:15 | LL | let r = Rc::new(()); | - has type `Rc<()>` which is not `Send` @@ -15,20 +15,20 @@ LL | bar().await LL | }; | - `r` is later dropped here note: required by a bound in `is_send` - --> $DIR/async-await-let-else.rs:19:15 + --> $DIR/async-await-let-else.rs:16:15 | LL | fn is_send(_: T) {} | ^^^^ required by this bound in `is_send` error: future cannot be sent between threads safely - --> $DIR/async-await-let-else.rs:50:13 + --> $DIR/async-await-let-else.rs:47:13 | LL | is_send(foo2(Some(true))); | ^^^^^^^^^^^^^^^^ future returned by `foo2` is not `Send` | = help: within `impl Future`, the trait `Send` is not implemented for `Rc<()>` note: future is not `Send` as this value is used across an await - --> $DIR/async-await-let-else.rs:23:27 + --> $DIR/async-await-let-else.rs:20:27 | LL | bar2(Rc::new(())).await | ----------- ^^^^^ await occurs here, with `Rc::new(())` maybe used later @@ -37,20 +37,20 @@ LL | bar2(Rc::new(())).await LL | }; | - `Rc::new(())` is later dropped here note: required by a bound in `is_send` - --> $DIR/async-await-let-else.rs:19:15 + --> $DIR/async-await-let-else.rs:16:15 | LL | fn is_send(_: T) {} | ^^^^ required by this bound in `is_send` error: future cannot be sent between threads safely - --> $DIR/async-await-let-else.rs:52:13 + --> $DIR/async-await-let-else.rs:49:13 | LL | is_send(foo3(Some(true))); | ^^^^^^^^^^^^^^^^ future returned by `foo3` is not `Send` | = help: within `impl Future`, the trait `Send` is not implemented for `Rc<()>` note: future is not `Send` as this value is used across an await - --> $DIR/async-await-let-else.rs:33:29 + --> $DIR/async-await-let-else.rs:30:29 | LL | (Rc::new(()), bar().await); | ----------- ^^^^^ - `Rc::new(())` is later dropped here @@ -58,20 +58,20 @@ LL | (Rc::new(()), bar().await); | | await occurs here, with `Rc::new(())` maybe used later | has type `Rc<()>` which is not `Send` note: required by a bound in `is_send` - --> $DIR/async-await-let-else.rs:19:15 + --> $DIR/async-await-let-else.rs:16:15 | LL | fn is_send(_: T) {} | ^^^^ required by this bound in `is_send` error: future cannot be sent between threads safely - --> $DIR/async-await-let-else.rs:54:13 + --> $DIR/async-await-let-else.rs:51:13 | LL | is_send(foo4(Some(true))); | ^^^^^^^^^^^^^^^^ future returned by `foo4` is not `Send` | = help: within `impl Future`, the trait `Send` is not implemented for `Rc<()>` note: future is not `Send` as this value is used across an await - --> $DIR/async-await-let-else.rs:41:15 + --> $DIR/async-await-let-else.rs:38:15 | LL | let r = Rc::new(()); | - has type `Rc<()>` which is not `Send` @@ -81,7 +81,7 @@ LL | bar().await; LL | }; | - `r` is later dropped here note: required by a bound in `is_send` - --> $DIR/async-await-let-else.rs:19:15 + --> $DIR/async-await-let-else.rs:16:15 | LL | fn is_send(_: T) {} | ^^^^ required by this bound in `is_send` diff --git a/tests/ui/async-await/async-error-span.drop_tracking_mir.stderr b/tests/ui/async-await/async-error-span.drop_tracking_mir.stderr deleted file mode 100644 index 2f29ee6cdb0..00000000000 --- a/tests/ui/async-await/async-error-span.drop_tracking_mir.stderr +++ /dev/null @@ -1,24 +0,0 @@ -error[E0277]: `()` is not a future - --> $DIR/async-error-span.rs:10:20 - | -LL | fn get_future() -> impl Future { - | ^^^^^^^^^^^^^^^^^^^^^^^^ `()` is not a future - | - = help: the trait `Future` is not implemented for `()` - = note: () must be a future or must implement `IntoFuture` to be awaited - -error[E0282]: type annotations needed - --> $DIR/async-error-span.rs:16:9 - | -LL | let a; - | ^ - | -help: consider giving `a` an explicit type - | -LL | let a: /* Type */; - | ++++++++++++ - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0277, E0282. -For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/async-await/async-error-span.no_drop_tracking.stderr b/tests/ui/async-await/async-error-span.no_drop_tracking.stderr deleted file mode 100644 index 99a674a2684..00000000000 --- a/tests/ui/async-await/async-error-span.no_drop_tracking.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error[E0277]: `()` is not a future - --> $DIR/async-error-span.rs:10:20 - | -LL | fn get_future() -> impl Future { - | ^^^^^^^^^^^^^^^^^^^^^^^^ `()` is not a future - | - = help: the trait `Future` is not implemented for `()` - = note: () must be a future or must implement `IntoFuture` to be awaited - -error[E0698]: type inside `async fn` body must be known in this context - --> $DIR/async-error-span.rs:16:9 - | -LL | let a; - | ^ cannot infer type - | -note: the type is part of the `async fn` body because of this `await` - --> $DIR/async-error-span.rs:19:18 - | -LL | get_future().await; - | ^^^^^ - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0277, E0698. -For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/async-await/async-error-span.rs b/tests/ui/async-await/async-error-span.rs index c9ecf359e3d..86d459bf084 100644 --- a/tests/ui/async-await/async-error-span.rs +++ b/tests/ui/async-await/async-error-span.rs @@ -1,6 +1,3 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir // edition:2018 // Regression test for issue #62382. @@ -13,9 +10,7 @@ fn get_future() -> impl Future { } async fn foo() { - let a; - //[no_drop_tracking,drop_tracking]~^ ERROR type inside `async fn` body must be known in this context - //[drop_tracking_mir]~^^ ERROR type annotations needed + let a; //~ ERROR type inside `async fn` body must be known in this context get_future().await; } diff --git a/tests/ui/async-await/async-error-span.drop_tracking.stderr b/tests/ui/async-await/async-error-span.stderr similarity index 86% rename from tests/ui/async-await/async-error-span.drop_tracking.stderr rename to tests/ui/async-await/async-error-span.stderr index 99a674a2684..68fb385718e 100644 --- a/tests/ui/async-await/async-error-span.drop_tracking.stderr +++ b/tests/ui/async-await/async-error-span.stderr @@ -1,5 +1,5 @@ error[E0277]: `()` is not a future - --> $DIR/async-error-span.rs:10:20 + --> $DIR/async-error-span.rs:7:20 | LL | fn get_future() -> impl Future { | ^^^^^^^^^^^^^^^^^^^^^^^^ `()` is not a future @@ -8,13 +8,13 @@ LL | fn get_future() -> impl Future { = note: () must be a future or must implement `IntoFuture` to be awaited error[E0698]: type inside `async fn` body must be known in this context - --> $DIR/async-error-span.rs:16:9 + --> $DIR/async-error-span.rs:13:9 | LL | let a; | ^ cannot infer type | note: the type is part of the `async fn` body because of this `await` - --> $DIR/async-error-span.rs:19:18 + --> $DIR/async-error-span.rs:14:18 | LL | get_future().await; | ^^^^^ diff --git a/tests/ui/async-await/async-fn-nonsend.drop_tracking_mir.stderr b/tests/ui/async-await/async-fn-nonsend.drop_tracking_mir.stderr deleted file mode 100644 index 219945e0971..00000000000 --- a/tests/ui/async-await/async-fn-nonsend.drop_tracking_mir.stderr +++ /dev/null @@ -1,43 +0,0 @@ -error: future cannot be sent between threads safely - --> $DIR/async-fn-nonsend.rs:72:17 - | -LL | assert_send(non_send_temporary_in_match()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `non_send_temporary_in_match` is not `Send` - | - = help: within `impl Future`, the trait `Send` is not implemented for `Rc<()>` -note: future is not `Send` as this value is used across an await - --> $DIR/async-fn-nonsend.rs:36:26 - | -LL | match Some(non_send()) { - | ---------------- has type `Option` which is not `Send` -LL | Some(_) => fut().await, - | ^^^^^ await occurs here, with `Some(non_send())` maybe used later -note: required by a bound in `assert_send` - --> $DIR/async-fn-nonsend.rs:67:24 - | -LL | fn assert_send(_: impl Send) {} - | ^^^^ required by this bound in `assert_send` - -error: future cannot be sent between threads safely - --> $DIR/async-fn-nonsend.rs:74:17 - | -LL | assert_send(non_sync_with_method_call()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `non_sync_with_method_call` is not `Send` - | - = help: within `impl Future`, the trait `Send` is not implemented for `dyn std::fmt::Write` -note: future is not `Send` as this value is used across an await - --> $DIR/async-fn-nonsend.rs:49:15 - | -LL | let f: &mut std::fmt::Formatter = &mut get_formatter(); - | --------------- has type `Formatter<'_>` which is not `Send` -... -LL | fut().await; - | ^^^^^ await occurs here, with `get_formatter()` maybe used later -note: required by a bound in `assert_send` - --> $DIR/async-fn-nonsend.rs:67:24 - | -LL | fn assert_send(_: impl Send) {} - | ^^^^ required by this bound in `assert_send` - -error: aborting due to 2 previous errors - diff --git a/tests/ui/async-await/async-fn-nonsend.no_drop_tracking.stderr b/tests/ui/async-await/async-fn-nonsend.no_drop_tracking.stderr deleted file mode 100644 index b29d2e192f4..00000000000 --- a/tests/ui/async-await/async-fn-nonsend.no_drop_tracking.stderr +++ /dev/null @@ -1,120 +0,0 @@ -error: future cannot be sent between threads safely - --> $DIR/async-fn-nonsend.rs:70:17 - | -LL | assert_send(local_dropped_before_await()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `local_dropped_before_await` is not `Send` - | - = help: within `impl Future`, the trait `Send` is not implemented for `Rc<()>` -note: future is not `Send` as this value is used across an await - --> $DIR/async-fn-nonsend.rs:27:11 - | -LL | let x = non_send(); - | - has type `impl Debug` which is not `Send` -LL | drop(x); -LL | fut().await; - | ^^^^^ await occurs here, with `x` maybe used later -LL | } - | - `x` is later dropped here -note: required by a bound in `assert_send` - --> $DIR/async-fn-nonsend.rs:67:24 - | -LL | fn assert_send(_: impl Send) {} - | ^^^^ required by this bound in `assert_send` - -error: future cannot be sent between threads safely - --> $DIR/async-fn-nonsend.rs:72:17 - | -LL | assert_send(non_send_temporary_in_match()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `non_send_temporary_in_match` is not `Send` - | - = help: within `impl Future`, the trait `Send` is not implemented for `Rc<()>` -note: future is not `Send` as this value is used across an await - --> $DIR/async-fn-nonsend.rs:36:26 - | -LL | match Some(non_send()) { - | ---------- has type `impl Debug` which is not `Send` -LL | Some(_) => fut().await, - | ^^^^^ await occurs here, with `non_send()` maybe used later -... -LL | } - | - `non_send()` is later dropped here -note: required by a bound in `assert_send` - --> $DIR/async-fn-nonsend.rs:67:24 - | -LL | fn assert_send(_: impl Send) {} - | ^^^^ required by this bound in `assert_send` - -error: future cannot be sent between threads safely - --> $DIR/async-fn-nonsend.rs:74:17 - | -LL | assert_send(non_sync_with_method_call()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `non_sync_with_method_call` is not `Send` - | - = help: within `impl Future`, the trait `Send` is not implemented for `dyn std::fmt::Write` -note: future is not `Send` as this value is used across an await - --> $DIR/async-fn-nonsend.rs:49:15 - | -LL | let f: &mut std::fmt::Formatter = &mut get_formatter(); - | --------------- has type `Formatter<'_>` which is not `Send` -... -LL | fut().await; - | ^^^^^ await occurs here, with `get_formatter()` maybe used later -LL | } -LL | } - | - `get_formatter()` is later dropped here -note: required by a bound in `assert_send` - --> $DIR/async-fn-nonsend.rs:67:24 - | -LL | fn assert_send(_: impl Send) {} - | ^^^^ required by this bound in `assert_send` - -error: future cannot be sent between threads safely - --> $DIR/async-fn-nonsend.rs:76:17 - | -LL | assert_send(non_sync_with_method_call_panic()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `non_sync_with_method_call_panic` is not `Send` - | - = help: within `impl Future`, the trait `Send` is not implemented for `dyn std::fmt::Write` -note: future is not `Send` as this value is used across an await - --> $DIR/async-fn-nonsend.rs:56:15 - | -LL | let f: &mut std::fmt::Formatter = panic!(); - | - has type `&mut Formatter<'_>` which is not `Send` -LL | if non_sync().fmt(f).unwrap() == () { -LL | fut().await; - | ^^^^^ await occurs here, with `f` maybe used later -LL | } -LL | } - | - `f` is later dropped here -note: required by a bound in `assert_send` - --> $DIR/async-fn-nonsend.rs:67:24 - | -LL | fn assert_send(_: impl Send) {} - | ^^^^ required by this bound in `assert_send` - -error: future cannot be sent between threads safely - --> $DIR/async-fn-nonsend.rs:78:17 - | -LL | assert_send(non_sync_with_method_call_infinite_loop()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `non_sync_with_method_call_infinite_loop` is not `Send` - | - = help: within `impl Future`, the trait `Send` is not implemented for `dyn std::fmt::Write` -note: future is not `Send` as this value is used across an await - --> $DIR/async-fn-nonsend.rs:63:15 - | -LL | let f: &mut std::fmt::Formatter = loop {}; - | - has type `&mut Formatter<'_>` which is not `Send` -LL | if non_sync().fmt(f).unwrap() == () { -LL | fut().await; - | ^^^^^ await occurs here, with `f` maybe used later -LL | } -LL | } - | - `f` is later dropped here -note: required by a bound in `assert_send` - --> $DIR/async-fn-nonsend.rs:67:24 - | -LL | fn assert_send(_: impl Send) {} - | ^^^^ required by this bound in `assert_send` - -error: aborting due to 5 previous errors - diff --git a/tests/ui/async-await/async-fn-nonsend.rs b/tests/ui/async-await/async-fn-nonsend.rs index ed440bd0182..d7f8d7ac546 100644 --- a/tests/ui/async-await/async-fn-nonsend.rs +++ b/tests/ui/async-await/async-fn-nonsend.rs @@ -1,8 +1,5 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir // edition:2018 -// compile-flags: --crate-type lib +// compile-flags: --crate-type lib -Zdrop-tracking use std::{cell::RefCell, fmt::Debug, rc::Rc}; @@ -68,13 +65,10 @@ fn assert_send(_: impl Send) {} pub fn pass_assert() { assert_send(local_dropped_before_await()); - //[no_drop_tracking]~^ ERROR future cannot be sent between threads safely assert_send(non_send_temporary_in_match()); //~^ ERROR future cannot be sent between threads safely assert_send(non_sync_with_method_call()); //~^ ERROR future cannot be sent between threads safely assert_send(non_sync_with_method_call_panic()); - //[no_drop_tracking]~^ ERROR future cannot be sent between threads safely assert_send(non_sync_with_method_call_infinite_loop()); - //[no_drop_tracking]~^ ERROR future cannot be sent between threads safely } diff --git a/tests/ui/async-await/async-fn-nonsend.drop_tracking.stderr b/tests/ui/async-await/async-fn-nonsend.stderr similarity index 89% rename from tests/ui/async-await/async-fn-nonsend.drop_tracking.stderr rename to tests/ui/async-await/async-fn-nonsend.stderr index 0515edaeda3..0d00fc072e1 100644 --- a/tests/ui/async-await/async-fn-nonsend.drop_tracking.stderr +++ b/tests/ui/async-await/async-fn-nonsend.stderr @@ -1,12 +1,12 @@ error: future cannot be sent between threads safely - --> $DIR/async-fn-nonsend.rs:72:17 + --> $DIR/async-fn-nonsend.rs:68:17 | LL | assert_send(non_send_temporary_in_match()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `non_send_temporary_in_match` is not `Send` | = help: within `impl Future`, the trait `Send` is not implemented for `Rc<()>` note: future is not `Send` as this value is used across an await - --> $DIR/async-fn-nonsend.rs:36:26 + --> $DIR/async-fn-nonsend.rs:33:26 | LL | match Some(non_send()) { | ---------------- has type `Option` which is not `Send` @@ -16,20 +16,20 @@ LL | Some(_) => fut().await, LL | } | - `Some(non_send())` is later dropped here note: required by a bound in `assert_send` - --> $DIR/async-fn-nonsend.rs:67:24 + --> $DIR/async-fn-nonsend.rs:64:24 | LL | fn assert_send(_: impl Send) {} | ^^^^ required by this bound in `assert_send` error: future cannot be sent between threads safely - --> $DIR/async-fn-nonsend.rs:74:17 + --> $DIR/async-fn-nonsend.rs:70:17 | LL | assert_send(non_sync_with_method_call()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `non_sync_with_method_call` is not `Send` | = help: within `impl Future`, the trait `Send` is not implemented for `dyn std::fmt::Write` note: future is not `Send` as this value is used across an await - --> $DIR/async-fn-nonsend.rs:49:15 + --> $DIR/async-fn-nonsend.rs:46:15 | LL | let f: &mut std::fmt::Formatter = &mut get_formatter(); | --------------- has type `Formatter<'_>` which is not `Send` @@ -40,7 +40,7 @@ LL | } LL | } | - `get_formatter()` is later dropped here note: required by a bound in `assert_send` - --> $DIR/async-fn-nonsend.rs:67:24 + --> $DIR/async-fn-nonsend.rs:64:24 | LL | fn assert_send(_: impl Send) {} | ^^^^ required by this bound in `assert_send` diff --git a/tests/ui/async-await/awaiting-unsized-param.drop_tracking_mir.stderr b/tests/ui/async-await/awaiting-unsized-param.drop_tracking_mir.stderr deleted file mode 100644 index 02cf8310a50..00000000000 --- a/tests/ui/async-await/awaiting-unsized-param.drop_tracking_mir.stderr +++ /dev/null @@ -1,21 +0,0 @@ -warning: the feature `unsized_locals` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/awaiting-unsized-param.rs:5:31 - | -LL | #![feature(unsized_fn_params, unsized_locals)] - | ^^^^^^^^^^^^^^ - | - = note: see issue #48055 for more information - = note: `#[warn(incomplete_features)]` on by default - -error[E0277]: the size for values of type `(dyn Future + Unpin + 'static)` cannot be known at compilation time - --> $DIR/awaiting-unsized-param.rs:10:17 - | -LL | async fn bug(mut f: dyn Future + Unpin) -> T { - | ^^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `(dyn Future + Unpin + 'static)` - = note: all values captured by value by a closure must have a statically known size - -error: aborting due to previous error; 1 warning emitted - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/async-await/awaiting-unsized-param.rs b/tests/ui/async-await/awaiting-unsized-param.rs index 2af8723b312..e8b18bf37f8 100644 --- a/tests/ui/async-await/awaiting-unsized-param.rs +++ b/tests/ui/async-await/awaiting-unsized-param.rs @@ -1,6 +1,4 @@ // edition: 2021 -// revisions: no_drop_tracking drop_tracking_mir -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir #![feature(unsized_fn_params, unsized_locals)] //~^ WARN the feature `unsized_locals` is incomplete diff --git a/tests/ui/async-await/awaiting-unsized-param.no_drop_tracking.stderr b/tests/ui/async-await/awaiting-unsized-param.stderr similarity index 91% rename from tests/ui/async-await/awaiting-unsized-param.no_drop_tracking.stderr rename to tests/ui/async-await/awaiting-unsized-param.stderr index 02cf8310a50..47a5dcebf25 100644 --- a/tests/ui/async-await/awaiting-unsized-param.no_drop_tracking.stderr +++ b/tests/ui/async-await/awaiting-unsized-param.stderr @@ -1,5 +1,5 @@ warning: the feature `unsized_locals` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/awaiting-unsized-param.rs:5:31 + --> $DIR/awaiting-unsized-param.rs:3:31 | LL | #![feature(unsized_fn_params, unsized_locals)] | ^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | #![feature(unsized_fn_params, unsized_locals)] = note: `#[warn(incomplete_features)]` on by default error[E0277]: the size for values of type `(dyn Future + Unpin + 'static)` cannot be known at compilation time - --> $DIR/awaiting-unsized-param.rs:10:17 + --> $DIR/awaiting-unsized-param.rs:8:17 | LL | async fn bug(mut f: dyn Future + Unpin) -> T { | ^^^^^ doesn't have a size known at compile-time diff --git a/tests/ui/async-await/default-struct-update.rs b/tests/ui/async-await/default-struct-update.rs index daee8469a14..64fb6280dd7 100644 --- a/tests/ui/async-await/default-struct-update.rs +++ b/tests/ui/async-await/default-struct-update.rs @@ -1,8 +1,6 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir // build-pass // edition:2018 +// compile-flags: -Zdrop-tracking=y fn main() { let _ = foo(); diff --git a/tests/ui/async-await/drop-and-assign.rs b/tests/ui/async-await/drop-and-assign.rs index e520dfbdcce..fa3f3303677 100644 --- a/tests/ui/async-await/drop-and-assign.rs +++ b/tests/ui/async-await/drop-and-assign.rs @@ -1,7 +1,5 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir // edition:2021 +// compile-flags: -Zdrop-tracking // build-pass struct A; diff --git a/tests/ui/async-await/drop-track-field-assign-nonsend.drop_tracking.stderr b/tests/ui/async-await/drop-track-field-assign-nonsend.drop_tracking.stderr deleted file mode 100644 index 80402d8424d..00000000000 --- a/tests/ui/async-await/drop-track-field-assign-nonsend.drop_tracking.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error: future cannot be sent between threads safely - --> $DIR/drop-track-field-assign-nonsend.rs:45:17 - | -LL | assert_send(agent.handle()); - | ^^^^^^^^^^^^^^ future returned by `handle` is not `Send` - | - = help: within `impl Future`, the trait `Send` is not implemented for `Rc` -note: future is not `Send` as this value is used across an await - --> $DIR/drop-track-field-assign-nonsend.rs:23:39 - | -LL | let mut info = self.info_result.clone(); - | -------- has type `InfoResult` which is not `Send` -... -LL | let _ = send_element(element).await; - | ^^^^^ await occurs here, with `mut info` maybe used later -LL | } - | - `mut info` is later dropped here -note: required by a bound in `assert_send` - --> $DIR/drop-track-field-assign-nonsend.rs:40:19 - | -LL | fn assert_send(_: T) {} - | ^^^^ required by this bound in `assert_send` - -error: aborting due to previous error - diff --git a/tests/ui/async-await/drop-track-field-assign-nonsend.drop_tracking_mir.stderr b/tests/ui/async-await/drop-track-field-assign-nonsend.drop_tracking_mir.stderr deleted file mode 100644 index d9141cf4e36..00000000000 --- a/tests/ui/async-await/drop-track-field-assign-nonsend.drop_tracking_mir.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error: future cannot be sent between threads safely - --> $DIR/drop-track-field-assign-nonsend.rs:45:17 - | -LL | assert_send(agent.handle()); - | ^^^^^^^^^^^^^^ future returned by `handle` is not `Send` - | - = help: within `impl Future`, the trait `Send` is not implemented for `Rc` -note: future is not `Send` as this value is used across an await - --> $DIR/drop-track-field-assign-nonsend.rs:23:39 - | -LL | let mut info = self.info_result.clone(); - | -------- has type `InfoResult` which is not `Send` -... -LL | let _ = send_element(element).await; - | ^^^^^ await occurs here, with `mut info` maybe used later -note: required by a bound in `assert_send` - --> $DIR/drop-track-field-assign-nonsend.rs:40:19 - | -LL | fn assert_send(_: T) {} - | ^^^^ required by this bound in `assert_send` - -error: aborting due to previous error - diff --git a/tests/ui/async-await/drop-track-field-assign-nonsend.no_drop_tracking.stderr b/tests/ui/async-await/drop-track-field-assign-nonsend.no_drop_tracking.stderr deleted file mode 100644 index 80402d8424d..00000000000 --- a/tests/ui/async-await/drop-track-field-assign-nonsend.no_drop_tracking.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error: future cannot be sent between threads safely - --> $DIR/drop-track-field-assign-nonsend.rs:45:17 - | -LL | assert_send(agent.handle()); - | ^^^^^^^^^^^^^^ future returned by `handle` is not `Send` - | - = help: within `impl Future`, the trait `Send` is not implemented for `Rc` -note: future is not `Send` as this value is used across an await - --> $DIR/drop-track-field-assign-nonsend.rs:23:39 - | -LL | let mut info = self.info_result.clone(); - | -------- has type `InfoResult` which is not `Send` -... -LL | let _ = send_element(element).await; - | ^^^^^ await occurs here, with `mut info` maybe used later -LL | } - | - `mut info` is later dropped here -note: required by a bound in `assert_send` - --> $DIR/drop-track-field-assign-nonsend.rs:40:19 - | -LL | fn assert_send(_: T) {} - | ^^^^ required by this bound in `assert_send` - -error: aborting due to previous error - diff --git a/tests/ui/async-await/drop-track-field-assign-nonsend.rs b/tests/ui/async-await/drop-track-field-assign-nonsend.rs index 3e22280008f..b6c0fda1521 100644 --- a/tests/ui/async-await/drop-track-field-assign-nonsend.rs +++ b/tests/ui/async-await/drop-track-field-assign-nonsend.rs @@ -1,8 +1,6 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir // Derived from an ICE found in tokio-xmpp during a crater run. // edition:2021 +// compile-flags: -Zdrop-tracking #![allow(dead_code)] diff --git a/tests/ui/async-await/field-assign-nonsend.drop_tracking.stderr b/tests/ui/async-await/drop-track-field-assign-nonsend.stderr similarity index 84% rename from tests/ui/async-await/field-assign-nonsend.drop_tracking.stderr rename to tests/ui/async-await/drop-track-field-assign-nonsend.stderr index e2e64c9ae0c..f36207b38a1 100644 --- a/tests/ui/async-await/field-assign-nonsend.drop_tracking.stderr +++ b/tests/ui/async-await/drop-track-field-assign-nonsend.stderr @@ -1,12 +1,12 @@ error: future cannot be sent between threads safely - --> $DIR/field-assign-nonsend.rs:45:17 + --> $DIR/drop-track-field-assign-nonsend.rs:43:17 | LL | assert_send(agent.handle()); | ^^^^^^^^^^^^^^ future returned by `handle` is not `Send` | = help: within `impl Future`, the trait `Send` is not implemented for `Rc` note: future is not `Send` as this value is used across an await - --> $DIR/field-assign-nonsend.rs:23:39 + --> $DIR/drop-track-field-assign-nonsend.rs:21:39 | LL | let mut info = self.info_result.clone(); | -------- has type `InfoResult` which is not `Send` @@ -16,7 +16,7 @@ LL | let _ = send_element(element).await; LL | } | - `mut info` is later dropped here note: required by a bound in `assert_send` - --> $DIR/field-assign-nonsend.rs:40:19 + --> $DIR/drop-track-field-assign-nonsend.rs:38:19 | LL | fn assert_send(_: T) {} | ^^^^ required by this bound in `assert_send` diff --git a/tests/ui/async-await/drop-track-field-assign.rs b/tests/ui/async-await/drop-track-field-assign.rs index b79d2af066a..cfea7db2a10 100644 --- a/tests/ui/async-await/drop-track-field-assign.rs +++ b/tests/ui/async-await/drop-track-field-assign.rs @@ -1,8 +1,6 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir // Derived from an ICE found in tokio-xmpp during a crater run. // edition:2021 +// compile-flags: -Zdrop-tracking // build-pass #![allow(dead_code)] diff --git a/tests/ui/async-await/field-assign-nonsend.drop_tracking_mir.stderr b/tests/ui/async-await/field-assign-nonsend.drop_tracking_mir.stderr deleted file mode 100644 index d1df8e91afa..00000000000 --- a/tests/ui/async-await/field-assign-nonsend.drop_tracking_mir.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error: future cannot be sent between threads safely - --> $DIR/field-assign-nonsend.rs:45:17 - | -LL | assert_send(agent.handle()); - | ^^^^^^^^^^^^^^ future returned by `handle` is not `Send` - | - = help: within `impl Future`, the trait `Send` is not implemented for `Rc` -note: future is not `Send` as this value is used across an await - --> $DIR/field-assign-nonsend.rs:23:39 - | -LL | let mut info = self.info_result.clone(); - | -------- has type `InfoResult` which is not `Send` -... -LL | let _ = send_element(element).await; - | ^^^^^ await occurs here, with `mut info` maybe used later -note: required by a bound in `assert_send` - --> $DIR/field-assign-nonsend.rs:40:19 - | -LL | fn assert_send(_: T) {} - | ^^^^ required by this bound in `assert_send` - -error: aborting due to previous error - diff --git a/tests/ui/async-await/field-assign-nonsend.rs b/tests/ui/async-await/field-assign-nonsend.rs index 3e22280008f..19315ef19f9 100644 --- a/tests/ui/async-await/field-assign-nonsend.rs +++ b/tests/ui/async-await/field-assign-nonsend.rs @@ -1,6 +1,3 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir // Derived from an ICE found in tokio-xmpp during a crater run. // edition:2021 diff --git a/tests/ui/async-await/field-assign-nonsend.no_drop_tracking.stderr b/tests/ui/async-await/field-assign-nonsend.stderr similarity index 87% rename from tests/ui/async-await/field-assign-nonsend.no_drop_tracking.stderr rename to tests/ui/async-await/field-assign-nonsend.stderr index e2e64c9ae0c..481b236bbdb 100644 --- a/tests/ui/async-await/field-assign-nonsend.no_drop_tracking.stderr +++ b/tests/ui/async-await/field-assign-nonsend.stderr @@ -1,12 +1,12 @@ error: future cannot be sent between threads safely - --> $DIR/field-assign-nonsend.rs:45:17 + --> $DIR/field-assign-nonsend.rs:42:17 | LL | assert_send(agent.handle()); | ^^^^^^^^^^^^^^ future returned by `handle` is not `Send` | = help: within `impl Future`, the trait `Send` is not implemented for `Rc` note: future is not `Send` as this value is used across an await - --> $DIR/field-assign-nonsend.rs:23:39 + --> $DIR/field-assign-nonsend.rs:20:39 | LL | let mut info = self.info_result.clone(); | -------- has type `InfoResult` which is not `Send` @@ -16,7 +16,7 @@ LL | let _ = send_element(element).await; LL | } | - `mut info` is later dropped here note: required by a bound in `assert_send` - --> $DIR/field-assign-nonsend.rs:40:19 + --> $DIR/field-assign-nonsend.rs:37:19 | LL | fn assert_send(_: T) {} | ^^^^ required by this bound in `assert_send` diff --git a/tests/ui/async-await/field-assign.rs b/tests/ui/async-await/field-assign.rs index b79d2af066a..4887eff7efa 100644 --- a/tests/ui/async-await/field-assign.rs +++ b/tests/ui/async-await/field-assign.rs @@ -1,6 +1,3 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir // Derived from an ICE found in tokio-xmpp during a crater run. // edition:2021 // build-pass diff --git a/tests/ui/async-await/issue-64130-1-sync.drop_tracking.stderr b/tests/ui/async-await/issue-64130-1-sync.drop_tracking.stderr deleted file mode 100644 index 56aa035f44b..00000000000 --- a/tests/ui/async-await/issue-64130-1-sync.drop_tracking.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error: future cannot be shared between threads safely - --> $DIR/issue-64130-1-sync.rs:25:13 - | -LL | is_sync(bar()); - | ^^^^^ future returned by `bar` is not `Sync` - | - = help: within `impl Future`, the trait `Sync` is not implemented for `Foo` -note: future is not `Sync` as this value is used across an await - --> $DIR/issue-64130-1-sync.rs:18:11 - | -LL | let x = Foo; - | - has type `Foo` which is not `Sync` -LL | baz().await; - | ^^^^^ await occurs here, with `x` maybe used later -LL | drop(x); -LL | } - | - `x` is later dropped here -note: required by a bound in `is_sync` - --> $DIR/issue-64130-1-sync.rs:14:15 - | -LL | fn is_sync(t: T) { } - | ^^^^ required by this bound in `is_sync` - -error: aborting due to previous error - diff --git a/tests/ui/async-await/issue-64130-1-sync.drop_tracking_mir.stderr b/tests/ui/async-await/issue-64130-1-sync.drop_tracking_mir.stderr deleted file mode 100644 index ea1bfb9f9ac..00000000000 --- a/tests/ui/async-await/issue-64130-1-sync.drop_tracking_mir.stderr +++ /dev/null @@ -1,22 +0,0 @@ -error: future cannot be shared between threads safely - --> $DIR/issue-64130-1-sync.rs:25:13 - | -LL | is_sync(bar()); - | ^^^^^ future returned by `bar` is not `Sync` - | - = help: within `impl Future`, the trait `Sync` is not implemented for `Foo` -note: future is not `Sync` as this value is used across an await - --> $DIR/issue-64130-1-sync.rs:18:11 - | -LL | let x = Foo; - | - has type `Foo` which is not `Sync` -LL | baz().await; - | ^^^^^ await occurs here, with `x` maybe used later -note: required by a bound in `is_sync` - --> $DIR/issue-64130-1-sync.rs:14:15 - | -LL | fn is_sync(t: T) { } - | ^^^^ required by this bound in `is_sync` - -error: aborting due to previous error - diff --git a/tests/ui/async-await/issue-64130-1-sync.rs b/tests/ui/async-await/issue-64130-1-sync.rs index 44646e0e5f2..1714cec5221 100644 --- a/tests/ui/async-await/issue-64130-1-sync.rs +++ b/tests/ui/async-await/issue-64130-1-sync.rs @@ -1,6 +1,3 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir #![feature(negative_impls)] // edition:2018 @@ -16,7 +13,6 @@ fn is_sync(t: T) { } async fn bar() { let x = Foo; baz().await; - drop(x); } async fn baz() { } diff --git a/tests/ui/async-await/issue-64130-1-sync.no_drop_tracking.stderr b/tests/ui/async-await/issue-64130-1-sync.stderr similarity index 83% rename from tests/ui/async-await/issue-64130-1-sync.no_drop_tracking.stderr rename to tests/ui/async-await/issue-64130-1-sync.stderr index 56aa035f44b..06d26ea73dc 100644 --- a/tests/ui/async-await/issue-64130-1-sync.no_drop_tracking.stderr +++ b/tests/ui/async-await/issue-64130-1-sync.stderr @@ -1,22 +1,21 @@ error: future cannot be shared between threads safely - --> $DIR/issue-64130-1-sync.rs:25:13 + --> $DIR/issue-64130-1-sync.rs:21:13 | LL | is_sync(bar()); | ^^^^^ future returned by `bar` is not `Sync` | = help: within `impl Future`, the trait `Sync` is not implemented for `Foo` note: future is not `Sync` as this value is used across an await - --> $DIR/issue-64130-1-sync.rs:18:11 + --> $DIR/issue-64130-1-sync.rs:15:11 | LL | let x = Foo; | - has type `Foo` which is not `Sync` LL | baz().await; | ^^^^^ await occurs here, with `x` maybe used later -LL | drop(x); LL | } | - `x` is later dropped here note: required by a bound in `is_sync` - --> $DIR/issue-64130-1-sync.rs:14:15 + --> $DIR/issue-64130-1-sync.rs:11:15 | LL | fn is_sync(t: T) { } | ^^^^ required by this bound in `is_sync` diff --git a/tests/ui/async-await/issue-64130-2-send.drop_tracking_mir.stderr b/tests/ui/async-await/issue-64130-2-send.drop_tracking_mir.stderr deleted file mode 100644 index 45e43525a20..00000000000 --- a/tests/ui/async-await/issue-64130-2-send.drop_tracking_mir.stderr +++ /dev/null @@ -1,26 +0,0 @@ -error: future cannot be sent between threads safely - --> $DIR/issue-64130-2-send.rs:24:13 - | -LL | is_send(bar()); - | ^^^^^ future returned by `bar` is not `Send` - | - = note: the trait bound `Unique: Send` is not satisfied -note: future is not `Send` as this value is used across an await - --> $DIR/issue-64130-2-send.rs:18:11 - | -LL | let x = Box::new(Foo); - | - has type `Box` which is not `Send` -LL | baz().await; - | ^^^^^ await occurs here, with `x` maybe used later -note: required by a bound in `is_send` - --> $DIR/issue-64130-2-send.rs:14:15 - | -LL | fn is_send(t: T) { } - | ^^^^ required by this bound in `is_send` -help: consider borrowing here - | -LL | is_send(&bar()); - | + - -error: aborting due to previous error - diff --git a/tests/ui/async-await/issue-64130-2-send.no_drop_tracking.stderr b/tests/ui/async-await/issue-64130-2-send.no_drop_tracking.stderr deleted file mode 100644 index d1717ad3310..00000000000 --- a/tests/ui/async-await/issue-64130-2-send.no_drop_tracking.stderr +++ /dev/null @@ -1,28 +0,0 @@ -error: future cannot be sent between threads safely - --> $DIR/issue-64130-2-send.rs:24:13 - | -LL | is_send(bar()); - | ^^^^^ future returned by `bar` is not `Send` - | - = note: the trait bound `Unique: Send` is not satisfied -note: future is not `Send` as this value is used across an await - --> $DIR/issue-64130-2-send.rs:18:11 - | -LL | let x = Box::new(Foo); - | - has type `Box` which is not `Send` -LL | baz().await; - | ^^^^^ await occurs here, with `x` maybe used later -LL | } - | - `x` is later dropped here -note: required by a bound in `is_send` - --> $DIR/issue-64130-2-send.rs:14:15 - | -LL | fn is_send(t: T) { } - | ^^^^ required by this bound in `is_send` -help: consider borrowing here - | -LL | is_send(&bar()); - | + - -error: aborting due to previous error - diff --git a/tests/ui/async-await/issue-64130-2-send.rs b/tests/ui/async-await/issue-64130-2-send.rs index d6d855bac07..7a6e5952cb9 100644 --- a/tests/ui/async-await/issue-64130-2-send.rs +++ b/tests/ui/async-await/issue-64130-2-send.rs @@ -1,6 +1,3 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir #![feature(negative_impls)] // edition:2018 @@ -14,7 +11,7 @@ impl !Send for Foo {} fn is_send(t: T) { } async fn bar() { - let x = Box::new(Foo); + let x = Foo; baz().await; } diff --git a/tests/ui/async-await/issue-64130-2-send.drop_tracking.stderr b/tests/ui/async-await/issue-64130-2-send.stderr similarity index 60% rename from tests/ui/async-await/issue-64130-2-send.drop_tracking.stderr rename to tests/ui/async-await/issue-64130-2-send.stderr index d1717ad3310..e71c78d6800 100644 --- a/tests/ui/async-await/issue-64130-2-send.drop_tracking.stderr +++ b/tests/ui/async-await/issue-64130-2-send.stderr @@ -1,28 +1,24 @@ error: future cannot be sent between threads safely - --> $DIR/issue-64130-2-send.rs:24:13 + --> $DIR/issue-64130-2-send.rs:21:13 | LL | is_send(bar()); | ^^^^^ future returned by `bar` is not `Send` | - = note: the trait bound `Unique: Send` is not satisfied + = help: within `impl Future`, the trait `Send` is not implemented for `Foo` note: future is not `Send` as this value is used across an await - --> $DIR/issue-64130-2-send.rs:18:11 + --> $DIR/issue-64130-2-send.rs:15:11 | -LL | let x = Box::new(Foo); - | - has type `Box` which is not `Send` +LL | let x = Foo; + | - has type `Foo` which is not `Send` LL | baz().await; | ^^^^^ await occurs here, with `x` maybe used later LL | } | - `x` is later dropped here note: required by a bound in `is_send` - --> $DIR/issue-64130-2-send.rs:14:15 + --> $DIR/issue-64130-2-send.rs:11:15 | LL | fn is_send(t: T) { } | ^^^^ required by this bound in `is_send` -help: consider borrowing here - | -LL | is_send(&bar()); - | + error: aborting due to previous error diff --git a/tests/ui/async-await/issue-64130-3-other.drop_tracking.stderr b/tests/ui/async-await/issue-64130-3-other.drop_tracking.stderr deleted file mode 100644 index b69f06da1cd..00000000000 --- a/tests/ui/async-await/issue-64130-3-other.drop_tracking.stderr +++ /dev/null @@ -1,27 +0,0 @@ -error[E0277]: the trait bound `Foo: Qux` is not satisfied in `impl Future` - --> $DIR/issue-64130-3-other.rs:27:12 - | -LL | async fn bar() { - | - within this `impl Future` -... -LL | is_qux(bar()); - | ^^^^^ within `impl Future`, the trait `Qux` is not implemented for `Foo` - | -note: future does not implement `Qux` as this value is used across an await - --> $DIR/issue-64130-3-other.rs:21:11 - | -LL | let x = Box::new(Foo); - | - has type `Box` which does not implement `Qux` -LL | baz().await; - | ^^^^^ await occurs here, with `x` maybe used later -LL | } - | - `x` is later dropped here -note: required by a bound in `is_qux` - --> $DIR/issue-64130-3-other.rs:17:14 - | -LL | fn is_qux(t: T) {} - | ^^^ required by this bound in `is_qux` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/async-await/issue-64130-3-other.drop_tracking_mir.stderr b/tests/ui/async-await/issue-64130-3-other.drop_tracking_mir.stderr deleted file mode 100644 index 1298371241c..00000000000 --- a/tests/ui/async-await/issue-64130-3-other.drop_tracking_mir.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error[E0277]: the trait bound `Foo: Qux` is not satisfied in `impl Future` - --> $DIR/issue-64130-3-other.rs:27:12 - | -LL | async fn bar() { - | - within this `impl Future` -... -LL | is_qux(bar()); - | ^^^^^ within `impl Future`, the trait `Qux` is not implemented for `Foo` - | -note: future does not implement `Qux` as this value is used across an await - --> $DIR/issue-64130-3-other.rs:21:11 - | -LL | let x = Box::new(Foo); - | - has type `Box` which does not implement `Qux` -LL | baz().await; - | ^^^^^ await occurs here, with `x` maybe used later -note: required by a bound in `is_qux` - --> $DIR/issue-64130-3-other.rs:17:14 - | -LL | fn is_qux(t: T) {} - | ^^^ required by this bound in `is_qux` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/async-await/issue-64130-3-other.rs b/tests/ui/async-await/issue-64130-3-other.rs index 92d3b7c81fb..630fb2c41cd 100644 --- a/tests/ui/async-await/issue-64130-3-other.rs +++ b/tests/ui/async-await/issue-64130-3-other.rs @@ -1,6 +1,3 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir #![feature(auto_traits)] #![feature(negative_impls)] // edition:2018 @@ -17,7 +14,7 @@ impl !Qux for Foo {} fn is_qux(t: T) {} async fn bar() { - let x = Box::new(Foo); + let x = Foo; baz().await; } diff --git a/tests/ui/async-await/issue-64130-3-other.no_drop_tracking.stderr b/tests/ui/async-await/issue-64130-3-other.stderr similarity index 77% rename from tests/ui/async-await/issue-64130-3-other.no_drop_tracking.stderr rename to tests/ui/async-await/issue-64130-3-other.stderr index b69f06da1cd..4107784395f 100644 --- a/tests/ui/async-await/issue-64130-3-other.no_drop_tracking.stderr +++ b/tests/ui/async-await/issue-64130-3-other.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `Foo: Qux` is not satisfied in `impl Future` - --> $DIR/issue-64130-3-other.rs:27:12 + --> $DIR/issue-64130-3-other.rs:24:12 | LL | async fn bar() { | - within this `impl Future` @@ -8,16 +8,16 @@ LL | is_qux(bar()); | ^^^^^ within `impl Future`, the trait `Qux` is not implemented for `Foo` | note: future does not implement `Qux` as this value is used across an await - --> $DIR/issue-64130-3-other.rs:21:11 + --> $DIR/issue-64130-3-other.rs:18:11 | -LL | let x = Box::new(Foo); - | - has type `Box` which does not implement `Qux` +LL | let x = Foo; + | - has type `Foo` which does not implement `Qux` LL | baz().await; | ^^^^^ await occurs here, with `x` maybe used later LL | } | - `x` is later dropped here note: required by a bound in `is_qux` - --> $DIR/issue-64130-3-other.rs:17:14 + --> $DIR/issue-64130-3-other.rs:14:14 | LL | fn is_qux(t: T) {} | ^^^ required by this bound in `is_qux` diff --git a/tests/ui/async-await/issue-64130-4-async-move.drop-tracking.stderr b/tests/ui/async-await/issue-64130-4-async-move.drop-tracking.stderr deleted file mode 100644 index 884619f4dd6..00000000000 --- a/tests/ui/async-await/issue-64130-4-async-move.drop-tracking.stderr +++ /dev/null @@ -1,26 +0,0 @@ -error: future cannot be sent between threads safely - --> $DIR/issue-64130-4-async-move.rs:20:17 - | -LL | pub fn foo() -> impl Future + Send { - | ^^^^^^^^^^^^^^^^^^ future created by async block is not `Send` - | - = help: the trait `Sync` is not implemented for `(dyn Any + Send + 'static)` -note: future is not `Send` as this value is used across an await - --> $DIR/issue-64130-4-async-move.rs:27:31 - | -LL | match client.status() { - | ------ has type `&Client` which is not `Send` -LL | 200 => { -LL | let _x = get().await; - | ^^^^^^ await occurs here, with `client` maybe used later -... -LL | } - | - `client` is later dropped here -help: consider moving this into a `let` binding to create a shorter lived borrow - --> $DIR/issue-64130-4-async-move.rs:25:15 - | -LL | match client.status() { - | ^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/tests/ui/async-await/issue-64130-4-async-move.no_drop_tracking.stderr b/tests/ui/async-await/issue-64130-4-async-move.no_drop_tracking.stderr deleted file mode 100644 index 60b7551ff8a..00000000000 --- a/tests/ui/async-await/issue-64130-4-async-move.no_drop_tracking.stderr +++ /dev/null @@ -1,26 +0,0 @@ -error: future cannot be sent between threads safely - --> $DIR/issue-64130-4-async-move.rs:21:17 - | -LL | pub fn foo() -> impl Future + Send { - | ^^^^^^^^^^^^^^^^^^ future created by async block is not `Send` - | - = help: the trait `Sync` is not implemented for `(dyn Any + Send + 'static)` -note: future is not `Send` as this value is used across an await - --> $DIR/issue-64130-4-async-move.rs:27:23 - | -LL | match client.status() { - | ------ has type `&Client` which is not `Send` -LL | 200 => { -LL | get().await; - | ^^^^^ await occurs here, with `client` maybe used later -... -LL | } - | - `client` is later dropped here -help: consider moving this into a `let` binding to create a shorter lived borrow - --> $DIR/issue-64130-4-async-move.rs:25:15 - | -LL | match client.status() { - | ^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/tests/ui/async-await/issue-64130-4-async-move.rs b/tests/ui/async-await/issue-64130-4-async-move.rs index 5d68a808b17..c333e160ef3 100644 --- a/tests/ui/async-await/issue-64130-4-async-move.rs +++ b/tests/ui/async-await/issue-64130-4-async-move.rs @@ -1,9 +1,6 @@ // edition:2018 -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir -// [drop_tracking_mir] check-pass -// [drop_tracking] check-pass +// check-pass +// compile-flags: -Zdrop-tracking=yes use std::any::Any; use std::future::Future; @@ -19,7 +16,6 @@ impl Client { async fn get() {} pub fn foo() -> impl Future + Send { - //[no_drop_tracking]~^ ERROR future cannot be sent between threads safely let client = Client(Box::new(true)); async move { match client.status() { diff --git a/tests/ui/async-await/issue-67252-unnamed-future.drop_tracking.stderr b/tests/ui/async-await/issue-67252-unnamed-future.drop_tracking.stderr deleted file mode 100644 index c4c0c43fc13..00000000000 --- a/tests/ui/async-await/issue-67252-unnamed-future.drop_tracking.stderr +++ /dev/null @@ -1,30 +0,0 @@ -error: future cannot be sent between threads safely - --> $DIR/issue-67252-unnamed-future.rs:21:11 - | -LL | spawn(async { - | ___________^ -LL | | let a = std::ptr::null_mut::<()>(); // `*mut ()` is not `Send` -LL | | AFuture.await; -LL | | drop(a); -LL | | }); - | |_____^ future created by async block is not `Send` - | - = help: within `{async block@$DIR/issue-67252-unnamed-future.rs:21:11: 25:6}`, the trait `Send` is not implemented for `*mut ()` -note: future is not `Send` as this value is used across an await - --> $DIR/issue-67252-unnamed-future.rs:23:17 - | -LL | let a = std::ptr::null_mut::<()>(); // `*mut ()` is not `Send` - | - has type `*mut ()` which is not `Send` -LL | AFuture.await; - | ^^^^^ await occurs here, with `a` maybe used later -LL | drop(a); -LL | }); - | - `a` is later dropped here -note: required by a bound in `spawn` - --> $DIR/issue-67252-unnamed-future.rs:9:13 - | -LL | fn spawn(_: T) {} - | ^^^^ required by this bound in `spawn` - -error: aborting due to previous error - diff --git a/tests/ui/async-await/issue-67252-unnamed-future.drop_tracking_mir.stderr b/tests/ui/async-await/issue-67252-unnamed-future.drop_tracking_mir.stderr deleted file mode 100644 index 0c4d8586ca6..00000000000 --- a/tests/ui/async-await/issue-67252-unnamed-future.drop_tracking_mir.stderr +++ /dev/null @@ -1,22 +0,0 @@ -error: future cannot be sent between threads safely - --> $DIR/issue-67252-unnamed-future.rs:21:5 - | -LL | spawn(async { - | ^^^^^ future created by async block is not `Send` - | - = help: within `{async block@$DIR/issue-67252-unnamed-future.rs:21:11: 25:6}`, the trait `Send` is not implemented for `*mut ()` -note: future is not `Send` as this value is used across an await - --> $DIR/issue-67252-unnamed-future.rs:23:17 - | -LL | let a = std::ptr::null_mut::<()>(); // `*mut ()` is not `Send` - | - has type `*mut ()` which is not `Send` -LL | AFuture.await; - | ^^^^^ await occurs here, with `a` maybe used later -note: required by a bound in `spawn` - --> $DIR/issue-67252-unnamed-future.rs:9:13 - | -LL | fn spawn(_: T) {} - | ^^^^ required by this bound in `spawn` - -error: aborting due to previous error - diff --git a/tests/ui/async-await/issue-67252-unnamed-future.no_drop_tracking.stderr b/tests/ui/async-await/issue-67252-unnamed-future.no_drop_tracking.stderr deleted file mode 100644 index c4c0c43fc13..00000000000 --- a/tests/ui/async-await/issue-67252-unnamed-future.no_drop_tracking.stderr +++ /dev/null @@ -1,30 +0,0 @@ -error: future cannot be sent between threads safely - --> $DIR/issue-67252-unnamed-future.rs:21:11 - | -LL | spawn(async { - | ___________^ -LL | | let a = std::ptr::null_mut::<()>(); // `*mut ()` is not `Send` -LL | | AFuture.await; -LL | | drop(a); -LL | | }); - | |_____^ future created by async block is not `Send` - | - = help: within `{async block@$DIR/issue-67252-unnamed-future.rs:21:11: 25:6}`, the trait `Send` is not implemented for `*mut ()` -note: future is not `Send` as this value is used across an await - --> $DIR/issue-67252-unnamed-future.rs:23:17 - | -LL | let a = std::ptr::null_mut::<()>(); // `*mut ()` is not `Send` - | - has type `*mut ()` which is not `Send` -LL | AFuture.await; - | ^^^^^ await occurs here, with `a` maybe used later -LL | drop(a); -LL | }); - | - `a` is later dropped here -note: required by a bound in `spawn` - --> $DIR/issue-67252-unnamed-future.rs:9:13 - | -LL | fn spawn(_: T) {} - | ^^^^ required by this bound in `spawn` - -error: aborting due to previous error - diff --git a/tests/ui/async-await/issue-67252-unnamed-future.rs b/tests/ui/async-await/issue-67252-unnamed-future.rs index bb9ad77cef3..1a7ff613341 100644 --- a/tests/ui/async-await/issue-67252-unnamed-future.rs +++ b/tests/ui/async-await/issue-67252-unnamed-future.rs @@ -1,6 +1,3 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir // edition:2018 use std::future::Future; use std::pin::Pin; @@ -19,9 +16,8 @@ impl Future for AFuture{ async fn foo() { spawn(async { //~ ERROR future cannot be sent between threads safely - let a = std::ptr::null_mut::<()>(); // `*mut ()` is not `Send` + let _a = std::ptr::null_mut::<()>(); // `*mut ()` is not `Send` AFuture.await; - drop(a); }); } diff --git a/tests/ui/async-await/issue-67252-unnamed-future.stderr b/tests/ui/async-await/issue-67252-unnamed-future.stderr new file mode 100644 index 00000000000..6aef35de0ca --- /dev/null +++ b/tests/ui/async-await/issue-67252-unnamed-future.stderr @@ -0,0 +1,28 @@ +error: future cannot be sent between threads safely + --> $DIR/issue-67252-unnamed-future.rs:18:11 + | +LL | spawn(async { + | ___________^ +LL | | let _a = std::ptr::null_mut::<()>(); // `*mut ()` is not `Send` +LL | | AFuture.await; +LL | | }); + | |_____^ future created by async block is not `Send` + | + = help: within `{async block@$DIR/issue-67252-unnamed-future.rs:18:11: 21:6}`, the trait `Send` is not implemented for `*mut ()` +note: future is not `Send` as this value is used across an await + --> $DIR/issue-67252-unnamed-future.rs:20:17 + | +LL | let _a = std::ptr::null_mut::<()>(); // `*mut ()` is not `Send` + | -- has type `*mut ()` which is not `Send` +LL | AFuture.await; + | ^^^^^ await occurs here, with `_a` maybe used later +LL | }); + | - `_a` is later dropped here +note: required by a bound in `spawn` + --> $DIR/issue-67252-unnamed-future.rs:6:13 + | +LL | fn spawn(_: T) {} + | ^^^^ required by this bound in `spawn` + +error: aborting due to previous error + diff --git a/tests/ui/async-await/issue-68112.drop_tracking.stderr b/tests/ui/async-await/issue-68112.drop_tracking.stderr deleted file mode 100644 index bd648de3067..00000000000 --- a/tests/ui/async-await/issue-68112.drop_tracking.stderr +++ /dev/null @@ -1,82 +0,0 @@ -error: future cannot be sent between threads safely - --> $DIR/issue-68112.rs:37:18 - | -LL | require_send(send_fut); - | ^^^^^^^^ future created by async block is not `Send` - | - = help: the trait `Sync` is not implemented for `RefCell` - = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead -note: future is not `Send` as it awaits another future which is not `Send` - --> $DIR/issue-68112.rs:34:17 - | -LL | let _ = non_send_fut.await; - | ^^^^^^^^^^^^ await occurs here on type `impl Future>>`, which is not `Send` -note: required by a bound in `require_send` - --> $DIR/issue-68112.rs:14:25 - | -LL | fn require_send(_: impl Send) {} - | ^^^^ required by this bound in `require_send` - -error: future cannot be sent between threads safely - --> $DIR/issue-68112.rs:46:18 - | -LL | require_send(send_fut); - | ^^^^^^^^ future created by async block is not `Send` - | - = help: the trait `Sync` is not implemented for `RefCell` - = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead -note: future is not `Send` as it awaits another future which is not `Send` - --> $DIR/issue-68112.rs:43:17 - | -LL | let _ = make_non_send_future1().await; - | ^^^^^^^^^^^^^^^^^^^^^^^ await occurs here on type `impl Future>>`, which is not `Send` -note: required by a bound in `require_send` - --> $DIR/issue-68112.rs:14:25 - | -LL | fn require_send(_: impl Send) {} - | ^^^^ required by this bound in `require_send` - -error[E0277]: `RefCell` cannot be shared between threads safely - --> $DIR/issue-68112.rs:65:18 - | -LL | require_send(send_fut); - | ------------ ^^^^^^^^ `RefCell` cannot be shared between threads safely - | | - | required by a bound introduced by this call - | - = help: the trait `Sync` is not implemented for `RefCell` - = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead - = note: required for `Arc>` to implement `Send` -note: required because it's used within this `async fn` body - --> $DIR/issue-68112.rs:50:31 - | -LL | async fn ready2(t: T) -> T { - | _______________________________^ -LL | | t -LL | | } - | |_^ -note: required because it appears within the type `impl Future>>` - --> $DIR/issue-68112.rs:53:31 - | -LL | fn make_non_send_future2() -> impl Future>> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: required because it captures the following types: `ResumeTy`, `impl Future>>`, `()`, `Ready` -note: required because it's used within this `async` block - --> $DIR/issue-68112.rs:60:20 - | -LL | let send_fut = async { - | ____________________^ -LL | | let non_send_fut = make_non_send_future2(); -LL | | let _ = non_send_fut.await; -LL | | ready(0).await; -LL | | }; - | |_____^ -note: required by a bound in `require_send` - --> $DIR/issue-68112.rs:14:25 - | -LL | fn require_send(_: impl Send) {} - | ^^^^ required by this bound in `require_send` - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/async-await/issue-68112.drop_tracking_mir.stderr b/tests/ui/async-await/issue-68112.drop_tracking_mir.stderr deleted file mode 100644 index 7a9242cbaf5..00000000000 --- a/tests/ui/async-await/issue-68112.drop_tracking_mir.stderr +++ /dev/null @@ -1,80 +0,0 @@ -error: future cannot be sent between threads safely - --> $DIR/issue-68112.rs:37:5 - | -LL | require_send(send_fut); - | ^^^^^^^^^^^^ future created by async block is not `Send` - | - = help: the trait `Sync` is not implemented for `RefCell` - = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead -note: future is not `Send` as it awaits another future which is not `Send` - --> $DIR/issue-68112.rs:34:17 - | -LL | let _ = non_send_fut.await; - | ^^^^^^^^^^^^ await occurs here on type `impl Future>>`, which is not `Send` -note: required by a bound in `require_send` - --> $DIR/issue-68112.rs:14:25 - | -LL | fn require_send(_: impl Send) {} - | ^^^^ required by this bound in `require_send` - -error: future cannot be sent between threads safely - --> $DIR/issue-68112.rs:46:5 - | -LL | require_send(send_fut); - | ^^^^^^^^^^^^ future created by async block is not `Send` - | - = help: the trait `Sync` is not implemented for `RefCell` - = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead -note: future is not `Send` as it awaits another future which is not `Send` - --> $DIR/issue-68112.rs:43:17 - | -LL | let _ = make_non_send_future1().await; - | ^^^^^^^^^^^^^^^^^^^^^^^ await occurs here on type `impl Future>>`, which is not `Send` -note: required by a bound in `require_send` - --> $DIR/issue-68112.rs:14:25 - | -LL | fn require_send(_: impl Send) {} - | ^^^^ required by this bound in `require_send` - -error[E0277]: `RefCell` cannot be shared between threads safely - --> $DIR/issue-68112.rs:65:5 - | -LL | require_send(send_fut); - | ^^^^^^^^^^^^ `RefCell` cannot be shared between threads safely - | - = help: the trait `Sync` is not implemented for `RefCell` - = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead - = note: required for `Arc>` to implement `Send` -note: required because it's used within this `async fn` body - --> $DIR/issue-68112.rs:50:31 - | -LL | async fn ready2(t: T) -> T { - | _______________________________^ -LL | | t -LL | | } - | |_^ -note: required because it appears within the type `impl Future>>` - --> $DIR/issue-68112.rs:53:31 - | -LL | fn make_non_send_future2() -> impl Future>> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: required because it captures the following types: `impl Future>>`, `Ready` -note: required because it's used within this `async` block - --> $DIR/issue-68112.rs:60:20 - | -LL | let send_fut = async { - | ____________________^ -LL | | let non_send_fut = make_non_send_future2(); -LL | | let _ = non_send_fut.await; -LL | | ready(0).await; -LL | | }; - | |_____^ -note: required by a bound in `require_send` - --> $DIR/issue-68112.rs:14:25 - | -LL | fn require_send(_: impl Send) {} - | ^^^^ required by this bound in `require_send` - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/async-await/issue-68112.rs b/tests/ui/async-await/issue-68112.rs index 19119ae0fc1..0005b90efc2 100644 --- a/tests/ui/async-await/issue-68112.rs +++ b/tests/ui/async-await/issue-68112.rs @@ -1,7 +1,4 @@ // edition:2018 -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir use std::{ cell::RefCell, @@ -14,7 +11,7 @@ use std::{ fn require_send(_: impl Send) {} struct Ready(Option); -impl Future for Ready { +impl Future for Ready { type Output = T; fn poll(mut self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll { Poll::Ready(self.0.take().unwrap()) diff --git a/tests/ui/async-await/issue-68112.no_drop_tracking.stderr b/tests/ui/async-await/issue-68112.stderr similarity index 90% rename from tests/ui/async-await/issue-68112.no_drop_tracking.stderr rename to tests/ui/async-await/issue-68112.stderr index 35b7341f63a..aec2541c9e6 100644 --- a/tests/ui/async-await/issue-68112.no_drop_tracking.stderr +++ b/tests/ui/async-await/issue-68112.stderr @@ -1,5 +1,5 @@ error: future cannot be sent between threads safely - --> $DIR/issue-68112.rs:37:18 + --> $DIR/issue-68112.rs:34:18 | LL | require_send(send_fut); | ^^^^^^^^ future created by async block is not `Send` @@ -7,18 +7,18 @@ LL | require_send(send_fut); = help: the trait `Sync` is not implemented for `RefCell` = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead note: future is not `Send` as it awaits another future which is not `Send` - --> $DIR/issue-68112.rs:34:17 + --> $DIR/issue-68112.rs:31:17 | LL | let _ = non_send_fut.await; | ^^^^^^^^^^^^ await occurs here on type `impl Future>>`, which is not `Send` note: required by a bound in `require_send` - --> $DIR/issue-68112.rs:14:25 + --> $DIR/issue-68112.rs:11:25 | LL | fn require_send(_: impl Send) {} | ^^^^ required by this bound in `require_send` error: future cannot be sent between threads safely - --> $DIR/issue-68112.rs:46:18 + --> $DIR/issue-68112.rs:43:18 | LL | require_send(send_fut); | ^^^^^^^^ future created by async block is not `Send` @@ -26,18 +26,18 @@ LL | require_send(send_fut); = help: the trait `Sync` is not implemented for `RefCell` = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead note: future is not `Send` as it awaits another future which is not `Send` - --> $DIR/issue-68112.rs:43:17 + --> $DIR/issue-68112.rs:40:17 | LL | let _ = make_non_send_future1().await; | ^^^^^^^^^^^^^^^^^^^^^^^ await occurs here on type `impl Future>>`, which is not `Send` note: required by a bound in `require_send` - --> $DIR/issue-68112.rs:14:25 + --> $DIR/issue-68112.rs:11:25 | LL | fn require_send(_: impl Send) {} | ^^^^ required by this bound in `require_send` error[E0277]: `RefCell` cannot be shared between threads safely - --> $DIR/issue-68112.rs:65:18 + --> $DIR/issue-68112.rs:62:18 | LL | require_send(send_fut); | ------------ ^^^^^^^^ `RefCell` cannot be shared between threads safely @@ -48,7 +48,7 @@ LL | require_send(send_fut); = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead = note: required for `Arc>` to implement `Send` note: required because it's used within this `async fn` body - --> $DIR/issue-68112.rs:50:31 + --> $DIR/issue-68112.rs:47:31 | LL | async fn ready2(t: T) -> T { | _______________________________^ @@ -56,13 +56,13 @@ LL | | t LL | | } | |_^ note: required because it appears within the type `impl Future>>` - --> $DIR/issue-68112.rs:53:31 + --> $DIR/issue-68112.rs:50:31 | LL | fn make_non_send_future2() -> impl Future>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: required because it captures the following types: `ResumeTy`, `impl Future>>`, `()`, `i32`, `Ready` note: required because it's used within this `async` block - --> $DIR/issue-68112.rs:60:20 + --> $DIR/issue-68112.rs:57:20 | LL | let send_fut = async { | ____________________^ @@ -72,7 +72,7 @@ LL | | ready(0).await; LL | | }; | |_____^ note: required by a bound in `require_send` - --> $DIR/issue-68112.rs:14:25 + --> $DIR/issue-68112.rs:11:25 | LL | fn require_send(_: impl Send) {} | ^^^^ required by this bound in `require_send` diff --git a/tests/ui/async-await/issue-70818.drop_tracking.stderr b/tests/ui/async-await/issue-70818.drop_tracking.stderr deleted file mode 100644 index ab0698c3ec2..00000000000 --- a/tests/ui/async-await/issue-70818.drop_tracking.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error: future cannot be sent between threads safely - --> $DIR/issue-70818.rs:7:38 - | -LL | fn foo(ty: T, ty1: U) -> impl Future + Send { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future created by async block is not `Send` - | -note: captured value is not `Send` - --> $DIR/issue-70818.rs:9:18 - | -LL | async { (ty, ty1) } - | ^^^ has type `U` which is not `Send` -help: consider restricting type parameter `U` - | -LL | fn foo(ty: T, ty1: U) -> impl Future + Send { - | +++++++++++++++++++ - -error: aborting due to previous error - diff --git a/tests/ui/async-await/issue-70818.no_drop_tracking.stderr b/tests/ui/async-await/issue-70818.no_drop_tracking.stderr deleted file mode 100644 index ab0698c3ec2..00000000000 --- a/tests/ui/async-await/issue-70818.no_drop_tracking.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error: future cannot be sent between threads safely - --> $DIR/issue-70818.rs:7:38 - | -LL | fn foo(ty: T, ty1: U) -> impl Future + Send { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future created by async block is not `Send` - | -note: captured value is not `Send` - --> $DIR/issue-70818.rs:9:18 - | -LL | async { (ty, ty1) } - | ^^^ has type `U` which is not `Send` -help: consider restricting type parameter `U` - | -LL | fn foo(ty: T, ty1: U) -> impl Future + Send { - | +++++++++++++++++++ - -error: aborting due to previous error - diff --git a/tests/ui/async-await/issue-70818.rs b/tests/ui/async-await/issue-70818.rs index 2941de0f577..019c56eb2fa 100644 --- a/tests/ui/async-await/issue-70818.rs +++ b/tests/ui/async-await/issue-70818.rs @@ -1,6 +1,3 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir // edition:2018 use std::future::Future; diff --git a/tests/ui/async-await/issue-70818.drop_tracking_mir.stderr b/tests/ui/async-await/issue-70818.stderr similarity index 90% rename from tests/ui/async-await/issue-70818.drop_tracking_mir.stderr rename to tests/ui/async-await/issue-70818.stderr index ab0698c3ec2..20109d4d116 100644 --- a/tests/ui/async-await/issue-70818.drop_tracking_mir.stderr +++ b/tests/ui/async-await/issue-70818.stderr @@ -1,11 +1,11 @@ error: future cannot be sent between threads safely - --> $DIR/issue-70818.rs:7:38 + --> $DIR/issue-70818.rs:4:38 | LL | fn foo(ty: T, ty1: U) -> impl Future + Send { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future created by async block is not `Send` | note: captured value is not `Send` - --> $DIR/issue-70818.rs:9:18 + --> $DIR/issue-70818.rs:6:18 | LL | async { (ty, ty1) } | ^^^ has type `U` which is not `Send` diff --git a/tests/ui/async-await/issue-70935-complex-spans.drop_tracking.stderr b/tests/ui/async-await/issue-70935-complex-spans.drop_tracking.stderr deleted file mode 100644 index f80bb4242aa..00000000000 --- a/tests/ui/async-await/issue-70935-complex-spans.drop_tracking.stderr +++ /dev/null @@ -1,41 +0,0 @@ -error[E0277]: `*mut ()` cannot be shared between threads safely - --> $DIR/issue-70935-complex-spans.rs:18:23 - | -LL | fn foo(x: NotSync) -> impl Future + Send { - | ^^^^^^^^^^^^^^^^^^ `*mut ()` cannot be shared between threads safely - | - = help: within `NotSync`, the trait `Sync` is not implemented for `*mut ()` -note: required because it appears within the type `PhantomData<*mut ()>` - --> $SRC_DIR/core/src/marker.rs:LL:COL -note: required because it appears within the type `NotSync` - --> $DIR/issue-70935-complex-spans.rs:12:8 - | -LL | struct NotSync(PhantomData<*mut ()>); - | ^^^^^^^ - = note: required for `&NotSync` to implement `Send` -note: required because it's used within this closure - --> $DIR/issue-70935-complex-spans.rs:22:13 - | -LL | baz(|| async { - | ^^ -note: required because it's used within this `async fn` body - --> $DIR/issue-70935-complex-spans.rs:15:67 - | -LL | async fn baz(_c: impl FnMut() -> T) where T: Future { - | ___________________________________________________________________^ -LL | | } - | |_^ - = note: required because it captures the following types: `ResumeTy`, `impl Future`, `()` -note: required because it's used within this `async` block - --> $DIR/issue-70935-complex-spans.rs:21:5 - | -LL | / async move { -LL | | baz(|| async { -LL | | foo(x.clone()); -LL | | }).await; -LL | | } - | |_____^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/async-await/issue-70935-complex-spans.drop_tracking_mir.stderr b/tests/ui/async-await/issue-70935-complex-spans.drop_tracking_mir.stderr deleted file mode 100644 index eb9d93e229f..00000000000 --- a/tests/ui/async-await/issue-70935-complex-spans.drop_tracking_mir.stderr +++ /dev/null @@ -1,41 +0,0 @@ -error[E0277]: `*mut ()` cannot be shared between threads safely - --> $DIR/issue-70935-complex-spans.rs:18:23 - | -LL | fn foo(x: NotSync) -> impl Future + Send { - | ^^^^^^^^^^^^^^^^^^ `*mut ()` cannot be shared between threads safely - | - = help: within `NotSync`, the trait `Sync` is not implemented for `*mut ()` -note: required because it appears within the type `PhantomData<*mut ()>` - --> $SRC_DIR/core/src/marker.rs:LL:COL -note: required because it appears within the type `NotSync` - --> $DIR/issue-70935-complex-spans.rs:12:8 - | -LL | struct NotSync(PhantomData<*mut ()>); - | ^^^^^^^ - = note: required for `&NotSync` to implement `Send` -note: required because it's used within this closure - --> $DIR/issue-70935-complex-spans.rs:22:13 - | -LL | baz(|| async { - | ^^ -note: required because it's used within this `async fn` body - --> $DIR/issue-70935-complex-spans.rs:15:67 - | -LL | async fn baz(_c: impl FnMut() -> T) where T: Future { - | ___________________________________________________________________^ -LL | | } - | |_^ - = note: required because it captures the following types: `impl Future` -note: required because it's used within this `async` block - --> $DIR/issue-70935-complex-spans.rs:21:5 - | -LL | / async move { -LL | | baz(|| async { -LL | | foo(x.clone()); -LL | | }).await; -LL | | } - | |_____^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/async-await/issue-70935-complex-spans.rs b/tests/ui/async-await/issue-70935-complex-spans.rs index 9ebde1d3977..33aa89c5a5d 100644 --- a/tests/ui/async-await/issue-70935-complex-spans.rs +++ b/tests/ui/async-await/issue-70935-complex-spans.rs @@ -1,7 +1,4 @@ // edition:2018 -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir // #70935: Check if we do not emit snippet // with newlines which lead complex diagnostics. @@ -16,8 +13,7 @@ async fn baz(_c: impl FnMut() -> T) where T: Future { } fn foo(x: NotSync) -> impl Future + Send { - //[no_drop_tracking]~^ ERROR future cannot be sent between threads safely - //[drop_tracking,drop_tracking_mir]~^^ ERROR `*mut ()` cannot be shared between threads + //~^ ERROR future cannot be sent between threads safely async move { baz(|| async { foo(x.clone()); diff --git a/tests/ui/async-await/issue-70935-complex-spans.no_drop_tracking.stderr b/tests/ui/async-await/issue-70935-complex-spans.stderr similarity index 84% rename from tests/ui/async-await/issue-70935-complex-spans.no_drop_tracking.stderr rename to tests/ui/async-await/issue-70935-complex-spans.stderr index b33aa407f4a..5d8ef77616a 100644 --- a/tests/ui/async-await/issue-70935-complex-spans.no_drop_tracking.stderr +++ b/tests/ui/async-await/issue-70935-complex-spans.stderr @@ -1,12 +1,12 @@ error: future cannot be sent between threads safely - --> $DIR/issue-70935-complex-spans.rs:18:23 + --> $DIR/issue-70935-complex-spans.rs:15:23 | LL | fn foo(x: NotSync) -> impl Future + Send { | ^^^^^^^^^^^^^^^^^^ future created by async block is not `Send` | = help: within `NotSync`, the trait `Sync` is not implemented for `*mut ()` note: future is not `Send` as this value is used across an await - --> $DIR/issue-70935-complex-spans.rs:24:12 + --> $DIR/issue-70935-complex-spans.rs:20:12 | LL | baz(|| async { | _____________- @@ -15,7 +15,7 @@ LL | | }).await; | | - ^^^^^- the value is later dropped here | | | | | |_________| await occurs here, with the value maybe used later - | has type `{closure@$DIR/issue-70935-complex-spans.rs:22:13: 22:15}` which is not `Send` + | has type `{closure@$DIR/issue-70935-complex-spans.rs:18:13: 18:15}` which is not `Send` error: aborting due to previous error diff --git a/tests/ui/async-await/issue-73137.rs b/tests/ui/async-await/issue-73137.rs index dcbe7765a9e..c43ce2cadba 100644 --- a/tests/ui/async-await/issue-73137.rs +++ b/tests/ui/async-await/issue-73137.rs @@ -2,9 +2,6 @@ // run-pass // edition:2018 -// revisions: normal drop-tracking -// [normal]compile-flags: -Zdrop-tracking=no -// [drop-tracking]compile-flags: -Zdrop-tracking #![allow(dead_code)] use std::future::Future; diff --git a/tests/ui/async-await/issue-73741-type-err-drop-tracking.drop_tracking.stderr b/tests/ui/async-await/issue-73741-type-err-drop-tracking.drop_tracking.stderr deleted file mode 100644 index 6d19c3beb2f..00000000000 --- a/tests/ui/async-await/issue-73741-type-err-drop-tracking.drop_tracking.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0070]: invalid left-hand side of assignment - --> $DIR/issue-73741-type-err-drop-tracking.rs:11:7 - | -LL | 1 = 2; - | - ^ - | | - | cannot assign to this expression - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0070`. diff --git a/tests/ui/async-await/issue-73741-type-err-drop-tracking.drop_tracking_mir.stderr b/tests/ui/async-await/issue-73741-type-err-drop-tracking.drop_tracking_mir.stderr deleted file mode 100644 index 6d19c3beb2f..00000000000 --- a/tests/ui/async-await/issue-73741-type-err-drop-tracking.drop_tracking_mir.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0070]: invalid left-hand side of assignment - --> $DIR/issue-73741-type-err-drop-tracking.rs:11:7 - | -LL | 1 = 2; - | - ^ - | | - | cannot assign to this expression - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0070`. diff --git a/tests/ui/async-await/issue-73741-type-err-drop-tracking.no_drop_tracking.stderr b/tests/ui/async-await/issue-73741-type-err-drop-tracking.no_drop_tracking.stderr deleted file mode 100644 index 6d19c3beb2f..00000000000 --- a/tests/ui/async-await/issue-73741-type-err-drop-tracking.no_drop_tracking.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0070]: invalid left-hand side of assignment - --> $DIR/issue-73741-type-err-drop-tracking.rs:11:7 - | -LL | 1 = 2; - | - ^ - | | - | cannot assign to this expression - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0070`. diff --git a/tests/ui/async-await/issue-73741-type-err-drop-tracking.rs b/tests/ui/async-await/issue-73741-type-err-drop-tracking.rs deleted file mode 100644 index 1fa8d69143a..00000000000 --- a/tests/ui/async-await/issue-73741-type-err-drop-tracking.rs +++ /dev/null @@ -1,17 +0,0 @@ -// edition:2018 -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir -// -// Regression test for issue #73741 -// Ensures that we don't emit spurious errors when -// a type error ocurrs in an `async fn` - -async fn weird() { - 1 = 2; //~ ERROR invalid left-hand side - - let mut loop_count = 0; - async {}.await -} - -fn main() {} diff --git a/tests/ui/async-await/issue-86507.drop_tracking_mir.stderr b/tests/ui/async-await/issue-86507.drop_tracking_mir.stderr deleted file mode 100644 index 8adc94d9f49..00000000000 --- a/tests/ui/async-await/issue-86507.drop_tracking_mir.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error: future cannot be sent between threads safely - --> $DIR/issue-86507.rs:20:13 - | -LL | / Box::pin( -LL | | async move { -LL | | let x = x; -LL | | } -LL | | ) - | |_____________^ future created by async block is not `Send` - | -note: captured value is not `Send` because `&` references cannot be sent unless their referent is `Sync` - --> $DIR/issue-86507.rs:22:29 - | -LL | let x = x; - | ^ has type `&T` which is not `Send`, because `T` is not `Sync` - = note: required for the cast from `Pin>` to `Pin + Send + 'async_trait)>>` -help: consider further restricting this bound - | -LL | fn bar<'me, 'async_trait, T: Send + std::marker::Sync>(x: &'me T) - | +++++++++++++++++++ - -error: aborting due to previous error - diff --git a/tests/ui/async-await/issue-86507.no_drop_tracking.stderr b/tests/ui/async-await/issue-86507.no_drop_tracking.stderr deleted file mode 100644 index 8adc94d9f49..00000000000 --- a/tests/ui/async-await/issue-86507.no_drop_tracking.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error: future cannot be sent between threads safely - --> $DIR/issue-86507.rs:20:13 - | -LL | / Box::pin( -LL | | async move { -LL | | let x = x; -LL | | } -LL | | ) - | |_____________^ future created by async block is not `Send` - | -note: captured value is not `Send` because `&` references cannot be sent unless their referent is `Sync` - --> $DIR/issue-86507.rs:22:29 - | -LL | let x = x; - | ^ has type `&T` which is not `Send`, because `T` is not `Sync` - = note: required for the cast from `Pin>` to `Pin + Send + 'async_trait)>>` -help: consider further restricting this bound - | -LL | fn bar<'me, 'async_trait, T: Send + std::marker::Sync>(x: &'me T) - | +++++++++++++++++++ - -error: aborting due to previous error - diff --git a/tests/ui/async-await/issue-86507.rs b/tests/ui/async-await/issue-86507.rs index 63c298dbe3d..317f0317664 100644 --- a/tests/ui/async-await/issue-86507.rs +++ b/tests/ui/async-await/issue-86507.rs @@ -1,6 +1,3 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir // edition:2018 use ::core::pin::Pin; diff --git a/tests/ui/async-await/issue-86507.drop_tracking.stderr b/tests/ui/async-await/issue-86507.stderr similarity index 86% rename from tests/ui/async-await/issue-86507.drop_tracking.stderr rename to tests/ui/async-await/issue-86507.stderr index 8adc94d9f49..d5a3f72cf25 100644 --- a/tests/ui/async-await/issue-86507.drop_tracking.stderr +++ b/tests/ui/async-await/issue-86507.stderr @@ -1,5 +1,5 @@ error: future cannot be sent between threads safely - --> $DIR/issue-86507.rs:20:13 + --> $DIR/issue-86507.rs:17:13 | LL | / Box::pin( LL | | async move { @@ -9,11 +9,11 @@ LL | | ) | |_____________^ future created by async block is not `Send` | note: captured value is not `Send` because `&` references cannot be sent unless their referent is `Sync` - --> $DIR/issue-86507.rs:22:29 + --> $DIR/issue-86507.rs:19:29 | LL | let x = x; | ^ has type `&T` which is not `Send`, because `T` is not `Sync` - = note: required for the cast from `Pin>` to `Pin + Send + 'async_trait)>>` + = note: required for the cast from `Pin>` to `Pin + Send + 'async_trait)>>` help: consider further restricting this bound | LL | fn bar<'me, 'async_trait, T: Send + std::marker::Sync>(x: &'me T) diff --git a/tests/ui/async-await/issue-93648.rs b/tests/ui/async-await/issue-93648.rs index ec2249ca592..4ce3ac1e874 100644 --- a/tests/ui/async-await/issue-93648.rs +++ b/tests/ui/async-await/issue-93648.rs @@ -1,8 +1,6 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir // edition:2021 // build-pass +// compile-flags: -Zdrop-tracking fn main() { let _ = async { diff --git a/tests/ui/async-await/issues/auxiliary/issue_67893.rs b/tests/ui/async-await/issues/auxiliary/issue_67893.rs index d5394469806..387966a5064 100644 --- a/tests/ui/async-await/issues/auxiliary/issue_67893.rs +++ b/tests/ui/async-await/issues/auxiliary/issue_67893.rs @@ -1,6 +1,3 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir // edition:2018 use std::sync::{Arc, Mutex}; diff --git a/tests/ui/async-await/issues/issue-65436-raw-ptr-not-send.no_drop_tracking.stderr b/tests/ui/async-await/issues/issue-65436-raw-ptr-not-send.no_drop_tracking.stderr deleted file mode 100644 index c734de73f65..00000000000 --- a/tests/ui/async-await/issues/issue-65436-raw-ptr-not-send.no_drop_tracking.stderr +++ /dev/null @@ -1,32 +0,0 @@ -error: future cannot be sent between threads safely - --> $DIR/issue-65436-raw-ptr-not-send.rs:17:17 - | -LL | assert_send(async { - | _________________^ -LL | | -LL | | bar(Foo(std::ptr::null())).await; -LL | | }) - | |_____^ future created by async block is not `Send` - | - = help: within `{async block@$DIR/issue-65436-raw-ptr-not-send.rs:17:17: 20:6}`, the trait `Send` is not implemented for `*const u8` -note: future is not `Send` as this value is used across an await - --> $DIR/issue-65436-raw-ptr-not-send.rs:19:36 - | -LL | bar(Foo(std::ptr::null())).await; - | ---------------- ^^^^^- `std::ptr::null()` is later dropped here - | | | - | | await occurs here, with `std::ptr::null()` maybe used later - | has type `*const u8` which is not `Send` -help: consider moving this into a `let` binding to create a shorter lived borrow - --> $DIR/issue-65436-raw-ptr-not-send.rs:19:13 - | -LL | bar(Foo(std::ptr::null())).await; - | ^^^^^^^^^^^^^^^^^^^^^ -note: required by a bound in `assert_send` - --> $DIR/issue-65436-raw-ptr-not-send.rs:14:19 - | -LL | fn assert_send(_: T) {} - | ^^^^ required by this bound in `assert_send` - -error: aborting due to previous error - diff --git a/tests/ui/async-await/issues/issue-65436-raw-ptr-not-send.rs b/tests/ui/async-await/issues/issue-65436-raw-ptr-not-send.rs index d7ef929517c..a6a45bea897 100644 --- a/tests/ui/async-await/issues/issue-65436-raw-ptr-not-send.rs +++ b/tests/ui/async-await/issues/issue-65436-raw-ptr-not-send.rs @@ -1,9 +1,6 @@ // edition:2018 -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir -// [drop_tracking] check-pass -// [drop_tracking_mir] check-pass +// check-pass +// compile-flags: -Zdrop-tracking=yes struct Foo(*const u8); @@ -15,7 +12,6 @@ fn assert_send(_: T) {} fn main() { assert_send(async { - //[no_drop_tracking]~^ ERROR future cannot be sent between threads safely bar(Foo(std::ptr::null())).await; }) } diff --git a/tests/ui/async-await/issues/issue-67611-static-mut-refs.rs b/tests/ui/async-await/issues/issue-67611-static-mut-refs.rs index 80d824d3b2e..caed762691e 100644 --- a/tests/ui/async-await/issues/issue-67611-static-mut-refs.rs +++ b/tests/ui/async-await/issues/issue-67611-static-mut-refs.rs @@ -1,10 +1,6 @@ // build-pass // edition:2018 -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir - #![feature(if_let_guard)] static mut A: [i32; 5] = [1, 2, 3, 4, 5]; diff --git a/tests/ui/async-await/issues/issue-67893.stderr b/tests/ui/async-await/issues/issue-67893.stderr index c941b9eeb29..e1bea29e923 100644 --- a/tests/ui/async-await/issues/issue-67893.stderr +++ b/tests/ui/async-await/issues/issue-67893.stderr @@ -6,7 +6,7 @@ LL | g(issue_67893::run()) | = help: within `impl Future`, the trait `Send` is not implemented for `MutexGuard<'_, ()>` note: future is not `Send` as this value is used across an await - --> $DIR/auxiliary/issue_67893.rs:12:27 + --> $DIR/auxiliary/issue_67893.rs:9:27 | LL | f(*x.lock().unwrap()).await; | ----------------- ^^^^^- `x.lock().unwrap()` is later dropped here diff --git a/tests/ui/async-await/mutually-recursive-async-impl-trait-type.drop_tracking.stderr b/tests/ui/async-await/mutually-recursive-async-impl-trait-type.drop_tracking.stderr deleted file mode 100644 index 8a7317bb95a..00000000000 --- a/tests/ui/async-await/mutually-recursive-async-impl-trait-type.drop_tracking.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0733]: recursion in an `async fn` requires boxing - --> $DIR/mutually-recursive-async-impl-trait-type.rs:9:18 - | -LL | async fn rec_1() { - | ^ recursive `async fn` - | - = note: a recursive `async fn` must be rewritten to return a boxed `dyn Future` - = note: consider using the `async_recursion` crate: https://crates.io/crates/async_recursion - -error[E0733]: recursion in an `async fn` requires boxing - --> $DIR/mutually-recursive-async-impl-trait-type.rs:13:18 - | -LL | async fn rec_2() { - | ^ recursive `async fn` - | - = note: a recursive `async fn` must be rewritten to return a boxed `dyn Future` - = note: consider using the `async_recursion` crate: https://crates.io/crates/async_recursion - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0733`. diff --git a/tests/ui/async-await/mutually-recursive-async-impl-trait-type.no_drop_tracking.stderr b/tests/ui/async-await/mutually-recursive-async-impl-trait-type.no_drop_tracking.stderr deleted file mode 100644 index 8a7317bb95a..00000000000 --- a/tests/ui/async-await/mutually-recursive-async-impl-trait-type.no_drop_tracking.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0733]: recursion in an `async fn` requires boxing - --> $DIR/mutually-recursive-async-impl-trait-type.rs:9:18 - | -LL | async fn rec_1() { - | ^ recursive `async fn` - | - = note: a recursive `async fn` must be rewritten to return a boxed `dyn Future` - = note: consider using the `async_recursion` crate: https://crates.io/crates/async_recursion - -error[E0733]: recursion in an `async fn` requires boxing - --> $DIR/mutually-recursive-async-impl-trait-type.rs:13:18 - | -LL | async fn rec_2() { - | ^ recursive `async fn` - | - = note: a recursive `async fn` must be rewritten to return a boxed `dyn Future` - = note: consider using the `async_recursion` crate: https://crates.io/crates/async_recursion - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0733`. diff --git a/tests/ui/async-await/mutually-recursive-async-impl-trait-type.rs b/tests/ui/async-await/mutually-recursive-async-impl-trait-type.rs index a241f30e73e..bb2a61f03ce 100644 --- a/tests/ui/async-await/mutually-recursive-async-impl-trait-type.rs +++ b/tests/ui/async-await/mutually-recursive-async-impl-trait-type.rs @@ -1,7 +1,3 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir - // edition:2018 // Test that impl trait does not allow creating recursive types that are // otherwise forbidden when using `async` and `await`. diff --git a/tests/ui/async-await/mutually-recursive-async-impl-trait-type.drop_tracking_mir.stderr b/tests/ui/async-await/mutually-recursive-async-impl-trait-type.stderr similarity index 92% rename from tests/ui/async-await/mutually-recursive-async-impl-trait-type.drop_tracking_mir.stderr rename to tests/ui/async-await/mutually-recursive-async-impl-trait-type.stderr index 8a7317bb95a..f789ad2a05c 100644 --- a/tests/ui/async-await/mutually-recursive-async-impl-trait-type.drop_tracking_mir.stderr +++ b/tests/ui/async-await/mutually-recursive-async-impl-trait-type.stderr @@ -1,5 +1,5 @@ error[E0733]: recursion in an `async fn` requires boxing - --> $DIR/mutually-recursive-async-impl-trait-type.rs:9:18 + --> $DIR/mutually-recursive-async-impl-trait-type.rs:5:18 | LL | async fn rec_1() { | ^ recursive `async fn` @@ -8,7 +8,7 @@ LL | async fn rec_1() { = note: consider using the `async_recursion` crate: https://crates.io/crates/async_recursion error[E0733]: recursion in an `async fn` requires boxing - --> $DIR/mutually-recursive-async-impl-trait-type.rs:13:18 + --> $DIR/mutually-recursive-async-impl-trait-type.rs:9:18 | LL | async fn rec_2() { | ^ recursive `async fn` diff --git a/tests/ui/async-await/non-trivial-drop.rs b/tests/ui/async-await/non-trivial-drop.rs index 258da0756de..214e345783b 100644 --- a/tests/ui/async-await/non-trivial-drop.rs +++ b/tests/ui/async-await/non-trivial-drop.rs @@ -1,8 +1,6 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir // build-pass // edition:2018 +// compile-flags: -Zdrop-tracking=y #![feature(generators)] diff --git a/tests/ui/async-await/partial-drop-partial-reinit.drop_tracking.stderr b/tests/ui/async-await/partial-drop-partial-reinit.drop_tracking.stderr deleted file mode 100644 index 17b4ef7bdc6..00000000000 --- a/tests/ui/async-await/partial-drop-partial-reinit.drop_tracking.stderr +++ /dev/null @@ -1,35 +0,0 @@ -error[E0277]: `NotSend` cannot be sent between threads safely - --> $DIR/partial-drop-partial-reinit.rs:9:16 - | -LL | gimme_send(foo()); - | ---------- ^^^^^ `NotSend` cannot be sent between threads safely - | | - | required by a bound introduced by this call -... -LL | async fn foo() { - | - within this `impl Future` - | - = help: within `impl Future`, the trait `Send` is not implemented for `NotSend` - = note: required because it appears within the type `(NotSend,)` - = note: required because it captures the following types: `ResumeTy`, `(NotSend,)`, `()`, `impl Future` -note: required because it's used within this `async fn` body - --> $DIR/partial-drop-partial-reinit.rs:31:16 - | -LL | async fn foo() { - | ________________^ -LL | | -LL | | -LL | | let mut x = (NotSend {},); -... | -LL | | bar().await; -LL | | } - | |_^ -note: required by a bound in `gimme_send` - --> $DIR/partial-drop-partial-reinit.rs:17:18 - | -LL | fn gimme_send(t: T) { - | ^^^^ required by this bound in `gimme_send` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/async-await/partial-drop-partial-reinit.rs b/tests/ui/async-await/partial-drop-partial-reinit.rs index 7d097e72fb4..75acb442e7a 100644 --- a/tests/ui/async-await/partial-drop-partial-reinit.rs +++ b/tests/ui/async-await/partial-drop-partial-reinit.rs @@ -1,7 +1,4 @@ // edition:2021 -// revisions: no_drop_tracking drop_tracking -// [drop_tracking] compile-flags: -Zdrop-tracking=yes -// [no_drop_tracking] compile-flags: -Zdrop-tracking=no #![feature(negative_impls)] #![allow(unused)] diff --git a/tests/ui/async-await/partial-drop-partial-reinit.no_drop_tracking.stderr b/tests/ui/async-await/partial-drop-partial-reinit.stderr similarity index 88% rename from tests/ui/async-await/partial-drop-partial-reinit.no_drop_tracking.stderr rename to tests/ui/async-await/partial-drop-partial-reinit.stderr index 34d8a159f10..05f5358340a 100644 --- a/tests/ui/async-await/partial-drop-partial-reinit.no_drop_tracking.stderr +++ b/tests/ui/async-await/partial-drop-partial-reinit.stderr @@ -1,5 +1,5 @@ error[E0277]: `NotSend` cannot be sent between threads safely - --> $DIR/partial-drop-partial-reinit.rs:9:16 + --> $DIR/partial-drop-partial-reinit.rs:6:16 | LL | gimme_send(foo()); | ---------- ^^^^^ `NotSend` cannot be sent between threads safely @@ -13,7 +13,7 @@ LL | async fn foo() { = note: required because it appears within the type `(NotSend,)` = note: required because it captures the following types: `ResumeTy`, `(NotSend,)`, `impl Future`, `()` note: required because it's used within this `async fn` body - --> $DIR/partial-drop-partial-reinit.rs:31:16 + --> $DIR/partial-drop-partial-reinit.rs:28:16 | LL | async fn foo() { | ________________^ @@ -25,7 +25,7 @@ LL | | bar().await; LL | | } | |_^ note: required by a bound in `gimme_send` - --> $DIR/partial-drop-partial-reinit.rs:17:18 + --> $DIR/partial-drop-partial-reinit.rs:14:18 | LL | fn gimme_send(t: T) { | ^^^^ required by this bound in `gimme_send` diff --git a/tests/ui/async-await/recursive-async-impl-trait-type.drop_tracking.stderr b/tests/ui/async-await/recursive-async-impl-trait-type.drop_tracking.stderr deleted file mode 100644 index 7e63a8da552..00000000000 --- a/tests/ui/async-await/recursive-async-impl-trait-type.drop_tracking.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0733]: recursion in an `async fn` requires boxing - --> $DIR/recursive-async-impl-trait-type.rs:8:40 - | -LL | async fn recursive_async_function() -> () { - | ^^ recursive `async fn` - | - = note: a recursive `async fn` must be rewritten to return a boxed `dyn Future` - = note: consider using the `async_recursion` crate: https://crates.io/crates/async_recursion - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0733`. diff --git a/tests/ui/async-await/recursive-async-impl-trait-type.no_drop_tracking.stderr b/tests/ui/async-await/recursive-async-impl-trait-type.no_drop_tracking.stderr deleted file mode 100644 index 7e63a8da552..00000000000 --- a/tests/ui/async-await/recursive-async-impl-trait-type.no_drop_tracking.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0733]: recursion in an `async fn` requires boxing - --> $DIR/recursive-async-impl-trait-type.rs:8:40 - | -LL | async fn recursive_async_function() -> () { - | ^^ recursive `async fn` - | - = note: a recursive `async fn` must be rewritten to return a boxed `dyn Future` - = note: consider using the `async_recursion` crate: https://crates.io/crates/async_recursion - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0733`. diff --git a/tests/ui/async-await/recursive-async-impl-trait-type.rs b/tests/ui/async-await/recursive-async-impl-trait-type.rs index 60b34d3a174..edc4cb8ac5d 100644 --- a/tests/ui/async-await/recursive-async-impl-trait-type.rs +++ b/tests/ui/async-await/recursive-async-impl-trait-type.rs @@ -1,6 +1,3 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir // edition:2018 // Test that impl trait does not allow creating recursive types that are // otherwise forbidden when using `async` and `await`. diff --git a/tests/ui/async-await/recursive-async-impl-trait-type.drop_tracking_mir.stderr b/tests/ui/async-await/recursive-async-impl-trait-type.stderr similarity index 90% rename from tests/ui/async-await/recursive-async-impl-trait-type.drop_tracking_mir.stderr rename to tests/ui/async-await/recursive-async-impl-trait-type.stderr index 7e63a8da552..63f64f44557 100644 --- a/tests/ui/async-await/recursive-async-impl-trait-type.drop_tracking_mir.stderr +++ b/tests/ui/async-await/recursive-async-impl-trait-type.stderr @@ -1,5 +1,5 @@ error[E0733]: recursion in an `async fn` requires boxing - --> $DIR/recursive-async-impl-trait-type.rs:8:40 + --> $DIR/recursive-async-impl-trait-type.rs:5:40 | LL | async fn recursive_async_function() -> () { | ^^ recursive `async fn` diff --git a/tests/ui/async-await/unresolved_type_param.drop_tracking_mir.stderr b/tests/ui/async-await/unresolved_type_param.drop_tracking_mir.stderr deleted file mode 100644 index 95c79946831..00000000000 --- a/tests/ui/async-await/unresolved_type_param.drop_tracking_mir.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0282]: type annotations needed - --> $DIR/unresolved_type_param.rs:12:5 - | -LL | bar().await; - | ^^^ cannot infer type of the type parameter `T` declared on the function `bar` - | -help: consider specifying the generic argument - | -LL | bar::().await; - | +++++ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/async-await/unresolved_type_param.no_drop_tracking.stderr b/tests/ui/async-await/unresolved_type_param.no_drop_tracking.stderr deleted file mode 100644 index 6642e90acd8..00000000000 --- a/tests/ui/async-await/unresolved_type_param.no_drop_tracking.stderr +++ /dev/null @@ -1,63 +0,0 @@ -error[E0698]: type inside `async fn` body must be known in this context - --> $DIR/unresolved_type_param.rs:12:5 - | -LL | bar().await; - | ^^^ cannot infer type for type parameter `T` declared on the function `bar` - | -note: the type is part of the `async fn` body because of this `await` - --> $DIR/unresolved_type_param.rs:12:11 - | -LL | bar().await; - | ^^^^^ - -error[E0698]: type inside `async fn` body must be known in this context - --> $DIR/unresolved_type_param.rs:12:5 - | -LL | bar().await; - | ^^^ cannot infer type for type parameter `T` declared on the function `bar` - | -note: the type is part of the `async fn` body because of this `await` - --> $DIR/unresolved_type_param.rs:12:11 - | -LL | bar().await; - | ^^^^^ - -error[E0698]: type inside `async fn` body must be known in this context - --> $DIR/unresolved_type_param.rs:12:5 - | -LL | bar().await; - | ^^^ cannot infer type for type parameter `T` declared on the function `bar` - | -note: the type is part of the `async fn` body because of this `await` - --> $DIR/unresolved_type_param.rs:12:11 - | -LL | bar().await; - | ^^^^^ - -error[E0698]: type inside `async fn` body must be known in this context - --> $DIR/unresolved_type_param.rs:12:5 - | -LL | bar().await; - | ^^^ cannot infer type for type parameter `T` declared on the function `bar` - | -note: the type is part of the `async fn` body because of this `await` - --> $DIR/unresolved_type_param.rs:12:11 - | -LL | bar().await; - | ^^^^^ - -error[E0698]: type inside `async fn` body must be known in this context - --> $DIR/unresolved_type_param.rs:12:5 - | -LL | bar().await; - | ^^^ cannot infer type for type parameter `T` declared on the function `bar` - | -note: the type is part of the `async fn` body because of this `await` - --> $DIR/unresolved_type_param.rs:12:11 - | -LL | bar().await; - | ^^^^^ - -error: aborting due to 5 previous errors - -For more information about this error, try `rustc --explain E0698`. diff --git a/tests/ui/async-await/unresolved_type_param.rs b/tests/ui/async-await/unresolved_type_param.rs index ca0a92b9434..6d6d8061491 100644 --- a/tests/ui/async-await/unresolved_type_param.rs +++ b/tests/ui/async-await/unresolved_type_param.rs @@ -1,36 +1,24 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir // Provoke an unresolved type error (T). // Error message should pinpoint the type parameter T as needing to be bound // (rather than give a general error message) // edition:2018 +// compile-flags: -Zdrop-tracking async fn bar() -> () {} async fn foo() { bar().await; - //[drop_tracking_mir]~^ ERROR type annotations needed - //[drop_tracking_mir]~| NOTE cannot infer type of the type parameter `T` - //[no_drop_tracking,drop_tracking]~^^^ ERROR type inside `async fn` body must be known in this context - //[no_drop_tracking,drop_tracking]~| ERROR type inside `async fn` body must be known in this context - //[no_drop_tracking,drop_tracking]~| ERROR type inside `async fn` body must be known in this context - //[no_drop_tracking,drop_tracking]~| NOTE cannot infer type for type parameter `T` - //[no_drop_tracking,drop_tracking]~| NOTE cannot infer type for type parameter `T` - //[no_drop_tracking,drop_tracking]~| NOTE cannot infer type for type parameter `T` - //[no_drop_tracking,drop_tracking]~| NOTE the type is part of the `async fn` body because of this `await` - //[no_drop_tracking,drop_tracking]~| NOTE the type is part of the `async fn` body because of this `await` - //[no_drop_tracking,drop_tracking]~| NOTE the type is part of the `async fn` body because of this `await` - //[no_drop_tracking,drop_tracking]~| NOTE in this expansion of desugaring of `await` - //[no_drop_tracking,drop_tracking]~| NOTE in this expansion of desugaring of `await` - //[no_drop_tracking,drop_tracking]~| NOTE in this expansion of desugaring of `await` - //[no_drop_tracking]~^^^^^^^^^^^^^^^ ERROR type inside `async fn` body must be known in this context - //[no_drop_tracking]~| ERROR type inside `async fn` body must be known in this context - //[no_drop_tracking]~| NOTE cannot infer type for type parameter `T` - //[no_drop_tracking]~| NOTE cannot infer type for type parameter `T` - //[no_drop_tracking]~| NOTE the type is part of the `async fn` body because of this `await` - //[no_drop_tracking]~| NOTE the type is part of the `async fn` body because of this `await` - //[no_drop_tracking]~| NOTE in this expansion of desugaring of `await` - //[no_drop_tracking]~| NOTE in this expansion of desugaring of `await` + //~^ ERROR type inside `async fn` body must be known in this context + //~| ERROR type inside `async fn` body must be known in this context + //~| ERROR type inside `async fn` body must be known in this context + //~| NOTE cannot infer type for type parameter `T` + //~| NOTE cannot infer type for type parameter `T` + //~| NOTE cannot infer type for type parameter `T` + //~| NOTE the type is part of the `async fn` body because of this `await` + //~| NOTE the type is part of the `async fn` body because of this `await` + //~| NOTE the type is part of the `async fn` body because of this `await` + //~| NOTE in this expansion of desugaring of `await` + //~| NOTE in this expansion of desugaring of `await` + //~| NOTE in this expansion of desugaring of `await` } fn main() {} diff --git a/tests/ui/async-await/unresolved_type_param.drop_tracking.stderr b/tests/ui/async-await/unresolved_type_param.stderr similarity index 80% rename from tests/ui/async-await/unresolved_type_param.drop_tracking.stderr rename to tests/ui/async-await/unresolved_type_param.stderr index 6b4a3a36395..ea78c2818c7 100644 --- a/tests/ui/async-await/unresolved_type_param.drop_tracking.stderr +++ b/tests/ui/async-await/unresolved_type_param.stderr @@ -1,35 +1,35 @@ error[E0698]: type inside `async fn` body must be known in this context - --> $DIR/unresolved_type_param.rs:12:5 + --> $DIR/unresolved_type_param.rs:10:5 | LL | bar().await; | ^^^ cannot infer type for type parameter `T` declared on the function `bar` | note: the type is part of the `async fn` body because of this `await` - --> $DIR/unresolved_type_param.rs:12:11 + --> $DIR/unresolved_type_param.rs:10:11 | LL | bar().await; | ^^^^^ error[E0698]: type inside `async fn` body must be known in this context - --> $DIR/unresolved_type_param.rs:12:5 + --> $DIR/unresolved_type_param.rs:10:5 | LL | bar().await; | ^^^ cannot infer type for type parameter `T` declared on the function `bar` | note: the type is part of the `async fn` body because of this `await` - --> $DIR/unresolved_type_param.rs:12:11 + --> $DIR/unresolved_type_param.rs:10:11 | LL | bar().await; | ^^^^^ error[E0698]: type inside `async fn` body must be known in this context - --> $DIR/unresolved_type_param.rs:12:5 + --> $DIR/unresolved_type_param.rs:10:5 | LL | bar().await; | ^^^ cannot infer type for type parameter `T` declared on the function `bar` | note: the type is part of the `async fn` body because of this `await` - --> $DIR/unresolved_type_param.rs:12:11 + --> $DIR/unresolved_type_param.rs:10:11 | LL | bar().await; | ^^^^^ diff --git a/tests/ui/async-await/unsized-across-await.no_drop_tracking.stderr b/tests/ui/async-await/unsized-across-await.no_drop_tracking.stderr deleted file mode 100644 index c606df8e031..00000000000 --- a/tests/ui/async-await/unsized-across-await.no_drop_tracking.stderr +++ /dev/null @@ -1,21 +0,0 @@ -warning: the feature `unsized_locals` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/unsized-across-await.rs:5:12 - | -LL | #![feature(unsized_locals)] - | ^^^^^^^^^^^^^^ - | - = note: see issue #48055 for more information - = note: `#[warn(incomplete_features)]` on by default - -error[E0277]: the size for values of type `dyn std::fmt::Display` cannot be known at compilation time - --> $DIR/unsized-across-await.rs:11:9 - | -LL | let _x = *x; - | ^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `dyn std::fmt::Display` - = note: all values live across `await` must have a statically known size - -error: aborting due to previous error; 1 warning emitted - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/async-await/unsized-across-await.rs b/tests/ui/async-await/unsized-across-await.rs index 9934e9db6d2..32cb4f88eae 100644 --- a/tests/ui/async-await/unsized-across-await.rs +++ b/tests/ui/async-await/unsized-across-await.rs @@ -1,6 +1,4 @@ // edition: 2021 -// revisions: no_drop_tracking drop_tracking_mir -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir #![feature(unsized_locals)] //~^ WARN the feature `unsized_locals` is incomplete diff --git a/tests/ui/async-await/unsized-across-await.drop_tracking_mir.stderr b/tests/ui/async-await/unsized-across-await.stderr similarity index 91% rename from tests/ui/async-await/unsized-across-await.drop_tracking_mir.stderr rename to tests/ui/async-await/unsized-across-await.stderr index c606df8e031..649b12ce5a5 100644 --- a/tests/ui/async-await/unsized-across-await.drop_tracking_mir.stderr +++ b/tests/ui/async-await/unsized-across-await.stderr @@ -1,5 +1,5 @@ warning: the feature `unsized_locals` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/unsized-across-await.rs:5:12 + --> $DIR/unsized-across-await.rs:3:12 | LL | #![feature(unsized_locals)] | ^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | #![feature(unsized_locals)] = note: `#[warn(incomplete_features)]` on by default error[E0277]: the size for values of type `dyn std::fmt::Display` cannot be known at compilation time - --> $DIR/unsized-across-await.rs:11:9 + --> $DIR/unsized-across-await.rs:9:9 | LL | let _x = *x; | ^^ doesn't have a size known at compile-time diff --git a/tests/ui/generator/addassign-yield.rs b/tests/ui/generator/addassign-yield.rs index 7211367afee..66f22bf31fc 100644 --- a/tests/ui/generator/addassign-yield.rs +++ b/tests/ui/generator/addassign-yield.rs @@ -1,6 +1,3 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir // run-pass // Regression test for broken MIR error (#61442) // Due to the two possible evaluation orders for diff --git a/tests/ui/generator/auto-trait-regions.drop_tracking.stderr b/tests/ui/generator/auto-trait-regions.drop_tracking.stderr deleted file mode 100644 index b2a5b92ed0f..00000000000 --- a/tests/ui/generator/auto-trait-regions.drop_tracking.stderr +++ /dev/null @@ -1,55 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/auto-trait-regions.rs:48:24 - | -LL | let a = A(&mut true, &mut true, No); - | ^^^^ - temporary value is freed at the end of this statement - | | - | creates a temporary value which is freed while still in use -... -LL | assert_foo(a); - | - borrow later used here - | -help: consider using a `let` binding to create a longer lived value - | -LL ~ let binding = true; -LL ~ let a = A(&mut binding, &mut true, No); - | - -error[E0716]: temporary value dropped while borrowed - --> $DIR/auto-trait-regions.rs:48:35 - | -LL | let a = A(&mut true, &mut true, No); - | ^^^^ - temporary value is freed at the end of this statement - | | - | creates a temporary value which is freed while still in use -... -LL | assert_foo(a); - | - borrow later used here - | -help: consider using a `let` binding to create a longer lived value - | -LL ~ let binding = true; -LL ~ let a = A(&mut true, &mut binding, No); - | - -error: implementation of `Foo` is not general enough - --> $DIR/auto-trait-regions.rs:34:5 - | -LL | assert_foo(gen); - | ^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough - | - = note: `&'0 OnlyFooIfStaticRef` must implement `Foo`, for any lifetime `'0`... - = note: ...but `Foo` is actually implemented for the type `&'static OnlyFooIfStaticRef` - -error: implementation of `Foo` is not general enough - --> $DIR/auto-trait-regions.rs:54:5 - | -LL | assert_foo(gen); - | ^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough - | - = note: `Foo` would have to be implemented for the type `A<'0, '1>`, for any two lifetimes `'0` and `'1`... - = note: ...but `Foo` is actually implemented for the type `A<'_, '2>`, for some specific lifetime `'2` - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0716`. diff --git a/tests/ui/generator/auto-trait-regions.no_drop_tracking.stderr b/tests/ui/generator/auto-trait-regions.no_drop_tracking.stderr deleted file mode 100644 index b2a5b92ed0f..00000000000 --- a/tests/ui/generator/auto-trait-regions.no_drop_tracking.stderr +++ /dev/null @@ -1,55 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/auto-trait-regions.rs:48:24 - | -LL | let a = A(&mut true, &mut true, No); - | ^^^^ - temporary value is freed at the end of this statement - | | - | creates a temporary value which is freed while still in use -... -LL | assert_foo(a); - | - borrow later used here - | -help: consider using a `let` binding to create a longer lived value - | -LL ~ let binding = true; -LL ~ let a = A(&mut binding, &mut true, No); - | - -error[E0716]: temporary value dropped while borrowed - --> $DIR/auto-trait-regions.rs:48:35 - | -LL | let a = A(&mut true, &mut true, No); - | ^^^^ - temporary value is freed at the end of this statement - | | - | creates a temporary value which is freed while still in use -... -LL | assert_foo(a); - | - borrow later used here - | -help: consider using a `let` binding to create a longer lived value - | -LL ~ let binding = true; -LL ~ let a = A(&mut true, &mut binding, No); - | - -error: implementation of `Foo` is not general enough - --> $DIR/auto-trait-regions.rs:34:5 - | -LL | assert_foo(gen); - | ^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough - | - = note: `&'0 OnlyFooIfStaticRef` must implement `Foo`, for any lifetime `'0`... - = note: ...but `Foo` is actually implemented for the type `&'static OnlyFooIfStaticRef` - -error: implementation of `Foo` is not general enough - --> $DIR/auto-trait-regions.rs:54:5 - | -LL | assert_foo(gen); - | ^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough - | - = note: `Foo` would have to be implemented for the type `A<'0, '1>`, for any two lifetimes `'0` and `'1`... - = note: ...but `Foo` is actually implemented for the type `A<'_, '2>`, for some specific lifetime `'2` - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0716`. diff --git a/tests/ui/generator/auto-trait-regions.rs b/tests/ui/generator/auto-trait-regions.rs index 350f3cc34ce..aa4218e13a4 100644 --- a/tests/ui/generator/auto-trait-regions.rs +++ b/tests/ui/generator/auto-trait-regions.rs @@ -1,6 +1,3 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir #![feature(generators)] #![feature(auto_traits)] #![feature(negative_impls)] diff --git a/tests/ui/generator/auto-trait-regions.drop_tracking_mir.stderr b/tests/ui/generator/auto-trait-regions.stderr similarity index 92% rename from tests/ui/generator/auto-trait-regions.drop_tracking_mir.stderr rename to tests/ui/generator/auto-trait-regions.stderr index b2a5b92ed0f..a9a0bde2ba0 100644 --- a/tests/ui/generator/auto-trait-regions.drop_tracking_mir.stderr +++ b/tests/ui/generator/auto-trait-regions.stderr @@ -1,5 +1,5 @@ error[E0716]: temporary value dropped while borrowed - --> $DIR/auto-trait-regions.rs:48:24 + --> $DIR/auto-trait-regions.rs:45:24 | LL | let a = A(&mut true, &mut true, No); | ^^^^ - temporary value is freed at the end of this statement @@ -16,7 +16,7 @@ LL ~ let a = A(&mut binding, &mut true, No); | error[E0716]: temporary value dropped while borrowed - --> $DIR/auto-trait-regions.rs:48:35 + --> $DIR/auto-trait-regions.rs:45:35 | LL | let a = A(&mut true, &mut true, No); | ^^^^ - temporary value is freed at the end of this statement @@ -33,7 +33,7 @@ LL ~ let a = A(&mut true, &mut binding, No); | error: implementation of `Foo` is not general enough - --> $DIR/auto-trait-regions.rs:34:5 + --> $DIR/auto-trait-regions.rs:31:5 | LL | assert_foo(gen); | ^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough @@ -42,7 +42,7 @@ LL | assert_foo(gen); = note: ...but `Foo` is actually implemented for the type `&'static OnlyFooIfStaticRef` error: implementation of `Foo` is not general enough - --> $DIR/auto-trait-regions.rs:54:5 + --> $DIR/auto-trait-regions.rs:51:5 | LL | assert_foo(gen); | ^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough diff --git a/tests/ui/generator/borrowing.drop_tracking_mir.stderr b/tests/ui/generator/borrowing.drop_tracking_mir.stderr deleted file mode 100644 index 8fbad276db4..00000000000 --- a/tests/ui/generator/borrowing.drop_tracking_mir.stderr +++ /dev/null @@ -1,39 +0,0 @@ -error[E0597]: `a` does not live long enough - --> $DIR/borrowing.rs:13:33 - | -LL | Pin::new(&mut || yield &a).resume(()) - | ----------^ - | | | - | | borrowed value does not live long enough - | value captured here by generator - | a temporary with access to the borrow is created here ... -LL | -LL | }; - | -- ... and the borrow might be used here, when that temporary is dropped and runs the destructor for generator - | | - | `a` dropped here while still borrowed - | - = note: the temporary is part of an expression at the end of a block; - consider forcing this temporary to be dropped sooner, before the block's local variables are dropped -help: for example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block - | -LL | let x = Pin::new(&mut || yield &a).resume(()); x - | +++++++ +++ - -error[E0597]: `a` does not live long enough - --> $DIR/borrowing.rs:20:20 - | -LL | let _b = { - | -- borrow later stored here -LL | let a = 3; -LL | || { - | -- value captured here by generator -LL | yield &a - | ^ borrowed value does not live long enough -... -LL | }; - | - `a` dropped here while still borrowed - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/tests/ui/generator/borrowing.no_drop_tracking.stderr b/tests/ui/generator/borrowing.no_drop_tracking.stderr deleted file mode 100644 index 96e3c327f8b..00000000000 --- a/tests/ui/generator/borrowing.no_drop_tracking.stderr +++ /dev/null @@ -1,31 +0,0 @@ -error[E0597]: `a` does not live long enough - --> $DIR/borrowing.rs:13:33 - | -LL | let _b = { - | -- borrow later stored here -LL | let a = 3; -LL | Pin::new(&mut || yield &a).resume(()) - | -- ^ borrowed value does not live long enough - | | - | value captured here by generator -LL | -LL | }; - | - `a` dropped here while still borrowed - -error[E0597]: `a` does not live long enough - --> $DIR/borrowing.rs:20:20 - | -LL | let _b = { - | -- borrow later stored here -LL | let a = 3; -LL | || { - | -- value captured here by generator -LL | yield &a - | ^ borrowed value does not live long enough -... -LL | }; - | - `a` dropped here while still borrowed - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/tests/ui/generator/borrowing.rs b/tests/ui/generator/borrowing.rs index 29f39437f8f..d36592583cd 100644 --- a/tests/ui/generator/borrowing.rs +++ b/tests/ui/generator/borrowing.rs @@ -1,7 +1,3 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir - #![feature(generators, generator_trait)] use std::ops::Generator; diff --git a/tests/ui/generator/borrowing.drop_tracking.stderr b/tests/ui/generator/borrowing.stderr similarity index 93% rename from tests/ui/generator/borrowing.drop_tracking.stderr rename to tests/ui/generator/borrowing.stderr index 96e3c327f8b..38e1ace8c4e 100644 --- a/tests/ui/generator/borrowing.drop_tracking.stderr +++ b/tests/ui/generator/borrowing.stderr @@ -1,5 +1,5 @@ error[E0597]: `a` does not live long enough - --> $DIR/borrowing.rs:13:33 + --> $DIR/borrowing.rs:9:33 | LL | let _b = { | -- borrow later stored here @@ -13,7 +13,7 @@ LL | }; | - `a` dropped here while still borrowed error[E0597]: `a` does not live long enough - --> $DIR/borrowing.rs:20:20 + --> $DIR/borrowing.rs:16:20 | LL | let _b = { | -- borrow later stored here diff --git a/tests/ui/generator/drop-tracking-parent-expression.drop_tracking_mir.stderr b/tests/ui/generator/drop-tracking-parent-expression.drop_tracking_mir.stderr deleted file mode 100644 index 25553e6bb60..00000000000 --- a/tests/ui/generator/drop-tracking-parent-expression.drop_tracking_mir.stderr +++ /dev/null @@ -1,122 +0,0 @@ -error: generator cannot be sent between threads safely - --> $DIR/drop-tracking-parent-expression.rs:27:13 - | -LL | assert_send(g); - | ^^^^^^^^^^^ generator is not `Send` -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation - | - = help: within `{generator@$DIR/drop-tracking-parent-expression.rs:21:21: 21:28}`, the trait `Send` is not implemented for `derived_drop::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/drop-tracking-parent-expression.rs:25:22 - | -LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { - | ------------------------ has type `derived_drop::Client` which is not `Send` -... -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/drop-tracking-parent-expression.rs:49:19 - | -LL | fn assert_send(_thing: T) {} - | ^^^^ required by this bound in `assert_send` - = note: this error originates in the macro `type_combinations` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: generator cannot be sent between threads safely - --> $DIR/drop-tracking-parent-expression.rs:27:13 - | -LL | assert_send(g); - | ^^^^^^^^^^^ generator is not `Send` -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation - | - = help: within `{generator@$DIR/drop-tracking-parent-expression.rs:21:21: 21:28}`, the trait `Send` is not implemented for `significant_drop::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/drop-tracking-parent-expression.rs:25:22 - | -LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { - | ------------------------ has type `significant_drop::Client` which is not `Send` -... -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/drop-tracking-parent-expression.rs:49:19 - | -LL | fn assert_send(_thing: T) {} - | ^^^^ required by this bound in `assert_send` - = note: this error originates in the macro `type_combinations` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: generator cannot be sent between threads safely - --> $DIR/drop-tracking-parent-expression.rs:27:13 - | -LL | assert_send(g); - | ^^^^^^^^^^^ generator is not `Send` -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation - | - = help: within `{generator@$DIR/drop-tracking-parent-expression.rs:21:21: 21:28}`, the trait `Send` is not implemented for `insignificant_dtor::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/drop-tracking-parent-expression.rs:25:22 - | -LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { - | ------------------------ has type `insignificant_dtor::Client` which is not `Send` -... -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/drop-tracking-parent-expression.rs:49:19 - | -LL | fn assert_send(_thing: T) {} - | ^^^^ required by this bound in `assert_send` - = note: this error originates in the macro `type_combinations` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: aborting due to 3 previous errors - diff --git a/tests/ui/generator/drop-tracking-parent-expression.no_drop_tracking.stderr b/tests/ui/generator/drop-tracking-parent-expression.no_drop_tracking.stderr deleted file mode 100644 index 2d141b6b49f..00000000000 --- a/tests/ui/generator/drop-tracking-parent-expression.no_drop_tracking.stderr +++ /dev/null @@ -1,334 +0,0 @@ -error: generator cannot be sent between threads safely - --> $DIR/drop-tracking-parent-expression.rs:27:25 - | -LL | assert_send(g); - | ^ generator is not `Send` -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation - | - = help: within `{generator@$DIR/drop-tracking-parent-expression.rs:21:21: 21:28}`, the trait `Send` is not implemented for `copy::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/drop-tracking-parent-expression.rs:25:22 - | -LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { - | ------------------------ has type `copy::Client` which is not `Send` -... -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -LL | }; - | - `$name::Client::default()` is later dropped here -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/drop-tracking-parent-expression.rs:49:19 - | -LL | fn assert_send(_thing: T) {} - | ^^^^ required by this bound in `assert_send` - = note: this error originates in the macro `type_combinations` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: generator cannot be sent between threads safely - --> $DIR/drop-tracking-parent-expression.rs:40:25 - | -LL | assert_send(g); - | ^ generator is not `Send` -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation - | - = help: within `{generator@$DIR/drop-tracking-parent-expression.rs:37:21: 37:28}`, the trait `Send` is not implemented for `copy::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/drop-tracking-parent-expression.rs:38:22 - | -LL | let g = move || match drop($name::Client::default()) { - | ------------------------ has type `copy::Client` which is not `Send` -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -LL | }; - | - `$name::Client::default()` is later dropped here -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/drop-tracking-parent-expression.rs:49:19 - | -LL | fn assert_send(_thing: T) {} - | ^^^^ required by this bound in `assert_send` - = note: this error originates in the macro `type_combinations` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: generator cannot be sent between threads safely - --> $DIR/drop-tracking-parent-expression.rs:27:25 - | -LL | assert_send(g); - | ^ generator is not `Send` -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation - | - = help: within `{generator@$DIR/drop-tracking-parent-expression.rs:21:21: 21:28}`, the trait `Send` is not implemented for `derived_drop::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/drop-tracking-parent-expression.rs:25:22 - | -LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { - | ------------------------ has type `derived_drop::Client` which is not `Send` -... -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -LL | }; - | - `$name::Client::default()` is later dropped here -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/drop-tracking-parent-expression.rs:49:19 - | -LL | fn assert_send(_thing: T) {} - | ^^^^ required by this bound in `assert_send` - = note: this error originates in the macro `type_combinations` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: generator cannot be sent between threads safely - --> $DIR/drop-tracking-parent-expression.rs:40:25 - | -LL | assert_send(g); - | ^ generator is not `Send` -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation - | - = help: within `{generator@$DIR/drop-tracking-parent-expression.rs:37:21: 37:28}`, the trait `Send` is not implemented for `derived_drop::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/drop-tracking-parent-expression.rs:38:22 - | -LL | let g = move || match drop($name::Client::default()) { - | ------------------------ has type `derived_drop::Client` which is not `Send` -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -LL | }; - | - `$name::Client::default()` is later dropped here -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/drop-tracking-parent-expression.rs:49:19 - | -LL | fn assert_send(_thing: T) {} - | ^^^^ required by this bound in `assert_send` - = note: this error originates in the macro `type_combinations` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: generator cannot be sent between threads safely - --> $DIR/drop-tracking-parent-expression.rs:27:25 - | -LL | assert_send(g); - | ^ generator is not `Send` -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation - | - = help: within `{generator@$DIR/drop-tracking-parent-expression.rs:21:21: 21:28}`, the trait `Send` is not implemented for `significant_drop::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/drop-tracking-parent-expression.rs:25:22 - | -LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { - | ------------------------ has type `significant_drop::Client` which is not `Send` -... -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -LL | }; - | - `$name::Client::default()` is later dropped here -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/drop-tracking-parent-expression.rs:49:19 - | -LL | fn assert_send(_thing: T) {} - | ^^^^ required by this bound in `assert_send` - = note: this error originates in the macro `type_combinations` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: generator cannot be sent between threads safely - --> $DIR/drop-tracking-parent-expression.rs:40:25 - | -LL | assert_send(g); - | ^ generator is not `Send` -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation - | - = help: within `{generator@$DIR/drop-tracking-parent-expression.rs:37:21: 37:28}`, the trait `Send` is not implemented for `significant_drop::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/drop-tracking-parent-expression.rs:38:22 - | -LL | let g = move || match drop($name::Client::default()) { - | ------------------------ has type `significant_drop::Client` which is not `Send` -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -LL | }; - | - `$name::Client::default()` is later dropped here -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/drop-tracking-parent-expression.rs:49:19 - | -LL | fn assert_send(_thing: T) {} - | ^^^^ required by this bound in `assert_send` - = note: this error originates in the macro `type_combinations` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: generator cannot be sent between threads safely - --> $DIR/drop-tracking-parent-expression.rs:27:25 - | -LL | assert_send(g); - | ^ generator is not `Send` -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation - | - = help: within `{generator@$DIR/drop-tracking-parent-expression.rs:21:21: 21:28}`, the trait `Send` is not implemented for `insignificant_dtor::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/drop-tracking-parent-expression.rs:25:22 - | -LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { - | ------------------------ has type `insignificant_dtor::Client` which is not `Send` -... -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -LL | }; - | - `$name::Client::default()` is later dropped here -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/drop-tracking-parent-expression.rs:49:19 - | -LL | fn assert_send(_thing: T) {} - | ^^^^ required by this bound in `assert_send` - = note: this error originates in the macro `type_combinations` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: generator cannot be sent between threads safely - --> $DIR/drop-tracking-parent-expression.rs:40:25 - | -LL | assert_send(g); - | ^ generator is not `Send` -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation - | - = help: within `{generator@$DIR/drop-tracking-parent-expression.rs:37:21: 37:28}`, the trait `Send` is not implemented for `insignificant_dtor::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/drop-tracking-parent-expression.rs:38:22 - | -LL | let g = move || match drop($name::Client::default()) { - | ------------------------ has type `insignificant_dtor::Client` which is not `Send` -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -LL | }; - | - `$name::Client::default()` is later dropped here -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/drop-tracking-parent-expression.rs:49:19 - | -LL | fn assert_send(_thing: T) {} - | ^^^^ required by this bound in `assert_send` - = note: this error originates in the macro `type_combinations` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: aborting due to 8 previous errors - diff --git a/tests/ui/generator/drop-tracking-parent-expression.rs b/tests/ui/generator/drop-tracking-parent-expression.rs index ed9ac6d11ad..d40f1b8f64d 100644 --- a/tests/ui/generator/drop-tracking-parent-expression.rs +++ b/tests/ui/generator/drop-tracking-parent-expression.rs @@ -1,7 +1,4 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir - +// compile-flags: -Zdrop-tracking #![feature(generators, negative_impls, rustc_attrs)] macro_rules! type_combinations { @@ -21,14 +18,13 @@ macro_rules! type_combinations { let g = move || match drop($name::Client { ..$name::Client::default() }) { //~^ `significant_drop::Client` which is not `Send` //~| `insignificant_dtor::Client` which is not `Send` - //[no_drop_tracking,drop_tracking]~| `derived_drop::Client` which is not `Send` + //~| `derived_drop::Client` which is not `Send` _ => yield, }; assert_send(g); //~^ ERROR cannot be sent between threads //~| ERROR cannot be sent between threads //~| ERROR cannot be sent between threads - //[no_drop_tracking]~| ERROR cannot be sent between threads } // Simple owned value. This works because the Client is considered moved into `drop`, @@ -38,10 +34,6 @@ macro_rules! type_combinations { _ => yield, }; assert_send(g); - //[no_drop_tracking]~^ ERROR cannot be sent between threads - //[no_drop_tracking]~| ERROR cannot be sent between threads - //[no_drop_tracking]~| ERROR cannot be sent between threads - //[no_drop_tracking]~| ERROR cannot be sent between threads } )* } } diff --git a/tests/ui/generator/drop-tracking-parent-expression.drop_tracking.stderr b/tests/ui/generator/drop-tracking-parent-expression.stderr similarity index 88% rename from tests/ui/generator/drop-tracking-parent-expression.drop_tracking.stderr rename to tests/ui/generator/drop-tracking-parent-expression.stderr index 190e60d5bfc..6119f689731 100644 --- a/tests/ui/generator/drop-tracking-parent-expression.drop_tracking.stderr +++ b/tests/ui/generator/drop-tracking-parent-expression.stderr @@ -1,5 +1,5 @@ error: generator cannot be sent between threads safely - --> $DIR/drop-tracking-parent-expression.rs:27:25 + --> $DIR/drop-tracking-parent-expression.rs:24:25 | LL | assert_send(g); | ^ generator is not `Send` @@ -13,9 +13,9 @@ LL | | }; LL | | ); | |_____- in this macro invocation | - = help: within `{generator@$DIR/drop-tracking-parent-expression.rs:21:21: 21:28}`, the trait `Send` is not implemented for `derived_drop::Client` + = help: within `{generator@$DIR/drop-tracking-parent-expression.rs:18:21: 18:28}`, the trait `Send` is not implemented for `derived_drop::Client` note: generator is not `Send` as this value is used across a yield - --> $DIR/drop-tracking-parent-expression.rs:25:22 + --> $DIR/drop-tracking-parent-expression.rs:22:22 | LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { | ------------------------ has type `derived_drop::Client` which is not `Send` @@ -34,14 +34,14 @@ LL | | }; LL | | ); | |_____- in this macro invocation note: required by a bound in `assert_send` - --> $DIR/drop-tracking-parent-expression.rs:49:19 + --> $DIR/drop-tracking-parent-expression.rs:41:19 | LL | fn assert_send(_thing: T) {} | ^^^^ required by this bound in `assert_send` = note: this error originates in the macro `type_combinations` (in Nightly builds, run with -Z macro-backtrace for more info) error: generator cannot be sent between threads safely - --> $DIR/drop-tracking-parent-expression.rs:27:25 + --> $DIR/drop-tracking-parent-expression.rs:24:25 | LL | assert_send(g); | ^ generator is not `Send` @@ -55,9 +55,9 @@ LL | | }; LL | | ); | |_____- in this macro invocation | - = help: within `{generator@$DIR/drop-tracking-parent-expression.rs:21:21: 21:28}`, the trait `Send` is not implemented for `significant_drop::Client` + = help: within `{generator@$DIR/drop-tracking-parent-expression.rs:18:21: 18:28}`, the trait `Send` is not implemented for `significant_drop::Client` note: generator is not `Send` as this value is used across a yield - --> $DIR/drop-tracking-parent-expression.rs:25:22 + --> $DIR/drop-tracking-parent-expression.rs:22:22 | LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { | ------------------------ has type `significant_drop::Client` which is not `Send` @@ -76,14 +76,14 @@ LL | | }; LL | | ); | |_____- in this macro invocation note: required by a bound in `assert_send` - --> $DIR/drop-tracking-parent-expression.rs:49:19 + --> $DIR/drop-tracking-parent-expression.rs:41:19 | LL | fn assert_send(_thing: T) {} | ^^^^ required by this bound in `assert_send` = note: this error originates in the macro `type_combinations` (in Nightly builds, run with -Z macro-backtrace for more info) error: generator cannot be sent between threads safely - --> $DIR/drop-tracking-parent-expression.rs:27:25 + --> $DIR/drop-tracking-parent-expression.rs:24:25 | LL | assert_send(g); | ^ generator is not `Send` @@ -97,9 +97,9 @@ LL | | }; LL | | ); | |_____- in this macro invocation | - = help: within `{generator@$DIR/drop-tracking-parent-expression.rs:21:21: 21:28}`, the trait `Send` is not implemented for `insignificant_dtor::Client` + = help: within `{generator@$DIR/drop-tracking-parent-expression.rs:18:21: 18:28}`, the trait `Send` is not implemented for `insignificant_dtor::Client` note: generator is not `Send` as this value is used across a yield - --> $DIR/drop-tracking-parent-expression.rs:25:22 + --> $DIR/drop-tracking-parent-expression.rs:22:22 | LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { | ------------------------ has type `insignificant_dtor::Client` which is not `Send` @@ -118,7 +118,7 @@ LL | | }; LL | | ); | |_____- in this macro invocation note: required by a bound in `assert_send` - --> $DIR/drop-tracking-parent-expression.rs:49:19 + --> $DIR/drop-tracking-parent-expression.rs:41:19 | LL | fn assert_send(_thing: T) {} | ^^^^ required by this bound in `assert_send` diff --git a/tests/ui/generator/drop-tracking-yielding-in-match-guards.rs b/tests/ui/generator/drop-tracking-yielding-in-match-guards.rs index cbc291701cb..646365e4359 100644 --- a/tests/ui/generator/drop-tracking-yielding-in-match-guards.rs +++ b/tests/ui/generator/drop-tracking-yielding-in-match-guards.rs @@ -1,8 +1,6 @@ // build-pass // edition:2018 -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir +// compile-flags: -Zdrop-tracking #![feature(generators)] diff --git a/tests/ui/generator/issue-105084.rs b/tests/ui/generator/issue-105084.rs index ff9357b76a0..9fdeb4fd2fc 100644 --- a/tests/ui/generator/issue-105084.rs +++ b/tests/ui/generator/issue-105084.rs @@ -1,10 +1,4 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir -// [no_drop_tracking] known-bug: #105084 -// [no_drop_tracking] check-pass -// [drop_tracking] known-bug: #105084 -// [drop_tracking] check-pass +// compile-flags: -Zdrop-tracking-mir #![feature(generators)] #![feature(generator_clone)] @@ -37,13 +31,13 @@ fn main() { // As it is not taken into account for trait computation, // the generator is `Copy`. let mut h = copy(g); - //[drop_tracking_mir]~^ ERROR the trait bound `Box<(i32, ())>: Copy` is not satisfied in + //~^ ERROR the trait bound `Box<(i32, ())>: Copy` is not satisfied in // We now have 2 boxes with the same backing allocation: // one inside `g` and one inside `h`. // Proceed and drop `t` in `g`. Pin::new(&mut g).resume(()); - //[drop_tracking_mir]~^ ERROR borrow of moved value: `g` + //~^ ERROR borrow of moved value: `g` // Proceed and drop `t` in `h` -> double free! Pin::new(&mut h).resume(()); diff --git a/tests/ui/generator/issue-105084.drop_tracking_mir.stderr b/tests/ui/generator/issue-105084.stderr similarity index 81% rename from tests/ui/generator/issue-105084.drop_tracking_mir.stderr rename to tests/ui/generator/issue-105084.stderr index c0ee3237ad1..3f1f11918f5 100644 --- a/tests/ui/generator/issue-105084.drop_tracking_mir.stderr +++ b/tests/ui/generator/issue-105084.stderr @@ -1,8 +1,8 @@ error[E0382]: borrow of moved value: `g` - --> $DIR/issue-105084.rs:45:14 + --> $DIR/issue-105084.rs:39:14 | LL | let mut g = || { - | ----- move occurs because `g` has type `{generator@$DIR/issue-105084.rs:22:17: 22:19}`, which does not implement the `Copy` trait + | ----- move occurs because `g` has type `{generator@$DIR/issue-105084.rs:16:17: 16:19}`, which does not implement the `Copy` trait ... LL | let mut h = copy(g); | - value moved here @@ -11,7 +11,7 @@ LL | Pin::new(&mut g).resume(()); | ^^^^^^ value borrowed here after move | note: consider changing this parameter type in function `copy` to borrow instead if owning the value isn't necessary - --> $DIR/issue-105084.rs:17:21 + --> $DIR/issue-105084.rs:11:21 | LL | fn copy(x: T) -> T { | ---- ^ this parameter takes ownership of the value @@ -22,17 +22,17 @@ help: consider cloning the value if the performance cost is acceptable LL | let mut h = copy(g.clone()); | ++++++++ -error[E0277]: the trait bound `Box<(i32, ())>: Copy` is not satisfied in `{generator@$DIR/issue-105084.rs:22:17: 22:19}` - --> $DIR/issue-105084.rs:39:17 +error[E0277]: the trait bound `Box<(i32, ())>: Copy` is not satisfied in `{generator@$DIR/issue-105084.rs:16:17: 16:19}` + --> $DIR/issue-105084.rs:33:17 | LL | let mut g = || { - | -- within this `{generator@$DIR/issue-105084.rs:22:17: 22:19}` + | -- within this `{generator@$DIR/issue-105084.rs:16:17: 16:19}` ... LL | let mut h = copy(g); - | ^^^^ within `{generator@$DIR/issue-105084.rs:22:17: 22:19}`, the trait `Copy` is not implemented for `Box<(i32, ())>` + | ^^^^ within `{generator@$DIR/issue-105084.rs:16:17: 16:19}`, the trait `Copy` is not implemented for `Box<(i32, ())>` | note: generator does not implement `Copy` as this value is used across a yield - --> $DIR/issue-105084.rs:29:22 + --> $DIR/issue-105084.rs:23:22 | LL | Box::new((5, yield)); | -------------^^^^^-- @@ -40,7 +40,7 @@ LL | Box::new((5, yield)); | | yield occurs here, with `Box::new((5, yield))` maybe used later | has type `Box<(i32, ())>` which does not implement `Copy` note: required by a bound in `copy` - --> $DIR/issue-105084.rs:17:12 + --> $DIR/issue-105084.rs:11:12 | LL | fn copy(x: T) -> T { | ^^^^ required by this bound in `copy` diff --git a/tests/ui/generator/issue-57017.no_drop_tracking.stderr b/tests/ui/generator/issue-57017.no_drop_tracking.stderr deleted file mode 100644 index cd5cf12cc49..00000000000 --- a/tests/ui/generator/issue-57017.no_drop_tracking.stderr +++ /dev/null @@ -1,248 +0,0 @@ -error: generator cannot be sent between threads safely - --> $DIR/issue-57017.rs:32:25 - | -LL | assert_send(g); - | ^ generator is not `Send` -... -LL | / type_combinations!( -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | derived_drop => { #[derive(Default)] pub struct Client { pub nickname: String } }; -LL | | significant_drop => { -... | -LL | | } -LL | | ); - | |_____- in this macro invocation - | - = help: the trait `Sync` is not implemented for `copy::unsync::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/issue-57017.rs:30:28 - | -LL | let g = move || match drop(&$name::unsync::Client::default()) { - | --------------------------------- has type `©::unsync::Client` which is not `Send` -LL | _status => yield, - | ^^^^^ yield occurs here, with `&$name::unsync::Client::default()` maybe used later -LL | }; - | - `&$name::unsync::Client::default()` is later dropped here -... -LL | / type_combinations!( -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | derived_drop => { #[derive(Default)] pub struct Client { pub nickname: String } }; -LL | | significant_drop => { -... | -LL | | } -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/issue-57017.rs:52:19 - | -LL | fn assert_send(_thing: T) {} - | ^^^^ required by this bound in `assert_send` - = note: this error originates in the macro `type_combinations` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: generator cannot be sent between threads safely - --> $DIR/issue-57017.rs:44:25 - | -LL | assert_send(g); - | ^ generator is not `Send` -... -LL | / type_combinations!( -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | derived_drop => { #[derive(Default)] pub struct Client { pub nickname: String } }; -LL | | significant_drop => { -... | -LL | | } -LL | | ); - | |_____- in this macro invocation - | - = help: within `{generator@$DIR/issue-57017.rs:41:21: 41:28}`, the trait `Send` is not implemented for `copy::unsend::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/issue-57017.rs:42:28 - | -LL | let g = move || match drop($name::unsend::Client::default()) { - | -------------------------------- has type `copy::unsend::Client` which is not `Send` -LL | _status => yield, - | ^^^^^ yield occurs here, with `$name::unsend::Client::default()` maybe used later -LL | }; - | - `$name::unsend::Client::default()` is later dropped here -... -LL | / type_combinations!( -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | derived_drop => { #[derive(Default)] pub struct Client { pub nickname: String } }; -LL | | significant_drop => { -... | -LL | | } -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/issue-57017.rs:52:19 - | -LL | fn assert_send(_thing: T) {} - | ^^^^ required by this bound in `assert_send` - = note: this error originates in the macro `type_combinations` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: generator cannot be sent between threads safely - --> $DIR/issue-57017.rs:32:25 - | -LL | assert_send(g); - | ^ generator is not `Send` -... -LL | / type_combinations!( -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | derived_drop => { #[derive(Default)] pub struct Client { pub nickname: String } }; -LL | | significant_drop => { -... | -LL | | } -LL | | ); - | |_____- in this macro invocation - | - = help: the trait `Sync` is not implemented for `derived_drop::unsync::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/issue-57017.rs:30:28 - | -LL | let g = move || match drop(&$name::unsync::Client::default()) { - | --------------------------------- has type `&derived_drop::unsync::Client` which is not `Send` -LL | _status => yield, - | ^^^^^ yield occurs here, with `&$name::unsync::Client::default()` maybe used later -LL | }; - | - `&$name::unsync::Client::default()` is later dropped here -... -LL | / type_combinations!( -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | derived_drop => { #[derive(Default)] pub struct Client { pub nickname: String } }; -LL | | significant_drop => { -... | -LL | | } -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/issue-57017.rs:52:19 - | -LL | fn assert_send(_thing: T) {} - | ^^^^ required by this bound in `assert_send` - = note: this error originates in the macro `type_combinations` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: generator cannot be sent between threads safely - --> $DIR/issue-57017.rs:44:25 - | -LL | assert_send(g); - | ^ generator is not `Send` -... -LL | / type_combinations!( -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | derived_drop => { #[derive(Default)] pub struct Client { pub nickname: String } }; -LL | | significant_drop => { -... | -LL | | } -LL | | ); - | |_____- in this macro invocation - | - = help: within `{generator@$DIR/issue-57017.rs:41:21: 41:28}`, the trait `Send` is not implemented for `derived_drop::unsend::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/issue-57017.rs:42:28 - | -LL | let g = move || match drop($name::unsend::Client::default()) { - | -------------------------------- has type `derived_drop::unsend::Client` which is not `Send` -LL | _status => yield, - | ^^^^^ yield occurs here, with `$name::unsend::Client::default()` maybe used later -LL | }; - | - `$name::unsend::Client::default()` is later dropped here -... -LL | / type_combinations!( -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | derived_drop => { #[derive(Default)] pub struct Client { pub nickname: String } }; -LL | | significant_drop => { -... | -LL | | } -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/issue-57017.rs:52:19 - | -LL | fn assert_send(_thing: T) {} - | ^^^^ required by this bound in `assert_send` - = note: this error originates in the macro `type_combinations` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: generator cannot be sent between threads safely - --> $DIR/issue-57017.rs:32:25 - | -LL | assert_send(g); - | ^ generator is not `Send` -... -LL | / type_combinations!( -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | derived_drop => { #[derive(Default)] pub struct Client { pub nickname: String } }; -LL | | significant_drop => { -... | -LL | | } -LL | | ); - | |_____- in this macro invocation - | - = help: the trait `Sync` is not implemented for `significant_drop::unsync::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/issue-57017.rs:30:28 - | -LL | let g = move || match drop(&$name::unsync::Client::default()) { - | --------------------------------- has type `&significant_drop::unsync::Client` which is not `Send` -LL | _status => yield, - | ^^^^^ yield occurs here, with `&$name::unsync::Client::default()` maybe used later -LL | }; - | - `&$name::unsync::Client::default()` is later dropped here -... -LL | / type_combinations!( -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | derived_drop => { #[derive(Default)] pub struct Client { pub nickname: String } }; -LL | | significant_drop => { -... | -LL | | } -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/issue-57017.rs:52:19 - | -LL | fn assert_send(_thing: T) {} - | ^^^^ required by this bound in `assert_send` - = note: this error originates in the macro `type_combinations` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: generator cannot be sent between threads safely - --> $DIR/issue-57017.rs:44:25 - | -LL | assert_send(g); - | ^ generator is not `Send` -... -LL | / type_combinations!( -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | derived_drop => { #[derive(Default)] pub struct Client { pub nickname: String } }; -LL | | significant_drop => { -... | -LL | | } -LL | | ); - | |_____- in this macro invocation - | - = help: within `{generator@$DIR/issue-57017.rs:41:21: 41:28}`, the trait `Send` is not implemented for `significant_drop::unsend::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/issue-57017.rs:42:28 - | -LL | let g = move || match drop($name::unsend::Client::default()) { - | -------------------------------- has type `significant_drop::unsend::Client` which is not `Send` -LL | _status => yield, - | ^^^^^ yield occurs here, with `$name::unsend::Client::default()` maybe used later -LL | }; - | - `$name::unsend::Client::default()` is later dropped here -... -LL | / type_combinations!( -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | derived_drop => { #[derive(Default)] pub struct Client { pub nickname: String } }; -LL | | significant_drop => { -... | -LL | | } -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/issue-57017.rs:52:19 - | -LL | fn assert_send(_thing: T) {} - | ^^^^ required by this bound in `assert_send` - = note: this error originates in the macro `type_combinations` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: aborting due to 6 previous errors - diff --git a/tests/ui/generator/issue-57017.rs b/tests/ui/generator/issue-57017.rs index 381897c77a5..6cb742b7ffe 100644 --- a/tests/ui/generator/issue-57017.rs +++ b/tests/ui/generator/issue-57017.rs @@ -1,9 +1,5 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir -// [drop_tracking] build-pass -// [drop_tracking_mir] build-pass - +// build-pass +// compile-flags: -Zdrop-tracking #![feature(generators, negative_impls)] #![allow(dropping_references, dropping_copy_types)] @@ -30,9 +26,6 @@ macro_rules! type_combinations { _status => yield, }; assert_send(g); - //[no_drop_tracking]~^ ERROR generator cannot be sent between threads safely - //[no_drop_tracking]~| ERROR generator cannot be sent between threads safely - //[no_drop_tracking]~| ERROR generator cannot be sent between threads safely } // This tests that `Client` is properly considered to be dropped after moving it into the @@ -42,9 +35,6 @@ macro_rules! type_combinations { _status => yield, }; assert_send(g); - //[no_drop_tracking]~^ ERROR generator cannot be sent between threads safely - //[no_drop_tracking]~| ERROR generator cannot be sent between threads safely - //[no_drop_tracking]~| ERROR generator cannot be sent between threads safely } )* } } diff --git a/tests/ui/generator/issue-57478.no_drop_tracking.stderr b/tests/ui/generator/issue-57478.no_drop_tracking.stderr deleted file mode 100644 index df931f5e04e..00000000000 --- a/tests/ui/generator/issue-57478.no_drop_tracking.stderr +++ /dev/null @@ -1,31 +0,0 @@ -error: generator cannot be sent between threads safely - --> $DIR/issue-57478.rs:13:17 - | -LL | assert_send(|| { - | _________________^ -LL | | -LL | | let guard = Foo; -LL | | drop(guard); -LL | | yield; -LL | | }) - | |_____^ generator is not `Send` - | - = help: within `{generator@$DIR/issue-57478.rs:13:17: 13:19}`, the trait `Send` is not implemented for `Foo` -note: generator is not `Send` as this value is used across a yield - --> $DIR/issue-57478.rs:17:9 - | -LL | let guard = Foo; - | ----- has type `Foo` which is not `Send` -LL | drop(guard); -LL | yield; - | ^^^^^ yield occurs here, with `guard` maybe used later -LL | }) - | - `guard` is later dropped here -note: required by a bound in `assert_send` - --> $DIR/issue-57478.rs:21:19 - | -LL | fn assert_send(_: T) {} - | ^^^^ required by this bound in `assert_send` - -error: aborting due to previous error - diff --git a/tests/ui/generator/issue-57478.rs b/tests/ui/generator/issue-57478.rs index 3c23b599271..91407ea1844 100644 --- a/tests/ui/generator/issue-57478.rs +++ b/tests/ui/generator/issue-57478.rs @@ -1,8 +1,5 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir -// [drop_tracking] check-pass -// [drop_tracking_mir] check-pass +// check-pass +// compile-flags: -Zdrop-tracking #![feature(negative_impls, generators)] @@ -11,7 +8,6 @@ impl !Send for Foo {} fn main() { assert_send(|| { - //[no_drop_tracking]~^ ERROR generator cannot be sent between threads safely let guard = Foo; drop(guard); yield; diff --git a/tests/ui/generator/issue-68112.drop_tracking.stderr b/tests/ui/generator/issue-68112.drop_tracking.stderr deleted file mode 100644 index 282eac1b686..00000000000 --- a/tests/ui/generator/issue-68112.drop_tracking.stderr +++ /dev/null @@ -1,66 +0,0 @@ -error: generator cannot be sent between threads safely - --> $DIR/issue-68112.rs:43:18 - | -LL | require_send(send_gen); - | ^^^^^^^^ generator is not `Send` - | - = help: the trait `Sync` is not implemented for `RefCell` - = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead -note: generator is not `Send` as this value is used across a yield - --> $DIR/issue-68112.rs:39:9 - | -LL | let _non_send_gen = make_non_send_generator(); - | ------------- has type `impl Generator>>` which is not `Send` -LL | -LL | yield; - | ^^^^^ yield occurs here, with `_non_send_gen` maybe used later -... -LL | }; - | - `_non_send_gen` is later dropped here -note: required by a bound in `require_send` - --> $DIR/issue-68112.rs:25:25 - | -LL | fn require_send(_: impl Send) {} - | ^^^^ required by this bound in `require_send` - -error[E0277]: `RefCell` cannot be shared between threads safely - --> $DIR/issue-68112.rs:67:18 - | -LL | require_send(send_gen); - | ------------ ^^^^^^^^ `RefCell` cannot be shared between threads safely - | | - | required by a bound introduced by this call - | - = help: the trait `Sync` is not implemented for `RefCell` - = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead - = note: required for `Arc>` to implement `Send` -note: required because it's used within this generator - --> $DIR/issue-68112.rs:52:5 - | -LL | || { - | ^^ -note: required because it appears within the type `impl Generator>>` - --> $DIR/issue-68112.rs:49:30 - | -LL | pub fn make_gen2(t: T) -> impl Generator { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: required because it appears within the type `impl Generator>>` - --> $DIR/issue-68112.rs:57:34 - | -LL | fn make_non_send_generator2() -> impl Generator>> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: required because it captures the following types: `impl Generator>>`, `()` -note: required because it's used within this generator - --> $DIR/issue-68112.rs:63:20 - | -LL | let send_gen = || { - | ^^ -note: required by a bound in `require_send` - --> $DIR/issue-68112.rs:25:25 - | -LL | fn require_send(_: impl Send) {} - | ^^^^ required by this bound in `require_send` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/generator/issue-68112.drop_tracking_mir.stderr b/tests/ui/generator/issue-68112.drop_tracking_mir.stderr deleted file mode 100644 index a83522b714d..00000000000 --- a/tests/ui/generator/issue-68112.drop_tracking_mir.stderr +++ /dev/null @@ -1,61 +0,0 @@ -error: generator cannot be sent between threads safely - --> $DIR/issue-68112.rs:43:5 - | -LL | require_send(send_gen); - | ^^^^^^^^^^^^ generator is not `Send` - | - = help: the trait `Sync` is not implemented for `RefCell` - = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead -note: generator is not `Send` as this value is used across a yield - --> $DIR/issue-68112.rs:39:9 - | -LL | let _non_send_gen = make_non_send_generator(); - | ------------- has type `impl Generator>>` which is not `Send` -LL | -LL | yield; - | ^^^^^ yield occurs here, with `_non_send_gen` maybe used later -note: required by a bound in `require_send` - --> $DIR/issue-68112.rs:25:25 - | -LL | fn require_send(_: impl Send) {} - | ^^^^ required by this bound in `require_send` - -error[E0277]: `RefCell` cannot be shared between threads safely - --> $DIR/issue-68112.rs:67:5 - | -LL | require_send(send_gen); - | ^^^^^^^^^^^^ `RefCell` cannot be shared between threads safely - | - = help: the trait `Sync` is not implemented for `RefCell` - = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead - = note: required for `Arc>` to implement `Send` -note: required because it's used within this generator - --> $DIR/issue-68112.rs:52:5 - | -LL | || { - | ^^ -note: required because it appears within the type `impl Generator>>` - --> $DIR/issue-68112.rs:49:30 - | -LL | pub fn make_gen2(t: T) -> impl Generator { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: required because it appears within the type `impl Generator>>` - --> $DIR/issue-68112.rs:57:34 - | -LL | fn make_non_send_generator2() -> impl Generator>> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: required because it captures the following types: `impl Generator>>` -note: required because it's used within this generator - --> $DIR/issue-68112.rs:63:20 - | -LL | let send_gen = || { - | ^^ -note: required by a bound in `require_send` - --> $DIR/issue-68112.rs:25:25 - | -LL | fn require_send(_: impl Send) {} - | ^^^^ required by this bound in `require_send` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/generator/issue-68112.rs b/tests/ui/generator/issue-68112.rs index 48b53b7693d..9def544e3d2 100644 --- a/tests/ui/generator/issue-68112.rs +++ b/tests/ui/generator/issue-68112.rs @@ -1,6 +1,3 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir #![feature(generators, generator_trait)] use std::{ @@ -11,7 +8,7 @@ use std::{ }; pub struct Ready(Option); -impl Generator<()> for Ready { +impl Generator<()> for Ready { type Return = T; type Yield = (); fn resume(mut self: Pin<&mut Self>, _args: ()) -> GeneratorState<(), T> { @@ -39,7 +36,7 @@ fn test1() { yield; //~^ NOTE yield occurs here //~| NOTE value is used across a yield - }; //[no_drop_tracking,drop_tracking]~ NOTE later dropped here + }; //~ NOTE later dropped here require_send(send_gen); //~^ ERROR generator cannot be sent between threads //~| NOTE not `Send` @@ -68,7 +65,7 @@ fn test2() { //~^ ERROR `RefCell` cannot be shared between threads safely //~| NOTE `RefCell` cannot be shared between threads safely //~| NOTE required for - //[no_drop_tracking,drop_tracking]~| NOTE required by a bound introduced by this call + //~| NOTE required by a bound introduced by this call //~| NOTE captures the following types //~| NOTE use `std::sync::RwLock` instead } diff --git a/tests/ui/generator/issue-68112.no_drop_tracking.stderr b/tests/ui/generator/issue-68112.stderr similarity index 89% rename from tests/ui/generator/issue-68112.no_drop_tracking.stderr rename to tests/ui/generator/issue-68112.stderr index 282eac1b686..b42bc93d01f 100644 --- a/tests/ui/generator/issue-68112.no_drop_tracking.stderr +++ b/tests/ui/generator/issue-68112.stderr @@ -1,5 +1,5 @@ error: generator cannot be sent between threads safely - --> $DIR/issue-68112.rs:43:18 + --> $DIR/issue-68112.rs:40:18 | LL | require_send(send_gen); | ^^^^^^^^ generator is not `Send` @@ -7,7 +7,7 @@ LL | require_send(send_gen); = help: the trait `Sync` is not implemented for `RefCell` = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead note: generator is not `Send` as this value is used across a yield - --> $DIR/issue-68112.rs:39:9 + --> $DIR/issue-68112.rs:36:9 | LL | let _non_send_gen = make_non_send_generator(); | ------------- has type `impl Generator>>` which is not `Send` @@ -18,13 +18,13 @@ LL | yield; LL | }; | - `_non_send_gen` is later dropped here note: required by a bound in `require_send` - --> $DIR/issue-68112.rs:25:25 + --> $DIR/issue-68112.rs:22:25 | LL | fn require_send(_: impl Send) {} | ^^^^ required by this bound in `require_send` error[E0277]: `RefCell` cannot be shared between threads safely - --> $DIR/issue-68112.rs:67:18 + --> $DIR/issue-68112.rs:64:18 | LL | require_send(send_gen); | ------------ ^^^^^^^^ `RefCell` cannot be shared between threads safely @@ -35,28 +35,28 @@ LL | require_send(send_gen); = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead = note: required for `Arc>` to implement `Send` note: required because it's used within this generator - --> $DIR/issue-68112.rs:52:5 + --> $DIR/issue-68112.rs:49:5 | LL | || { | ^^ note: required because it appears within the type `impl Generator>>` - --> $DIR/issue-68112.rs:49:30 + --> $DIR/issue-68112.rs:46:30 | LL | pub fn make_gen2(t: T) -> impl Generator { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ note: required because it appears within the type `impl Generator>>` - --> $DIR/issue-68112.rs:57:34 + --> $DIR/issue-68112.rs:54:34 | LL | fn make_non_send_generator2() -> impl Generator>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: required because it captures the following types: `impl Generator>>`, `()` note: required because it's used within this generator - --> $DIR/issue-68112.rs:63:20 + --> $DIR/issue-68112.rs:60:20 | LL | let send_gen = || { | ^^ note: required by a bound in `require_send` - --> $DIR/issue-68112.rs:25:25 + --> $DIR/issue-68112.rs:22:25 | LL | fn require_send(_: impl Send) {} | ^^^^ required by this bound in `require_send` diff --git a/tests/ui/generator/issue-93161.rs b/tests/ui/generator/issue-93161.rs index 8d3f7c62f39..92305609c83 100644 --- a/tests/ui/generator/issue-93161.rs +++ b/tests/ui/generator/issue-93161.rs @@ -1,8 +1,6 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir // edition:2021 // run-pass +// compile-flags: -Zdrop-tracking #![feature(never_type)] diff --git a/tests/ui/generator/not-send-sync.drop_tracking.stderr b/tests/ui/generator/not-send-sync.drop_tracking.stderr deleted file mode 100644 index 53f62dc4ea2..00000000000 --- a/tests/ui/generator/not-send-sync.drop_tracking.stderr +++ /dev/null @@ -1,60 +0,0 @@ -error: generator cannot be shared between threads safely - --> $DIR/not-send-sync.rs:17:17 - | -LL | assert_sync(|| { - | _________________^ -LL | | -LL | | let a = NotSync; -LL | | yield; -LL | | drop(a); -LL | | }); - | |_____^ generator is not `Sync` - | - = help: within `{generator@$DIR/not-send-sync.rs:17:17: 17:19}`, the trait `Sync` is not implemented for `NotSync` -note: generator is not `Sync` as this value is used across a yield - --> $DIR/not-send-sync.rs:20:9 - | -LL | let a = NotSync; - | - has type `NotSync` which is not `Sync` -LL | yield; - | ^^^^^ yield occurs here, with `a` maybe used later -LL | drop(a); -LL | }); - | - `a` is later dropped here -note: required by a bound in `assert_sync` - --> $DIR/not-send-sync.rs:14:23 - | -LL | fn assert_sync(_: T) {} - | ^^^^ required by this bound in `assert_sync` - -error: generator cannot be sent between threads safely - --> $DIR/not-send-sync.rs:24:17 - | -LL | assert_send(|| { - | _________________^ -LL | | -LL | | let a = NotSend; -LL | | yield; -LL | | drop(a); -LL | | }); - | |_____^ generator is not `Send` - | - = help: within `{generator@$DIR/not-send-sync.rs:24:17: 24:19}`, the trait `Send` is not implemented for `NotSend` -note: generator is not `Send` as this value is used across a yield - --> $DIR/not-send-sync.rs:27:9 - | -LL | let a = NotSend; - | - has type `NotSend` which is not `Send` -LL | yield; - | ^^^^^ yield occurs here, with `a` maybe used later -LL | drop(a); -LL | }); - | - `a` is later dropped here -note: required by a bound in `assert_send` - --> $DIR/not-send-sync.rs:15:23 - | -LL | fn assert_send(_: T) {} - | ^^^^ required by this bound in `assert_send` - -error: aborting due to 2 previous errors - diff --git a/tests/ui/generator/not-send-sync.drop_tracking_mir.stderr b/tests/ui/generator/not-send-sync.drop_tracking_mir.stderr deleted file mode 100644 index 2438e7846b1..00000000000 --- a/tests/ui/generator/not-send-sync.drop_tracking_mir.stderr +++ /dev/null @@ -1,42 +0,0 @@ -error: generator cannot be shared between threads safely - --> $DIR/not-send-sync.rs:17:5 - | -LL | assert_sync(|| { - | ^^^^^^^^^^^ generator is not `Sync` - | - = help: within `{generator@$DIR/not-send-sync.rs:17:17: 17:19}`, the trait `Sync` is not implemented for `NotSync` -note: generator is not `Sync` as this value is used across a yield - --> $DIR/not-send-sync.rs:20:9 - | -LL | let a = NotSync; - | - has type `NotSync` which is not `Sync` -LL | yield; - | ^^^^^ yield occurs here, with `a` maybe used later -note: required by a bound in `assert_sync` - --> $DIR/not-send-sync.rs:14:23 - | -LL | fn assert_sync(_: T) {} - | ^^^^ required by this bound in `assert_sync` - -error: generator cannot be sent between threads safely - --> $DIR/not-send-sync.rs:24:5 - | -LL | assert_send(|| { - | ^^^^^^^^^^^ generator is not `Send` - | - = help: within `{generator@$DIR/not-send-sync.rs:24:17: 24:19}`, the trait `Send` is not implemented for `NotSend` -note: generator is not `Send` as this value is used across a yield - --> $DIR/not-send-sync.rs:27:9 - | -LL | let a = NotSend; - | - has type `NotSend` which is not `Send` -LL | yield; - | ^^^^^ yield occurs here, with `a` maybe used later -note: required by a bound in `assert_send` - --> $DIR/not-send-sync.rs:15:23 - | -LL | fn assert_send(_: T) {} - | ^^^^ required by this bound in `assert_send` - -error: aborting due to 2 previous errors - diff --git a/tests/ui/generator/not-send-sync.no_drop_tracking.stderr b/tests/ui/generator/not-send-sync.no_drop_tracking.stderr deleted file mode 100644 index 53f62dc4ea2..00000000000 --- a/tests/ui/generator/not-send-sync.no_drop_tracking.stderr +++ /dev/null @@ -1,60 +0,0 @@ -error: generator cannot be shared between threads safely - --> $DIR/not-send-sync.rs:17:17 - | -LL | assert_sync(|| { - | _________________^ -LL | | -LL | | let a = NotSync; -LL | | yield; -LL | | drop(a); -LL | | }); - | |_____^ generator is not `Sync` - | - = help: within `{generator@$DIR/not-send-sync.rs:17:17: 17:19}`, the trait `Sync` is not implemented for `NotSync` -note: generator is not `Sync` as this value is used across a yield - --> $DIR/not-send-sync.rs:20:9 - | -LL | let a = NotSync; - | - has type `NotSync` which is not `Sync` -LL | yield; - | ^^^^^ yield occurs here, with `a` maybe used later -LL | drop(a); -LL | }); - | - `a` is later dropped here -note: required by a bound in `assert_sync` - --> $DIR/not-send-sync.rs:14:23 - | -LL | fn assert_sync(_: T) {} - | ^^^^ required by this bound in `assert_sync` - -error: generator cannot be sent between threads safely - --> $DIR/not-send-sync.rs:24:17 - | -LL | assert_send(|| { - | _________________^ -LL | | -LL | | let a = NotSend; -LL | | yield; -LL | | drop(a); -LL | | }); - | |_____^ generator is not `Send` - | - = help: within `{generator@$DIR/not-send-sync.rs:24:17: 24:19}`, the trait `Send` is not implemented for `NotSend` -note: generator is not `Send` as this value is used across a yield - --> $DIR/not-send-sync.rs:27:9 - | -LL | let a = NotSend; - | - has type `NotSend` which is not `Send` -LL | yield; - | ^^^^^ yield occurs here, with `a` maybe used later -LL | drop(a); -LL | }); - | - `a` is later dropped here -note: required by a bound in `assert_send` - --> $DIR/not-send-sync.rs:15:23 - | -LL | fn assert_send(_: T) {} - | ^^^^ required by this bound in `assert_send` - -error: aborting due to 2 previous errors - diff --git a/tests/ui/generator/not-send-sync.rs b/tests/ui/generator/not-send-sync.rs index 8794db452b4..8ca5565fb2a 100644 --- a/tests/ui/generator/not-send-sync.rs +++ b/tests/ui/generator/not-send-sync.rs @@ -1,14 +1,6 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir #![feature(generators)] -#![feature(negative_impls)] -struct NotSend; -struct NotSync; - -impl !Send for NotSend {} -impl !Sync for NotSync {} +use std::cell::Cell; fn main() { fn assert_sync(_: T) {} @@ -16,15 +8,14 @@ fn main() { assert_sync(|| { //~^ ERROR: generator cannot be shared between threads safely - let a = NotSync; + let a = Cell::new(2); yield; - drop(a); }); + let a = Cell::new(2); assert_send(|| { - //~^ ERROR: generator cannot be sent between threads safely - let a = NotSend; + //~^ ERROR: E0277 + drop(&a); yield; - drop(a); }); } diff --git a/tests/ui/generator/not-send-sync.stderr b/tests/ui/generator/not-send-sync.stderr new file mode 100644 index 00000000000..6e0269026b5 --- /dev/null +++ b/tests/ui/generator/not-send-sync.stderr @@ -0,0 +1,58 @@ +error[E0277]: `Cell` cannot be shared between threads safely + --> $DIR/not-send-sync.rs:16:17 + | +LL | assert_send(|| { + | _____-----------_^ + | | | + | | required by a bound introduced by this call +LL | | +LL | | drop(&a); +LL | | yield; +LL | | }); + | |_____^ `Cell` cannot be shared between threads safely + | + = help: the trait `Sync` is not implemented for `Cell` + = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` or `std::sync::atomic::AtomicI32` instead + = note: required for `&Cell` to implement `Send` +note: required because it's used within this generator + --> $DIR/not-send-sync.rs:16:17 + | +LL | assert_send(|| { + | ^^ +note: required by a bound in `assert_send` + --> $DIR/not-send-sync.rs:7:23 + | +LL | fn assert_send(_: T) {} + | ^^^^ required by this bound in `assert_send` + +error: generator cannot be shared between threads safely + --> $DIR/not-send-sync.rs:9:17 + | +LL | assert_sync(|| { + | _________________^ +LL | | +LL | | let a = Cell::new(2); +LL | | yield; +LL | | }); + | |_____^ generator is not `Sync` + | + = help: within `{generator@$DIR/not-send-sync.rs:9:17: 9:19}`, the trait `Sync` is not implemented for `Cell` + = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` or `std::sync::atomic::AtomicI32` instead +note: generator is not `Sync` as this value is used across a yield + --> $DIR/not-send-sync.rs:12:9 + | +LL | let a = Cell::new(2); + | - has type `Cell` which is not `Sync` +LL | yield; + | ^^^^^ yield occurs here, with `a` maybe used later +LL | }); + | - `a` is later dropped here +note: required by a bound in `assert_sync` + --> $DIR/not-send-sync.rs:6:23 + | +LL | fn assert_sync(_: T) {} + | ^^^^ required by this bound in `assert_sync` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/generator/parent-expression.drop_tracking_mir.stderr b/tests/ui/generator/parent-expression.drop_tracking_mir.stderr deleted file mode 100644 index 11bfb9902b0..00000000000 --- a/tests/ui/generator/parent-expression.drop_tracking_mir.stderr +++ /dev/null @@ -1,122 +0,0 @@ -error: generator cannot be sent between threads safely - --> $DIR/parent-expression.rs:27:13 - | -LL | assert_send(g); - | ^^^^^^^^^^^ generator is not `Send` -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation - | - = help: within `{generator@$DIR/parent-expression.rs:21:21: 21:28}`, the trait `Send` is not implemented for `derived_drop::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/parent-expression.rs:25:22 - | -LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { - | ------------------------ has type `derived_drop::Client` which is not `Send` -... -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/parent-expression.rs:49:19 - | -LL | fn assert_send(_thing: T) {} - | ^^^^ required by this bound in `assert_send` - = note: this error originates in the macro `type_combinations` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: generator cannot be sent between threads safely - --> $DIR/parent-expression.rs:27:13 - | -LL | assert_send(g); - | ^^^^^^^^^^^ generator is not `Send` -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation - | - = help: within `{generator@$DIR/parent-expression.rs:21:21: 21:28}`, the trait `Send` is not implemented for `significant_drop::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/parent-expression.rs:25:22 - | -LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { - | ------------------------ has type `significant_drop::Client` which is not `Send` -... -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/parent-expression.rs:49:19 - | -LL | fn assert_send(_thing: T) {} - | ^^^^ required by this bound in `assert_send` - = note: this error originates in the macro `type_combinations` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: generator cannot be sent between threads safely - --> $DIR/parent-expression.rs:27:13 - | -LL | assert_send(g); - | ^^^^^^^^^^^ generator is not `Send` -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation - | - = help: within `{generator@$DIR/parent-expression.rs:21:21: 21:28}`, the trait `Send` is not implemented for `insignificant_dtor::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/parent-expression.rs:25:22 - | -LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { - | ------------------------ has type `insignificant_dtor::Client` which is not `Send` -... -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/parent-expression.rs:49:19 - | -LL | fn assert_send(_thing: T) {} - | ^^^^ required by this bound in `assert_send` - = note: this error originates in the macro `type_combinations` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: aborting due to 3 previous errors - diff --git a/tests/ui/generator/parent-expression.no_drop_tracking.stderr b/tests/ui/generator/parent-expression.no_drop_tracking.stderr deleted file mode 100644 index 5750d2d0afd..00000000000 --- a/tests/ui/generator/parent-expression.no_drop_tracking.stderr +++ /dev/null @@ -1,334 +0,0 @@ -error: generator cannot be sent between threads safely - --> $DIR/parent-expression.rs:27:25 - | -LL | assert_send(g); - | ^ generator is not `Send` -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation - | - = help: within `{generator@$DIR/parent-expression.rs:21:21: 21:28}`, the trait `Send` is not implemented for `copy::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/parent-expression.rs:25:22 - | -LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { - | ------------------------ has type `copy::Client` which is not `Send` -... -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -LL | }; - | - `$name::Client::default()` is later dropped here -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/parent-expression.rs:49:19 - | -LL | fn assert_send(_thing: T) {} - | ^^^^ required by this bound in `assert_send` - = note: this error originates in the macro `type_combinations` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: generator cannot be sent between threads safely - --> $DIR/parent-expression.rs:40:25 - | -LL | assert_send(g); - | ^ generator is not `Send` -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation - | - = help: within `{generator@$DIR/parent-expression.rs:37:21: 37:28}`, the trait `Send` is not implemented for `copy::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/parent-expression.rs:38:22 - | -LL | let g = move || match drop($name::Client::default()) { - | ------------------------ has type `copy::Client` which is not `Send` -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -LL | }; - | - `$name::Client::default()` is later dropped here -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/parent-expression.rs:49:19 - | -LL | fn assert_send(_thing: T) {} - | ^^^^ required by this bound in `assert_send` - = note: this error originates in the macro `type_combinations` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: generator cannot be sent between threads safely - --> $DIR/parent-expression.rs:27:25 - | -LL | assert_send(g); - | ^ generator is not `Send` -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation - | - = help: within `{generator@$DIR/parent-expression.rs:21:21: 21:28}`, the trait `Send` is not implemented for `derived_drop::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/parent-expression.rs:25:22 - | -LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { - | ------------------------ has type `derived_drop::Client` which is not `Send` -... -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -LL | }; - | - `$name::Client::default()` is later dropped here -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/parent-expression.rs:49:19 - | -LL | fn assert_send(_thing: T) {} - | ^^^^ required by this bound in `assert_send` - = note: this error originates in the macro `type_combinations` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: generator cannot be sent between threads safely - --> $DIR/parent-expression.rs:40:25 - | -LL | assert_send(g); - | ^ generator is not `Send` -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation - | - = help: within `{generator@$DIR/parent-expression.rs:37:21: 37:28}`, the trait `Send` is not implemented for `derived_drop::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/parent-expression.rs:38:22 - | -LL | let g = move || match drop($name::Client::default()) { - | ------------------------ has type `derived_drop::Client` which is not `Send` -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -LL | }; - | - `$name::Client::default()` is later dropped here -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/parent-expression.rs:49:19 - | -LL | fn assert_send(_thing: T) {} - | ^^^^ required by this bound in `assert_send` - = note: this error originates in the macro `type_combinations` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: generator cannot be sent between threads safely - --> $DIR/parent-expression.rs:27:25 - | -LL | assert_send(g); - | ^ generator is not `Send` -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation - | - = help: within `{generator@$DIR/parent-expression.rs:21:21: 21:28}`, the trait `Send` is not implemented for `significant_drop::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/parent-expression.rs:25:22 - | -LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { - | ------------------------ has type `significant_drop::Client` which is not `Send` -... -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -LL | }; - | - `$name::Client::default()` is later dropped here -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/parent-expression.rs:49:19 - | -LL | fn assert_send(_thing: T) {} - | ^^^^ required by this bound in `assert_send` - = note: this error originates in the macro `type_combinations` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: generator cannot be sent between threads safely - --> $DIR/parent-expression.rs:40:25 - | -LL | assert_send(g); - | ^ generator is not `Send` -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation - | - = help: within `{generator@$DIR/parent-expression.rs:37:21: 37:28}`, the trait `Send` is not implemented for `significant_drop::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/parent-expression.rs:38:22 - | -LL | let g = move || match drop($name::Client::default()) { - | ------------------------ has type `significant_drop::Client` which is not `Send` -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -LL | }; - | - `$name::Client::default()` is later dropped here -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/parent-expression.rs:49:19 - | -LL | fn assert_send(_thing: T) {} - | ^^^^ required by this bound in `assert_send` - = note: this error originates in the macro `type_combinations` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: generator cannot be sent between threads safely - --> $DIR/parent-expression.rs:27:25 - | -LL | assert_send(g); - | ^ generator is not `Send` -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation - | - = help: within `{generator@$DIR/parent-expression.rs:21:21: 21:28}`, the trait `Send` is not implemented for `insignificant_dtor::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/parent-expression.rs:25:22 - | -LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { - | ------------------------ has type `insignificant_dtor::Client` which is not `Send` -... -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -LL | }; - | - `$name::Client::default()` is later dropped here -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/parent-expression.rs:49:19 - | -LL | fn assert_send(_thing: T) {} - | ^^^^ required by this bound in `assert_send` - = note: this error originates in the macro `type_combinations` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: generator cannot be sent between threads safely - --> $DIR/parent-expression.rs:40:25 - | -LL | assert_send(g); - | ^ generator is not `Send` -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation - | - = help: within `{generator@$DIR/parent-expression.rs:37:21: 37:28}`, the trait `Send` is not implemented for `insignificant_dtor::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/parent-expression.rs:38:22 - | -LL | let g = move || match drop($name::Client::default()) { - | ------------------------ has type `insignificant_dtor::Client` which is not `Send` -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -LL | }; - | - `$name::Client::default()` is later dropped here -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/parent-expression.rs:49:19 - | -LL | fn assert_send(_thing: T) {} - | ^^^^ required by this bound in `assert_send` - = note: this error originates in the macro `type_combinations` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: aborting due to 8 previous errors - diff --git a/tests/ui/generator/parent-expression.rs b/tests/ui/generator/parent-expression.rs index 239034e3d4e..47a179c14ad 100644 --- a/tests/ui/generator/parent-expression.rs +++ b/tests/ui/generator/parent-expression.rs @@ -1,6 +1,4 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir +// compile-flags: -Zdrop-tracking #![feature(generators, negative_impls, rustc_attrs)] @@ -28,7 +26,6 @@ macro_rules! type_combinations { //~^ ERROR cannot be sent between threads //~| ERROR cannot be sent between threads //~| ERROR cannot be sent between threads - //[no_drop_tracking]~^^^^ ERROR cannot be sent between threads } // Simple owned value. This works because the Client is considered moved into `drop`, @@ -38,10 +35,6 @@ macro_rules! type_combinations { _ => yield, }; assert_send(g); - //[no_drop_tracking]~^ ERROR cannot be sent between threads - //[no_drop_tracking]~| ERROR cannot be sent between threads - //[no_drop_tracking]~| ERROR cannot be sent between threads - //[no_drop_tracking]~| ERROR cannot be sent between threads } )* } } diff --git a/tests/ui/generator/parent-expression.drop_tracking.stderr b/tests/ui/generator/parent-expression.stderr similarity index 87% rename from tests/ui/generator/parent-expression.drop_tracking.stderr rename to tests/ui/generator/parent-expression.stderr index f55c8d58fd0..5fb54abeb2d 100644 --- a/tests/ui/generator/parent-expression.drop_tracking.stderr +++ b/tests/ui/generator/parent-expression.stderr @@ -1,5 +1,5 @@ error: generator cannot be sent between threads safely - --> $DIR/parent-expression.rs:27:25 + --> $DIR/parent-expression.rs:25:25 | LL | assert_send(g); | ^ generator is not `Send` @@ -13,9 +13,9 @@ LL | | }; LL | | ); | |_____- in this macro invocation | - = help: within `{generator@$DIR/parent-expression.rs:21:21: 21:28}`, the trait `Send` is not implemented for `derived_drop::Client` + = help: within `{generator@$DIR/parent-expression.rs:19:21: 19:28}`, the trait `Send` is not implemented for `derived_drop::Client` note: generator is not `Send` as this value is used across a yield - --> $DIR/parent-expression.rs:25:22 + --> $DIR/parent-expression.rs:23:22 | LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { | ------------------------ has type `derived_drop::Client` which is not `Send` @@ -34,14 +34,14 @@ LL | | }; LL | | ); | |_____- in this macro invocation note: required by a bound in `assert_send` - --> $DIR/parent-expression.rs:49:19 + --> $DIR/parent-expression.rs:42:19 | LL | fn assert_send(_thing: T) {} | ^^^^ required by this bound in `assert_send` = note: this error originates in the macro `type_combinations` (in Nightly builds, run with -Z macro-backtrace for more info) error: generator cannot be sent between threads safely - --> $DIR/parent-expression.rs:27:25 + --> $DIR/parent-expression.rs:25:25 | LL | assert_send(g); | ^ generator is not `Send` @@ -55,9 +55,9 @@ LL | | }; LL | | ); | |_____- in this macro invocation | - = help: within `{generator@$DIR/parent-expression.rs:21:21: 21:28}`, the trait `Send` is not implemented for `significant_drop::Client` + = help: within `{generator@$DIR/parent-expression.rs:19:21: 19:28}`, the trait `Send` is not implemented for `significant_drop::Client` note: generator is not `Send` as this value is used across a yield - --> $DIR/parent-expression.rs:25:22 + --> $DIR/parent-expression.rs:23:22 | LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { | ------------------------ has type `significant_drop::Client` which is not `Send` @@ -76,14 +76,14 @@ LL | | }; LL | | ); | |_____- in this macro invocation note: required by a bound in `assert_send` - --> $DIR/parent-expression.rs:49:19 + --> $DIR/parent-expression.rs:42:19 | LL | fn assert_send(_thing: T) {} | ^^^^ required by this bound in `assert_send` = note: this error originates in the macro `type_combinations` (in Nightly builds, run with -Z macro-backtrace for more info) error: generator cannot be sent between threads safely - --> $DIR/parent-expression.rs:27:25 + --> $DIR/parent-expression.rs:25:25 | LL | assert_send(g); | ^ generator is not `Send` @@ -97,9 +97,9 @@ LL | | }; LL | | ); | |_____- in this macro invocation | - = help: within `{generator@$DIR/parent-expression.rs:21:21: 21:28}`, the trait `Send` is not implemented for `insignificant_dtor::Client` + = help: within `{generator@$DIR/parent-expression.rs:19:21: 19:28}`, the trait `Send` is not implemented for `insignificant_dtor::Client` note: generator is not `Send` as this value is used across a yield - --> $DIR/parent-expression.rs:25:22 + --> $DIR/parent-expression.rs:23:22 | LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { | ------------------------ has type `insignificant_dtor::Client` which is not `Send` @@ -118,7 +118,7 @@ LL | | }; LL | | ); | |_____- in this macro invocation note: required by a bound in `assert_send` - --> $DIR/parent-expression.rs:49:19 + --> $DIR/parent-expression.rs:42:19 | LL | fn assert_send(_thing: T) {} | ^^^^ required by this bound in `assert_send` diff --git a/tests/ui/generator/partial-drop.no_drop_tracking.stderr b/tests/ui/generator/partial-drop.no_drop_tracking.stderr deleted file mode 100644 index 34b7101825f..00000000000 --- a/tests/ui/generator/partial-drop.no_drop_tracking.stderr +++ /dev/null @@ -1,61 +0,0 @@ -error: generator cannot be sent between threads safely - --> $DIR/partial-drop.rs:17:17 - | -LL | assert_send(|| { - | _________________^ -LL | | -LL | | let guard = Bar { foo: Foo, x: 42 }; -LL | | drop(guard.foo); -LL | | yield; -LL | | }); - | |_____^ generator is not `Send` - | - = help: within `{generator@$DIR/partial-drop.rs:17:17: 17:19}`, the trait `Send` is not implemented for `Foo` -note: generator is not `Send` as this value is used across a yield - --> $DIR/partial-drop.rs:21:9 - | -LL | let guard = Bar { foo: Foo, x: 42 }; - | ----- has type `Bar` which is not `Send` -LL | drop(guard.foo); -LL | yield; - | ^^^^^ yield occurs here, with `guard` maybe used later -LL | }); - | - `guard` is later dropped here -note: required by a bound in `assert_send` - --> $DIR/partial-drop.rs:33:19 - | -LL | fn assert_send(_: T) {} - | ^^^^ required by this bound in `assert_send` - -error: generator cannot be sent between threads safely - --> $DIR/partial-drop.rs:24:17 - | -LL | assert_send(|| { - | _________________^ -LL | | -LL | | let guard = Bar { foo: Foo, x: 42 }; -LL | | let Bar { foo, x } = guard; -LL | | drop(foo); -LL | | yield; -LL | | }); - | |_____^ generator is not `Send` - | - = help: within `{generator@$DIR/partial-drop.rs:24:17: 24:19}`, the trait `Send` is not implemented for `Foo` -note: generator is not `Send` as this value is used across a yield - --> $DIR/partial-drop.rs:29:9 - | -LL | let Bar { foo, x } = guard; - | --- has type `Foo` which is not `Send` -LL | drop(foo); -LL | yield; - | ^^^^^ yield occurs here, with `foo` maybe used later -LL | }); - | - `foo` is later dropped here -note: required by a bound in `assert_send` - --> $DIR/partial-drop.rs:33:19 - | -LL | fn assert_send(_: T) {} - | ^^^^ required by this bound in `assert_send` - -error: aborting due to 2 previous errors - diff --git a/tests/ui/generator/partial-drop.rs b/tests/ui/generator/partial-drop.rs index 1d3ae075d43..c872fb7f3e6 100644 --- a/tests/ui/generator/partial-drop.rs +++ b/tests/ui/generator/partial-drop.rs @@ -1,7 +1,4 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir -// [drop_tracking_mir] check-pass +// compile-flags: -Zdrop-tracking #![feature(negative_impls, generators)] @@ -15,14 +12,26 @@ struct Bar { fn main() { assert_send(|| { - //[no_drop_tracking,drop_tracking]~^ ERROR generator cannot be sent between threads safely + //~^ ERROR generator cannot be sent between threads safely + // FIXME: it would be nice to make this work. let guard = Bar { foo: Foo, x: 42 }; drop(guard.foo); yield; }); assert_send(|| { - //[no_drop_tracking,drop_tracking]~^ ERROR generator cannot be sent between threads safely + //~^ ERROR generator cannot be sent between threads safely + // FIXME: it would be nice to make this work. + let guard = Bar { foo: Foo, x: 42 }; + drop(guard); + guard.foo = Foo; + guard.x = 23; + yield; + }); + + assert_send(|| { + //~^ ERROR generator cannot be sent between threads safely + // FIXME: it would be nice to make this work. let guard = Bar { foo: Foo, x: 42 }; let Bar { foo, x } = guard; drop(foo); diff --git a/tests/ui/generator/partial-drop.drop_tracking.stderr b/tests/ui/generator/partial-drop.stderr similarity index 52% rename from tests/ui/generator/partial-drop.drop_tracking.stderr rename to tests/ui/generator/partial-drop.stderr index b3de7853361..f374b549df3 100644 --- a/tests/ui/generator/partial-drop.drop_tracking.stderr +++ b/tests/ui/generator/partial-drop.stderr @@ -1,18 +1,19 @@ error: generator cannot be sent between threads safely - --> $DIR/partial-drop.rs:17:17 + --> $DIR/partial-drop.rs:14:17 | LL | assert_send(|| { | _________________^ LL | | +LL | | // FIXME: it would be nice to make this work. LL | | let guard = Bar { foo: Foo, x: 42 }; LL | | drop(guard.foo); LL | | yield; LL | | }); | |_____^ generator is not `Send` | - = help: within `{generator@$DIR/partial-drop.rs:17:17: 17:19}`, the trait `Send` is not implemented for `Foo` + = help: within `{generator@$DIR/partial-drop.rs:14:17: 14:19}`, the trait `Send` is not implemented for `Foo` note: generator is not `Send` as this value is used across a yield - --> $DIR/partial-drop.rs:21:9 + --> $DIR/partial-drop.rs:19:9 | LL | let guard = Bar { foo: Foo, x: 42 }; | ----- has type `Bar` which is not `Send` @@ -22,25 +23,25 @@ LL | yield; LL | }); | - `guard` is later dropped here note: required by a bound in `assert_send` - --> $DIR/partial-drop.rs:33:19 + --> $DIR/partial-drop.rs:42:19 | LL | fn assert_send(_: T) {} | ^^^^ required by this bound in `assert_send` error: generator cannot be sent between threads safely - --> $DIR/partial-drop.rs:24:17 + --> $DIR/partial-drop.rs:22:17 | LL | assert_send(|| { | _________________^ LL | | +LL | | // FIXME: it would be nice to make this work. LL | | let guard = Bar { foo: Foo, x: 42 }; -LL | | let Bar { foo, x } = guard; -LL | | drop(foo); +... | LL | | yield; LL | | }); | |_____^ generator is not `Send` | - = help: within `{generator@$DIR/partial-drop.rs:24:17: 24:19}`, the trait `Send` is not implemented for `Foo` + = help: within `{generator@$DIR/partial-drop.rs:22:17: 22:19}`, the trait `Send` is not implemented for `Foo` note: generator is not `Send` as this value is used across a yield --> $DIR/partial-drop.rs:29:9 | @@ -52,10 +53,40 @@ LL | yield; LL | }); | - `guard` is later dropped here note: required by a bound in `assert_send` - --> $DIR/partial-drop.rs:33:19 + --> $DIR/partial-drop.rs:42:19 | LL | fn assert_send(_: T) {} | ^^^^ required by this bound in `assert_send` -error: aborting due to 2 previous errors +error: generator cannot be sent between threads safely + --> $DIR/partial-drop.rs:32:17 + | +LL | assert_send(|| { + | _________________^ +LL | | +LL | | // FIXME: it would be nice to make this work. +LL | | let guard = Bar { foo: Foo, x: 42 }; +... | +LL | | yield; +LL | | }); + | |_____^ generator is not `Send` + | + = help: within `{generator@$DIR/partial-drop.rs:32:17: 32:19}`, the trait `Send` is not implemented for `Foo` +note: generator is not `Send` as this value is used across a yield + --> $DIR/partial-drop.rs:38:9 + | +LL | let guard = Bar { foo: Foo, x: 42 }; + | ----- has type `Bar` which is not `Send` +... +LL | yield; + | ^^^^^ yield occurs here, with `guard` maybe used later +LL | }); + | - `guard` is later dropped here +note: required by a bound in `assert_send` + --> $DIR/partial-drop.rs:42:19 + | +LL | fn assert_send(_: T) {} + | ^^^^ required by this bound in `assert_send` + +error: aborting due to 3 previous errors diff --git a/tests/ui/generator/print/generator-print-verbose-1.drop_tracking.stderr b/tests/ui/generator/print/generator-print-verbose-1.drop_tracking.stderr deleted file mode 100644 index 429b202f603..00000000000 --- a/tests/ui/generator/print/generator-print-verbose-1.drop_tracking.stderr +++ /dev/null @@ -1,64 +0,0 @@ -error: generator cannot be sent between threads safely - --> $DIR/generator-print-verbose-1.rs:40:18 - | -LL | require_send(send_gen); - | ^^^^^^^^ generator is not `Send` - | - = help: the trait `Sync` is not implemented for `RefCell` - = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead -note: generator is not `Send` as this value is used across a yield - --> $DIR/generator-print-verbose-1.rs:38:9 - | -LL | let _non_send_gen = make_non_send_generator(); - | ------------- has type `Opaque(DefId(0:34 ~ generator_print_verbose_1[7d1d]::make_non_send_generator::{opaque#0}), [])` which is not `Send` -LL | yield; - | ^^^^^ yield occurs here, with `_non_send_gen` maybe used later -LL | }; - | - `_non_send_gen` is later dropped here -note: required by a bound in `require_send` - --> $DIR/generator-print-verbose-1.rs:29:25 - | -LL | fn require_send(_: impl Send) {} - | ^^^^ required by this bound in `require_send` - -error[E0277]: `RefCell` cannot be shared between threads safely - --> $DIR/generator-print-verbose-1.rs:59:18 - | -LL | require_send(send_gen); - | ------------ ^^^^^^^^ `RefCell` cannot be shared between threads safely - | | - | required by a bound introduced by this call - | - = help: the trait `Sync` is not implemented for `RefCell` - = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead - = note: required for `Arc>` to implement `Send` -note: required because it's used within this generator - --> $DIR/generator-print-verbose-1.rs:45:5 - | -LL | || { - | ^^ -note: required because it appears within the type `Opaque(DefId(0:35 ~ generator_print_verbose_1[7d1d]::make_gen2::{opaque#0}), [Arc>])` - --> $DIR/generator-print-verbose-1.rs:44:30 - | -LL | pub fn make_gen2(t: T) -> impl Generator { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: required because it appears within the type `Opaque(DefId(0:36 ~ generator_print_verbose_1[7d1d]::make_non_send_generator2::{opaque#0}), [])` - --> $DIR/generator-print-verbose-1.rs:50:34 - | -LL | fn make_non_send_generator2() -> impl Generator>> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: required because it captures the following types: `Opaque(DefId(0:36 ~ generator_print_verbose_1[7d1d]::make_non_send_generator2::{opaque#0}), [])`, `()` -note: required because it's used within this generator - --> $DIR/generator-print-verbose-1.rs:55:20 - | -LL | let send_gen = || { - | ^^ -note: required by a bound in `require_send` - --> $DIR/generator-print-verbose-1.rs:29:25 - | -LL | fn require_send(_: impl Send) {} - | ^^^^ required by this bound in `require_send` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/generator/print/generator-print-verbose-1.drop_tracking_mir.stderr b/tests/ui/generator/print/generator-print-verbose-1.drop_tracking_mir.stderr deleted file mode 100644 index 01a30fd2f4e..00000000000 --- a/tests/ui/generator/print/generator-print-verbose-1.drop_tracking_mir.stderr +++ /dev/null @@ -1,60 +0,0 @@ -error: generator cannot be sent between threads safely - --> $DIR/generator-print-verbose-1.rs:40:5 - | -LL | require_send(send_gen); - | ^^^^^^^^^^^^ generator is not `Send` - | - = help: the trait `Sync` is not implemented for `RefCell` - = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead -note: generator is not `Send` as this value is used across a yield - --> $DIR/generator-print-verbose-1.rs:38:9 - | -LL | let _non_send_gen = make_non_send_generator(); - | ------------- has type `Opaque(DefId(0:34 ~ generator_print_verbose_1[7d1d]::make_non_send_generator::{opaque#0}), [])` which is not `Send` -LL | yield; - | ^^^^^ yield occurs here, with `_non_send_gen` maybe used later -note: required by a bound in `require_send` - --> $DIR/generator-print-verbose-1.rs:29:25 - | -LL | fn require_send(_: impl Send) {} - | ^^^^ required by this bound in `require_send` - -error[E0277]: `RefCell` cannot be shared between threads safely - --> $DIR/generator-print-verbose-1.rs:59:5 - | -LL | require_send(send_gen); - | ^^^^^^^^^^^^ `RefCell` cannot be shared between threads safely - | - = help: the trait `Sync` is not implemented for `RefCell` - = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead - = note: required for `Arc>` to implement `Send` -note: required because it's used within this generator - --> $DIR/generator-print-verbose-1.rs:45:5 - | -LL | || { - | ^^ -note: required because it appears within the type `Opaque(DefId(0:35 ~ generator_print_verbose_1[7d1d]::make_gen2::{opaque#0}), [Arc>])` - --> $DIR/generator-print-verbose-1.rs:44:30 - | -LL | pub fn make_gen2(t: T) -> impl Generator { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: required because it appears within the type `Opaque(DefId(0:36 ~ generator_print_verbose_1[7d1d]::make_non_send_generator2::{opaque#0}), [])` - --> $DIR/generator-print-verbose-1.rs:50:34 - | -LL | fn make_non_send_generator2() -> impl Generator>> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: required because it captures the following types: `Opaque(DefId(0:36 ~ generator_print_verbose_1[7d1d]::make_non_send_generator2::{opaque#0}), [])` -note: required because it's used within this generator - --> $DIR/generator-print-verbose-1.rs:55:20 - | -LL | let send_gen = || { - | ^^ -note: required by a bound in `require_send` - --> $DIR/generator-print-verbose-1.rs:29:25 - | -LL | fn require_send(_: impl Send) {} - | ^^^^ required by this bound in `require_send` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/generator/print/generator-print-verbose-1.rs b/tests/ui/generator/print/generator-print-verbose-1.rs index c7052c7d1b0..89124ad7289 100644 --- a/tests/ui/generator/print/generator-print-verbose-1.rs +++ b/tests/ui/generator/print/generator-print-verbose-1.rs @@ -1,6 +1,3 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir // compile-flags: -Zverbose // Same as: tests/ui/generator/issue-68112.stderr @@ -15,7 +12,7 @@ use std::{ }; pub struct Ready(Option); -impl Generator<()> for Ready { +impl Generator<()> for Ready { type Return = T; type Yield = (); fn resume(mut self: Pin<&mut Self>, _args: ()) -> GeneratorState<(), T> { diff --git a/tests/ui/generator/print/generator-print-verbose-1.no_drop_tracking.stderr b/tests/ui/generator/print/generator-print-verbose-1.stderr similarity index 86% rename from tests/ui/generator/print/generator-print-verbose-1.no_drop_tracking.stderr rename to tests/ui/generator/print/generator-print-verbose-1.stderr index 429b202f603..1e409534c75 100644 --- a/tests/ui/generator/print/generator-print-verbose-1.no_drop_tracking.stderr +++ b/tests/ui/generator/print/generator-print-verbose-1.stderr @@ -1,5 +1,5 @@ error: generator cannot be sent between threads safely - --> $DIR/generator-print-verbose-1.rs:40:18 + --> $DIR/generator-print-verbose-1.rs:37:18 | LL | require_send(send_gen); | ^^^^^^^^ generator is not `Send` @@ -7,7 +7,7 @@ LL | require_send(send_gen); = help: the trait `Sync` is not implemented for `RefCell` = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead note: generator is not `Send` as this value is used across a yield - --> $DIR/generator-print-verbose-1.rs:38:9 + --> $DIR/generator-print-verbose-1.rs:35:9 | LL | let _non_send_gen = make_non_send_generator(); | ------------- has type `Opaque(DefId(0:34 ~ generator_print_verbose_1[7d1d]::make_non_send_generator::{opaque#0}), [])` which is not `Send` @@ -16,13 +16,13 @@ LL | yield; LL | }; | - `_non_send_gen` is later dropped here note: required by a bound in `require_send` - --> $DIR/generator-print-verbose-1.rs:29:25 + --> $DIR/generator-print-verbose-1.rs:26:25 | LL | fn require_send(_: impl Send) {} | ^^^^ required by this bound in `require_send` error[E0277]: `RefCell` cannot be shared between threads safely - --> $DIR/generator-print-verbose-1.rs:59:18 + --> $DIR/generator-print-verbose-1.rs:56:18 | LL | require_send(send_gen); | ------------ ^^^^^^^^ `RefCell` cannot be shared between threads safely @@ -33,28 +33,28 @@ LL | require_send(send_gen); = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead = note: required for `Arc>` to implement `Send` note: required because it's used within this generator - --> $DIR/generator-print-verbose-1.rs:45:5 + --> $DIR/generator-print-verbose-1.rs:42:5 | LL | || { | ^^ note: required because it appears within the type `Opaque(DefId(0:35 ~ generator_print_verbose_1[7d1d]::make_gen2::{opaque#0}), [Arc>])` - --> $DIR/generator-print-verbose-1.rs:44:30 + --> $DIR/generator-print-verbose-1.rs:41:30 | LL | pub fn make_gen2(t: T) -> impl Generator { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ note: required because it appears within the type `Opaque(DefId(0:36 ~ generator_print_verbose_1[7d1d]::make_non_send_generator2::{opaque#0}), [])` - --> $DIR/generator-print-verbose-1.rs:50:34 + --> $DIR/generator-print-verbose-1.rs:47:34 | LL | fn make_non_send_generator2() -> impl Generator>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: required because it captures the following types: `Opaque(DefId(0:36 ~ generator_print_verbose_1[7d1d]::make_non_send_generator2::{opaque#0}), [])`, `()` note: required because it's used within this generator - --> $DIR/generator-print-verbose-1.rs:55:20 + --> $DIR/generator-print-verbose-1.rs:52:20 | LL | let send_gen = || { | ^^ note: required by a bound in `require_send` - --> $DIR/generator-print-verbose-1.rs:29:25 + --> $DIR/generator-print-verbose-1.rs:26:25 | LL | fn require_send(_: impl Send) {} | ^^^^ required by this bound in `require_send` diff --git a/tests/ui/generator/print/generator-print-verbose-2.drop_tracking.stderr b/tests/ui/generator/print/generator-print-verbose-2.drop_tracking.stderr deleted file mode 100644 index 53b4cadacd0..00000000000 --- a/tests/ui/generator/print/generator-print-verbose-2.drop_tracking.stderr +++ /dev/null @@ -1,60 +0,0 @@ -error: generator cannot be shared between threads safely - --> $DIR/generator-print-verbose-2.rs:20:17 - | -LL | assert_sync(|| { - | _________________^ -LL | | -LL | | let a = NotSync; -LL | | yield; -LL | | drop(a); -LL | | }); - | |_____^ generator is not `Sync` - | - = help: within `{main::{closure#0} upvar_tys=() {NotSync, ()}}`, the trait `Sync` is not implemented for `NotSync` -note: generator is not `Sync` as this value is used across a yield - --> $DIR/generator-print-verbose-2.rs:23:9 - | -LL | let a = NotSync; - | - has type `NotSync` which is not `Sync` -LL | yield; - | ^^^^^ yield occurs here, with `a` maybe used later -LL | drop(a); -LL | }); - | - `a` is later dropped here -note: required by a bound in `assert_sync` - --> $DIR/generator-print-verbose-2.rs:17:23 - | -LL | fn assert_sync(_: T) {} - | ^^^^ required by this bound in `assert_sync` - -error: generator cannot be sent between threads safely - --> $DIR/generator-print-verbose-2.rs:27:17 - | -LL | assert_send(|| { - | _________________^ -LL | | -LL | | let a = NotSend; -LL | | yield; -LL | | drop(a); -LL | | }); - | |_____^ generator is not `Send` - | - = help: within `{main::{closure#1} upvar_tys=() {NotSend, ()}}`, the trait `Send` is not implemented for `NotSend` -note: generator is not `Send` as this value is used across a yield - --> $DIR/generator-print-verbose-2.rs:30:9 - | -LL | let a = NotSend; - | - has type `NotSend` which is not `Send` -LL | yield; - | ^^^^^ yield occurs here, with `a` maybe used later -LL | drop(a); -LL | }); - | - `a` is later dropped here -note: required by a bound in `assert_send` - --> $DIR/generator-print-verbose-2.rs:18:23 - | -LL | fn assert_send(_: T) {} - | ^^^^ required by this bound in `assert_send` - -error: aborting due to 2 previous errors - diff --git a/tests/ui/generator/print/generator-print-verbose-2.drop_tracking_mir.stderr b/tests/ui/generator/print/generator-print-verbose-2.drop_tracking_mir.stderr deleted file mode 100644 index 937881340c6..00000000000 --- a/tests/ui/generator/print/generator-print-verbose-2.drop_tracking_mir.stderr +++ /dev/null @@ -1,42 +0,0 @@ -error: generator cannot be shared between threads safely - --> $DIR/generator-print-verbose-2.rs:20:5 - | -LL | assert_sync(|| { - | ^^^^^^^^^^^ generator is not `Sync` - | - = help: within `{main::{closure#0} upvar_tys=() {main::{closure#0}}}`, the trait `Sync` is not implemented for `NotSync` -note: generator is not `Sync` as this value is used across a yield - --> $DIR/generator-print-verbose-2.rs:23:9 - | -LL | let a = NotSync; - | - has type `NotSync` which is not `Sync` -LL | yield; - | ^^^^^ yield occurs here, with `a` maybe used later -note: required by a bound in `assert_sync` - --> $DIR/generator-print-verbose-2.rs:17:23 - | -LL | fn assert_sync(_: T) {} - | ^^^^ required by this bound in `assert_sync` - -error: generator cannot be sent between threads safely - --> $DIR/generator-print-verbose-2.rs:27:5 - | -LL | assert_send(|| { - | ^^^^^^^^^^^ generator is not `Send` - | - = help: within `{main::{closure#1} upvar_tys=() {main::{closure#1}}}`, the trait `Send` is not implemented for `NotSend` -note: generator is not `Send` as this value is used across a yield - --> $DIR/generator-print-verbose-2.rs:30:9 - | -LL | let a = NotSend; - | - has type `NotSend` which is not `Send` -LL | yield; - | ^^^^^ yield occurs here, with `a` maybe used later -note: required by a bound in `assert_send` - --> $DIR/generator-print-verbose-2.rs:18:23 - | -LL | fn assert_send(_: T) {} - | ^^^^ required by this bound in `assert_send` - -error: aborting due to 2 previous errors - diff --git a/tests/ui/generator/print/generator-print-verbose-2.no_drop_tracking.stderr b/tests/ui/generator/print/generator-print-verbose-2.no_drop_tracking.stderr deleted file mode 100644 index 53b4cadacd0..00000000000 --- a/tests/ui/generator/print/generator-print-verbose-2.no_drop_tracking.stderr +++ /dev/null @@ -1,60 +0,0 @@ -error: generator cannot be shared between threads safely - --> $DIR/generator-print-verbose-2.rs:20:17 - | -LL | assert_sync(|| { - | _________________^ -LL | | -LL | | let a = NotSync; -LL | | yield; -LL | | drop(a); -LL | | }); - | |_____^ generator is not `Sync` - | - = help: within `{main::{closure#0} upvar_tys=() {NotSync, ()}}`, the trait `Sync` is not implemented for `NotSync` -note: generator is not `Sync` as this value is used across a yield - --> $DIR/generator-print-verbose-2.rs:23:9 - | -LL | let a = NotSync; - | - has type `NotSync` which is not `Sync` -LL | yield; - | ^^^^^ yield occurs here, with `a` maybe used later -LL | drop(a); -LL | }); - | - `a` is later dropped here -note: required by a bound in `assert_sync` - --> $DIR/generator-print-verbose-2.rs:17:23 - | -LL | fn assert_sync(_: T) {} - | ^^^^ required by this bound in `assert_sync` - -error: generator cannot be sent between threads safely - --> $DIR/generator-print-verbose-2.rs:27:17 - | -LL | assert_send(|| { - | _________________^ -LL | | -LL | | let a = NotSend; -LL | | yield; -LL | | drop(a); -LL | | }); - | |_____^ generator is not `Send` - | - = help: within `{main::{closure#1} upvar_tys=() {NotSend, ()}}`, the trait `Send` is not implemented for `NotSend` -note: generator is not `Send` as this value is used across a yield - --> $DIR/generator-print-verbose-2.rs:30:9 - | -LL | let a = NotSend; - | - has type `NotSend` which is not `Send` -LL | yield; - | ^^^^^ yield occurs here, with `a` maybe used later -LL | drop(a); -LL | }); - | - `a` is later dropped here -note: required by a bound in `assert_send` - --> $DIR/generator-print-verbose-2.rs:18:23 - | -LL | fn assert_send(_: T) {} - | ^^^^ required by this bound in `assert_send` - -error: aborting due to 2 previous errors - diff --git a/tests/ui/generator/print/generator-print-verbose-2.rs b/tests/ui/generator/print/generator-print-verbose-2.rs index ab29db6e09c..d914719cb36 100644 --- a/tests/ui/generator/print/generator-print-verbose-2.rs +++ b/tests/ui/generator/print/generator-print-verbose-2.rs @@ -1,17 +1,9 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir // compile-flags: -Zverbose // Same as test/ui/generator/not-send-sync.rs #![feature(generators)] -#![feature(negative_impls)] -struct NotSend; -struct NotSync; - -impl !Send for NotSend {} -impl !Sync for NotSync {} +use std::cell::Cell; fn main() { fn assert_sync(_: T) {} @@ -19,15 +11,14 @@ fn main() { assert_sync(|| { //~^ ERROR: generator cannot be shared between threads safely - let a = NotSync; + let a = Cell::new(2); yield; - drop(a); }); + let a = Cell::new(2); assert_send(|| { - //~^ ERROR: generator cannot be sent between threads safely - let a = NotSend; + //~^ ERROR: E0277 + drop(&a); yield; - drop(a); }); } diff --git a/tests/ui/generator/print/generator-print-verbose-2.stderr b/tests/ui/generator/print/generator-print-verbose-2.stderr new file mode 100644 index 00000000000..4e88e73f1d6 --- /dev/null +++ b/tests/ui/generator/print/generator-print-verbose-2.stderr @@ -0,0 +1,58 @@ +error[E0277]: `Cell` cannot be shared between threads safely + --> $DIR/generator-print-verbose-2.rs:19:17 + | +LL | assert_send(|| { + | _____-----------_^ + | | | + | | required by a bound introduced by this call +LL | | +LL | | drop(&a); +LL | | yield; +LL | | }); + | |_____^ `Cell` cannot be shared between threads safely + | + = help: the trait `Sync` is not implemented for `Cell` + = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` or `std::sync::atomic::AtomicI32` instead + = note: required for `&'?4 Cell` to implement `Send` +note: required because it's used within this generator + --> $DIR/generator-print-verbose-2.rs:19:17 + | +LL | assert_send(|| { + | ^^ +note: required by a bound in `assert_send` + --> $DIR/generator-print-verbose-2.rs:10:23 + | +LL | fn assert_send(_: T) {} + | ^^^^ required by this bound in `assert_send` + +error: generator cannot be shared between threads safely + --> $DIR/generator-print-verbose-2.rs:12:17 + | +LL | assert_sync(|| { + | _________________^ +LL | | +LL | | let a = Cell::new(2); +LL | | yield; +LL | | }); + | |_____^ generator is not `Sync` + | + = help: within `{main::{closure#0} upvar_tys=() {Cell, ()}}`, the trait `Sync` is not implemented for `Cell` + = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` or `std::sync::atomic::AtomicI32` instead +note: generator is not `Sync` as this value is used across a yield + --> $DIR/generator-print-verbose-2.rs:15:9 + | +LL | let a = Cell::new(2); + | - has type `Cell` which is not `Sync` +LL | yield; + | ^^^^^ yield occurs here, with `a` maybe used later +LL | }); + | - `a` is later dropped here +note: required by a bound in `assert_sync` + --> $DIR/generator-print-verbose-2.rs:9:23 + | +LL | fn assert_sync(_: T) {} + | ^^^^ required by this bound in `assert_sync` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/generator/retain-resume-ref.drop_tracking_mir.stderr b/tests/ui/generator/retain-resume-ref.drop_tracking_mir.stderr deleted file mode 100644 index 736ed1fb608..00000000000 --- a/tests/ui/generator/retain-resume-ref.drop_tracking_mir.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0499]: cannot borrow `thing` as mutable more than once at a time - --> $DIR/retain-resume-ref.rs:27:25 - | -LL | gen.as_mut().resume(&mut thing); - | ---------- first mutable borrow occurs here -LL | gen.as_mut().resume(&mut thing); - | ^^^^^^^^^^ second mutable borrow occurs here -LL | -LL | } - | - first borrow might be used here, when `gen` is dropped and runs the destructor for generator - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0499`. diff --git a/tests/ui/generator/retain-resume-ref.no_drop_tracking.stderr b/tests/ui/generator/retain-resume-ref.no_drop_tracking.stderr deleted file mode 100644 index 7122a951e80..00000000000 --- a/tests/ui/generator/retain-resume-ref.no_drop_tracking.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0499]: cannot borrow `thing` as mutable more than once at a time - --> $DIR/retain-resume-ref.rs:27:25 - | -LL | gen.as_mut().resume(&mut thing); - | ---------- first mutable borrow occurs here -LL | gen.as_mut().resume(&mut thing); - | ------ ^^^^^^^^^^ second mutable borrow occurs here - | | - | first borrow later used by call - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0499`. diff --git a/tests/ui/generator/retain-resume-ref.rs b/tests/ui/generator/retain-resume-ref.rs index 0050d98d03b..0606ea71cdf 100644 --- a/tests/ui/generator/retain-resume-ref.rs +++ b/tests/ui/generator/retain-resume-ref.rs @@ -1,7 +1,3 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir - //! This test ensures that a mutable reference cannot be passed as a resume argument twice. #![feature(generators, generator_trait)] diff --git a/tests/ui/generator/retain-resume-ref.drop_tracking.stderr b/tests/ui/generator/retain-resume-ref.stderr similarity index 92% rename from tests/ui/generator/retain-resume-ref.drop_tracking.stderr rename to tests/ui/generator/retain-resume-ref.stderr index 7122a951e80..e33310d12d9 100644 --- a/tests/ui/generator/retain-resume-ref.drop_tracking.stderr +++ b/tests/ui/generator/retain-resume-ref.stderr @@ -1,5 +1,5 @@ error[E0499]: cannot borrow `thing` as mutable more than once at a time - --> $DIR/retain-resume-ref.rs:27:25 + --> $DIR/retain-resume-ref.rs:23:25 | LL | gen.as_mut().resume(&mut thing); | ---------- first mutable borrow occurs here diff --git a/tests/ui/generator/static-mut-reference-across-yield.rs b/tests/ui/generator/static-mut-reference-across-yield.rs index 4784ff49be2..0fa6d9cdc77 100644 --- a/tests/ui/generator/static-mut-reference-across-yield.rs +++ b/tests/ui/generator/static-mut-reference-across-yield.rs @@ -1,8 +1,6 @@ // build-pass -// revisions: mir thir drop_tracking drop_tracking_mir +// revisions: mir thir // [thir]compile-flags: -Zthir-unsafeck -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir #![feature(generators)] diff --git a/tests/ui/generator/unresolved-ct-var-drop-tracking.rs b/tests/ui/generator/unresolved-ct-var-drop-tracking.rs deleted file mode 100644 index a6589348d30..00000000000 --- a/tests/ui/generator/unresolved-ct-var-drop-tracking.rs +++ /dev/null @@ -1,15 +0,0 @@ -// incremental -// edition:2021 -// compile-flags: -Zdrop-tracking - -fn main() { - let _ = async { - let s = std::array::from_fn(|_| ()).await; - //~^ ERROR `[(); _]` is not a future - //~| ERROR type inside `async` block must be known in this context - //~| ERROR type inside `async` block must be known in this context - //~| ERROR type inside `async` block must be known in this context - //~| ERROR type inside `async` block must be known in this context - //~| ERROR type inside `async` block must be known in this context - }; -} diff --git a/tests/ui/generator/unresolved-ct-var-drop-tracking.stderr b/tests/ui/generator/unresolved-ct-var-drop-tracking.stderr deleted file mode 100644 index dec0141ab67..00000000000 --- a/tests/ui/generator/unresolved-ct-var-drop-tracking.stderr +++ /dev/null @@ -1,78 +0,0 @@ -error[E0277]: `[(); _]` is not a future - --> $DIR/unresolved-ct-var-drop-tracking.rs:7:45 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ----------------------------^^^^^ - | | || - | | |`[(); _]` is not a future - | | help: remove the `.await` - | this call returns `[(); _]` - | - = help: the trait `Future` is not implemented for `[(); _]` - = note: [(); _] must be a future or must implement `IntoFuture` to be awaited - = note: required for `[(); _]` to implement `IntoFuture` - -error[E0698]: type inside `async` block must be known in this context - --> $DIR/unresolved-ct-var-drop-tracking.rs:7:17 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn` - | -note: the type is part of the `async` block because of this `await` - --> $DIR/unresolved-ct-var-drop-tracking.rs:7:45 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^ - -error[E0698]: type inside `async` block must be known in this context - --> $DIR/unresolved-ct-var-drop-tracking.rs:7:17 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn` - | -note: the type is part of the `async` block because of this `await` - --> $DIR/unresolved-ct-var-drop-tracking.rs:7:45 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^ - -error[E0698]: type inside `async` block must be known in this context - --> $DIR/unresolved-ct-var-drop-tracking.rs:7:17 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn` - | -note: the type is part of the `async` block because of this `await` - --> $DIR/unresolved-ct-var-drop-tracking.rs:7:45 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^ - -error[E0698]: type inside `async` block must be known in this context - --> $DIR/unresolved-ct-var-drop-tracking.rs:7:17 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn` - | -note: the type is part of the `async` block because of this `await` - --> $DIR/unresolved-ct-var-drop-tracking.rs:7:45 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^ - -error[E0698]: type inside `async` block must be known in this context - --> $DIR/unresolved-ct-var-drop-tracking.rs:7:17 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn` - | -note: the type is part of the `async` block because of this `await` - --> $DIR/unresolved-ct-var-drop-tracking.rs:7:45 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^ - -error: aborting due to 6 previous errors - -Some errors have detailed explanations: E0277, E0698. -For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/impl-trait/issue-55872-2.drop_tracking.stderr b/tests/ui/impl-trait/issue-55872-2.drop_tracking.stderr deleted file mode 100644 index 477c964bd40..00000000000 --- a/tests/ui/impl-trait/issue-55872-2.drop_tracking.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias - --> $DIR/issue-55872-2.rs:17:9 - | -LL | async {} - | ^^^^^^^^ - -error: aborting due to previous error - diff --git a/tests/ui/impl-trait/issue-55872-2.drop_tracking_mir.stderr b/tests/ui/impl-trait/issue-55872-2.drop_tracking_mir.stderr deleted file mode 100644 index c14bb5cc914..00000000000 --- a/tests/ui/impl-trait/issue-55872-2.drop_tracking_mir.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias - --> $DIR/issue-55872-2.rs:17:9 - | -LL | async {} - | ^^^^^^^^ - -error: type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias - --> $DIR/issue-55872-2.rs:17:9 - | -LL | async {} - | ^^^^^^^^ - -error: aborting due to 2 previous errors - diff --git a/tests/ui/impl-trait/issue-55872-2.rs b/tests/ui/impl-trait/issue-55872-2.rs index 7a5cb3b3dfc..ec3d924cea7 100644 --- a/tests/ui/impl-trait/issue-55872-2.rs +++ b/tests/ui/impl-trait/issue-55872-2.rs @@ -1,6 +1,3 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir // edition:2018 #![feature(impl_trait_in_assoc_type)] @@ -16,7 +13,6 @@ impl Bar for S { fn foo() -> Self::E { async {} //~^ ERROR type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias - //[drop_tracking_mir]~^^ ERROR type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias } } diff --git a/tests/ui/impl-trait/issue-55872-2.no_drop_tracking.stderr b/tests/ui/impl-trait/issue-55872-2.stderr similarity index 86% rename from tests/ui/impl-trait/issue-55872-2.no_drop_tracking.stderr rename to tests/ui/impl-trait/issue-55872-2.stderr index 477c964bd40..11b8485c8bb 100644 --- a/tests/ui/impl-trait/issue-55872-2.no_drop_tracking.stderr +++ b/tests/ui/impl-trait/issue-55872-2.stderr @@ -1,5 +1,5 @@ error: type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias - --> $DIR/issue-55872-2.rs:17:9 + --> $DIR/issue-55872-2.rs:14:9 | LL | async {} | ^^^^^^^^ diff --git a/tests/ui/impl-trait/recursive-impl-trait-type-indirect.drop_tracking_mir.stderr b/tests/ui/impl-trait/recursive-impl-trait-type-indirect.drop_tracking_mir.stderr deleted file mode 100644 index 7cef19c48fe..00000000000 --- a/tests/ui/impl-trait/recursive-impl-trait-type-indirect.drop_tracking_mir.stderr +++ /dev/null @@ -1,147 +0,0 @@ -error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:11:22 - | -LL | fn option(i: i32) -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -LL | -LL | if i < 0 { None } else { Some((option(i - 1), i)) } - | ---- ------------------------ returning here with type `Option<(impl Sized, i32)>` - | | - | returning here with type `Option<(impl Sized, i32)>` - -error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:16:15 - | -LL | fn tuple() -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -LL | -LL | (tuple(),) - | ---------- returning here with type `(impl Sized,)` - -error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:21:15 - | -LL | fn array() -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -LL | -LL | [array()] - | --------- returning here with type `[impl Sized; 1]` - -error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:26:13 - | -LL | fn ptr() -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -LL | -LL | &ptr() as *const _ - | ------------------ returning here with type `*const impl Sized` - -error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:31:16 - | -LL | fn fn_ptr() -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -LL | -LL | fn_ptr as fn() -> _ - | ------------------- returning here with type `fn() -> impl Sized` - -error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:36:25 - | -LL | fn closure_capture() -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -... -LL | / move || { -LL | | x; - | | - closure captures itself here -LL | | } - | |_____- returning here with type `{closure@$DIR/recursive-impl-trait-type-indirect.rs:39:5: 39:12}` - -error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:44:29 - | -LL | fn closure_ref_capture() -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -... -LL | / move || { -LL | | &x; - | | - closure captures itself here -LL | | } - | |_____- returning here with type `{closure@$DIR/recursive-impl-trait-type-indirect.rs:47:5: 47:12}` - -error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:52:21 - | -LL | fn closure_sig() -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -LL | -LL | || closure_sig() - | ---------------- returning here with type `{closure@$DIR/recursive-impl-trait-type-indirect.rs:54:5: 54:7}` - -error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:57:23 - | -LL | fn generator_sig() -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -LL | -LL | || generator_sig() - | ------------------ returning here with type `{closure@$DIR/recursive-impl-trait-type-indirect.rs:59:5: 59:7}` - -error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:62:27 - | -LL | fn generator_capture() -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -... -LL | / move || { -LL | | yield; -LL | | x; - | | - generator captures itself here -LL | | } - | |_____- returning here with type `{generator@$DIR/recursive-impl-trait-type-indirect.rs:65:5: 65:12}` - -error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:71:35 - | -LL | fn substs_change() -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -LL | -LL | (substs_change::<&T>(),) - | ------------------------ returning here with type `(impl Sized,)` - -error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:76:24 - | -LL | fn generator_hold() -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -... -LL | let x = generator_hold(); - | - generator captures itself here - -error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:90:26 - | -LL | fn mutual_recursion() -> impl Sync { - | ^^^^^^^^^ recursive opaque type -LL | -LL | mutual_recursion_b() - | -------------------- returning here with type `impl Sized` -... -LL | fn mutual_recursion_b() -> impl Sized { - | ---------- returning this opaque type `impl Sized` - -error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:95:28 - | -LL | fn mutual_recursion() -> impl Sync { - | --------- returning this opaque type `impl Sync` -... -LL | fn mutual_recursion_b() -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -LL | -LL | mutual_recursion() - | ------------------ returning here with type `impl Sync` - -error: aborting due to 14 previous errors - -For more information about this error, try `rustc --explain E0720`. diff --git a/tests/ui/impl-trait/recursive-impl-trait-type-indirect.no_drop_tracking.stderr b/tests/ui/impl-trait/recursive-impl-trait-type-indirect.no_drop_tracking.stderr deleted file mode 100644 index 4d4090f27fc..00000000000 --- a/tests/ui/impl-trait/recursive-impl-trait-type-indirect.no_drop_tracking.stderr +++ /dev/null @@ -1,152 +0,0 @@ -error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:11:22 - | -LL | fn option(i: i32) -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -LL | -LL | if i < 0 { None } else { Some((option(i - 1), i)) } - | ---- ------------------------ returning here with type `Option<(impl Sized, i32)>` - | | - | returning here with type `Option<(impl Sized, i32)>` - -error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:16:15 - | -LL | fn tuple() -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -LL | -LL | (tuple(),) - | ---------- returning here with type `(impl Sized,)` - -error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:21:15 - | -LL | fn array() -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -LL | -LL | [array()] - | --------- returning here with type `[impl Sized; 1]` - -error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:26:13 - | -LL | fn ptr() -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -LL | -LL | &ptr() as *const _ - | ------------------ returning here with type `*const impl Sized` - -error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:31:16 - | -LL | fn fn_ptr() -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -LL | -LL | fn_ptr as fn() -> _ - | ------------------- returning here with type `fn() -> impl Sized` - -error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:36:25 - | -LL | fn closure_capture() -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -... -LL | / move || { -LL | | x; - | | - closure captures itself here -LL | | } - | |_____- returning here with type `{closure@$DIR/recursive-impl-trait-type-indirect.rs:39:5: 39:12}` - -error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:44:29 - | -LL | fn closure_ref_capture() -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -... -LL | / move || { -LL | | &x; - | | - closure captures itself here -LL | | } - | |_____- returning here with type `{closure@$DIR/recursive-impl-trait-type-indirect.rs:47:5: 47:12}` - -error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:52:21 - | -LL | fn closure_sig() -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -LL | -LL | || closure_sig() - | ---------------- returning here with type `{closure@$DIR/recursive-impl-trait-type-indirect.rs:54:5: 54:7}` - -error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:57:23 - | -LL | fn generator_sig() -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -LL | -LL | || generator_sig() - | ------------------ returning here with type `{closure@$DIR/recursive-impl-trait-type-indirect.rs:59:5: 59:7}` - -error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:62:27 - | -LL | fn generator_capture() -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -... -LL | / move || { -LL | | yield; -LL | | x; - | | - generator captures itself here -LL | | } - | |_____- returning here with type `{generator@$DIR/recursive-impl-trait-type-indirect.rs:65:5: 65:12}` - -error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:71:35 - | -LL | fn substs_change() -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -LL | -LL | (substs_change::<&T>(),) - | ------------------------ returning here with type `(impl Sized,)` - -error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:76:24 - | -LL | fn generator_hold() -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -LL | -LL | / move || { -LL | | let x = generator_hold(); - | | - generator captures itself here -LL | | yield; -LL | | x; -LL | | } - | |_____- returning here with type `{generator@$DIR/recursive-impl-trait-type-indirect.rs:78:5: 78:12}` - -error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:90:26 - | -LL | fn mutual_recursion() -> impl Sync { - | ^^^^^^^^^ recursive opaque type -LL | -LL | mutual_recursion_b() - | -------------------- returning here with type `impl Sized` -... -LL | fn mutual_recursion_b() -> impl Sized { - | ---------- returning this opaque type `impl Sized` - -error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:95:28 - | -LL | fn mutual_recursion() -> impl Sync { - | --------- returning this opaque type `impl Sync` -... -LL | fn mutual_recursion_b() -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -LL | -LL | mutual_recursion() - | ------------------ returning here with type `impl Sync` - -error: aborting due to 14 previous errors - -For more information about this error, try `rustc --explain E0720`. diff --git a/tests/ui/impl-trait/recursive-impl-trait-type-indirect.rs b/tests/ui/impl-trait/recursive-impl-trait-type-indirect.rs index 630372e13ed..ffc0cd9d10c 100644 --- a/tests/ui/impl-trait/recursive-impl-trait-type-indirect.rs +++ b/tests/ui/impl-trait/recursive-impl-trait-type-indirect.rs @@ -1,7 +1,3 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir - // Test that impl trait does not allow creating recursive types that are // otherwise forbidden. diff --git a/tests/ui/impl-trait/recursive-impl-trait-type-indirect.drop_tracking.stderr b/tests/ui/impl-trait/recursive-impl-trait-type-indirect.stderr similarity index 80% rename from tests/ui/impl-trait/recursive-impl-trait-type-indirect.drop_tracking.stderr rename to tests/ui/impl-trait/recursive-impl-trait-type-indirect.stderr index 4d4090f27fc..a792e371185 100644 --- a/tests/ui/impl-trait/recursive-impl-trait-type-indirect.drop_tracking.stderr +++ b/tests/ui/impl-trait/recursive-impl-trait-type-indirect.stderr @@ -1,5 +1,5 @@ error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:11:22 + --> $DIR/recursive-impl-trait-type-indirect.rs:7:22 | LL | fn option(i: i32) -> impl Sized { | ^^^^^^^^^^ recursive opaque type @@ -10,7 +10,7 @@ LL | if i < 0 { None } else { Some((option(i - 1), i)) } | returning here with type `Option<(impl Sized, i32)>` error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:16:15 + --> $DIR/recursive-impl-trait-type-indirect.rs:12:15 | LL | fn tuple() -> impl Sized { | ^^^^^^^^^^ recursive opaque type @@ -19,7 +19,7 @@ LL | (tuple(),) | ---------- returning here with type `(impl Sized,)` error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:21:15 + --> $DIR/recursive-impl-trait-type-indirect.rs:17:15 | LL | fn array() -> impl Sized { | ^^^^^^^^^^ recursive opaque type @@ -28,7 +28,7 @@ LL | [array()] | --------- returning here with type `[impl Sized; 1]` error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:26:13 + --> $DIR/recursive-impl-trait-type-indirect.rs:22:13 | LL | fn ptr() -> impl Sized { | ^^^^^^^^^^ recursive opaque type @@ -37,7 +37,7 @@ LL | &ptr() as *const _ | ------------------ returning here with type `*const impl Sized` error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:31:16 + --> $DIR/recursive-impl-trait-type-indirect.rs:27:16 | LL | fn fn_ptr() -> impl Sized { | ^^^^^^^^^^ recursive opaque type @@ -46,7 +46,7 @@ LL | fn_ptr as fn() -> _ | ------------------- returning here with type `fn() -> impl Sized` error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:36:25 + --> $DIR/recursive-impl-trait-type-indirect.rs:32:25 | LL | fn closure_capture() -> impl Sized { | ^^^^^^^^^^ recursive opaque type @@ -55,10 +55,10 @@ LL | / move || { LL | | x; | | - closure captures itself here LL | | } - | |_____- returning here with type `{closure@$DIR/recursive-impl-trait-type-indirect.rs:39:5: 39:12}` + | |_____- returning here with type `{closure@$DIR/recursive-impl-trait-type-indirect.rs:35:5: 35:12}` error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:44:29 + --> $DIR/recursive-impl-trait-type-indirect.rs:40:29 | LL | fn closure_ref_capture() -> impl Sized { | ^^^^^^^^^^ recursive opaque type @@ -67,28 +67,28 @@ LL | / move || { LL | | &x; | | - closure captures itself here LL | | } - | |_____- returning here with type `{closure@$DIR/recursive-impl-trait-type-indirect.rs:47:5: 47:12}` + | |_____- returning here with type `{closure@$DIR/recursive-impl-trait-type-indirect.rs:43:5: 43:12}` error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:52:21 + --> $DIR/recursive-impl-trait-type-indirect.rs:48:21 | LL | fn closure_sig() -> impl Sized { | ^^^^^^^^^^ recursive opaque type LL | LL | || closure_sig() - | ---------------- returning here with type `{closure@$DIR/recursive-impl-trait-type-indirect.rs:54:5: 54:7}` + | ---------------- returning here with type `{closure@$DIR/recursive-impl-trait-type-indirect.rs:50:5: 50:7}` error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:57:23 + --> $DIR/recursive-impl-trait-type-indirect.rs:53:23 | LL | fn generator_sig() -> impl Sized { | ^^^^^^^^^^ recursive opaque type LL | LL | || generator_sig() - | ------------------ returning here with type `{closure@$DIR/recursive-impl-trait-type-indirect.rs:59:5: 59:7}` + | ------------------ returning here with type `{closure@$DIR/recursive-impl-trait-type-indirect.rs:55:5: 55:7}` error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:62:27 + --> $DIR/recursive-impl-trait-type-indirect.rs:58:27 | LL | fn generator_capture() -> impl Sized { | ^^^^^^^^^^ recursive opaque type @@ -98,10 +98,10 @@ LL | | yield; LL | | x; | | - generator captures itself here LL | | } - | |_____- returning here with type `{generator@$DIR/recursive-impl-trait-type-indirect.rs:65:5: 65:12}` + | |_____- returning here with type `{generator@$DIR/recursive-impl-trait-type-indirect.rs:61:5: 61:12}` error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:71:35 + --> $DIR/recursive-impl-trait-type-indirect.rs:67:35 | LL | fn substs_change() -> impl Sized { | ^^^^^^^^^^ recursive opaque type @@ -110,7 +110,7 @@ LL | (substs_change::<&T>(),) | ------------------------ returning here with type `(impl Sized,)` error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:76:24 + --> $DIR/recursive-impl-trait-type-indirect.rs:72:24 | LL | fn generator_hold() -> impl Sized { | ^^^^^^^^^^ recursive opaque type @@ -121,10 +121,10 @@ LL | | let x = generator_hold(); LL | | yield; LL | | x; LL | | } - | |_____- returning here with type `{generator@$DIR/recursive-impl-trait-type-indirect.rs:78:5: 78:12}` + | |_____- returning here with type `{generator@$DIR/recursive-impl-trait-type-indirect.rs:74:5: 74:12}` error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:90:26 + --> $DIR/recursive-impl-trait-type-indirect.rs:86:26 | LL | fn mutual_recursion() -> impl Sync { | ^^^^^^^^^ recursive opaque type @@ -136,7 +136,7 @@ LL | fn mutual_recursion_b() -> impl Sized { | ---------- returning this opaque type `impl Sized` error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:95:28 + --> $DIR/recursive-impl-trait-type-indirect.rs:91:28 | LL | fn mutual_recursion() -> impl Sync { | --------- returning this opaque type `impl Sync` diff --git a/tests/ui/lint/must_not_suspend/dedup.drop_tracking_mir.stderr b/tests/ui/lint/must_not_suspend/dedup.drop_tracking_mir.stderr deleted file mode 100644 index cd3baa857ab..00000000000 --- a/tests/ui/lint/must_not_suspend/dedup.drop_tracking_mir.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error: `No` held across a suspend point, but should not be - --> $DIR/dedup.rs:19:9 - | -LL | let no = No {}; - | ^^ -LL | wheeee(&no).await; - | ----- the value is held across this suspend point - | -help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point - --> $DIR/dedup.rs:19:9 - | -LL | let no = No {}; - | ^^ -note: the lint level is defined here - --> $DIR/dedup.rs:6:9 - | -LL | #![deny(must_not_suspend)] - | ^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/tests/ui/lint/must_not_suspend/dedup.no_drop_tracking.stderr b/tests/ui/lint/must_not_suspend/dedup.no_drop_tracking.stderr deleted file mode 100644 index aff2f7c32b9..00000000000 --- a/tests/ui/lint/must_not_suspend/dedup.no_drop_tracking.stderr +++ /dev/null @@ -1,33 +0,0 @@ -error: `No` held across a suspend point, but should not be - --> $DIR/dedup.rs:19:9 - | -LL | let no = No {}; - | ^^ -LL | wheeee(&no).await; - | ----- the value is held across this suspend point - | -help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point - --> $DIR/dedup.rs:19:9 - | -LL | let no = No {}; - | ^^ -note: the lint level is defined here - --> $DIR/dedup.rs:6:9 - | -LL | #![deny(must_not_suspend)] - | ^^^^^^^^^^^^^^^^ - -error: `No` held across a suspend point, but should not be - --> $DIR/dedup.rs:20:13 - | -LL | wheeee(&no).await; - | ^^ ----- the value is held across this suspend point - | -help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point - --> $DIR/dedup.rs:20:13 - | -LL | wheeee(&no).await; - | ^^ - -error: aborting due to 2 previous errors - diff --git a/tests/ui/lint/must_not_suspend/dedup.rs b/tests/ui/lint/must_not_suspend/dedup.rs index 96bdb7715b1..81a08579bb7 100644 --- a/tests/ui/lint/must_not_suspend/dedup.rs +++ b/tests/ui/lint/must_not_suspend/dedup.rs @@ -1,6 +1,3 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir // edition:2018 #![feature(must_not_suspend)] #![deny(must_not_suspend)] @@ -16,9 +13,7 @@ async fn wheeee(t: T) { } async fn yes() { - let no = No {}; //~ ERROR `No` held across - wheeee(&no).await; //[no_drop_tracking]~ ERROR `No` held across - drop(no); + wheeee(&No {}).await; //~ ERROR `No` held across } fn main() { diff --git a/tests/ui/lint/must_not_suspend/dedup.drop_tracking.stderr b/tests/ui/lint/must_not_suspend/dedup.stderr similarity index 55% rename from tests/ui/lint/must_not_suspend/dedup.drop_tracking.stderr rename to tests/ui/lint/must_not_suspend/dedup.stderr index cd3baa857ab..6925b1640b2 100644 --- a/tests/ui/lint/must_not_suspend/dedup.drop_tracking.stderr +++ b/tests/ui/lint/must_not_suspend/dedup.stderr @@ -1,18 +1,16 @@ error: `No` held across a suspend point, but should not be - --> $DIR/dedup.rs:19:9 + --> $DIR/dedup.rs:16:13 | -LL | let no = No {}; - | ^^ -LL | wheeee(&no).await; - | ----- the value is held across this suspend point +LL | wheeee(&No {}).await; + | ^^^^^ ----- the value is held across this suspend point | help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point - --> $DIR/dedup.rs:19:9 + --> $DIR/dedup.rs:16:13 | -LL | let no = No {}; - | ^^ +LL | wheeee(&No {}).await; + | ^^^^^ note: the lint level is defined here - --> $DIR/dedup.rs:6:9 + --> $DIR/dedup.rs:3:9 | LL | #![deny(must_not_suspend)] | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui/lint/must_not_suspend/ref-drop-tracking.rs b/tests/ui/lint/must_not_suspend/ref-drop-tracking.rs deleted file mode 100644 index 1bc4a381257..00000000000 --- a/tests/ui/lint/must_not_suspend/ref-drop-tracking.rs +++ /dev/null @@ -1,30 +0,0 @@ -// edition:2018 -// compile-flags: -Zdrop-tracking -#![feature(must_not_suspend)] -#![deny(must_not_suspend)] - -#[must_not_suspend = "You gotta use Umm's, ya know?"] -struct Umm { - i: i64 -} - -struct Bar { - u: Umm, -} - -async fn other() {} - -impl Bar { - async fn uhoh(&mut self) { - let guard = &mut self.u; //~ ERROR `Umm` held across - - other().await; - - *guard = Umm { - i: 2 - } - } -} - -fn main() { -} diff --git a/tests/ui/lint/must_not_suspend/ref-drop-tracking.stderr b/tests/ui/lint/must_not_suspend/ref-drop-tracking.stderr deleted file mode 100644 index 348880b9c9f..00000000000 --- a/tests/ui/lint/must_not_suspend/ref-drop-tracking.stderr +++ /dev/null @@ -1,27 +0,0 @@ -error: reference to `Umm` held across a suspend point, but should not be - --> $DIR/ref-drop-tracking.rs:19:13 - | -LL | let guard = &mut self.u; - | ^^^^^ -LL | -LL | other().await; - | ----- the value is held across this suspend point - | -note: You gotta use Umm's, ya know? - --> $DIR/ref-drop-tracking.rs:19:13 - | -LL | let guard = &mut self.u; - | ^^^^^ -help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point - --> $DIR/ref-drop-tracking.rs:19:13 - | -LL | let guard = &mut self.u; - | ^^^^^ -note: the lint level is defined here - --> $DIR/ref-drop-tracking.rs:4:9 - | -LL | #![deny(must_not_suspend)] - | ^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/tests/ui/lint/must_not_suspend/ref.drop_tracking.stderr b/tests/ui/lint/must_not_suspend/ref.drop_tracking.stderr deleted file mode 100644 index fb18c2be9cb..00000000000 --- a/tests/ui/lint/must_not_suspend/ref.drop_tracking.stderr +++ /dev/null @@ -1,27 +0,0 @@ -error: reference to `Umm` held across a suspend point, but should not be - --> $DIR/ref.rs:22:13 - | -LL | let guard = &mut self.u; - | ^^^^^ -LL | -LL | other().await; - | ----- the value is held across this suspend point - | -note: You gotta use Umm's, ya know? - --> $DIR/ref.rs:22:13 - | -LL | let guard = &mut self.u; - | ^^^^^ -help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point - --> $DIR/ref.rs:22:13 - | -LL | let guard = &mut self.u; - | ^^^^^ -note: the lint level is defined here - --> $DIR/ref.rs:7:9 - | -LL | #![deny(must_not_suspend)] - | ^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/tests/ui/lint/must_not_suspend/ref.drop_tracking_mir.stderr b/tests/ui/lint/must_not_suspend/ref.drop_tracking_mir.stderr deleted file mode 100644 index fb18c2be9cb..00000000000 --- a/tests/ui/lint/must_not_suspend/ref.drop_tracking_mir.stderr +++ /dev/null @@ -1,27 +0,0 @@ -error: reference to `Umm` held across a suspend point, but should not be - --> $DIR/ref.rs:22:13 - | -LL | let guard = &mut self.u; - | ^^^^^ -LL | -LL | other().await; - | ----- the value is held across this suspend point - | -note: You gotta use Umm's, ya know? - --> $DIR/ref.rs:22:13 - | -LL | let guard = &mut self.u; - | ^^^^^ -help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point - --> $DIR/ref.rs:22:13 - | -LL | let guard = &mut self.u; - | ^^^^^ -note: the lint level is defined here - --> $DIR/ref.rs:7:9 - | -LL | #![deny(must_not_suspend)] - | ^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/tests/ui/lint/must_not_suspend/ref.rs b/tests/ui/lint/must_not_suspend/ref.rs index d05dcb83ac5..3b6ef39c9fe 100644 --- a/tests/ui/lint/must_not_suspend/ref.rs +++ b/tests/ui/lint/must_not_suspend/ref.rs @@ -1,8 +1,4 @@ // edition:2018 -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir - #![feature(must_not_suspend)] #![deny(must_not_suspend)] @@ -23,7 +19,6 @@ impl Bar { other().await; - let _g = &*guard; *guard = Umm { i: 2 } } } diff --git a/tests/ui/lint/must_not_suspend/ref.no_drop_tracking.stderr b/tests/ui/lint/must_not_suspend/ref.stderr similarity index 88% rename from tests/ui/lint/must_not_suspend/ref.no_drop_tracking.stderr rename to tests/ui/lint/must_not_suspend/ref.stderr index 6976dd34991..148af00a3d2 100644 --- a/tests/ui/lint/must_not_suspend/ref.no_drop_tracking.stderr +++ b/tests/ui/lint/must_not_suspend/ref.stderr @@ -1,5 +1,5 @@ error: `Umm` held across a suspend point, but should not be - --> $DIR/ref.rs:22:26 + --> $DIR/ref.rs:18:26 | LL | let guard = &mut self.u; | ^^^^^^ @@ -8,17 +8,17 @@ LL | other().await; | ----- the value is held across this suspend point | note: You gotta use Umm's, ya know? - --> $DIR/ref.rs:22:26 + --> $DIR/ref.rs:18:26 | LL | let guard = &mut self.u; | ^^^^^^ help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point - --> $DIR/ref.rs:22:26 + --> $DIR/ref.rs:18:26 | LL | let guard = &mut self.u; | ^^^^^^ note: the lint level is defined here - --> $DIR/ref.rs:7:9 + --> $DIR/ref.rs:3:9 | LL | #![deny(must_not_suspend)] | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui/lint/must_not_suspend/trait.drop_tracking_mir.stderr b/tests/ui/lint/must_not_suspend/trait.drop_tracking_mir.stderr deleted file mode 100644 index 8c8ad1f3788..00000000000 --- a/tests/ui/lint/must_not_suspend/trait.drop_tracking_mir.stderr +++ /dev/null @@ -1,37 +0,0 @@ -error: implementer of `Wow` held across a suspend point, but should not be - --> $DIR/trait.rs:24:9 - | -LL | let _guard1 = r#impl(); - | ^^^^^^^ -... -LL | other().await; - | ----- the value is held across this suspend point - | -help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point - --> $DIR/trait.rs:24:9 - | -LL | let _guard1 = r#impl(); - | ^^^^^^^ -note: the lint level is defined here - --> $DIR/trait.rs:6:9 - | -LL | #![deny(must_not_suspend)] - | ^^^^^^^^^^^^^^^^ - -error: boxed `Wow` trait object held across a suspend point, but should not be - --> $DIR/trait.rs:25:9 - | -LL | let _guard2 = r#dyn(); - | ^^^^^^^ -LL | -LL | other().await; - | ----- the value is held across this suspend point - | -help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point - --> $DIR/trait.rs:25:9 - | -LL | let _guard2 = r#dyn(); - | ^^^^^^^ - -error: aborting due to 2 previous errors - diff --git a/tests/ui/lint/must_not_suspend/trait.no_drop_tracking.stderr b/tests/ui/lint/must_not_suspend/trait.no_drop_tracking.stderr deleted file mode 100644 index 8c8ad1f3788..00000000000 --- a/tests/ui/lint/must_not_suspend/trait.no_drop_tracking.stderr +++ /dev/null @@ -1,37 +0,0 @@ -error: implementer of `Wow` held across a suspend point, but should not be - --> $DIR/trait.rs:24:9 - | -LL | let _guard1 = r#impl(); - | ^^^^^^^ -... -LL | other().await; - | ----- the value is held across this suspend point - | -help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point - --> $DIR/trait.rs:24:9 - | -LL | let _guard1 = r#impl(); - | ^^^^^^^ -note: the lint level is defined here - --> $DIR/trait.rs:6:9 - | -LL | #![deny(must_not_suspend)] - | ^^^^^^^^^^^^^^^^ - -error: boxed `Wow` trait object held across a suspend point, but should not be - --> $DIR/trait.rs:25:9 - | -LL | let _guard2 = r#dyn(); - | ^^^^^^^ -LL | -LL | other().await; - | ----- the value is held across this suspend point - | -help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point - --> $DIR/trait.rs:25:9 - | -LL | let _guard2 = r#dyn(); - | ^^^^^^^ - -error: aborting due to 2 previous errors - diff --git a/tests/ui/lint/must_not_suspend/trait.rs b/tests/ui/lint/must_not_suspend/trait.rs index cc3ae298dbb..6c911cb4b0f 100644 --- a/tests/ui/lint/must_not_suspend/trait.rs +++ b/tests/ui/lint/must_not_suspend/trait.rs @@ -1,6 +1,3 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir // edition:2018 #![feature(must_not_suspend)] #![deny(must_not_suspend)] @@ -25,9 +22,6 @@ pub async fn uhoh() { let _guard2 = r#dyn(); //~ ERROR boxed `Wow` trait object held across other().await; - - drop(_guard1); - drop(_guard2); } fn main() { diff --git a/tests/ui/lint/must_not_suspend/trait.drop_tracking.stderr b/tests/ui/lint/must_not_suspend/trait.stderr similarity index 88% rename from tests/ui/lint/must_not_suspend/trait.drop_tracking.stderr rename to tests/ui/lint/must_not_suspend/trait.stderr index 8c8ad1f3788..2c03f8e822d 100644 --- a/tests/ui/lint/must_not_suspend/trait.drop_tracking.stderr +++ b/tests/ui/lint/must_not_suspend/trait.stderr @@ -1,5 +1,5 @@ error: implementer of `Wow` held across a suspend point, but should not be - --> $DIR/trait.rs:24:9 + --> $DIR/trait.rs:21:9 | LL | let _guard1 = r#impl(); | ^^^^^^^ @@ -8,18 +8,18 @@ LL | other().await; | ----- the value is held across this suspend point | help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point - --> $DIR/trait.rs:24:9 + --> $DIR/trait.rs:21:9 | LL | let _guard1 = r#impl(); | ^^^^^^^ note: the lint level is defined here - --> $DIR/trait.rs:6:9 + --> $DIR/trait.rs:3:9 | LL | #![deny(must_not_suspend)] | ^^^^^^^^^^^^^^^^ error: boxed `Wow` trait object held across a suspend point, but should not be - --> $DIR/trait.rs:25:9 + --> $DIR/trait.rs:22:9 | LL | let _guard2 = r#dyn(); | ^^^^^^^ @@ -28,7 +28,7 @@ LL | other().await; | ----- the value is held across this suspend point | help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point - --> $DIR/trait.rs:25:9 + --> $DIR/trait.rs:22:9 | LL | let _guard2 = r#dyn(); | ^^^^^^^ diff --git a/tests/ui/lint/must_not_suspend/unit.drop_tracking.stderr b/tests/ui/lint/must_not_suspend/unit.drop_tracking.stderr deleted file mode 100644 index e24cffdd0df..00000000000 --- a/tests/ui/lint/must_not_suspend/unit.drop_tracking.stderr +++ /dev/null @@ -1,26 +0,0 @@ -error: `Umm` held across a suspend point, but should not be - --> $DIR/unit.rs:22:9 - | -LL | let _guard = bar(); - | ^^^^^^ -LL | other().await; - | ----- the value is held across this suspend point - | -note: You gotta use Umm's, ya know? - --> $DIR/unit.rs:22:9 - | -LL | let _guard = bar(); - | ^^^^^^ -help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point - --> $DIR/unit.rs:22:9 - | -LL | let _guard = bar(); - | ^^^^^^ -note: the lint level is defined here - --> $DIR/unit.rs:6:9 - | -LL | #![deny(must_not_suspend)] - | ^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/tests/ui/lint/must_not_suspend/unit.no_drop_tracking.stderr b/tests/ui/lint/must_not_suspend/unit.no_drop_tracking.stderr deleted file mode 100644 index e24cffdd0df..00000000000 --- a/tests/ui/lint/must_not_suspend/unit.no_drop_tracking.stderr +++ /dev/null @@ -1,26 +0,0 @@ -error: `Umm` held across a suspend point, but should not be - --> $DIR/unit.rs:22:9 - | -LL | let _guard = bar(); - | ^^^^^^ -LL | other().await; - | ----- the value is held across this suspend point - | -note: You gotta use Umm's, ya know? - --> $DIR/unit.rs:22:9 - | -LL | let _guard = bar(); - | ^^^^^^ -help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point - --> $DIR/unit.rs:22:9 - | -LL | let _guard = bar(); - | ^^^^^^ -note: the lint level is defined here - --> $DIR/unit.rs:6:9 - | -LL | #![deny(must_not_suspend)] - | ^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/tests/ui/lint/must_not_suspend/unit.rs b/tests/ui/lint/must_not_suspend/unit.rs index fbc51b36681..d3a19f70432 100644 --- a/tests/ui/lint/must_not_suspend/unit.rs +++ b/tests/ui/lint/must_not_suspend/unit.rs @@ -1,6 +1,3 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir // edition:2018 #![feature(must_not_suspend)] #![deny(must_not_suspend)] @@ -10,6 +7,7 @@ struct Umm { i: i64 } + fn bar() -> Umm { Umm { i: 1 @@ -21,7 +19,6 @@ async fn other() {} pub async fn uhoh() { let _guard = bar(); //~ ERROR `Umm` held across other().await; - drop(_guard); } fn main() { diff --git a/tests/ui/lint/must_not_suspend/unit.drop_tracking_mir.stderr b/tests/ui/lint/must_not_suspend/unit.stderr similarity index 86% rename from tests/ui/lint/must_not_suspend/unit.drop_tracking_mir.stderr rename to tests/ui/lint/must_not_suspend/unit.stderr index e24cffdd0df..11c95c1464a 100644 --- a/tests/ui/lint/must_not_suspend/unit.drop_tracking_mir.stderr +++ b/tests/ui/lint/must_not_suspend/unit.stderr @@ -1,5 +1,5 @@ error: `Umm` held across a suspend point, but should not be - --> $DIR/unit.rs:22:9 + --> $DIR/unit.rs:20:9 | LL | let _guard = bar(); | ^^^^^^ @@ -7,17 +7,17 @@ LL | other().await; | ----- the value is held across this suspend point | note: You gotta use Umm's, ya know? - --> $DIR/unit.rs:22:9 + --> $DIR/unit.rs:20:9 | LL | let _guard = bar(); | ^^^^^^ help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point - --> $DIR/unit.rs:22:9 + --> $DIR/unit.rs:20:9 | LL | let _guard = bar(); | ^^^^^^ note: the lint level is defined here - --> $DIR/unit.rs:6:9 + --> $DIR/unit.rs:3:9 | LL | #![deny(must_not_suspend)] | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui/lint/must_not_suspend/warn.drop_tracking.stderr b/tests/ui/lint/must_not_suspend/warn.drop_tracking.stderr deleted file mode 100644 index 4f7b40a5efe..00000000000 --- a/tests/ui/lint/must_not_suspend/warn.drop_tracking.stderr +++ /dev/null @@ -1,26 +0,0 @@ -warning: `Umm` held across a suspend point, but should not be - --> $DIR/warn.rs:24:9 - | -LL | let _guard = bar(); - | ^^^^^^ -LL | other().await; - | ----- the value is held across this suspend point - | -note: You gotta use Umm's, ya know? - --> $DIR/warn.rs:24:9 - | -LL | let _guard = bar(); - | ^^^^^^ -help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point - --> $DIR/warn.rs:24:9 - | -LL | let _guard = bar(); - | ^^^^^^ -note: the lint level is defined here - --> $DIR/warn.rs:7:9 - | -LL | #![warn(must_not_suspend)] - | ^^^^^^^^^^^^^^^^ - -warning: 1 warning emitted - diff --git a/tests/ui/lint/must_not_suspend/warn.no_drop_tracking.stderr b/tests/ui/lint/must_not_suspend/warn.no_drop_tracking.stderr deleted file mode 100644 index 4f7b40a5efe..00000000000 --- a/tests/ui/lint/must_not_suspend/warn.no_drop_tracking.stderr +++ /dev/null @@ -1,26 +0,0 @@ -warning: `Umm` held across a suspend point, but should not be - --> $DIR/warn.rs:24:9 - | -LL | let _guard = bar(); - | ^^^^^^ -LL | other().await; - | ----- the value is held across this suspend point - | -note: You gotta use Umm's, ya know? - --> $DIR/warn.rs:24:9 - | -LL | let _guard = bar(); - | ^^^^^^ -help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point - --> $DIR/warn.rs:24:9 - | -LL | let _guard = bar(); - | ^^^^^^ -note: the lint level is defined here - --> $DIR/warn.rs:7:9 - | -LL | #![warn(must_not_suspend)] - | ^^^^^^^^^^^^^^^^ - -warning: 1 warning emitted - diff --git a/tests/ui/lint/must_not_suspend/warn.rs b/tests/ui/lint/must_not_suspend/warn.rs index 5a4863169ea..7fdea66a235 100644 --- a/tests/ui/lint/must_not_suspend/warn.rs +++ b/tests/ui/lint/must_not_suspend/warn.rs @@ -1,6 +1,3 @@ -// revisions: no_drop_tracking drop_tracking drop_tracking_mir -// [drop_tracking] compile-flags: -Zdrop-tracking -// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir // edition:2018 // run-pass #![feature(must_not_suspend)] @@ -23,7 +20,6 @@ async fn other() {} pub async fn uhoh() { let _guard = bar(); //~ WARNING `Umm` held across other().await; - drop(_guard); } fn main() { diff --git a/tests/ui/lint/must_not_suspend/warn.drop_tracking_mir.stderr b/tests/ui/lint/must_not_suspend/warn.stderr similarity index 86% rename from tests/ui/lint/must_not_suspend/warn.drop_tracking_mir.stderr rename to tests/ui/lint/must_not_suspend/warn.stderr index 4f7b40a5efe..194433552cf 100644 --- a/tests/ui/lint/must_not_suspend/warn.drop_tracking_mir.stderr +++ b/tests/ui/lint/must_not_suspend/warn.stderr @@ -1,5 +1,5 @@ warning: `Umm` held across a suspend point, but should not be - --> $DIR/warn.rs:24:9 + --> $DIR/warn.rs:21:9 | LL | let _guard = bar(); | ^^^^^^ @@ -7,17 +7,17 @@ LL | other().await; | ----- the value is held across this suspend point | note: You gotta use Umm's, ya know? - --> $DIR/warn.rs:24:9 + --> $DIR/warn.rs:21:9 | LL | let _guard = bar(); | ^^^^^^ help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point - --> $DIR/warn.rs:24:9 + --> $DIR/warn.rs:21:9 | LL | let _guard = bar(); | ^^^^^^ note: the lint level is defined here - --> $DIR/warn.rs:7:9 + --> $DIR/warn.rs:4:9 | LL | #![warn(must_not_suspend)] | ^^^^^^^^^^^^^^^^ From 286502c9ed77e49aea5bb89cf18c5eda3a8fce92 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sat, 28 Jan 2023 12:56:04 +0000 Subject: [PATCH 17/30] Enable drop_tracking_mir by default. --- .../rustc_hir_analysis/src/check/check.rs | 9 +- .../rustc_hir_typeck/src/fn_ctxt/_impl.rs | 20 +- .../drop_ranges/cfg_build.rs | 601 --------------- .../drop_ranges/cfg_propagate.rs | 92 --- .../drop_ranges/cfg_visualize.rs | 96 --- .../src/generator_interior/drop_ranges/mod.rs | 306 -------- .../drop_ranges/record_consumed_borrow.rs | 242 ------ .../src/generator_interior/mod.rs | 723 ------------------ compiler/rustc_hir_typeck/src/lib.rs | 1 - compiler/rustc_hir_typeck/src/writeback.rs | 6 +- compiler/rustc_interface/src/passes.rs | 14 +- compiler/rustc_interface/src/tests.rs | 2 - compiler/rustc_lint_defs/src/builtin.rs | 1 + compiler/rustc_metadata/src/rmeta/decoder.rs | 19 - .../src/rmeta/decoder/cstore_impl.rs | 1 - compiler/rustc_metadata/src/rmeta/encoder.rs | 21 +- compiler/rustc_metadata/src/rmeta/mod.rs | 3 +- compiler/rustc_middle/src/query/mod.rs | 7 - compiler/rustc_middle/src/ty/codec.rs | 1 - compiler/rustc_middle/src/ty/mod.rs | 5 +- compiler/rustc_middle/src/ty/parameterized.rs | 1 - .../rustc_middle/src/ty/typeck_results.rs | 70 -- compiler/rustc_mir_transform/src/generator.rs | 107 +-- compiler/rustc_mir_transform/src/lib.rs | 4 +- compiler/rustc_session/src/options.rs | 6 - .../src/typeid/typeid_itanium_cxx_abi.rs | 8 +- .../src/traits/error_reporting/suggestions.rs | 191 ++--- compiler/rustc_ty_utils/src/needs_drop.rs | 27 +- .../clippy_lints/src/await_holding_invalid.rs | 43 +- 29 files changed, 114 insertions(+), 2513 deletions(-) delete mode 100644 compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/cfg_build.rs delete mode 100644 compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/cfg_propagate.rs delete mode 100644 compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/cfg_visualize.rs delete mode 100644 compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/mod.rs delete mode 100644 compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/record_consumed_borrow.rs delete mode 100644 compiler/rustc_hir_typeck/src/generator_interior/mod.rs diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs index 116222ba56e..564206f9e4b 100644 --- a/compiler/rustc_hir_analysis/src/check/check.rs +++ b/compiler/rustc_hir_analysis/src/check/check.rs @@ -1579,13 +1579,7 @@ fn opaque_type_cycle_error( label_match(capture.place.ty(), capture.get_path_span(tcx)); } // Label any generator locals that capture the opaque - for interior_ty in - typeck_results.generator_interior_types.as_ref().skip_binder() - { - label_match(interior_ty.ty, interior_ty.span); - } - if tcx.sess.opts.unstable_opts.drop_tracking_mir - && let DefKind::Generator = tcx.def_kind(closure_def_id) + if let DefKind::Generator = tcx.def_kind(closure_def_id) && let Some(generator_layout) = tcx.mir_generator_witnesses(closure_def_id) { for interior_ty in &generator_layout.field_tys { @@ -1603,7 +1597,6 @@ fn opaque_type_cycle_error( } pub(super) fn check_generator_obligations(tcx: TyCtxt<'_>, def_id: LocalDefId) { - debug_assert!(tcx.sess.opts.unstable_opts.drop_tracking_mir); debug_assert!(matches!(tcx.def_kind(def_id), DefKind::Generator)); let typeck = tcx.typeck(def_id); diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs index fea726ff8ca..e32f45b4224 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs @@ -510,25 +510,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } pub(in super::super) fn resolve_generator_interiors(&self, def_id: DefId) { - if self.tcx.sess.opts.unstable_opts.drop_tracking_mir { - self.save_generator_interior_predicates(def_id); - return; - } - - self.select_obligations_where_possible(|_| {}); - - let mut generators = self.deferred_generator_interiors.borrow_mut(); - for (generator_def_id, body_id, interior, kind) in generators.drain(..) { - crate::generator_interior::resolve_interior( - self, - def_id, - generator_def_id, - body_id, - interior, - kind, - ); - self.select_obligations_where_possible(|_| {}); - } + self.save_generator_interior_predicates(def_id); } /// Unify the inference variables corresponding to generator witnesses, and save all the diff --git a/compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/cfg_build.rs b/compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/cfg_build.rs deleted file mode 100644 index cfedcee9956..00000000000 --- a/compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/cfg_build.rs +++ /dev/null @@ -1,601 +0,0 @@ -use super::{ - for_each_consumable, record_consumed_borrow::ConsumedAndBorrowedPlaces, DropRangesBuilder, - NodeInfo, PostOrderId, TrackedValue, TrackedValueIndex, -}; -use hir::{ - intravisit::{self, Visitor}, - Body, Expr, ExprKind, Guard, HirId, LoopIdError, -}; -use rustc_data_structures::unord::{UnordMap, UnordSet}; -use rustc_hir as hir; -use rustc_index::IndexVec; -use rustc_infer::infer::InferCtxt; -use rustc_middle::{ - hir::map::Map, - ty::{ParamEnv, TyCtxt, TypeVisitableExt, TypeckResults}, -}; -use std::mem::swap; - -/// Traverses the body to find the control flow graph and locations for the -/// relevant places are dropped or reinitialized. -/// -/// The resulting structure still needs to be iterated to a fixed point, which -/// can be done with propagate_to_fixpoint in cfg_propagate. -pub(super) fn build_control_flow_graph<'tcx>( - infcx: &InferCtxt<'tcx>, - typeck_results: &TypeckResults<'tcx>, - param_env: ParamEnv<'tcx>, - consumed_borrowed_places: ConsumedAndBorrowedPlaces, - body: &'tcx Body<'tcx>, - num_exprs: usize, -) -> (DropRangesBuilder, UnordSet) { - let mut drop_range_visitor = DropRangeVisitor::new( - infcx, - typeck_results, - param_env, - consumed_borrowed_places, - num_exprs, - ); - intravisit::walk_body(&mut drop_range_visitor, body); - - drop_range_visitor.drop_ranges.process_deferred_edges(); - if let Some(filename) = &infcx.tcx.sess.opts.unstable_opts.dump_drop_tracking_cfg { - super::cfg_visualize::write_graph_to_file( - &drop_range_visitor.drop_ranges, - filename, - infcx.tcx, - ); - } - - (drop_range_visitor.drop_ranges, drop_range_visitor.places.borrowed_temporaries) -} - -/// This struct is used to gather the information for `DropRanges` to determine the regions of the -/// HIR tree for which a value is dropped. -/// -/// We are interested in points where a variables is dropped or initialized, and the control flow -/// of the code. We identify locations in code by their post-order traversal index, so it is -/// important for this traversal to match that in `RegionResolutionVisitor` and `InteriorVisitor`. -/// -/// We make several simplifying assumptions, with the goal of being more conservative than -/// necessary rather than less conservative (since being less conservative is unsound, but more -/// conservative is still safe). These assumptions are: -/// -/// 1. Moving a variable `a` counts as a move of the whole variable. -/// 2. Moving a partial path like `a.b.c` is ignored. -/// 3. Reinitializing through a field (e.g. `a.b.c = 5`) counts as a reinitialization of all of -/// `a`. -/// -/// Some examples: -/// -/// Rule 1: -/// ```rust -/// let mut a = (vec![0], vec![0]); -/// drop(a); -/// // `a` is not considered initialized. -/// ``` -/// -/// Rule 2: -/// ```rust -/// let mut a = (vec![0], vec![0]); -/// drop(a.0); -/// drop(a.1); -/// // `a` is still considered initialized. -/// ``` -/// -/// Rule 3: -/// ```compile_fail,E0382 -/// let mut a = (vec![0], vec![0]); -/// drop(a); -/// a.1 = vec![1]; -/// // all of `a` is considered initialized -/// ``` - -struct DropRangeVisitor<'a, 'tcx> { - typeck_results: &'a TypeckResults<'tcx>, - infcx: &'a InferCtxt<'tcx>, - param_env: ParamEnv<'tcx>, - places: ConsumedAndBorrowedPlaces, - drop_ranges: DropRangesBuilder, - expr_index: PostOrderId, - label_stack: Vec<(Option, PostOrderId)>, -} - -impl<'a, 'tcx> DropRangeVisitor<'a, 'tcx> { - fn new( - infcx: &'a InferCtxt<'tcx>, - typeck_results: &'a TypeckResults<'tcx>, - param_env: ParamEnv<'tcx>, - places: ConsumedAndBorrowedPlaces, - num_exprs: usize, - ) -> Self { - debug!("consumed_places: {:?}", places.consumed); - let drop_ranges = DropRangesBuilder::new( - places.consumed.iter().flat_map(|(_, places)| places.iter().cloned()), - infcx.tcx.hir(), - num_exprs, - ); - Self { - infcx, - typeck_results, - param_env, - places, - drop_ranges, - expr_index: PostOrderId::from_u32(0), - label_stack: vec![], - } - } - - fn tcx(&self) -> TyCtxt<'tcx> { - self.infcx.tcx - } - - fn record_drop(&mut self, value: TrackedValue) { - if self.places.borrowed.contains(&value) { - debug!("not marking {:?} as dropped because it is borrowed at some point", value); - } else { - debug!("marking {:?} as dropped at {:?}", value, self.expr_index); - let count = self.expr_index; - self.drop_ranges.drop_at(value, count); - } - } - - /// ExprUseVisitor's consume callback doesn't go deep enough for our purposes in all - /// expressions. This method consumes a little deeper into the expression when needed. - fn consume_expr(&mut self, expr: &hir::Expr<'_>) { - debug!("consuming expr {:?}, count={:?}", expr.kind, self.expr_index); - let places = self - .places - .consumed - .get(&expr.hir_id) - .map_or(vec![], |places| places.iter().cloned().collect()); - for place in places { - trace!(?place, "consuming place"); - for_each_consumable(self.tcx().hir(), place, |value| self.record_drop(value)); - } - } - - /// Marks an expression as being reinitialized. - /// - /// Note that we always approximated on the side of things being more - /// initialized than they actually are, as opposed to less. In cases such - /// as `x.y = ...`, we would consider all of `x` as being initialized - /// instead of just the `y` field. - /// - /// This is because it is always safe to consider something initialized - /// even when it is not, but the other way around will cause problems. - /// - /// In the future, we will hopefully tighten up these rules to be more - /// precise. - fn reinit_expr(&mut self, expr: &hir::Expr<'_>) { - // Walk the expression to find the base. For example, in an expression - // like `*a[i].x`, we want to find the `a` and mark that as - // reinitialized. - match expr.kind { - ExprKind::Path(hir::QPath::Resolved( - _, - hir::Path { res: hir::def::Res::Local(hir_id), .. }, - )) => { - // This is the base case, where we have found an actual named variable. - - let location = self.expr_index; - debug!("reinitializing {:?} at {:?}", hir_id, location); - self.drop_ranges.reinit_at(TrackedValue::Variable(*hir_id), location); - } - - ExprKind::Field(base, _) => self.reinit_expr(base), - - // Most expressions do not refer to something where we need to track - // reinitializations. - // - // Some of these may be interesting in the future - ExprKind::Path(..) - | ExprKind::ConstBlock(..) - | ExprKind::Array(..) - | ExprKind::Call(..) - | ExprKind::MethodCall(..) - | ExprKind::Tup(..) - | ExprKind::Binary(..) - | ExprKind::Unary(..) - | ExprKind::Lit(..) - | ExprKind::Cast(..) - | ExprKind::Type(..) - | ExprKind::DropTemps(..) - | ExprKind::Let(..) - | ExprKind::If(..) - | ExprKind::Loop(..) - | ExprKind::Match(..) - | ExprKind::Closure { .. } - | ExprKind::Block(..) - | ExprKind::Assign(..) - | ExprKind::AssignOp(..) - | ExprKind::Index(..) - | ExprKind::AddrOf(..) - | ExprKind::Break(..) - | ExprKind::Continue(..) - | ExprKind::Ret(..) - | ExprKind::Become(..) - | ExprKind::InlineAsm(..) - | ExprKind::OffsetOf(..) - | ExprKind::Struct(..) - | ExprKind::Repeat(..) - | ExprKind::Yield(..) - | ExprKind::Err(_) => (), - } - } - - /// For an expression with an uninhabited return type (e.g. a function that returns !), - /// this adds a self edge to the CFG to model the fact that the function does not - /// return. - fn handle_uninhabited_return(&mut self, expr: &Expr<'tcx>) { - let ty = self.typeck_results.expr_ty(expr); - let ty = self.infcx.resolve_vars_if_possible(ty); - if ty.has_non_region_infer() { - self.tcx() - .sess - .delay_span_bug(expr.span, format!("could not resolve infer vars in `{ty}`")); - return; - } - let ty = self.tcx().erase_regions(ty); - let m = self.tcx().parent_module(expr.hir_id).to_def_id(); - if !ty.is_inhabited_from(self.tcx(), m, self.param_env) { - // This function will not return. We model this fact as an infinite loop. - self.drop_ranges.add_control_edge(self.expr_index + 1, self.expr_index + 1); - } - } - - /// Map a Destination to an equivalent expression node - /// - /// The destination field of a Break or Continue expression can target either an - /// expression or a block. The drop range analysis, however, only deals in - /// expression nodes, so blocks that might be the destination of a Break or Continue - /// will not have a PostOrderId. - /// - /// If the destination is an expression, this function will simply return that expression's - /// hir_id. If the destination is a block, this function will return the hir_id of last - /// expression in the block. - fn find_target_expression_from_destination( - &self, - destination: hir::Destination, - ) -> Result { - destination.target_id.map(|target| { - let node = self.tcx().hir().get(target); - match node { - hir::Node::Expr(_) => target, - hir::Node::Block(b) => find_last_block_expression(b), - hir::Node::Param(..) - | hir::Node::Item(..) - | hir::Node::ForeignItem(..) - | hir::Node::TraitItem(..) - | hir::Node::ImplItem(..) - | hir::Node::Variant(..) - | hir::Node::Field(..) - | hir::Node::AnonConst(..) - | hir::Node::ConstBlock(..) - | hir::Node::Stmt(..) - | hir::Node::PathSegment(..) - | hir::Node::Ty(..) - | hir::Node::TypeBinding(..) - | hir::Node::TraitRef(..) - | hir::Node::Pat(..) - | hir::Node::PatField(..) - | hir::Node::ExprField(..) - | hir::Node::Arm(..) - | hir::Node::Local(..) - | hir::Node::Ctor(..) - | hir::Node::Lifetime(..) - | hir::Node::GenericParam(..) - | hir::Node::Crate(..) - | hir::Node::Infer(..) => bug!("Unsupported branch target: {:?}", node), - } - }) - } -} - -fn find_last_block_expression(block: &hir::Block<'_>) -> HirId { - block.expr.map_or_else( - // If there is no tail expression, there will be at least one statement in the - // block because the block contains a break or continue statement. - || block.stmts.last().unwrap().hir_id, - |expr| expr.hir_id, - ) -} - -impl<'a, 'tcx> Visitor<'tcx> for DropRangeVisitor<'a, 'tcx> { - fn visit_expr(&mut self, expr: &'tcx Expr<'tcx>) { - let mut reinit = None; - match expr.kind { - ExprKind::Assign(lhs, rhs, _) => { - self.visit_expr(rhs); - self.visit_expr(lhs); - - reinit = Some(lhs); - } - - ExprKind::If(test, if_true, if_false) => { - self.visit_expr(test); - - let fork = self.expr_index; - - self.drop_ranges.add_control_edge(fork, self.expr_index + 1); - self.visit_expr(if_true); - let true_end = self.expr_index; - - self.drop_ranges.add_control_edge(fork, self.expr_index + 1); - if let Some(if_false) = if_false { - self.visit_expr(if_false); - } - - self.drop_ranges.add_control_edge(true_end, self.expr_index + 1); - } - ExprKind::Match(scrutinee, arms, ..) => { - // We walk through the match expression almost like a chain of if expressions. - // Here's a diagram to follow along with: - // - // ┌─┐ - // match │A│ { - // ┌───┴─┘ - // │ - // ┌▼┌───►┌─┐ ┌─┐ - // │B│ if │C│ =>│D│, - // └─┘ ├─┴──►└─┴──────┐ - // ┌──┘ │ - // ┌──┘ │ - // │ │ - // ┌▼┌───►┌─┐ ┌─┐ │ - // │E│ if │F│ =>│G│, │ - // └─┘ ├─┴──►└─┴┐ │ - // │ │ │ - // } ▼ ▼ │ - // ┌─┐◄───────────────────┘ - // │H│ - // └─┘ - // - // The order we want is that the scrutinee (A) flows into the first pattern (B), - // which flows into the guard (C). Then the guard either flows into the arm body - // (D) or into the start of the next arm (E). Finally, the body flows to the end - // of the match block (H). - // - // The subsequent arms follow the same ordering. First we go to the pattern, then - // the guard (if present, otherwise it flows straight into the body), then into - // the body and then to the end of the match expression. - // - // The comments below show which edge is being added. - self.visit_expr(scrutinee); - - let (guard_exit, arm_end_ids) = arms.iter().fold( - (self.expr_index, vec![]), - |(incoming_edge, mut arm_end_ids), hir::Arm { pat, body, guard, .. }| { - // A -> B, or C -> E - self.drop_ranges.add_control_edge(incoming_edge, self.expr_index + 1); - self.visit_pat(pat); - // B -> C and E -> F are added implicitly due to the traversal order. - match guard { - Some(Guard::If(expr)) => self.visit_expr(expr), - Some(Guard::IfLet(let_expr)) => { - self.visit_let_expr(let_expr); - } - None => (), - } - // Likewise, C -> D and F -> G are added implicitly. - - // Save C, F, so we can add the other outgoing edge. - let to_next_arm = self.expr_index; - - // The default edge does not get added since we also have an explicit edge, - // so we also need to add an edge to the next node as well. - // - // This adds C -> D, F -> G - self.drop_ranges.add_control_edge(self.expr_index, self.expr_index + 1); - self.visit_expr(body); - - // Save the end of the body so we can add the exit edge once we know where - // the exit is. - arm_end_ids.push(self.expr_index); - - // Pass C to the next iteration, as well as vec![D] - // - // On the last round through, we pass F and vec![D, G] so that we can - // add all the exit edges. - (to_next_arm, arm_end_ids) - }, - ); - // F -> H - self.drop_ranges.add_control_edge(guard_exit, self.expr_index + 1); - - arm_end_ids.into_iter().for_each(|arm_end| { - // D -> H, G -> H - self.drop_ranges.add_control_edge(arm_end, self.expr_index + 1) - }); - } - - ExprKind::Loop(body, label, ..) => { - let loop_begin = self.expr_index + 1; - self.label_stack.push((label, loop_begin)); - if body.stmts.is_empty() && body.expr.is_none() { - // For empty loops we won't have updated self.expr_index after visiting the - // body, meaning we'd get an edge from expr_index to expr_index + 1, but - // instead we want an edge from expr_index + 1 to expr_index + 1. - self.drop_ranges.add_control_edge(loop_begin, loop_begin); - } else { - self.visit_block(body); - self.drop_ranges.add_control_edge(self.expr_index, loop_begin); - } - self.label_stack.pop(); - } - // Find the loop entry by searching through the label stack for either the last entry - // (if label is none), or the first entry where the label matches this one. The Loop - // case maintains this stack mapping labels to the PostOrderId for the loop entry. - ExprKind::Continue(hir::Destination { label, .. }, ..) => self - .label_stack - .iter() - .rev() - .find(|(loop_label, _)| label.is_none() || *loop_label == label) - .map_or((), |(_, target)| { - self.drop_ranges.add_control_edge(self.expr_index, *target) - }), - - ExprKind::Break(destination, value) => { - // destination either points to an expression or to a block. We use - // find_target_expression_from_destination to use the last expression of the block - // if destination points to a block. - // - // We add an edge to the hir_id of the expression/block we are breaking out of, and - // then in process_deferred_edges we will map this hir_id to its PostOrderId, which - // will refer to the end of the block due to the post order traversal. - if let Ok(target) = self.find_target_expression_from_destination(destination) { - self.drop_ranges.add_control_edge_hir_id(self.expr_index, target) - } - - if let Some(value) = value { - self.visit_expr(value); - } - } - - ExprKind::Become(_call) => bug!("encountered a tail-call inside a generator"), - - ExprKind::Call(f, args) => { - self.visit_expr(f); - for arg in args { - self.visit_expr(arg); - } - - self.handle_uninhabited_return(expr); - } - ExprKind::MethodCall(_, receiver, exprs, _) => { - self.visit_expr(receiver); - for expr in exprs { - self.visit_expr(expr); - } - - self.handle_uninhabited_return(expr); - } - - ExprKind::AddrOf(..) - | ExprKind::Array(..) - // FIXME(eholk): We probably need special handling for AssignOps. The ScopeTree builder - // in region.rs runs both lhs then rhs and rhs then lhs and then sets all yields to be - // the latest they show up in either traversal. With the older scope-based - // approximation, this was fine, but it's probably not right now. What we probably want - // to do instead is still run both orders, but consider anything that showed up as a - // yield in either order. - | ExprKind::AssignOp(..) - | ExprKind::Binary(..) - | ExprKind::Block(..) - | ExprKind::Cast(..) - | ExprKind::Closure { .. } - | ExprKind::ConstBlock(..) - | ExprKind::DropTemps(..) - | ExprKind::Err(_) - | ExprKind::Field(..) - | ExprKind::Index(..) - | ExprKind::InlineAsm(..) - | ExprKind::OffsetOf(..) - | ExprKind::Let(..) - | ExprKind::Lit(..) - | ExprKind::Path(..) - | ExprKind::Repeat(..) - | ExprKind::Ret(..) - | ExprKind::Struct(..) - | ExprKind::Tup(..) - | ExprKind::Type(..) - | ExprKind::Unary(..) - | ExprKind::Yield(..) => intravisit::walk_expr(self, expr), - } - - self.expr_index = self.expr_index + 1; - self.drop_ranges.add_node_mapping(expr.hir_id, self.expr_index); - self.consume_expr(expr); - if let Some(expr) = reinit { - self.reinit_expr(expr); - } - } - - fn visit_pat(&mut self, pat: &'tcx hir::Pat<'tcx>) { - intravisit::walk_pat(self, pat); - - // Increment expr_count here to match what InteriorVisitor expects. - self.expr_index = self.expr_index + 1; - - // Save a node mapping to get better CFG visualization - self.drop_ranges.add_node_mapping(pat.hir_id, self.expr_index); - } -} - -impl DropRangesBuilder { - fn new( - tracked_values: impl Iterator, - hir: Map<'_>, - num_exprs: usize, - ) -> Self { - let mut tracked_value_map = UnordMap::<_, TrackedValueIndex>::default(); - let mut next = <_>::from(0u32); - for value in tracked_values { - for_each_consumable(hir, value, |value| { - if let std::collections::hash_map::Entry::Vacant(e) = tracked_value_map.entry(value) - { - e.insert(next); - next = next + 1; - } - }); - } - debug!("hir_id_map: {:#?}", tracked_value_map); - let num_values = tracked_value_map.len(); - Self { - tracked_value_map, - nodes: IndexVec::from_fn_n(|_| NodeInfo::new(num_values), num_exprs + 1), - deferred_edges: <_>::default(), - post_order_map: <_>::default(), - } - } - - fn tracked_value_index(&self, tracked_value: TrackedValue) -> TrackedValueIndex { - *self.tracked_value_map.get(&tracked_value).unwrap() - } - - /// Adds an entry in the mapping from HirIds to PostOrderIds - /// - /// Needed so that `add_control_edge_hir_id` can work. - fn add_node_mapping(&mut self, node_hir_id: HirId, post_order_id: PostOrderId) { - self.post_order_map.insert(node_hir_id, post_order_id); - } - - /// Like add_control_edge, but uses a hir_id as the target. - /// - /// This can be used for branches where we do not know the PostOrderId of the target yet, - /// such as when handling `break` or `continue`. - fn add_control_edge_hir_id(&mut self, from: PostOrderId, to: HirId) { - self.deferred_edges.push((from, to)); - } - - fn drop_at(&mut self, value: TrackedValue, location: PostOrderId) { - let value = self.tracked_value_index(value); - self.node_mut(location).drops.push(value); - } - - fn reinit_at(&mut self, value: TrackedValue, location: PostOrderId) { - let value = match self.tracked_value_map.get(&value) { - Some(value) => *value, - // If there's no value, this is never consumed and therefore is never dropped. We can - // ignore this. - None => return, - }; - self.node_mut(location).reinits.push(value); - } - - /// Looks up PostOrderId for any control edges added by HirId and adds a proper edge for them. - /// - /// Should be called after visiting the HIR but before solving the control flow, otherwise some - /// edges will be missed. - fn process_deferred_edges(&mut self) { - trace!("processing deferred edges. post_order_map={:#?}", self.post_order_map); - let mut edges = vec![]; - swap(&mut edges, &mut self.deferred_edges); - edges.into_iter().for_each(|(from, to)| { - trace!("Adding deferred edge from {:?} to {:?}", from, to); - let to = *self.post_order_map.get(&to).expect("Expression ID not found"); - trace!("target edge PostOrderId={:?}", to); - self.add_control_edge(from, to) - }); - } -} diff --git a/compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/cfg_propagate.rs b/compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/cfg_propagate.rs deleted file mode 100644 index 633b478895b..00000000000 --- a/compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/cfg_propagate.rs +++ /dev/null @@ -1,92 +0,0 @@ -use super::{DropRangesBuilder, PostOrderId}; -use rustc_index::{bit_set::BitSet, IndexVec}; -use std::collections::BTreeMap; - -impl DropRangesBuilder { - pub fn propagate_to_fixpoint(&mut self) { - trace!("before fixpoint: {:#?}", self); - let preds = self.compute_predecessors(); - - trace!("predecessors: {:#?}", preds.iter_enumerated().collect::>()); - - let mut new_state = BitSet::new_empty(self.num_values()); - let mut changed_nodes = BitSet::new_empty(self.nodes.len()); - let mut unchanged_mask = BitSet::new_filled(self.nodes.len()); - changed_nodes.insert(0u32.into()); - - let mut propagate = || { - let mut changed = false; - unchanged_mask.insert_all(); - for id in self.nodes.indices() { - trace!("processing {:?}, changed_nodes: {:?}", id, changed_nodes); - // Check if any predecessor has changed, and if not then short-circuit. - // - // We handle the start node specially, since it doesn't have any predecessors, - // but we need to start somewhere. - if match id.index() { - 0 => !changed_nodes.contains(id), - _ => !preds[id].iter().any(|pred| changed_nodes.contains(*pred)), - } { - trace!("short-circuiting because none of {:?} have changed", preds[id]); - unchanged_mask.remove(id); - continue; - } - - if id.index() == 0 { - new_state.clear(); - } else { - // If we are not the start node and we have no predecessors, treat - // everything as dropped because there's no way to get here anyway. - new_state.insert_all(); - }; - - for pred in &preds[id] { - new_state.intersect(&self.nodes[*pred].drop_state); - } - - for drop in &self.nodes[id].drops { - new_state.insert(*drop); - } - - for reinit in &self.nodes[id].reinits { - new_state.remove(*reinit); - } - - if self.nodes[id].drop_state.intersect(&new_state) { - changed_nodes.insert(id); - changed = true; - } else { - unchanged_mask.remove(id); - } - } - - changed_nodes.intersect(&unchanged_mask); - changed - }; - - while propagate() { - trace!("drop_state changed, re-running propagation"); - } - - trace!("after fixpoint: {:#?}", self); - } - - fn compute_predecessors(&self) -> IndexVec> { - let mut preds = IndexVec::from_fn_n(|_| vec![], self.nodes.len()); - for (id, node) in self.nodes.iter_enumerated() { - // If the node has no explicit successors, we assume that control - // will from this node into the next one. - // - // If there are successors listed, then we assume that all - // possible successors are given and we do not include the default. - if node.successors.len() == 0 && id.index() != self.nodes.len() - 1 { - preds[id + 1].push(id); - } else { - for succ in &node.successors { - preds[*succ].push(id); - } - } - } - preds - } -} diff --git a/compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/cfg_visualize.rs b/compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/cfg_visualize.rs deleted file mode 100644 index e8d31be79d9..00000000000 --- a/compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/cfg_visualize.rs +++ /dev/null @@ -1,96 +0,0 @@ -//! Implementation of GraphWalk for DropRanges so we can visualize the control -//! flow graph when needed for debugging. - -use rustc_graphviz as dot; -use rustc_hir::{Expr, ExprKind, Node}; -use rustc_middle::ty::TyCtxt; - -use super::{DropRangesBuilder, PostOrderId}; - -/// Writes the CFG for DropRangesBuilder to a .dot file for visualization. -/// -/// It is not normally called, but is kept around to easily add debugging -/// code when needed. -pub(super) fn write_graph_to_file( - drop_ranges: &DropRangesBuilder, - filename: &str, - tcx: TyCtxt<'_>, -) { - dot::render( - &DropRangesGraph { drop_ranges, tcx }, - &mut std::fs::File::create(filename).unwrap(), - ) - .unwrap(); -} - -struct DropRangesGraph<'a, 'tcx> { - drop_ranges: &'a DropRangesBuilder, - tcx: TyCtxt<'tcx>, -} - -impl<'a> dot::GraphWalk<'a> for DropRangesGraph<'_, '_> { - type Node = PostOrderId; - - type Edge = (PostOrderId, PostOrderId); - - fn nodes(&'a self) -> dot::Nodes<'a, Self::Node> { - self.drop_ranges.nodes.iter_enumerated().map(|(i, _)| i).collect() - } - - fn edges(&'a self) -> dot::Edges<'a, Self::Edge> { - self.drop_ranges - .nodes - .iter_enumerated() - .flat_map(|(i, node)| { - if node.successors.len() == 0 { - vec![(i, i + 1)] - } else { - node.successors.iter().map(move |&s| (i, s)).collect() - } - }) - .collect() - } - - fn source(&'a self, edge: &Self::Edge) -> Self::Node { - edge.0 - } - - fn target(&'a self, edge: &Self::Edge) -> Self::Node { - edge.1 - } -} - -impl<'a> dot::Labeller<'a> for DropRangesGraph<'_, '_> { - type Node = PostOrderId; - - type Edge = (PostOrderId, PostOrderId); - - fn graph_id(&'a self) -> dot::Id<'a> { - dot::Id::new("drop_ranges").unwrap() - } - - fn node_id(&'a self, n: &Self::Node) -> dot::Id<'a> { - dot::Id::new(format!("id{}", n.index())).unwrap() - } - - fn node_label(&'a self, n: &Self::Node) -> dot::LabelText<'a> { - dot::LabelText::LabelStr( - format!( - "{n:?}: {}", - self.drop_ranges - .post_order_map - .iter() - .find(|(_hir_id, &post_order_id)| post_order_id == *n) - .map_or("".into(), |(hir_id, _)| format!( - "{}{}", - self.tcx.hir().node_to_string(*hir_id), - match self.tcx.hir().find(*hir_id) { - Some(Node::Expr(Expr { kind: ExprKind::Yield(..), .. })) => " (yield)", - _ => "", - } - )) - ) - .into(), - ) - } -} diff --git a/compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/mod.rs b/compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/mod.rs deleted file mode 100644 index e563bd40b65..00000000000 --- a/compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/mod.rs +++ /dev/null @@ -1,306 +0,0 @@ -//! Drop range analysis finds the portions of the tree where a value is guaranteed to be dropped -//! (i.e. moved, uninitialized, etc.). This is used to exclude the types of those values from the -//! generator type. See `InteriorVisitor::record` for where the results of this analysis are used. -//! -//! There are three phases to this analysis: -//! 1. Use `ExprUseVisitor` to identify the interesting values that are consumed and borrowed. -//! 2. Use `DropRangeVisitor` to find where the interesting values are dropped or reinitialized, -//! and also build a control flow graph. -//! 3. Use `DropRanges::propagate_to_fixpoint` to flow the dropped/reinitialized information through -//! the CFG and find the exact points where we know a value is definitely dropped. -//! -//! The end result is a data structure that maps the post-order index of each node in the HIR tree -//! to a set of values that are known to be dropped at that location. - -use self::cfg_build::build_control_flow_graph; -use self::record_consumed_borrow::find_consumed_and_borrowed; -use crate::FnCtxt; -use hir::def_id::DefId; -use hir::{Body, HirId, HirIdMap, Node}; -use rustc_data_structures::unord::{UnordMap, UnordSet}; -use rustc_hir as hir; -use rustc_index::bit_set::BitSet; -use rustc_index::IndexVec; -use rustc_middle::hir::map::Map; -use rustc_middle::hir::place::{PlaceBase, PlaceWithHirId}; -use rustc_middle::ty; -use std::collections::BTreeMap; -use std::fmt::Debug; - -mod cfg_build; -mod cfg_propagate; -mod cfg_visualize; -mod record_consumed_borrow; - -pub fn compute_drop_ranges<'a, 'tcx>( - fcx: &'a FnCtxt<'a, 'tcx>, - def_id: DefId, - body: &'tcx Body<'tcx>, -) -> DropRanges { - if fcx.sess().opts.unstable_opts.drop_tracking { - let consumed_borrowed_places = find_consumed_and_borrowed(fcx, def_id, body); - - let typeck_results = &fcx.typeck_results.borrow(); - let num_exprs = fcx.tcx.region_scope_tree(def_id).body_expr_count(body.id()).unwrap_or(0); - let (mut drop_ranges, borrowed_temporaries) = build_control_flow_graph( - &fcx, - typeck_results, - fcx.param_env, - consumed_borrowed_places, - body, - num_exprs, - ); - - drop_ranges.propagate_to_fixpoint(); - - debug!("borrowed_temporaries = {borrowed_temporaries:?}"); - DropRanges { - tracked_value_map: drop_ranges.tracked_value_map, - nodes: drop_ranges.nodes, - borrowed_temporaries: Some(borrowed_temporaries), - } - } else { - // If drop range tracking is not enabled, skip all the analysis and produce an - // empty set of DropRanges. - DropRanges { - tracked_value_map: UnordMap::default(), - nodes: IndexVec::new(), - borrowed_temporaries: None, - } - } -} - -/// Applies `f` to consumable node in the HIR subtree pointed to by `place`. -/// -/// This includes the place itself, and if the place is a reference to a local -/// variable then `f` is also called on the HIR node for that variable as well. -/// -/// For example, if `place` points to `foo()`, then `f` is called once for the -/// result of `foo`. On the other hand, if `place` points to `x` then `f` will -/// be called both on the `ExprKind::Path` node that represents the expression -/// as well as the HirId of the local `x` itself. -fn for_each_consumable(hir: Map<'_>, place: TrackedValue, mut f: impl FnMut(TrackedValue)) { - f(place); - let node = hir.find(place.hir_id()); - if let Some(Node::Expr(expr)) = node { - match expr.kind { - hir::ExprKind::Path(hir::QPath::Resolved( - _, - hir::Path { res: hir::def::Res::Local(hir_id), .. }, - )) => { - f(TrackedValue::Variable(*hir_id)); - } - _ => (), - } - } -} - -rustc_index::newtype_index! { - #[debug_format = "id({})"] - pub struct PostOrderId {} -} - -rustc_index::newtype_index! { - #[debug_format = "hidx({})"] - pub struct TrackedValueIndex {} -} - -/// Identifies a value whose drop state we need to track. -#[derive(PartialEq, Eq, Hash, Clone, Copy)] -enum TrackedValue { - /// Represents a named variable, such as a let binding, parameter, or upvar. - /// - /// The HirId points to the variable's definition site. - Variable(HirId), - /// A value produced as a result of an expression. - /// - /// The HirId points to the expression that returns this value. - Temporary(HirId), -} - -impl Debug for TrackedValue { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - ty::tls::with_opt(|opt_tcx| { - if let Some(tcx) = opt_tcx { - write!(f, "{}", tcx.hir().node_to_string(self.hir_id())) - } else { - match self { - Self::Variable(hir_id) => write!(f, "Variable({hir_id:?})"), - Self::Temporary(hir_id) => write!(f, "Temporary({hir_id:?})"), - } - } - }) - } -} - -impl TrackedValue { - fn hir_id(&self) -> HirId { - match self { - TrackedValue::Variable(hir_id) | TrackedValue::Temporary(hir_id) => *hir_id, - } - } - - fn from_place_with_projections_allowed(place_with_id: &PlaceWithHirId<'_>) -> Self { - match place_with_id.place.base { - PlaceBase::Rvalue | PlaceBase::StaticItem => { - TrackedValue::Temporary(place_with_id.hir_id) - } - PlaceBase::Local(hir_id) - | PlaceBase::Upvar(ty::UpvarId { var_path: ty::UpvarPath { hir_id }, .. }) => { - TrackedValue::Variable(hir_id) - } - } - } -} - -/// Represents a reason why we might not be able to convert a HirId or Place -/// into a tracked value. -#[derive(Debug)] -enum TrackedValueConversionError { - /// Place projects are not currently supported. - /// - /// The reasoning around these is kind of subtle, so we choose to be more - /// conservative around these for now. There is no reason in theory we - /// cannot support these, we just have not implemented it yet. - PlaceProjectionsNotSupported, -} - -impl TryFrom<&PlaceWithHirId<'_>> for TrackedValue { - type Error = TrackedValueConversionError; - - fn try_from(place_with_id: &PlaceWithHirId<'_>) -> Result { - if !place_with_id.place.projections.is_empty() { - debug!( - "TrackedValue from PlaceWithHirId: {:?} has projections, which are not supported.", - place_with_id - ); - return Err(TrackedValueConversionError::PlaceProjectionsNotSupported); - } - - Ok(TrackedValue::from_place_with_projections_allowed(place_with_id)) - } -} - -pub struct DropRanges { - tracked_value_map: UnordMap, - nodes: IndexVec, - borrowed_temporaries: Option>, -} - -impl DropRanges { - pub fn is_dropped_at(&self, hir_id: HirId, location: usize) -> bool { - self.tracked_value_map - .get(&TrackedValue::Temporary(hir_id)) - .or(self.tracked_value_map.get(&TrackedValue::Variable(hir_id))) - .cloned() - .is_some_and(|tracked_value_id| { - self.expect_node(location.into()).drop_state.contains(tracked_value_id) - }) - } - - pub fn is_borrowed_temporary(&self, expr: &hir::Expr<'_>) -> bool { - if let Some(b) = &self.borrowed_temporaries { b.contains(&expr.hir_id) } else { true } - } - - /// Returns a reference to the NodeInfo for a node, panicking if it does not exist - fn expect_node(&self, id: PostOrderId) -> &NodeInfo { - &self.nodes[id] - } -} - -/// Tracks information needed to compute drop ranges. -struct DropRangesBuilder { - /// The core of DropRangesBuilder is a set of nodes, which each represent - /// one expression. We primarily refer to them by their index in a - /// post-order traversal of the HIR tree, since this is what - /// generator_interior uses to talk about yield positions. - /// - /// This IndexVec keeps the relevant details for each node. See the - /// NodeInfo struct for more details, but this information includes things - /// such as the set of control-flow successors, which variables are dropped - /// or reinitialized, and whether each variable has been inferred to be - /// known-dropped or potentially reinitialized at each point. - nodes: IndexVec, - /// We refer to values whose drop state we are tracking by the HirId of - /// where they are defined. Within a NodeInfo, however, we store the - /// drop-state in a bit vector indexed by a HirIdIndex - /// (see NodeInfo::drop_state). The hir_id_map field stores the mapping - /// from HirIds to the HirIdIndex that is used to represent that value in - /// bitvector. - tracked_value_map: UnordMap, - - /// When building the control flow graph, we don't always know the - /// post-order index of the target node at the point we encounter it. - /// For example, this happens with break and continue. In those cases, - /// we store a pair of the PostOrderId of the source and the HirId - /// of the target. Once we have gathered all of these edges, we make a - /// pass over the set of deferred edges (see process_deferred_edges in - /// cfg_build.rs), look up the PostOrderId for the target (since now the - /// post-order index for all nodes is known), and add missing control flow - /// edges. - deferred_edges: Vec<(PostOrderId, HirId)>, - /// This maps HirIds of expressions to their post-order index. It is - /// used in process_deferred_edges to correctly add back-edges. - post_order_map: HirIdMap, -} - -impl Debug for DropRangesBuilder { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.debug_struct("DropRanges") - .field("hir_id_map", &self.tracked_value_map) - .field("post_order_maps", &self.post_order_map) - .field("nodes", &self.nodes.iter_enumerated().collect::>()) - .finish() - } -} - -/// DropRanges keeps track of what values are definitely dropped at each point in the code. -/// -/// Values of interest are defined by the hir_id of their place. Locations in code are identified -/// by their index in the post-order traversal. At its core, DropRanges maps -/// (hir_id, post_order_id) -> bool, where a true value indicates that the value is definitely -/// dropped at the point of the node identified by post_order_id. -impl DropRangesBuilder { - /// Returns the number of values (hir_ids) that are tracked - fn num_values(&self) -> usize { - self.tracked_value_map.len() - } - - fn node_mut(&mut self, id: PostOrderId) -> &mut NodeInfo { - let size = self.num_values(); - self.nodes.ensure_contains_elem(id, || NodeInfo::new(size)) - } - - fn add_control_edge(&mut self, from: PostOrderId, to: PostOrderId) { - trace!("adding control edge from {:?} to {:?}", from, to); - self.node_mut(from).successors.push(to); - } -} - -#[derive(Debug)] -struct NodeInfo { - /// IDs of nodes that can follow this one in the control flow - /// - /// If the vec is empty, then control proceeds to the next node. - successors: Vec, - - /// List of hir_ids that are dropped by this node. - drops: Vec, - - /// List of hir_ids that are reinitialized by this node. - reinits: Vec, - - /// Set of values that are definitely dropped at this point. - drop_state: BitSet, -} - -impl NodeInfo { - fn new(num_values: usize) -> Self { - Self { - successors: vec![], - drops: vec![], - reinits: vec![], - drop_state: BitSet::new_filled(num_values), - } - } -} diff --git a/compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/record_consumed_borrow.rs b/compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/record_consumed_borrow.rs deleted file mode 100644 index 29413f08012..00000000000 --- a/compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/record_consumed_borrow.rs +++ /dev/null @@ -1,242 +0,0 @@ -use super::TrackedValue; -use crate::{ - expr_use_visitor::{self, ExprUseVisitor}, - FnCtxt, -}; -use hir::{def_id::DefId, Body, HirId, HirIdMap}; -use rustc_data_structures::{fx::FxIndexSet, unord::UnordSet}; -use rustc_hir as hir; -use rustc_middle::ty::{ParamEnv, TyCtxt}; -use rustc_middle::{ - hir::place::{PlaceBase, Projection, ProjectionKind}, - ty::TypeVisitableExt, -}; - -pub(super) fn find_consumed_and_borrowed<'a, 'tcx>( - fcx: &'a FnCtxt<'a, 'tcx>, - def_id: DefId, - body: &'tcx Body<'tcx>, -) -> ConsumedAndBorrowedPlaces { - let mut expr_use_visitor = ExprUseDelegate::new(fcx.tcx, fcx.param_env); - expr_use_visitor.consume_body(fcx, def_id, body); - expr_use_visitor.places -} - -pub(super) struct ConsumedAndBorrowedPlaces { - /// Records the variables/expressions that are dropped by a given expression. - /// - /// The key is the hir-id of the expression, and the value is a set or hir-ids for variables - /// or values that are consumed by that expression. - /// - /// Note that this set excludes "partial drops" -- for example, a statement like `drop(x.y)` is - /// not considered a drop of `x`, although it would be a drop of `x.y`. - pub(super) consumed: HirIdMap>, - - /// A set of hir-ids of values or variables that are borrowed at some point within the body. - pub(super) borrowed: UnordSet, - - /// A set of hir-ids of values or variables that are borrowed at some point within the body. - pub(super) borrowed_temporaries: UnordSet, -} - -/// Works with ExprUseVisitor to find interesting values for the drop range analysis. -/// -/// Interesting values are those that are either dropped or borrowed. For dropped values, we also -/// record the parent expression, which is the point where the drop actually takes place. -struct ExprUseDelegate<'tcx> { - tcx: TyCtxt<'tcx>, - param_env: ParamEnv<'tcx>, - places: ConsumedAndBorrowedPlaces, -} - -impl<'tcx> ExprUseDelegate<'tcx> { - fn new(tcx: TyCtxt<'tcx>, param_env: ParamEnv<'tcx>) -> Self { - Self { - tcx, - param_env, - places: ConsumedAndBorrowedPlaces { - consumed: <_>::default(), - borrowed: <_>::default(), - borrowed_temporaries: <_>::default(), - }, - } - } - - fn consume_body(&mut self, fcx: &'_ FnCtxt<'_, 'tcx>, def_id: DefId, body: &'tcx Body<'tcx>) { - // Run ExprUseVisitor to find where values are consumed. - ExprUseVisitor::new( - self, - &fcx.infcx, - def_id.expect_local(), - fcx.param_env, - &fcx.typeck_results.borrow(), - ) - .consume_body(body); - } - - fn mark_consumed(&mut self, consumer: HirId, target: TrackedValue) { - self.places.consumed.entry(consumer).or_insert_with(|| <_>::default()); - - debug!(?consumer, ?target, "mark_consumed"); - self.places.consumed.get_mut(&consumer).map(|places| places.insert(target)); - } - - fn borrow_place(&mut self, place_with_id: &expr_use_visitor::PlaceWithHirId<'tcx>) { - self.places - .borrowed - .insert(TrackedValue::from_place_with_projections_allowed(place_with_id)); - - // Ordinarily a value is consumed by it's parent, but in the special case of a - // borrowed RValue, we create a reference that lives as long as the temporary scope - // for that expression (typically, the innermost statement, but sometimes the enclosing - // block). We record this fact here so that later in generator_interior - // we can use the correct scope. - // - // We special case borrows through a dereference (`&*x`, `&mut *x` where `x` is - // some rvalue expression), since these are essentially a copy of a pointer. - // In other words, this borrow does not refer to the - // temporary (`*x`), but to the referent (whatever `x` is a borrow of). - // - // We were considering that we might encounter problems down the line if somehow, - // some part of the compiler were to look at this result and try to use it to - // drive a borrowck-like analysis (this does not currently happen, as of this writing). - // But even this should be fine, because the lifetime of the dereferenced reference - // found in the rvalue is only significant as an intermediate 'link' to the value we - // are producing, and we separately track whether that value is live over a yield. - // Example: - // - // ```notrust - // fn identity(x: &mut T) -> &mut T { x } - // let a: A = ...; - // let y: &'y mut A = &mut *identity(&'a mut a); - // ^^^^^^^^^^^^^^^^^^^^^^^^^ the borrow we are talking about - // ``` - // - // The expression `*identity(...)` is a deref of an rvalue, - // where the `identity(...)` (the rvalue) produces a return type - // of `&'rv mut A`, where `'a: 'rv`. We then assign this result to - // `'y`, resulting in (transitively) `'a: 'y` (i.e., while `y` is in use, - // `a` will be considered borrowed). Other parts of the code will ensure - // that if `y` is live over a yield, `&'y mut A` appears in the generator - // state. If `'y` is live, then any sound region analysis must conclude - // that `'a` is also live. So if this causes a bug, blame some other - // part of the code! - let is_deref = place_with_id - .place - .projections - .iter() - .any(|Projection { kind, .. }| *kind == ProjectionKind::Deref); - - if let (false, PlaceBase::Rvalue) = (is_deref, place_with_id.place.base) { - self.places.borrowed_temporaries.insert(place_with_id.hir_id); - } - } -} - -impl<'tcx> expr_use_visitor::Delegate<'tcx> for ExprUseDelegate<'tcx> { - fn consume( - &mut self, - place_with_id: &expr_use_visitor::PlaceWithHirId<'tcx>, - diag_expr_id: HirId, - ) { - let hir = self.tcx.hir(); - let parent = match hir.opt_parent_id(place_with_id.hir_id) { - Some(parent) => parent, - None => place_with_id.hir_id, - }; - debug!( - "consume {:?}; diag_expr_id={}, using parent {}", - place_with_id, - hir.node_to_string(diag_expr_id), - hir.node_to_string(parent) - ); - - if let Ok(tracked_value) = place_with_id.try_into() { - self.mark_consumed(parent, tracked_value) - } - } - - fn borrow( - &mut self, - place_with_id: &expr_use_visitor::PlaceWithHirId<'tcx>, - diag_expr_id: HirId, - bk: rustc_middle::ty::BorrowKind, - ) { - debug!( - "borrow: place_with_id = {place_with_id:#?}, diag_expr_id={diag_expr_id:#?}, \ - borrow_kind={bk:#?}" - ); - - self.borrow_place(place_with_id); - } - - fn copy( - &mut self, - place_with_id: &expr_use_visitor::PlaceWithHirId<'tcx>, - _diag_expr_id: HirId, - ) { - debug!("copy: place_with_id = {place_with_id:?}"); - - self.places - .borrowed - .insert(TrackedValue::from_place_with_projections_allowed(place_with_id)); - - // For copied we treat this mostly like a borrow except that we don't add the place - // to borrowed_temporaries because the copy is consumed. - } - - fn mutate( - &mut self, - assignee_place: &expr_use_visitor::PlaceWithHirId<'tcx>, - diag_expr_id: HirId, - ) { - debug!("mutate {assignee_place:?}; diag_expr_id={diag_expr_id:?}"); - - if assignee_place.place.base == PlaceBase::Rvalue - && assignee_place.place.projections.is_empty() - { - // Assigning to an Rvalue is illegal unless done through a dereference. We would have - // already gotten a type error, so we will just return here. - return; - } - - // If the type being assigned needs dropped, then the mutation counts as a borrow - // since it is essentially doing `Drop::drop(&mut x); x = new_value;`. - let ty = self.tcx.erase_regions(assignee_place.place.base_ty); - if ty.has_infer() { - self.tcx.sess.delay_span_bug( - self.tcx.hir().span(assignee_place.hir_id), - format!("inference variables in {ty}"), - ); - } else if ty.needs_drop(self.tcx, self.param_env) { - self.places - .borrowed - .insert(TrackedValue::from_place_with_projections_allowed(assignee_place)); - } - } - - fn bind( - &mut self, - binding_place: &expr_use_visitor::PlaceWithHirId<'tcx>, - diag_expr_id: HirId, - ) { - debug!("bind {binding_place:?}; diag_expr_id={diag_expr_id:?}"); - } - - fn fake_read( - &mut self, - place_with_id: &expr_use_visitor::PlaceWithHirId<'tcx>, - cause: rustc_middle::mir::FakeReadCause, - diag_expr_id: HirId, - ) { - debug!( - "fake_read place_with_id={place_with_id:?}; cause={cause:?}; diag_expr_id={diag_expr_id:?}" - ); - - // fake reads happen in places like the scrutinee of a match expression. - // we treat those as a borrow, much like a copy: the idea is that we are - // transiently creating a `&T` ref that we can read from to observe the current - // value (this `&T` is immediately dropped afterwards). - self.borrow_place(place_with_id); - } -} diff --git a/compiler/rustc_hir_typeck/src/generator_interior/mod.rs b/compiler/rustc_hir_typeck/src/generator_interior/mod.rs deleted file mode 100644 index d2ab5aa6bae..00000000000 --- a/compiler/rustc_hir_typeck/src/generator_interior/mod.rs +++ /dev/null @@ -1,723 +0,0 @@ -//! This calculates the types which has storage which lives across a suspension point in a -//! generator from the perspective of typeck. The actual types used at runtime -//! is calculated in `rustc_mir_transform::generator` and may be a subset of the -//! types computed here. - -use self::drop_ranges::DropRanges; -use super::FnCtxt; -use rustc_data_structures::fx::{FxHashSet, FxIndexSet}; -use rustc_errors::{pluralize, DelayDm}; -use rustc_hir as hir; -use rustc_hir::def::{CtorKind, DefKind, Res}; -use rustc_hir::def_id::{DefId, LocalDefId}; -use rustc_hir::hir_id::HirIdSet; -use rustc_hir::intravisit::{self, Visitor}; -use rustc_hir::{Arm, Expr, ExprKind, Guard, HirId, Pat, PatKind}; -use rustc_infer::infer::{DefineOpaqueTypes, RegionVariableOrigin}; -use rustc_middle::middle::region::{self, Scope, ScopeData, YieldData}; -use rustc_middle::traits::ObligationCauseCode; -use rustc_middle::ty::fold::FnMutDelegate; -use rustc_middle::ty::{self, BoundVariableKind, RvalueScopes, Ty, TyCtxt, TypeVisitableExt}; -use rustc_span::symbol::sym; -use rustc_span::Span; -use smallvec::{smallvec, SmallVec}; - -mod drop_ranges; - -struct InteriorVisitor<'a, 'tcx> { - fcx: &'a FnCtxt<'a, 'tcx>, - region_scope_tree: &'a region::ScopeTree, - types: FxIndexSet>, - rvalue_scopes: &'a RvalueScopes, - expr_count: usize, - kind: hir::GeneratorKind, - prev_unresolved_span: Option, - linted_values: HirIdSet, - drop_ranges: DropRanges, -} - -impl<'a, 'tcx> InteriorVisitor<'a, 'tcx> { - fn record( - &mut self, - ty: Ty<'tcx>, - hir_id: HirId, - scope: Option, - expr: Option<&'tcx Expr<'tcx>>, - source_span: Span, - ) { - use rustc_span::DUMMY_SP; - - let ty = self.fcx.resolve_vars_if_possible(ty); - - debug!( - "attempting to record type ty={:?}; hir_id={:?}; scope={:?}; expr={:?}; source_span={:?}; expr_count={:?}", - ty, hir_id, scope, expr, source_span, self.expr_count, - ); - - let live_across_yield = scope - .map(|s| { - self.region_scope_tree.yield_in_scope(s).and_then(|yield_data| { - // If we are recording an expression that is the last yield - // in the scope, or that has a postorder CFG index larger - // than the one of all of the yields, then its value can't - // be storage-live (and therefore live) at any of the yields. - // - // See the mega-comment at `yield_in_scope` for a proof. - - yield_data - .iter() - .find(|yield_data| { - debug!( - "comparing counts yield: {} self: {}, source_span = {:?}", - yield_data.expr_and_pat_count, self.expr_count, source_span - ); - - if self - .is_dropped_at_yield_location(hir_id, yield_data.expr_and_pat_count) - { - debug!("value is dropped at yield point; not recording"); - return false; - } - - // If it is a borrowing happening in the guard, - // it needs to be recorded regardless because they - // do live across this yield point. - yield_data.expr_and_pat_count >= self.expr_count - }) - .cloned() - }) - }) - .unwrap_or_else(|| { - Some(YieldData { span: DUMMY_SP, expr_and_pat_count: 0, source: self.kind.into() }) - }); - - if let Some(yield_data) = live_across_yield { - debug!( - "type in expr = {:?}, scope = {:?}, type = {:?}, count = {}, yield_span = {:?}", - expr, scope, ty, self.expr_count, yield_data.span - ); - - if let Some((unresolved_term, unresolved_type_span)) = - self.fcx.first_unresolved_const_or_ty_var(&ty) - { - // If unresolved type isn't a ty_var then unresolved_type_span is None - let span = self - .prev_unresolved_span - .unwrap_or_else(|| unresolved_type_span.unwrap_or(source_span)); - - // If we encounter an int/float variable, then inference fallback didn't - // finish due to some other error. Don't emit spurious additional errors. - if let Some(unresolved_ty) = unresolved_term.ty() - && let ty::Infer(ty::InferTy::IntVar(_) | ty::InferTy::FloatVar(_)) = unresolved_ty.kind() - { - self.fcx - .tcx - .sess - .delay_span_bug(span, format!("Encountered var {unresolved_term:?}")); - } else { - let note = format!( - "the type is part of the {} because of this {}", - self.kind.descr(), - yield_data.source - ); - - self.fcx - .need_type_info_err_in_generator(self.kind, span, unresolved_term) - .span_note(yield_data.span, note) - .emit(); - } - } else { - // Insert the type into the ordered set. - let scope_span = scope.map(|s| s.span(self.fcx.tcx, self.region_scope_tree)); - - if !self.linted_values.contains(&hir_id) { - check_must_not_suspend_ty( - self.fcx, - ty, - hir_id, - SuspendCheckData { - expr, - source_span, - yield_span: yield_data.span, - plural_len: 1, - ..Default::default() - }, - ); - self.linted_values.insert(hir_id); - } - - self.types.insert(ty::GeneratorInteriorTypeCause { - span: source_span, - ty, - scope_span, - yield_span: yield_data.span, - expr: expr.map(|e| e.hir_id), - }); - } - } else { - debug!( - "no type in expr = {:?}, count = {:?}, span = {:?}", - expr, - self.expr_count, - expr.map(|e| e.span) - ); - if let Some((unresolved_type, unresolved_type_span)) = - self.fcx.first_unresolved_const_or_ty_var(&ty) - { - debug!( - "remained unresolved_type = {:?}, unresolved_type_span: {:?}", - unresolved_type, unresolved_type_span - ); - self.prev_unresolved_span = unresolved_type_span; - } - } - } - - /// If drop tracking is enabled, consult drop_ranges to see if a value is - /// known to be dropped at a yield point and therefore can be omitted from - /// the generator witness. - fn is_dropped_at_yield_location(&self, value_hir_id: HirId, yield_location: usize) -> bool { - // short-circuit if drop tracking is not enabled. - if !self.fcx.sess().opts.unstable_opts.drop_tracking { - return false; - } - - self.drop_ranges.is_dropped_at(value_hir_id, yield_location) - } -} - -pub fn resolve_interior<'a, 'tcx>( - fcx: &'a FnCtxt<'a, 'tcx>, - def_id: DefId, - generator_def_id: LocalDefId, - body_id: hir::BodyId, - interior: Ty<'tcx>, - kind: hir::GeneratorKind, -) { - let body = fcx.tcx.hir().body(body_id); - let typeck_results = fcx.inh.typeck_results.borrow(); - let mut visitor = InteriorVisitor { - fcx, - types: FxIndexSet::default(), - region_scope_tree: fcx.tcx.region_scope_tree(def_id), - rvalue_scopes: &typeck_results.rvalue_scopes, - expr_count: 0, - kind, - prev_unresolved_span: None, - linted_values: <_>::default(), - drop_ranges: drop_ranges::compute_drop_ranges(fcx, def_id, body), - }; - intravisit::walk_body(&mut visitor, body); - - // Check that we visited the same amount of expressions as the RegionResolutionVisitor - let region_expr_count = fcx.tcx.region_scope_tree(def_id).body_expr_count(body_id).unwrap(); - assert_eq!(region_expr_count, visitor.expr_count); - - // The types are already kept in insertion order. - let types = visitor.types; - - if fcx.tcx.features().unsized_locals || fcx.tcx.features().unsized_fn_params { - for interior_ty in &types { - fcx.require_type_is_sized( - interior_ty.ty, - interior_ty.span, - ObligationCauseCode::SizedGeneratorInterior(generator_def_id), - ); - } - } - - // The types in the generator interior contain lifetimes local to the generator itself, - // which should not be exposed outside of the generator. Therefore, we replace these - // lifetimes with existentially-bound lifetimes, which reflect the exact value of the - // lifetimes not being known by users. - // - // These lifetimes are used in auto trait impl checking (for example, - // if a Sync generator contains an &'α T, we need to check whether &'α T: Sync), - // so knowledge of the exact relationships between them isn't particularly important. - - debug!("types in generator {:?}, span = {:?}", types, body.value.span); - - // We want to deduplicate if the lifetimes are the same modulo some non-informative counter. - // So, we need to actually do two passes: first by type to anonymize (preserving information - // required for diagnostics), then a second pass over all captured types to reassign disjoint - // region indices. - let mut captured_tys = FxHashSet::default(); - let type_causes: Vec<_> = types - .into_iter() - .filter_map(|mut cause| { - // Replace all regions inside the generator interior with late bound regions. - // Note that each region slot in the types gets a new fresh late bound region, - // which means that none of the regions inside relate to any other, even if - // typeck had previously found constraints that would cause them to be related. - - let mut counter = 0; - let mut mk_bound_region = |kind| { - let var = ty::BoundVar::from_u32(counter); - counter += 1; - ty::BoundRegion { var, kind } - }; - let ty = fcx.normalize(cause.span, cause.ty); - let ty = fcx.tcx.fold_regions(ty, |region, current_depth| { - let br = match region.kind() { - ty::ReVar(vid) => { - let origin = fcx.region_var_origin(vid); - match origin { - RegionVariableOrigin::EarlyBoundRegion(span, _) => { - mk_bound_region(ty::BrAnon(Some(span))) - } - _ => mk_bound_region(ty::BrAnon(None)), - } - } - ty::ReEarlyBound(region) => { - mk_bound_region(ty::BrNamed(region.def_id, region.name)) - } - ty::ReLateBound(_, ty::BoundRegion { kind, .. }) - | ty::ReFree(ty::FreeRegion { bound_region: kind, .. }) => match kind { - ty::BoundRegionKind::BrAnon(span) => mk_bound_region(ty::BrAnon(span)), - ty::BoundRegionKind::BrNamed(def_id, sym) => { - mk_bound_region(ty::BrNamed(def_id, sym)) - } - ty::BoundRegionKind::BrEnv => mk_bound_region(ty::BrAnon(None)), - }, - _ => mk_bound_region(ty::BrAnon(None)), - }; - let r = ty::Region::new_late_bound(fcx.tcx, current_depth, br); - r - }); - captured_tys.insert(ty).then(|| { - cause.ty = ty; - cause - }) - }) - .collect(); - - let mut bound_vars: SmallVec<[BoundVariableKind; 4]> = smallvec![]; - let mut counter = 0; - // Optimization: If there is only one captured type, then we don't actually - // need to fold and reindex (since the first type doesn't change). - let type_causes = if captured_tys.len() > 0 { - // Optimization: Use `replace_escaping_bound_vars_uncached` instead of - // `fold_regions`, since we only have late bound regions, and it skips - // types without bound regions. - fcx.tcx.replace_escaping_bound_vars_uncached( - type_causes, - FnMutDelegate { - regions: &mut |br| { - let kind = br.kind; - let var = ty::BoundVar::from_usize(bound_vars.len()); - bound_vars.push(ty::BoundVariableKind::Region(kind)); - counter += 1; - ty::Region::new_late_bound( - fcx.tcx, - ty::INNERMOST, - ty::BoundRegion { var, kind }, - ) - }, - types: &mut |b| bug!("unexpected bound ty in binder: {b:?}"), - consts: &mut |b, ty| bug!("unexpected bound ct in binder: {b:?} {ty}"), - }, - ) - } else { - type_causes - }; - - // Extract type components to build the witness type. - let type_list = fcx.tcx.mk_type_list_from_iter(type_causes.iter().map(|cause| cause.ty)); - let bound_vars = fcx.tcx.mk_bound_variable_kinds(&bound_vars); - let witness = - Ty::new_generator_witness(fcx.tcx, ty::Binder::bind_with_vars(type_list, bound_vars)); - - drop(typeck_results); - // Store the generator types and spans into the typeck results for this generator. - fcx.inh.typeck_results.borrow_mut().generator_interior_types = - ty::Binder::bind_with_vars(type_causes, bound_vars); - - debug!( - "types in generator after region replacement {:?}, span = {:?}", - witness, body.value.span - ); - - // Unify the type variable inside the generator with the new witness - match fcx.at(&fcx.misc(body.value.span), fcx.param_env).eq( - DefineOpaqueTypes::No, - interior, - witness, - ) { - Ok(ok) => fcx.register_infer_ok_obligations(ok), - _ => bug!("failed to relate {interior} and {witness}"), - } -} - -// This visitor has to have the same visit_expr calls as RegionResolutionVisitor in -// librustc_middle/middle/region.rs since `expr_count` is compared against the results -// there. -impl<'a, 'tcx> Visitor<'tcx> for InteriorVisitor<'a, 'tcx> { - fn visit_arm(&mut self, arm: &'tcx Arm<'tcx>) { - let Arm { guard, pat, body, .. } = arm; - self.visit_pat(pat); - if let Some(ref g) = guard { - { - // If there is a guard, we need to count all variables bound in the pattern as - // borrowed for the entire guard body, regardless of whether they are accessed. - // We do this by walking the pattern bindings and recording `&T` for any `x: T` - // that is bound. - - struct ArmPatCollector<'a, 'b, 'tcx> { - interior_visitor: &'a mut InteriorVisitor<'b, 'tcx>, - scope: Scope, - } - - impl<'a, 'b, 'tcx> Visitor<'tcx> for ArmPatCollector<'a, 'b, 'tcx> { - fn visit_pat(&mut self, pat: &'tcx Pat<'tcx>) { - intravisit::walk_pat(self, pat); - if let PatKind::Binding(_, id, ident, ..) = pat.kind { - let ty = - self.interior_visitor.fcx.typeck_results.borrow().node_type(id); - let tcx = self.interior_visitor.fcx.tcx; - let ty = Ty::new_ref( - tcx, - // Use `ReErased` as `resolve_interior` is going to replace all the - // regions anyway. - tcx.lifetimes.re_erased, - ty::TypeAndMut { ty, mutbl: hir::Mutability::Not }, - ); - self.interior_visitor.record( - ty, - id, - Some(self.scope), - None, - ident.span, - ); - } - } - } - - ArmPatCollector { - interior_visitor: self, - scope: Scope { id: g.body().hir_id.local_id, data: ScopeData::Node }, - } - .visit_pat(pat); - } - - match g { - Guard::If(ref e) => { - self.visit_expr(e); - } - Guard::IfLet(ref l) => { - self.visit_let_expr(l); - } - } - } - self.visit_expr(body); - } - - fn visit_pat(&mut self, pat: &'tcx Pat<'tcx>) { - intravisit::walk_pat(self, pat); - - self.expr_count += 1; - - if let PatKind::Binding(..) = pat.kind { - let scope = self.region_scope_tree.var_scope(pat.hir_id.local_id).unwrap(); - let ty = self.fcx.typeck_results.borrow().pat_ty(pat); - self.record(ty, pat.hir_id, Some(scope), None, pat.span); - } - } - - fn visit_expr(&mut self, expr: &'tcx Expr<'tcx>) { - match &expr.kind { - ExprKind::Call(callee, args) => match &callee.kind { - ExprKind::Path(qpath) => { - let res = self.fcx.typeck_results.borrow().qpath_res(qpath, callee.hir_id); - match res { - // Direct calls never need to keep the callee `ty::FnDef` - // ZST in a temporary, so skip its type, just in case it - // can significantly complicate the generator type. - Res::Def( - DefKind::Fn | DefKind::AssocFn | DefKind::Ctor(_, CtorKind::Fn), - _, - ) => { - // NOTE(eddyb) this assumes a path expression has - // no nested expressions to keep track of. - self.expr_count += 1; - - // Record the rest of the call expression normally. - for arg in *args { - self.visit_expr(arg); - } - } - _ => intravisit::walk_expr(self, expr), - } - } - _ => intravisit::walk_expr(self, expr), - }, - _ => intravisit::walk_expr(self, expr), - } - - self.expr_count += 1; - - debug!("is_borrowed_temporary: {:?}", self.drop_ranges.is_borrowed_temporary(expr)); - - let ty = self.fcx.typeck_results.borrow().expr_ty_adjusted_opt(expr); - - // Typically, the value produced by an expression is consumed by its parent in some way, - // so we only have to check if the parent contains a yield (note that the parent may, for - // example, store the value into a local variable, but then we already consider local - // variables to be live across their scope). - // - // However, in the case of temporary values, we are going to store the value into a - // temporary on the stack that is live for the current temporary scope and then return a - // reference to it. That value may be live across the entire temporary scope. - // - // There's another subtlety: if the type has an observable drop, it must be dropped after - // the yield, even if it's not borrowed or referenced after the yield. Ideally this would - // *only* happen for types with observable drop, not all types which wrap them, but that - // doesn't match the behavior of MIR borrowck and causes ICEs. See the FIXME comment in - // tests/ui/generator/drop-tracking-parent-expression.rs. - let scope = if self.drop_ranges.is_borrowed_temporary(expr) - || ty.map_or(true, |ty| { - // Avoid ICEs in needs_drop. - let ty = self.fcx.resolve_vars_if_possible(ty); - let ty = self.fcx.tcx.erase_regions(ty); - if ty.has_infer() { - self.fcx - .tcx - .sess - .delay_span_bug(expr.span, format!("inference variables in {ty}")); - true - } else { - ty.needs_drop(self.fcx.tcx, self.fcx.param_env) - } - }) { - self.rvalue_scopes.temporary_scope(self.region_scope_tree, expr.hir_id.local_id) - } else { - let parent_expr = self - .fcx - .tcx - .hir() - .parent_iter(expr.hir_id) - .find(|(_, node)| matches!(node, hir::Node::Expr(_))) - .map(|(id, _)| id); - debug!("parent_expr: {:?}", parent_expr); - match parent_expr { - Some(parent) => Some(Scope { id: parent.local_id, data: ScopeData::Node }), - None => { - self.rvalue_scopes.temporary_scope(self.region_scope_tree, expr.hir_id.local_id) - } - } - }; - - // If there are adjustments, then record the final type -- - // this is the actual value that is being produced. - if let Some(adjusted_ty) = ty { - self.record(adjusted_ty, expr.hir_id, scope, Some(expr), expr.span); - } - - // Also record the unadjusted type (which is the only type if - // there are no adjustments). The reason for this is that the - // unadjusted value is sometimes a "temporary" that would wind - // up in a MIR temporary. - // - // As an example, consider an expression like `vec![].push(x)`. - // Here, the `vec![]` would wind up MIR stored into a - // temporary variable `t` which we can borrow to invoke - // `>::push(&mut t, x)`. - // - // Note that an expression can have many adjustments, and we - // are just ignoring those intermediate types. This is because - // those intermediate values are always linearly "consumed" by - // the other adjustments, and hence would never be directly - // captured in the MIR. - // - // (Note that this partly relies on the fact that the `Deref` - // traits always return references, which means their content - // can be reborrowed without needing to spill to a temporary. - // If this were not the case, then we could conceivably have - // to create intermediate temporaries.) - // - // The type table might not have information for this expression - // if it is in a malformed scope. (#66387) - if let Some(ty) = self.fcx.typeck_results.borrow().expr_ty_opt(expr) { - self.record(ty, expr.hir_id, scope, Some(expr), expr.span); - } else { - self.fcx.tcx.sess.delay_span_bug(expr.span, "no type for node"); - } - } -} - -#[derive(Default)] -struct SuspendCheckData<'a, 'tcx> { - expr: Option<&'tcx Expr<'tcx>>, - source_span: Span, - yield_span: Span, - descr_pre: &'a str, - descr_post: &'a str, - plural_len: usize, -} - -// Returns whether it emitted a diagnostic or not -// Note that this fn and the proceeding one are based on the code -// for creating must_use diagnostics -// -// Note that this technique was chosen over things like a `Suspend` marker trait -// as it is simpler and has precedent in the compiler -fn check_must_not_suspend_ty<'tcx>( - fcx: &FnCtxt<'_, 'tcx>, - ty: Ty<'tcx>, - hir_id: HirId, - data: SuspendCheckData<'_, 'tcx>, -) -> bool { - if ty.is_unit() - // FIXME: should this check `Ty::is_inhabited_from`. This query is not available in this stage - // of typeck (before ReVar and RePlaceholder are removed), but may remove noise, like in - // `must_use` - // || !ty.is_inhabited_from(fcx.tcx, fcx.tcx.parent_module(hir_id).to_def_id(), fcx.param_env) - { - return false; - } - - let plural_suffix = pluralize!(data.plural_len); - - debug!("Checking must_not_suspend for {}", ty); - - match *ty.kind() { - ty::Adt(..) if ty.is_box() => { - let boxed_ty = ty.boxed_ty(); - let descr_pre = &format!("{}boxed ", data.descr_pre); - check_must_not_suspend_ty(fcx, boxed_ty, hir_id, SuspendCheckData { descr_pre, ..data }) - } - ty::Adt(def, _) => check_must_not_suspend_def(fcx.tcx, def.did(), hir_id, data), - // FIXME: support adding the attribute to TAITs - ty::Alias(ty::Opaque, ty::AliasTy { def_id: def, .. }) => { - let mut has_emitted = false; - for &(predicate, _) in fcx.tcx.explicit_item_bounds(def).skip_binder() { - // We only look at the `DefId`, so it is safe to skip the binder here. - if let ty::ClauseKind::Trait(ref poly_trait_predicate) = - predicate.kind().skip_binder() - { - let def_id = poly_trait_predicate.trait_ref.def_id; - let descr_pre = &format!("{}implementer{} of ", data.descr_pre, plural_suffix); - if check_must_not_suspend_def( - fcx.tcx, - def_id, - hir_id, - SuspendCheckData { descr_pre, ..data }, - ) { - has_emitted = true; - break; - } - } - } - has_emitted - } - ty::Dynamic(binder, _, _) => { - let mut has_emitted = false; - for predicate in binder.iter() { - if let ty::ExistentialPredicate::Trait(ref trait_ref) = predicate.skip_binder() { - let def_id = trait_ref.def_id; - let descr_post = &format!(" trait object{}{}", plural_suffix, data.descr_post); - if check_must_not_suspend_def( - fcx.tcx, - def_id, - hir_id, - SuspendCheckData { descr_post, ..data }, - ) { - has_emitted = true; - break; - } - } - } - has_emitted - } - ty::Tuple(fields) => { - let mut has_emitted = false; - let comps = match data.expr.map(|e| &e.kind) { - Some(hir::ExprKind::Tup(comps)) if comps.len() == fields.len() => Some(comps), - _ => None, - }; - for (i, ty) in fields.iter().enumerate() { - let descr_post = &format!(" in tuple element {i}"); - let span = comps.and_then(|c| c.get(i)).map(|e| e.span).unwrap_or(data.source_span); - if check_must_not_suspend_ty( - fcx, - ty, - hir_id, - SuspendCheckData { - descr_post, - expr: comps.and_then(|comps| comps.get(i)), - source_span: span, - ..data - }, - ) { - has_emitted = true; - } - } - has_emitted - } - ty::Array(ty, len) => { - let descr_pre = &format!("{}array{} of ", data.descr_pre, plural_suffix); - let target_usize = - len.try_eval_target_usize(fcx.tcx, fcx.param_env).unwrap_or(0) as usize; - let plural_len = target_usize.saturating_add(1); - check_must_not_suspend_ty( - fcx, - ty, - hir_id, - SuspendCheckData { descr_pre, plural_len, ..data }, - ) - } - // If drop tracking is enabled, we want to look through references, since the referent - // may not be considered live across the await point. - ty::Ref(_region, ty, _mutability) if fcx.sess().opts.unstable_opts.drop_tracking => { - let descr_pre = &format!("{}reference{} to ", data.descr_pre, plural_suffix); - check_must_not_suspend_ty(fcx, ty, hir_id, SuspendCheckData { descr_pre, ..data }) - } - _ => false, - } -} - -fn check_must_not_suspend_def( - tcx: TyCtxt<'_>, - def_id: DefId, - hir_id: HirId, - data: SuspendCheckData<'_, '_>, -) -> bool { - if let Some(attr) = tcx.get_attr(def_id, sym::must_not_suspend) { - tcx.struct_span_lint_hir( - rustc_session::lint::builtin::MUST_NOT_SUSPEND, - hir_id, - data.source_span, - DelayDm(|| { - format!( - "{}`{}`{} held across a suspend point, but should not be", - data.descr_pre, - tcx.def_path_str(def_id), - data.descr_post, - ) - }), - |lint| { - // add span pointing to the offending yield/await - lint.span_label(data.yield_span, "the value is held across this suspend point"); - - // Add optional reason note - if let Some(note) = attr.value_str() { - // FIXME(guswynn): consider formatting this better - lint.span_note(data.source_span, note.to_string()); - } - - // Add some quick suggestions on what to do - // FIXME: can `drop` work as a suggestion here as well? - lint.span_help( - data.source_span, - "consider using a block (`{ ... }`) \ - to shrink the value's scope, ending before the suspend point", - ); - - lint - }, - ); - - true - } else { - false - } -} diff --git a/compiler/rustc_hir_typeck/src/lib.rs b/compiler/rustc_hir_typeck/src/lib.rs index f17f1d14bf3..6873382c4ac 100644 --- a/compiler/rustc_hir_typeck/src/lib.rs +++ b/compiler/rustc_hir_typeck/src/lib.rs @@ -32,7 +32,6 @@ pub mod expr_use_visitor; mod fallback; mod fn_ctxt; mod gather_locals; -mod generator_interior; mod inherited; mod intrinsicck; mod mem_categorization; diff --git a/compiler/rustc_hir_typeck/src/writeback.rs b/compiler/rustc_hir_typeck/src/writeback.rs index 2fe41c1197f..9c16b486dbc 100644 --- a/compiler/rustc_hir_typeck/src/writeback.rs +++ b/compiler/rustc_hir_typeck/src/writeback.rs @@ -63,7 +63,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { wbcx.visit_coercion_casts(); wbcx.visit_user_provided_tys(); wbcx.visit_user_provided_sigs(); - wbcx.visit_generator_interior_types(); + wbcx.visit_generator_interior(); wbcx.visit_offset_of_container_types(); wbcx.typeck_results.rvalue_scopes = @@ -538,11 +538,9 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> { ); } - fn visit_generator_interior_types(&mut self) { + fn visit_generator_interior(&mut self) { let fcx_typeck_results = self.fcx.typeck_results.borrow(); assert_eq!(fcx_typeck_results.hir_owner, self.typeck_results.hir_owner); - self.typeck_results.generator_interior_types = - fcx_typeck_results.generator_interior_types.clone(); self.tcx().with_stable_hashing_context(move |ref hcx| { for (&expr_def_id, predicates) in fcx_typeck_results.generator_interior_predicates.to_sorted(hcx, false).into_iter() diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index ce097922aef..0e8f93cef17 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -798,14 +798,12 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> { } }); - if tcx.sess.opts.unstable_opts.drop_tracking_mir { - tcx.hir().par_body_owners(|def_id| { - if let rustc_hir::def::DefKind::Generator = tcx.def_kind(def_id) { - tcx.ensure().mir_generator_witnesses(def_id); - tcx.ensure().check_generator_obligations(def_id); - } - }); - } + tcx.hir().par_body_owners(|def_id| { + if let rustc_hir::def::DefKind::Generator = tcx.def_kind(def_id) { + tcx.ensure().mir_generator_witnesses(def_id); + tcx.ensure().check_generator_obligations(def_id); + } + }); sess.time("layout_testing", || layout_test::test_layout(tcx)); sess.time("abi_testing", || abi_test::test_abi(tcx)); diff --git a/compiler/rustc_interface/src/tests.rs b/compiler/rustc_interface/src/tests.rs index 1746cc8b719..2510ce71460 100644 --- a/compiler/rustc_interface/src/tests.rs +++ b/compiler/rustc_interface/src/tests.rs @@ -684,7 +684,6 @@ fn test_unstable_options_tracking_hash() { untracked!(dep_tasks, true); untracked!(dont_buffer_diagnostics, true); untracked!(dump_dep_graph, true); - untracked!(dump_drop_tracking_cfg, Some("cfg.dot".to_string())); untracked!(dump_mir, Some(String::from("abc"))); untracked!(dump_mir_dataflow, true); untracked!(dump_mir_dir, String::from("abc")); @@ -773,7 +772,6 @@ fn test_unstable_options_tracking_hash() { tracked!(debug_info_for_profiling, true); tracked!(debug_macros, true); tracked!(dep_info_omit_d_target, true); - tracked!(drop_tracking, true); tracked!(dual_proc_macros, true); tracked!(dwarf_version, Some(5)); tracked!(emit_thin_lto, false); diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 1951db49e91..21575bf6b04 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -306,6 +306,7 @@ declare_lint! { /// pub async fn uhoh() { /// let guard = SyncThing {}; /// yield_now().await; + /// let _guard = guard; /// } /// ``` /// diff --git a/compiler/rustc_metadata/src/rmeta/decoder.rs b/compiler/rustc_metadata/src/rmeta/decoder.rs index 8ea9c60e4f2..b189e79df56 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder.rs @@ -24,7 +24,6 @@ use rustc_middle::middle::exported_symbols::{ExportedSymbol, SymbolExportInfo}; use rustc_middle::mir::interpret::{AllocDecodingSession, AllocDecodingState}; use rustc_middle::ty::codec::TyDecoder; use rustc_middle::ty::fast_reject::SimplifiedType; -use rustc_middle::ty::GeneratorDiagnosticData; use rustc_middle::ty::{self, ParameterizedOverTcx, Ty, TyCtxt, Visibility}; use rustc_serialize::opaque::MemDecoder; use rustc_serialize::{Decodable, Decoder}; @@ -1750,24 +1749,6 @@ impl<'a, 'tcx> CrateMetadataRef<'a> { .clone() } - fn get_generator_diagnostic_data( - self, - tcx: TyCtxt<'tcx>, - id: DefIndex, - ) -> Option> { - self.root - .tables - .generator_diagnostic_data - .get(self, id) - .map(|param| param.decode((self, tcx))) - .map(|generator_data| GeneratorDiagnosticData { - generator_interior_types: generator_data.generator_interior_types, - hir_owner: generator_data.hir_owner, - nodes_types: generator_data.nodes_types, - adjustments: generator_data.adjustments, - }) - } - fn get_attr_flags(self, index: DefIndex) -> AttrFlags { self.root.tables.attr_flags.get(self, index) } diff --git a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs index b682a153c77..b56fe375849 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs @@ -374,7 +374,6 @@ provide! { tcx, def_id, other, cdata, crate_extern_paths => { cdata.source().paths().cloned().collect() } expn_that_defined => { cdata.get_expn_that_defined(def_id.index, tcx.sess) } - generator_diagnostic_data => { cdata.get_generator_diagnostic_data(tcx, def_id.index) } is_doc_hidden => { cdata.get_attr_flags(def_id.index).contains(AttrFlags::IS_DOC_HIDDEN) } doc_link_resolutions => { tcx.arena.alloc(cdata.get_doc_link_resolutions(def_id.index)) } doc_link_traits_in_scope => { diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index cc7ae932e11..7506fc1bb05 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -1439,7 +1439,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { } } if let DefKind::Generator = def_kind { - self.encode_info_for_generator(local_id); + let data = self.tcx.generator_kind(def_id).unwrap(); + record!(self.tables.generator_kind[def_id] <- data); } if let DefKind::Enum | DefKind::Struct | DefKind::Union = def_kind { self.encode_info_for_adt(local_id); @@ -1612,8 +1613,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { record!(self.tables.closure_saved_names_of_captured_variables[def_id.to_def_id()] <- tcx.closure_saved_names_of_captured_variables(def_id)); - if tcx.sess.opts.unstable_opts.drop_tracking_mir - && let DefKind::Generator = self.tcx.def_kind(def_id) + if let DefKind::Generator = self.tcx.def_kind(def_id) && let Some(witnesses) = tcx.mir_generator_witnesses(def_id) { record!(self.tables.mir_generator_witnesses[def_id.to_def_id()] <- witnesses); @@ -1640,6 +1640,12 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { } record!(self.tables.promoted_mir[def_id.to_def_id()] <- tcx.promoted_mir(def_id)); + if let DefKind::Generator = self.tcx.def_kind(def_id) + && let Some(witnesses) = tcx.mir_generator_witnesses(def_id) + { + record!(self.tables.mir_generator_witnesses[def_id.to_def_id()] <- witnesses); + } + let instance = ty::InstanceDef::Item(def_id.to_def_id()); let unused = tcx.unused_generic_params(instance); self.tables.unused_generic_params.set(def_id.local_def_index, unused); @@ -1712,15 +1718,6 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { record!(self.tables.macro_definition[def_id.to_def_id()] <- &*macro_def.body); } - #[instrument(level = "debug", skip(self))] - fn encode_info_for_generator(&mut self, def_id: LocalDefId) { - let typeck_result: &'tcx ty::TypeckResults<'tcx> = self.tcx.typeck(def_id); - let data = self.tcx.generator_kind(def_id).unwrap(); - let generator_diagnostic_data = typeck_result.get_generator_diagnostic_data(); - record!(self.tables.generator_kind[def_id.to_def_id()] <- data); - record!(self.tables.generator_diagnostic_data[def_id.to_def_id()] <- generator_diagnostic_data); - } - fn encode_native_libraries(&mut self) -> LazyArray { empty_proc_macro!(self); let used_libraries = self.tcx.native_libraries(LOCAL_CRATE); diff --git a/compiler/rustc_metadata/src/rmeta/mod.rs b/compiler/rustc_metadata/src/rmeta/mod.rs index 43d5cf43a81..09b2a1a0cb2 100644 --- a/compiler/rustc_metadata/src/rmeta/mod.rs +++ b/compiler/rustc_metadata/src/rmeta/mod.rs @@ -23,7 +23,7 @@ use rustc_middle::middle::resolve_bound_vars::ObjectLifetimeDefault; use rustc_middle::mir; use rustc_middle::ty::fast_reject::SimplifiedType; use rustc_middle::ty::{self, ReprOptions, Ty, UnusedGenericParams}; -use rustc_middle::ty::{DeducedParamAttrs, GeneratorDiagnosticData, ParameterizedOverTcx, TyCtxt}; +use rustc_middle::ty::{DeducedParamAttrs, ParameterizedOverTcx, TyCtxt}; use rustc_middle::util::Providers; use rustc_serialize::opaque::FileEncoder; use rustc_session::config::SymbolManglingVersion; @@ -452,7 +452,6 @@ define_tables! { // definitions from any given crate. def_keys: Table>, proc_macro_quoted_spans: Table>, - generator_diagnostic_data: Table>>, variant_data: Table>, assoc_container: Table, macro_definition: Table>, diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs index 6928f59c3fd..5986a8b1cd8 100644 --- a/compiler/rustc_middle/src/query/mod.rs +++ b/compiler/rustc_middle/src/query/mod.rs @@ -44,7 +44,6 @@ use crate::traits::{ use crate::ty::fast_reject::SimplifiedType; use crate::ty::layout::ValidityRequirement; use crate::ty::util::AlwaysRequiresDrop; -use crate::ty::GeneratorDiagnosticData; use crate::ty::TyCtxtFeed; use crate::ty::{ self, print::describe_as_module, CrateInherentImpls, ParamEnvAnd, Ty, TyCtxt, @@ -2149,12 +2148,6 @@ rustc_queries! { desc { "computing the backend features for CLI flags" } } - query generator_diagnostic_data(key: DefId) -> &'tcx Option> { - arena_cache - desc { |tcx| "looking up generator diagnostic data of `{}`", tcx.def_path_str(key) } - separate_provide_extern - } - query check_validity_requirement(key: (ValidityRequirement, ty::ParamEnvAnd<'tcx, Ty<'tcx>>)) -> Result> { desc { "checking validity requirement for `{}`: {}", key.1.value, key.0 } } diff --git a/compiler/rustc_middle/src/ty/codec.rs b/compiler/rustc_middle/src/ty/codec.rs index 7c05deae90a..dff7ff8c66b 100644 --- a/compiler/rustc_middle/src/ty/codec.rs +++ b/compiler/rustc_middle/src/ty/codec.rs @@ -566,6 +566,5 @@ impl_binder_encode_decode! { ty::TraitPredicate<'tcx>, ty::ExistentialPredicate<'tcx>, ty::TraitRef<'tcx>, - Vec>, ty::ExistentialTraitRef<'tcx>, } diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index b050208b4a6..aa1e7f216a0 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -106,9 +106,8 @@ pub use self::sty::{ }; pub use self::trait_def::TraitDef; pub use self::typeck_results::{ - CanonicalUserType, CanonicalUserTypeAnnotation, CanonicalUserTypeAnnotations, - GeneratorDiagnosticData, GeneratorInteriorTypeCause, TypeckResults, UserType, - UserTypeAnnotationIndex, + CanonicalUserType, CanonicalUserTypeAnnotation, CanonicalUserTypeAnnotations, TypeckResults, + UserType, UserTypeAnnotationIndex, }; pub mod _match; diff --git a/compiler/rustc_middle/src/ty/parameterized.rs b/compiler/rustc_middle/src/ty/parameterized.rs index f1093e88312..9aa673e4418 100644 --- a/compiler/rustc_middle/src/ty/parameterized.rs +++ b/compiler/rustc_middle/src/ty/parameterized.rs @@ -132,5 +132,4 @@ parameterized_over_tcx! { ty::Predicate, ty::Clause, ty::ClauseKind, - ty::GeneratorDiagnosticData, } diff --git a/compiler/rustc_middle/src/ty/typeck_results.rs b/compiler/rustc_middle/src/ty/typeck_results.rs index 69c4c588c44..a44224e4dc7 100644 --- a/compiler/rustc_middle/src/ty/typeck_results.rs +++ b/compiler/rustc_middle/src/ty/typeck_results.rs @@ -189,10 +189,6 @@ pub struct TypeckResults<'tcx> { /// Details may be find in `rustc_hir_analysis::check::rvalue_scopes`. pub rvalue_scopes: RvalueScopes, - /// Stores the type, expression, span and optional scope span of all types - /// that are live across the yield of this generator (if a generator). - pub generator_interior_types: ty::Binder<'tcx, Vec>>, - /// Stores the predicates that apply on generator witness types. /// formatting modified file tests/ui/generator/retain-resume-ref.rs pub generator_interior_predicates: @@ -212,49 +208,6 @@ pub struct TypeckResults<'tcx> { offset_of_data: ItemLocalMap<(Ty<'tcx>, Vec)>, } -/// Whenever a value may be live across a generator yield, the type of that value winds up in the -/// `GeneratorInteriorTypeCause` struct. This struct adds additional information about such -/// captured types that can be useful for diagnostics. In particular, it stores the span that -/// caused a given type to be recorded, along with the scope that enclosed the value (which can -/// be used to find the await that the value is live across). -/// -/// For example: -/// -/// ```ignore (pseudo-Rust) -/// async move { -/// let x: T = expr; -/// foo.await -/// ... -/// } -/// ``` -/// -/// Here, we would store the type `T`, the span of the value `x`, the "scope-span" for -/// the scope that contains `x`, the expr `T` evaluated from, and the span of `foo.await`. -#[derive(TyEncodable, TyDecodable, Clone, Debug, Eq, Hash, PartialEq, HashStable)] -#[derive(TypeFoldable, TypeVisitable)] -pub struct GeneratorInteriorTypeCause<'tcx> { - /// Type of the captured binding. - pub ty: Ty<'tcx>, - /// Span of the binding that was captured. - pub span: Span, - /// Span of the scope of the captured binding. - pub scope_span: Option, - /// Span of `.await` or `yield` expression. - pub yield_span: Span, - /// Expr which the type evaluated from. - pub expr: Option, -} - -// This type holds diagnostic information on generators and async functions across crate boundaries -// and is used to provide better error messages -#[derive(TyEncodable, TyDecodable, Clone, Debug, HashStable)] -pub struct GeneratorDiagnosticData<'tcx> { - pub generator_interior_types: ty::Binder<'tcx, Vec>>, - pub hir_owner: DefId, - pub nodes_types: ItemLocalMap>, - pub adjustments: ItemLocalMap>>, -} - impl<'tcx> TypeckResults<'tcx> { pub fn new(hir_owner: OwnerId) -> TypeckResults<'tcx> { TypeckResults { @@ -278,7 +231,6 @@ impl<'tcx> TypeckResults<'tcx> { closure_min_captures: Default::default(), closure_fake_reads: Default::default(), rvalue_scopes: Default::default(), - generator_interior_types: ty::Binder::dummy(Default::default()), generator_interior_predicates: Default::default(), treat_byte_string_as_slice: Default::default(), closure_size_eval: Default::default(), @@ -351,28 +303,6 @@ impl<'tcx> TypeckResults<'tcx> { LocalTableInContextMut { hir_owner: self.hir_owner, data: &mut self.node_types } } - pub fn get_generator_diagnostic_data(&self) -> GeneratorDiagnosticData<'tcx> { - let generator_interior_type = self.generator_interior_types.map_bound_ref(|vec| { - vec.iter() - .map(|item| { - GeneratorInteriorTypeCause { - ty: item.ty, - span: item.span, - scope_span: item.scope_span, - yield_span: item.yield_span, - expr: None, //FIXME: Passing expression over crate boundaries is impossible at the moment - } - }) - .collect::>() - }); - GeneratorDiagnosticData { - generator_interior_types: generator_interior_type, - hir_owner: self.hir_owner.to_def_id(), - nodes_types: self.node_types.clone(), - adjustments: self.adjustments.clone(), - } - } - pub fn node_type(&self, id: hir::HirId) -> Ty<'tcx> { self.node_type_opt(id).unwrap_or_else(|| { bug!("node_type: no type for node {}", tls::with(|tcx| tcx.hir().node_to_string(id))) diff --git a/compiler/rustc_mir_transform/src/generator.rs b/compiler/rustc_mir_transform/src/generator.rs index 9bcdc7d728d..8a807d786a5 100644 --- a/compiler/rustc_mir_transform/src/generator.rs +++ b/compiler/rustc_mir_transform/src/generator.rs @@ -853,60 +853,7 @@ impl StorageConflictVisitor<'_, '_, '_> { } } -/// Validates the typeck view of the generator against the actual set of types saved between -/// yield points. -fn sanitize_witness<'tcx>( - tcx: TyCtxt<'tcx>, - body: &Body<'tcx>, - witness: Ty<'tcx>, - upvars: &'tcx ty::List>, - layout: &GeneratorLayout<'tcx>, -) { - let did = body.source.def_id(); - let param_env = tcx.param_env(did); - - let allowed_upvars = tcx.normalize_erasing_regions(param_env, upvars); - let allowed = match witness.kind() { - &ty::GeneratorWitness(interior_tys) => { - tcx.normalize_erasing_late_bound_regions(param_env, interior_tys) - } - _ => { - tcx.sess.delay_span_bug( - body.span, - format!("unexpected generator witness type {:?}", witness.kind()), - ); - return; - } - }; - - let mut mismatches = Vec::new(); - for fty in &layout.field_tys { - if fty.ignore_for_traits { - continue; - } - let decl_ty = tcx.normalize_erasing_regions(param_env, fty.ty); - - // Sanity check that typeck knows about the type of locals which are - // live across a suspension point - if !allowed.contains(&decl_ty) && !allowed_upvars.contains(&decl_ty) { - mismatches.push(decl_ty); - } - } - - if !mismatches.is_empty() { - span_bug!( - body.span, - "Broken MIR: generator contains type {:?} in MIR, \ - but typeck only knows about {} and {:?}", - mismatches, - allowed, - allowed_upvars - ); - } -} - fn compute_layout<'tcx>( - tcx: TyCtxt<'tcx>, liveness: LivenessInfo, body: &Body<'tcx>, ) -> ( @@ -932,27 +879,20 @@ fn compute_layout<'tcx>( let decl = &body.local_decls[local]; debug!(?decl); - let ignore_for_traits = if tcx.sess.opts.unstable_opts.drop_tracking_mir { - // Do not `assert_crate_local` here, as post-borrowck cleanup may have already cleared - // the information. This is alright, since `ignore_for_traits` is only relevant when - // this code runs on pre-cleanup MIR, and `ignore_for_traits = false` is the safer - // default. - match decl.local_info { - // Do not include raw pointers created from accessing `static` items, as those could - // well be re-created by another access to the same static. - ClearCrossCrate::Set(box LocalInfo::StaticRef { is_thread_local, .. }) => { - !is_thread_local - } - // Fake borrows are only read by fake reads, so do not have any reality in - // post-analysis MIR. - ClearCrossCrate::Set(box LocalInfo::FakeBorrow) => true, - _ => false, + // Do not `assert_crate_local` here, as post-borrowck cleanup may have already cleared + // the information. This is alright, since `ignore_for_traits` is only relevant when + // this code runs on pre-cleanup MIR, and `ignore_for_traits = false` is the safer + // default. + let ignore_for_traits = match decl.local_info { + // Do not include raw pointers created from accessing `static` items, as those could + // well be re-created by another access to the same static. + ClearCrossCrate::Set(box LocalInfo::StaticRef { is_thread_local, .. }) => { + !is_thread_local } - } else { - // FIXME(#105084) HIR-based drop tracking does not account for all the temporaries that - // MIR building may introduce. This leads to wrongly ignored types, but this is - // necessary for internal consistency and to avoid ICEs. - decl.internal + // Fake borrows are only read by fake reads, so do not have any reality in + // post-analysis MIR. + ClearCrossCrate::Set(box LocalInfo::FakeBorrow) => true, + _ => false, }; let decl = GeneratorSavedTy { ty: decl.ty, source_info: decl.source_info, ignore_for_traits }; @@ -1445,8 +1385,6 @@ pub(crate) fn mir_generator_witnesses<'tcx>( tcx: TyCtxt<'tcx>, def_id: LocalDefId, ) -> Option> { - assert!(tcx.sess.opts.unstable_opts.drop_tracking_mir); - let (body, _) = tcx.mir_promoted(def_id); let body = body.borrow(); let body = &*body; @@ -1469,7 +1407,7 @@ pub(crate) fn mir_generator_witnesses<'tcx>( // Extract locals which are live across suspension point into `layout` // `remap` gives a mapping from local indices onto generator struct indices // `storage_liveness` tells us which locals have live storage at suspension points - let (_, generator_layout, _) = compute_layout(tcx, liveness_info, body); + let (_, generator_layout, _) = compute_layout(liveness_info, body); check_suspend_tys(tcx, &generator_layout, &body); @@ -1489,15 +1427,10 @@ impl<'tcx> MirPass<'tcx> for StateTransform { let gen_ty = body.local_decls.raw[1].ty; // Get the discriminant type and args which typeck computed - let (discr_ty, upvars, interior, movable) = match *gen_ty.kind() { + let (discr_ty, movable) = match *gen_ty.kind() { ty::Generator(_, args, movability) => { let args = args.as_generator(); - ( - args.discr_ty(tcx), - args.upvar_tys(), - args.witness(), - movability == hir::Movability::Movable, - ) + (args.discr_ty(tcx), movability == hir::Movability::Movable) } _ => { tcx.sess.delay_span_bug(body.span, format!("unexpected generator type {gen_ty}")); @@ -1574,13 +1507,7 @@ impl<'tcx> MirPass<'tcx> for StateTransform { // Extract locals which are live across suspension point into `layout` // `remap` gives a mapping from local indices onto generator struct indices // `storage_liveness` tells us which locals have live storage at suspension points - let (remap, layout, storage_liveness) = compute_layout(tcx, liveness_info, body); - - if tcx.sess.opts.unstable_opts.validate_mir - && !tcx.sess.opts.unstable_opts.drop_tracking_mir - { - sanitize_witness(tcx, body, interior, upvars, &layout); - } + let (remap, layout, storage_liveness) = compute_layout(liveness_info, body); let can_return = can_return(tcx, body, tcx.param_env(body.source.def_id())); diff --git a/compiler/rustc_mir_transform/src/lib.rs b/compiler/rustc_mir_transform/src/lib.rs index d55b0cbe635..d7fef093278 100644 --- a/compiler/rustc_mir_transform/src/lib.rs +++ b/compiler/rustc_mir_transform/src/lib.rs @@ -358,9 +358,7 @@ fn inner_mir_for_ctfe(tcx: TyCtxt<'_>, def: LocalDefId) -> Body<'_> { /// mir borrowck *before* doing so in order to ensure that borrowck can be run and doesn't /// end up missing the source MIR due to stealing happening. fn mir_drops_elaborated_and_const_checked(tcx: TyCtxt<'_>, def: LocalDefId) -> &Steal> { - if tcx.sess.opts.unstable_opts.drop_tracking_mir - && let DefKind::Generator = tcx.def_kind(def) - { + if let DefKind::Generator = tcx.def_kind(def) { tcx.ensure_with_value().mir_generator_witnesses(def); } let mir_borrowck = tcx.mir_borrowck(def); diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index 23f2be632b2..c1424db600e 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -1458,17 +1458,11 @@ options! { dont_buffer_diagnostics: bool = (false, parse_bool, [UNTRACKED], "emit diagnostics rather than buffering (breaks NLL error downgrading, sorting) \ (default: no)"), - drop_tracking: bool = (false, parse_bool, [TRACKED], - "enables drop tracking in generators (default: no)"), - drop_tracking_mir: bool = (false, parse_bool, [TRACKED], - "enables drop tracking on MIR in generators (default: no)"), dual_proc_macros: bool = (false, parse_bool, [TRACKED], "load proc macros for both target and host, but only link to the target (default: no)"), dump_dep_graph: bool = (false, parse_bool, [UNTRACKED], "dump the dependency graph to $RUST_DEP_GRAPH (default: /tmp/dep_graph.gv) \ (default: no)"), - dump_drop_tracking_cfg: Option = (None, parse_opt_string, [UNTRACKED], - "dump drop-tracking control-flow graph as a `.dot` file (default: no)"), dump_mir: Option = (None, parse_opt_string, [UNTRACKED], "dump MIR state to file. `val` is used to select which passes and functions to dump. For example: diff --git a/compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs b/compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs index d1f2c1b27fd..3d9b8539ee2 100644 --- a/compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs +++ b/compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs @@ -779,6 +779,7 @@ fn transform_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, options: TransformTyOptio | ty::Str | ty::Never | ty::Foreign(..) + | ty::GeneratorWitnessMIR(..) | ty::GeneratorWitness(..) => {} ty::Bool => { @@ -973,12 +974,7 @@ fn transform_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, options: TransformTyOptio ); } - ty::Bound(..) - | ty::Error(..) - | ty::GeneratorWitnessMIR(..) - | ty::Infer(..) - | ty::Param(..) - | ty::Placeholder(..) => { + ty::Bound(..) | ty::Error(..) | ty::Infer(..) | ty::Param(..) | ty::Placeholder(..) => { bug!("transform_ty: unexpected `{:?}`", ty.kind()); } } diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index bb96e135741..428267a923e 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -30,10 +30,9 @@ use rustc_infer::infer::{DefineOpaqueTypes, InferOk, LateBoundRegionConversionTi use rustc_middle::hir::map; use rustc_middle::ty::error::TypeError::{self, Sorts}; use rustc_middle::ty::{ - self, suggest_arbitrary_trait_bound, suggest_constraining_type_param, AdtKind, - GeneratorDiagnosticData, GeneratorInteriorTypeCause, GenericArgs, InferTy, IsSuggestable, - ToPredicate, Ty, TyCtxt, TypeAndMut, TypeFoldable, TypeFolder, TypeSuperFoldable, - TypeVisitableExt, TypeckResults, + self, suggest_arbitrary_trait_bound, suggest_constraining_type_param, AdtKind, GenericArgs, + InferTy, IsSuggestable, ToPredicate, Ty, TyCtxt, TypeAndMut, TypeFoldable, TypeFolder, + TypeSuperFoldable, TypeVisitableExt, TypeckResults, }; use rustc_span::def_id::LocalDefId; use rustc_span::symbol::{sym, Ident, Symbol}; @@ -58,15 +57,12 @@ pub enum GeneratorInteriorOrUpvar { // This type provides a uniform interface to retrieve data on generators, whether it originated from // the local crate being compiled or from a foreign crate. #[derive(Debug)] -pub enum GeneratorData<'tcx, 'a> { - Local(&'a TypeckResults<'tcx>), - Foreign(&'tcx GeneratorDiagnosticData<'tcx>), -} +struct GeneratorData<'tcx, 'a>(&'a TypeckResults<'tcx>); impl<'tcx, 'a> GeneratorData<'tcx, 'a> { - // Try to get information about variables captured by the generator that matches a type we are - // looking for with `ty_matches` function. We uses it to find upvar which causes a failure to - // meet an obligation + /// Try to get information about variables captured by the generator that matches a type we are + /// looking for with `ty_matches` function. We uses it to find upvar which causes a failure to + /// meet an obligation fn try_get_upvar_span( &self, infer_context: &InferCtxt<'tcx>, @@ -76,27 +72,21 @@ impl<'tcx, 'a> GeneratorData<'tcx, 'a> { where F: Fn(ty::Binder<'tcx, Ty<'tcx>>) -> bool, { - match self { - GeneratorData::Local(typeck_results) => { - infer_context.tcx.upvars_mentioned(generator_did).and_then(|upvars| { - upvars.iter().find_map(|(upvar_id, upvar)| { - let upvar_ty = typeck_results.node_type(*upvar_id); - let upvar_ty = infer_context.resolve_vars_if_possible(upvar_ty); - ty_matches(ty::Binder::dummy(upvar_ty)) - .then(|| GeneratorInteriorOrUpvar::Upvar(upvar.span)) - }) - }) - } - GeneratorData::Foreign(_) => None, - } + infer_context.tcx.upvars_mentioned(generator_did).and_then(|upvars| { + upvars.iter().find_map(|(upvar_id, upvar)| { + let upvar_ty = self.0.node_type(*upvar_id); + let upvar_ty = infer_context.resolve_vars_if_possible(upvar_ty); + ty_matches(ty::Binder::dummy(upvar_ty)) + .then(|| GeneratorInteriorOrUpvar::Upvar(upvar.span)) + }) + }) } - // Try to get the span of a type being awaited on that matches the type we are looking with the - // `ty_matches` function. We uses it to find awaited type which causes a failure to meet an - // obligation + /// Try to get the span of a type being awaited on that matches the type we are looking with the + /// `ty_matches` function. We uses it to find awaited type which causes a failure to meet an + /// obligation fn get_from_await_ty( &self, - tcx: TyCtxt<'tcx>, visitor: AwaitsVisitor, hir: map::Map<'tcx>, ty_matches: F, @@ -104,69 +94,12 @@ impl<'tcx, 'a> GeneratorData<'tcx, 'a> { where F: Fn(ty::Binder<'tcx, Ty<'tcx>>) -> bool, { - match self { - GeneratorData::Local(typeck_results) => visitor - .awaits - .into_iter() - .map(|id| hir.expect_expr(id)) - .find(|await_expr| { - ty_matches(ty::Binder::dummy(typeck_results.expr_ty_adjusted(&await_expr))) - }) - .map(|expr| expr.span), - GeneratorData::Foreign(generator_diagnostic_data) => visitor - .awaits - .into_iter() - .map(|id| hir.expect_expr(id)) - .find(|await_expr| { - ty_matches(ty::Binder::dummy( - generator_diagnostic_data - .adjustments - .get(&await_expr.hir_id.local_id) - .map_or::<&[ty::adjustment::Adjustment<'tcx>], _>(&[], |a| &a[..]) - .last() - .map_or_else::, _, _>( - || { - generator_diagnostic_data - .nodes_types - .get(&await_expr.hir_id.local_id) - .cloned() - .unwrap_or_else(|| { - bug!( - "node_type: no type for node {}", - tcx.hir().node_to_string(await_expr.hir_id) - ) - }) - }, - |adj| adj.target, - ), - )) - }) - .map(|expr| expr.span), - } - } - - /// Get the type, expression, span and optional scope span of all types - /// that are live across the yield of this generator - fn get_generator_interior_types( - &self, - ) -> ty::Binder<'tcx, &[GeneratorInteriorTypeCause<'tcx>]> { - match self { - GeneratorData::Local(typeck_result) => { - typeck_result.generator_interior_types.as_deref() - } - GeneratorData::Foreign(generator_diagnostic_data) => { - generator_diagnostic_data.generator_interior_types.as_deref() - } - } - } - - // Used to get the source of the data, note we don't have as much information for generators - // originated from foreign crates - fn is_foreign(&self) -> bool { - match self { - GeneratorData::Local(_) => false, - GeneratorData::Foreign(_) => true, - } + visitor + .awaits + .into_iter() + .map(|id| hir.expect_expr(id)) + .find(|await_expr| ty_matches(ty::Binder::dummy(self.0.expr_ty_adjusted(&await_expr)))) + .map(|expr| expr.span) } } @@ -316,7 +249,7 @@ pub trait TypeErrCtxtExt<'tcx> { outer_generator: Option, trait_pred: ty::TraitPredicate<'tcx>, target_ty: Ty<'tcx>, - typeck_results: Option<&ty::TypeckResults<'tcx>>, + typeck_results: &ty::TypeckResults<'tcx>, obligation: &PredicateObligation<'tcx>, next_code: Option<&ObligationCauseCode<'tcx>>, ); @@ -2351,12 +2284,9 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { // cycles. If we can't use resolved types because the generator comes from another crate, // we still provide a targeted error but without all the relevant spans. let generator_data = match &self.typeck_results { - Some(t) if t.hir_owner.to_def_id() == generator_did_root => GeneratorData::Local(&t), + Some(t) if t.hir_owner.to_def_id() == generator_did_root => GeneratorData(&t), _ if generator_did.is_local() => { - GeneratorData::Local(self.tcx.typeck(generator_did.expect_local())) - } - _ if let Some(generator_diag_data) = self.tcx.generator_diagnostic_data(generator_did) => { - GeneratorData::Foreign(generator_diag_data) + GeneratorData(self.tcx.typeck(generator_did.expect_local())) } _ => return false, }; @@ -2368,30 +2298,11 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { let mut interior_or_upvar_span = None; - let from_awaited_ty = generator_data.get_from_await_ty(self.tcx, visitor, hir, ty_matches); + let from_awaited_ty = generator_data.get_from_await_ty(visitor, hir, ty_matches); debug!(?from_awaited_ty); - // The generator interior types share the same binders - if let Some(cause) = - generator_data.get_generator_interior_types().skip_binder().iter().find( - |ty::GeneratorInteriorTypeCause { ty, .. }| { - ty_matches(generator_data.get_generator_interior_types().rebind(*ty)) - }, - ) - { - let ty::GeneratorInteriorTypeCause { span, scope_span, yield_span, expr, .. } = cause; - - interior_or_upvar_span = Some(GeneratorInteriorOrUpvar::Interior( - *span, - Some((*scope_span, *yield_span, *expr, from_awaited_ty)), - )); - - if interior_or_upvar_span.is_none() && generator_data.is_foreign() { - interior_or_upvar_span = Some(GeneratorInteriorOrUpvar::Interior(*span, None)); - } - } else if self.tcx.sess.opts.unstable_opts.drop_tracking_mir - // Avoid disclosing internal information to downstream crates. - && generator_did.is_local() + // Avoid disclosing internal information to downstream crates. + if generator_did.is_local() // Try to avoid cycles. && !generator_within_in_progress_typeck && let Some(generator_info) = self.tcx.mir_generator_witnesses(generator_did) @@ -2420,17 +2331,14 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { generator_data.try_get_upvar_span(&self, generator_did, ty_matches); } - if interior_or_upvar_span.is_none() && generator_data.is_foreign() { + if interior_or_upvar_span.is_none() && !generator_did.is_local() { interior_or_upvar_span = Some(GeneratorInteriorOrUpvar::Interior(span, None)); } debug!(?interior_or_upvar_span); if let Some(interior_or_upvar_span) = interior_or_upvar_span { let is_async = self.tcx.generator_is_async(generator_did); - let typeck_results = match generator_data { - GeneratorData::Local(typeck_results) => Some(typeck_results), - GeneratorData::Foreign(_) => None, - }; + let typeck_results = generator_data.0; self.note_obligation_cause_for_async_await( err, interior_or_upvar_span, @@ -2459,7 +2367,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { outer_generator: Option, trait_pred: ty::TraitPredicate<'tcx>, target_ty: Ty<'tcx>, - typeck_results: Option<&ty::TypeckResults<'tcx>>, + typeck_results: &ty::TypeckResults<'tcx>, obligation: &PredicateObligation<'tcx>, next_code: Option<&ObligationCauseCode<'tcx>>, ) { @@ -2584,11 +2492,6 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { ); } else { // Look at the last interior type to get a span for the `.await`. - debug!( - generator_interior_types = ?format_args!( - "{:#?}", typeck_results.as_ref().map(|t| &t.generator_interior_types) - ), - ); explain_yield(interior_span, yield_span, scope_span); } @@ -2608,14 +2511,10 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { // ^^^^^^^ a temporary `&T` created inside this method call due to `&self` // ``` // - let is_region_borrow = if let Some(typeck_results) = typeck_results { - typeck_results - .expr_adjustments(expr) - .iter() - .any(|adj| adj.is_region_borrow()) - } else { - false - }; + let is_region_borrow = typeck_results + .expr_adjustments(expr) + .iter() + .any(|adj| adj.is_region_borrow()); // ```rust // struct Foo(*const u8); @@ -2628,16 +2527,14 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { DefKind::Fn | DefKind::Ctor(..) => target_ty.is_unsafe_ptr(), _ => false, }; - if let Some(typeck_results) = typeck_results { - if (typeck_results.is_method_call(e) && is_region_borrow) - || is_raw_borrow_inside_fn_like_call - { - err.span_help( - parent_span, - "consider moving this into a `let` \ + if (typeck_results.is_method_call(e) && is_region_borrow) + || is_raw_borrow_inside_fn_like_call + { + err.span_help( + parent_span, + "consider moving this into a `let` \ binding to create a shorter lived borrow", - ); - } + ); } } } diff --git a/compiler/rustc_ty_utils/src/needs_drop.rs b/compiler/rustc_ty_utils/src/needs_drop.rs index 1fc5d9359a4..76d381dd19f 100644 --- a/compiler/rustc_ty_utils/src/needs_drop.rs +++ b/compiler/rustc_ty_utils/src/needs_drop.rs @@ -7,7 +7,7 @@ use rustc_middle::ty::util::{needs_drop_components, AlwaysRequiresDrop}; use rustc_middle::ty::GenericArgsRef; use rustc_middle::ty::{self, EarlyBinder, Ty, TyCtxt}; use rustc_session::Limit; -use rustc_span::{sym, DUMMY_SP}; +use rustc_span::sym; use crate::errors::NeedsDropOverflow; @@ -133,7 +133,7 @@ where // The information required to determine whether a generator has drop is // computed on MIR, while this very method is used to build MIR. // To avoid cycles, we consider that generators always require drop. - ty::Generator(..) if tcx.sess.opts.unstable_opts.drop_tracking_mir => { + ty::Generator(..) => { return Some(Err(AlwaysRequiresDrop)); } @@ -145,29 +145,6 @@ where } } - ty::Generator(def_id, args, _) => { - let args = args.as_generator(); - for upvar in args.upvar_tys() { - queue_type(self, upvar); - } - - let witness = args.witness(); - let interior_tys = match witness.kind() { - &ty::GeneratorWitness(tys) => tcx.erase_late_bound_regions(tys), - _ => { - tcx.sess.delay_span_bug( - tcx.hir().span_if_local(def_id).unwrap_or(DUMMY_SP), - format!("unexpected generator witness type {witness:?}"), - ); - return Some(Err(AlwaysRequiresDrop)); - } - }; - - for interior_ty in interior_tys { - queue_type(self, interior_ty); - } - } - // Check for a `Drop` impl and whether this is a union or // `ManuallyDrop`. If it's a struct or enum without a `Drop` // impl then check whether the field types need `Drop`. diff --git a/src/tools/clippy/clippy_lints/src/await_holding_invalid.rs b/src/tools/clippy/clippy_lints/src/await_holding_invalid.rs index d40a385435a..7dd808a7b3b 100644 --- a/src/tools/clippy/clippy_lints/src/await_holding_invalid.rs +++ b/src/tools/clippy/clippy_lints/src/await_holding_invalid.rs @@ -2,9 +2,9 @@ use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::{match_def_path, paths}; use rustc_data_structures::fx::FxHashMap; use rustc_hir::def_id::DefId; -use rustc_hir::{AsyncGeneratorKind, Body, BodyId, GeneratorKind}; +use rustc_hir::{AsyncGeneratorKind, Body, GeneratorKind}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_middle::ty::GeneratorInteriorTypeCause; +use rustc_middle::mir::GeneratorLayout; use rustc_session::{declare_tool_lint, impl_lint_pass}; use rustc_span::{sym, Span}; @@ -197,28 +197,35 @@ impl LateLintPass<'_> for AwaitHolding { fn check_body(&mut self, cx: &LateContext<'_>, body: &'_ Body<'_>) { use AsyncGeneratorKind::{Block, Closure, Fn}; if let Some(GeneratorKind::Async(Block | Closure | Fn)) = body.generator_kind { - let body_id = BodyId { - hir_id: body.value.hir_id, - }; - let typeck_results = cx.tcx.typeck_body(body_id); - self.check_interior_types( - cx, - typeck_results.generator_interior_types.as_ref().skip_binder(), - body.value.span, - ); + let def_id = cx.tcx.hir().body_owner_def_id(body.id()); + if let Some(generator_layout) = cx.tcx.mir_generator_witnesses(def_id) { + self.check_interior_types(cx, generator_layout); + } } } } impl AwaitHolding { - fn check_interior_types(&self, cx: &LateContext<'_>, ty_causes: &[GeneratorInteriorTypeCause<'_>], span: Span) { - for ty_cause in ty_causes { + fn check_interior_types(&self, cx: &LateContext<'_>, generator: &GeneratorLayout<'_>) { + for (ty_index, ty_cause) in generator.field_tys.iter_enumerated() { if let rustc_middle::ty::Adt(adt, _) = ty_cause.ty.kind() { + let await_points = || { + generator + .variant_source_info + .iter_enumerated() + .filter_map(|(variant, source_info)| { + generator.variant_fields[variant] + .raw + .contains(&ty_index) + .then_some(source_info.span) + }) + .collect::>() + }; if is_mutex_guard(cx, adt.did()) { span_lint_and_then( cx, AWAIT_HOLDING_LOCK, - ty_cause.span, + ty_cause.source_info.span, "this `MutexGuard` is held across an `await` point", |diag| { diag.help( @@ -226,7 +233,7 @@ impl AwaitHolding { `MutexGuard` is dropped before calling await", ); diag.span_note( - ty_cause.scope_span.unwrap_or(span), + await_points(), "these are all the `await` points this lock is held through", ); }, @@ -235,18 +242,18 @@ impl AwaitHolding { span_lint_and_then( cx, AWAIT_HOLDING_REFCELL_REF, - ty_cause.span, + ty_cause.source_info.span, "this `RefCell` reference is held across an `await` point", |diag| { diag.help("ensure the reference is dropped before calling `await`"); diag.span_note( - ty_cause.scope_span.unwrap_or(span), + await_points(), "these are all the `await` points this reference is held through", ); }, ); } else if let Some(disallowed) = self.def_ids.get(&adt.did()) { - emit_invalid_type(cx, ty_cause.span, disallowed); + emit_invalid_type(cx, ty_cause.source_info.span, disallowed); } } } From 211d2ed07bb5dff7683fb021341db751cec2ca1e Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sat, 24 Jun 2023 10:02:54 +0000 Subject: [PATCH 18/30] Bless tests. --- .../async-await/async-await-let-else.stderr | 46 ++++++---- tests/ui/async-await/async-error-span.rs | 2 +- tests/ui/async-await/async-error-span.stderr | 13 ++- tests/ui/async-await/async-fn-nonsend.rs | 2 +- tests/ui/async-await/async-fn-nonsend.stderr | 6 -- .../ui/async-await/async-is-unwindsafe.stderr | 14 +-- tests/ui/async-await/await-sequence.rs | 1 - tests/ui/async-await/default-struct-update.rs | 1 - tests/ui/async-await/drop-and-assign.rs | 1 - .../drop-track-bad-field-in-fru.rs | 1 - .../drop-track-bad-field-in-fru.stderr | 4 +- .../drop-track-field-assign-nonsend.rs | 1 - .../drop-track-field-assign-nonsend.stderr | 8 +- .../ui/async-await/drop-track-field-assign.rs | 1 - ...drop-tracking-unresolved-typeck-results.rs | 3 - ...-tracking-unresolved-typeck-results.stderr | 40 +------- .../async-await/field-assign-nonsend.stderr | 2 - .../indirect-recursion-issue-112047.rs | 2 +- .../indirect-recursion-issue-112047.stderr | 9 +- tests/ui/async-await/issue-64130-1-sync.rs | 1 + .../ui/async-await/issue-64130-1-sync.stderr | 4 +- tests/ui/async-await/issue-64130-2-send.rs | 1 + .../ui/async-await/issue-64130-2-send.stderr | 4 +- tests/ui/async-await/issue-64130-3-other.rs | 1 + .../ui/async-await/issue-64130-3-other.stderr | 4 +- .../async-await/issue-64130-4-async-move.rs | 1 - .../issue-64130-non-send-future-diags.stderr | 2 - .../async-await/issue-67252-unnamed-future.rs | 3 +- .../issue-67252-unnamed-future.stderr | 20 ++-- tests/ui/async-await/issue-68112.rs | 2 +- tests/ui/async-await/issue-68112.stderr | 16 ++-- .../async-await/issue-70935-complex-spans.rs | 2 +- .../issue-70935-complex-spans.stderr | 40 ++++++-- tests/ui/async-await/issue-71137.stderr | 3 - tests/ui/async-await/issue-93197.rs | 1 - tests/ui/async-await/issue-93648.rs | 1 - .../issues/auxiliary/issue_67893.rs | 4 +- tests/ui/async-await/issues/issue-107280.rs | 5 - .../ui/async-await/issues/issue-107280.stderr | 67 +------------- .../issues/issue-65436-raw-ptr-not-send.rs | 1 - tests/ui/async-await/issues/issue-67893.rs | 2 +- .../ui/async-await/issues/issue-67893.stderr | 28 ++++-- tests/ui/async-await/non-trivial-drop.rs | 1 - .../partial-drop-partial-reinit.stderr | 2 +- .../issue-110963-early.current.stderr | 25 +++-- .../issue-110963-early.next.stderr | 25 +++-- .../issue-110963-early.stderr | 25 +++-- tests/ui/async-await/unresolved_type_param.rs | 14 +-- .../async-await/unresolved_type_param.stderr | 41 ++------- .../ui/borrowck/async-reference-generality.rs | 3 +- .../async-reference-generality.stderr | 27 ------ .../erase-error-in-mir-drop-tracking.rs | 23 ----- .../erase-error-in-mir-drop-tracking.stderr | 24 ----- .../subtyping-enforces-type-equality.stderr | 1 - tests/ui/generator/borrowing.stderr | 20 ++-- tests/ui/generator/clone-impl.stderr | 30 +++--- .../ui/generator/derived-drop-parent-expr.rs | 1 - tests/ui/generator/drop-control-flow.rs | 1 - .../generator/drop-track-addassign-yield.rs | 1 - .../ui/generator/drop-tracking-error-body.rs | 18 ---- .../generator/drop-tracking-error-body.stderr | 17 ---- .../drop-tracking-parent-expression.rs | 1 - .../drop-tracking-parent-expression.stderr | 36 +++----- .../drop-tracking-yielding-in-match-guards.rs | 1 - tests/ui/generator/drop-yield-twice.stderr | 15 +-- tests/ui/generator/issue-102645.rs | 2 - tests/ui/generator/issue-102645.stderr | 2 +- tests/ui/generator/issue-105084.rs | 2 - tests/ui/generator/issue-105084.stderr | 18 ++-- ...sue-110929-generator-conflict-error-ice.rs | 1 - ...110929-generator-conflict-error-ice.stderr | 2 +- tests/ui/generator/issue-57017.rs | 1 - tests/ui/generator/issue-57478.rs | 1 - tests/ui/generator/issue-68112.rs | 5 +- tests/ui/generator/issue-68112.stderr | 15 +-- tests/ui/generator/issue-93161.rs | 1 - tests/ui/generator/not-send-sync.rs | 16 +++- tests/ui/generator/not-send-sync.stderr | 72 ++++++--------- tests/ui/generator/parent-expression.rs | 2 - tests/ui/generator/parent-expression.stderr | 36 +++----- tests/ui/generator/partial-drop.rs | 14 +-- tests/ui/generator/partial-drop.stderr | 92 ------------------- .../print/generator-print-verbose-1.rs | 2 +- .../print/generator-print-verbose-1.stderr | 14 +-- .../print/generator-print-verbose-2.rs | 16 +++- .../print/generator-print-verbose-2.stderr | 72 ++++++--------- tests/ui/generator/retain-resume-ref.stderr | 7 +- tests/ui/generator/unresolved-ct-var.rs | 5 - tests/ui/generator/unresolved-ct-var.stderr | 65 +------------ ...eld.rs => unsized-capture-across-yield.rs} | 12 --- ...rr => unsized-capture-across-yield.stderr} | 15 +-- .../generator/unsized-local-across-yield.rs | 21 +++++ .../unsized-local-across-yield.stderr | 21 +++++ .../bugs/issue-100013.stderr | 30 ------ tests/ui/impl-trait/issue-55872-2.rs | 1 + tests/ui/impl-trait/issue-55872-2.stderr | 8 +- tests/ui/impl-trait/recursive-generator.rs | 1 - .../ui/impl-trait/recursive-generator.stderr | 15 +-- .../recursive-impl-trait-type-indirect.stderr | 15 +-- tests/ui/lint/must_not_suspend/dedup.rs | 5 +- tests/ui/lint/must_not_suspend/dedup.stderr | 15 +-- tests/ui/lint/must_not_suspend/ref.stderr | 14 +-- tests/ui/lint/must_not_suspend/unit.rs | 1 + tests/ui/lint/must_not_suspend/warn.rs | 3 +- tests/ui/lint/must_not_suspend/warn.stderr | 12 +-- .../new-solver/auto-with-drop_tracking_mir.rs | 2 +- tests/ui/traits/unsend-future.rs | 1 + tests/ui/traits/unsend-future.stderr | 4 +- .../indirect-recursion-issue-112047.rs | 2 +- .../indirect-recursion-issue-112047.stderr | 15 ++- 110 files changed, 483 insertions(+), 915 deletions(-) delete mode 100644 tests/ui/borrowck/async-reference-generality.stderr delete mode 100644 tests/ui/borrowck/erase-error-in-mir-drop-tracking.rs delete mode 100644 tests/ui/borrowck/erase-error-in-mir-drop-tracking.stderr delete mode 100644 tests/ui/codegen/subtyping-enforces-type-equality.stderr delete mode 100644 tests/ui/generator/drop-tracking-error-body.rs delete mode 100644 tests/ui/generator/drop-tracking-error-body.stderr delete mode 100644 tests/ui/generator/partial-drop.stderr rename tests/ui/generator/{unsized-across-yield.rs => unsized-capture-across-yield.rs} (66%) rename tests/ui/generator/{unsized-across-yield.stderr => unsized-capture-across-yield.stderr} (61%) create mode 100644 tests/ui/generator/unsized-local-across-yield.rs create mode 100644 tests/ui/generator/unsized-local-across-yield.stderr diff --git a/tests/ui/async-await/async-await-let-else.stderr b/tests/ui/async-await/async-await-let-else.stderr index b47201502f6..9a1c1782233 100644 --- a/tests/ui/async-await/async-await-let-else.stderr +++ b/tests/ui/async-await/async-await-let-else.stderr @@ -12,30 +12,43 @@ LL | let r = Rc::new(()); | - has type `Rc<()>` which is not `Send` LL | bar().await | ^^^^^ await occurs here, with `r` maybe used later -LL | }; - | - `r` is later dropped here note: required by a bound in `is_send` --> $DIR/async-await-let-else.rs:16:15 | LL | fn is_send(_: T) {} | ^^^^ required by this bound in `is_send` -error: future cannot be sent between threads safely +error[E0277]: `Rc<()>` cannot be sent between threads safely --> $DIR/async-await-let-else.rs:47:13 | +LL | async fn foo2(x: Option) { + | - within this `impl Future` +... LL | is_send(foo2(Some(true))); - | ^^^^^^^^^^^^^^^^ future returned by `foo2` is not `Send` + | ------- ^^^^^^^^^^^^^^^^ `Rc<()>` cannot be sent between threads safely + | | + | required by a bound introduced by this call | = help: within `impl Future`, the trait `Send` is not implemented for `Rc<()>` -note: future is not `Send` as this value is used across an await - --> $DIR/async-await-let-else.rs:20:27 +note: required because it's used within this `async fn` body + --> $DIR/async-await-let-else.rs:24:29 | -LL | bar2(Rc::new(())).await - | ----------- ^^^^^ await occurs here, with `Rc::new(())` maybe used later - | | - | has type `Rc<()>` which is not `Send` -LL | }; - | - `Rc::new(())` is later dropped here +LL | async fn bar2(_: T) -> ! { + | _____________________________^ +LL | | panic!() +LL | | } + | |_^ + = note: required because it captures the following types: `impl Future` +note: required because it's used within this `async fn` body + --> $DIR/async-await-let-else.rs:18:32 + | +LL | async fn foo2(x: Option) { + | ________________________________^ +LL | | let Some(_) = x else { +LL | | bar2(Rc::new(())).await +LL | | }; +LL | | } + | |_^ note: required by a bound in `is_send` --> $DIR/async-await-let-else.rs:16:15 | @@ -53,9 +66,8 @@ note: future is not `Send` as this value is used across an await --> $DIR/async-await-let-else.rs:30:29 | LL | (Rc::new(()), bar().await); - | ----------- ^^^^^ - `Rc::new(())` is later dropped here - | | | - | | await occurs here, with `Rc::new(())` maybe used later + | ----------- ^^^^^ await occurs here, with `Rc::new(())` maybe used later + | | | has type `Rc<()>` which is not `Send` note: required by a bound in `is_send` --> $DIR/async-await-let-else.rs:16:15 @@ -77,9 +89,6 @@ LL | let r = Rc::new(()); | - has type `Rc<()>` which is not `Send` LL | bar().await; | ^^^^^ await occurs here, with `r` maybe used later -... -LL | }; - | - `r` is later dropped here note: required by a bound in `is_send` --> $DIR/async-await-let-else.rs:16:15 | @@ -88,3 +97,4 @@ LL | fn is_send(_: T) {} error: aborting due to 4 previous errors +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/async-await/async-error-span.rs b/tests/ui/async-await/async-error-span.rs index 86d459bf084..c8127df625e 100644 --- a/tests/ui/async-await/async-error-span.rs +++ b/tests/ui/async-await/async-error-span.rs @@ -10,7 +10,7 @@ fn get_future() -> impl Future { } async fn foo() { - let a; //~ ERROR type inside `async fn` body must be known in this context + let a; //~ ERROR type annotations needed get_future().await; } diff --git a/tests/ui/async-await/async-error-span.stderr b/tests/ui/async-await/async-error-span.stderr index 68fb385718e..2ec968ffc03 100644 --- a/tests/ui/async-await/async-error-span.stderr +++ b/tests/ui/async-await/async-error-span.stderr @@ -7,19 +7,18 @@ LL | fn get_future() -> impl Future { = help: the trait `Future` is not implemented for `()` = note: () must be a future or must implement `IntoFuture` to be awaited -error[E0698]: type inside `async fn` body must be known in this context +error[E0282]: type annotations needed --> $DIR/async-error-span.rs:13:9 | LL | let a; - | ^ cannot infer type + | ^ | -note: the type is part of the `async fn` body because of this `await` - --> $DIR/async-error-span.rs:14:18 +help: consider giving `a` an explicit type | -LL | get_future().await; - | ^^^^^ +LL | let a: /* Type */; + | ++++++++++++ error: aborting due to 2 previous errors -Some errors have detailed explanations: E0277, E0698. +Some errors have detailed explanations: E0277, E0282. For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/async-await/async-fn-nonsend.rs b/tests/ui/async-await/async-fn-nonsend.rs index d7f8d7ac546..c5453b67ef5 100644 --- a/tests/ui/async-await/async-fn-nonsend.rs +++ b/tests/ui/async-await/async-fn-nonsend.rs @@ -1,5 +1,5 @@ // edition:2018 -// compile-flags: --crate-type lib -Zdrop-tracking +// compile-flags: --crate-type lib use std::{cell::RefCell, fmt::Debug, rc::Rc}; diff --git a/tests/ui/async-await/async-fn-nonsend.stderr b/tests/ui/async-await/async-fn-nonsend.stderr index 0d00fc072e1..0ced6c36f47 100644 --- a/tests/ui/async-await/async-fn-nonsend.stderr +++ b/tests/ui/async-await/async-fn-nonsend.stderr @@ -12,9 +12,6 @@ LL | match Some(non_send()) { | ---------------- has type `Option` which is not `Send` LL | Some(_) => fut().await, | ^^^^^ await occurs here, with `Some(non_send())` maybe used later -... -LL | } - | - `Some(non_send())` is later dropped here note: required by a bound in `assert_send` --> $DIR/async-fn-nonsend.rs:64:24 | @@ -36,9 +33,6 @@ LL | let f: &mut std::fmt::Formatter = &mut get_formatter(); ... LL | fut().await; | ^^^^^ await occurs here, with `get_formatter()` maybe used later -LL | } -LL | } - | - `get_formatter()` is later dropped here note: required by a bound in `assert_send` --> $DIR/async-fn-nonsend.rs:64:24 | diff --git a/tests/ui/async-await/async-is-unwindsafe.stderr b/tests/ui/async-await/async-is-unwindsafe.stderr index c21f8cfa51f..eaa45538050 100644 --- a/tests/ui/async-await/async-is-unwindsafe.stderr +++ b/tests/ui/async-await/async-is-unwindsafe.stderr @@ -1,18 +1,17 @@ error[E0277]: the type `&mut Context<'_>` may not be safely transferred across an unwind boundary - --> $DIR/async-is-unwindsafe.rs:12:19 + --> $DIR/async-is-unwindsafe.rs:12:5 | LL | is_unwindsafe(async { - | ___________________^ + | _____^^^^^^^^^^^^^_- + | | | + | | `&mut Context<'_>` may not be safely transferred across an unwind boundary LL | | LL | | use std::ptr::null; LL | | use std::task::{Context, RawWaker, RawWakerVTable, Waker}; ... | LL | | drop(cx_ref); LL | | }); - | | ^ - | | | - | |_____`&mut Context<'_>` may not be safely transferred across an unwind boundary - | within this `{async block@$DIR/async-is-unwindsafe.rs:12:19: 29:6}` + | |_____- within this `{async block@$DIR/async-is-unwindsafe.rs:12:19: 29:6}` | = help: within `{async block@$DIR/async-is-unwindsafe.rs:12:19: 29:6}`, the trait `UnwindSafe` is not implemented for `&mut Context<'_>` = note: `UnwindSafe` is implemented for `&Context<'_>`, but not for `&mut Context<'_>` @@ -24,9 +23,6 @@ LL | let cx_ref = &mut cx; LL | LL | async {}.await; // this needs an inner await point | ^^^^^ await occurs here, with `cx_ref` maybe used later -... -LL | }); - | - `cx_ref` is later dropped here note: required by a bound in `is_unwindsafe` --> $DIR/async-is-unwindsafe.rs:3:26 | diff --git a/tests/ui/async-await/await-sequence.rs b/tests/ui/async-await/await-sequence.rs index 726c4284ec1..79f68dd606c 100644 --- a/tests/ui/async-await/await-sequence.rs +++ b/tests/ui/async-await/await-sequence.rs @@ -1,5 +1,4 @@ // edition:2021 -// compile-flags: -Z drop-tracking // build-pass use std::collections::HashMap; diff --git a/tests/ui/async-await/default-struct-update.rs b/tests/ui/async-await/default-struct-update.rs index 64fb6280dd7..f4757e7cbae 100644 --- a/tests/ui/async-await/default-struct-update.rs +++ b/tests/ui/async-await/default-struct-update.rs @@ -1,6 +1,5 @@ // build-pass // edition:2018 -// compile-flags: -Zdrop-tracking=y fn main() { let _ = foo(); diff --git a/tests/ui/async-await/drop-and-assign.rs b/tests/ui/async-await/drop-and-assign.rs index fa3f3303677..ef39033a9d4 100644 --- a/tests/ui/async-await/drop-and-assign.rs +++ b/tests/ui/async-await/drop-and-assign.rs @@ -1,5 +1,4 @@ // edition:2021 -// compile-flags: -Zdrop-tracking // build-pass struct A; diff --git a/tests/ui/async-await/drop-track-bad-field-in-fru.rs b/tests/ui/async-await/drop-track-bad-field-in-fru.rs index 28ad7767583..667b288e676 100644 --- a/tests/ui/async-await/drop-track-bad-field-in-fru.rs +++ b/tests/ui/async-await/drop-track-bad-field-in-fru.rs @@ -1,4 +1,3 @@ -// compile-flags: -Zdrop-tracking // edition: 2021 fn main() {} diff --git a/tests/ui/async-await/drop-track-bad-field-in-fru.stderr b/tests/ui/async-await/drop-track-bad-field-in-fru.stderr index b49b15db64c..721e0106293 100644 --- a/tests/ui/async-await/drop-track-bad-field-in-fru.stderr +++ b/tests/ui/async-await/drop-track-bad-field-in-fru.stderr @@ -1,5 +1,5 @@ error[E0559]: variant `Option<_>::None` has no field named `value` - --> $DIR/drop-track-bad-field-in-fru.rs:7:12 + --> $DIR/drop-track-bad-field-in-fru.rs:6:12 | LL | None { value: (), ..Default::default() }.await; | ^^^^^ `Option<_>::None` does not have this field @@ -7,7 +7,7 @@ LL | None { value: (), ..Default::default() }.await; = note: all struct fields are already assigned error[E0277]: `Option<_>` is not a future - --> $DIR/drop-track-bad-field-in-fru.rs:7:46 + --> $DIR/drop-track-bad-field-in-fru.rs:6:46 | LL | None { value: (), ..Default::default() }.await; | -^^^^^ diff --git a/tests/ui/async-await/drop-track-field-assign-nonsend.rs b/tests/ui/async-await/drop-track-field-assign-nonsend.rs index b6c0fda1521..19315ef19f9 100644 --- a/tests/ui/async-await/drop-track-field-assign-nonsend.rs +++ b/tests/ui/async-await/drop-track-field-assign-nonsend.rs @@ -1,6 +1,5 @@ // Derived from an ICE found in tokio-xmpp during a crater run. // edition:2021 -// compile-flags: -Zdrop-tracking #![allow(dead_code)] diff --git a/tests/ui/async-await/drop-track-field-assign-nonsend.stderr b/tests/ui/async-await/drop-track-field-assign-nonsend.stderr index f36207b38a1..6c235916d64 100644 --- a/tests/ui/async-await/drop-track-field-assign-nonsend.stderr +++ b/tests/ui/async-await/drop-track-field-assign-nonsend.stderr @@ -1,22 +1,20 @@ error: future cannot be sent between threads safely - --> $DIR/drop-track-field-assign-nonsend.rs:43:17 + --> $DIR/drop-track-field-assign-nonsend.rs:42:17 | LL | assert_send(agent.handle()); | ^^^^^^^^^^^^^^ future returned by `handle` is not `Send` | = help: within `impl Future`, the trait `Send` is not implemented for `Rc` note: future is not `Send` as this value is used across an await - --> $DIR/drop-track-field-assign-nonsend.rs:21:39 + --> $DIR/drop-track-field-assign-nonsend.rs:20:39 | LL | let mut info = self.info_result.clone(); | -------- has type `InfoResult` which is not `Send` ... LL | let _ = send_element(element).await; | ^^^^^ await occurs here, with `mut info` maybe used later -LL | } - | - `mut info` is later dropped here note: required by a bound in `assert_send` - --> $DIR/drop-track-field-assign-nonsend.rs:38:19 + --> $DIR/drop-track-field-assign-nonsend.rs:37:19 | LL | fn assert_send(_: T) {} | ^^^^ required by this bound in `assert_send` diff --git a/tests/ui/async-await/drop-track-field-assign.rs b/tests/ui/async-await/drop-track-field-assign.rs index cfea7db2a10..4887eff7efa 100644 --- a/tests/ui/async-await/drop-track-field-assign.rs +++ b/tests/ui/async-await/drop-track-field-assign.rs @@ -1,6 +1,5 @@ // Derived from an ICE found in tokio-xmpp during a crater run. // edition:2021 -// compile-flags: -Zdrop-tracking // build-pass #![allow(dead_code)] diff --git a/tests/ui/async-await/drop-tracking-unresolved-typeck-results.rs b/tests/ui/async-await/drop-tracking-unresolved-typeck-results.rs index 7f729429581..9f80b9c6e9f 100644 --- a/tests/ui/async-await/drop-tracking-unresolved-typeck-results.rs +++ b/tests/ui/async-await/drop-tracking-unresolved-typeck-results.rs @@ -1,4 +1,3 @@ -// compile-flags: -Zdrop-tracking // incremental // edition: 2021 @@ -99,8 +98,6 @@ fn main() { send(async { //~^ ERROR implementation of `FnOnce` is not general enough //~| ERROR implementation of `FnOnce` is not general enough - //~| ERROR implementation of `FnOnce` is not general enough - //~| ERROR implementation of `FnOnce` is not general enough Next(&Buffered(Map(Empty(PhantomData), ready::<&()>), FuturesOrdered(PhantomData), 0)).await }); } diff --git a/tests/ui/async-await/drop-tracking-unresolved-typeck-results.stderr b/tests/ui/async-await/drop-tracking-unresolved-typeck-results.stderr index aa9a22e9e72..cfb0ebe38b6 100644 --- a/tests/ui/async-await/drop-tracking-unresolved-typeck-results.stderr +++ b/tests/ui/async-await/drop-tracking-unresolved-typeck-results.stderr @@ -1,11 +1,9 @@ error: implementation of `FnOnce` is not general enough - --> $DIR/drop-tracking-unresolved-typeck-results.rs:99:5 + --> $DIR/drop-tracking-unresolved-typeck-results.rs:98:5 | LL | / send(async { LL | | LL | | -LL | | -LL | | LL | | Next(&Buffered(Map(Empty(PhantomData), ready::<&()>), FuturesOrdered(PhantomData), 0)).await LL | | }); | |______^ implementation of `FnOnce` is not general enough @@ -14,13 +12,11 @@ LL | | }); = note: ...but it actually implements `FnOnce<(&(),)>` error: implementation of `FnOnce` is not general enough - --> $DIR/drop-tracking-unresolved-typeck-results.rs:99:5 + --> $DIR/drop-tracking-unresolved-typeck-results.rs:98:5 | LL | / send(async { LL | | LL | | -LL | | -LL | | LL | | Next(&Buffered(Map(Empty(PhantomData), ready::<&()>), FuturesOrdered(PhantomData), 0)).await LL | | }); | |______^ implementation of `FnOnce` is not general enough @@ -28,35 +24,5 @@ LL | | }); = note: `fn(&'0 ()) -> std::future::Ready<&'0 ()> {std::future::ready::<&'0 ()>}` must implement `FnOnce<(&'1 (),)>`, for any two lifetimes `'0` and `'1`... = note: ...but it actually implements `FnOnce<(&(),)>` -error: implementation of `FnOnce` is not general enough - --> $DIR/drop-tracking-unresolved-typeck-results.rs:99:5 - | -LL | / send(async { -LL | | -LL | | -LL | | -LL | | -LL | | Next(&Buffered(Map(Empty(PhantomData), ready::<&()>), FuturesOrdered(PhantomData), 0)).await -LL | | }); - | |______^ implementation of `FnOnce` is not general enough - | - = note: `fn(&'0 ()) -> std::future::Ready<&'0 ()> {std::future::ready::<&'0 ()>}` must implement `FnOnce<(&'1 (),)>`, for any two lifetimes `'0` and `'1`... - = note: ...but it actually implements `FnOnce<(&(),)>` - -error: implementation of `FnOnce` is not general enough - --> $DIR/drop-tracking-unresolved-typeck-results.rs:99:5 - | -LL | / send(async { -LL | | -LL | | -LL | | -LL | | -LL | | Next(&Buffered(Map(Empty(PhantomData), ready::<&()>), FuturesOrdered(PhantomData), 0)).await -LL | | }); - | |______^ implementation of `FnOnce` is not general enough - | - = note: `fn(&'0 ()) -> std::future::Ready<&'0 ()> {std::future::ready::<&'0 ()>}` must implement `FnOnce<(&'1 (),)>`, for any two lifetimes `'0` and `'1`... - = note: ...but it actually implements `FnOnce<(&(),)>` - -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors diff --git a/tests/ui/async-await/field-assign-nonsend.stderr b/tests/ui/async-await/field-assign-nonsend.stderr index 481b236bbdb..3037d702447 100644 --- a/tests/ui/async-await/field-assign-nonsend.stderr +++ b/tests/ui/async-await/field-assign-nonsend.stderr @@ -13,8 +13,6 @@ LL | let mut info = self.info_result.clone(); ... LL | let _ = send_element(element).await; | ^^^^^ await occurs here, with `mut info` maybe used later -LL | } - | - `mut info` is later dropped here note: required by a bound in `assert_send` --> $DIR/field-assign-nonsend.rs:37:19 | diff --git a/tests/ui/async-await/in-trait/indirect-recursion-issue-112047.rs b/tests/ui/async-await/in-trait/indirect-recursion-issue-112047.rs index 85d17ddff94..2fe6b473df6 100644 --- a/tests/ui/async-await/in-trait/indirect-recursion-issue-112047.rs +++ b/tests/ui/async-await/in-trait/indirect-recursion-issue-112047.rs @@ -1,6 +1,6 @@ // edition: 2021 // build-fail -//~^^ ERROR overflow evaluating the requirement `::{opaque#0} == _` +//~^^ ERROR cycle detected when computing layout of #![feature(async_fn_in_trait)] diff --git a/tests/ui/async-await/in-trait/indirect-recursion-issue-112047.stderr b/tests/ui/async-await/in-trait/indirect-recursion-issue-112047.stderr index 3f487a6e5fe..e0c1acfedfc 100644 --- a/tests/ui/async-await/in-trait/indirect-recursion-issue-112047.stderr +++ b/tests/ui/async-await/in-trait/indirect-recursion-issue-112047.stderr @@ -1,5 +1,10 @@ -error[E0275]: overflow evaluating the requirement `::{opaque#0} == _` +error[E0391]: cycle detected when computing layout of `{async fn body@$DIR/indirect-recursion-issue-112047.rs:35:27: 37:6}` + | + = note: ...which requires computing layout of `<::Second as Second>::{opaque#0}`... + = note: ...which again requires computing layout of `{async fn body@$DIR/indirect-recursion-issue-112047.rs:35:27: 37:6}`, completing the cycle + = note: cycle used when computing layout of `::second::{opaque#0}` + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to previous error -For more information about this error, try `rustc --explain E0275`. +For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/async-await/issue-64130-1-sync.rs b/tests/ui/async-await/issue-64130-1-sync.rs index 1714cec5221..7769085a0db 100644 --- a/tests/ui/async-await/issue-64130-1-sync.rs +++ b/tests/ui/async-await/issue-64130-1-sync.rs @@ -13,6 +13,7 @@ fn is_sync(t: T) { } async fn bar() { let x = Foo; baz().await; + drop(x); } async fn baz() { } diff --git a/tests/ui/async-await/issue-64130-1-sync.stderr b/tests/ui/async-await/issue-64130-1-sync.stderr index 06d26ea73dc..207e085d273 100644 --- a/tests/ui/async-await/issue-64130-1-sync.stderr +++ b/tests/ui/async-await/issue-64130-1-sync.stderr @@ -1,5 +1,5 @@ error: future cannot be shared between threads safely - --> $DIR/issue-64130-1-sync.rs:21:13 + --> $DIR/issue-64130-1-sync.rs:22:13 | LL | is_sync(bar()); | ^^^^^ future returned by `bar` is not `Sync` @@ -12,8 +12,6 @@ LL | let x = Foo; | - has type `Foo` which is not `Sync` LL | baz().await; | ^^^^^ await occurs here, with `x` maybe used later -LL | } - | - `x` is later dropped here note: required by a bound in `is_sync` --> $DIR/issue-64130-1-sync.rs:11:15 | diff --git a/tests/ui/async-await/issue-64130-2-send.rs b/tests/ui/async-await/issue-64130-2-send.rs index 7a6e5952cb9..0195afe6b39 100644 --- a/tests/ui/async-await/issue-64130-2-send.rs +++ b/tests/ui/async-await/issue-64130-2-send.rs @@ -13,6 +13,7 @@ fn is_send(t: T) { } async fn bar() { let x = Foo; baz().await; + drop(x); } async fn baz() { } diff --git a/tests/ui/async-await/issue-64130-2-send.stderr b/tests/ui/async-await/issue-64130-2-send.stderr index e71c78d6800..a433c76ae70 100644 --- a/tests/ui/async-await/issue-64130-2-send.stderr +++ b/tests/ui/async-await/issue-64130-2-send.stderr @@ -1,5 +1,5 @@ error: future cannot be sent between threads safely - --> $DIR/issue-64130-2-send.rs:21:13 + --> $DIR/issue-64130-2-send.rs:22:13 | LL | is_send(bar()); | ^^^^^ future returned by `bar` is not `Send` @@ -12,8 +12,6 @@ LL | let x = Foo; | - has type `Foo` which is not `Send` LL | baz().await; | ^^^^^ await occurs here, with `x` maybe used later -LL | } - | - `x` is later dropped here note: required by a bound in `is_send` --> $DIR/issue-64130-2-send.rs:11:15 | diff --git a/tests/ui/async-await/issue-64130-3-other.rs b/tests/ui/async-await/issue-64130-3-other.rs index 630fb2c41cd..074d67aa3fb 100644 --- a/tests/ui/async-await/issue-64130-3-other.rs +++ b/tests/ui/async-await/issue-64130-3-other.rs @@ -16,6 +16,7 @@ fn is_qux(t: T) {} async fn bar() { let x = Foo; baz().await; + drop(x); } async fn baz() {} diff --git a/tests/ui/async-await/issue-64130-3-other.stderr b/tests/ui/async-await/issue-64130-3-other.stderr index 4107784395f..573da1034c5 100644 --- a/tests/ui/async-await/issue-64130-3-other.stderr +++ b/tests/ui/async-await/issue-64130-3-other.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `Foo: Qux` is not satisfied in `impl Future` - --> $DIR/issue-64130-3-other.rs:24:12 + --> $DIR/issue-64130-3-other.rs:25:12 | LL | async fn bar() { | - within this `impl Future` @@ -14,8 +14,6 @@ LL | let x = Foo; | - has type `Foo` which does not implement `Qux` LL | baz().await; | ^^^^^ await occurs here, with `x` maybe used later -LL | } - | - `x` is later dropped here note: required by a bound in `is_qux` --> $DIR/issue-64130-3-other.rs:14:14 | diff --git a/tests/ui/async-await/issue-64130-4-async-move.rs b/tests/ui/async-await/issue-64130-4-async-move.rs index c333e160ef3..359813f6379 100644 --- a/tests/ui/async-await/issue-64130-4-async-move.rs +++ b/tests/ui/async-await/issue-64130-4-async-move.rs @@ -1,6 +1,5 @@ // edition:2018 // check-pass -// compile-flags: -Zdrop-tracking=yes use std::any::Any; use std::future::Future; diff --git a/tests/ui/async-await/issue-64130-non-send-future-diags.stderr b/tests/ui/async-await/issue-64130-non-send-future-diags.stderr index e044e2ca011..cb02fcf5ce7 100644 --- a/tests/ui/async-await/issue-64130-non-send-future-diags.stderr +++ b/tests/ui/async-await/issue-64130-non-send-future-diags.stderr @@ -12,8 +12,6 @@ LL | let g = x.lock().unwrap(); | - has type `MutexGuard<'_, u32>` which is not `Send` LL | baz().await; | ^^^^^ await occurs here, with `g` maybe used later -LL | } - | - `g` is later dropped here note: required by a bound in `is_send` --> $DIR/issue-64130-non-send-future-diags.rs:9:15 | diff --git a/tests/ui/async-await/issue-67252-unnamed-future.rs b/tests/ui/async-await/issue-67252-unnamed-future.rs index 1a7ff613341..60717d99346 100644 --- a/tests/ui/async-await/issue-67252-unnamed-future.rs +++ b/tests/ui/async-await/issue-67252-unnamed-future.rs @@ -16,8 +16,9 @@ impl Future for AFuture{ async fn foo() { spawn(async { //~ ERROR future cannot be sent between threads safely - let _a = std::ptr::null_mut::<()>(); // `*mut ()` is not `Send` + let a = std::ptr::null_mut::<()>(); // `*mut ()` is not `Send` AFuture.await; + let _a = a; }); } diff --git a/tests/ui/async-await/issue-67252-unnamed-future.stderr b/tests/ui/async-await/issue-67252-unnamed-future.stderr index 6aef35de0ca..069befa9121 100644 --- a/tests/ui/async-await/issue-67252-unnamed-future.stderr +++ b/tests/ui/async-await/issue-67252-unnamed-future.stderr @@ -1,23 +1,17 @@ error: future cannot be sent between threads safely - --> $DIR/issue-67252-unnamed-future.rs:18:11 + --> $DIR/issue-67252-unnamed-future.rs:18:5 | -LL | spawn(async { - | ___________^ -LL | | let _a = std::ptr::null_mut::<()>(); // `*mut ()` is not `Send` -LL | | AFuture.await; -LL | | }); - | |_____^ future created by async block is not `Send` +LL | spawn(async { + | ^^^^^ future created by async block is not `Send` | - = help: within `{async block@$DIR/issue-67252-unnamed-future.rs:18:11: 21:6}`, the trait `Send` is not implemented for `*mut ()` + = help: within `{async block@$DIR/issue-67252-unnamed-future.rs:18:11: 22:6}`, the trait `Send` is not implemented for `*mut ()` note: future is not `Send` as this value is used across an await --> $DIR/issue-67252-unnamed-future.rs:20:17 | -LL | let _a = std::ptr::null_mut::<()>(); // `*mut ()` is not `Send` - | -- has type `*mut ()` which is not `Send` +LL | let a = std::ptr::null_mut::<()>(); // `*mut ()` is not `Send` + | - has type `*mut ()` which is not `Send` LL | AFuture.await; - | ^^^^^ await occurs here, with `_a` maybe used later -LL | }); - | - `_a` is later dropped here + | ^^^^^ await occurs here, with `a` maybe used later note: required by a bound in `spawn` --> $DIR/issue-67252-unnamed-future.rs:6:13 | diff --git a/tests/ui/async-await/issue-68112.rs b/tests/ui/async-await/issue-68112.rs index 0005b90efc2..fd6089e0c03 100644 --- a/tests/ui/async-await/issue-68112.rs +++ b/tests/ui/async-await/issue-68112.rs @@ -11,7 +11,7 @@ use std::{ fn require_send(_: impl Send) {} struct Ready(Option); -impl Future for Ready { +impl Future for Ready { type Output = T; fn poll(mut self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll { Poll::Ready(self.0.take().unwrap()) diff --git a/tests/ui/async-await/issue-68112.stderr b/tests/ui/async-await/issue-68112.stderr index aec2541c9e6..17b619ebee3 100644 --- a/tests/ui/async-await/issue-68112.stderr +++ b/tests/ui/async-await/issue-68112.stderr @@ -1,8 +1,8 @@ error: future cannot be sent between threads safely - --> $DIR/issue-68112.rs:34:18 + --> $DIR/issue-68112.rs:34:5 | LL | require_send(send_fut); - | ^^^^^^^^ future created by async block is not `Send` + | ^^^^^^^^^^^^ future created by async block is not `Send` | = help: the trait `Sync` is not implemented for `RefCell` = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead @@ -18,10 +18,10 @@ LL | fn require_send(_: impl Send) {} | ^^^^ required by this bound in `require_send` error: future cannot be sent between threads safely - --> $DIR/issue-68112.rs:43:18 + --> $DIR/issue-68112.rs:43:5 | LL | require_send(send_fut); - | ^^^^^^^^ future created by async block is not `Send` + | ^^^^^^^^^^^^ future created by async block is not `Send` | = help: the trait `Sync` is not implemented for `RefCell` = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead @@ -37,12 +37,10 @@ LL | fn require_send(_: impl Send) {} | ^^^^ required by this bound in `require_send` error[E0277]: `RefCell` cannot be shared between threads safely - --> $DIR/issue-68112.rs:62:18 + --> $DIR/issue-68112.rs:62:5 | LL | require_send(send_fut); - | ------------ ^^^^^^^^ `RefCell` cannot be shared between threads safely - | | - | required by a bound introduced by this call + | ^^^^^^^^^^^^ `RefCell` cannot be shared between threads safely | = help: the trait `Sync` is not implemented for `RefCell` = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead @@ -60,7 +58,7 @@ note: required because it appears within the type `impl Future impl Future>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: required because it captures the following types: `ResumeTy`, `impl Future>>`, `()`, `i32`, `Ready` + = note: required because it captures the following types: `impl Future>>`, `Ready` note: required because it's used within this `async` block --> $DIR/issue-68112.rs:57:20 | diff --git a/tests/ui/async-await/issue-70935-complex-spans.rs b/tests/ui/async-await/issue-70935-complex-spans.rs index 33aa89c5a5d..4af73739584 100644 --- a/tests/ui/async-await/issue-70935-complex-spans.rs +++ b/tests/ui/async-await/issue-70935-complex-spans.rs @@ -13,7 +13,7 @@ async fn baz(_c: impl FnMut() -> T) where T: Future { } fn foo(x: NotSync) -> impl Future + Send { - //~^ ERROR future cannot be sent between threads safely + //~^ ERROR `*mut ()` cannot be shared between threads safely async move { baz(|| async { foo(x.clone()); diff --git a/tests/ui/async-await/issue-70935-complex-spans.stderr b/tests/ui/async-await/issue-70935-complex-spans.stderr index 5d8ef77616a..ab834daa85d 100644 --- a/tests/ui/async-await/issue-70935-complex-spans.stderr +++ b/tests/ui/async-await/issue-70935-complex-spans.stderr @@ -1,21 +1,41 @@ -error: future cannot be sent between threads safely +error[E0277]: `*mut ()` cannot be shared between threads safely --> $DIR/issue-70935-complex-spans.rs:15:23 | LL | fn foo(x: NotSync) -> impl Future + Send { - | ^^^^^^^^^^^^^^^^^^ future created by async block is not `Send` + | ^^^^^^^^^^^^^^^^^^ `*mut ()` cannot be shared between threads safely | = help: within `NotSync`, the trait `Sync` is not implemented for `*mut ()` -note: future is not `Send` as this value is used across an await - --> $DIR/issue-70935-complex-spans.rs:20:12 +note: required because it appears within the type `PhantomData<*mut ()>` + --> $SRC_DIR/core/src/marker.rs:LL:COL +note: required because it appears within the type `NotSync` + --> $DIR/issue-70935-complex-spans.rs:9:8 | -LL | baz(|| async { - | _____________- +LL | struct NotSync(PhantomData<*mut ()>); + | ^^^^^^^ + = note: required for `&NotSync` to implement `Send` +note: required because it's used within this closure + --> $DIR/issue-70935-complex-spans.rs:18:13 + | +LL | baz(|| async { + | ^^ +note: required because it's used within this `async fn` body + --> $DIR/issue-70935-complex-spans.rs:12:67 + | +LL | async fn baz(_c: impl FnMut() -> T) where T: Future { + | ___________________________________________________________________^ +LL | | } + | |_^ + = note: required because it captures the following types: `impl Future` +note: required because it's used within this `async` block + --> $DIR/issue-70935-complex-spans.rs:17:5 + | +LL | / async move { +LL | | baz(|| async { LL | | foo(x.clone()); LL | | }).await; - | | - ^^^^^- the value is later dropped here - | | | | - | |_________| await occurs here, with the value maybe used later - | has type `{closure@$DIR/issue-70935-complex-spans.rs:18:13: 18:15}` which is not `Send` +LL | | } + | |_____^ error: aborting due to previous error +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/async-await/issue-71137.stderr b/tests/ui/async-await/issue-71137.stderr index a344246d6bf..443af010c4a 100644 --- a/tests/ui/async-await/issue-71137.stderr +++ b/tests/ui/async-await/issue-71137.stderr @@ -12,9 +12,6 @@ LL | let mut guard = m.lock().unwrap(); | --------- has type `MutexGuard<'_, i32>` which is not `Send` LL | (async { "right"; }).await; | ^^^^^ await occurs here, with `mut guard` maybe used later -LL | *guard += 1; -LL | } - | - `mut guard` is later dropped here note: required by a bound in `fake_spawn` --> $DIR/issue-71137.rs:8:27 | diff --git a/tests/ui/async-await/issue-93197.rs b/tests/ui/async-await/issue-93197.rs index c627fe17afb..05ec013d0af 100644 --- a/tests/ui/async-await/issue-93197.rs +++ b/tests/ui/async-await/issue-93197.rs @@ -1,7 +1,6 @@ // Regression test for #93197 // check-pass // edition:2021 -// compile-flags: -Zdrop-tracking #![feature(try_blocks)] diff --git a/tests/ui/async-await/issue-93648.rs b/tests/ui/async-await/issue-93648.rs index 4ce3ac1e874..b27a79a428b 100644 --- a/tests/ui/async-await/issue-93648.rs +++ b/tests/ui/async-await/issue-93648.rs @@ -1,6 +1,5 @@ // edition:2021 // build-pass -// compile-flags: -Zdrop-tracking fn main() { let _ = async { diff --git a/tests/ui/async-await/issues/auxiliary/issue_67893.rs b/tests/ui/async-await/issues/auxiliary/issue_67893.rs index 387966a5064..efde4d2864d 100644 --- a/tests/ui/async-await/issues/auxiliary/issue_67893.rs +++ b/tests/ui/async-await/issues/auxiliary/issue_67893.rs @@ -2,9 +2,11 @@ use std::sync::{Arc, Mutex}; +fn make_arc() -> Arc> { unimplemented!() } + pub async fn f(_: ()) {} pub async fn run() { - let x: Arc> = unimplemented!(); + let x: Arc> = make_arc(); f(*x.lock().unwrap()).await; } diff --git a/tests/ui/async-await/issues/issue-107280.rs b/tests/ui/async-await/issues/issue-107280.rs index 85fce87403a..81ae9553cf0 100644 --- a/tests/ui/async-await/issues/issue-107280.rs +++ b/tests/ui/async-await/issues/issue-107280.rs @@ -3,11 +3,6 @@ async fn foo() { inner::().await //~^ ERROR: function takes 2 generic arguments but 1 generic argument was supplied - //~| ERROR: type inside `async fn` body must be known in this context - //~| ERROR: type inside `async fn` body must be known in this context - //~| ERROR: type inside `async fn` body must be known in this context - //~| ERROR: type inside `async fn` body must be known in this context - //~| ERROR: type inside `async fn` body must be known in this context } async fn inner() {} diff --git a/tests/ui/async-await/issues/issue-107280.stderr b/tests/ui/async-await/issues/issue-107280.stderr index 2e69862a0e0..c5fd5c5bf0a 100644 --- a/tests/ui/async-await/issues/issue-107280.stderr +++ b/tests/ui/async-await/issues/issue-107280.stderr @@ -7,7 +7,7 @@ LL | inner::().await | expected 2 generic arguments | note: function defined here, with 2 generic parameters: `T`, `PING` - --> $DIR/issue-107280.rs:13:10 + --> $DIR/issue-107280.rs:8:10 | LL | async fn inner() {} | ^^^^^ - ---------------- @@ -16,67 +16,6 @@ help: add missing generic argument LL | inner::().await | ++++++ -error[E0698]: type inside `async fn` body must be known in this context - --> $DIR/issue-107280.rs:4:5 - | -LL | inner::().await - | ^^^^^^^^^^^^^^ cannot infer the value of const parameter `PING` declared on the function `inner` - | -note: the type is part of the `async fn` body because of this `await` - --> $DIR/issue-107280.rs:4:22 - | -LL | inner::().await - | ^^^^^ +error: aborting due to previous error -error[E0698]: type inside `async fn` body must be known in this context - --> $DIR/issue-107280.rs:4:5 - | -LL | inner::().await - | ^^^^^^^^^^^^^^ cannot infer the value of const parameter `PING` declared on the function `inner` - | -note: the type is part of the `async fn` body because of this `await` - --> $DIR/issue-107280.rs:4:22 - | -LL | inner::().await - | ^^^^^ - -error[E0698]: type inside `async fn` body must be known in this context - --> $DIR/issue-107280.rs:4:5 - | -LL | inner::().await - | ^^^^^^^^^^^^^^ cannot infer the value of const parameter `PING` declared on the function `inner` - | -note: the type is part of the `async fn` body because of this `await` - --> $DIR/issue-107280.rs:4:22 - | -LL | inner::().await - | ^^^^^ - -error[E0698]: type inside `async fn` body must be known in this context - --> $DIR/issue-107280.rs:4:5 - | -LL | inner::().await - | ^^^^^^^^^^^^^^ cannot infer the value of const parameter `PING` declared on the function `inner` - | -note: the type is part of the `async fn` body because of this `await` - --> $DIR/issue-107280.rs:4:22 - | -LL | inner::().await - | ^^^^^ - -error[E0698]: type inside `async fn` body must be known in this context - --> $DIR/issue-107280.rs:4:5 - | -LL | inner::().await - | ^^^^^^^^^^^^^^ cannot infer the value of const parameter `PING` declared on the function `inner` - | -note: the type is part of the `async fn` body because of this `await` - --> $DIR/issue-107280.rs:4:22 - | -LL | inner::().await - | ^^^^^ - -error: aborting due to 6 previous errors - -Some errors have detailed explanations: E0107, E0698. -For more information about an error, try `rustc --explain E0107`. +For more information about this error, try `rustc --explain E0107`. diff --git a/tests/ui/async-await/issues/issue-65436-raw-ptr-not-send.rs b/tests/ui/async-await/issues/issue-65436-raw-ptr-not-send.rs index a6a45bea897..ef6f105f34a 100644 --- a/tests/ui/async-await/issues/issue-65436-raw-ptr-not-send.rs +++ b/tests/ui/async-await/issues/issue-65436-raw-ptr-not-send.rs @@ -1,6 +1,5 @@ // edition:2018 // check-pass -// compile-flags: -Zdrop-tracking=yes struct Foo(*const u8); diff --git a/tests/ui/async-await/issues/issue-67893.rs b/tests/ui/async-await/issues/issue-67893.rs index d73772e5fa0..359c75f170c 100644 --- a/tests/ui/async-await/issues/issue-67893.rs +++ b/tests/ui/async-await/issues/issue-67893.rs @@ -7,5 +7,5 @@ fn g(_: impl Send) {} fn main() { g(issue_67893::run()) - //~^ ERROR future cannot be sent between threads safely + //~^ ERROR `MutexGuard<'_, ()>` cannot be sent between threads safely } diff --git a/tests/ui/async-await/issues/issue-67893.stderr b/tests/ui/async-await/issues/issue-67893.stderr index e1bea29e923..f36269e8f36 100644 --- a/tests/ui/async-await/issues/issue-67893.stderr +++ b/tests/ui/async-await/issues/issue-67893.stderr @@ -1,18 +1,27 @@ -error: future cannot be sent between threads safely +error[E0277]: `MutexGuard<'_, ()>` cannot be sent between threads safely --> $DIR/issue-67893.rs:9:7 | LL | g(issue_67893::run()) - | ^^^^^^^^^^^^^^^^^^ future is not `Send` + | - ^^^^^^^^^^^^^^^^^^ `MutexGuard<'_, ()>` cannot be sent between threads safely + | | + | required by a bound introduced by this call + | + ::: $DIR/auxiliary/issue_67893.rs:9:20 + | +LL | pub async fn run() { + | - within this `impl Future` | = help: within `impl Future`, the trait `Send` is not implemented for `MutexGuard<'_, ()>` -note: future is not `Send` as this value is used across an await - --> $DIR/auxiliary/issue_67893.rs:9:27 + = note: required because it captures the following types: `Arc>`, `MutexGuard<'_, ()>`, `impl Future` +note: required because it's used within this `async fn` body + --> $DIR/auxiliary/issue_67893.rs:9:20 | -LL | f(*x.lock().unwrap()).await; - | ----------------- ^^^^^- `x.lock().unwrap()` is later dropped here - | | | - | | await occurs here, with `x.lock().unwrap()` maybe used later - | has type `MutexGuard<'_, ()>` which is not `Send` +LL | pub async fn run() { + | ____________________^ +LL | | let x: Arc> = make_arc(); +LL | | f(*x.lock().unwrap()).await; +LL | | } + | |_^ note: required by a bound in `g` --> $DIR/issue-67893.rs:6:14 | @@ -21,3 +30,4 @@ LL | fn g(_: impl Send) {} error: aborting due to previous error +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/async-await/non-trivial-drop.rs b/tests/ui/async-await/non-trivial-drop.rs index 214e345783b..3fed7c972a1 100644 --- a/tests/ui/async-await/non-trivial-drop.rs +++ b/tests/ui/async-await/non-trivial-drop.rs @@ -1,6 +1,5 @@ // build-pass // edition:2018 -// compile-flags: -Zdrop-tracking=y #![feature(generators)] diff --git a/tests/ui/async-await/partial-drop-partial-reinit.stderr b/tests/ui/async-await/partial-drop-partial-reinit.stderr index 05f5358340a..85e1830c78e 100644 --- a/tests/ui/async-await/partial-drop-partial-reinit.stderr +++ b/tests/ui/async-await/partial-drop-partial-reinit.stderr @@ -11,7 +11,7 @@ LL | async fn foo() { | = help: within `impl Future`, the trait `Send` is not implemented for `NotSend` = note: required because it appears within the type `(NotSend,)` - = note: required because it captures the following types: `ResumeTy`, `(NotSend,)`, `impl Future`, `()` + = note: required because it captures the following types: `(NotSend,)`, `impl Future` note: required because it's used within this `async fn` body --> $DIR/partial-drop-partial-reinit.rs:28:16 | diff --git a/tests/ui/async-await/return-type-notation/issue-110963-early.current.stderr b/tests/ui/async-await/return-type-notation/issue-110963-early.current.stderr index 1b847b59eb5..77385e966ce 100644 --- a/tests/ui/async-await/return-type-notation/issue-110963-early.current.stderr +++ b/tests/ui/async-await/return-type-notation/issue-110963-early.current.stderr @@ -7,7 +7,7 @@ LL | #![feature(return_type_notation)] = note: see issue #109417 for more information = note: `#[warn(incomplete_features)]` on by default -error: higher-ranked lifetime error +error[E0308]: mismatched types --> $DIR/issue-110963-early.rs:17:5 | LL | / spawn(async move { @@ -16,11 +16,17 @@ LL | | if !hc.check().await { LL | | log_health_check_failure().await; LL | | } LL | | }); - | |______^ + | |______^ one type is more general than the other | - = note: could not prove `[async block@$DIR/issue-110963-early.rs:17:11: 22:6]: Send` + = note: expected trait `Send` + found trait `for<'a> Send` +note: the lifetime requirement is introduced here + --> $DIR/issue-110963-early.rs:37:17 + | +LL | F: Future + Send + 'static, + | ^^^^ -error: higher-ranked lifetime error +error[E0308]: mismatched types --> $DIR/issue-110963-early.rs:17:5 | LL | / spawn(async move { @@ -29,9 +35,16 @@ LL | | if !hc.check().await { LL | | log_health_check_failure().await; LL | | } LL | | }); - | |______^ + | |______^ one type is more general than the other | - = note: could not prove `[async block@$DIR/issue-110963-early.rs:17:11: 22:6]: Send` + = note: expected trait `Send` + found trait `for<'a> Send` +note: the lifetime requirement is introduced here + --> $DIR/issue-110963-early.rs:37:17 + | +LL | F: Future + Send + 'static, + | ^^^^ error: aborting due to 2 previous errors; 1 warning emitted +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/async-await/return-type-notation/issue-110963-early.next.stderr b/tests/ui/async-await/return-type-notation/issue-110963-early.next.stderr index 1b847b59eb5..77385e966ce 100644 --- a/tests/ui/async-await/return-type-notation/issue-110963-early.next.stderr +++ b/tests/ui/async-await/return-type-notation/issue-110963-early.next.stderr @@ -7,7 +7,7 @@ LL | #![feature(return_type_notation)] = note: see issue #109417 for more information = note: `#[warn(incomplete_features)]` on by default -error: higher-ranked lifetime error +error[E0308]: mismatched types --> $DIR/issue-110963-early.rs:17:5 | LL | / spawn(async move { @@ -16,11 +16,17 @@ LL | | if !hc.check().await { LL | | log_health_check_failure().await; LL | | } LL | | }); - | |______^ + | |______^ one type is more general than the other | - = note: could not prove `[async block@$DIR/issue-110963-early.rs:17:11: 22:6]: Send` + = note: expected trait `Send` + found trait `for<'a> Send` +note: the lifetime requirement is introduced here + --> $DIR/issue-110963-early.rs:37:17 + | +LL | F: Future + Send + 'static, + | ^^^^ -error: higher-ranked lifetime error +error[E0308]: mismatched types --> $DIR/issue-110963-early.rs:17:5 | LL | / spawn(async move { @@ -29,9 +35,16 @@ LL | | if !hc.check().await { LL | | log_health_check_failure().await; LL | | } LL | | }); - | |______^ + | |______^ one type is more general than the other | - = note: could not prove `[async block@$DIR/issue-110963-early.rs:17:11: 22:6]: Send` + = note: expected trait `Send` + found trait `for<'a> Send` +note: the lifetime requirement is introduced here + --> $DIR/issue-110963-early.rs:37:17 + | +LL | F: Future + Send + 'static, + | ^^^^ error: aborting due to 2 previous errors; 1 warning emitted +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/async-await/return-type-notation/issue-110963-early.stderr b/tests/ui/async-await/return-type-notation/issue-110963-early.stderr index 4ca5519c438..969094a2c58 100644 --- a/tests/ui/async-await/return-type-notation/issue-110963-early.stderr +++ b/tests/ui/async-await/return-type-notation/issue-110963-early.stderr @@ -7,7 +7,7 @@ LL | #![feature(return_type_notation)] = note: see issue #109417 for more information = note: `#[warn(incomplete_features)]` on by default -error: higher-ranked lifetime error +error[E0308]: mismatched types --> $DIR/issue-110963-early.rs:15:5 | LL | / spawn(async move { @@ -16,11 +16,17 @@ LL | | if !hc.check().await { LL | | log_health_check_failure().await; LL | | } LL | | }); - | |______^ + | |______^ one type is more general than the other | - = note: could not prove `{async block@$DIR/issue-110963-early.rs:15:11: 20:6}: Send` + = note: expected trait `Send` + found trait `for<'a> Send` +note: the lifetime requirement is introduced here + --> $DIR/issue-110963-early.rs:35:17 + | +LL | F: Future + Send + 'static, + | ^^^^ -error: higher-ranked lifetime error +error[E0308]: mismatched types --> $DIR/issue-110963-early.rs:15:5 | LL | / spawn(async move { @@ -29,9 +35,16 @@ LL | | if !hc.check().await { LL | | log_health_check_failure().await; LL | | } LL | | }); - | |______^ + | |______^ one type is more general than the other | - = note: could not prove `{async block@$DIR/issue-110963-early.rs:15:11: 20:6}: Send` + = note: expected trait `Send` + found trait `for<'a> Send` +note: the lifetime requirement is introduced here + --> $DIR/issue-110963-early.rs:35:17 + | +LL | F: Future + Send + 'static, + | ^^^^ error: aborting due to 2 previous errors; 1 warning emitted +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/async-await/unresolved_type_param.rs b/tests/ui/async-await/unresolved_type_param.rs index 6d6d8061491..dd5aa0dd077 100644 --- a/tests/ui/async-await/unresolved_type_param.rs +++ b/tests/ui/async-await/unresolved_type_param.rs @@ -2,23 +2,11 @@ // Error message should pinpoint the type parameter T as needing to be bound // (rather than give a general error message) // edition:2018 -// compile-flags: -Zdrop-tracking async fn bar() -> () {} async fn foo() { bar().await; - //~^ ERROR type inside `async fn` body must be known in this context - //~| ERROR type inside `async fn` body must be known in this context - //~| ERROR type inside `async fn` body must be known in this context - //~| NOTE cannot infer type for type parameter `T` - //~| NOTE cannot infer type for type parameter `T` - //~| NOTE cannot infer type for type parameter `T` - //~| NOTE the type is part of the `async fn` body because of this `await` - //~| NOTE the type is part of the `async fn` body because of this `await` - //~| NOTE the type is part of the `async fn` body because of this `await` - //~| NOTE in this expansion of desugaring of `await` - //~| NOTE in this expansion of desugaring of `await` - //~| NOTE in this expansion of desugaring of `await` + //~^ ERROR type annotations needed } fn main() {} diff --git a/tests/ui/async-await/unresolved_type_param.stderr b/tests/ui/async-await/unresolved_type_param.stderr index ea78c2818c7..45aa766065e 100644 --- a/tests/ui/async-await/unresolved_type_param.stderr +++ b/tests/ui/async-await/unresolved_type_param.stderr @@ -1,39 +1,14 @@ -error[E0698]: type inside `async fn` body must be known in this context - --> $DIR/unresolved_type_param.rs:10:5 +error[E0282]: type annotations needed + --> $DIR/unresolved_type_param.rs:9:5 | LL | bar().await; - | ^^^ cannot infer type for type parameter `T` declared on the function `bar` + | ^^^ cannot infer type of the type parameter `T` declared on the function `bar` | -note: the type is part of the `async fn` body because of this `await` - --> $DIR/unresolved_type_param.rs:10:11 +help: consider specifying the generic argument | -LL | bar().await; - | ^^^^^ +LL | bar::().await; + | +++++ -error[E0698]: type inside `async fn` body must be known in this context - --> $DIR/unresolved_type_param.rs:10:5 - | -LL | bar().await; - | ^^^ cannot infer type for type parameter `T` declared on the function `bar` - | -note: the type is part of the `async fn` body because of this `await` - --> $DIR/unresolved_type_param.rs:10:11 - | -LL | bar().await; - | ^^^^^ +error: aborting due to previous error -error[E0698]: type inside `async fn` body must be known in this context - --> $DIR/unresolved_type_param.rs:10:5 - | -LL | bar().await; - | ^^^ cannot infer type for type parameter `T` declared on the function `bar` - | -note: the type is part of the `async fn` body because of this `await` - --> $DIR/unresolved_type_param.rs:10:11 - | -LL | bar().await; - | ^^^^^ - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0698`. +For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/borrowck/async-reference-generality.rs b/tests/ui/borrowck/async-reference-generality.rs index 487d1ac81bf..668df9ea710 100644 --- a/tests/ui/borrowck/async-reference-generality.rs +++ b/tests/ui/borrowck/async-reference-generality.rs @@ -1,5 +1,4 @@ -// check-fail -// known-bug: #99492 +// check-pass // edition: 2021 use std::marker::PhantomData; diff --git a/tests/ui/borrowck/async-reference-generality.stderr b/tests/ui/borrowck/async-reference-generality.stderr deleted file mode 100644 index af720ad2931..00000000000 --- a/tests/ui/borrowck/async-reference-generality.stderr +++ /dev/null @@ -1,27 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/async-reference-generality.rs:23:5 - | -LL | / async { -LL | | let _x = Struct::, _>(PhantomData); -LL | | async {}.await; -LL | | } - | |_____^ one type is more general than the other - | - = note: expected reference `&()` - found reference `&()` - -error[E0308]: mismatched types - --> $DIR/async-reference-generality.rs:23:5 - | -LL | / async { -LL | | let _x = Struct::, _>(PhantomData); -LL | | async {}.await; -LL | | } - | |_____^ one type is more general than the other - | - = note: expected reference `&()` - found reference `&()` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/borrowck/erase-error-in-mir-drop-tracking.rs b/tests/ui/borrowck/erase-error-in-mir-drop-tracking.rs deleted file mode 100644 index addbe5d658a..00000000000 --- a/tests/ui/borrowck/erase-error-in-mir-drop-tracking.rs +++ /dev/null @@ -1,23 +0,0 @@ -// compile-flags: -Zdrop-tracking-mir -// edition:2021 - -use std::future::Future; - -trait Client { - type Connecting<'a>: Future + Send - where - Self: 'a; - - fn connect(&'_ self) -> Self::Connecting<'a>; - //~^ ERROR use of undeclared lifetime name `'a` -} - -fn call_connect(c: &'_ C) -> impl '_ + Future + Send -where - C: Client + Send + Sync, -{ - async move { c.connect().await } - //~^ ERROR `C` does not live long enough -} - -fn main() {} diff --git a/tests/ui/borrowck/erase-error-in-mir-drop-tracking.stderr b/tests/ui/borrowck/erase-error-in-mir-drop-tracking.stderr deleted file mode 100644 index 53abe3dc952..00000000000 --- a/tests/ui/borrowck/erase-error-in-mir-drop-tracking.stderr +++ /dev/null @@ -1,24 +0,0 @@ -error[E0261]: use of undeclared lifetime name `'a` - --> $DIR/erase-error-in-mir-drop-tracking.rs:11:46 - | -LL | fn connect(&'_ self) -> Self::Connecting<'a>; - | ^^ undeclared lifetime - | -help: consider introducing lifetime `'a` here - | -LL | fn connect<'a>(&'_ self) -> Self::Connecting<'a>; - | ++++ -help: consider introducing lifetime `'a` here - | -LL | trait Client<'a> { - | ++++ - -error: `C` does not live long enough - --> $DIR/erase-error-in-mir-drop-tracking.rs:19:5 - | -LL | async move { c.connect().await } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0261`. diff --git a/tests/ui/codegen/subtyping-enforces-type-equality.stderr b/tests/ui/codegen/subtyping-enforces-type-equality.stderr deleted file mode 100644 index 870ca0f839f..00000000000 --- a/tests/ui/codegen/subtyping-enforces-type-equality.stderr +++ /dev/null @@ -1 +0,0 @@ -WARN rustc_codegen_ssa::mir::locals Unexpected initial operand type. See the issues/114858 diff --git a/tests/ui/generator/borrowing.stderr b/tests/ui/generator/borrowing.stderr index 38e1ace8c4e..03a69fe3623 100644 --- a/tests/ui/generator/borrowing.stderr +++ b/tests/ui/generator/borrowing.stderr @@ -1,16 +1,24 @@ error[E0597]: `a` does not live long enough --> $DIR/borrowing.rs:9:33 | -LL | let _b = { - | -- borrow later stored here -LL | let a = 3; LL | Pin::new(&mut || yield &a).resume(()) - | -- ^ borrowed value does not live long enough - | | + | ----------^ + | | | + | | borrowed value does not live long enough | value captured here by generator + | a temporary with access to the borrow is created here ... LL | LL | }; - | - `a` dropped here while still borrowed + | -- ... and the borrow might be used here, when that temporary is dropped and runs the destructor for generator + | | + | `a` dropped here while still borrowed + | + = note: the temporary is part of an expression at the end of a block; + consider forcing this temporary to be dropped sooner, before the block's local variables are dropped +help: for example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block + | +LL | let x = Pin::new(&mut || yield &a).resume(()); x + | +++++++ +++ error[E0597]: `a` does not live long enough --> $DIR/borrowing.rs:16:20 diff --git a/tests/ui/generator/clone-impl.stderr b/tests/ui/generator/clone-impl.stderr index edd3eb7e3da..870216398b1 100644 --- a/tests/ui/generator/clone-impl.stderr +++ b/tests/ui/generator/clone-impl.stderr @@ -1,11 +1,11 @@ error[E0277]: the trait bound `Vec: Copy` is not satisfied in `{generator@$DIR/clone-impl.rs:36:23: 36:30}` - --> $DIR/clone-impl.rs:42:16 + --> $DIR/clone-impl.rs:42:5 | LL | let gen_clone_0 = move || { | ------- within this `{generator@$DIR/clone-impl.rs:36:23: 36:30}` ... LL | check_copy(&gen_clone_0); - | ^^^^^^^^^^^^ within `{generator@$DIR/clone-impl.rs:36:23: 36:30}`, the trait `Copy` is not implemented for `Vec` + | ^^^^^^^^^^ within `{generator@$DIR/clone-impl.rs:36:23: 36:30}`, the trait `Copy` is not implemented for `Vec` | note: captured value does not implement `Copy` --> $DIR/clone-impl.rs:40:14 @@ -19,13 +19,13 @@ LL | fn check_copy(_x: &T) {} | ^^^^ required by this bound in `check_copy` error[E0277]: the trait bound `Vec: Copy` is not satisfied in `{generator@$DIR/clone-impl.rs:36:23: 36:30}` - --> $DIR/clone-impl.rs:42:16 + --> $DIR/clone-impl.rs:42:5 | LL | let gen_clone_0 = move || { | ------- within this `{generator@$DIR/clone-impl.rs:36:23: 36:30}` ... LL | check_copy(&gen_clone_0); - | ^^^^^^^^^^^^ within `{generator@$DIR/clone-impl.rs:36:23: 36:30}`, the trait `Copy` is not implemented for `Vec` + | ^^^^^^^^^^ within `{generator@$DIR/clone-impl.rs:36:23: 36:30}`, the trait `Copy` is not implemented for `Vec` | note: generator does not implement `Copy` as this value is used across a yield --> $DIR/clone-impl.rs:38:9 @@ -34,9 +34,6 @@ LL | let v = vec!['a']; | - has type `Vec` which does not implement `Copy` LL | yield; | ^^^^^ yield occurs here, with `v` maybe used later -... -LL | }; - | - `v` is later dropped here note: required by a bound in `check_copy` --> $DIR/clone-impl.rs:72:18 | @@ -44,13 +41,13 @@ LL | fn check_copy(_x: &T) {} | ^^^^ required by this bound in `check_copy` error[E0277]: the trait bound `Vec: Copy` is not satisfied in `{generator@$DIR/clone-impl.rs:46:23: 46:30}` - --> $DIR/clone-impl.rs:58:16 + --> $DIR/clone-impl.rs:58:5 | LL | let gen_clone_1 = move || { | ------- within this `{generator@$DIR/clone-impl.rs:46:23: 46:30}` ... LL | check_copy(&gen_clone_1); - | ^^^^^^^^^^^^ within `{generator@$DIR/clone-impl.rs:46:23: 46:30}`, the trait `Copy` is not implemented for `Vec` + | ^^^^^^^^^^ within `{generator@$DIR/clone-impl.rs:46:23: 46:30}`, the trait `Copy` is not implemented for `Vec` | note: captured value does not implement `Copy` --> $DIR/clone-impl.rs:56:14 @@ -64,13 +61,13 @@ LL | fn check_copy(_x: &T) {} | ^^^^ required by this bound in `check_copy` error[E0277]: the trait bound `Vec: Copy` is not satisfied in `{generator@$DIR/clone-impl.rs:46:23: 46:30}` - --> $DIR/clone-impl.rs:58:16 + --> $DIR/clone-impl.rs:58:5 | LL | let gen_clone_1 = move || { | ------- within this `{generator@$DIR/clone-impl.rs:46:23: 46:30}` ... LL | check_copy(&gen_clone_1); - | ^^^^^^^^^^^^ within `{generator@$DIR/clone-impl.rs:46:23: 46:30}`, the trait `Copy` is not implemented for `Vec` + | ^^^^^^^^^^ within `{generator@$DIR/clone-impl.rs:46:23: 46:30}`, the trait `Copy` is not implemented for `Vec` | note: generator does not implement `Copy` as this value is used across a yield --> $DIR/clone-impl.rs:52:9 @@ -80,9 +77,6 @@ LL | let v = vec!['a']; ... LL | yield; | ^^^^^ yield occurs here, with `v` maybe used later -... -LL | }; - | - `v` is later dropped here note: required by a bound in `check_copy` --> $DIR/clone-impl.rs:72:18 | @@ -90,13 +84,13 @@ LL | fn check_copy(_x: &T) {} | ^^^^ required by this bound in `check_copy` error[E0277]: the trait bound `NonClone: Copy` is not satisfied in `{generator@$DIR/clone-impl.rs:62:25: 62:32}` - --> $DIR/clone-impl.rs:66:16 + --> $DIR/clone-impl.rs:66:5 | LL | let gen_non_clone = move || { | ------- within this `{generator@$DIR/clone-impl.rs:62:25: 62:32}` ... LL | check_copy(&gen_non_clone); - | ^^^^^^^^^^^^^^ within `{generator@$DIR/clone-impl.rs:62:25: 62:32}`, the trait `Copy` is not implemented for `NonClone` + | ^^^^^^^^^^ within `{generator@$DIR/clone-impl.rs:62:25: 62:32}`, the trait `Copy` is not implemented for `NonClone` | note: captured value does not implement `Copy` --> $DIR/clone-impl.rs:64:14 @@ -115,13 +109,13 @@ LL | struct NonClone; | error[E0277]: the trait bound `NonClone: Clone` is not satisfied in `{generator@$DIR/clone-impl.rs:62:25: 62:32}` - --> $DIR/clone-impl.rs:68:17 + --> $DIR/clone-impl.rs:68:5 | LL | let gen_non_clone = move || { | ------- within this `{generator@$DIR/clone-impl.rs:62:25: 62:32}` ... LL | check_clone(&gen_non_clone); - | ^^^^^^^^^^^^^^ within `{generator@$DIR/clone-impl.rs:62:25: 62:32}`, the trait `Clone` is not implemented for `NonClone` + | ^^^^^^^^^^^ within `{generator@$DIR/clone-impl.rs:62:25: 62:32}`, the trait `Clone` is not implemented for `NonClone` | note: captured value does not implement `Clone` --> $DIR/clone-impl.rs:64:14 diff --git a/tests/ui/generator/derived-drop-parent-expr.rs b/tests/ui/generator/derived-drop-parent-expr.rs index 4bd34346a18..e381924517d 100644 --- a/tests/ui/generator/derived-drop-parent-expr.rs +++ b/tests/ui/generator/derived-drop-parent-expr.rs @@ -1,5 +1,4 @@ // build-pass -// compile-flags:-Zdrop-tracking //! Like drop-tracking-parent-expression, but also tests that this doesn't ICE when building MIR #![feature(generators)] diff --git a/tests/ui/generator/drop-control-flow.rs b/tests/ui/generator/drop-control-flow.rs index c6efda9541f..1c25c06ba4c 100644 --- a/tests/ui/generator/drop-control-flow.rs +++ b/tests/ui/generator/drop-control-flow.rs @@ -1,5 +1,4 @@ // build-pass -// compile-flags: -Zdrop-tracking // A test to ensure generators capture values that were conditionally dropped, // and also that values that are dropped along all paths to a yield do not get diff --git a/tests/ui/generator/drop-track-addassign-yield.rs b/tests/ui/generator/drop-track-addassign-yield.rs index 71cfb170bf6..1e64f1d2ec7 100644 --- a/tests/ui/generator/drop-track-addassign-yield.rs +++ b/tests/ui/generator/drop-track-addassign-yield.rs @@ -1,5 +1,4 @@ // run-pass -// compile-flags: -Zdrop-tracking // Based on addassign-yield.rs, but with drop tracking enabled. Originally we did not implement // the fake_read callback on ExprUseVisitor which caused this case to break. diff --git a/tests/ui/generator/drop-tracking-error-body.rs b/tests/ui/generator/drop-tracking-error-body.rs deleted file mode 100644 index f99d9ab6bf8..00000000000 --- a/tests/ui/generator/drop-tracking-error-body.rs +++ /dev/null @@ -1,18 +0,0 @@ -// compile-flags: -Zdrop-tracking-mir --edition=2021 - -#![feature(generators)] - -pub async fn async_bad_body() { - match true {} //~ ERROR non-exhaustive patterns: type `bool` is non-empty -} - -pub fn generator_bad_body() { - || { - // 'non-exhaustive pattern' only seems to be reported once, so this annotation doesn't work - // keep the function around so we can make sure it doesn't ICE - match true {}; // ERROR non-exhaustive patterns: type `bool` is non-empty - yield (); - }; -} - -fn main() {} diff --git a/tests/ui/generator/drop-tracking-error-body.stderr b/tests/ui/generator/drop-tracking-error-body.stderr deleted file mode 100644 index 28a6892336f..00000000000 --- a/tests/ui/generator/drop-tracking-error-body.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0004]: non-exhaustive patterns: type `bool` is non-empty - --> $DIR/drop-tracking-error-body.rs:6:11 - | -LL | match true {} - | ^^^^ - | - = note: the matched value is of type `bool` -help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown - | -LL ~ match true { -LL + _ => todo!(), -LL ~ } - | - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/generator/drop-tracking-parent-expression.rs b/tests/ui/generator/drop-tracking-parent-expression.rs index d40f1b8f64d..198b14528aa 100644 --- a/tests/ui/generator/drop-tracking-parent-expression.rs +++ b/tests/ui/generator/drop-tracking-parent-expression.rs @@ -1,4 +1,3 @@ -// compile-flags: -Zdrop-tracking #![feature(generators, negative_impls, rustc_attrs)] macro_rules! type_combinations { diff --git a/tests/ui/generator/drop-tracking-parent-expression.stderr b/tests/ui/generator/drop-tracking-parent-expression.stderr index 6119f689731..e85bb1347a7 100644 --- a/tests/ui/generator/drop-tracking-parent-expression.stderr +++ b/tests/ui/generator/drop-tracking-parent-expression.stderr @@ -1,8 +1,8 @@ error: generator cannot be sent between threads safely - --> $DIR/drop-tracking-parent-expression.rs:24:25 + --> $DIR/drop-tracking-parent-expression.rs:23:13 | LL | assert_send(g); - | ^ generator is not `Send` + | ^^^^^^^^^^^ generator is not `Send` ... LL | / type_combinations!( LL | | // OK @@ -13,17 +13,15 @@ LL | | }; LL | | ); | |_____- in this macro invocation | - = help: within `{generator@$DIR/drop-tracking-parent-expression.rs:18:21: 18:28}`, the trait `Send` is not implemented for `derived_drop::Client` + = help: within `{generator@$DIR/drop-tracking-parent-expression.rs:17:21: 17:28}`, the trait `Send` is not implemented for `derived_drop::Client` note: generator is not `Send` as this value is used across a yield - --> $DIR/drop-tracking-parent-expression.rs:22:22 + --> $DIR/drop-tracking-parent-expression.rs:21:22 | LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { | ------------------------ has type `derived_drop::Client` which is not `Send` ... LL | _ => yield, | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -LL | }; - | - `$name::Client::default()` is later dropped here ... LL | / type_combinations!( LL | | // OK @@ -34,17 +32,17 @@ LL | | }; LL | | ); | |_____- in this macro invocation note: required by a bound in `assert_send` - --> $DIR/drop-tracking-parent-expression.rs:41:19 + --> $DIR/drop-tracking-parent-expression.rs:40:19 | LL | fn assert_send(_thing: T) {} | ^^^^ required by this bound in `assert_send` = note: this error originates in the macro `type_combinations` (in Nightly builds, run with -Z macro-backtrace for more info) error: generator cannot be sent between threads safely - --> $DIR/drop-tracking-parent-expression.rs:24:25 + --> $DIR/drop-tracking-parent-expression.rs:23:13 | LL | assert_send(g); - | ^ generator is not `Send` + | ^^^^^^^^^^^ generator is not `Send` ... LL | / type_combinations!( LL | | // OK @@ -55,17 +53,15 @@ LL | | }; LL | | ); | |_____- in this macro invocation | - = help: within `{generator@$DIR/drop-tracking-parent-expression.rs:18:21: 18:28}`, the trait `Send` is not implemented for `significant_drop::Client` + = help: within `{generator@$DIR/drop-tracking-parent-expression.rs:17:21: 17:28}`, the trait `Send` is not implemented for `significant_drop::Client` note: generator is not `Send` as this value is used across a yield - --> $DIR/drop-tracking-parent-expression.rs:22:22 + --> $DIR/drop-tracking-parent-expression.rs:21:22 | LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { | ------------------------ has type `significant_drop::Client` which is not `Send` ... LL | _ => yield, | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -LL | }; - | - `$name::Client::default()` is later dropped here ... LL | / type_combinations!( LL | | // OK @@ -76,17 +72,17 @@ LL | | }; LL | | ); | |_____- in this macro invocation note: required by a bound in `assert_send` - --> $DIR/drop-tracking-parent-expression.rs:41:19 + --> $DIR/drop-tracking-parent-expression.rs:40:19 | LL | fn assert_send(_thing: T) {} | ^^^^ required by this bound in `assert_send` = note: this error originates in the macro `type_combinations` (in Nightly builds, run with -Z macro-backtrace for more info) error: generator cannot be sent between threads safely - --> $DIR/drop-tracking-parent-expression.rs:24:25 + --> $DIR/drop-tracking-parent-expression.rs:23:13 | LL | assert_send(g); - | ^ generator is not `Send` + | ^^^^^^^^^^^ generator is not `Send` ... LL | / type_combinations!( LL | | // OK @@ -97,17 +93,15 @@ LL | | }; LL | | ); | |_____- in this macro invocation | - = help: within `{generator@$DIR/drop-tracking-parent-expression.rs:18:21: 18:28}`, the trait `Send` is not implemented for `insignificant_dtor::Client` + = help: within `{generator@$DIR/drop-tracking-parent-expression.rs:17:21: 17:28}`, the trait `Send` is not implemented for `insignificant_dtor::Client` note: generator is not `Send` as this value is used across a yield - --> $DIR/drop-tracking-parent-expression.rs:22:22 + --> $DIR/drop-tracking-parent-expression.rs:21:22 | LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { | ------------------------ has type `insignificant_dtor::Client` which is not `Send` ... LL | _ => yield, | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -LL | }; - | - `$name::Client::default()` is later dropped here ... LL | / type_combinations!( LL | | // OK @@ -118,7 +112,7 @@ LL | | }; LL | | ); | |_____- in this macro invocation note: required by a bound in `assert_send` - --> $DIR/drop-tracking-parent-expression.rs:41:19 + --> $DIR/drop-tracking-parent-expression.rs:40:19 | LL | fn assert_send(_thing: T) {} | ^^^^ required by this bound in `assert_send` diff --git a/tests/ui/generator/drop-tracking-yielding-in-match-guards.rs b/tests/ui/generator/drop-tracking-yielding-in-match-guards.rs index 646365e4359..92e0136d51b 100644 --- a/tests/ui/generator/drop-tracking-yielding-in-match-guards.rs +++ b/tests/ui/generator/drop-tracking-yielding-in-match-guards.rs @@ -1,6 +1,5 @@ // build-pass // edition:2018 -// compile-flags: -Zdrop-tracking #![feature(generators)] diff --git a/tests/ui/generator/drop-yield-twice.stderr b/tests/ui/generator/drop-yield-twice.stderr index 6a28e463189..39a906f0bf4 100644 --- a/tests/ui/generator/drop-yield-twice.stderr +++ b/tests/ui/generator/drop-yield-twice.stderr @@ -1,14 +1,8 @@ error: generator cannot be sent between threads safely - --> $DIR/drop-yield-twice.rs:7:17 + --> $DIR/drop-yield-twice.rs:7:5 | -LL | assert_send(|| { - | _________________^ -LL | | let guard = Foo(42); -LL | | yield; -LL | | drop(guard); -LL | | yield; -LL | | }) - | |_____^ generator is not `Send` +LL | assert_send(|| { + | ^^^^^^^^^^^ generator is not `Send` | = help: within `{generator@$DIR/drop-yield-twice.rs:7:17: 7:19}`, the trait `Send` is not implemented for `Foo` note: generator is not `Send` as this value is used across a yield @@ -18,9 +12,6 @@ LL | let guard = Foo(42); | ----- has type `Foo` which is not `Send` LL | yield; | ^^^^^ yield occurs here, with `guard` maybe used later -... -LL | }) - | - `guard` is later dropped here note: required by a bound in `assert_send` --> $DIR/drop-yield-twice.rs:15:19 | diff --git a/tests/ui/generator/issue-102645.rs b/tests/ui/generator/issue-102645.rs index 35acd5cd727..677cc69d3f2 100644 --- a/tests/ui/generator/issue-102645.rs +++ b/tests/ui/generator/issue-102645.rs @@ -1,5 +1,3 @@ -// compile-flags: -Zdrop-tracking - #![feature(generators, generator_trait)] use std::ops::Generator; diff --git a/tests/ui/generator/issue-102645.stderr b/tests/ui/generator/issue-102645.stderr index 3f9a4c2f3c5..5d28dfc45b3 100644 --- a/tests/ui/generator/issue-102645.stderr +++ b/tests/ui/generator/issue-102645.stderr @@ -1,5 +1,5 @@ error[E0061]: this method takes 1 argument but 0 arguments were supplied - --> $DIR/issue-102645.rs:16:22 + --> $DIR/issue-102645.rs:14:22 | LL | Pin::new(&mut b).resume(); | ^^^^^^-- an argument of type `()` is missing diff --git a/tests/ui/generator/issue-105084.rs b/tests/ui/generator/issue-105084.rs index 9fdeb4fd2fc..50b5da6e6ad 100644 --- a/tests/ui/generator/issue-105084.rs +++ b/tests/ui/generator/issue-105084.rs @@ -1,5 +1,3 @@ -// compile-flags: -Zdrop-tracking-mir - #![feature(generators)] #![feature(generator_clone)] #![feature(generator_trait)] diff --git a/tests/ui/generator/issue-105084.stderr b/tests/ui/generator/issue-105084.stderr index 3f1f11918f5..573c31f1134 100644 --- a/tests/ui/generator/issue-105084.stderr +++ b/tests/ui/generator/issue-105084.stderr @@ -1,8 +1,8 @@ error[E0382]: borrow of moved value: `g` - --> $DIR/issue-105084.rs:39:14 + --> $DIR/issue-105084.rs:37:14 | LL | let mut g = || { - | ----- move occurs because `g` has type `{generator@$DIR/issue-105084.rs:16:17: 16:19}`, which does not implement the `Copy` trait + | ----- move occurs because `g` has type `{generator@$DIR/issue-105084.rs:14:17: 14:19}`, which does not implement the `Copy` trait ... LL | let mut h = copy(g); | - value moved here @@ -11,7 +11,7 @@ LL | Pin::new(&mut g).resume(()); | ^^^^^^ value borrowed here after move | note: consider changing this parameter type in function `copy` to borrow instead if owning the value isn't necessary - --> $DIR/issue-105084.rs:11:21 + --> $DIR/issue-105084.rs:9:21 | LL | fn copy(x: T) -> T { | ---- ^ this parameter takes ownership of the value @@ -22,17 +22,17 @@ help: consider cloning the value if the performance cost is acceptable LL | let mut h = copy(g.clone()); | ++++++++ -error[E0277]: the trait bound `Box<(i32, ())>: Copy` is not satisfied in `{generator@$DIR/issue-105084.rs:16:17: 16:19}` - --> $DIR/issue-105084.rs:33:17 +error[E0277]: the trait bound `Box<(i32, ())>: Copy` is not satisfied in `{generator@$DIR/issue-105084.rs:14:17: 14:19}` + --> $DIR/issue-105084.rs:31:17 | LL | let mut g = || { - | -- within this `{generator@$DIR/issue-105084.rs:16:17: 16:19}` + | -- within this `{generator@$DIR/issue-105084.rs:14:17: 14:19}` ... LL | let mut h = copy(g); - | ^^^^ within `{generator@$DIR/issue-105084.rs:16:17: 16:19}`, the trait `Copy` is not implemented for `Box<(i32, ())>` + | ^^^^ within `{generator@$DIR/issue-105084.rs:14:17: 14:19}`, the trait `Copy` is not implemented for `Box<(i32, ())>` | note: generator does not implement `Copy` as this value is used across a yield - --> $DIR/issue-105084.rs:23:22 + --> $DIR/issue-105084.rs:21:22 | LL | Box::new((5, yield)); | -------------^^^^^-- @@ -40,7 +40,7 @@ LL | Box::new((5, yield)); | | yield occurs here, with `Box::new((5, yield))` maybe used later | has type `Box<(i32, ())>` which does not implement `Copy` note: required by a bound in `copy` - --> $DIR/issue-105084.rs:11:12 + --> $DIR/issue-105084.rs:9:12 | LL | fn copy(x: T) -> T { | ^^^^ required by this bound in `copy` diff --git a/tests/ui/generator/issue-110929-generator-conflict-error-ice.rs b/tests/ui/generator/issue-110929-generator-conflict-error-ice.rs index 9408acc15f9..a45479e5300 100644 --- a/tests/ui/generator/issue-110929-generator-conflict-error-ice.rs +++ b/tests/ui/generator/issue-110929-generator-conflict-error-ice.rs @@ -1,5 +1,4 @@ // edition:2021 -// compile-flags: -Zdrop-tracking-mir=yes #![feature(generators)] fn main() { diff --git a/tests/ui/generator/issue-110929-generator-conflict-error-ice.stderr b/tests/ui/generator/issue-110929-generator-conflict-error-ice.stderr index 4d72ebe79eb..66f0e3d94bd 100644 --- a/tests/ui/generator/issue-110929-generator-conflict-error-ice.stderr +++ b/tests/ui/generator/issue-110929-generator-conflict-error-ice.stderr @@ -1,5 +1,5 @@ error[E0499]: cannot borrow `*x` as mutable more than once at a time - --> $DIR/issue-110929-generator-conflict-error-ice.rs:9:9 + --> $DIR/issue-110929-generator-conflict-error-ice.rs:8:9 | LL | let _c = || yield *&mut *x; | -- -- first borrow occurs due to use of `*x` in generator diff --git a/tests/ui/generator/issue-57017.rs b/tests/ui/generator/issue-57017.rs index 6cb742b7ffe..bb2d6679b67 100644 --- a/tests/ui/generator/issue-57017.rs +++ b/tests/ui/generator/issue-57017.rs @@ -1,5 +1,4 @@ // build-pass -// compile-flags: -Zdrop-tracking #![feature(generators, negative_impls)] #![allow(dropping_references, dropping_copy_types)] diff --git a/tests/ui/generator/issue-57478.rs b/tests/ui/generator/issue-57478.rs index 91407ea1844..39710febdb9 100644 --- a/tests/ui/generator/issue-57478.rs +++ b/tests/ui/generator/issue-57478.rs @@ -1,5 +1,4 @@ // check-pass -// compile-flags: -Zdrop-tracking #![feature(negative_impls, generators)] diff --git a/tests/ui/generator/issue-68112.rs b/tests/ui/generator/issue-68112.rs index 9def544e3d2..9dd68726f92 100644 --- a/tests/ui/generator/issue-68112.rs +++ b/tests/ui/generator/issue-68112.rs @@ -8,7 +8,7 @@ use std::{ }; pub struct Ready(Option); -impl Generator<()> for Ready { +impl Generator<()> for Ready { type Return = T; type Yield = (); fn resume(mut self: Pin<&mut Self>, _args: ()) -> GeneratorState<(), T> { @@ -36,7 +36,7 @@ fn test1() { yield; //~^ NOTE yield occurs here //~| NOTE value is used across a yield - }; //~ NOTE later dropped here + }; require_send(send_gen); //~^ ERROR generator cannot be sent between threads //~| NOTE not `Send` @@ -65,7 +65,6 @@ fn test2() { //~^ ERROR `RefCell` cannot be shared between threads safely //~| NOTE `RefCell` cannot be shared between threads safely //~| NOTE required for - //~| NOTE required by a bound introduced by this call //~| NOTE captures the following types //~| NOTE use `std::sync::RwLock` instead } diff --git a/tests/ui/generator/issue-68112.stderr b/tests/ui/generator/issue-68112.stderr index b42bc93d01f..8080048222f 100644 --- a/tests/ui/generator/issue-68112.stderr +++ b/tests/ui/generator/issue-68112.stderr @@ -1,8 +1,8 @@ error: generator cannot be sent between threads safely - --> $DIR/issue-68112.rs:40:18 + --> $DIR/issue-68112.rs:40:5 | LL | require_send(send_gen); - | ^^^^^^^^ generator is not `Send` + | ^^^^^^^^^^^^ generator is not `Send` | = help: the trait `Sync` is not implemented for `RefCell` = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead @@ -14,9 +14,6 @@ LL | let _non_send_gen = make_non_send_generator(); LL | LL | yield; | ^^^^^ yield occurs here, with `_non_send_gen` maybe used later -... -LL | }; - | - `_non_send_gen` is later dropped here note: required by a bound in `require_send` --> $DIR/issue-68112.rs:22:25 | @@ -24,12 +21,10 @@ LL | fn require_send(_: impl Send) {} | ^^^^ required by this bound in `require_send` error[E0277]: `RefCell` cannot be shared between threads safely - --> $DIR/issue-68112.rs:64:18 + --> $DIR/issue-68112.rs:64:5 | LL | require_send(send_gen); - | ------------ ^^^^^^^^ `RefCell` cannot be shared between threads safely - | | - | required by a bound introduced by this call + | ^^^^^^^^^^^^ `RefCell` cannot be shared between threads safely | = help: the trait `Sync` is not implemented for `RefCell` = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead @@ -49,7 +44,7 @@ note: required because it appears within the type `impl Generator impl Generator>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: required because it captures the following types: `impl Generator>>`, `()` + = note: required because it captures the following types: `impl Generator>>` note: required because it's used within this generator --> $DIR/issue-68112.rs:60:20 | diff --git a/tests/ui/generator/issue-93161.rs b/tests/ui/generator/issue-93161.rs index 92305609c83..ae8603b7c09 100644 --- a/tests/ui/generator/issue-93161.rs +++ b/tests/ui/generator/issue-93161.rs @@ -1,6 +1,5 @@ // edition:2021 // run-pass -// compile-flags: -Zdrop-tracking #![feature(never_type)] diff --git a/tests/ui/generator/not-send-sync.rs b/tests/ui/generator/not-send-sync.rs index 8ca5565fb2a..16c8cd47629 100644 --- a/tests/ui/generator/not-send-sync.rs +++ b/tests/ui/generator/not-send-sync.rs @@ -1,6 +1,11 @@ #![feature(generators)] +#![feature(negative_impls)] -use std::cell::Cell; +struct NotSend; +struct NotSync; + +impl !Send for NotSend {} +impl !Sync for NotSync {} fn main() { fn assert_sync(_: T) {} @@ -8,14 +13,15 @@ fn main() { assert_sync(|| { //~^ ERROR: generator cannot be shared between threads safely - let a = Cell::new(2); + let a = NotSync; yield; + drop(a); }); - let a = Cell::new(2); assert_send(|| { - //~^ ERROR: E0277 - drop(&a); + //~^ ERROR: generator cannot be sent between threads safely + let a = NotSend; yield; + drop(a); }); } diff --git a/tests/ui/generator/not-send-sync.stderr b/tests/ui/generator/not-send-sync.stderr index 6e0269026b5..13ce687e0bb 100644 --- a/tests/ui/generator/not-send-sync.stderr +++ b/tests/ui/generator/not-send-sync.stderr @@ -1,58 +1,42 @@ -error[E0277]: `Cell` cannot be shared between threads safely - --> $DIR/not-send-sync.rs:16:17 - | -LL | assert_send(|| { - | _____-----------_^ - | | | - | | required by a bound introduced by this call -LL | | -LL | | drop(&a); -LL | | yield; -LL | | }); - | |_____^ `Cell` cannot be shared between threads safely - | - = help: the trait `Sync` is not implemented for `Cell` - = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` or `std::sync::atomic::AtomicI32` instead - = note: required for `&Cell` to implement `Send` -note: required because it's used within this generator - --> $DIR/not-send-sync.rs:16:17 - | -LL | assert_send(|| { - | ^^ -note: required by a bound in `assert_send` - --> $DIR/not-send-sync.rs:7:23 - | -LL | fn assert_send(_: T) {} - | ^^^^ required by this bound in `assert_send` - error: generator cannot be shared between threads safely - --> $DIR/not-send-sync.rs:9:17 + --> $DIR/not-send-sync.rs:14:5 | -LL | assert_sync(|| { - | _________________^ -LL | | -LL | | let a = Cell::new(2); -LL | | yield; -LL | | }); - | |_____^ generator is not `Sync` +LL | assert_sync(|| { + | ^^^^^^^^^^^ generator is not `Sync` | - = help: within `{generator@$DIR/not-send-sync.rs:9:17: 9:19}`, the trait `Sync` is not implemented for `Cell` - = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` or `std::sync::atomic::AtomicI32` instead + = help: within `{generator@$DIR/not-send-sync.rs:14:17: 14:19}`, the trait `Sync` is not implemented for `NotSync` note: generator is not `Sync` as this value is used across a yield - --> $DIR/not-send-sync.rs:12:9 + --> $DIR/not-send-sync.rs:17:9 | -LL | let a = Cell::new(2); - | - has type `Cell` which is not `Sync` +LL | let a = NotSync; + | - has type `NotSync` which is not `Sync` LL | yield; | ^^^^^ yield occurs here, with `a` maybe used later -LL | }); - | - `a` is later dropped here note: required by a bound in `assert_sync` - --> $DIR/not-send-sync.rs:6:23 + --> $DIR/not-send-sync.rs:11:23 | LL | fn assert_sync(_: T) {} | ^^^^ required by this bound in `assert_sync` +error: generator cannot be sent between threads safely + --> $DIR/not-send-sync.rs:21:5 + | +LL | assert_send(|| { + | ^^^^^^^^^^^ generator is not `Send` + | + = help: within `{generator@$DIR/not-send-sync.rs:21:17: 21:19}`, the trait `Send` is not implemented for `NotSend` +note: generator is not `Send` as this value is used across a yield + --> $DIR/not-send-sync.rs:24:9 + | +LL | let a = NotSend; + | - has type `NotSend` which is not `Send` +LL | yield; + | ^^^^^ yield occurs here, with `a` maybe used later +note: required by a bound in `assert_send` + --> $DIR/not-send-sync.rs:12:23 + | +LL | fn assert_send(_: T) {} + | ^^^^ required by this bound in `assert_send` + error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/generator/parent-expression.rs b/tests/ui/generator/parent-expression.rs index 47a179c14ad..198b14528aa 100644 --- a/tests/ui/generator/parent-expression.rs +++ b/tests/ui/generator/parent-expression.rs @@ -1,5 +1,3 @@ -// compile-flags: -Zdrop-tracking - #![feature(generators, negative_impls, rustc_attrs)] macro_rules! type_combinations { diff --git a/tests/ui/generator/parent-expression.stderr b/tests/ui/generator/parent-expression.stderr index 5fb54abeb2d..25a3b051b1f 100644 --- a/tests/ui/generator/parent-expression.stderr +++ b/tests/ui/generator/parent-expression.stderr @@ -1,8 +1,8 @@ error: generator cannot be sent between threads safely - --> $DIR/parent-expression.rs:25:25 + --> $DIR/parent-expression.rs:23:13 | LL | assert_send(g); - | ^ generator is not `Send` + | ^^^^^^^^^^^ generator is not `Send` ... LL | / type_combinations!( LL | | // OK @@ -13,17 +13,15 @@ LL | | }; LL | | ); | |_____- in this macro invocation | - = help: within `{generator@$DIR/parent-expression.rs:19:21: 19:28}`, the trait `Send` is not implemented for `derived_drop::Client` + = help: within `{generator@$DIR/parent-expression.rs:17:21: 17:28}`, the trait `Send` is not implemented for `derived_drop::Client` note: generator is not `Send` as this value is used across a yield - --> $DIR/parent-expression.rs:23:22 + --> $DIR/parent-expression.rs:21:22 | LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { | ------------------------ has type `derived_drop::Client` which is not `Send` ... LL | _ => yield, | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -LL | }; - | - `$name::Client::default()` is later dropped here ... LL | / type_combinations!( LL | | // OK @@ -34,17 +32,17 @@ LL | | }; LL | | ); | |_____- in this macro invocation note: required by a bound in `assert_send` - --> $DIR/parent-expression.rs:42:19 + --> $DIR/parent-expression.rs:40:19 | LL | fn assert_send(_thing: T) {} | ^^^^ required by this bound in `assert_send` = note: this error originates in the macro `type_combinations` (in Nightly builds, run with -Z macro-backtrace for more info) error: generator cannot be sent between threads safely - --> $DIR/parent-expression.rs:25:25 + --> $DIR/parent-expression.rs:23:13 | LL | assert_send(g); - | ^ generator is not `Send` + | ^^^^^^^^^^^ generator is not `Send` ... LL | / type_combinations!( LL | | // OK @@ -55,17 +53,15 @@ LL | | }; LL | | ); | |_____- in this macro invocation | - = help: within `{generator@$DIR/parent-expression.rs:19:21: 19:28}`, the trait `Send` is not implemented for `significant_drop::Client` + = help: within `{generator@$DIR/parent-expression.rs:17:21: 17:28}`, the trait `Send` is not implemented for `significant_drop::Client` note: generator is not `Send` as this value is used across a yield - --> $DIR/parent-expression.rs:23:22 + --> $DIR/parent-expression.rs:21:22 | LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { | ------------------------ has type `significant_drop::Client` which is not `Send` ... LL | _ => yield, | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -LL | }; - | - `$name::Client::default()` is later dropped here ... LL | / type_combinations!( LL | | // OK @@ -76,17 +72,17 @@ LL | | }; LL | | ); | |_____- in this macro invocation note: required by a bound in `assert_send` - --> $DIR/parent-expression.rs:42:19 + --> $DIR/parent-expression.rs:40:19 | LL | fn assert_send(_thing: T) {} | ^^^^ required by this bound in `assert_send` = note: this error originates in the macro `type_combinations` (in Nightly builds, run with -Z macro-backtrace for more info) error: generator cannot be sent between threads safely - --> $DIR/parent-expression.rs:25:25 + --> $DIR/parent-expression.rs:23:13 | LL | assert_send(g); - | ^ generator is not `Send` + | ^^^^^^^^^^^ generator is not `Send` ... LL | / type_combinations!( LL | | // OK @@ -97,17 +93,15 @@ LL | | }; LL | | ); | |_____- in this macro invocation | - = help: within `{generator@$DIR/parent-expression.rs:19:21: 19:28}`, the trait `Send` is not implemented for `insignificant_dtor::Client` + = help: within `{generator@$DIR/parent-expression.rs:17:21: 17:28}`, the trait `Send` is not implemented for `insignificant_dtor::Client` note: generator is not `Send` as this value is used across a yield - --> $DIR/parent-expression.rs:23:22 + --> $DIR/parent-expression.rs:21:22 | LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { | ------------------------ has type `insignificant_dtor::Client` which is not `Send` ... LL | _ => yield, | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -LL | }; - | - `$name::Client::default()` is later dropped here ... LL | / type_combinations!( LL | | // OK @@ -118,7 +112,7 @@ LL | | }; LL | | ); | |_____- in this macro invocation note: required by a bound in `assert_send` - --> $DIR/parent-expression.rs:42:19 + --> $DIR/parent-expression.rs:40:19 | LL | fn assert_send(_thing: T) {} | ^^^^ required by this bound in `assert_send` diff --git a/tests/ui/generator/partial-drop.rs b/tests/ui/generator/partial-drop.rs index c872fb7f3e6..868f36adce2 100644 --- a/tests/ui/generator/partial-drop.rs +++ b/tests/ui/generator/partial-drop.rs @@ -1,5 +1,4 @@ -// compile-flags: -Zdrop-tracking - +// check-pass #![feature(negative_impls, generators)] struct Foo; @@ -12,26 +11,19 @@ struct Bar { fn main() { assert_send(|| { - //~^ ERROR generator cannot be sent between threads safely - // FIXME: it would be nice to make this work. let guard = Bar { foo: Foo, x: 42 }; drop(guard.foo); yield; }); assert_send(|| { - //~^ ERROR generator cannot be sent between threads safely - // FIXME: it would be nice to make this work. - let guard = Bar { foo: Foo, x: 42 }; + let mut guard = Bar { foo: Foo, x: 42 }; drop(guard); - guard.foo = Foo; - guard.x = 23; + guard = Bar { foo: Foo, x: 23 }; yield; }); assert_send(|| { - //~^ ERROR generator cannot be sent between threads safely - // FIXME: it would be nice to make this work. let guard = Bar { foo: Foo, x: 42 }; let Bar { foo, x } = guard; drop(foo); diff --git a/tests/ui/generator/partial-drop.stderr b/tests/ui/generator/partial-drop.stderr deleted file mode 100644 index f374b549df3..00000000000 --- a/tests/ui/generator/partial-drop.stderr +++ /dev/null @@ -1,92 +0,0 @@ -error: generator cannot be sent between threads safely - --> $DIR/partial-drop.rs:14:17 - | -LL | assert_send(|| { - | _________________^ -LL | | -LL | | // FIXME: it would be nice to make this work. -LL | | let guard = Bar { foo: Foo, x: 42 }; -LL | | drop(guard.foo); -LL | | yield; -LL | | }); - | |_____^ generator is not `Send` - | - = help: within `{generator@$DIR/partial-drop.rs:14:17: 14:19}`, the trait `Send` is not implemented for `Foo` -note: generator is not `Send` as this value is used across a yield - --> $DIR/partial-drop.rs:19:9 - | -LL | let guard = Bar { foo: Foo, x: 42 }; - | ----- has type `Bar` which is not `Send` -LL | drop(guard.foo); -LL | yield; - | ^^^^^ yield occurs here, with `guard` maybe used later -LL | }); - | - `guard` is later dropped here -note: required by a bound in `assert_send` - --> $DIR/partial-drop.rs:42:19 - | -LL | fn assert_send(_: T) {} - | ^^^^ required by this bound in `assert_send` - -error: generator cannot be sent between threads safely - --> $DIR/partial-drop.rs:22:17 - | -LL | assert_send(|| { - | _________________^ -LL | | -LL | | // FIXME: it would be nice to make this work. -LL | | let guard = Bar { foo: Foo, x: 42 }; -... | -LL | | yield; -LL | | }); - | |_____^ generator is not `Send` - | - = help: within `{generator@$DIR/partial-drop.rs:22:17: 22:19}`, the trait `Send` is not implemented for `Foo` -note: generator is not `Send` as this value is used across a yield - --> $DIR/partial-drop.rs:29:9 - | -LL | let guard = Bar { foo: Foo, x: 42 }; - | ----- has type `Bar` which is not `Send` -... -LL | yield; - | ^^^^^ yield occurs here, with `guard` maybe used later -LL | }); - | - `guard` is later dropped here -note: required by a bound in `assert_send` - --> $DIR/partial-drop.rs:42:19 - | -LL | fn assert_send(_: T) {} - | ^^^^ required by this bound in `assert_send` - -error: generator cannot be sent between threads safely - --> $DIR/partial-drop.rs:32:17 - | -LL | assert_send(|| { - | _________________^ -LL | | -LL | | // FIXME: it would be nice to make this work. -LL | | let guard = Bar { foo: Foo, x: 42 }; -... | -LL | | yield; -LL | | }); - | |_____^ generator is not `Send` - | - = help: within `{generator@$DIR/partial-drop.rs:32:17: 32:19}`, the trait `Send` is not implemented for `Foo` -note: generator is not `Send` as this value is used across a yield - --> $DIR/partial-drop.rs:38:9 - | -LL | let guard = Bar { foo: Foo, x: 42 }; - | ----- has type `Bar` which is not `Send` -... -LL | yield; - | ^^^^^ yield occurs here, with `guard` maybe used later -LL | }); - | - `guard` is later dropped here -note: required by a bound in `assert_send` - --> $DIR/partial-drop.rs:42:19 - | -LL | fn assert_send(_: T) {} - | ^^^^ required by this bound in `assert_send` - -error: aborting due to 3 previous errors - diff --git a/tests/ui/generator/print/generator-print-verbose-1.rs b/tests/ui/generator/print/generator-print-verbose-1.rs index 89124ad7289..e52234c08a3 100644 --- a/tests/ui/generator/print/generator-print-verbose-1.rs +++ b/tests/ui/generator/print/generator-print-verbose-1.rs @@ -12,7 +12,7 @@ use std::{ }; pub struct Ready(Option); -impl Generator<()> for Ready { +impl Generator<()> for Ready { type Return = T; type Yield = (); fn resume(mut self: Pin<&mut Self>, _args: ()) -> GeneratorState<(), T> { diff --git a/tests/ui/generator/print/generator-print-verbose-1.stderr b/tests/ui/generator/print/generator-print-verbose-1.stderr index 1e409534c75..d949543de41 100644 --- a/tests/ui/generator/print/generator-print-verbose-1.stderr +++ b/tests/ui/generator/print/generator-print-verbose-1.stderr @@ -1,8 +1,8 @@ error: generator cannot be sent between threads safely - --> $DIR/generator-print-verbose-1.rs:37:18 + --> $DIR/generator-print-verbose-1.rs:37:5 | LL | require_send(send_gen); - | ^^^^^^^^ generator is not `Send` + | ^^^^^^^^^^^^ generator is not `Send` | = help: the trait `Sync` is not implemented for `RefCell` = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead @@ -13,8 +13,6 @@ LL | let _non_send_gen = make_non_send_generator(); | ------------- has type `Opaque(DefId(0:34 ~ generator_print_verbose_1[7d1d]::make_non_send_generator::{opaque#0}), [])` which is not `Send` LL | yield; | ^^^^^ yield occurs here, with `_non_send_gen` maybe used later -LL | }; - | - `_non_send_gen` is later dropped here note: required by a bound in `require_send` --> $DIR/generator-print-verbose-1.rs:26:25 | @@ -22,12 +20,10 @@ LL | fn require_send(_: impl Send) {} | ^^^^ required by this bound in `require_send` error[E0277]: `RefCell` cannot be shared between threads safely - --> $DIR/generator-print-verbose-1.rs:56:18 + --> $DIR/generator-print-verbose-1.rs:56:5 | LL | require_send(send_gen); - | ------------ ^^^^^^^^ `RefCell` cannot be shared between threads safely - | | - | required by a bound introduced by this call + | ^^^^^^^^^^^^ `RefCell` cannot be shared between threads safely | = help: the trait `Sync` is not implemented for `RefCell` = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead @@ -47,7 +43,7 @@ note: required because it appears within the type `Opaque(DefId(0:36 ~ generator | LL | fn make_non_send_generator2() -> impl Generator>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: required because it captures the following types: `Opaque(DefId(0:36 ~ generator_print_verbose_1[7d1d]::make_non_send_generator2::{opaque#0}), [])`, `()` + = note: required because it captures the following types: `Opaque(DefId(0:36 ~ generator_print_verbose_1[7d1d]::make_non_send_generator2::{opaque#0}), [])` note: required because it's used within this generator --> $DIR/generator-print-verbose-1.rs:52:20 | diff --git a/tests/ui/generator/print/generator-print-verbose-2.rs b/tests/ui/generator/print/generator-print-verbose-2.rs index d914719cb36..e53a7ef8cc1 100644 --- a/tests/ui/generator/print/generator-print-verbose-2.rs +++ b/tests/ui/generator/print/generator-print-verbose-2.rs @@ -2,8 +2,13 @@ // Same as test/ui/generator/not-send-sync.rs #![feature(generators)] +#![feature(negative_impls)] -use std::cell::Cell; +struct NotSend; +struct NotSync; + +impl !Send for NotSend {} +impl !Sync for NotSync {} fn main() { fn assert_sync(_: T) {} @@ -11,14 +16,15 @@ fn main() { assert_sync(|| { //~^ ERROR: generator cannot be shared between threads safely - let a = Cell::new(2); + let a = NotSync; yield; + drop(a); }); - let a = Cell::new(2); assert_send(|| { - //~^ ERROR: E0277 - drop(&a); + //~^ ERROR: generator cannot be sent between threads safely + let a = NotSend; yield; + drop(a); }); } diff --git a/tests/ui/generator/print/generator-print-verbose-2.stderr b/tests/ui/generator/print/generator-print-verbose-2.stderr index 4e88e73f1d6..8ff7557619f 100644 --- a/tests/ui/generator/print/generator-print-verbose-2.stderr +++ b/tests/ui/generator/print/generator-print-verbose-2.stderr @@ -1,58 +1,42 @@ -error[E0277]: `Cell` cannot be shared between threads safely - --> $DIR/generator-print-verbose-2.rs:19:17 - | -LL | assert_send(|| { - | _____-----------_^ - | | | - | | required by a bound introduced by this call -LL | | -LL | | drop(&a); -LL | | yield; -LL | | }); - | |_____^ `Cell` cannot be shared between threads safely - | - = help: the trait `Sync` is not implemented for `Cell` - = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` or `std::sync::atomic::AtomicI32` instead - = note: required for `&'?4 Cell` to implement `Send` -note: required because it's used within this generator - --> $DIR/generator-print-verbose-2.rs:19:17 - | -LL | assert_send(|| { - | ^^ -note: required by a bound in `assert_send` - --> $DIR/generator-print-verbose-2.rs:10:23 - | -LL | fn assert_send(_: T) {} - | ^^^^ required by this bound in `assert_send` - error: generator cannot be shared between threads safely - --> $DIR/generator-print-verbose-2.rs:12:17 + --> $DIR/generator-print-verbose-2.rs:17:5 | -LL | assert_sync(|| { - | _________________^ -LL | | -LL | | let a = Cell::new(2); -LL | | yield; -LL | | }); - | |_____^ generator is not `Sync` +LL | assert_sync(|| { + | ^^^^^^^^^^^ generator is not `Sync` | - = help: within `{main::{closure#0} upvar_tys=() {Cell, ()}}`, the trait `Sync` is not implemented for `Cell` - = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` or `std::sync::atomic::AtomicI32` instead + = help: within `{main::{closure#0} upvar_tys=() {main::{closure#0}}}`, the trait `Sync` is not implemented for `NotSync` note: generator is not `Sync` as this value is used across a yield - --> $DIR/generator-print-verbose-2.rs:15:9 + --> $DIR/generator-print-verbose-2.rs:20:9 | -LL | let a = Cell::new(2); - | - has type `Cell` which is not `Sync` +LL | let a = NotSync; + | - has type `NotSync` which is not `Sync` LL | yield; | ^^^^^ yield occurs here, with `a` maybe used later -LL | }); - | - `a` is later dropped here note: required by a bound in `assert_sync` - --> $DIR/generator-print-verbose-2.rs:9:23 + --> $DIR/generator-print-verbose-2.rs:14:23 | LL | fn assert_sync(_: T) {} | ^^^^ required by this bound in `assert_sync` +error: generator cannot be sent between threads safely + --> $DIR/generator-print-verbose-2.rs:24:5 + | +LL | assert_send(|| { + | ^^^^^^^^^^^ generator is not `Send` + | + = help: within `{main::{closure#1} upvar_tys=() {main::{closure#1}}}`, the trait `Send` is not implemented for `NotSend` +note: generator is not `Send` as this value is used across a yield + --> $DIR/generator-print-verbose-2.rs:27:9 + | +LL | let a = NotSend; + | - has type `NotSend` which is not `Send` +LL | yield; + | ^^^^^ yield occurs here, with `a` maybe used later +note: required by a bound in `assert_send` + --> $DIR/generator-print-verbose-2.rs:15:23 + | +LL | fn assert_send(_: T) {} + | ^^^^ required by this bound in `assert_send` + error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/generator/retain-resume-ref.stderr b/tests/ui/generator/retain-resume-ref.stderr index e33310d12d9..bc715c7030e 100644 --- a/tests/ui/generator/retain-resume-ref.stderr +++ b/tests/ui/generator/retain-resume-ref.stderr @@ -4,9 +4,10 @@ error[E0499]: cannot borrow `thing` as mutable more than once at a time LL | gen.as_mut().resume(&mut thing); | ---------- first mutable borrow occurs here LL | gen.as_mut().resume(&mut thing); - | ------ ^^^^^^^^^^ second mutable borrow occurs here - | | - | first borrow later used by call + | ^^^^^^^^^^ second mutable borrow occurs here +LL | +LL | } + | - first borrow might be used here, when `gen` is dropped and runs the destructor for generator error: aborting due to previous error diff --git a/tests/ui/generator/unresolved-ct-var.rs b/tests/ui/generator/unresolved-ct-var.rs index 0a1570fc239..0316385fba9 100644 --- a/tests/ui/generator/unresolved-ct-var.rs +++ b/tests/ui/generator/unresolved-ct-var.rs @@ -5,10 +5,5 @@ fn main() { let _ = async { let s = std::array::from_fn(|_| ()).await; //~^ ERROR `[(); _]` is not a future - //~| ERROR type inside `async` block must be known in this context - //~| ERROR type inside `async` block must be known in this context - //~| ERROR type inside `async` block must be known in this context - //~| ERROR type inside `async` block must be known in this context - //~| ERROR type inside `async` block must be known in this context }; } diff --git a/tests/ui/generator/unresolved-ct-var.stderr b/tests/ui/generator/unresolved-ct-var.stderr index ace254178b7..9badc1dc291 100644 --- a/tests/ui/generator/unresolved-ct-var.stderr +++ b/tests/ui/generator/unresolved-ct-var.stderr @@ -12,67 +12,6 @@ LL | let s = std::array::from_fn(|_| ()).await; = note: [(); _] must be a future or must implement `IntoFuture` to be awaited = note: required for `[(); _]` to implement `IntoFuture` -error[E0698]: type inside `async` block must be known in this context - --> $DIR/unresolved-ct-var.rs:6:17 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn` - | -note: the type is part of the `async` block because of this `await` - --> $DIR/unresolved-ct-var.rs:6:45 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^ +error: aborting due to previous error -error[E0698]: type inside `async` block must be known in this context - --> $DIR/unresolved-ct-var.rs:6:17 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn` - | -note: the type is part of the `async` block because of this `await` - --> $DIR/unresolved-ct-var.rs:6:45 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^ - -error[E0698]: type inside `async` block must be known in this context - --> $DIR/unresolved-ct-var.rs:6:17 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn` - | -note: the type is part of the `async` block because of this `await` - --> $DIR/unresolved-ct-var.rs:6:45 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^ - -error[E0698]: type inside `async` block must be known in this context - --> $DIR/unresolved-ct-var.rs:6:17 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn` - | -note: the type is part of the `async` block because of this `await` - --> $DIR/unresolved-ct-var.rs:6:45 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^ - -error[E0698]: type inside `async` block must be known in this context - --> $DIR/unresolved-ct-var.rs:6:17 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn` - | -note: the type is part of the `async` block because of this `await` - --> $DIR/unresolved-ct-var.rs:6:45 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^ - -error: aborting due to 6 previous errors - -Some errors have detailed explanations: E0277, E0698. -For more information about an error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/generator/unsized-across-yield.rs b/tests/ui/generator/unsized-capture-across-yield.rs similarity index 66% rename from tests/ui/generator/unsized-across-yield.rs rename to tests/ui/generator/unsized-capture-across-yield.rs index 876d08ac1f0..7bcb0800ccf 100644 --- a/tests/ui/generator/unsized-across-yield.rs +++ b/tests/ui/generator/unsized-capture-across-yield.rs @@ -5,17 +5,6 @@ use std::ops::Generator; -fn across() -> impl Generator { - move || { - let b: [u8] = *(Box::new([]) as Box<[u8]>); - //~^ ERROR the size for values of type `[u8]` cannot be known at compilation time - - yield; - - for elem in b.iter() {} - } -} - fn capture() -> impl Generator { let b: [u8] = *(Box::new([]) as Box<[u8]>); move || { @@ -29,6 +18,5 @@ fn capture() -> impl Generator { } fn main() { - across(); capture(); } diff --git a/tests/ui/generator/unsized-across-yield.stderr b/tests/ui/generator/unsized-capture-across-yield.stderr similarity index 61% rename from tests/ui/generator/unsized-across-yield.stderr rename to tests/ui/generator/unsized-capture-across-yield.stderr index 82375a0ec2d..8a5b968a561 100644 --- a/tests/ui/generator/unsized-across-yield.stderr +++ b/tests/ui/generator/unsized-capture-across-yield.stderr @@ -1,5 +1,5 @@ warning: the feature `unsized_locals` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/unsized-across-yield.rs:3:12 + --> $DIR/unsized-capture-across-yield.rs:3:12 | LL | #![feature(unsized_locals)] | ^^^^^^^^^^^^^^ @@ -8,16 +8,7 @@ LL | #![feature(unsized_locals)] = note: `#[warn(incomplete_features)]` on by default error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/unsized-across-yield.rs:10:13 - | -LL | let b: [u8] = *(Box::new([]) as Box<[u8]>); - | ^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `[u8]` - = note: all values live across `yield` must have a statically known size - -error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/unsized-across-yield.rs:22:27 + --> $DIR/unsized-capture-across-yield.rs:11:27 | LL | move || { | -- this closure captures all values by move @@ -27,6 +18,6 @@ LL | println!("{:?}", &b); = help: the trait `Sized` is not implemented for `[u8]` = note: all values captured by value by a closure must have a statically known size -error: aborting due to 2 previous errors; 1 warning emitted +error: aborting due to previous error; 1 warning emitted For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/generator/unsized-local-across-yield.rs b/tests/ui/generator/unsized-local-across-yield.rs new file mode 100644 index 00000000000..f761f45c2af --- /dev/null +++ b/tests/ui/generator/unsized-local-across-yield.rs @@ -0,0 +1,21 @@ +#![feature(generator_trait)] +#![feature(generators)] +#![feature(unsized_locals)] +//~^ WARN the feature `unsized_locals` is incomplete and may not be safe to use and/or cause compiler crashes + +use std::ops::Generator; + +fn across() -> impl Generator { + move || { + let b: [u8] = *(Box::new([]) as Box<[u8]>); + //~^ ERROR the size for values of type `[u8]` cannot be known at compilation time + + yield; + + for elem in b.iter() {} + } +} + +fn main() { + across(); +} diff --git a/tests/ui/generator/unsized-local-across-yield.stderr b/tests/ui/generator/unsized-local-across-yield.stderr new file mode 100644 index 00000000000..1942f266e6c --- /dev/null +++ b/tests/ui/generator/unsized-local-across-yield.stderr @@ -0,0 +1,21 @@ +warning: the feature `unsized_locals` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/unsized-local-across-yield.rs:3:12 + | +LL | #![feature(unsized_locals)] + | ^^^^^^^^^^^^^^ + | + = note: see issue #48055 for more information + = note: `#[warn(incomplete_features)]` on by default + +error[E0277]: the size for values of type `[u8]` cannot be known at compilation time + --> $DIR/unsized-local-across-yield.rs:10:13 + | +LL | let b: [u8] = *(Box::new([]) as Box<[u8]>); + | ^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `[u8]` + = note: all values live across `yield` must have a statically known size + +error: aborting due to previous error; 1 warning emitted + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/generic-associated-types/bugs/issue-100013.stderr b/tests/ui/generic-associated-types/bugs/issue-100013.stderr index 86dbad84d99..93c69422f00 100644 --- a/tests/ui/generic-associated-types/bugs/issue-100013.stderr +++ b/tests/ui/generic-associated-types/bugs/issue-100013.stderr @@ -7,16 +7,6 @@ LL | | async {}.await; // a yield point LL | | } | |_____^ | -note: the lifetime defined here... - --> $DIR/issue-100013.rs:16:38 - | -LL | let x = None::>; // a type referencing GAT - | ^^ -note: ...must outlive the lifetime defined here - --> $DIR/issue-100013.rs:16:34 - | -LL | let x = None::>; // a type referencing GAT - | ^^ = note: this is a known limitation that will be removed in the future (see issue #100013 for more information) error: lifetime bound not satisfied @@ -28,16 +18,6 @@ LL | | async {}.await; // a yield point LL | | } | |_____^ | -note: the lifetime `'b` defined here... - --> $DIR/issue-100013.rs:21:14 - | -LL | fn call2<'a, 'b, I: FutureIterator>() -> impl Send { - | ^^ -note: ...must outlive the lifetime `'a` defined here - --> $DIR/issue-100013.rs:21:10 - | -LL | fn call2<'a, 'b, I: FutureIterator>() -> impl Send { - | ^^ = note: this is a known limitation that will be removed in the future (see issue #100013 for more information) error: lifetime may not live long enough @@ -62,16 +42,6 @@ LL | | async {}.await; // a yield point LL | | } | |_____^ | -note: the lifetime `'b` defined here... - --> $DIR/issue-100013.rs:28:18 - | -LL | fn call3<'a: 'b, 'b, I: FutureIterator>() -> impl Send { - | ^^ -note: ...must outlive the lifetime `'a` defined here - --> $DIR/issue-100013.rs:28:10 - | -LL | fn call3<'a: 'b, 'b, I: FutureIterator>() -> impl Send { - | ^^ = note: this is a known limitation that will be removed in the future (see issue #100013 for more information) error: aborting due to 4 previous errors diff --git a/tests/ui/impl-trait/issue-55872-2.rs b/tests/ui/impl-trait/issue-55872-2.rs index ec3d924cea7..8a96fdc5c63 100644 --- a/tests/ui/impl-trait/issue-55872-2.rs +++ b/tests/ui/impl-trait/issue-55872-2.rs @@ -13,6 +13,7 @@ impl Bar for S { fn foo() -> Self::E { async {} //~^ ERROR type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias + //~| ERROR type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias } } diff --git a/tests/ui/impl-trait/issue-55872-2.stderr b/tests/ui/impl-trait/issue-55872-2.stderr index 11b8485c8bb..3e70f1cf800 100644 --- a/tests/ui/impl-trait/issue-55872-2.stderr +++ b/tests/ui/impl-trait/issue-55872-2.stderr @@ -4,5 +4,11 @@ error: type parameter `T` is part of concrete type but not used in parameter lis LL | async {} | ^^^^^^^^ -error: aborting due to previous error +error: type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias + --> $DIR/issue-55872-2.rs:14:9 + | +LL | async {} + | ^^^^^^^^ + +error: aborting due to 2 previous errors diff --git a/tests/ui/impl-trait/recursive-generator.rs b/tests/ui/impl-trait/recursive-generator.rs index e876f0fb43f..000af70c454 100644 --- a/tests/ui/impl-trait/recursive-generator.rs +++ b/tests/ui/impl-trait/recursive-generator.rs @@ -7,7 +7,6 @@ fn foo() -> impl Generator { //~| NOTE recursive opaque type //~| NOTE in this expansion of desugaring of || { - //~^ NOTE returning here let mut gen = Box::pin(foo()); //~^ NOTE generator captures itself here let mut r = gen.as_mut().resume(()); diff --git a/tests/ui/impl-trait/recursive-generator.stderr b/tests/ui/impl-trait/recursive-generator.stderr index 9d8139ef114..86e193d9599 100644 --- a/tests/ui/impl-trait/recursive-generator.stderr +++ b/tests/ui/impl-trait/recursive-generator.stderr @@ -1,18 +1,11 @@ error[E0720]: cannot resolve opaque type --> $DIR/recursive-generator.rs:5:13 | -LL | fn foo() -> impl Generator { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ recursive opaque type +LL | fn foo() -> impl Generator { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ recursive opaque type ... -LL | / || { -LL | | -LL | | let mut gen = Box::pin(foo()); - | | ------- generator captures itself here -LL | | -... | -LL | | } -LL | | } - | |_____- returning here with type `{generator@$DIR/recursive-generator.rs:9:5: 9:7}` +LL | let mut gen = Box::pin(foo()); + | ------- generator captures itself here error: aborting due to previous error diff --git a/tests/ui/impl-trait/recursive-impl-trait-type-indirect.stderr b/tests/ui/impl-trait/recursive-impl-trait-type-indirect.stderr index a792e371185..1d919fb5240 100644 --- a/tests/ui/impl-trait/recursive-impl-trait-type-indirect.stderr +++ b/tests/ui/impl-trait/recursive-impl-trait-type-indirect.stderr @@ -112,16 +112,11 @@ LL | (substs_change::<&T>(),) error[E0720]: cannot resolve opaque type --> $DIR/recursive-impl-trait-type-indirect.rs:72:24 | -LL | fn generator_hold() -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -LL | -LL | / move || { -LL | | let x = generator_hold(); - | | - generator captures itself here -LL | | yield; -LL | | x; -LL | | } - | |_____- returning here with type `{generator@$DIR/recursive-impl-trait-type-indirect.rs:74:5: 74:12}` +LL | fn generator_hold() -> impl Sized { + | ^^^^^^^^^^ recursive opaque type +... +LL | let x = generator_hold(); + | - generator captures itself here error[E0720]: cannot resolve opaque type --> $DIR/recursive-impl-trait-type-indirect.rs:86:26 diff --git a/tests/ui/lint/must_not_suspend/dedup.rs b/tests/ui/lint/must_not_suspend/dedup.rs index 81a08579bb7..867bdf2ec12 100644 --- a/tests/ui/lint/must_not_suspend/dedup.rs +++ b/tests/ui/lint/must_not_suspend/dedup.rs @@ -13,7 +13,10 @@ async fn wheeee(t: T) { } async fn yes() { - wheeee(&No {}).await; //~ ERROR `No` held across + let no = No {}; + //~^ ERROR `No` held across + wheeee(&no).await; + drop(no); } fn main() { diff --git a/tests/ui/lint/must_not_suspend/dedup.stderr b/tests/ui/lint/must_not_suspend/dedup.stderr index 6925b1640b2..5d5b04a5d95 100644 --- a/tests/ui/lint/must_not_suspend/dedup.stderr +++ b/tests/ui/lint/must_not_suspend/dedup.stderr @@ -1,14 +1,17 @@ error: `No` held across a suspend point, but should not be - --> $DIR/dedup.rs:16:13 + --> $DIR/dedup.rs:16:9 | -LL | wheeee(&No {}).await; - | ^^^^^ ----- the value is held across this suspend point +LL | let no = No {}; + | ^^ +LL | +LL | wheeee(&no).await; + | ----- the value is held across this suspend point | help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point - --> $DIR/dedup.rs:16:13 + --> $DIR/dedup.rs:16:9 | -LL | wheeee(&No {}).await; - | ^^^^^ +LL | let no = No {}; + | ^^ note: the lint level is defined here --> $DIR/dedup.rs:3:9 | diff --git a/tests/ui/lint/must_not_suspend/ref.stderr b/tests/ui/lint/must_not_suspend/ref.stderr index 148af00a3d2..ed91a4a0bc6 100644 --- a/tests/ui/lint/must_not_suspend/ref.stderr +++ b/tests/ui/lint/must_not_suspend/ref.stderr @@ -1,22 +1,22 @@ -error: `Umm` held across a suspend point, but should not be - --> $DIR/ref.rs:18:26 +error: reference to `Umm` held across a suspend point, but should not be + --> $DIR/ref.rs:18:13 | LL | let guard = &mut self.u; - | ^^^^^^ + | ^^^^^ LL | LL | other().await; | ----- the value is held across this suspend point | note: You gotta use Umm's, ya know? - --> $DIR/ref.rs:18:26 + --> $DIR/ref.rs:18:13 | LL | let guard = &mut self.u; - | ^^^^^^ + | ^^^^^ help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point - --> $DIR/ref.rs:18:26 + --> $DIR/ref.rs:18:13 | LL | let guard = &mut self.u; - | ^^^^^^ + | ^^^^^ note: the lint level is defined here --> $DIR/ref.rs:3:9 | diff --git a/tests/ui/lint/must_not_suspend/unit.rs b/tests/ui/lint/must_not_suspend/unit.rs index d3a19f70432..af4a76caa4e 100644 --- a/tests/ui/lint/must_not_suspend/unit.rs +++ b/tests/ui/lint/must_not_suspend/unit.rs @@ -19,6 +19,7 @@ async fn other() {} pub async fn uhoh() { let _guard = bar(); //~ ERROR `Umm` held across other().await; + drop(_guard); } fn main() { diff --git a/tests/ui/lint/must_not_suspend/warn.rs b/tests/ui/lint/must_not_suspend/warn.rs index 7fdea66a235..2d5dd01e5bf 100644 --- a/tests/ui/lint/must_not_suspend/warn.rs +++ b/tests/ui/lint/must_not_suspend/warn.rs @@ -18,8 +18,9 @@ fn bar() -> Umm { async fn other() {} pub async fn uhoh() { - let _guard = bar(); //~ WARNING `Umm` held across + let guard = bar(); //~ WARNING `Umm` held across other().await; + drop(guard); } fn main() { diff --git a/tests/ui/lint/must_not_suspend/warn.stderr b/tests/ui/lint/must_not_suspend/warn.stderr index 194433552cf..e59656e508c 100644 --- a/tests/ui/lint/must_not_suspend/warn.stderr +++ b/tests/ui/lint/must_not_suspend/warn.stderr @@ -1,21 +1,21 @@ warning: `Umm` held across a suspend point, but should not be --> $DIR/warn.rs:21:9 | -LL | let _guard = bar(); - | ^^^^^^ +LL | let guard = bar(); + | ^^^^^ LL | other().await; | ----- the value is held across this suspend point | note: You gotta use Umm's, ya know? --> $DIR/warn.rs:21:9 | -LL | let _guard = bar(); - | ^^^^^^ +LL | let guard = bar(); + | ^^^^^ help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point --> $DIR/warn.rs:21:9 | -LL | let _guard = bar(); - | ^^^^^^ +LL | let guard = bar(); + | ^^^^^ note: the lint level is defined here --> $DIR/warn.rs:4:9 | diff --git a/tests/ui/traits/new-solver/auto-with-drop_tracking_mir.rs b/tests/ui/traits/new-solver/auto-with-drop_tracking_mir.rs index e311a4af2f4..6b54718e35c 100644 --- a/tests/ui/traits/new-solver/auto-with-drop_tracking_mir.rs +++ b/tests/ui/traits/new-solver/auto-with-drop_tracking_mir.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next -Zdrop-tracking-mir +// compile-flags: -Ztrait-solver=next // edition: 2021 // revisions: pass fail //[pass] check-pass diff --git a/tests/ui/traits/unsend-future.rs b/tests/ui/traits/unsend-future.rs index fbbc07b11e7..a8367573fbd 100644 --- a/tests/ui/traits/unsend-future.rs +++ b/tests/ui/traits/unsend-future.rs @@ -13,6 +13,7 @@ fn require_handler(h: H) {} async fn handler() { let a = &1 as *const i32; async {}.await; + let b = a; } fn main() { diff --git a/tests/ui/traits/unsend-future.stderr b/tests/ui/traits/unsend-future.stderr index 6ce1cf452f4..01829021b4a 100644 --- a/tests/ui/traits/unsend-future.stderr +++ b/tests/ui/traits/unsend-future.stderr @@ -1,5 +1,5 @@ error: future cannot be sent between threads safely - --> $DIR/unsend-future.rs:19:21 + --> $DIR/unsend-future.rs:20:21 | LL | require_handler(handler) | ^^^^^^^ future returned by `handler` is not `Send` @@ -12,8 +12,6 @@ LL | let a = &1 as *const i32; | - has type `*const i32` which is not `Send` LL | async {}.await; | ^^^^^ await occurs here, with `a` maybe used later -LL | } - | - `a` is later dropped here note: required by a bound in `require_handler` --> $DIR/unsend-future.rs:11:23 | diff --git a/tests/ui/type-alias-impl-trait/indirect-recursion-issue-112047.rs b/tests/ui/type-alias-impl-trait/indirect-recursion-issue-112047.rs index baa22e1ce18..f6cbbf04d82 100644 --- a/tests/ui/type-alias-impl-trait/indirect-recursion-issue-112047.rs +++ b/tests/ui/type-alias-impl-trait/indirect-recursion-issue-112047.rs @@ -1,6 +1,6 @@ // edition: 2021 // build-fail -//~^^ ERROR overflow evaluating the requirement `<() as Recur>::Recur == _` +//~^^ ERROR cycle detected when computing layout of #![feature(impl_trait_in_assoc_type)] diff --git a/tests/ui/type-alias-impl-trait/indirect-recursion-issue-112047.stderr b/tests/ui/type-alias-impl-trait/indirect-recursion-issue-112047.stderr index 0238694c24d..3312230bc81 100644 --- a/tests/ui/type-alias-impl-trait/indirect-recursion-issue-112047.stderr +++ b/tests/ui/type-alias-impl-trait/indirect-recursion-issue-112047.stderr @@ -1,5 +1,16 @@ -error[E0275]: overflow evaluating the requirement `<() as Recur>::Recur == _` +error[E0391]: cycle detected when computing layout of `{async block@$DIR/indirect-recursion-issue-112047.rs:23:9: 23:42}` + | + = note: ...which requires computing layout of `core::mem::maybe_uninit::MaybeUninit`... + = note: ...which requires computing layout of `core::mem::maybe_uninit::MaybeUninit<{async fn body@$DIR/indirect-recursion-issue-112047.rs:15:31: 17:2}>`... + = note: ...which requires computing layout of `core::mem::manually_drop::ManuallyDrop<{async fn body@$DIR/indirect-recursion-issue-112047.rs:15:31: 17:2}>`... + = note: ...which requires computing layout of `{async fn body@$DIR/indirect-recursion-issue-112047.rs:15:31: 17:2}`... + = note: ...which requires computing layout of `core::mem::maybe_uninit::MaybeUninit<<() as Recur>::Recur>`... + = note: ...which requires computing layout of `core::mem::maybe_uninit::MaybeUninit<{async block@$DIR/indirect-recursion-issue-112047.rs:23:9: 23:42}>`... + = note: ...which requires computing layout of `core::mem::manually_drop::ManuallyDrop<{async block@$DIR/indirect-recursion-issue-112047.rs:23:9: 23:42}>`... + = note: ...which again requires computing layout of `{async block@$DIR/indirect-recursion-issue-112047.rs:23:9: 23:42}`, completing the cycle + = note: cycle used when computing layout of `::Recur` + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to previous error -For more information about this error, try `rustc --explain E0275`. +For more information about this error, try `rustc --explain E0391`. From d989e14cf2885b483a443875a0974ca25e902f24 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sat, 28 Jan 2023 18:49:48 +0000 Subject: [PATCH 19/30] Bless mir-opt --- ...await.a-{closure#0}.generator_resume.0.mir | 16 +++- ...await.b-{closure#0}.generator_resume.0.mir | 20 +++-- ...ine_generator.main.Inline.panic-abort.diff | 75 ++++++++++--------- ...ne_generator.main.Inline.panic-unwind.diff | 54 +++++++------ 4 files changed, 97 insertions(+), 68 deletions(-) diff --git a/tests/mir-opt/building/async_await.a-{closure#0}.generator_resume.0.mir b/tests/mir-opt/building/async_await.a-{closure#0}.generator_resume.0.mir index 51e0faf1733..98b1befc3bf 100644 --- a/tests/mir-opt/building/async_await.a-{closure#0}.generator_resume.0.mir +++ b/tests/mir-opt/building/async_await.a-{closure#0}.generator_resume.0.mir @@ -18,22 +18,30 @@ fn a::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:11:14: 11:16}> bb0: { _5 = discriminant((*(_1.0: &mut {async fn body@$DIR/async_await.rs:11:14: 11:16}))); - switchInt(move _5) -> [0: bb1, 1: bb2, otherwise: bb3]; + switchInt(move _5) -> [0: bb1, 1: bb4, otherwise: bb5]; } bb1: { _4 = move _2; _3 = const (); + goto -> bb3; + } + + bb2: { _0 = Poll::<()>::Ready(move _3); discriminant((*(_1.0: &mut {async fn body@$DIR/async_await.rs:11:14: 11:16}))) = 1; return; } - bb2: { - assert(const false, "`async fn` resumed after completion") -> [success: bb2, unwind unreachable]; + bb3: { + goto -> bb2; } - bb3: { + bb4: { + assert(const false, "`async fn` resumed after completion") -> [success: bb4, unwind unreachable]; + } + + bb5: { unreachable; } } diff --git a/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir b/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir index 0c46c60a2da..4d3baee7f11 100644 --- a/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir +++ b/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir @@ -104,7 +104,7 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:14:18: 17:2}>, bb0: { _39 = discriminant((*(_1.0: &mut {async fn body@$DIR/async_await.rs:14:18: 17:2}))); - switchInt(move _39) -> [0: bb1, 1: bb28, 3: bb26, 4: bb27, otherwise: bb29]; + switchInt(move _39) -> [0: bb1, 1: bb29, 3: bb27, 4: bb28, otherwise: bb30]; } bb1: { @@ -187,7 +187,7 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:14:18: 17:2}>, StorageDead(_12); StorageDead(_9); StorageDead(_8); - goto -> bb12; + drop((((*(_1.0: &mut {async fn body@$DIR/async_await.rs:14:18: 17:2})) as variant#3).0: impl std::future::Future)) -> [return: bb12, unwind unreachable]; } bb11: { @@ -279,7 +279,7 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:14:18: 17:2}>, StorageDead(_28); StorageDead(_25); StorageDead(_24); - goto -> bb23; + drop((((*(_1.0: &mut {async fn body@$DIR/async_await.rs:14:18: 17:2})) as variant#4).0: impl std::future::Future)) -> [return: bb23, unwind unreachable]; } bb22: { @@ -297,7 +297,7 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:14:18: 17:2}>, bb24: { StorageDead(_21); - goto -> bb25; + goto -> bb26; } bb25: { @@ -307,6 +307,10 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:14:18: 17:2}>, } bb26: { + goto -> bb25; + } + + bb27: { StorageLive(_3); StorageLive(_4); StorageLive(_19); @@ -315,7 +319,7 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:14:18: 17:2}>, goto -> bb11; } - bb27: { + bb28: { StorageLive(_21); StorageLive(_35); StorageLive(_36); @@ -323,11 +327,11 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:14:18: 17:2}>, goto -> bb22; } - bb28: { - assert(const false, "`async fn` resumed after completion") -> [success: bb28, unwind unreachable]; + bb29: { + assert(const false, "`async fn` resumed after completion") -> [success: bb29, unwind unreachable]; } - bb29: { + bb30: { unreachable; } } diff --git a/tests/mir-opt/inline/inline_generator.main.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_generator.main.Inline.panic-abort.diff index d2c0591cc0a..3f093a02dd2 100644 --- a/tests/mir-opt/inline/inline_generator.main.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/inline_generator.main.Inline.panic-abort.diff @@ -36,62 +36,67 @@ StorageLive(_3); StorageLive(_4); - _4 = g() -> [return: bb1, unwind unreachable]; -- } -- -- bb1: { + _4 = {generator@$DIR/inline_generator.rs:16:5: 16:8 (#0)}; - _3 = &mut _4; -- _2 = Pin::<&mut {generator@$DIR/inline_generator.rs:16:5: 16:8}>::new(move _3) -> [return: bb2, unwind unreachable]; -- } -- -- bb2: { ++ _3 = &mut _4; + _2 = Pin::<&mut {generator@$DIR/inline_generator.rs:16:5: 16:8}> { pointer: move _3 }; - StorageDead(_3); -- _1 = <{generator@$DIR/inline_generator.rs:16:5: 16:8} as Generator>::resume(move _2, const false) -> [return: bb3, unwind unreachable]; ++ StorageDead(_3); + StorageLive(_5); + _5 = const false; + _6 = deref_copy (_2.0: &mut {generator@$DIR/inline_generator.rs:16:5: 16:8}); + _7 = discriminant((*_6)); -+ switchInt(move _7) -> [0: bb2, 1: bb6, 3: bb7, otherwise: bb8]; ++ switchInt(move _7) -> [0: bb3, 1: bb7, 3: bb8, otherwise: bb9]; } -- bb3: { -+ bb1: { + bb1: { +- _3 = &mut _4; +- _2 = Pin::<&mut {generator@$DIR/inline_generator.rs:16:5: 16:8}>::new(move _3) -> [return: bb2, unwind unreachable]; + StorageDead(_5); - StorageDead(_2); - StorageDead(_4); - _0 = const (); - StorageDead(_1); - return; -+ } -+ -+ bb2: { ++ StorageDead(_2); ++ drop(_4) -> [return: bb2, unwind unreachable]; + } + + bb2: { +- StorageDead(_3); +- _1 = <{generator@$DIR/inline_generator.rs:16:5: 16:8} as Generator>::resume(move _2, const false) -> [return: bb3, unwind unreachable]; ++ StorageDead(_4); ++ _0 = const (); ++ StorageDead(_1); ++ return; + } + + bb3: { +- StorageDead(_2); +- drop(_4) -> [return: bb4, unwind unreachable]; + StorageLive(_8); -+ switchInt(_5) -> [0: bb3, otherwise: bb4]; -+ } -+ -+ bb3: { ++ switchInt(_5) -> [0: bb4, otherwise: bb5]; + } + + bb4: { +- StorageDead(_4); +- _0 = const (); +- StorageDead(_1); +- return; + _8 = const 13_i32; -+ goto -> bb5; -+ } -+ -+ bb4: { -+ _8 = const 7_i32; -+ goto -> bb5; ++ goto -> bb6; + } + + bb5: { ++ _8 = const 7_i32; ++ goto -> bb6; ++ } ++ ++ bb6: { + _1 = GeneratorState::::Yielded(move _8); + _9 = deref_copy (_2.0: &mut {generator@$DIR/inline_generator.rs:16:5: 16:8}); + discriminant((*_9)) = 3; + goto -> bb1; + } + -+ bb6: { -+ assert(const false, "generator resumed after completion") -> [success: bb6, unwind unreachable]; ++ bb7: { ++ assert(const false, "generator resumed after completion") -> [success: bb7, unwind unreachable]; + } + -+ bb7: { ++ bb8: { + StorageLive(_8); + StorageDead(_8); + _1 = GeneratorState::::Complete(_5); @@ -100,7 +105,7 @@ + goto -> bb1; + } + -+ bb8: { ++ bb9: { + unreachable; } } diff --git a/tests/mir-opt/inline/inline_generator.main.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_generator.main.Inline.panic-unwind.diff index c024e3d7f77..3d76262c266 100644 --- a/tests/mir-opt/inline/inline_generator.main.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/inline_generator.main.Inline.panic-unwind.diff @@ -41,62 +41,74 @@ - bb1: { + _4 = {generator@$DIR/inline_generator.rs:16:5: 16:8 (#0)}; _3 = &mut _4; -- _2 = Pin::<&mut {generator@$DIR/inline_generator.rs:16:5: 16:8}>::new(move _3) -> [return: bb2, unwind: bb4]; +- _2 = Pin::<&mut {generator@$DIR/inline_generator.rs:16:5: 16:8}>::new(move _3) -> [return: bb2, unwind: bb5]; - } - - bb2: { + _2 = Pin::<&mut {generator@$DIR/inline_generator.rs:16:5: 16:8}> { pointer: move _3 }; StorageDead(_3); -- _1 = <{generator@$DIR/inline_generator.rs:16:5: 16:8} as Generator>::resume(move _2, const false) -> [return: bb3, unwind: bb4]; +- _1 = <{generator@$DIR/inline_generator.rs:16:5: 16:8} as Generator>::resume(move _2, const false) -> [return: bb3, unwind: bb5]; + StorageLive(_5); + _5 = const false; + _6 = deref_copy (_2.0: &mut {generator@$DIR/inline_generator.rs:16:5: 16:8}); + _7 = discriminant((*_6)); -+ switchInt(move _7) -> [0: bb3, 1: bb7, 3: bb8, otherwise: bb9]; ++ switchInt(move _7) -> [0: bb5, 1: bb9, 3: bb10, otherwise: bb11]; } - bb3: { + bb1: { + StorageDead(_5); StorageDead(_2); +- drop(_4) -> [return: bb4, unwind: bb6]; ++ drop(_4) -> [return: bb2, unwind: bb4]; + } + +- bb4: { ++ bb2: { StorageDead(_4); _0 = const (); StorageDead(_1); return; } -- bb4 (cleanup): { -+ bb2 (cleanup): { +- bb5 (cleanup): { +- drop(_4) -> [return: bb6, unwind terminate(cleanup)]; ++ bb3 (cleanup): { ++ drop(_4) -> [return: bb4, unwind terminate(cleanup)]; + } + +- bb6 (cleanup): { ++ bb4 (cleanup): { resume; + } + -+ bb3: { -+ StorageLive(_8); -+ switchInt(_5) -> [0: bb4, otherwise: bb5]; -+ } -+ -+ bb4: { -+ _8 = const 13_i32; -+ goto -> bb6; -+ } -+ + bb5: { -+ _8 = const 7_i32; -+ goto -> bb6; ++ StorageLive(_8); ++ switchInt(_5) -> [0: bb6, otherwise: bb7]; + } + + bb6: { ++ _8 = const 13_i32; ++ goto -> bb8; ++ } ++ ++ bb7: { ++ _8 = const 7_i32; ++ goto -> bb8; ++ } ++ ++ bb8: { + _1 = GeneratorState::::Yielded(move _8); + _9 = deref_copy (_2.0: &mut {generator@$DIR/inline_generator.rs:16:5: 16:8}); + discriminant((*_9)) = 3; + goto -> bb1; + } + -+ bb7: { -+ assert(const false, "generator resumed after completion") -> [success: bb7, unwind: bb2]; ++ bb9: { ++ assert(const false, "generator resumed after completion") -> [success: bb9, unwind: bb3]; + } + -+ bb8: { ++ bb10: { + StorageLive(_8); + StorageDead(_8); + _1 = GeneratorState::::Complete(_5); @@ -105,7 +117,7 @@ + goto -> bb1; + } + -+ bb9: { ++ bb11: { + unreachable; } } From 6aa1268900506d5004c681e07b868db0cfc683fe Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sat, 28 Jan 2023 23:20:02 +0000 Subject: [PATCH 20/30] Bless clippy. --- .../await_holding_invalid_type.rs | 6 +- .../await_holding_invalid_type.stderr | 6 +- .../clippy/tests/ui/await_holding_lock.stderr | 131 ++++++------------ .../tests/ui/await_holding_refcell_ref.stderr | 63 +++------ src/tools/clippy/tests/ui/future_not_send.rs | 1 + .../clippy/tests/ui/future_not_send.stderr | 36 ++--- 6 files changed, 82 insertions(+), 161 deletions(-) diff --git a/src/tools/clippy/tests/ui-toml/await_holding_invalid_type/await_holding_invalid_type.rs b/src/tools/clippy/tests/ui-toml/await_holding_invalid_type/await_holding_invalid_type.rs index fbef5c4564b..868cf00a8d4 100644 --- a/src/tools/clippy/tests/ui-toml/await_holding_invalid_type/await_holding_invalid_type.rs +++ b/src/tools/clippy/tests/ui-toml/await_holding_invalid_type/await_holding_invalid_type.rs @@ -7,8 +7,10 @@ async fn bad() -> u32 { } async fn bad_reason() -> u32 { - let _x = Ipv4Addr::new(127, 0, 0, 1); - baz().await + let x = Ipv4Addr::new(127, 0, 0, 1); + let y = baz().await; + let _x = x; + y } async fn good() -> u32 { diff --git a/src/tools/clippy/tests/ui-toml/await_holding_invalid_type/await_holding_invalid_type.stderr b/src/tools/clippy/tests/ui-toml/await_holding_invalid_type/await_holding_invalid_type.stderr index 6f8b04fd12b..ddcd1940d47 100644 --- a/src/tools/clippy/tests/ui-toml/await_holding_invalid_type/await_holding_invalid_type.stderr +++ b/src/tools/clippy/tests/ui-toml/await_holding_invalid_type/await_holding_invalid_type.stderr @@ -11,11 +11,11 @@ LL | let _x = String::from("hello"); error: `std::net::Ipv4Addr` may not be held across an `await` point per `clippy.toml` --> $DIR/await_holding_invalid_type.rs:10:9 | -LL | let _x = Ipv4Addr::new(127, 0, 0, 1); - | ^^ +LL | let x = Ipv4Addr::new(127, 0, 0, 1); + | ^ error: `std::string::String` may not be held across an `await` point per `clippy.toml` - --> $DIR/await_holding_invalid_type.rs:31:13 + --> $DIR/await_holding_invalid_type.rs:33:13 | LL | let _x = String::from("hi!"); | ^^ diff --git a/src/tools/clippy/tests/ui/await_holding_lock.stderr b/src/tools/clippy/tests/ui/await_holding_lock.stderr index 56b111c4d9e..47821040002 100644 --- a/src/tools/clippy/tests/ui/await_holding_lock.stderr +++ b/src/tools/clippy/tests/ui/await_holding_lock.stderr @@ -6,13 +6,10 @@ LL | let guard = x.lock().unwrap(); | = help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await note: these are all the `await` points this lock is held through - --> $DIR/await_holding_lock.rs:9:9 + --> $DIR/await_holding_lock.rs:11:15 | -LL | / let guard = x.lock().unwrap(); -LL | | -LL | | baz().await -LL | | } - | |_____^ +LL | baz().await + | ^^^^^ = note: `-D clippy::await-holding-lock` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::await_holding_lock)]` @@ -24,13 +21,10 @@ LL | let guard = x.read().unwrap(); | = help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await note: these are all the `await` points this lock is held through - --> $DIR/await_holding_lock.rs:25:9 + --> $DIR/await_holding_lock.rs:27:15 | -LL | / let guard = x.read().unwrap(); -LL | | -LL | | baz().await -LL | | } - | |_____^ +LL | baz().await + | ^^^^^ error: this `MutexGuard` is held across an `await` point --> $DIR/await_holding_lock.rs:31:13 @@ -40,13 +34,10 @@ LL | let mut guard = x.write().unwrap(); | = help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await note: these are all the `await` points this lock is held through - --> $DIR/await_holding_lock.rs:31:9 + --> $DIR/await_holding_lock.rs:33:15 | -LL | / let mut guard = x.write().unwrap(); -LL | | -LL | | baz().await -LL | | } - | |_____^ +LL | baz().await + | ^^^^^ error: this `MutexGuard` is held across an `await` point --> $DIR/await_holding_lock.rs:53:13 @@ -56,16 +47,13 @@ LL | let guard = x.lock().unwrap(); | = help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await note: these are all the `await` points this lock is held through - --> $DIR/await_holding_lock.rs:53:9 + --> $DIR/await_holding_lock.rs:56:28 | -LL | / let guard = x.lock().unwrap(); -LL | | -LL | | -LL | | let second = baz().await; -... | -LL | | first + second + third -LL | | } - | |_____^ +LL | let second = baz().await; + | ^^^^^ +LL | +LL | let third = baz().await; + | ^^^^^ error: this `MutexGuard` is held across an `await` point --> $DIR/await_holding_lock.rs:67:17 @@ -75,13 +63,10 @@ LL | let guard = x.lock().unwrap(); | = help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await note: these are all the `await` points this lock is held through - --> $DIR/await_holding_lock.rs:67:13 + --> $DIR/await_holding_lock.rs:69:19 | -LL | / let guard = x.lock().unwrap(); -LL | | -LL | | baz().await -LL | | }; - | |_________^ +LL | baz().await + | ^^^^^ error: this `MutexGuard` is held across an `await` point --> $DIR/await_holding_lock.rs:80:17 @@ -91,13 +76,10 @@ LL | let guard = x.lock().unwrap(); | = help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await note: these are all the `await` points this lock is held through - --> $DIR/await_holding_lock.rs:80:13 + --> $DIR/await_holding_lock.rs:82:19 | -LL | / let guard = x.lock().unwrap(); -LL | | -LL | | baz().await -LL | | } - | |_________^ +LL | baz().await + | ^^^^^ error: this `MutexGuard` is held across an `await` point --> $DIR/await_holding_lock.rs:93:13 @@ -107,13 +89,10 @@ LL | let guard = x.lock(); | = help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await note: these are all the `await` points this lock is held through - --> $DIR/await_holding_lock.rs:93:9 + --> $DIR/await_holding_lock.rs:95:15 | -LL | / let guard = x.lock(); -LL | | -LL | | baz().await -LL | | } - | |_____^ +LL | baz().await + | ^^^^^ error: this `MutexGuard` is held across an `await` point --> $DIR/await_holding_lock.rs:109:13 @@ -123,13 +102,10 @@ LL | let guard = x.read(); | = help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await note: these are all the `await` points this lock is held through - --> $DIR/await_holding_lock.rs:109:9 + --> $DIR/await_holding_lock.rs:111:15 | -LL | / let guard = x.read(); -LL | | -LL | | baz().await -LL | | } - | |_____^ +LL | baz().await + | ^^^^^ error: this `MutexGuard` is held across an `await` point --> $DIR/await_holding_lock.rs:115:13 @@ -139,13 +115,10 @@ LL | let mut guard = x.write(); | = help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await note: these are all the `await` points this lock is held through - --> $DIR/await_holding_lock.rs:115:9 + --> $DIR/await_holding_lock.rs:117:15 | -LL | / let mut guard = x.write(); -LL | | -LL | | baz().await -LL | | } - | |_____^ +LL | baz().await + | ^^^^^ error: this `MutexGuard` is held across an `await` point --> $DIR/await_holding_lock.rs:137:13 @@ -155,16 +128,13 @@ LL | let guard = x.lock(); | = help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await note: these are all the `await` points this lock is held through - --> $DIR/await_holding_lock.rs:137:9 + --> $DIR/await_holding_lock.rs:140:28 | -LL | / let guard = x.lock(); -LL | | -LL | | -LL | | let second = baz().await; -... | -LL | | first + second + third -LL | | } - | |_____^ +LL | let second = baz().await; + | ^^^^^ +LL | +LL | let third = baz().await; + | ^^^^^ error: this `MutexGuard` is held across an `await` point --> $DIR/await_holding_lock.rs:151:17 @@ -174,13 +144,10 @@ LL | let guard = x.lock(); | = help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await note: these are all the `await` points this lock is held through - --> $DIR/await_holding_lock.rs:151:13 + --> $DIR/await_holding_lock.rs:153:19 | -LL | / let guard = x.lock(); -LL | | -LL | | baz().await -LL | | }; - | |_________^ +LL | baz().await + | ^^^^^ error: this `MutexGuard` is held across an `await` point --> $DIR/await_holding_lock.rs:164:17 @@ -190,13 +157,10 @@ LL | let guard = x.lock(); | = help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await note: these are all the `await` points this lock is held through - --> $DIR/await_holding_lock.rs:164:13 + --> $DIR/await_holding_lock.rs:166:19 | -LL | / let guard = x.lock(); -LL | | -LL | | baz().await -LL | | } - | |_________^ +LL | baz().await + | ^^^^^ error: this `MutexGuard` is held across an `await` point --> $DIR/await_holding_lock.rs:185:9 @@ -206,15 +170,10 @@ LL | let mut guard = x.lock().unwrap(); | = help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await note: these are all the `await` points this lock is held through - --> $DIR/await_holding_lock.rs:185:5 + --> $DIR/await_holding_lock.rs:189:11 | -LL | / let mut guard = x.lock().unwrap(); -LL | | -LL | | *guard += 1; -LL | | drop(guard); -LL | | baz().await; -LL | | } - | |_^ +LL | baz().await; + | ^^^^^ error: aborting due to 13 previous errors diff --git a/src/tools/clippy/tests/ui/await_holding_refcell_ref.stderr b/src/tools/clippy/tests/ui/await_holding_refcell_ref.stderr index 6b7e1d1afdd..9264af93dc1 100644 --- a/src/tools/clippy/tests/ui/await_holding_refcell_ref.stderr +++ b/src/tools/clippy/tests/ui/await_holding_refcell_ref.stderr @@ -6,13 +6,10 @@ LL | let b = x.borrow(); | = help: ensure the reference is dropped before calling `await` note: these are all the `await` points this reference is held through - --> $DIR/await_holding_refcell_ref.rs:6:5 + --> $DIR/await_holding_refcell_ref.rs:8:11 | -LL | / let b = x.borrow(); -LL | | -LL | | baz().await -LL | | } - | |_^ +LL | baz().await + | ^^^^^ = note: `-D clippy::await-holding-refcell-ref` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::await_holding_refcell_ref)]` @@ -24,13 +21,10 @@ LL | let b = x.borrow_mut(); | = help: ensure the reference is dropped before calling `await` note: these are all the `await` points this reference is held through - --> $DIR/await_holding_refcell_ref.rs:12:5 + --> $DIR/await_holding_refcell_ref.rs:14:11 | -LL | / let b = x.borrow_mut(); -LL | | -LL | | baz().await -LL | | } - | |_^ +LL | baz().await + | ^^^^^ error: this `RefCell` reference is held across an `await` point --> $DIR/await_holding_refcell_ref.rs:34:9 @@ -40,16 +34,13 @@ LL | let b = x.borrow_mut(); | = help: ensure the reference is dropped before calling `await` note: these are all the `await` points this reference is held through - --> $DIR/await_holding_refcell_ref.rs:34:5 + --> $DIR/await_holding_refcell_ref.rs:37:24 | -LL | / let b = x.borrow_mut(); -LL | | -LL | | -LL | | let second = baz().await; -... | -LL | | first + second + third -LL | | } - | |_^ +LL | let second = baz().await; + | ^^^^^ +LL | +LL | let third = baz().await; + | ^^^^^ error: this `RefCell` reference is held across an `await` point --> $DIR/await_holding_refcell_ref.rs:47:9 @@ -59,16 +50,10 @@ LL | let b = x.borrow_mut(); | = help: ensure the reference is dropped before calling `await` note: these are all the `await` points this reference is held through - --> $DIR/await_holding_refcell_ref.rs:47:5 + --> $DIR/await_holding_refcell_ref.rs:50:24 | -LL | / let b = x.borrow_mut(); -LL | | -LL | | -LL | | let second = baz().await; -... | -LL | | first + second + third -LL | | } - | |_^ +LL | let second = baz().await; + | ^^^^^ error: this `RefCell` reference is held across an `await` point --> $DIR/await_holding_refcell_ref.rs:63:13 @@ -78,13 +63,10 @@ LL | let b = x.borrow_mut(); | = help: ensure the reference is dropped before calling `await` note: these are all the `await` points this reference is held through - --> $DIR/await_holding_refcell_ref.rs:63:9 + --> $DIR/await_holding_refcell_ref.rs:65:15 | -LL | / let b = x.borrow_mut(); -LL | | -LL | | baz().await -LL | | }; - | |_____^ +LL | baz().await + | ^^^^^ error: this `RefCell` reference is held across an `await` point --> $DIR/await_holding_refcell_ref.rs:76:13 @@ -94,13 +76,10 @@ LL | let b = x.borrow_mut(); | = help: ensure the reference is dropped before calling `await` note: these are all the `await` points this reference is held through - --> $DIR/await_holding_refcell_ref.rs:76:9 + --> $DIR/await_holding_refcell_ref.rs:78:15 | -LL | / let b = x.borrow_mut(); -LL | | -LL | | baz().await -LL | | } - | |_____^ +LL | baz().await + | ^^^^^ error: aborting due to 6 previous errors diff --git a/src/tools/clippy/tests/ui/future_not_send.rs b/src/tools/clippy/tests/ui/future_not_send.rs index 06090e2713d..9274340b5ca 100644 --- a/src/tools/clippy/tests/ui/future_not_send.rs +++ b/src/tools/clippy/tests/ui/future_not_send.rs @@ -59,6 +59,7 @@ where { let rt = &t; async { true }.await; + let _ = rt; t } diff --git a/src/tools/clippy/tests/ui/future_not_send.stderr b/src/tools/clippy/tests/ui/future_not_send.stderr index e417de723ff..f43e3c8ff9f 100644 --- a/src/tools/clippy/tests/ui/future_not_send.stderr +++ b/src/tools/clippy/tests/ui/future_not_send.stderr @@ -12,19 +12,12 @@ LL | async fn private_future(rc: Rc<[u8]>, cell: &Cell) -> bool { LL | LL | async { true }.await | ^^^^^ await occurs here, with `rc` maybe used later -LL | } - | - `rc` is later dropped here = note: `std::rc::Rc<[u8]>` doesn't implement `std::marker::Send` -note: future is not `Send` as this value is used across an await - --> $DIR/future_not_send.rs:9:20 +note: captured value is not `Send` because `&` references cannot be sent unless their referent is `Sync` + --> $DIR/future_not_send.rs:7:39 | LL | async fn private_future(rc: Rc<[u8]>, cell: &Cell) -> bool { - | ---- has type `&std::cell::Cell` which is not `Send` -LL | -LL | async { true }.await - | ^^^^^ await occurs here, with `cell` maybe used later -LL | } - | - `cell` is later dropped here + | ^^^^ has type `&std::cell::Cell` which is not `Send`, because `std::cell::Cell` is not `Sync` = note: `std::cell::Cell` doesn't implement `std::marker::Sync` = note: `-D clippy::future-not-send` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::future_not_send)]` @@ -43,8 +36,6 @@ LL | pub async fn public_future(rc: Rc<[u8]>) { LL | LL | async { true }.await; | ^^^^^ await occurs here, with `rc` maybe used later -LL | } - | - `rc` is later dropped here = note: `std::rc::Rc<[u8]>` doesn't implement `std::marker::Send` error: future cannot be sent between threads safely @@ -93,9 +84,6 @@ LL | async fn private_future(&self) -> usize { LL | LL | async { true }.await; | ^^^^^ await occurs here, with `&self` maybe used later -LL | self.rc.len() -LL | } - | - `&self` is later dropped here = note: `std::rc::Rc<[u8]>` doesn't implement `std::marker::Sync` error: future cannot be sent between threads safely @@ -104,16 +92,11 @@ error: future cannot be sent between threads safely LL | pub async fn public_future(&self) { | ^ future returned by `public_future` is not `Send` | -note: future is not `Send` as this value is used across an await - --> $DIR/future_not_send.rs:46:31 +note: captured value is not `Send` because `&` references cannot be sent unless their referent is `Sync` + --> $DIR/future_not_send.rs:44:32 | LL | pub async fn public_future(&self) { - | ----- has type `&Dummy` which is not `Send` -LL | -LL | self.private_future().await; - | ^^^^^ await occurs here, with `&self` maybe used later -LL | } - | - `&self` is later dropped here + | ^^^^^ has type `&Dummy` which is not `Send`, because `Dummy` is not `Sync` = note: `std::rc::Rc<[u8]>` doesn't implement `std::marker::Sync` error: future cannot be sent between threads safely @@ -129,19 +112,16 @@ LL | let rt = &t; | -- has type `&T` which is not `Send` LL | async { true }.await; | ^^^^^ await occurs here, with `rt` maybe used later -LL | t -LL | } - | - `rt` is later dropped here = note: `T` doesn't implement `std::marker::Sync` error: future cannot be sent between threads safely - --> $DIR/future_not_send.rs:72:34 + --> $DIR/future_not_send.rs:73:34 | LL | async fn unclear_future(t: T) {} | ^ future returned by `unclear_future` is not `Send` | note: captured value is not `Send` - --> $DIR/future_not_send.rs:72:28 + --> $DIR/future_not_send.rs:73:28 | LL | async fn unclear_future(t: T) {} | ^ has type `T` which is not `Send` From baa64b0e77007a31ce0cfaada5300b536f951d2f Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Wed, 7 Jun 2023 17:43:17 +0000 Subject: [PATCH 21/30] Remove dead error code. --- .../src/error_codes/E0698.md | 4 ++- compiler/rustc_infer/src/errors/mod.rs | 13 +------ .../infer/error_reporting/need_type_info.rs | 35 +------------------ 3 files changed, 5 insertions(+), 47 deletions(-) diff --git a/compiler/rustc_error_codes/src/error_codes/E0698.md b/compiler/rustc_error_codes/src/error_codes/E0698.md index 3ba992a8476..9bc652e642f 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0698.md +++ b/compiler/rustc_error_codes/src/error_codes/E0698.md @@ -1,9 +1,11 @@ +#### Note: this error code is no longer emitted by the compiler. + When using generators (or async) all type variables must be bound so a generator can be constructed. Erroneous code example: -```edition2018,compile_fail,E0698 +```edition2018,compile_fail,E0282 async fn bar() -> () {} async fn foo() { diff --git a/compiler/rustc_infer/src/errors/mod.rs b/compiler/rustc_infer/src/errors/mod.rs index 38910e45ecc..ad4525c922b 100644 --- a/compiler/rustc_infer/src/errors/mod.rs +++ b/compiler/rustc_infer/src/errors/mod.rs @@ -14,8 +14,7 @@ use rustc_span::{symbol::Ident, BytePos, Span}; use crate::fluent_generated as fluent; use crate::infer::error_reporting::{ - need_type_info::{GeneratorKindAsDiagArg, UnderspecifiedArgKind}, - nice_region_error::placeholder_error::Highlighted, + need_type_info::UnderspecifiedArgKind, nice_region_error::placeholder_error::Highlighted, ObligationCauseAsDiagArg, }; @@ -86,16 +85,6 @@ pub struct AmbiguousReturn<'a> { pub multi_suggestions: Vec>, } -#[derive(Diagnostic)] -#[diag(infer_need_type_info_in_generator, code = "E0698")] -pub struct NeedTypeInfoInGenerator<'a> { - #[primary_span] - pub span: Span, - pub generator_kind: GeneratorKindAsDiagArg, - #[subdiagnostic] - pub bad_label: InferenceBadError<'a>, -} - // Used when a better one isn't available #[derive(Subdiagnostic)] #[label(infer_label_bad)] diff --git a/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs b/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs index f2a3c47bdfe..bcaa4091c3a 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs @@ -1,5 +1,5 @@ use crate::errors::{ - AmbiguousImpl, AmbiguousReturn, AnnotationRequired, InferenceBadError, NeedTypeInfoInGenerator, + AmbiguousImpl, AmbiguousReturn, AnnotationRequired, InferenceBadError, SourceKindMultiSuggestion, SourceKindSubdiag, }; use crate::infer::error_reporting::TypeErrCtxt; @@ -595,39 +595,6 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { } } -impl<'tcx> InferCtxt<'tcx> { - pub fn need_type_info_err_in_generator( - &self, - kind: hir::GeneratorKind, - span: Span, - ty: ty::Term<'tcx>, - ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> { - let ty = self.resolve_vars_if_possible(ty); - let data = self.extract_inference_diagnostics_data(ty.into(), None); - - NeedTypeInfoInGenerator { - bad_label: data.make_bad_error(span), - span, - generator_kind: GeneratorKindAsDiagArg(kind), - } - .into_diagnostic(&self.tcx.sess.parse_sess.span_diagnostic) - } -} - -pub struct GeneratorKindAsDiagArg(pub hir::GeneratorKind); - -impl IntoDiagnosticArg for GeneratorKindAsDiagArg { - fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue<'static> { - let kind = match self.0 { - hir::GeneratorKind::Async(hir::AsyncGeneratorKind::Block) => "async_block", - hir::GeneratorKind::Async(hir::AsyncGeneratorKind::Closure) => "async_closure", - hir::GeneratorKind::Async(hir::AsyncGeneratorKind::Fn) => "async_fn", - hir::GeneratorKind::Gen => "generator", - }; - rustc_errors::DiagnosticArgValue::Str(kind.into()) - } -} - #[derive(Debug)] struct InferSource<'tcx> { span: Span, From 855a75b6d68084dd98383f37950da43c87476f0d Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Thu, 3 Aug 2023 13:25:26 +0000 Subject: [PATCH 22/30] Remove useless wrapper. --- compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs index e32f45b4224..229f3d59dfe 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs @@ -509,10 +509,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { typeck_results.rvalue_scopes = rvalue_scopes; } - pub(in super::super) fn resolve_generator_interiors(&self, def_id: DefId) { - self.save_generator_interior_predicates(def_id); - } - /// Unify the inference variables corresponding to generator witnesses, and save all the /// predicates that were stalled on those inference variables. /// @@ -522,7 +518,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// We must not attempt to select obligations after this method has run, or risk query cycle /// ICE. #[instrument(level = "debug", skip(self))] - fn save_generator_interior_predicates(&self, def_id: DefId) { + pub(in super::super) fn resolve_generator_interiors(&self, def_id: DefId) { // Try selecting all obligations that are not blocked on inference variables. // Once we start unifying generator witnesses, trying to select obligations on them will // trigger query cycle ICEs, as doing so requires MIR. From 44ac8dcc71c908aa320ccb51717ab2a0a8262b1d Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Thu, 3 Aug 2023 13:47:04 +0000 Subject: [PATCH 23/30] Remove GeneratorWitness and rename GeneratorWitnessMIR. --- .../src/debuginfo/type_names.rs | 1 - .../src/const_eval/valtrees.rs | 3 +- .../src/interpret/eval_context.rs | 1 - .../src/interpret/intrinsics.rs | 3 +- .../src/interpret/validity.rs | 1 - .../rustc_const_eval/src/util/type_name.rs | 3 +- .../src/coherence/inherent_impls.rs | 1 - .../src/coherence/orphan.rs | 1 - .../src/variance/constraints.rs | 6 +- compiler/rustc_hir_typeck/src/cast.rs | 1 - .../rustc_hir_typeck/src/fn_ctxt/_impl.rs | 2 +- .../src/infer/canonical/canonicalizer.rs | 1 - compiler/rustc_infer/src/infer/equate.rs | 20 ------ .../src/infer/outlives/components.rs | 2 +- compiler/rustc_infer/src/infer/sub.rs | 19 ------ compiler/rustc_lint/src/types.rs | 1 - compiler/rustc_middle/src/ty/context.rs | 1 - compiler/rustc_middle/src/ty/error.rs | 5 +- compiler/rustc_middle/src/ty/fast_reject.rs | 13 ++-- compiler/rustc_middle/src/ty/flags.rs | 6 +- compiler/rustc_middle/src/ty/layout.rs | 1 - compiler/rustc_middle/src/ty/opaque_types.rs | 4 +- compiler/rustc_middle/src/ty/print/mod.rs | 3 +- compiler/rustc_middle/src/ty/print/pretty.rs | 5 +- compiler/rustc_middle/src/ty/relate.rs | 14 +--- .../rustc_middle/src/ty/structural_impls.rs | 8 +-- compiler/rustc_middle/src/ty/sty.rs | 18 +---- compiler/rustc_middle/src/ty/util.rs | 22 ++----- compiler/rustc_middle/src/ty/walk.rs | 5 +- .../src/move_paths/builder.rs | 6 +- compiler/rustc_privacy/src/lib.rs | 3 +- compiler/rustc_smir/src/rustc_smir/mod.rs | 6 +- .../src/typeid/typeid_itanium_cxx_abi.rs | 2 - compiler/rustc_symbol_mangling/src/v0.rs | 3 +- .../src/solve/assembly/mod.rs | 8 +-- .../src/solve/assembly/structural_traits.rs | 12 +--- .../src/solve/canonicalize.rs | 3 +- .../src/solve/project_goals.rs | 2 - .../src/solve/trait_goals.rs | 3 +- .../src/traits/coherence.rs | 4 +- .../src/traits/error_reporting/mod.rs | 1 - .../src/traits/error_reporting/suggestions.rs | 21 +----- .../src/traits/project.rs | 2 - .../src/traits/query/dropck_outlives.rs | 4 +- .../src/traits/select/candidate_assembly.rs | 13 ++-- .../src/traits/select/confirmation.rs | 5 +- .../src/traits/select/mod.rs | 25 +------ .../src/traits/structural_match.rs | 2 +- .../rustc_trait_selection/src/traits/wf.rs | 1 - compiler/rustc_ty_utils/src/layout.rs | 6 +- compiler/rustc_ty_utils/src/needs_drop.rs | 1 - compiler/rustc_ty_utils/src/ty.rs | 8 +-- compiler/rustc_type_ir/src/sty.rs | 66 ++++--------------- src/librustdoc/clean/mod.rs | 1 - .../passes/collect_intra_doc_links.rs | 3 +- .../clippy/clippy_lints/src/dereference.rs | 1 - .../internal-lints/ty_tykind_usage.rs | 1 - .../internal-lints/ty_tykind_usage.stderr | 32 ++++----- tests/ui/symbol-names/basic.legacy.stderr | 4 +- .../ui/symbol-names/issue-60925.legacy.stderr | 4 +- 60 files changed, 91 insertions(+), 333 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs b/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs index a2190293c0b..989df448a31 100644 --- a/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs +++ b/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs @@ -426,7 +426,6 @@ fn push_debuginfo_type_name<'tcx>( | ty::Placeholder(..) | ty::Alias(..) | ty::Bound(..) - | ty::GeneratorWitnessMIR(..) | ty::GeneratorWitness(..) => { bug!( "debuginfo: Trying to create type name for \ diff --git a/compiler/rustc_const_eval/src/const_eval/valtrees.rs b/compiler/rustc_const_eval/src/const_eval/valtrees.rs index 2fba7455cb2..7436ea6ae57 100644 --- a/compiler/rustc_const_eval/src/const_eval/valtrees.rs +++ b/compiler/rustc_const_eval/src/const_eval/valtrees.rs @@ -152,7 +152,7 @@ pub(crate) fn const_to_valtree_inner<'tcx>( // FIXME(oli-obk): we can probably encode closures just like structs | ty::Closure(..) | ty::Generator(..) - | ty::GeneratorWitness(..) |ty::GeneratorWitnessMIR(..)=> Err(ValTreeCreationError::NonSupportedType), + | ty::GeneratorWitness(..) => Err(ValTreeCreationError::NonSupportedType), } } @@ -280,7 +280,6 @@ pub fn valtree_to_const_value<'tcx>( | ty::Closure(..) | ty::Generator(..) | ty::GeneratorWitness(..) - | ty::GeneratorWitnessMIR(..) | ty::FnPtr(_) | ty::RawPtr(_) | ty::Str diff --git a/compiler/rustc_const_eval/src/interpret/eval_context.rs b/compiler/rustc_const_eval/src/interpret/eval_context.rs index 83f2052d0f8..7c743a21d93 100644 --- a/compiler/rustc_const_eval/src/interpret/eval_context.rs +++ b/compiler/rustc_const_eval/src/interpret/eval_context.rs @@ -963,7 +963,6 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { | ty::Ref(..) | ty::Generator(..) | ty::GeneratorWitness(..) - | ty::GeneratorWitnessMIR(..) | ty::Array(..) | ty::Closure(..) | ty::Never diff --git a/compiler/rustc_const_eval/src/interpret/intrinsics.rs b/compiler/rustc_const_eval/src/interpret/intrinsics.rs index 2b26dbbba98..2c0ba9b2673 100644 --- a/compiler/rustc_const_eval/src/interpret/intrinsics.rs +++ b/compiler/rustc_const_eval/src/interpret/intrinsics.rs @@ -100,8 +100,7 @@ pub(crate) fn eval_nullary_intrinsic<'tcx>( | ty::Dynamic(_, _, _) | ty::Closure(_, _) | ty::Generator(_, _, _) - | ty::GeneratorWitness(_) - | ty::GeneratorWitnessMIR(_, _) + | ty::GeneratorWitness(..) | ty::Never | ty::Tuple(_) | ty::Error(_) => ConstValue::from_target_usize(0u64, &tcx), diff --git a/compiler/rustc_const_eval/src/interpret/validity.rs b/compiler/rustc_const_eval/src/interpret/validity.rs index 8e2b35fd5b6..3e023a89648 100644 --- a/compiler/rustc_const_eval/src/interpret/validity.rs +++ b/compiler/rustc_const_eval/src/interpret/validity.rs @@ -583,7 +583,6 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, ' | ty::Bound(..) | ty::Param(..) | ty::Alias(..) - | ty::GeneratorWitnessMIR(..) | ty::GeneratorWitness(..) => bug!("Encountered invalid type {:?}", ty), } } diff --git a/compiler/rustc_const_eval/src/util/type_name.rs b/compiler/rustc_const_eval/src/util/type_name.rs index 14a840ad1b1..a924afda6f0 100644 --- a/compiler/rustc_const_eval/src/util/type_name.rs +++ b/compiler/rustc_const_eval/src/util/type_name.rs @@ -64,8 +64,7 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> { ty::Alias(ty::Weak, _) => bug!("type_name: unexpected weak projection"), ty::Alias(ty::Inherent, _) => bug!("type_name: unexpected inherent projection"), - ty::GeneratorWitness(_) => bug!("type_name: unexpected `GeneratorWitness`"), - ty::GeneratorWitnessMIR(..) => bug!("type_name: unexpected `GeneratorWitnessMIR`"), + ty::GeneratorWitness(..) => bug!("type_name: unexpected `GeneratorWitness`"), } } diff --git a/compiler/rustc_hir_analysis/src/coherence/inherent_impls.rs b/compiler/rustc_hir_analysis/src/coherence/inherent_impls.rs index aa7c9e504c1..0042d683b19 100644 --- a/compiler/rustc_hir_analysis/src/coherence/inherent_impls.rs +++ b/compiler/rustc_hir_analysis/src/coherence/inherent_impls.rs @@ -157,7 +157,6 @@ impl<'tcx> InherentCollect<'tcx> { | ty::Closure(..) | ty::Generator(..) | ty::GeneratorWitness(..) - | ty::GeneratorWitnessMIR(..) | ty::Bound(..) | ty::Placeholder(_) | ty::Infer(_) => { diff --git a/compiler/rustc_hir_analysis/src/coherence/orphan.rs b/compiler/rustc_hir_analysis/src/coherence/orphan.rs index bbdb108c59b..69020b1f11d 100644 --- a/compiler/rustc_hir_analysis/src/coherence/orphan.rs +++ b/compiler/rustc_hir_analysis/src/coherence/orphan.rs @@ -245,7 +245,6 @@ fn do_orphan_check_impl<'tcx>( ty::Closure(..) | ty::Generator(..) | ty::GeneratorWitness(..) - | ty::GeneratorWitnessMIR(..) | ty::Bound(..) | ty::Placeholder(..) | ty::Infer(..) => { diff --git a/compiler/rustc_hir_analysis/src/variance/constraints.rs b/compiler/rustc_hir_analysis/src/variance/constraints.rs index 8a40509d7cc..9aac7160f2e 100644 --- a/compiler/rustc_hir_analysis/src/variance/constraints.rs +++ b/compiler/rustc_hir_analysis/src/variance/constraints.rs @@ -314,11 +314,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { // types, where we use Error as the Self type } - ty::Placeholder(..) - | ty::GeneratorWitness(..) - | ty::GeneratorWitnessMIR(..) - | ty::Bound(..) - | ty::Infer(..) => { + ty::Placeholder(..) | ty::GeneratorWitness(..) | ty::Bound(..) | ty::Infer(..) => { bug!("unexpected type encountered in variance inference: {}", ty); } } diff --git a/compiler/rustc_hir_typeck/src/cast.rs b/compiler/rustc_hir_typeck/src/cast.rs index 57cd88afcdc..2b1ac7f3537 100644 --- a/compiler/rustc_hir_typeck/src/cast.rs +++ b/compiler/rustc_hir_typeck/src/cast.rs @@ -129,7 +129,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { | ty::Float(_) | ty::Array(..) | ty::GeneratorWitness(..) - | ty::GeneratorWitnessMIR(..) | ty::RawPtr(_) | ty::Ref(..) | ty::FnDef(..) diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs index 229f3d59dfe..415920221f5 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs @@ -535,7 +535,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.tcx, self.tcx.typeck_root_def_id(expr_def_id.to_def_id()), ); - let witness = Ty::new_generator_witness_mir(self.tcx, expr_def_id.to_def_id(), args); + let witness = Ty::new_generator_witness(self.tcx, expr_def_id.to_def_id(), args); // Unify `interior` with `witness` and collect all the resulting obligations. let span = self.tcx.hir().body(body_id).value.span; diff --git a/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs b/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs index 99bd296d0d5..5978e2c743c 100644 --- a/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs +++ b/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs @@ -459,7 +459,6 @@ impl<'cx, 'tcx> TypeFolder> for Canonicalizer<'cx, 'tcx> { ty::Closure(..) | ty::Generator(..) | ty::GeneratorWitness(..) - | ty::GeneratorWitnessMIR(..) | ty::Bool | ty::Char | ty::Int(..) diff --git a/compiler/rustc_infer/src/infer/equate.rs b/compiler/rustc_infer/src/infer/equate.rs index 1dbab48fd6c..665297da20f 100644 --- a/compiler/rustc_infer/src/infer/equate.rs +++ b/compiler/rustc_infer/src/infer/equate.rs @@ -119,26 +119,6 @@ impl<'tcx> TypeRelation<'tcx> for Equate<'_, '_, 'tcx> { .obligations, ); } - // Optimization of GeneratorWitness relation since we know that all - // free regions are replaced with bound regions during construction. - // This greatly speeds up equating of GeneratorWitness. - (&ty::GeneratorWitness(a_types), &ty::GeneratorWitness(b_types)) => { - let a_types = infcx.tcx.anonymize_bound_vars(a_types); - let b_types = infcx.tcx.anonymize_bound_vars(b_types); - if a_types.bound_vars() == b_types.bound_vars() { - let (a_types, b_types) = infcx.instantiate_binder_with_placeholders( - a_types.map_bound(|a_types| (a_types, b_types.skip_binder())), - ); - for (a, b) in std::iter::zip(a_types, b_types) { - self.relate(a, b)?; - } - } else { - return Err(ty::error::TypeError::Sorts(ty::relate::expected_found( - self, a, b, - ))); - } - } - _ => { self.fields.infcx.super_combine_tys(self, a, b)?; } diff --git a/compiler/rustc_infer/src/infer/outlives/components.rs b/compiler/rustc_infer/src/infer/outlives/components.rs index 2ac9568f60b..6a9d40daab6 100644 --- a/compiler/rustc_infer/src/infer/outlives/components.rs +++ b/compiler/rustc_infer/src/infer/outlives/components.rs @@ -112,7 +112,7 @@ fn compute_components<'tcx>( } // All regions are bound inside a witness - ty::GeneratorWitness(..) | ty::GeneratorWitnessMIR(..) => (), + ty::GeneratorWitness(..) => (), // OutlivesTypeParameterEnv -- the actual checking that `X:'a` // is implied by the environment is done in regionck. diff --git a/compiler/rustc_infer/src/infer/sub.rs b/compiler/rustc_infer/src/infer/sub.rs index 27e1ed56f31..0c3bb633b53 100644 --- a/compiler/rustc_infer/src/infer/sub.rs +++ b/compiler/rustc_infer/src/infer/sub.rs @@ -147,25 +147,6 @@ impl<'tcx> TypeRelation<'tcx> for Sub<'_, '_, 'tcx> { ); Ok(a) } - // Optimization of GeneratorWitness relation since we know that all - // free regions are replaced with bound regions during construction. - // This greatly speeds up subtyping of GeneratorWitness. - (&ty::GeneratorWitness(a_types), &ty::GeneratorWitness(b_types)) => { - let a_types = infcx.tcx.anonymize_bound_vars(a_types); - let b_types = infcx.tcx.anonymize_bound_vars(b_types); - if a_types.bound_vars() == b_types.bound_vars() { - let (a_types, b_types) = infcx.instantiate_binder_with_placeholders( - a_types.map_bound(|a_types| (a_types, b_types.skip_binder())), - ); - for (a, b) in std::iter::zip(a_types, b_types) { - self.relate(a, b)?; - } - Ok(a) - } else { - Err(ty::error::TypeError::Sorts(ty::relate::expected_found(self, a, b))) - } - } - _ => { self.fields.infcx.super_combine_tys(self, a, b)?; Ok(a) diff --git a/compiler/rustc_lint/src/types.rs b/compiler/rustc_lint/src/types.rs index 57c2e289f20..44cf1591c7d 100644 --- a/compiler/rustc_lint/src/types.rs +++ b/compiler/rustc_lint/src/types.rs @@ -1271,7 +1271,6 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { | ty::Closure(..) | ty::Generator(..) | ty::GeneratorWitness(..) - | ty::GeneratorWitnessMIR(..) | ty::Placeholder(..) | ty::FnDef(..) => bug!("unexpected type in foreign function: {:?}", ty), } diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 25eafce0d9e..400d4bcad5b 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -1384,7 +1384,6 @@ impl<'tcx> TyCtxt<'tcx> { Placeholder, Generator, GeneratorWitness, - GeneratorWitnessMIR, Dynamic, Closure, Tuple, diff --git a/compiler/rustc_middle/src/ty/error.rs b/compiler/rustc_middle/src/ty/error.rs index f939d466078..459c8dfb596 100644 --- a/compiler/rustc_middle/src/ty/error.rs +++ b/compiler/rustc_middle/src/ty/error.rs @@ -242,8 +242,7 @@ impl<'tcx> Ty<'tcx> { ty::Dynamic(..) => "trait object".into(), ty::Closure(..) => "closure".into(), ty::Generator(def_id, ..) => tcx.generator_kind(def_id).unwrap().descr().into(), - ty::GeneratorWitness(..) | - ty::GeneratorWitnessMIR(..) => "generator witness".into(), + ty::GeneratorWitness(..) => "generator witness".into(), ty::Infer(ty::TyVar(_)) => "inferred type".into(), ty::Infer(ty::IntVar(_)) => "integer".into(), ty::Infer(ty::FloatVar(_)) => "floating-point number".into(), @@ -295,7 +294,7 @@ impl<'tcx> Ty<'tcx> { ty::Dynamic(..) => "trait object".into(), ty::Closure(..) => "closure".into(), ty::Generator(def_id, ..) => tcx.generator_kind(def_id).unwrap().descr().into(), - ty::GeneratorWitness(..) | ty::GeneratorWitnessMIR(..) => "generator witness".into(), + ty::GeneratorWitness(..) => "generator witness".into(), ty::Tuple(..) => "tuple".into(), ty::Placeholder(..) => "higher-ranked type".into(), ty::Bound(..) => "bound type variable".into(), diff --git a/compiler/rustc_middle/src/ty/fast_reject.rs b/compiler/rustc_middle/src/ty/fast_reject.rs index 668aa4521c1..16935d5b380 100644 --- a/compiler/rustc_middle/src/ty/fast_reject.rs +++ b/compiler/rustc_middle/src/ty/fast_reject.rs @@ -29,8 +29,7 @@ pub enum SimplifiedType { Trait(DefId), Closure(DefId), Generator(DefId), - GeneratorWitness(usize), - GeneratorWitnessMIR(DefId), + GeneratorWitness(DefId), Function(usize), Placeholder, } @@ -130,10 +129,7 @@ pub fn simplify_type<'tcx>( ty::Ref(_, _, mutbl) => Some(SimplifiedType::Ref(mutbl)), ty::FnDef(def_id, _) | ty::Closure(def_id, _) => Some(SimplifiedType::Closure(def_id)), ty::Generator(def_id, _, _) => Some(SimplifiedType::Generator(def_id)), - ty::GeneratorWitness(tys) => { - Some(SimplifiedType::GeneratorWitness(tys.skip_binder().len())) - } - ty::GeneratorWitnessMIR(def_id, _) => Some(SimplifiedType::GeneratorWitnessMIR(def_id)), + ty::GeneratorWitness(def_id, _) => Some(SimplifiedType::GeneratorWitness(def_id)), ty::Never => Some(SimplifiedType::Never), ty::Tuple(tys) => Some(SimplifiedType::Tuple(tys.len())), ty::FnPtr(f) => Some(SimplifiedType::Function(f.skip_binder().inputs().len())), @@ -169,7 +165,7 @@ impl SimplifiedType { | SimplifiedType::Trait(d) | SimplifiedType::Closure(d) | SimplifiedType::Generator(d) - | SimplifiedType::GeneratorWitnessMIR(d) => Some(d), + | SimplifiedType::GeneratorWitness(d) => Some(d), _ => None, } } @@ -240,7 +236,6 @@ impl DeepRejectCtxt { | ty::Closure(..) | ty::Generator(..) | ty::GeneratorWitness(..) - | ty::GeneratorWitnessMIR(..) | ty::Placeholder(..) | ty::Bound(..) | ty::Infer(_) => bug!("unexpected impl_ty: {impl_ty}"), @@ -342,7 +337,7 @@ impl DeepRejectCtxt { ty::Error(_) => true, - ty::GeneratorWitness(..) | ty::GeneratorWitnessMIR(..) => { + ty::GeneratorWitness(..) => { bug!("unexpected obligation type: {:?}", obligation_ty) } } diff --git a/compiler/rustc_middle/src/ty/flags.rs b/compiler/rustc_middle/src/ty/flags.rs index 231635c086e..7ed31fbbfd8 100644 --- a/compiler/rustc_middle/src/ty/flags.rs +++ b/compiler/rustc_middle/src/ty/flags.rs @@ -127,11 +127,7 @@ impl FlagComputation { self.add_ty(args.tupled_upvars_ty()); } - &ty::GeneratorWitness(ts) => { - self.bound_computation(ts, |flags, ts| flags.add_tys(ts)); - } - - ty::GeneratorWitnessMIR(_, args) => { + ty::GeneratorWitness(_, args) => { let should_remove_further_specializable = !self.flags.contains(TypeFlags::STILL_FURTHER_SPECIALIZABLE); self.add_args(args); diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index 8b425ce0267..bccf5e83987 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -810,7 +810,6 @@ where | ty::Never | ty::FnDef(..) | ty::GeneratorWitness(..) - | ty::GeneratorWitnessMIR(..) | ty::Foreign(..) | ty::Dynamic(_, _, ty::Dyn) => { bug!("TyAndLayout::field({:?}): not applicable", this) diff --git a/compiler/rustc_middle/src/ty/opaque_types.rs b/compiler/rustc_middle/src/ty/opaque_types.rs index 0ff5ac90304..6491936c219 100644 --- a/compiler/rustc_middle/src/ty/opaque_types.rs +++ b/compiler/rustc_middle/src/ty/opaque_types.rs @@ -157,9 +157,9 @@ impl<'tcx> TypeFolder> for ReverseMapper<'tcx> { Ty::new_generator(self.tcx, def_id, args, movability) } - ty::GeneratorWitnessMIR(def_id, args) => { + ty::GeneratorWitness(def_id, args) => { let args = self.fold_closure_args(def_id, args); - Ty::new_generator_witness_mir(self.tcx, def_id, args) + Ty::new_generator_witness(self.tcx, def_id, args) } ty::Param(param) => { diff --git a/compiler/rustc_middle/src/ty/print/mod.rs b/compiler/rustc_middle/src/ty/print/mod.rs index 05871d0bc39..aa8e2e30715 100644 --- a/compiler/rustc_middle/src/ty/print/mod.rs +++ b/compiler/rustc_middle/src/ty/print/mod.rs @@ -271,7 +271,7 @@ fn characteristic_def_id_of_type_cached<'a>( ty::FnDef(def_id, _) | ty::Closure(def_id, _) | ty::Generator(def_id, _, _) - | ty::GeneratorWitnessMIR(def_id, _) + | ty::GeneratorWitness(def_id, _) | ty::Foreign(def_id) => Some(def_id), ty::Bool @@ -286,7 +286,6 @@ fn characteristic_def_id_of_type_cached<'a>( | ty::Infer(_) | ty::Bound(..) | ty::Error(_) - | ty::GeneratorWitness(..) | ty::Never | ty::Float(_) => None, } diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index 5b833dde92c..34e3479c58e 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -838,10 +838,7 @@ pub trait PrettyPrinter<'tcx>: p!("}}") } - ty::GeneratorWitness(types) => { - p!(in_binder(&types)); - } - ty::GeneratorWitnessMIR(did, args) => { + ty::GeneratorWitness(did, args) => { p!(write("{{")); if !self.tcx().sess.verbose() { p!("generator witness"); diff --git a/compiler/rustc_middle/src/ty/relate.rs b/compiler/rustc_middle/src/ty/relate.rs index 47512d350e5..e9d763afa68 100644 --- a/compiler/rustc_middle/src/ty/relate.rs +++ b/compiler/rustc_middle/src/ty/relate.rs @@ -453,24 +453,14 @@ pub fn structurally_relate_tys<'tcx, R: TypeRelation<'tcx>>( Ok(Ty::new_generator(tcx, a_id, args, movability)) } - (&ty::GeneratorWitness(a_types), &ty::GeneratorWitness(b_types)) => { - // Wrap our types with a temporary GeneratorWitness struct - // inside the binder so we can related them - let a_types = a_types.map_bound(GeneratorWitness); - let b_types = b_types.map_bound(GeneratorWitness); - // Then remove the GeneratorWitness for the result - let types = relation.relate(a_types, b_types)?.map_bound(|witness| witness.0); - Ok(Ty::new_generator_witness(tcx, types)) - } - - (&ty::GeneratorWitnessMIR(a_id, a_args), &ty::GeneratorWitnessMIR(b_id, b_args)) + (&ty::GeneratorWitness(a_id, a_args), &ty::GeneratorWitness(b_id, b_args)) if a_id == b_id => { // All GeneratorWitness types with the same id represent // the (anonymous) type of the same generator expression. So // all of their regions should be equated. let args = relation.relate(a_args, b_args)?; - Ok(Ty::new_generator_witness_mir(tcx, a_id, args)) + Ok(Ty::new_generator_witness(tcx, a_id, args)) } (&ty::Closure(a_id, a_args), &ty::Closure(b_id, b_args)) if a_id == b_id => { diff --git a/compiler/rustc_middle/src/ty/structural_impls.rs b/compiler/rustc_middle/src/ty/structural_impls.rs index b66c0f20990..f6372ef3f2f 100644 --- a/compiler/rustc_middle/src/ty/structural_impls.rs +++ b/compiler/rustc_middle/src/ty/structural_impls.rs @@ -657,9 +657,8 @@ impl<'tcx> TypeSuperFoldable> for Ty<'tcx> { ty::Generator(did, args, movability) => { ty::Generator(did, args.try_fold_with(folder)?, movability) } - ty::GeneratorWitness(types) => ty::GeneratorWitness(types.try_fold_with(folder)?), - ty::GeneratorWitnessMIR(did, args) => { - ty::GeneratorWitnessMIR(did, args.try_fold_with(folder)?) + ty::GeneratorWitness(did, args) => { + ty::GeneratorWitness(did, args.try_fold_with(folder)?) } ty::Closure(did, args) => ty::Closure(did, args.try_fold_with(folder)?), ty::Alias(kind, data) => ty::Alias(kind, data.try_fold_with(folder)?), @@ -708,8 +707,7 @@ impl<'tcx> TypeSuperVisitable> for Ty<'tcx> { ty.visit_with(visitor) } ty::Generator(_did, ref args, _) => args.visit_with(visitor), - ty::GeneratorWitness(ref types) => types.visit_with(visitor), - ty::GeneratorWitnessMIR(_did, ref args) => args.visit_with(visitor), + ty::GeneratorWitness(_did, ref args) => args.visit_with(visitor), ty::Closure(_did, ref args) => args.visit_with(visitor), ty::Alias(_, ref data) => data.visit_with(visitor), diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index f0526a23714..d2c42235adb 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -2164,19 +2164,11 @@ impl<'tcx> Ty<'tcx> { #[inline] pub fn new_generator_witness( - tcx: TyCtxt<'tcx>, - types: ty::Binder<'tcx, &'tcx List>>, - ) -> Ty<'tcx> { - Ty::new(tcx, GeneratorWitness(types)) - } - - #[inline] - pub fn new_generator_witness_mir( tcx: TyCtxt<'tcx>, id: DefId, args: GenericArgsRef<'tcx>, ) -> Ty<'tcx> { - Ty::new(tcx, GeneratorWitnessMIR(id, args)) + Ty::new(tcx, GeneratorWitness(id, args)) } // misc @@ -2706,7 +2698,6 @@ impl<'tcx> Ty<'tcx> { | ty::Dynamic(..) | ty::Closure(..) | ty::GeneratorWitness(..) - | ty::GeneratorWitnessMIR(..) | ty::Never | ty::Tuple(_) | ty::Error(_) @@ -2742,7 +2733,6 @@ impl<'tcx> Ty<'tcx> { | ty::Ref(..) | ty::Generator(..) | ty::GeneratorWitness(..) - | ty::GeneratorWitnessMIR(..) | ty::Array(..) | ty::Closure(..) | ty::Never @@ -2831,7 +2821,6 @@ impl<'tcx> Ty<'tcx> { | ty::Ref(..) | ty::Generator(..) | ty::GeneratorWitness(..) - | ty::GeneratorWitnessMIR(..) | ty::Array(..) | ty::Closure(..) | ty::Never @@ -2894,7 +2883,7 @@ impl<'tcx> Ty<'tcx> { // anything with custom metadata it might be more complicated. ty::Ref(_, _, hir::Mutability::Not) | ty::RawPtr(..) => false, - ty::Generator(..) | ty::GeneratorWitness(..) | ty::GeneratorWitnessMIR(..) => false, + ty::Generator(..) | ty::GeneratorWitness(..) => false, // Might be, but not "trivial" so just giving the safe answer. ty::Adt(..) | ty::Closure(..) => false, @@ -2970,8 +2959,7 @@ impl<'tcx> Ty<'tcx> { | Dynamic(_, _, _) | Closure(_, _) | Generator(_, _, _) - | GeneratorWitness(_) - | GeneratorWitnessMIR(_, _) + | GeneratorWitness(..) | Never | Tuple(_) => true, Error(_) | Infer(_) | Alias(_, _) | Param(_) | Bound(_, _) | Placeholder(_) => false, diff --git a/compiler/rustc_middle/src/ty/util.rs b/compiler/rustc_middle/src/ty/util.rs index 564f982f842..0dda7cd83be 100644 --- a/compiler/rustc_middle/src/ty/util.rs +++ b/compiler/rustc_middle/src/ty/util.rs @@ -855,7 +855,7 @@ impl<'tcx> OpaqueTypeExpander<'tcx> { let hidden_ty = bty.instantiate(self.tcx, args); self.fold_ty(hidden_ty); } - let expanded_ty = Ty::new_generator_witness_mir(self.tcx, def_id, args); + let expanded_ty = Ty::new_generator_witness(self.tcx, def_id, args); self.expanded_cache.insert((def_id, args), expanded_ty); expanded_ty } @@ -888,7 +888,7 @@ impl<'tcx> TypeFolder> for OpaqueTypeExpander<'tcx> { t }; if self.expand_generators { - if let ty::GeneratorWitnessMIR(def_id, args) = *t.kind() { + if let ty::GeneratorWitness(def_id, args) = *t.kind() { t = self.expand_generator(def_id, args).unwrap_or(t); } } @@ -1025,8 +1025,7 @@ impl<'tcx> Ty<'tcx> { | ty::Dynamic(..) | ty::Foreign(_) | ty::Generator(..) - | ty::GeneratorWitness(_) - | ty::GeneratorWitnessMIR(..) + | ty::GeneratorWitness(..) | ty::Infer(_) | ty::Alias(..) | ty::Param(_) @@ -1065,8 +1064,7 @@ impl<'tcx> Ty<'tcx> { | ty::Dynamic(..) | ty::Foreign(_) | ty::Generator(..) - | ty::GeneratorWitness(_) - | ty::GeneratorWitnessMIR(..) + | ty::GeneratorWitness(..) | ty::Infer(_) | ty::Alias(..) | ty::Param(_) @@ -1194,10 +1192,7 @@ impl<'tcx> Ty<'tcx> { false } - ty::Foreign(_) - | ty::GeneratorWitness(..) - | ty::GeneratorWitnessMIR(..) - | ty::Error(_) => false, + ty::Foreign(_) | ty::GeneratorWitness(..) | ty::Error(_) => false, } } @@ -1293,7 +1288,6 @@ pub fn needs_drop_components<'tcx>( | ty::FnPtr(_) | ty::Char | ty::GeneratorWitness(..) - | ty::GeneratorWitnessMIR(..) | ty::RawPtr(_) | ty::Ref(..) | ty::Str => Ok(SmallVec::new()), @@ -1364,11 +1358,7 @@ pub fn is_trivially_const_drop(ty: Ty<'_>) -> bool { // Not trivial because they have components, and instead of looking inside, // we'll just perform trait selection. - ty::Closure(..) - | ty::Generator(..) - | ty::GeneratorWitness(_) - | ty::GeneratorWitnessMIR(..) - | ty::Adt(..) => false, + ty::Closure(..) | ty::Generator(..) | ty::GeneratorWitness(..) | ty::Adt(..) => false, ty::Array(ty, _) | ty::Slice(ty) => is_trivially_const_drop(ty), diff --git a/compiler/rustc_middle/src/ty/walk.rs b/compiler/rustc_middle/src/ty/walk.rs index 7c3d9ed390a..a86ff64bd0c 100644 --- a/compiler/rustc_middle/src/ty/walk.rs +++ b/compiler/rustc_middle/src/ty/walk.rs @@ -190,14 +190,11 @@ fn push_inner<'tcx>(stack: &mut TypeWalkerStack<'tcx>, parent: GenericArg<'tcx>) ty::Adt(_, args) | ty::Closure(_, args) | ty::Generator(_, args, _) - | ty::GeneratorWitnessMIR(_, args) + | ty::GeneratorWitness(_, args) | ty::FnDef(_, args) => { stack.extend(args.iter().rev()); } ty::Tuple(ts) => stack.extend(ts.iter().rev().map(GenericArg::from)), - ty::GeneratorWitness(ts) => { - stack.extend(ts.skip_binder().iter().rev().map(|ty| ty.into())); - } ty::FnPtr(sig) => { stack.push(sig.skip_binder().output().into()); stack.extend(sig.skip_binder().inputs().iter().copied().rev().map(|ty| ty.into())); diff --git a/compiler/rustc_mir_dataflow/src/move_paths/builder.rs b/compiler/rustc_mir_dataflow/src/move_paths/builder.rs index 213b81eaac9..9ced3a7f3cd 100644 --- a/compiler/rustc_mir_dataflow/src/move_paths/builder.rs +++ b/compiler/rustc_mir_dataflow/src/move_paths/builder.rs @@ -144,8 +144,7 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> { | ty::Dynamic(_, _, _) | ty::Closure(_, _) | ty::Generator(_, _, _) - | ty::GeneratorWitness(_) - | ty::GeneratorWitnessMIR(_, _) + | ty::GeneratorWitness(..) | ty::Never | ty::Tuple(_) | ty::Alias(_, _) @@ -184,8 +183,7 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> { | ty::FnDef(_, _) | ty::FnPtr(_) | ty::Dynamic(_, _, _) - | ty::GeneratorWitness(_) - | ty::GeneratorWitnessMIR(_, _) + | ty::GeneratorWitness(..) | ty::Never | ty::Alias(_, _) | ty::Param(_) diff --git a/compiler/rustc_privacy/src/lib.rs b/compiler/rustc_privacy/src/lib.rs index 1c2303ae9e0..2e71ac8d7dc 100644 --- a/compiler/rustc_privacy/src/lib.rs +++ b/compiler/rustc_privacy/src/lib.rs @@ -291,8 +291,7 @@ where | ty::Param(..) | ty::Bound(..) | ty::Error(_) - | ty::GeneratorWitness(..) - | ty::GeneratorWitnessMIR(..) => {} + | ty::GeneratorWitness(..) => {} ty::Placeholder(..) | ty::Infer(..) => { bug!("unexpected type: {:?}", ty) } diff --git a/compiler/rustc_smir/src/rustc_smir/mod.rs b/compiler/rustc_smir/src/rustc_smir/mod.rs index ad5f17cab6c..07aeac6b539 100644 --- a/compiler/rustc_smir/src/rustc_smir/mod.rs +++ b/compiler/rustc_smir/src/rustc_smir/mod.rs @@ -1128,11 +1128,7 @@ impl<'tcx> Stable<'tcx> for Ty<'tcx> { ty::Bound(debruijn_idx, bound_ty) => { TyKind::Bound(debruijn_idx.as_usize(), bound_ty.stable(tables)) } - ty::Placeholder(..) - | ty::GeneratorWitness(_) - | ty::GeneratorWitnessMIR(_, _) - | ty::Infer(_) - | ty::Error(_) => { + ty::Placeholder(..) | ty::GeneratorWitness(..) | ty::Infer(_) | ty::Error(_) => { unreachable!(); } } diff --git a/compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs b/compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs index 3d9b8539ee2..6ad3e7155e8 100644 --- a/compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs +++ b/compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs @@ -720,7 +720,6 @@ fn encode_ty<'tcx>( | ty::Bound(..) | ty::Error(..) | ty::GeneratorWitness(..) - | ty::GeneratorWitnessMIR(..) | ty::Infer(..) | ty::Placeholder(..) => { bug!("encode_ty: unexpected `{:?}`", ty.kind()); @@ -779,7 +778,6 @@ fn transform_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, options: TransformTyOptio | ty::Str | ty::Never | ty::Foreign(..) - | ty::GeneratorWitnessMIR(..) | ty::GeneratorWitness(..) => {} ty::Bool => { diff --git a/compiler/rustc_symbol_mangling/src/v0.rs b/compiler/rustc_symbol_mangling/src/v0.rs index e9a7d0be4b4..ec94deb4658 100644 --- a/compiler/rustc_symbol_mangling/src/v0.rs +++ b/compiler/rustc_symbol_mangling/src/v0.rs @@ -484,8 +484,7 @@ impl<'tcx> Printer<'tcx> for &mut SymbolMangler<'tcx> { ty::Alias(ty::Inherent, _) => bug!("symbol_names: unexpected inherent projection"), ty::Alias(ty::Weak, _) => bug!("symbol_names: unexpected weak projection"), - ty::GeneratorWitness(_) => bug!("symbol_names: unexpected `GeneratorWitness`"), - ty::GeneratorWitnessMIR(..) => bug!("symbol_names: unexpected `GeneratorWitnessMIR`"), + ty::GeneratorWitness(..) => bug!("symbol_names: unexpected `GeneratorWitness`"), } // Only cache types that do not refer to an enclosing diff --git a/compiler/rustc_trait_selection/src/solve/assembly/mod.rs b/compiler/rustc_trait_selection/src/solve/assembly/mod.rs index 128b9ad7e47..23d2c0c4ea0 100644 --- a/compiler/rustc_trait_selection/src/solve/assembly/mod.rs +++ b/compiler/rustc_trait_selection/src/solve/assembly/mod.rs @@ -469,7 +469,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> { // FIXME: These should ideally not exist as a self type. It would be nice for // the builtin auto trait impls of generators to instead directly recurse // into the witness. - ty::GeneratorWitness(_) | ty::GeneratorWitnessMIR(_, _) => (), + ty::GeneratorWitness(..) => (), // These variants should not exist as a self type. ty::Infer(ty::TyVar(_) | ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) @@ -621,8 +621,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> { | ty::Dynamic(..) | ty::Closure(..) | ty::Generator(..) - | ty::GeneratorWitness(_) - | ty::GeneratorWitnessMIR(..) + | ty::GeneratorWitness(..) | ty::Never | ty::Tuple(_) | ty::Param(_) @@ -778,8 +777,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> { | ty::Alias(..) | ty::Closure(..) | ty::Generator(..) - | ty::GeneratorWitness(_) - | ty::GeneratorWitnessMIR(..) + | ty::GeneratorWitness(..) | ty::Never | ty::Tuple(_) | ty::Param(_) diff --git a/compiler/rustc_trait_selection/src/solve/assembly/structural_traits.rs b/compiler/rustc_trait_selection/src/solve/assembly/structural_traits.rs index b61e02ba761..5935c614ffd 100644 --- a/compiler/rustc_trait_selection/src/solve/assembly/structural_traits.rs +++ b/compiler/rustc_trait_selection/src/solve/assembly/structural_traits.rs @@ -61,9 +61,7 @@ pub(in crate::solve) fn instantiate_constituent_tys_for_auto_trait<'tcx>( Ok(vec![generator_args.tupled_upvars_ty(), generator_args.witness()]) } - ty::GeneratorWitness(types) => Ok(ecx.instantiate_binder_with_placeholders(types).to_vec()), - - ty::GeneratorWitnessMIR(def_id, args) => Ok(ecx + ty::GeneratorWitness(def_id, args) => Ok(ecx .tcx() .generator_hidden_types(def_id) .map(|bty| { @@ -127,7 +125,6 @@ pub(in crate::solve) fn instantiate_constituent_tys_for_sized_trait<'tcx>( | ty::Ref(..) | ty::Generator(..) | ty::GeneratorWitness(..) - | ty::GeneratorWitnessMIR(..) | ty::Array(..) | ty::Closure(..) | ty::Never @@ -204,9 +201,7 @@ pub(in crate::solve) fn instantiate_constituent_tys_for_copy_clone_trait<'tcx>( } } - ty::GeneratorWitness(types) => Ok(ecx.instantiate_binder_with_placeholders(types).to_vec()), - - ty::GeneratorWitnessMIR(def_id, args) => Ok(ecx + ty::GeneratorWitness(def_id, args) => Ok(ecx .tcx() .generator_hidden_types(def_id) .map(|bty| { @@ -282,8 +277,7 @@ pub(in crate::solve) fn extract_tupled_inputs_and_output_from_callable<'tcx>( | ty::Ref(_, _, _) | ty::Dynamic(_, _, _) | ty::Generator(_, _, _) - | ty::GeneratorWitness(_) - | ty::GeneratorWitnessMIR(..) + | ty::GeneratorWitness(..) | ty::Never | ty::Tuple(_) | ty::Alias(_, _) diff --git a/compiler/rustc_trait_selection/src/solve/canonicalize.rs b/compiler/rustc_trait_selection/src/solve/canonicalize.rs index f5901057a9d..64b1321e51d 100644 --- a/compiler/rustc_trait_selection/src/solve/canonicalize.rs +++ b/compiler/rustc_trait_selection/src/solve/canonicalize.rs @@ -330,8 +330,7 @@ impl<'tcx> TypeFolder> for Canonicalizer<'_, 'tcx> { | ty::Dynamic(_, _, _) | ty::Closure(_, _) | ty::Generator(_, _, _) - | ty::GeneratorWitness(_) - | ty::GeneratorWitnessMIR(..) + | ty::GeneratorWitness(..) | ty::Never | ty::Tuple(_) | ty::Alias(_, _) diff --git a/compiler/rustc_trait_selection/src/solve/project_goals.rs b/compiler/rustc_trait_selection/src/solve/project_goals.rs index f6e781b87ba..c579da61e38 100644 --- a/compiler/rustc_trait_selection/src/solve/project_goals.rs +++ b/compiler/rustc_trait_selection/src/solve/project_goals.rs @@ -388,7 +388,6 @@ impl<'tcx> assembly::GoalKind<'tcx> for ProjectionPredicate<'tcx> { | ty::Infer(ty::IntVar(..) | ty::FloatVar(..)) | ty::Generator(..) | ty::GeneratorWitness(..) - | ty::GeneratorWitnessMIR(..) | ty::Never | ty::Foreign(..) => tcx.types.unit, @@ -556,7 +555,6 @@ impl<'tcx> assembly::GoalKind<'tcx> for ProjectionPredicate<'tcx> { | ty::Infer(ty::IntVar(..) | ty::FloatVar(..)) | ty::Generator(..) | ty::GeneratorWitness(..) - | ty::GeneratorWitnessMIR(..) | ty::Never | ty::Foreign(..) | ty::Adt(_, _) diff --git a/compiler/rustc_trait_selection/src/solve/trait_goals.rs b/compiler/rustc_trait_selection/src/solve/trait_goals.rs index f18eed94a68..8055c63b9f3 100644 --- a/compiler/rustc_trait_selection/src/solve/trait_goals.rs +++ b/compiler/rustc_trait_selection/src/solve/trait_goals.rs @@ -879,8 +879,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> { | ty::FnPtr(_) | ty::Closure(_, _) | ty::Generator(_, _, _) - | ty::GeneratorWitness(_) - | ty::GeneratorWitnessMIR(_, _) + | ty::GeneratorWitness(..) | ty::Never | ty::Tuple(_) | ty::Adt(_, _) diff --git a/compiler/rustc_trait_selection/src/traits/coherence.rs b/compiler/rustc_trait_selection/src/traits/coherence.rs index 59f712721fb..acab4498a09 100644 --- a/compiler/rustc_trait_selection/src/traits/coherence.rs +++ b/compiler/rustc_trait_selection/src/traits/coherence.rs @@ -827,9 +827,7 @@ where // This should only be created when checking whether we have to check whether some // auto trait impl applies. There will never be multiple impls, so we can just // act as if it were a local type here. - ty::GeneratorWitness(_) | ty::GeneratorWitnessMIR(..) => { - ControlFlow::Break(OrphanCheckEarlyExit::LocalTy(ty)) - } + ty::GeneratorWitness(..) => ControlFlow::Break(OrphanCheckEarlyExit::LocalTy(ty)), ty::Alias(ty::Opaque, ..) => { // This merits some explanation. // Normally, opaque types are not involved when performing diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs index d3e0d3b8b18..2a333a4f0e3 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs @@ -1847,7 +1847,6 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> { ty::Generator(..) => Some(18), ty::Foreign(..) => Some(19), ty::GeneratorWitness(..) => Some(20), - ty::GeneratorWitnessMIR(..) => Some(21), ty::Placeholder(..) | ty::Bound(..) | ty::Infer(..) | ty::Error(_) => None, } } diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index 428267a923e..748ecdc01b4 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -2173,11 +2173,10 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { ); match *ty.kind() { - ty::Generator(did, ..) | ty::GeneratorWitnessMIR(did, _) => { + ty::Generator(did, ..) | ty::GeneratorWitness(did, _) => { generator = generator.or(Some(did)); outer_generator = Some(did); } - ty::GeneratorWitness(..) => {} ty::Tuple(_) if !seen_upvar_tys_infer_tuple => { // By introducing a tuple of upvar types into the chain of obligations // of a generator, the first non-generator item is now the tuple itself, @@ -2203,11 +2202,10 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { ); match *ty.kind() { - ty::Generator(did, ..) | ty::GeneratorWitnessMIR(did, ..) => { + ty::Generator(did, ..) | ty::GeneratorWitness(did, ..) => { generator = generator.or(Some(did)); outer_generator = Some(did); } - ty::GeneratorWitness(..) => {} ty::Tuple(_) if !seen_upvar_tys_infer_tuple => { // By introducing a tuple of upvar types into the chain of obligations // of a generator, the first non-generator item is now the tuple itself, @@ -2987,20 +2985,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { } err.span_note(self.tcx.def_span(def_id), msg) } - ty::GeneratorWitness(bound_tys) => { - use std::fmt::Write; - - // FIXME: this is kind of an unusual format for rustc, can we make it more clear? - // Maybe we should just remove this note altogether? - // FIXME: only print types which don't meet the trait requirement - let mut msg = - "required because it captures the following types: ".to_owned(); - for ty in bound_tys.skip_binder() { - with_forced_trimmed_paths!(write!(msg, "`{ty}`, ").unwrap()); - } - err.note(msg.trim_end_matches(", ").to_string()) - } - ty::GeneratorWitnessMIR(def_id, args) => { + ty::GeneratorWitness(def_id, args) => { use std::fmt::Write; // FIXME: this is kind of an unusual format for rustc, can we make it more clear? diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs index 93e8e1f4bb1..154cc7a7141 100644 --- a/compiler/rustc_trait_selection/src/traits/project.rs +++ b/compiler/rustc_trait_selection/src/traits/project.rs @@ -1813,7 +1813,6 @@ fn assemble_candidates_from_impls<'cx, 'tcx>( | ty::Closure(..) | ty::Generator(..) | ty::GeneratorWitness(..) - | ty::GeneratorWitnessMIR(..) | ty::Never | ty::Tuple(..) // Integers and floats always have `u8` as their discriminant. @@ -1863,7 +1862,6 @@ fn assemble_candidates_from_impls<'cx, 'tcx>( | ty::Closure(..) | ty::Generator(..) | ty::GeneratorWitness(..) - | ty::GeneratorWitnessMIR(..) | ty::Never // Extern types have unit metadata, according to RFC 2850 | ty::Foreign(_) diff --git a/compiler/rustc_trait_selection/src/traits/query/dropck_outlives.rs b/compiler/rustc_trait_selection/src/traits/query/dropck_outlives.rs index 9484a50e3a9..86ea7a2bf83 100644 --- a/compiler/rustc_trait_selection/src/traits/query/dropck_outlives.rs +++ b/compiler/rustc_trait_selection/src/traits/query/dropck_outlives.rs @@ -36,7 +36,6 @@ pub fn trivial_dropck_outlives<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool { | ty::FnPtr(_) | ty::Char | ty::GeneratorWitness(..) - | ty::GeneratorWitnessMIR(..) | ty::RawPtr(_) | ty::Ref(..) | ty::Str @@ -218,8 +217,7 @@ pub fn dtorck_constraint_for_ty_inner<'tcx>( | ty::Ref(..) | ty::FnDef(..) | ty::FnPtr(_) - | ty::GeneratorWitness(..) - | ty::GeneratorWitnessMIR(..) => { + | ty::GeneratorWitness(..) => { // these types never have a destructor } 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 e3da87a2210..bead8758ad6 100644 --- a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs +++ b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs @@ -436,8 +436,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { | ty::Ref(_, _, _) | ty::Closure(_, _) | ty::Generator(_, _, _) - | ty::GeneratorWitness(_) - | ty::GeneratorWitnessMIR(_, _) + | ty::GeneratorWitness(..) | ty::Never | ty::Tuple(_) | ty::Error(_) => return true, @@ -569,8 +568,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { | ty::Generator(..) | ty::Never | ty::Tuple(_) - | ty::GeneratorWitness(_) - | ty::GeneratorWitnessMIR(..) => { + | ty::GeneratorWitness(..) => { // Only consider auto impls if there are no manual impls for the root of `self_ty`. // // For example, we only consider auto candidates for `&i32: Auto` if no explicit impl @@ -946,8 +944,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { | ty::Closure(..) | ty::Generator(..) | ty::Tuple(_) - | ty::GeneratorWitness(_) - | ty::GeneratorWitnessMIR(..) => { + | ty::GeneratorWitness(..) => { // These are built-in, and cannot have a custom `impl const Destruct`. candidates.vec.push(ConstDestructCandidate(None)); } @@ -1020,8 +1017,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { | ty::Dynamic(_, _, _) | ty::Closure(_, _) | ty::Generator(_, _, _) - | ty::GeneratorWitness(_) - | ty::GeneratorWitnessMIR(..) + | ty::GeneratorWitness(..) | ty::Never | ty::Alias(..) | ty::Param(_) @@ -1083,7 +1079,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { | ty::Closure(..) | ty::Generator(..) | ty::GeneratorWitness(..) - | ty::GeneratorWitnessMIR(..) | ty::Never | ty::Tuple(..) | ty::Alias(..) diff --git a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs index eadac70057c..08ee9c73bf8 100644 --- a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs +++ b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs @@ -1238,10 +1238,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { let generator = args.as_generator(); stack.extend([generator.tupled_upvars_ty(), generator.witness()]); } - ty::GeneratorWitness(tys) => { - stack.extend(tcx.erase_late_bound_regions(tys).to_vec()); - } - ty::GeneratorWitnessMIR(def_id, args) => { + ty::GeneratorWitness(def_id, args) => { let tcx = self.tcx(); stack.extend(tcx.generator_hidden_types(def_id).map(|bty| { let ty = bty.instantiate(tcx, args); diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs index d4ca0c8a5c5..7d672e658c7 100644 --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs @@ -2131,7 +2131,6 @@ impl<'tcx> SelectionContext<'_, 'tcx> { | ty::Ref(..) | ty::Generator(..) | ty::GeneratorWitness(..) - | ty::GeneratorWitnessMIR(..) | ty::Array(..) | ty::Closure(..) | ty::Never @@ -2230,22 +2229,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> { } } - ty::GeneratorWitness(binder) => { - let witness_tys = binder.skip_binder(); - for witness_ty in witness_tys.iter() { - let resolved = self.infcx.shallow_resolve(witness_ty); - if resolved.is_ty_var() { - return Ambiguous; - } - } - // (*) binder moved here - let all_vars = self.tcx().mk_bound_variable_kinds_from_iter( - obligation.predicate.bound_vars().iter().chain(binder.bound_vars().iter()), - ); - Where(ty::Binder::bind_with_vars(witness_tys.to_vec(), all_vars)) - } - - ty::GeneratorWitnessMIR(def_id, ref args) => { + ty::GeneratorWitness(def_id, ref args) => { let hidden_types = bind_generator_hidden_types_above( self.infcx, def_id, @@ -2350,12 +2334,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> { t.rebind([ty].into_iter().chain(iter::once(witness)).collect()) } - ty::GeneratorWitness(types) => { - debug_assert!(!types.has_escaping_bound_vars()); - types.map_bound(|types| types.to_vec()) - } - - ty::GeneratorWitnessMIR(def_id, ref args) => { + ty::GeneratorWitness(def_id, ref args) => { bind_generator_hidden_types_above(self.infcx, def_id, args, t.bound_vars()) } diff --git a/compiler/rustc_trait_selection/src/traits/structural_match.rs b/compiler/rustc_trait_selection/src/traits/structural_match.rs index 0864e4dc841..fc9b424369a 100644 --- a/compiler/rustc_trait_selection/src/traits/structural_match.rs +++ b/compiler/rustc_trait_selection/src/traits/structural_match.rs @@ -79,7 +79,7 @@ impl<'tcx> TypeVisitor> for Search<'tcx> { ty::Closure(..) => { return ControlFlow::Break(ty); } - ty::Generator(..) | ty::GeneratorWitness(..) | ty::GeneratorWitnessMIR(..) => { + ty::Generator(..) | ty::GeneratorWitness(..) => { return ControlFlow::Break(ty); } ty::FnDef(..) => { diff --git a/compiler/rustc_trait_selection/src/traits/wf.rs b/compiler/rustc_trait_selection/src/traits/wf.rs index f26310665f9..b04008d9ee5 100644 --- a/compiler/rustc_trait_selection/src/traits/wf.rs +++ b/compiler/rustc_trait_selection/src/traits/wf.rs @@ -609,7 +609,6 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> { | ty::Error(_) | ty::Str | ty::GeneratorWitness(..) - | ty::GeneratorWitnessMIR(..) | ty::Never | ty::Param(_) | ty::Bound(..) diff --git a/compiler/rustc_ty_utils/src/layout.rs b/compiler/rustc_ty_utils/src/layout.rs index a03b82305f0..5bd68d7ccaa 100644 --- a/compiler/rustc_ty_utils/src/layout.rs +++ b/compiler/rustc_ty_utils/src/layout.rs @@ -577,11 +577,7 @@ fn layout_of_uncached<'tcx>( return Err(error(cx, LayoutError::Unknown(ty))); } - ty::Bound(..) - | ty::GeneratorWitness(..) - | ty::GeneratorWitnessMIR(..) - | ty::Infer(_) - | ty::Error(_) => { + ty::Bound(..) | ty::GeneratorWitness(..) | ty::Infer(_) | ty::Error(_) => { bug!("Layout::compute: unexpected type `{}`", ty) } diff --git a/compiler/rustc_ty_utils/src/needs_drop.rs b/compiler/rustc_ty_utils/src/needs_drop.rs index 76d381dd19f..6dcbc4470e6 100644 --- a/compiler/rustc_ty_utils/src/needs_drop.rs +++ b/compiler/rustc_ty_utils/src/needs_drop.rs @@ -192,7 +192,6 @@ where | ty::Tuple(_) | ty::Bound(..) | ty::GeneratorWitness(..) - | ty::GeneratorWitnessMIR(..) | ty::Never | ty::Infer(_) | ty::Error(_) => { diff --git a/compiler/rustc_ty_utils/src/ty.rs b/compiler/rustc_ty_utils/src/ty.rs index 6c23589b39a..4234e69e854 100644 --- a/compiler/rustc_ty_utils/src/ty.rs +++ b/compiler/rustc_ty_utils/src/ty.rs @@ -21,13 +21,7 @@ fn sized_constraint_for_ty<'tcx>( Bool | Char | Int(..) | Uint(..) | Float(..) | RawPtr(..) | Ref(..) | FnDef(..) | FnPtr(_) | Array(..) | Closure(..) | Generator(..) | Never => vec![], - Str - | Dynamic(..) - | Slice(_) - | Foreign(..) - | Error(_) - | GeneratorWitness(..) - | GeneratorWitnessMIR(..) => { + Str | Dynamic(..) | Slice(_) | Foreign(..) | Error(_) | GeneratorWitness(..) => { // these are never sized - return the target type vec![ty] } diff --git a/compiler/rustc_type_ir/src/sty.rs b/compiler/rustc_type_ir/src/sty.rs index b574cdcc879..c7fa0dcffa9 100644 --- a/compiler/rustc_type_ir/src/sty.rs +++ b/compiler/rustc_type_ir/src/sty.rs @@ -143,31 +143,6 @@ pub enum TyKind { /// `GeneratorArgs`. Generator(I::DefId, I::GenericArgsRef, I::Movability), - /// A type representing the types stored inside a generator. - /// This should only appear as part of the `GeneratorArgs`. - /// - /// Note that the captured variables for generators are stored separately - /// using a tuple in the same way as for closures. - /// - /// Unlike upvars, the witness can reference lifetimes from - /// inside of the generator itself. To deal with them in - /// the type of the generator, we convert them to higher ranked - /// lifetimes bound by the witness itself. - /// - /// Looking at the following example, the witness for this generator - /// may end up as something like `for<'a> [Vec, &'a Vec]`: - /// - /// ```ignore UNSOLVED (ask @compiler-errors, should this error? can we just swap the yields?) - /// #![feature(generators)] - /// |a| { - /// let x = &vec![3]; - /// yield a; - /// yield x[0]; - /// } - /// # ; - /// ``` - GeneratorWitness(I::BinderListTy), - /// A type representing the types stored inside a generator. /// This should only appear as part of the `GeneratorArgs`. /// @@ -192,7 +167,7 @@ pub enum TyKind { /// } /// # ; /// ``` - GeneratorWitnessMIR(I::DefId, I::GenericArgsRef), + GeneratorWitness(I::DefId, I::GenericArgsRef), /// The never type `!`. Never, @@ -278,7 +253,7 @@ const fn tykind_discriminant(value: &TyKind) -> usize { Dynamic(..) => 14, Closure(_, _) => 15, Generator(_, _, _) => 16, - GeneratorWitness(_) => 17, + GeneratorWitness(_, _) => 17, Never => 18, Tuple(_) => 19, Alias(_, _) => 20, @@ -287,7 +262,6 @@ const fn tykind_discriminant(value: &TyKind) -> usize { Placeholder(_) => 23, Infer(_) => 24, Error(_) => 25, - GeneratorWitnessMIR(_, _) => 26, } } @@ -312,8 +286,7 @@ impl Clone for TyKind { Dynamic(p, r, repr) => Dynamic(p.clone(), r.clone(), *repr), Closure(d, s) => Closure(d.clone(), s.clone()), Generator(d, s, m) => Generator(d.clone(), s.clone(), m.clone()), - GeneratorWitness(g) => GeneratorWitness(g.clone()), - GeneratorWitnessMIR(d, s) => GeneratorWitnessMIR(d.clone(), s.clone()), + GeneratorWitness(d, s) => GeneratorWitness(d.clone(), s.clone()), Never => Never, Tuple(t) => Tuple(t.clone()), Alias(k, p) => Alias(*k, p.clone()), @@ -355,10 +328,7 @@ impl PartialEq for TyKind { (Generator(a_d, a_s, a_m), Generator(b_d, b_s, b_m)) => { a_d == b_d && a_s == b_s && a_m == b_m } - (GeneratorWitness(a_g), GeneratorWitness(b_g)) => a_g == b_g, - (GeneratorWitnessMIR(a_d, a_s), GeneratorWitnessMIR(b_d, b_s)) => { - a_d == b_d && a_s == b_s - } + (GeneratorWitness(a_d, a_s), GeneratorWitness(b_d, b_s)) => a_d == b_d && a_s == b_s, (Tuple(a_t), Tuple(b_t)) => a_t == b_t, (Alias(a_i, a_p), Alias(b_i, b_p)) => a_i == b_i && a_p == b_p, (Param(a_p), Param(b_p)) => a_p == b_p, @@ -415,10 +385,9 @@ impl Ord for TyKind { (Generator(a_d, a_s, a_m), Generator(b_d, b_s, b_m)) => { a_d.cmp(b_d).then_with(|| a_s.cmp(b_s).then_with(|| a_m.cmp(b_m))) } - (GeneratorWitness(a_g), GeneratorWitness(b_g)) => a_g.cmp(b_g), ( - GeneratorWitnessMIR(a_d, a_s), - GeneratorWitnessMIR(b_d, b_s), + GeneratorWitness(a_d, a_s), + GeneratorWitness(b_d, b_s), ) => match Ord::cmp(a_d, b_d) { Ordering::Equal => Ord::cmp(a_s, b_s), cmp => cmp, @@ -483,8 +452,7 @@ impl hash::Hash for TyKind { s.hash(state); m.hash(state) } - GeneratorWitness(g) => g.hash(state), - GeneratorWitnessMIR(d, s) => { + GeneratorWitness(d, s) => { d.hash(state); s.hash(state); } @@ -558,9 +526,8 @@ impl DebugWithInfcx for TyKind { }, Closure(d, s) => f.debug_tuple_field2_finish("Closure", d, &this.wrap(s)), Generator(d, s, m) => f.debug_tuple_field3_finish("Generator", d, &this.wrap(s), m), - GeneratorWitness(g) => f.debug_tuple_field1_finish("GeneratorWitness", &this.wrap(g)), - GeneratorWitnessMIR(d, s) => { - f.debug_tuple_field2_finish("GeneratorWitnessMIR", d, &this.wrap(s)) + GeneratorWitness(d, s) => { + f.debug_tuple_field2_finish("GeneratorWitness", d, &this.wrap(s)) } Never => write!(f, "!"), Tuple(t) => { @@ -682,10 +649,7 @@ where args.encode(e); m.encode(e); }), - GeneratorWitness(b) => e.emit_enum_variant(disc, |e| { - b.encode(e); - }), - GeneratorWitnessMIR(def_id, args) => e.emit_enum_variant(disc, |e| { + GeneratorWitness(def_id, args) => e.emit_enum_variant(disc, |e| { def_id.encode(e); args.encode(e); }), @@ -762,7 +726,7 @@ where 14 => Dynamic(Decodable::decode(d), Decodable::decode(d), Decodable::decode(d)), 15 => Closure(Decodable::decode(d), Decodable::decode(d)), 16 => Generator(Decodable::decode(d), Decodable::decode(d), Decodable::decode(d)), - 17 => GeneratorWitness(Decodable::decode(d)), + 17 => GeneratorWitness(Decodable::decode(d), Decodable::decode(d)), 18 => Never, 19 => Tuple(Decodable::decode(d)), 20 => Alias(Decodable::decode(d), Decodable::decode(d)), @@ -771,12 +735,11 @@ where 23 => Placeholder(Decodable::decode(d)), 24 => Infer(Decodable::decode(d)), 25 => Error(Decodable::decode(d)), - 26 => GeneratorWitnessMIR(Decodable::decode(d), Decodable::decode(d)), _ => panic!( "{}", format!( "invalid enum variant tag while decoding `{}`, expected 0..{}", - "TyKind", 27, + "TyKind", 26, ) ), } @@ -870,10 +833,7 @@ where args.hash_stable(__hcx, __hasher); m.hash_stable(__hcx, __hasher); } - GeneratorWitness(b) => { - b.hash_stable(__hcx, __hasher); - } - GeneratorWitnessMIR(def_id, args) => { + GeneratorWitness(def_id, args) => { def_id.hash_stable(__hcx, __hasher); args.hash_stable(__hcx, __hasher); } diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index c4011461885..e0ac769dadd 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -2288,7 +2288,6 @@ pub(crate) fn clean_middle_ty<'tcx>( ty::Bound(..) => panic!("Bound"), ty::Placeholder(..) => panic!("Placeholder"), ty::GeneratorWitness(..) => panic!("GeneratorWitness"), - ty::GeneratorWitnessMIR(..) => panic!("GeneratorWitnessMIR"), ty::Infer(..) => panic!("Infer"), ty::Error(_) => rustc_errors::FatalError.raise(), } diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 0db846bfc7e..8ea9b7a418b 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -522,8 +522,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> { ty::Alias(..) | ty::Closure(..) | ty::Generator(..) - | ty::GeneratorWitness(_) - | ty::GeneratorWitnessMIR(..) + | ty::GeneratorWitness(..) | ty::Dynamic(..) | ty::Param(_) | ty::Bound(..) diff --git a/src/tools/clippy/clippy_lints/src/dereference.rs b/src/tools/clippy/clippy_lints/src/dereference.rs index 8090f821d1f..fe37fd4a0c1 100644 --- a/src/tools/clippy/clippy_lints/src/dereference.rs +++ b/src/tools/clippy/clippy_lints/src/dereference.rs @@ -940,7 +940,6 @@ impl TyCoercionStability { | ty::FnDef(..) | ty::Generator(..) | ty::GeneratorWitness(..) - | ty::GeneratorWitnessMIR(..) | ty::Closure(..) | ty::Never | ty::Tuple(_) diff --git a/tests/ui-fulldeps/internal-lints/ty_tykind_usage.rs b/tests/ui-fulldeps/internal-lints/ty_tykind_usage.rs index bf655510a5a..3f7429a5fcc 100644 --- a/tests/ui-fulldeps/internal-lints/ty_tykind_usage.rs +++ b/tests/ui-fulldeps/internal-lints/ty_tykind_usage.rs @@ -31,7 +31,6 @@ fn main() { TyKind::Closure(..) => (), //~ ERROR usage of `ty::TyKind::` TyKind::Generator(..) => (), //~ ERROR usage of `ty::TyKind::` TyKind::GeneratorWitness(..) => (), //~ ERROR usage of `ty::TyKind::` - TyKind::GeneratorWitnessMIR(..) => (), //~ ERROR usage of `ty::TyKind::` TyKind::Never => (), //~ ERROR usage of `ty::TyKind::` TyKind::Tuple(..) => (), //~ ERROR usage of `ty::TyKind::` TyKind::Alias(..) => (), //~ ERROR usage of `ty::TyKind::` diff --git a/tests/ui-fulldeps/internal-lints/ty_tykind_usage.stderr b/tests/ui-fulldeps/internal-lints/ty_tykind_usage.stderr index 9f8c0bea0ee..1f49d6b6464 100644 --- a/tests/ui-fulldeps/internal-lints/ty_tykind_usage.stderr +++ b/tests/ui-fulldeps/internal-lints/ty_tykind_usage.stderr @@ -121,65 +121,59 @@ LL | TyKind::GeneratorWitness(..) => (), error: usage of `ty::TyKind::` --> $DIR/ty_tykind_usage.rs:34:9 | -LL | TyKind::GeneratorWitnessMIR(..) => (), +LL | TyKind::Never => (), | ^^^^^^ help: try using `ty::` directly: `ty` error: usage of `ty::TyKind::` --> $DIR/ty_tykind_usage.rs:35:9 | -LL | TyKind::Never => (), +LL | TyKind::Tuple(..) => (), | ^^^^^^ help: try using `ty::` directly: `ty` error: usage of `ty::TyKind::` --> $DIR/ty_tykind_usage.rs:36:9 | -LL | TyKind::Tuple(..) => (), +LL | TyKind::Alias(..) => (), | ^^^^^^ help: try using `ty::` directly: `ty` error: usage of `ty::TyKind::` --> $DIR/ty_tykind_usage.rs:37:9 | -LL | TyKind::Alias(..) => (), +LL | TyKind::Param(..) => (), | ^^^^^^ help: try using `ty::` directly: `ty` error: usage of `ty::TyKind::` --> $DIR/ty_tykind_usage.rs:38:9 | -LL | TyKind::Param(..) => (), +LL | TyKind::Bound(..) => (), | ^^^^^^ help: try using `ty::` directly: `ty` error: usage of `ty::TyKind::` --> $DIR/ty_tykind_usage.rs:39:9 | -LL | TyKind::Bound(..) => (), +LL | TyKind::Placeholder(..) => (), | ^^^^^^ help: try using `ty::` directly: `ty` error: usage of `ty::TyKind::` --> $DIR/ty_tykind_usage.rs:40:9 | -LL | TyKind::Placeholder(..) => (), +LL | TyKind::Infer(..) => (), | ^^^^^^ help: try using `ty::` directly: `ty` error: usage of `ty::TyKind::` --> $DIR/ty_tykind_usage.rs:41:9 | -LL | TyKind::Infer(..) => (), - | ^^^^^^ help: try using `ty::` directly: `ty` - -error: usage of `ty::TyKind::` - --> $DIR/ty_tykind_usage.rs:42:9 - | LL | TyKind::Error(_) => (), | ^^^^^^ help: try using `ty::` directly: `ty` error: usage of `ty::TyKind::` - --> $DIR/ty_tykind_usage.rs:47:12 + --> $DIR/ty_tykind_usage.rs:46:12 | LL | if let TyKind::Int(int_ty) = kind {} | ^^^^^^ help: try using `ty::` directly: `ty` error: usage of `ty::TyKind` - --> $DIR/ty_tykind_usage.rs:49:24 + --> $DIR/ty_tykind_usage.rs:48:24 | LL | fn ty_kind(ty_bad: TyKind<'_>, ty_good: Ty<'_>) {} | ^^^^^^^^^^ @@ -187,7 +181,7 @@ LL | fn ty_kind(ty_bad: TyKind<'_>, ty_good: Ty<'_>) {} = help: try using `Ty` instead error: usage of `ty::TyKind` - --> $DIR/ty_tykind_usage.rs:51:37 + --> $DIR/ty_tykind_usage.rs:50:37 | LL | fn ir_ty_kind(bad: IrTyKind) -> IrTyKind { | ^^^^^^^^^^^ @@ -195,7 +189,7 @@ LL | fn ir_ty_kind(bad: IrTyKind) -> IrTyKind { = help: try using `Ty` instead error: usage of `ty::TyKind` - --> $DIR/ty_tykind_usage.rs:51:53 + --> $DIR/ty_tykind_usage.rs:50:53 | LL | fn ir_ty_kind(bad: IrTyKind) -> IrTyKind { | ^^^^^^^^^^^ @@ -203,12 +197,12 @@ LL | fn ir_ty_kind(bad: IrTyKind) -> IrTyKind { = help: try using `Ty` instead error: usage of `ty::TyKind::` - --> $DIR/ty_tykind_usage.rs:54:9 + --> $DIR/ty_tykind_usage.rs:53:9 | LL | IrTyKind::Bool | --------^^^^^^ | | | help: try using `ty::` directly: `ty` -error: aborting due to 33 previous errors +error: aborting due to 32 previous errors diff --git a/tests/ui/symbol-names/basic.legacy.stderr b/tests/ui/symbol-names/basic.legacy.stderr index c1cbefac828..61d27ec69f4 100644 --- a/tests/ui/symbol-names/basic.legacy.stderr +++ b/tests/ui/symbol-names/basic.legacy.stderr @@ -1,10 +1,10 @@ -error: symbol-name(_ZN5basic4main17h6fc0c8d27b1a289fE) +error: symbol-name(_ZN5basic4main17h9308686d0228fa1dE) --> $DIR/basic.rs:8:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ -error: demangling(basic::main::h6fc0c8d27b1a289f) +error: demangling(basic::main::h9308686d0228fa1d) --> $DIR/basic.rs:8:1 | LL | #[rustc_symbol_name] diff --git a/tests/ui/symbol-names/issue-60925.legacy.stderr b/tests/ui/symbol-names/issue-60925.legacy.stderr index 7dd68e6e3a8..eb65f3b58ff 100644 --- a/tests/ui/symbol-names/issue-60925.legacy.stderr +++ b/tests/ui/symbol-names/issue-60925.legacy.stderr @@ -1,10 +1,10 @@ -error: symbol-name(_ZN11issue_609253foo37Foo$LT$issue_60925..llv$u6d$..Foo$GT$3foo17hab58a402db4ebf3aE) +error: symbol-name(_ZN11issue_609253foo37Foo$LT$issue_60925..llv$u6d$..Foo$GT$3foo17h84ab5dafbd2a1508E) --> $DIR/issue-60925.rs:21:9 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ -error: demangling(issue_60925::foo::Foo::foo::hab58a402db4ebf3a) +error: demangling(issue_60925::foo::Foo::foo::h84ab5dafbd2a1508) --> $DIR/issue-60925.rs:21:9 | LL | #[rustc_symbol_name] From bffb3467e1707a9d4fbff73fa6a7ed40cad5170b Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sat, 23 Sep 2023 13:03:14 +0000 Subject: [PATCH 24/30] Make test more robust to opts. --- tests/codegen/async-fn-debug-awaitee-field.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/codegen/async-fn-debug-awaitee-field.rs b/tests/codegen/async-fn-debug-awaitee-field.rs index bc268615814..690505fd72b 100644 --- a/tests/codegen/async-fn-debug-awaitee-field.rs +++ b/tests/codegen/async-fn-debug-awaitee-field.rs @@ -5,12 +5,14 @@ // ignore-tidy-linelength // compile-flags: -C debuginfo=2 --edition=2018 -async fn foo() {} +#![crate_type = "lib"] -async fn async_fn_test() { +pub async fn async_fn_test() { foo().await; } +pub async fn foo() {} + // NONMSVC: [[GEN:!.*]] = !DICompositeType(tag: DW_TAG_structure_type, name: "{async_fn_env#0}", scope: [[GEN_SCOPE:![0-9]*]], // MSVC: [[GEN:!.*]] = !DICompositeType(tag: DW_TAG_union_type, name: "enum2$", // NONMSVC: [[GEN_SCOPE:!.*]] = !DINamespace(name: "async_fn_test", @@ -19,7 +21,3 @@ async fn async_fn_test() { // NONMSVC: [[AWAITEE_TYPE]] = !DICompositeType(tag: DW_TAG_structure_type, name: "{async_fn_env#0}", scope: [[AWAITEE_SCOPE:![0-9]*]], // MSVC: [[AWAITEE_TYPE]] = !DICompositeType(tag: DW_TAG_union_type, name: "enum2$", // NONMSVC: [[AWAITEE_SCOPE]] = !DINamespace(name: "foo", - -fn main() { - let _fn = async_fn_test(); -} From 8ec5639bc204217cf0a37ba92d35358f787b6d69 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Tue, 5 Sep 2023 17:14:37 +0000 Subject: [PATCH 25/30] Reuse calculate_debuginfo_offset for fragments. --- .../rustc_codegen_ssa/src/mir/debuginfo.rs | 43 +++++-------------- 1 file changed, 10 insertions(+), 33 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/mir/debuginfo.rs b/compiler/rustc_codegen_ssa/src/mir/debuginfo.rs index d1560114763..0dc30d21c5b 100644 --- a/compiler/rustc_codegen_ssa/src/mir/debuginfo.rs +++ b/compiler/rustc_codegen_ssa/src/mir/debuginfo.rs @@ -158,8 +158,7 @@ fn calculate_debuginfo_offset< L: DebugInfoOffsetLocation<'tcx, Bx>, >( bx: &mut Bx, - local: mir::Local, - var: &PerLocalVarDebugInfo<'tcx, Bx::DIVariable>, + projection: &[mir::PlaceElem<'tcx>], base: L, ) -> DebugInfoOffset { let mut direct_offset = Size::ZERO; @@ -167,7 +166,7 @@ fn calculate_debuginfo_offset< let mut indirect_offsets = vec![]; let mut place = base; - for elem in &var.projection[..] { + for elem in projection { match *elem { mir::ProjectionElem::Deref => { indirect_offsets.push(Size::ZERO); @@ -188,11 +187,7 @@ fn calculate_debuginfo_offset< } => { let offset = indirect_offsets.last_mut().unwrap_or(&mut direct_offset); let FieldsShape::Array { stride, count: _ } = place.layout().fields else { - span_bug!( - var.source_info.span, - "ConstantIndex on non-array type {:?}", - place.layout() - ) + bug!("ConstantIndex on non-array type {:?}", place.layout()) }; *offset += stride * index; place = place.project_constant_index(bx, index); @@ -200,11 +195,7 @@ fn calculate_debuginfo_offset< _ => { // Sanity check for `can_use_in_debuginfo`. debug_assert!(!elem.can_use_in_debuginfo()); - span_bug!( - var.source_info.span, - "unsupported var debuginfo place `{:?}`", - mir::Place { local, projection: var.projection }, - ) + bug!("unsupported var debuginfo projection `{:?}`", projection) } } } @@ -407,7 +398,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { let Some(dbg_loc) = self.dbg_loc(var.source_info) else { return }; let DebugInfoOffset { direct_offset, indirect_offsets, result: _ } = - calculate_debuginfo_offset(bx, local, &var, base.layout); + calculate_debuginfo_offset(bx, &var.projection, base.layout); // When targeting MSVC, create extra allocas for arguments instead of pointing multiple // dbg_var_addr() calls into the same alloca with offsets. MSVC uses CodeView records @@ -425,7 +416,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { if should_create_individual_allocas { let DebugInfoOffset { direct_offset: _, indirect_offsets: _, result: place } = - calculate_debuginfo_offset(bx, local, &var, base); + calculate_debuginfo_offset(bx, &var.projection, base); // Create a variable which will be a pointer to the actual value let ptr_ty = Ty::new_ptr( @@ -532,23 +523,9 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { let fragment = if let Some(ref fragment) = var.composite { let var_layout = self.cx.layout_of(var_ty); - let mut fragment_start = Size::ZERO; - let mut fragment_layout = var_layout; - - for elem in &fragment.projection { - match *elem { - mir::ProjectionElem::Field(field, _) => { - let i = field.index(); - fragment_start += fragment_layout.fields.offset(i); - fragment_layout = fragment_layout.field(self.cx, i); - } - _ => span_bug!( - var.source_info.span, - "unsupported fragment projection `{:?}`", - elem, - ), - } - } + let DebugInfoOffset { direct_offset, indirect_offsets, result: fragment_layout } = + calculate_debuginfo_offset(bx, &fragment.projection, var_layout); + debug_assert!(indirect_offsets.is_empty()); if fragment_layout.size == Size::ZERO { // Fragment is a ZST, so does not represent anything. Avoid generating anything @@ -559,7 +536,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { // DWARF is concerned, it's not really a fragment. None } else { - Some(fragment_start..fragment_start + fragment_layout.size) + Some(direct_offset..direct_offset + fragment_layout.size) } } else { None From 2d25a25e5dc5636778d1e4e86bf6fa2d9a1be0af Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 23 Sep 2023 20:03:03 +0200 Subject: [PATCH 26/30] Migrate GUI colors test to original CSS color format --- tests/rustdoc-gui/default-settings.goml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/rustdoc-gui/default-settings.goml b/tests/rustdoc-gui/default-settings.goml index 3466f3693f9..ff4abb65c02 100644 --- a/tests/rustdoc-gui/default-settings.goml +++ b/tests/rustdoc-gui/default-settings.goml @@ -5,4 +5,4 @@ go-to: "file://" + |DOC_PATH| + "/settings/index.html" // Wait a bit to be sure the default theme is applied. // If the theme isn't applied, the command will time out. -wait-for-css: ("body", {"background-color": "rgb(15, 20, 25)"}) +wait-for-css: ("body", {"background-color": "#0f1419"}) From 74f52613454714cd033165cc635a407ef61f04c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emil=20Gardstr=C3=B6m?= Date: Sat, 23 Sep 2023 20:48:00 +0200 Subject: [PATCH 27/30] implement Literal::byte_character without this, the only way to create a `LitKind::Byte` is by doing `"b'a'".parse::()`, this solves that by enabling `Literal::byte_character(b'a')` --- library/proc_macro/src/lib.rs | 7 +++++++ .../feature-gate-proc_macro_byte_character.rs | 10 ++++++++++ .../feature-gate-proc_macro_byte_character.stderr | 12 ++++++++++++ tests/ui/proc-macro/auxiliary/api/mod.rs | 1 + tests/ui/proc-macro/auxiliary/api/parse.rs | 4 ++++ 5 files changed, 34 insertions(+) create mode 100644 tests/ui/feature-gates/feature-gate-proc_macro_byte_character.rs create mode 100644 tests/ui/feature-gates/feature-gate-proc_macro_byte_character.stderr diff --git a/library/proc_macro/src/lib.rs b/library/proc_macro/src/lib.rs index d382fec9352..d322d882cc1 100644 --- a/library/proc_macro/src/lib.rs +++ b/library/proc_macro/src/lib.rs @@ -1337,6 +1337,13 @@ impl Literal { Literal::new(bridge::LitKind::Char, symbol, None) } + /// Byte character literal. + #[unstable(feature = "proc_macro_byte_character", issue = "115268")] + pub fn byte_character(byte: u8) -> Literal { + let string = [byte].escape_ascii().to_string(); + Literal::new(bridge::LitKind::Byte, &string, None) + } + /// Byte string literal. #[stable(feature = "proc_macro_lib2", since = "1.29.0")] pub fn byte_string(bytes: &[u8]) -> Literal { diff --git a/tests/ui/feature-gates/feature-gate-proc_macro_byte_character.rs b/tests/ui/feature-gates/feature-gate-proc_macro_byte_character.rs new file mode 100644 index 00000000000..0648ce0ee20 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-proc_macro_byte_character.rs @@ -0,0 +1,10 @@ +// force-host +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::Literal; + +fn test() { + Literal::byte_character(b'a'); //~ ERROR use of unstable library feature 'proc_macro_byte_character' +} diff --git a/tests/ui/feature-gates/feature-gate-proc_macro_byte_character.stderr b/tests/ui/feature-gates/feature-gate-proc_macro_byte_character.stderr new file mode 100644 index 00000000000..00691538938 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-proc_macro_byte_character.stderr @@ -0,0 +1,12 @@ +error[E0658]: use of unstable library feature 'proc_macro_byte_character' + --> $DIR/feature-gate-proc_macro_byte_character.rs:9:5 + | +LL | Literal::byte_character(b'a'); + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #115268 for more information + = help: add `#![feature(proc_macro_byte_character)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/proc-macro/auxiliary/api/mod.rs b/tests/ui/proc-macro/auxiliary/api/mod.rs index 739c25132e7..3bea5d75779 100644 --- a/tests/ui/proc-macro/auxiliary/api/mod.rs +++ b/tests/ui/proc-macro/auxiliary/api/mod.rs @@ -4,6 +4,7 @@ #![crate_type = "proc-macro"] #![crate_name = "proc_macro_api_tests"] #![feature(proc_macro_span)] +#![feature(proc_macro_byte_character)] #![deny(dead_code)] // catch if a test function is never called extern crate proc_macro; diff --git a/tests/ui/proc-macro/auxiliary/api/parse.rs b/tests/ui/proc-macro/auxiliary/api/parse.rs index 27391f83111..07c9f464961 100644 --- a/tests/ui/proc-macro/auxiliary/api/parse.rs +++ b/tests/ui/proc-macro/auxiliary/api/parse.rs @@ -29,12 +29,16 @@ fn test_display_literal() { assert_eq!(Literal::character('\'').to_string(), "'\\''"); assert_eq!(Literal::character('"').to_string(), "'\"'"); assert_eq!(Literal::character('\u{1}').to_string(), "'\\u{1}'"); + + assert_eq!(Literal::byte_character(b'a').to_string(), "b'a'"); + assert_eq!(Literal::byte_character(0).to_string(), "b'\\x00'"); } fn test_parse_literal() { assert_eq!("1".parse::().unwrap().to_string(), "1"); assert_eq!("1.0".parse::().unwrap().to_string(), "1.0"); assert_eq!("'a'".parse::().unwrap().to_string(), "'a'"); + assert_eq!("b'a'".parse::().unwrap().to_string(), "b'a'"); assert_eq!("\"\n\"".parse::().unwrap().to_string(), "\"\n\""); assert_eq!("b\"\"".parse::().unwrap().to_string(), "b\"\""); assert_eq!("r##\"\"##".parse::().unwrap().to_string(), "r##\"\"##"); From 58bbca958d917a89124da248735926f86c59a149 Mon Sep 17 00:00:00 2001 From: BlackHoleFox Date: Sun, 13 Nov 2022 16:58:18 -0600 Subject: [PATCH 28/30] Raise minimum supported macOS to 10.12 --- .github/workflows/ci.yml | 12 +++---- compiler/rustc_target/src/spec/apple_base.rs | 31 ++++++------------- .../src/spec/x86_64_apple_darwin.rs | 2 +- .../std/src/sys/unix/thread_parking/darwin.rs | 3 +- src/ci/github-actions/ci.yml | 8 ++--- src/doc/rustc/src/platform-support.md | 4 +-- src/etc/installer/pkg/Distribution.xml | 2 +- .../macos/i686-macosx-deployment-target.rs | 4 +-- .../macos/i686-no-macosx-deployment-target.rs | 2 +- .../macos/x86_64-macosx-deployment-target.rs | 4 +-- .../x86_64-no-macosx-deployment-target.rs | 2 +- .../run-make/macos-deployment-target/Makefile | 4 +-- 12 files changed, 33 insertions(+), 45 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3680136d89f..60af69e0fc4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -305,7 +305,7 @@ jobs: SCRIPT: "./x.py dist bootstrap --include-default-paths --host=x86_64-apple-darwin --target=x86_64-apple-darwin" RUST_CONFIGURE_ARGS: "--enable-full-tools --enable-sanitizers --enable-profiler --set rust.jemalloc --set llvm.ninja=false --set rust.lto=thin" RUSTC_RETRY_LINKER_ON_SEGFAULT: 1 - MACOSX_DEPLOYMENT_TARGET: 10.7 + MACOSX_DEPLOYMENT_TARGET: 10.12 SELECT_XCODE: /Applications/Xcode_13.4.1.app NO_LLVM_ASSERTIONS: 1 NO_DEBUG_ASSERTIONS: 1 @@ -317,7 +317,7 @@ jobs: SCRIPT: "./x.py dist bootstrap --include-default-paths --host='' --target=aarch64-apple-ios,x86_64-apple-ios,aarch64-apple-ios-sim" RUST_CONFIGURE_ARGS: "--enable-sanitizers --enable-profiler --set rust.jemalloc --set llvm.ninja=false" RUSTC_RETRY_LINKER_ON_SEGFAULT: 1 - MACOSX_DEPLOYMENT_TARGET: 10.7 + MACOSX_DEPLOYMENT_TARGET: 10.12 SELECT_XCODE: /Applications/Xcode_13.4.1.app NO_LLVM_ASSERTIONS: 1 NO_DEBUG_ASSERTIONS: 1 @@ -328,8 +328,8 @@ jobs: SCRIPT: "./x.py --stage 2 test --skip tests/ui --skip tests/rustdoc --skip tests/run-make-fulldeps" RUST_CONFIGURE_ARGS: "--build=x86_64-apple-darwin --enable-sanitizers --enable-profiler --set rust.jemalloc --set llvm.ninja=false" RUSTC_RETRY_LINKER_ON_SEGFAULT: 1 - MACOSX_DEPLOYMENT_TARGET: 10.8 - MACOSX_STD_DEPLOYMENT_TARGET: 10.7 + MACOSX_DEPLOYMENT_TARGET: 10.12 + MACOSX_STD_DEPLOYMENT_TARGET: 10.12 NO_LLVM_ASSERTIONS: 1 NO_DEBUG_ASSERTIONS: 1 NO_OVERFLOW_CHECKS: 1 @@ -339,8 +339,8 @@ jobs: SCRIPT: "./x.py --stage 2 test tests/ui tests/rustdoc tests/run-make-fulldeps" RUST_CONFIGURE_ARGS: "--build=x86_64-apple-darwin --enable-sanitizers --enable-profiler --set rust.jemalloc --set llvm.ninja=false" RUSTC_RETRY_LINKER_ON_SEGFAULT: 1 - MACOSX_DEPLOYMENT_TARGET: 10.8 - MACOSX_STD_DEPLOYMENT_TARGET: 10.7 + MACOSX_DEPLOYMENT_TARGET: 10.12 + MACOSX_STD_DEPLOYMENT_TARGET: 10.12 NO_LLVM_ASSERTIONS: 1 NO_DEBUG_ASSERTIONS: 1 NO_OVERFLOW_CHECKS: 1 diff --git a/compiler/rustc_target/src/spec/apple_base.rs b/compiler/rustc_target/src/spec/apple_base.rs index f7dcec307dd..4a046fe5b64 100644 --- a/compiler/rustc_target/src/spec/apple_base.rs +++ b/compiler/rustc_target/src/spec/apple_base.rs @@ -67,13 +67,16 @@ impl Arch { Armv7s => "cortex-a9", Arm64 => "apple-a7", Arm64_32 => "apple-s4", - I386 | I686 => "yonah", - X86_64 | X86_64_sim => "core2", + // Only macOS 10.12+ is supported, which means + // all x86_64/x86 CPUs must be running at least penryn + // https://github.com/llvm/llvm-project/blob/01f924d0e37a5deae51df0d77e10a15b63aa0c0f/clang/lib/Driver/ToolChains/Arch/X86.cpp#L79-L82 + I386 | I686 => "penryn", + X86_64 | X86_64_sim => "penryn", + X86_64_macabi => "penryn", // Note: `core-avx2` is slightly more advanced than `x86_64h`, see // comments (and disabled features) in `x86_64h_apple_darwin` for - // details. + // details. It is a higher baseline then `penryn` however. X86_64h => "core-avx2", - X86_64_macabi => "core2", Arm64_macabi => "apple-a12", Arm64_sim => "apple-a12", } @@ -115,20 +118,8 @@ fn pre_link_args(os: &'static str, arch: Arch, abi: &'static str) -> LinkArgs { } pub fn opts(os: &'static str, arch: Arch) -> TargetOptions { - // Static TLS is only available in macOS 10.7+. If you try to compile for 10.6 - // either the linker will complain if it is used or the binary will end up - // segfaulting at runtime when run on 10.6. Rust by default supports macOS - // 10.7+, but there is a standard environment variable, - // MACOSX_DEPLOYMENT_TARGET, which is used to signal targeting older - // versions of macOS. For example compiling on 10.10 with - // MACOSX_DEPLOYMENT_TARGET set to 10.6 will cause the linker to generate - // warnings about the usage of static TLS. - // - // Here we detect what version is being requested, defaulting to 10.7. Static - // TLS is flagged as enabled if it looks to be supported. The architecture - // only matters for default deployment target which is 11.0 for ARM64 and - // 10.7 for everything else. - let has_thread_local = os == "macos" && macos_deployment_target(Arch::X86_64) >= (10, 7); + // TODO: iOS 10+ always has TLS too. + let has_thread_local = os == "macos"; let abi = arch.target_abi(); @@ -239,9 +230,7 @@ fn macos_default_deployment_target(arch: Arch) -> (u32, u32) { match arch { // Note: Arm64_sim is not included since macOS has no simulator. Arm64 | Arm64_macabi => (11, 0), - // x86_64h-apple-darwin only supports macOS 10.8 and later - X86_64h => (10, 8), - _ => (10, 7), + _ => (10, 12), } } diff --git a/compiler/rustc_target/src/spec/x86_64_apple_darwin.rs b/compiler/rustc_target/src/spec/x86_64_apple_darwin.rs index e90bda9c9a8..e3f5d7321d1 100644 --- a/compiler/rustc_target/src/spec/x86_64_apple_darwin.rs +++ b/compiler/rustc_target/src/spec/x86_64_apple_darwin.rs @@ -5,7 +5,7 @@ use crate::spec::{StackProbeType, Target, TargetOptions}; pub fn target() -> Target { let arch = Arch::X86_64; let mut base = opts("macos", arch); - base.max_atomic_width = Some(128); // core2 supports cmpxchg16b + base.max_atomic_width = Some(128); // penryn+ supports cmpxchg16b base.frame_pointer = FramePointer::Always; base.add_pre_link_args(LinkerFlavor::Darwin(Cc::Yes, Lld::No), &["-m64"]); base.stack_probes = StackProbeType::X86; diff --git a/library/std/src/sys/unix/thread_parking/darwin.rs b/library/std/src/sys/unix/thread_parking/darwin.rs index b709fada3b4..8231f3cba2d 100644 --- a/library/std/src/sys/unix/thread_parking/darwin.rs +++ b/library/std/src/sys/unix/thread_parking/darwin.rs @@ -2,8 +2,7 @@ //! //! Darwin actually has futex syscalls (`__ulock_wait`/`__ulock_wake`), but they //! cannot be used in `std` because they are non-public (their use will lead to -//! rejection from the App Store) and because they are only available starting -//! with macOS version 10.12, even though the minimum target version is 10.7. +//! rejection from the App Store). //! //! Therefore, we need to look for other synchronization primitives. Luckily, Darwin //! supports semaphores, which allow us to implement the behaviour we need with diff --git a/src/ci/github-actions/ci.yml b/src/ci/github-actions/ci.yml index 89b82d59d31..0271855087b 100644 --- a/src/ci/github-actions/ci.yml +++ b/src/ci/github-actions/ci.yml @@ -484,7 +484,7 @@ jobs: SCRIPT: ./x.py dist bootstrap --include-default-paths --host=x86_64-apple-darwin --target=x86_64-apple-darwin RUST_CONFIGURE_ARGS: --enable-full-tools --enable-sanitizers --enable-profiler --set rust.jemalloc --set llvm.ninja=false --set rust.lto=thin RUSTC_RETRY_LINKER_ON_SEGFAULT: 1 - MACOSX_DEPLOYMENT_TARGET: 10.7 + MACOSX_DEPLOYMENT_TARGET: 10.12 SELECT_XCODE: /Applications/Xcode_13.4.1.app NO_LLVM_ASSERTIONS: 1 NO_DEBUG_ASSERTIONS: 1 @@ -497,7 +497,7 @@ jobs: SCRIPT: ./x.py dist bootstrap --include-default-paths --host='' --target=aarch64-apple-ios,x86_64-apple-ios,aarch64-apple-ios-sim RUST_CONFIGURE_ARGS: --enable-sanitizers --enable-profiler --set rust.jemalloc --set llvm.ninja=false RUSTC_RETRY_LINKER_ON_SEGFAULT: 1 - MACOSX_DEPLOYMENT_TARGET: 10.7 + MACOSX_DEPLOYMENT_TARGET: 10.12 SELECT_XCODE: /Applications/Xcode_13.4.1.app NO_LLVM_ASSERTIONS: 1 NO_DEBUG_ASSERTIONS: 1 @@ -509,8 +509,8 @@ jobs: SCRIPT: ./x.py --stage 2 test --skip tests/ui --skip tests/rustdoc --skip tests/run-make-fulldeps RUST_CONFIGURE_ARGS: --build=x86_64-apple-darwin --enable-sanitizers --enable-profiler --set rust.jemalloc --set llvm.ninja=false RUSTC_RETRY_LINKER_ON_SEGFAULT: 1 - MACOSX_DEPLOYMENT_TARGET: 10.8 - MACOSX_STD_DEPLOYMENT_TARGET: 10.7 + MACOSX_DEPLOYMENT_TARGET: 10.12 + MACOSX_STD_DEPLOYMENT_TARGET: 10.12 NO_LLVM_ASSERTIONS: 1 NO_DEBUG_ASSERTIONS: 1 NO_OVERFLOW_CHECKS: 1 diff --git a/src/doc/rustc/src/platform-support.md b/src/doc/rustc/src/platform-support.md index 2cb0a8f3c17..2f2a4f44feb 100644 --- a/src/doc/rustc/src/platform-support.md +++ b/src/doc/rustc/src/platform-support.md @@ -36,7 +36,7 @@ target | notes `i686-pc-windows-gnu` | 32-bit MinGW (Windows 7+) [^windows-support] `i686-pc-windows-msvc` | 32-bit MSVC (Windows 7+) [^windows-support] `i686-unknown-linux-gnu` | 32-bit Linux (kernel 3.2+, glibc 2.17+) -`x86_64-apple-darwin` | 64-bit macOS (10.7+, Lion+) +`x86_64-apple-darwin` | 64-bit macOS (10.12+, Sierra+) `x86_64-pc-windows-gnu` | 64-bit MinGW (Windows 7+) [^windows-support] `x86_64-pc-windows-msvc` | 64-bit MSVC (Windows 7+) [^windows-support] `x86_64-unknown-linux-gnu` | 64-bit Linux (kernel 3.2+, glibc 2.17+) @@ -264,7 +264,7 @@ target | std | host | notes `hexagon-unknown-linux-musl` | ? | | `i386-apple-ios` | ✓ | | 32-bit x86 iOS [`i586-pc-nto-qnx700`](platform-support/nto-qnx.md) | * | | 32-bit x86 QNX Neutrino 7.0 RTOS | -`i686-apple-darwin` | ✓ | ✓ | 32-bit macOS (10.7+, Lion+) +`i686-apple-darwin` | ✓ | ✓ | 32-bit macOS (10.12+, Sierra+) `i686-pc-windows-msvc` | * | | 32-bit Windows XP support `i686-unknown-haiku` | ✓ | ✓ | 32-bit Haiku [`i686-unknown-netbsd`](platform-support/netbsd.md) | ✓ | ✓ | NetBSD/i386 with SSE2 diff --git a/src/etc/installer/pkg/Distribution.xml b/src/etc/installer/pkg/Distribution.xml index 395814e7488..85c26ec4993 100644 --- a/src/etc/installer/pkg/Distribution.xml +++ b/src/etc/installer/pkg/Distribution.xml @@ -7,7 +7,7 @@ - + diff --git a/tests/codegen/macos/i686-macosx-deployment-target.rs b/tests/codegen/macos/i686-macosx-deployment-target.rs index 17258a264a5..ba49178dcb6 100644 --- a/tests/codegen/macos/i686-macosx-deployment-target.rs +++ b/tests/codegen/macos/i686-macosx-deployment-target.rs @@ -4,7 +4,7 @@ // compile-flags: -O --target=i686-apple-darwin --crate-type=rlib // needs-llvm-components: x86 -// rustc-env:MACOSX_DEPLOYMENT_TARGET=10.9 +// rustc-env:MACOSX_DEPLOYMENT_TARGET=10.14 #![feature(no_core, lang_items)] #![no_core] @@ -20,7 +20,7 @@ pub struct Bool { b: bool, } -// CHECK: target triple = "i686-apple-macosx10.9.0" +// CHECK: target triple = "i686-apple-macosx10.14.0" #[no_mangle] pub extern "C" fn structbool() -> Bool { Bool { b: true } diff --git a/tests/codegen/macos/i686-no-macosx-deployment-target.rs b/tests/codegen/macos/i686-no-macosx-deployment-target.rs index 043040a95e3..479fe7968f7 100644 --- a/tests/codegen/macos/i686-no-macosx-deployment-target.rs +++ b/tests/codegen/macos/i686-no-macosx-deployment-target.rs @@ -20,7 +20,7 @@ pub struct Bool { b: bool, } -// CHECK: target triple = "i686-apple-macosx10.7.0" +// CHECK: target triple = "i686-apple-macosx10.12.0" #[no_mangle] pub extern "C" fn structbool() -> Bool { Bool { b: true } diff --git a/tests/codegen/macos/x86_64-macosx-deployment-target.rs b/tests/codegen/macos/x86_64-macosx-deployment-target.rs index 8e673d11d98..957c727bb93 100644 --- a/tests/codegen/macos/x86_64-macosx-deployment-target.rs +++ b/tests/codegen/macos/x86_64-macosx-deployment-target.rs @@ -4,7 +4,7 @@ // compile-flags: -O --target=x86_64-apple-darwin --crate-type=rlib // needs-llvm-components: x86 -// rustc-env:MACOSX_DEPLOYMENT_TARGET=10.9 +// rustc-env:MACOSX_DEPLOYMENT_TARGET=10.14 #![feature(no_core, lang_items)] #![no_core] @@ -20,7 +20,7 @@ pub struct Bool { b: bool, } -// CHECK: target triple = "x86_64-apple-macosx10.9.0" +// CHECK: target triple = "x86_64-apple-macosx10.14.0" #[no_mangle] pub extern "C" fn structbool() -> Bool { Bool { b: true } diff --git a/tests/codegen/macos/x86_64-no-macosx-deployment-target.rs b/tests/codegen/macos/x86_64-no-macosx-deployment-target.rs index 25ae6924de0..edbc1b66c71 100644 --- a/tests/codegen/macos/x86_64-no-macosx-deployment-target.rs +++ b/tests/codegen/macos/x86_64-no-macosx-deployment-target.rs @@ -20,7 +20,7 @@ pub struct Bool { b: bool, } -// CHECK: target triple = "x86_64-apple-macosx10.7.0" +// CHECK: target triple = "x86_64-apple-macosx10.12.0" #[no_mangle] pub extern "C" fn structbool() -> Bool { Bool { b: true } diff --git a/tests/run-make/macos-deployment-target/Makefile b/tests/run-make/macos-deployment-target/Makefile index d0cf836bcdf..757ca699535 100644 --- a/tests/run-make/macos-deployment-target/Makefile +++ b/tests/run-make/macos-deployment-target/Makefile @@ -9,12 +9,12 @@ include ../tools.mk ifeq ($(strip $(shell uname -m)),arm64) GREP_PATTERN = "minos 11.0" else - GREP_PATTERN = "version 10.9" + GREP_PATTERN = "version 10.13" endif OUT_FILE=$(TMPDIR)/with_deployment_target.dylib all: - env MACOSX_DEPLOYMENT_TARGET=10.9 $(RUSTC) with_deployment_target.rs -o $(OUT_FILE) + env MACOSX_DEPLOYMENT_TARGET=10.13 $(RUSTC) with_deployment_target.rs -o $(OUT_FILE) # XXX: The check is for either the x86_64 minimum OR the aarch64 minimum (M1 starts at macOS 11). # They also use different load commands, so we let that change with each too. The aarch64 check # isn't as robust as the x86 one, but testing both seems unneeded. From 3b52befdcec6b43163c937ed6e842c1c49846052 Mon Sep 17 00:00:00 2001 From: BlackHoleFox Date: Sun, 13 Nov 2022 17:23:26 -0600 Subject: [PATCH 29/30] Raise minimum supported iOS version to 10.0 Drop the armv7-apple-ios target too because its no longer supported with the hardware iOS 10 requires. --- compiler/rustc_target/src/spec/apple_base.rs | 27 +++++++++---------- .../rustc_target/src/spec/armv7_apple_ios.rs | 21 --------------- .../rustc_target/src/spec/armv7s_apple_ios.rs | 4 +-- compiler/rustc_target/src/spec/mod.rs | 1 - library/std/src/sys/unix/thread_local_dtor.rs | 2 +- src/bootstrap/llvm.rs | 9 +------ src/doc/rustc/src/platform-support.md | 1 - src/tools/build-manifest/src/main.rs | 1 - 8 files changed, 17 insertions(+), 49 deletions(-) delete mode 100644 compiler/rustc_target/src/spec/armv7_apple_ios.rs diff --git a/compiler/rustc_target/src/spec/apple_base.rs b/compiler/rustc_target/src/spec/apple_base.rs index 4a046fe5b64..9ed06b73197 100644 --- a/compiler/rustc_target/src/spec/apple_base.rs +++ b/compiler/rustc_target/src/spec/apple_base.rs @@ -11,7 +11,6 @@ use Arch::*; #[allow(non_camel_case_types)] #[derive(Copy, Clone)] pub enum Arch { - Armv7, Armv7k, Armv7s, Arm64, @@ -29,7 +28,6 @@ pub enum Arch { impl Arch { pub fn target_name(self) -> &'static str { match self { - Armv7 => "armv7", Armv7k => "armv7k", Armv7s => "armv7s", Arm64 | Arm64_macabi | Arm64_sim => "arm64", @@ -43,7 +41,7 @@ impl Arch { pub fn target_arch(self) -> Cow<'static, str> { Cow::Borrowed(match self { - Armv7 | Armv7k | Armv7s => "arm", + Armv7k | Armv7s => "arm", Arm64 | Arm64_32 | Arm64_macabi | Arm64_sim => "aarch64", I386 | I686 => "x86", X86_64 | X86_64_sim | X86_64_macabi | X86_64h => "x86_64", @@ -52,7 +50,7 @@ impl Arch { fn target_abi(self) -> &'static str { match self { - Armv7 | Armv7k | Armv7s | Arm64 | Arm64_32 | I386 | I686 | X86_64 | X86_64h => "", + Armv7k | Armv7s | Arm64 | Arm64_32 | I386 | I686 | X86_64 | X86_64h => "", X86_64_macabi | Arm64_macabi => "macabi", // x86_64-apple-ios is a simulator target, even though it isn't // declared that way in the target like the other ones... @@ -62,9 +60,8 @@ impl Arch { fn target_cpu(self) -> &'static str { match self { - Armv7 => "cortex-a8", // iOS7 is supported on iPhone 4 and higher Armv7k => "cortex-a8", - Armv7s => "cortex-a9", + Armv7s => "swift", // iOS 10 is only supported on iPhone 5 or higher. Arm64 => "apple-a7", Arm64_32 => "apple-s4", // Only macOS 10.12+ is supported, which means @@ -118,9 +115,6 @@ fn pre_link_args(os: &'static str, arch: Arch, abi: &'static str) -> LinkArgs { } pub fn opts(os: &'static str, arch: Arch) -> TargetOptions { - // TODO: iOS 10+ always has TLS too. - let has_thread_local = os == "macos"; - let abi = arch.target_abi(); TargetOptions { @@ -136,12 +130,17 @@ pub fn opts(os: &'static str, arch: Arch) -> TargetOptions { pre_link_args: pre_link_args(os, arch, abi), families: cvs!["unix"], is_like_osx: true, - default_dwarf_version: 2, + // LLVM notes that macOS 10.11+ and iOS 9+ default + // to v4, so we do the same. + // https://github.com/llvm/llvm-project/blob/378778a0d10c2f8d5df8ceff81f95b6002984a4b/clang/lib/Driver/ToolChains/Darwin.cpp#L1203 + default_dwarf_version: 4, frame_pointer: FramePointer::Always, has_rpath: true, dll_suffix: ".dylib".into(), archive_format: "darwin".into(), - has_thread_local, + // Thread locals became available with iOS 8 and macOS 10.7, + // and both are far below our minimum. + has_thread_local: true, abi_return_struct_as_int: true, emit_debug_gdb_scripts: false, eh_frame_header: false, @@ -281,8 +280,8 @@ fn link_env_remove(arch: Arch, os: &'static str) -> StaticCow<[StaticCow]> // Otherwise if cross-compiling for a different OS/SDK, remove any part // of the linking environment that's wrong and reversed. match arch { - Armv7 | Armv7k | Armv7s | Arm64 | Arm64_32 | I386 | I686 | X86_64 | X86_64_sim - | X86_64h | Arm64_sim => { + Armv7k | Armv7s | Arm64 | Arm64_32 | I386 | I686 | X86_64 | X86_64_sim | X86_64h + | Arm64_sim => { cvs!["MACOSX_DEPLOYMENT_TARGET"] } X86_64_macabi | Arm64_macabi => cvs!["IPHONEOS_DEPLOYMENT_TARGET"], @@ -292,7 +291,7 @@ fn link_env_remove(arch: Arch, os: &'static str) -> StaticCow<[StaticCow]> fn ios_deployment_target() -> (u32, u32) { // If you are looking for the default deployment target, prefer `rustc --print deployment-target`. - from_set_deployment_target("IPHONEOS_DEPLOYMENT_TARGET").unwrap_or((7, 0)) + from_set_deployment_target("IPHONEOS_DEPLOYMENT_TARGET").unwrap_or((10, 0)) } fn mac_catalyst_deployment_target() -> (u32, u32) { diff --git a/compiler/rustc_target/src/spec/armv7_apple_ios.rs b/compiler/rustc_target/src/spec/armv7_apple_ios.rs deleted file mode 100644 index 3259c854791..00000000000 --- a/compiler/rustc_target/src/spec/armv7_apple_ios.rs +++ /dev/null @@ -1,21 +0,0 @@ -use super::apple_base::{ios_llvm_target, opts, Arch}; -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - let arch = Arch::Armv7; - Target { - // Clang automatically chooses a more specific target based on - // IPHONEOS_DEPLOYMENT_TARGET. - // This is required for the target to pick the right - // MACH-O commands, so we do too. - llvm_target: ios_llvm_target(arch).into(), - pointer_width: 32, - data_layout: "e-m:o-p:32:32-Fi8-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32".into(), - arch: arch.target_arch(), - options: TargetOptions { - features: "+v7,+vfp3,+neon".into(), - max_atomic_width: Some(64), - ..opts("ios", arch) - }, - } -} diff --git a/compiler/rustc_target/src/spec/armv7s_apple_ios.rs b/compiler/rustc_target/src/spec/armv7s_apple_ios.rs index be4bc675844..be7f8542c9e 100644 --- a/compiler/rustc_target/src/spec/armv7s_apple_ios.rs +++ b/compiler/rustc_target/src/spec/armv7s_apple_ios.rs @@ -1,10 +1,10 @@ -use super::apple_base::{opts, Arch}; +use super::apple_base::{ios_llvm_target, opts, Arch}; use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { let arch = Arch::Armv7s; Target { - llvm_target: "armv7s-apple-ios".into(), + llvm_target: ios_llvm_target(arch).into(), pointer_width: 32, data_layout: "e-m:o-p:32:32-Fi8-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32".into(), arch: arch.target_arch(), diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index fca99381c0c..a9f696b55a7 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -1390,7 +1390,6 @@ supported_targets! { ("i386-apple-ios", i386_apple_ios), ("x86_64-apple-ios", x86_64_apple_ios), ("aarch64-apple-ios", aarch64_apple_ios), - ("armv7-apple-ios", armv7_apple_ios), ("armv7s-apple-ios", armv7s_apple_ios), ("x86_64-apple-ios-macabi", x86_64_apple_ios_macabi), ("aarch64-apple-ios-macabi", aarch64_apple_ios_macabi), diff --git a/library/std/src/sys/unix/thread_local_dtor.rs b/library/std/src/sys/unix/thread_local_dtor.rs index 236d2f2ee29..1ce4dd9d846 100644 --- a/library/std/src/sys/unix/thread_local_dtor.rs +++ b/library/std/src/sys/unix/thread_local_dtor.rs @@ -48,7 +48,7 @@ pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) { // workaround below is to register, via _tlv_atexit, a custom DTOR list once per // thread. thread_local dtors are pushed to the DTOR list without calling // _tlv_atexit. -#[cfg(target_os = "macos")] +#[cfg(any(target_os = "macos", target_os = "ios", target_os = "watchos"))] pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) { use crate::cell::Cell; use crate::mem; diff --git a/src/bootstrap/llvm.rs b/src/bootstrap/llvm.rs index aefed501513..29dc3b7acc5 100644 --- a/src/bootstrap/llvm.rs +++ b/src/bootstrap/llvm.rs @@ -703,14 +703,7 @@ fn configure_cmake( cflags.push(" "); cflags.push(s); } - // Some compiler features used by LLVM (such as thread locals) will not work on a min version below iOS 10. - if target.contains("apple-ios") { - if target.contains("86-") { - cflags.push(" -miphonesimulator-version-min=10.0"); - } else { - cflags.push(" -miphoneos-version-min=10.0"); - } - } + if builder.config.llvm_clang_cl.is_some() { cflags.push(&format!(" --target={target}")); } diff --git a/src/doc/rustc/src/platform-support.md b/src/doc/rustc/src/platform-support.md index 2f2a4f44feb..d8c529ca5b9 100644 --- a/src/doc/rustc/src/platform-support.md +++ b/src/doc/rustc/src/platform-support.md @@ -244,7 +244,6 @@ target | std | host | notes `armv6-unknown-freebsd` | ✓ | ✓ | ARMv6 FreeBSD [`armv6-unknown-netbsd-eabihf`](platform-support/netbsd.md) | ✓ | ✓ | ARMv6 NetBSD w/hard-float [`armv6k-nintendo-3ds`](platform-support/armv6k-nintendo-3ds.md) | ? | | ARMv6K Nintendo 3DS, Horizon (Requires devkitARM toolchain) -`armv7-apple-ios` | ✓ | | ARMv7-A Cortex-A8 iOS [`armv7-sony-vita-newlibeabihf`](platform-support/armv7-sony-vita-newlibeabihf.md) | ? | | ARMv7-A Cortex-A9 Sony PlayStation Vita (requires VITASDK toolchain) [`armv7-unknown-linux-ohos`](platform-support/openharmony.md) | ✓ | | ARMv7-A OpenHarmony | [`armv7-unknown-linux-uclibceabi`](platform-support/armv7-unknown-linux-uclibceabi.md) | ✓ | ✓ | ARMv7-A Linux with uClibc, softfloat diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index 778609da062..0f7a3c2f952 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -69,7 +69,6 @@ static TARGETS: &[&str] = &[ "arm-unknown-linux-musleabihf", "armv5te-unknown-linux-gnueabi", "armv5te-unknown-linux-musleabi", - "armv7-apple-ios", "armv7-linux-androideabi", "thumbv7neon-linux-androideabi", "armv7-unknown-linux-gnueabi", From 2044a2d7fa1de37aef704443dc127e5072a5d04c Mon Sep 17 00:00:00 2001 From: BlackHoleFox Date: Sun, 13 Nov 2022 17:25:56 -0600 Subject: [PATCH 30/30] Raise minimum supported tvOS version to 10.0 --- compiler/rustc_target/src/spec/apple_base.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_target/src/spec/apple_base.rs b/compiler/rustc_target/src/spec/apple_base.rs index 9ed06b73197..7a666eea437 100644 --- a/compiler/rustc_target/src/spec/apple_base.rs +++ b/compiler/rustc_target/src/spec/apple_base.rs @@ -322,7 +322,7 @@ pub fn ios_sim_llvm_target(arch: Arch) -> String { fn tvos_deployment_target() -> (u32, u32) { // If you are looking for the default deployment target, prefer `rustc --print deployment-target`. - from_set_deployment_target("TVOS_DEPLOYMENT_TARGET").unwrap_or((7, 0)) + from_set_deployment_target("TVOS_DEPLOYMENT_TARGET").unwrap_or((10, 0)) } fn tvos_lld_platform_version() -> String {