From f46fffc276c19b2c81c9b5e84f4f8678fc4d6d0a Mon Sep 17 00:00:00 2001 From: Jack Wrenn Date: Thu, 18 Aug 2022 19:39:14 +0000 Subject: [PATCH 01/25] safe transmute: use `Assume` struct to provide analysis options This was left as a TODO in #92268, and brings the trait more in line with what was defined in MCP411. `Assume::visibility` has been renamed to `Assume::safety`, as library safety is what's actually being assumed; visibility is just the mechanism by which it is currently checked (this may change). ref: https://github.com/rust-lang/compiler-team/issues/411 ref: https://github.com/rust-lang/rust/issues/99571 --- Cargo.lock | 1 + compiler/rustc_hir/src/lang_items.rs | 3 +- compiler/rustc_span/src/symbol.rs | 5 + .../src/traits/select/confirmation.rs | 20 +- compiler/rustc_transmute/Cargo.toml | 2 + compiler/rustc_transmute/src/lib.rs | 59 ++- .../src/maybe_transmutable/mod.rs | 2 +- .../src/maybe_transmutable/tests.rs | 4 +- library/core/src/lib.rs | 2 + library/core/src/mem/transmutability.rs | 88 +++- .../abstraction/abstracted_assume.rs | 27 +- .../abstraction/const_generic_fn.rs | 6 +- .../arrays/should_have_correct_length.rs | 4 +- .../arrays/should_inherit_alignment.rs | 9 +- .../should_require_well_defined_layout.rs | 9 +- .../should_require_well_defined_layout.stderr | 120 +++-- ...mitive_reprs_should_have_correct_length.rs | 11 +- ...ve_reprs_should_have_correct_length.stderr | 420 ++++++++++++------ .../should_require_well_defined_layout.rs | 11 +- .../should_require_well_defined_layout.stderr | 126 ++++-- .../enums/should_order_correctly.rs | 9 +- .../enums/should_pad_variants.rs | 9 +- .../enums/should_pad_variants.stderr | 20 +- .../enums/should_respect_endianness.rs | 9 +- .../enums/should_respect_endianness.stderr | 20 +- .../unknown_dst.rs | 2 +- .../unknown_src.rs | 2 +- .../unknown_src_field.rs | 2 +- .../wrong-type-assume.rs | 29 +- .../wrong-type-assume.stderr | 37 +- .../ui/transmutability/primitives/bool.rs | 6 +- .../ui/transmutability/primitives/bool.stderr | 6 +- .../ui/transmutability/primitives/numbers.rs | 2 +- .../transmutability/primitives/numbers.stderr | 342 +++++++------- .../ui/transmutability/primitives/unit.rs | 9 +- .../ui/transmutability/primitives/unit.stderr | 20 +- src/test/ui/transmutability/references.rs | 11 +- src/test/ui/transmutability/references.stderr | 21 +- .../structs/repr/should_handle_align.rs | 11 +- .../structs/repr/should_handle_packed.rs | 11 +- .../should_require_well_defined_layout.rs | 11 +- .../should_require_well_defined_layout.stderr | 252 +++++++---- .../structs/should_order_fields_correctly.rs | 9 +- src/test/ui/transmutability/unions/boolish.rs | 4 +- .../unions/repr/should_handle_align.rs | 11 +- .../unions/repr/should_handle_packed.rs | 11 +- .../should_require_well_defined_layout.rs | 11 +- .../should_require_well_defined_layout.stderr | 42 +- .../unions/should_pad_variants.rs | 9 +- .../unions/should_pad_variants.stderr | 20 +- ...mit_intersecting_if_validity_is_assumed.rs | 5 +- .../unions/should_reject_contraction.rs | 4 +- .../unions/should_reject_contraction.stderr | 6 +- .../unions/should_reject_disjoint.rs | 5 +- .../unions/should_reject_disjoint.stderr | 16 +- .../unions/should_reject_intersecting.rs | 6 +- .../unions/should_reject_intersecting.stderr | 12 +- .../should_accept_if_dst_has_private_field.rs | 6 +- ...hould_accept_if_dst_has_private_variant.rs | 6 +- ...ept_if_dst_has_tricky_unreachable_field.rs | 6 +- ...uld_accept_if_dst_has_unreachable_field.rs | 6 +- ...should_accept_if_dst_has_unreachable_ty.rs | 6 +- .../should_accept_if_src_has_private_field.rs | 3 +- ...hould_accept_if_src_has_private_variant.rs | 3 +- ...uld_accept_if_src_has_unreachable_field.rs | 3 +- ...accept_if_src_has_unreachable_field.stderr | 2 +- ...should_accept_if_src_has_unreachable_ty.rs | 3 +- ...ld_accept_if_src_has_unreachable_ty.stderr | 4 +- .../should_reject_if_dst_has_private_field.rs | 3 +- ...uld_reject_if_dst_has_private_field.stderr | 8 +- ...hould_reject_if_dst_has_private_variant.rs | 3 +- ...d_reject_if_dst_has_private_variant.stderr | 8 +- ...ect_if_dst_has_tricky_unreachable_field.rs | 3 +- ...uld_reject_if_dst_has_unreachable_field.rs | 3 +- ...reject_if_dst_has_unreachable_field.stderr | 8 +- ...should_reject_if_dst_has_unreachable_ty.rs | 3 +- ...ld_reject_if_dst_has_unreachable_ty.stderr | 12 +- 77 files changed, 1320 insertions(+), 720 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cb245ce0ff828..ff0e5fde3d1ed 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4581,6 +4581,7 @@ version = "0.1.0" dependencies = [ "itertools", "rustc_data_structures", + "rustc_hir", "rustc_infer", "rustc_macros", "rustc_middle", diff --git a/compiler/rustc_hir/src/lang_items.rs b/compiler/rustc_hir/src/lang_items.rs index c337be12ae492..ccbc225b9ecc5 100644 --- a/compiler/rustc_hir/src/lang_items.rs +++ b/compiler/rustc_hir/src/lang_items.rs @@ -192,7 +192,8 @@ language_item_table! { DispatchFromDyn, sym::dispatch_from_dyn, dispatch_from_dyn_trait, Target::Trait, GenericRequirement::Minimum(1); // language items relating to transmutability - TransmuteTrait, sym::transmute_trait, transmute_trait, Target::Trait, GenericRequirement::Exact(6); + TransmuteOpts, sym::transmute_opts, transmute_opts, Target::Struct, GenericRequirement::Exact(0); + TransmuteTrait, sym::transmute_trait, transmute_trait, Target::Trait, GenericRequirement::Exact(3); Add(Op), sym::add, add_trait, Target::Trait, GenericRequirement::Exact(1); Sub(Op), sym::sub, sub_trait, Target::Trait, GenericRequirement::Exact(1); diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 156f53ac48626..130cc9a854ada 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -334,6 +334,7 @@ symbols! { alias, align, align_offset, + alignment, alignstack, all, alloc, @@ -859,6 +860,7 @@ symbols! { lib, libc, lifetime, + lifetimes, likely, line, line_macro, @@ -1284,6 +1286,7 @@ symbols! { rustfmt, rvalue_static_promotion, s, + safety, sanitize, sanitizer_runtime, saturating_add, @@ -1466,6 +1469,7 @@ symbols! { trait_alias, trait_upcasting, transmute, + transmute_opts, transmute_trait, transparent, transparent_enums, @@ -1560,6 +1564,7 @@ symbols! { va_list, va_start, val, + validity, values, var, variant_count, diff --git a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs index 2a1099fc82abc..e44f66657955e 100644 --- a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs +++ b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs @@ -279,29 +279,17 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { let predicate = obligation.predicate; let type_at = |i| predicate.map_bound(|p| p.trait_ref.substs.type_at(i)); - let bool_at = |i| { - predicate - .skip_binder() - .trait_ref - .substs - .const_at(i) - .try_eval_bool(self.tcx(), obligation.param_env) - .unwrap_or(true) - }; + let const_at = |i| predicate.skip_binder().trait_ref.substs.const_at(i); let src_and_dst = predicate.map_bound(|p| rustc_transmute::Types { - src: p.trait_ref.substs.type_at(1), dst: p.trait_ref.substs.type_at(0), + src: p.trait_ref.substs.type_at(1), }); let scope = type_at(2).skip_binder(); - let assume = rustc_transmute::Assume { - alignment: bool_at(3), - lifetimes: bool_at(4), - validity: bool_at(5), - visibility: bool_at(6), - }; + let assume = + rustc_transmute::Assume::from_const(self.infcx.tcx, obligation.param_env, const_at(3)); let cause = obligation.cause.clone(); diff --git a/compiler/rustc_transmute/Cargo.toml b/compiler/rustc_transmute/Cargo.toml index 9dc96e08a8e27..fa3f45fa235f1 100644 --- a/compiler/rustc_transmute/Cargo.toml +++ b/compiler/rustc_transmute/Cargo.toml @@ -8,6 +8,7 @@ edition = "2021" [dependencies] tracing = "0.1" rustc_data_structures = { path = "../rustc_data_structures", optional = true} +rustc_hir = { path = "../rustc_hir", optional = true} rustc_infer = { path = "../rustc_infer", optional = true} rustc_macros = { path = "../rustc_macros", optional = true} rustc_middle = { path = "../rustc_middle", optional = true} @@ -18,6 +19,7 @@ rustc_target = { path = "../rustc_target", optional = true} rustc = [ "rustc_middle", "rustc_data_structures", + "rustc_hir", "rustc_infer", "rustc_macros", "rustc_span", diff --git a/compiler/rustc_transmute/src/lib.rs b/compiler/rustc_transmute/src/lib.rs index 32e6cb9c64f7f..d7c2119a1c440 100644 --- a/compiler/rustc_transmute/src/lib.rs +++ b/compiler/rustc_transmute/src/lib.rs @@ -26,8 +26,8 @@ pub(crate) mod maybe_transmutable; pub struct Assume { pub alignment: bool, pub lifetimes: bool, + pub safety: bool, pub validity: bool, - pub visibility: bool, } /// The type encodes answers to the question: "Are these types transmutable?" @@ -69,11 +69,17 @@ pub enum Reason { #[cfg(feature = "rustc")] mod rustc { + use super::*; + + use rustc_hir::lang_items::LangItem; use rustc_infer::infer::InferCtxt; use rustc_macros::{TypeFoldable, TypeVisitable}; use rustc_middle::traits::ObligationCause; use rustc_middle::ty::Binder; + use rustc_middle::ty::Const; + use rustc_middle::ty::ParamEnv; use rustc_middle::ty::Ty; + use rustc_middle::ty::TyCtxt; /// The source and destination types of a transmutation. #[derive(TypeFoldable, TypeVisitable, Debug, Clone, Copy)] @@ -113,6 +119,57 @@ mod rustc { .answer() } } + + impl Assume { + /// Constructs an `Assume` from a given const-`Assume`. + pub fn from_const<'tcx>( + tcx: TyCtxt<'tcx>, + param_env: ParamEnv<'tcx>, + c: Const<'tcx>, + ) -> Self { + use rustc_middle::ty::DestructuredConst; + use rustc_middle::ty::TypeVisitable; + use rustc_span::symbol::sym; + + let c = c.eval(tcx, param_env); + + if let Some(err) = c.error_reported() { + return Self { alignment: true, lifetimes: true, safety: true, validity: true }; + } + + let adt_def = c.ty().ty_adt_def().expect("The given `Const` must be an ADT."); + + assert_eq!( + tcx.require_lang_item(LangItem::TransmuteOpts, None), + adt_def.did(), + "The given `Const` was not marked with the `{}` lang item.", + LangItem::TransmuteOpts.name(), + ); + + let DestructuredConst { variant, fields } = tcx.destructure_const(c); + let variant_idx = variant.expect("The given `Const` must be an ADT."); + let variant = adt_def.variant(variant_idx); + + let get_field = |name| { + let (field_idx, _) = variant + .fields + .iter() + .enumerate() + .find(|(_, field_def)| name == field_def.name) + .expect(&format!("There were no fields named `{name}`.")); + fields[field_idx].try_eval_bool(tcx, param_env).expect(&format!( + "The field named `{name}` lang item could not be evaluated to a bool." + )) + }; + + Self { + alignment: get_field(sym::alignment), + lifetimes: get_field(sym::lifetimes), + safety: get_field(sym::safety), + validity: get_field(sym::validity), + } + } + } } #[cfg(feature = "rustc")] diff --git a/compiler/rustc_transmute/src/maybe_transmutable/mod.rs b/compiler/rustc_transmute/src/maybe_transmutable/mod.rs index 076d922d1b72b..b6b6de38f66bc 100644 --- a/compiler/rustc_transmute/src/maybe_transmutable/mod.rs +++ b/compiler/rustc_transmute/src/maybe_transmutable/mod.rs @@ -105,7 +105,7 @@ where #[inline(always)] #[instrument(level = "debug", skip(self), fields(src = ?self.src, dst = ?self.dst))] pub(crate) fn answer(self) -> Answer<::Ref> { - let assume_visibility = self.assume.visibility; + let assume_visibility = self.assume.safety; let query_or_answer = self.map_layouts(|src, dst, scope, context| { // Remove all `Def` nodes from `src`, without checking their visibility. let src = src.prune(&|def| true); diff --git a/compiler/rustc_transmute/src/maybe_transmutable/tests.rs b/compiler/rustc_transmute/src/maybe_transmutable/tests.rs index d9d125687f656..4d5772a4f2ea5 100644 --- a/compiler/rustc_transmute/src/maybe_transmutable/tests.rs +++ b/compiler/rustc_transmute/src/maybe_transmutable/tests.rs @@ -13,7 +13,7 @@ mod bool { layout::Tree::::bool(), layout::Tree::::bool(), (), - crate::Assume { alignment: false, lifetimes: false, validity: true, visibility: false }, + crate::Assume { alignment: false, lifetimes: false, validity: true, safety: false }, UltraMinimal, ) .answer(); @@ -26,7 +26,7 @@ mod bool { layout::Dfa::::bool(), layout::Dfa::::bool(), (), - crate::Assume { alignment: false, lifetimes: false, validity: true, visibility: false }, + crate::Assume { alignment: false, lifetimes: false, validity: true, safety: false }, UltraMinimal, ) .answer(); diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index 24742bb49b9a5..3e54ca996c1a4 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -93,6 +93,7 @@ #![warn(missing_debug_implementations)] #![warn(missing_docs)] #![allow(explicit_outlives_requirements)] +#![allow(incomplete_features)] // // Library features: #![feature(const_align_offset)] @@ -160,6 +161,7 @@ // // Language features: #![feature(abi_unadjusted)] +#![feature(adt_const_params)] #![feature(allow_internal_unsafe)] #![feature(allow_internal_unstable)] #![feature(associated_type_bounds)] diff --git a/library/core/src/mem/transmutability.rs b/library/core/src/mem/transmutability.rs index b4fabedad7829..87a378631050a 100644 --- a/library/core/src/mem/transmutability.rs +++ b/library/core/src/mem/transmutability.rs @@ -4,25 +4,20 @@ /// any value of type `Self` are safely transmutable into a value of type `Dst`, in a given `Context`, /// notwithstanding whatever safety checks you have asked the compiler to [`Assume`] are satisfied. #[unstable(feature = "transmutability", issue = "99571")] -#[lang = "transmute_trait"] +#[cfg_attr(not(bootstrap), lang = "transmute_trait")] #[rustc_on_unimplemented( message = "`{Src}` cannot be safely transmuted into `{Self}` in the defining scope of `{Context}`.", label = "`{Src}` cannot be safely transmuted into `{Self}` in the defining scope of `{Context}`." )] -pub unsafe trait BikeshedIntrinsicFrom< - Src, - Context, - const ASSUME_ALIGNMENT: bool, - const ASSUME_LIFETIMES: bool, - const ASSUME_VALIDITY: bool, - const ASSUME_VISIBILITY: bool, -> where +pub unsafe trait BikeshedIntrinsicFrom +where Src: ?Sized, { } /// What transmutation safety conditions shall the compiler assume that *you* are checking? #[unstable(feature = "transmutability", issue = "99571")] +#[cfg_attr(not(bootstrap), lang = "transmute_opts")] #[derive(PartialEq, Eq, Clone, Copy, Debug)] pub struct Assume { /// When `true`, the compiler assumes that *you* are ensuring (either dynamically or statically) that @@ -33,11 +28,80 @@ pub struct Assume { /// that violates Rust's memory model. pub lifetimes: bool, + /// When `true`, the compiler assumes that *you* have ensured that it is safe for you to violate the + /// type and field privacy of the destination type (and sometimes of the source type, too). + pub safety: bool, + /// When `true`, the compiler assumes that *you* are ensuring that the source type is actually a valid /// instance of the destination type. pub validity: bool, +} - /// When `true`, the compiler assumes that *you* have ensured that it is safe for you to violate the - /// type and field privacy of the destination type (and sometimes of the source type, too). - pub visibility: bool, +impl Assume { + /// Do not assume that *you* have ensured any safety properties are met. + #[unstable(feature = "transmutability", issue = "99571")] + pub const NOTHING: Self = + Self { alignment: false, lifetimes: false, safety: false, validity: false }; + + /// Assume only that alignment conditions are met. + #[unstable(feature = "transmutability", issue = "99571")] + pub const ALIGNMENT: Self = Self { alignment: true, ..Self::NOTHING }; + + /// Assume only that lifetime conditions are met. + #[unstable(feature = "transmutability", issue = "99571")] + pub const LIFETIMES: Self = Self { lifetimes: true, ..Self::NOTHING }; + + /// Assume only that safety conditions are met. + #[unstable(feature = "transmutability", issue = "99571")] + pub const SAFETY: Self = Self { safety: true, ..Self::NOTHING }; + + /// Assume only that dynamically-satisfiable validity conditions are met. + #[unstable(feature = "transmutability", issue = "99571")] + pub const VALIDITY: Self = Self { validity: true, ..Self::NOTHING }; + + /// Assume both `self` and `other_assumptions`. + #[unstable(feature = "transmutability", issue = "99571")] + pub const fn and(self, other_assumptions: Self) -> Self { + Self { + alignment: self.alignment || other_assumptions.alignment, + lifetimes: self.lifetimes || other_assumptions.lifetimes, + safety: self.safety || other_assumptions.safety, + validity: self.validity || other_assumptions.validity, + } + } + + /// Assume `self`, excepting `other_assumptions`. + #[unstable(feature = "transmutability", issue = "99571")] + pub const fn but_not(self, other_assumptions: Self) -> Self { + Self { + alignment: self.alignment && !other_assumptions.alignment, + lifetimes: self.lifetimes && !other_assumptions.lifetimes, + safety: self.safety && !other_assumptions.safety, + validity: self.validity && !other_assumptions.validity, + } + } +} + +// FIXME(jswrenn): This const op is not actually usable. Why? +// https://github.com/rust-lang/rust/pull/100726#issuecomment-1219928926 +#[unstable(feature = "transmutability", issue = "99571")] +#[rustc_const_unstable(feature = "transmutability", issue = "99571")] +impl const core::ops::Add for Assume { + type Output = Assume; + + fn add(self, other_assumptions: Assume) -> Assume { + self.and(other_assumptions) + } +} + +// FIXME(jswrenn): This const op is not actually usable. Why? +// https://github.com/rust-lang/rust/pull/100726#issuecomment-1219928926 +#[unstable(feature = "transmutability", issue = "99571")] +#[rustc_const_unstable(feature = "transmutability", issue = "99571")] +impl const core::ops::Sub for Assume { + type Output = Assume; + + fn sub(self, other_assumptions: Assume) -> Assume { + self.but_not(other_assumptions) + } } diff --git a/src/test/ui/transmutability/abstraction/abstracted_assume.rs b/src/test/ui/transmutability/abstraction/abstracted_assume.rs index 2abbbf3c158d6..0225c4230dc4d 100644 --- a/src/test/ui/transmutability/abstraction/abstracted_assume.rs +++ b/src/test/ui/transmutability/abstraction/abstracted_assume.rs @@ -3,6 +3,7 @@ //! provided indirectly through an abstraction. #![crate_type = "lib"] +#![feature(adt_const_params)] #![feature(transmutability)] #![allow(dead_code, incomplete_features, non_camel_case_types)] @@ -13,19 +14,13 @@ mod assert { Src, Dst, Context, - const ASSUME_ALIGNMENT: bool, - const ASSUME_LIFETIMES: bool, - const ASSUME_VALIDITY: bool, - const ASSUME_VISIBILITY: bool, + const ASSUME: std::mem::Assume, >() where Dst: BikeshedIntrinsicFrom< Src, Context, - ASSUME_ALIGNMENT, - ASSUME_LIFETIMES, - ASSUME_VALIDITY, - ASSUME_VISIBILITY, + ASSUME, >, {} } @@ -35,7 +30,7 @@ fn direct() { #[repr(C)] struct Src; #[repr(C)] struct Dst; - assert::is_transmutable::(); + assert::is_transmutable::(); } fn via_const() { @@ -45,7 +40,7 @@ fn via_const() { const FALSE: bool = false; - assert::is_transmutable::(); + assert::is_transmutable::(); } fn via_associated_const() { @@ -65,9 +60,13 @@ fn via_associated_const() { Src, Dst, Context, - {Ty::FALSE}, - {Ty::FALSE}, - {Ty::FALSE}, - {Ty::FALSE} + { + std::mem::Assume { + alignment: {Ty::FALSE}, + lifetimes: {Ty::FALSE}, + safety: {Ty::FALSE}, + validity: {Ty::FALSE}, + } + } >(); } diff --git a/src/test/ui/transmutability/abstraction/const_generic_fn.rs b/src/test/ui/transmutability/abstraction/const_generic_fn.rs index 94c38bb28f7e2..e693a09570f3a 100644 --- a/src/test/ui/transmutability/abstraction/const_generic_fn.rs +++ b/src/test/ui/transmutability/abstraction/const_generic_fn.rs @@ -6,13 +6,13 @@ #![allow(dead_code, incomplete_features, non_camel_case_types)] mod assert { - use std::mem::BikeshedIntrinsicFrom; + use std::mem::{Assume, BikeshedIntrinsicFrom}; pub struct Context; pub fn array_like() where - T: BikeshedIntrinsicFrom<[E; N], Context, false, false, false, true>, - [E; N]: BikeshedIntrinsicFrom + T: BikeshedIntrinsicFrom<[E; N], Context, { Assume::SAFETY }>, + [E; N]: BikeshedIntrinsicFrom {} } diff --git a/src/test/ui/transmutability/arrays/should_have_correct_length.rs b/src/test/ui/transmutability/arrays/should_have_correct_length.rs index bfe6d830a1be7..353797d0c4bb0 100644 --- a/src/test/ui/transmutability/arrays/should_have_correct_length.rs +++ b/src/test/ui/transmutability/arrays/should_have_correct_length.rs @@ -6,12 +6,12 @@ #![allow(dead_code, incomplete_features, non_camel_case_types)] mod assert { - use std::mem::BikeshedIntrinsicFrom; + use std::mem::{Assume, BikeshedIntrinsicFrom}; pub struct Context; pub fn is_maybe_transmutable() where - Dst: BikeshedIntrinsicFrom + Dst: BikeshedIntrinsicFrom {} } diff --git a/src/test/ui/transmutability/arrays/should_inherit_alignment.rs b/src/test/ui/transmutability/arrays/should_inherit_alignment.rs index fcb1765ea6bb4..b00e5c7e4008c 100644 --- a/src/test/ui/transmutability/arrays/should_inherit_alignment.rs +++ b/src/test/ui/transmutability/arrays/should_inherit_alignment.rs @@ -6,12 +6,17 @@ #![allow(dead_code, incomplete_features, non_camel_case_types)] mod assert { - use std::mem::BikeshedIntrinsicFrom; + use std::mem::{Assume, BikeshedIntrinsicFrom}; pub struct Context; pub fn is_maybe_transmutable() where - Dst: BikeshedIntrinsicFrom + Dst: BikeshedIntrinsicFrom {} } diff --git a/src/test/ui/transmutability/arrays/should_require_well_defined_layout.rs b/src/test/ui/transmutability/arrays/should_require_well_defined_layout.rs index 8e69527c1862c..853bd9cbc0fb3 100644 --- a/src/test/ui/transmutability/arrays/should_require_well_defined_layout.rs +++ b/src/test/ui/transmutability/arrays/should_require_well_defined_layout.rs @@ -5,12 +5,17 @@ #![allow(dead_code, incomplete_features, non_camel_case_types)] mod assert { - use std::mem::BikeshedIntrinsicFrom; + use std::mem::{Assume, BikeshedIntrinsicFrom}; pub struct Context; pub fn is_maybe_transmutable() where - Dst: BikeshedIntrinsicFrom + Dst: BikeshedIntrinsicFrom {} } diff --git a/src/test/ui/transmutability/arrays/should_require_well_defined_layout.stderr b/src/test/ui/transmutability/arrays/should_require_well_defined_layout.stderr index eae0c947d4253..96a2fdc54dbb4 100644 --- a/src/test/ui/transmutability/arrays/should_require_well_defined_layout.stderr +++ b/src/test/ui/transmutability/arrays/should_require_well_defined_layout.stderr @@ -1,98 +1,134 @@ error[E0277]: `[String; 0]` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. - --> $DIR/should_require_well_defined_layout.rs:21:52 + --> $DIR/should_require_well_defined_layout.rs:26:52 | LL | assert::is_maybe_transmutable::(); | ^^ `[String; 0]` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom<[String; 0], assert::Context, true, true, true, true>` is not implemented for `()` + = help: the trait `BikeshedIntrinsicFrom<[String; 0], assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `()` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_require_well_defined_layout.rs:13:14 | -LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` +LL | pub fn is_maybe_transmutable() + | --------------------- required by a bound in this +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_maybe_transmutable` error[E0277]: `u128` cannot be safely transmuted into `[String; 0]` in the defining scope of `assert::Context`. - --> $DIR/should_require_well_defined_layout.rs:22:47 + --> $DIR/should_require_well_defined_layout.rs:27:47 | LL | assert::is_maybe_transmutable::(); | ^^^^^^^^^ `u128` cannot be safely transmuted into `[String; 0]` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `[String; 0]` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `[String; 0]` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_require_well_defined_layout.rs:13:14 | -LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` +LL | pub fn is_maybe_transmutable() + | --------------------- required by a bound in this +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_maybe_transmutable` error[E0277]: `[String; 1]` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. - --> $DIR/should_require_well_defined_layout.rs:27:52 + --> $DIR/should_require_well_defined_layout.rs:32:52 | LL | assert::is_maybe_transmutable::(); | ^^ `[String; 1]` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom<[String; 1], assert::Context, true, true, true, true>` is not implemented for `()` + = help: the trait `BikeshedIntrinsicFrom<[String; 1], assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `()` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_require_well_defined_layout.rs:13:14 | -LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` +LL | pub fn is_maybe_transmutable() + | --------------------- required by a bound in this +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_maybe_transmutable` error[E0277]: `u128` cannot be safely transmuted into `[String; 1]` in the defining scope of `assert::Context`. - --> $DIR/should_require_well_defined_layout.rs:28:47 + --> $DIR/should_require_well_defined_layout.rs:33:47 | LL | assert::is_maybe_transmutable::(); | ^^^^^^^^^ `u128` cannot be safely transmuted into `[String; 1]` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `[String; 1]` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `[String; 1]` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_require_well_defined_layout.rs:13:14 | -LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` +LL | pub fn is_maybe_transmutable() + | --------------------- required by a bound in this +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_maybe_transmutable` error[E0277]: `[String; 2]` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. - --> $DIR/should_require_well_defined_layout.rs:33:52 + --> $DIR/should_require_well_defined_layout.rs:38:52 | LL | assert::is_maybe_transmutable::(); | ^^ `[String; 2]` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom<[String; 2], assert::Context, true, true, true, true>` is not implemented for `()` + = help: the trait `BikeshedIntrinsicFrom<[String; 2], assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `()` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_require_well_defined_layout.rs:13:14 | -LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` +LL | pub fn is_maybe_transmutable() + | --------------------- required by a bound in this +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_maybe_transmutable` error[E0277]: `u128` cannot be safely transmuted into `[String; 2]` in the defining scope of `assert::Context`. - --> $DIR/should_require_well_defined_layout.rs:34:47 + --> $DIR/should_require_well_defined_layout.rs:39:47 | LL | assert::is_maybe_transmutable::(); | ^^^^^^^^^ `u128` cannot be safely transmuted into `[String; 2]` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `[String; 2]` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `[String; 2]` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_require_well_defined_layout.rs:13:14 | -LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` +LL | pub fn is_maybe_transmutable() + | --------------------- required by a bound in this +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_maybe_transmutable` error: aborting due to 6 previous errors diff --git a/src/test/ui/transmutability/enums/repr/primitive_reprs_should_have_correct_length.rs b/src/test/ui/transmutability/enums/repr/primitive_reprs_should_have_correct_length.rs index 18e02b0d2b908..940f070e7e360 100644 --- a/src/test/ui/transmutability/enums/repr/primitive_reprs_should_have_correct_length.rs +++ b/src/test/ui/transmutability/enums/repr/primitive_reprs_should_have_correct_length.rs @@ -5,11 +5,18 @@ #![allow(dead_code)] mod assert { - use std::mem::BikeshedIntrinsicFrom; + use std::mem::{Assume, BikeshedIntrinsicFrom}; pub fn is_transmutable() where - Dst: BikeshedIntrinsicFrom + Dst: BikeshedIntrinsicFrom {} } diff --git a/src/test/ui/transmutability/enums/repr/primitive_reprs_should_have_correct_length.stderr b/src/test/ui/transmutability/enums/repr/primitive_reprs_should_have_correct_length.stderr index fa2e3b89b079a..4da5fcea3374c 100644 --- a/src/test/ui/transmutability/enums/repr/primitive_reprs_should_have_correct_length.stderr +++ b/src/test/ui/transmutability/enums/repr/primitive_reprs_should_have_correct_length.stderr @@ -1,322 +1,462 @@ error[E0277]: `Zst` cannot be safely transmuted into `V0i8` in the defining scope of `n8::Context`. - --> $DIR/primitive_reprs_should_have_correct_length.rs:41:44 + --> $DIR/primitive_reprs_should_have_correct_length.rs:48:44 | LL | assert::is_transmutable::(); | ^^^^^^^ `Zst` cannot be safely transmuted into `V0i8` in the defining scope of `n8::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `V0i8` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `V0i8` note: required by a bound in `is_transmutable` --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | -LL | pub fn is_transmutable() - | --------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | pub fn is_transmutable() + | --------------- required by a bound in this +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_transmutable` error[E0277]: `V0i8` cannot be safely transmuted into `u16` in the defining scope of `n8::Context`. - --> $DIR/primitive_reprs_should_have_correct_length.rs:43:44 + --> $DIR/primitive_reprs_should_have_correct_length.rs:50:44 | LL | assert::is_transmutable::(); | ^^^^^^ `V0i8` cannot be safely transmuted into `u16` in the defining scope of `n8::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u16` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u16` note: required by a bound in `is_transmutable` --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | -LL | pub fn is_transmutable() - | --------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | pub fn is_transmutable() + | --------------- required by a bound in this +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_transmutable` error[E0277]: `Zst` cannot be safely transmuted into `V0u8` in the defining scope of `n8::Context`. - --> $DIR/primitive_reprs_should_have_correct_length.rs:49:44 + --> $DIR/primitive_reprs_should_have_correct_length.rs:56:44 | LL | assert::is_transmutable::(); | ^^^^^^^ `Zst` cannot be safely transmuted into `V0u8` in the defining scope of `n8::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `V0u8` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `V0u8` note: required by a bound in `is_transmutable` --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | -LL | pub fn is_transmutable() - | --------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | pub fn is_transmutable() + | --------------- required by a bound in this +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_transmutable` error[E0277]: `V0u8` cannot be safely transmuted into `u16` in the defining scope of `n8::Context`. - --> $DIR/primitive_reprs_should_have_correct_length.rs:51:44 + --> $DIR/primitive_reprs_should_have_correct_length.rs:58:44 | LL | assert::is_transmutable::(); | ^^^^^^ `V0u8` cannot be safely transmuted into `u16` in the defining scope of `n8::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u16` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u16` note: required by a bound in `is_transmutable` --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | -LL | pub fn is_transmutable() - | --------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | pub fn is_transmutable() + | --------------- required by a bound in this +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_transmutable` error[E0277]: `u8` cannot be safely transmuted into `V0i16` in the defining scope of `n16::Context`. - --> $DIR/primitive_reprs_should_have_correct_length.rs:65:44 + --> $DIR/primitive_reprs_should_have_correct_length.rs:72:44 | LL | assert::is_transmutable::(); | ^^^^^^^ `u8` cannot be safely transmuted into `V0i16` in the defining scope of `n16::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `V0i16` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `V0i16` note: required by a bound in `is_transmutable` --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | -LL | pub fn is_transmutable() - | --------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | pub fn is_transmutable() + | --------------- required by a bound in this +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_transmutable` error[E0277]: `V0i16` cannot be safely transmuted into `u32` in the defining scope of `n16::Context`. - --> $DIR/primitive_reprs_should_have_correct_length.rs:67:44 + --> $DIR/primitive_reprs_should_have_correct_length.rs:74:44 | LL | assert::is_transmutable::(); | ^^^^^^ `V0i16` cannot be safely transmuted into `u32` in the defining scope of `n16::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u32` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u32` note: required by a bound in `is_transmutable` --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | -LL | pub fn is_transmutable() - | --------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | pub fn is_transmutable() + | --------------- required by a bound in this +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_transmutable` error[E0277]: `u8` cannot be safely transmuted into `V0u16` in the defining scope of `n16::Context`. - --> $DIR/primitive_reprs_should_have_correct_length.rs:73:44 + --> $DIR/primitive_reprs_should_have_correct_length.rs:80:44 | LL | assert::is_transmutable::(); | ^^^^^^^ `u8` cannot be safely transmuted into `V0u16` in the defining scope of `n16::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `V0u16` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `V0u16` note: required by a bound in `is_transmutable` --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | -LL | pub fn is_transmutable() - | --------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | pub fn is_transmutable() + | --------------- required by a bound in this +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_transmutable` error[E0277]: `V0u16` cannot be safely transmuted into `u32` in the defining scope of `n16::Context`. - --> $DIR/primitive_reprs_should_have_correct_length.rs:75:44 + --> $DIR/primitive_reprs_should_have_correct_length.rs:82:44 | LL | assert::is_transmutable::(); | ^^^^^^ `V0u16` cannot be safely transmuted into `u32` in the defining scope of `n16::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u32` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u32` note: required by a bound in `is_transmutable` --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | -LL | pub fn is_transmutable() - | --------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | pub fn is_transmutable() + | --------------- required by a bound in this +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_transmutable` error[E0277]: `u16` cannot be safely transmuted into `V0i32` in the defining scope of `n32::Context`. - --> $DIR/primitive_reprs_should_have_correct_length.rs:89:44 + --> $DIR/primitive_reprs_should_have_correct_length.rs:96:44 | LL | assert::is_transmutable::(); | ^^^^^^^ `u16` cannot be safely transmuted into `V0i32` in the defining scope of `n32::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `V0i32` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `V0i32` note: required by a bound in `is_transmutable` --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | -LL | pub fn is_transmutable() - | --------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | pub fn is_transmutable() + | --------------- required by a bound in this +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_transmutable` error[E0277]: `V0i32` cannot be safely transmuted into `u64` in the defining scope of `n32::Context`. - --> $DIR/primitive_reprs_should_have_correct_length.rs:91:44 + --> $DIR/primitive_reprs_should_have_correct_length.rs:98:44 | LL | assert::is_transmutable::(); | ^^^^^^ `V0i32` cannot be safely transmuted into `u64` in the defining scope of `n32::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u64` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u64` note: required by a bound in `is_transmutable` --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | -LL | pub fn is_transmutable() - | --------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | pub fn is_transmutable() + | --------------- required by a bound in this +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_transmutable` error[E0277]: `u16` cannot be safely transmuted into `V0u32` in the defining scope of `n32::Context`. - --> $DIR/primitive_reprs_should_have_correct_length.rs:97:44 + --> $DIR/primitive_reprs_should_have_correct_length.rs:104:44 | LL | assert::is_transmutable::(); | ^^^^^^^ `u16` cannot be safely transmuted into `V0u32` in the defining scope of `n32::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `V0u32` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `V0u32` note: required by a bound in `is_transmutable` --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | -LL | pub fn is_transmutable() - | --------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | pub fn is_transmutable() + | --------------- required by a bound in this +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_transmutable` error[E0277]: `V0u32` cannot be safely transmuted into `u64` in the defining scope of `n32::Context`. - --> $DIR/primitive_reprs_should_have_correct_length.rs:99:44 + --> $DIR/primitive_reprs_should_have_correct_length.rs:106:44 | LL | assert::is_transmutable::(); | ^^^^^^ `V0u32` cannot be safely transmuted into `u64` in the defining scope of `n32::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u64` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u64` note: required by a bound in `is_transmutable` --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | -LL | pub fn is_transmutable() - | --------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | pub fn is_transmutable() + | --------------- required by a bound in this +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_transmutable` error[E0277]: `u32` cannot be safely transmuted into `V0i64` in the defining scope of `n64::Context`. - --> $DIR/primitive_reprs_should_have_correct_length.rs:113:44 + --> $DIR/primitive_reprs_should_have_correct_length.rs:120:44 | LL | assert::is_transmutable::(); | ^^^^^^^ `u32` cannot be safely transmuted into `V0i64` in the defining scope of `n64::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `V0i64` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `V0i64` note: required by a bound in `is_transmutable` --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | -LL | pub fn is_transmutable() - | --------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | pub fn is_transmutable() + | --------------- required by a bound in this +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_transmutable` error[E0277]: `V0i64` cannot be safely transmuted into `u128` in the defining scope of `n64::Context`. - --> $DIR/primitive_reprs_should_have_correct_length.rs:115:44 + --> $DIR/primitive_reprs_should_have_correct_length.rs:122:44 | LL | assert::is_transmutable::(); | ^^^^^^ `V0i64` cannot be safely transmuted into `u128` in the defining scope of `n64::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u128` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u128` note: required by a bound in `is_transmutable` --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | -LL | pub fn is_transmutable() - | --------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | pub fn is_transmutable() + | --------------- required by a bound in this +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_transmutable` error[E0277]: `u32` cannot be safely transmuted into `V0u64` in the defining scope of `n64::Context`. - --> $DIR/primitive_reprs_should_have_correct_length.rs:121:44 + --> $DIR/primitive_reprs_should_have_correct_length.rs:128:44 | LL | assert::is_transmutable::(); | ^^^^^^^ `u32` cannot be safely transmuted into `V0u64` in the defining scope of `n64::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `V0u64` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `V0u64` note: required by a bound in `is_transmutable` --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | -LL | pub fn is_transmutable() - | --------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | pub fn is_transmutable() + | --------------- required by a bound in this +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_transmutable` error[E0277]: `V0u64` cannot be safely transmuted into `u128` in the defining scope of `n64::Context`. - --> $DIR/primitive_reprs_should_have_correct_length.rs:123:44 + --> $DIR/primitive_reprs_should_have_correct_length.rs:130:44 | LL | assert::is_transmutable::(); | ^^^^^^ `V0u64` cannot be safely transmuted into `u128` in the defining scope of `n64::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u128` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u128` note: required by a bound in `is_transmutable` --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | -LL | pub fn is_transmutable() - | --------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | pub fn is_transmutable() + | --------------- required by a bound in this +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_transmutable` error[E0277]: `u8` cannot be safely transmuted into `V0isize` in the defining scope of `nsize::Context`. - --> $DIR/primitive_reprs_should_have_correct_length.rs:137:44 + --> $DIR/primitive_reprs_should_have_correct_length.rs:144:44 | LL | assert::is_transmutable::(); | ^^^^^^^ `u8` cannot be safely transmuted into `V0isize` in the defining scope of `nsize::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `V0isize` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `V0isize` note: required by a bound in `is_transmutable` --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | -LL | pub fn is_transmutable() - | --------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | pub fn is_transmutable() + | --------------- required by a bound in this +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_transmutable` error[E0277]: `V0isize` cannot be safely transmuted into `[usize; 2]` in the defining scope of `nsize::Context`. - --> $DIR/primitive_reprs_should_have_correct_length.rs:139:44 + --> $DIR/primitive_reprs_should_have_correct_length.rs:146:44 | LL | assert::is_transmutable::(); | ^^^^^^ `V0isize` cannot be safely transmuted into `[usize; 2]` in the defining scope of `nsize::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `[usize; 2]` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `[usize; 2]` note: required by a bound in `is_transmutable` --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | -LL | pub fn is_transmutable() - | --------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | pub fn is_transmutable() + | --------------- required by a bound in this +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_transmutable` error[E0277]: `u8` cannot be safely transmuted into `V0usize` in the defining scope of `nsize::Context`. - --> $DIR/primitive_reprs_should_have_correct_length.rs:145:44 + --> $DIR/primitive_reprs_should_have_correct_length.rs:152:44 | LL | assert::is_transmutable::(); | ^^^^^^^ `u8` cannot be safely transmuted into `V0usize` in the defining scope of `nsize::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `V0usize` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `V0usize` note: required by a bound in `is_transmutable` --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | -LL | pub fn is_transmutable() - | --------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | pub fn is_transmutable() + | --------------- required by a bound in this +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_transmutable` error[E0277]: `V0usize` cannot be safely transmuted into `[usize; 2]` in the defining scope of `nsize::Context`. - --> $DIR/primitive_reprs_should_have_correct_length.rs:147:44 + --> $DIR/primitive_reprs_should_have_correct_length.rs:154:44 | LL | assert::is_transmutable::(); | ^^^^^^ `V0usize` cannot be safely transmuted into `[usize; 2]` in the defining scope of `nsize::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `[usize; 2]` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `[usize; 2]` note: required by a bound in `is_transmutable` --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | -LL | pub fn is_transmutable() - | --------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | pub fn is_transmutable() + | --------------- required by a bound in this +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_transmutable` error: aborting due to 20 previous errors diff --git a/src/test/ui/transmutability/enums/repr/should_require_well_defined_layout.rs b/src/test/ui/transmutability/enums/repr/should_require_well_defined_layout.rs index 978a12648f03a..102111ae291c6 100644 --- a/src/test/ui/transmutability/enums/repr/should_require_well_defined_layout.rs +++ b/src/test/ui/transmutability/enums/repr/should_require_well_defined_layout.rs @@ -6,12 +6,19 @@ #![allow(dead_code, incomplete_features, non_camel_case_types)] mod assert { - use std::mem::BikeshedIntrinsicFrom; + use std::mem::{Assume, BikeshedIntrinsicFrom}; pub struct Context; pub fn is_maybe_transmutable() where - Dst: BikeshedIntrinsicFrom + Dst: BikeshedIntrinsicFrom {} } diff --git a/src/test/ui/transmutability/enums/repr/should_require_well_defined_layout.stderr b/src/test/ui/transmutability/enums/repr/should_require_well_defined_layout.stderr index 3273e87c89ff4..510b8c56e5ab8 100644 --- a/src/test/ui/transmutability/enums/repr/should_require_well_defined_layout.stderr +++ b/src/test/ui/transmutability/enums/repr/should_require_well_defined_layout.stderr @@ -1,98 +1,140 @@ error[E0277]: `void::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. - --> $DIR/should_require_well_defined_layout.rs:21:52 + --> $DIR/should_require_well_defined_layout.rs:28:52 | LL | assert::is_maybe_transmutable::(); | ^^ `void::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `()` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `()` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_require_well_defined_layout.rs:14:14 | -LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` +LL | pub fn is_maybe_transmutable() + | --------------------- required by a bound in this +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_maybe_transmutable` error[E0277]: `u128` cannot be safely transmuted into `void::repr_rust` in the defining scope of `assert::Context`. - --> $DIR/should_require_well_defined_layout.rs:22:47 + --> $DIR/should_require_well_defined_layout.rs:29:47 | LL | assert::is_maybe_transmutable::(); | ^^^^^^^^^ `u128` cannot be safely transmuted into `void::repr_rust` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `void::repr_rust` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `void::repr_rust` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_require_well_defined_layout.rs:14:14 | -LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` +LL | pub fn is_maybe_transmutable() + | --------------------- required by a bound in this +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_maybe_transmutable` error[E0277]: `singleton::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. - --> $DIR/should_require_well_defined_layout.rs:27:52 + --> $DIR/should_require_well_defined_layout.rs:34:52 | LL | assert::is_maybe_transmutable::(); | ^^ `singleton::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `()` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `()` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_require_well_defined_layout.rs:14:14 | -LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` +LL | pub fn is_maybe_transmutable() + | --------------------- required by a bound in this +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_maybe_transmutable` error[E0277]: `u128` cannot be safely transmuted into `singleton::repr_rust` in the defining scope of `assert::Context`. - --> $DIR/should_require_well_defined_layout.rs:28:47 + --> $DIR/should_require_well_defined_layout.rs:35:47 | LL | assert::is_maybe_transmutable::(); | ^^^^^^^^^ `u128` cannot be safely transmuted into `singleton::repr_rust` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `singleton::repr_rust` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `singleton::repr_rust` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_require_well_defined_layout.rs:14:14 | -LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` +LL | pub fn is_maybe_transmutable() + | --------------------- required by a bound in this +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_maybe_transmutable` error[E0277]: `duplex::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. - --> $DIR/should_require_well_defined_layout.rs:33:52 + --> $DIR/should_require_well_defined_layout.rs:40:52 | LL | assert::is_maybe_transmutable::(); | ^^ `duplex::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `()` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `()` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_require_well_defined_layout.rs:14:14 | -LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` +LL | pub fn is_maybe_transmutable() + | --------------------- required by a bound in this +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_maybe_transmutable` error[E0277]: `u128` cannot be safely transmuted into `duplex::repr_rust` in the defining scope of `assert::Context`. - --> $DIR/should_require_well_defined_layout.rs:34:47 + --> $DIR/should_require_well_defined_layout.rs:41:47 | LL | assert::is_maybe_transmutable::(); | ^^^^^^^^^ `u128` cannot be safely transmuted into `duplex::repr_rust` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `duplex::repr_rust` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `duplex::repr_rust` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_require_well_defined_layout.rs:14:14 | -LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` +LL | pub fn is_maybe_transmutable() + | --------------------- required by a bound in this +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_maybe_transmutable` error: aborting due to 6 previous errors diff --git a/src/test/ui/transmutability/enums/should_order_correctly.rs b/src/test/ui/transmutability/enums/should_order_correctly.rs index 6558d2658ee45..b753cf0e62d59 100644 --- a/src/test/ui/transmutability/enums/should_order_correctly.rs +++ b/src/test/ui/transmutability/enums/should_order_correctly.rs @@ -7,12 +7,17 @@ #![allow(dead_code)] mod assert { - use std::mem::BikeshedIntrinsicFrom; + use std::mem::{Assume, BikeshedIntrinsicFrom}; pub struct Context; pub fn is_transmutable() where - Dst: BikeshedIntrinsicFrom + Dst: BikeshedIntrinsicFrom {} } diff --git a/src/test/ui/transmutability/enums/should_pad_variants.rs b/src/test/ui/transmutability/enums/should_pad_variants.rs index 466b6c8a15b52..c077c52a36ac7 100644 --- a/src/test/ui/transmutability/enums/should_pad_variants.rs +++ b/src/test/ui/transmutability/enums/should_pad_variants.rs @@ -6,11 +6,16 @@ #![allow(dead_code)] mod assert { - use std::mem::BikeshedIntrinsicFrom; + use std::mem::{Assume, BikeshedIntrinsicFrom}; pub fn is_transmutable() where - Dst: BikeshedIntrinsicFrom + Dst: BikeshedIntrinsicFrom {} } diff --git a/src/test/ui/transmutability/enums/should_pad_variants.stderr b/src/test/ui/transmutability/enums/should_pad_variants.stderr index 429f7211d17a8..a823503d594e9 100644 --- a/src/test/ui/transmutability/enums/should_pad_variants.stderr +++ b/src/test/ui/transmutability/enums/should_pad_variants.stderr @@ -1,18 +1,24 @@ error[E0277]: `Src` cannot be safely transmuted into `Dst` in the defining scope of `should_pad_variants::Context`. - --> $DIR/should_pad_variants.rs:39:36 + --> $DIR/should_pad_variants.rs:44:36 | LL | assert::is_transmutable::(); | ^^^ `Src` cannot be safely transmuted into `Dst` in the defining scope of `should_pad_variants::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `Dst` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `Dst` note: required by a bound in `is_transmutable` --> $DIR/should_pad_variants.rs:13:14 | -LL | pub fn is_transmutable() - | --------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | pub fn is_transmutable() + | --------------- required by a bound in this +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_transmutable` error: aborting due to previous error diff --git a/src/test/ui/transmutability/enums/should_respect_endianness.rs b/src/test/ui/transmutability/enums/should_respect_endianness.rs index 67a3c4e94ba8f..19ff690050031 100644 --- a/src/test/ui/transmutability/enums/should_respect_endianness.rs +++ b/src/test/ui/transmutability/enums/should_respect_endianness.rs @@ -7,12 +7,17 @@ #![allow(dead_code)] mod assert { - use std::mem::BikeshedIntrinsicFrom; + use std::mem::{Assume, BikeshedIntrinsicFrom}; pub struct Context; pub fn is_transmutable() where - Dst: BikeshedIntrinsicFrom + Dst: BikeshedIntrinsicFrom {} } diff --git a/src/test/ui/transmutability/enums/should_respect_endianness.stderr b/src/test/ui/transmutability/enums/should_respect_endianness.stderr index 78023cb378aca..fcb70813bd961 100644 --- a/src/test/ui/transmutability/enums/should_respect_endianness.stderr +++ b/src/test/ui/transmutability/enums/should_respect_endianness.stderr @@ -1,18 +1,24 @@ error[E0277]: `Src` cannot be safely transmuted into `Unexpected` in the defining scope of `assert::Context`. - --> $DIR/should_respect_endianness.rs:32:36 + --> $DIR/should_respect_endianness.rs:37:36 | LL | assert::is_transmutable::(); | ^^^^^^^^^^ `Src` cannot be safely transmuted into `Unexpected` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `Unexpected` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `Unexpected` note: required by a bound in `is_transmutable` --> $DIR/should_respect_endianness.rs:15:14 | -LL | pub fn is_transmutable() - | --------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | pub fn is_transmutable() + | --------------- required by a bound in this +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_transmutable` error: aborting due to previous error diff --git a/src/test/ui/transmutability/malformed-program-gracefulness/unknown_dst.rs b/src/test/ui/transmutability/malformed-program-gracefulness/unknown_dst.rs index e13462d390b03..b3a1e13b85bed 100644 --- a/src/test/ui/transmutability/malformed-program-gracefulness/unknown_dst.rs +++ b/src/test/ui/transmutability/malformed-program-gracefulness/unknown_dst.rs @@ -10,7 +10,7 @@ mod assert { pub fn is_transmutable() where - Dst: BikeshedIntrinsicFrom + Dst: BikeshedIntrinsicFrom {} } diff --git a/src/test/ui/transmutability/malformed-program-gracefulness/unknown_src.rs b/src/test/ui/transmutability/malformed-program-gracefulness/unknown_src.rs index dc51e2a8f4d2b..092b205b77027 100644 --- a/src/test/ui/transmutability/malformed-program-gracefulness/unknown_src.rs +++ b/src/test/ui/transmutability/malformed-program-gracefulness/unknown_src.rs @@ -10,7 +10,7 @@ mod assert { pub fn is_transmutable() where - Dst: BikeshedIntrinsicFrom + Dst: BikeshedIntrinsicFrom {} } diff --git a/src/test/ui/transmutability/malformed-program-gracefulness/unknown_src_field.rs b/src/test/ui/transmutability/malformed-program-gracefulness/unknown_src_field.rs index 86fc8bd6b2856..ebe34e13432b5 100644 --- a/src/test/ui/transmutability/malformed-program-gracefulness/unknown_src_field.rs +++ b/src/test/ui/transmutability/malformed-program-gracefulness/unknown_src_field.rs @@ -10,7 +10,7 @@ mod assert { pub fn is_transmutable() where - Dst: BikeshedIntrinsicFrom + Dst: BikeshedIntrinsicFrom {} } diff --git a/src/test/ui/transmutability/malformed-program-gracefulness/wrong-type-assume.rs b/src/test/ui/transmutability/malformed-program-gracefulness/wrong-type-assume.rs index bd36748e7901b..354abf99d4d07 100644 --- a/src/test/ui/transmutability/malformed-program-gracefulness/wrong-type-assume.rs +++ b/src/test/ui/transmutability/malformed-program-gracefulness/wrong-type-assume.rs @@ -2,11 +2,13 @@ //! provided. #![crate_type = "lib"] +#![feature(adt_const_params)] +#![feature(generic_const_exprs)] #![feature(transmutability)] #![allow(dead_code, incomplete_features, non_camel_case_types)] mod assert { - use std::mem::BikeshedIntrinsicFrom; + use std::mem::{Assume, BikeshedIntrinsicFrom}; pub fn is_transmutable< Src, @@ -14,19 +16,34 @@ mod assert { Context, const ASSUME_ALIGNMENT: bool, const ASSUME_LIFETIMES: bool, + const ASSUME_SAFETY: bool, const ASSUME_VALIDITY: bool, - const ASSUME_VISIBILITY: bool, >() where Dst: BikeshedIntrinsicFrom< Src, Context, - ASSUME_ALIGNMENT, - ASSUME_LIFETIMES, - ASSUME_VALIDITY, - ASSUME_VISIBILITY, + { from_options(ASSUME_ALIGNMENT, ASSUME_LIFETIMES, ASSUME_SAFETY, ASSUME_VALIDITY) } + //~^ ERROR E0080 + //~| ERROR E0080 + //~| ERROR E0080 + //~| ERROR E0080 >, {} + + const fn from_options( + alignment: bool, + lifetimes: bool, + safety: bool, + validity: bool, + ) -> Assume { + Assume { + alignment, + lifetimes, + safety, + validity, + } + } } fn test() { diff --git a/src/test/ui/transmutability/malformed-program-gracefulness/wrong-type-assume.stderr b/src/test/ui/transmutability/malformed-program-gracefulness/wrong-type-assume.stderr index e1464e02352c6..a258f2ecea6d9 100644 --- a/src/test/ui/transmutability/malformed-program-gracefulness/wrong-type-assume.stderr +++ b/src/test/ui/transmutability/malformed-program-gracefulness/wrong-type-assume.stderr @@ -1,27 +1,52 @@ error[E0308]: mismatched types - --> $DIR/wrong-type-assume.rs:36:51 + --> $DIR/wrong-type-assume.rs:53:51 | LL | assert::is_transmutable::(); | ^^^ expected `bool`, found `u8` +error[E0080]: evaluation of `assert::is_transmutable::::{constant#0}` failed + --> $DIR/wrong-type-assume.rs:26:15 + | +LL | { from_options(ASSUME_ALIGNMENT, ASSUME_LIFETIMES, ASSUME_SAFETY, ASSUME_VALIDITY) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors + error[E0308]: mismatched types - --> $DIR/wrong-type-assume.rs:37:58 + --> $DIR/wrong-type-assume.rs:54:58 | LL | assert::is_transmutable::(); | ^^^ expected `bool`, found `u8` +error[E0080]: evaluation of `assert::is_transmutable::::{constant#0}` failed + --> $DIR/wrong-type-assume.rs:26:15 + | +LL | { from_options(ASSUME_ALIGNMENT, ASSUME_LIFETIMES, ASSUME_SAFETY, ASSUME_VALIDITY) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors + error[E0308]: mismatched types - --> $DIR/wrong-type-assume.rs:38:65 + --> $DIR/wrong-type-assume.rs:55:65 | LL | assert::is_transmutable::(); | ^^^ expected `bool`, found `u8` +error[E0080]: evaluation of `assert::is_transmutable::::{constant#0}` failed + --> $DIR/wrong-type-assume.rs:26:15 + | +LL | { from_options(ASSUME_ALIGNMENT, ASSUME_LIFETIMES, ASSUME_SAFETY, ASSUME_VALIDITY) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors + error[E0308]: mismatched types - --> $DIR/wrong-type-assume.rs:39:72 + --> $DIR/wrong-type-assume.rs:56:72 | LL | assert::is_transmutable::(); | ^^^ expected `bool`, found `u8` -error: aborting due to 4 previous errors +error[E0080]: evaluation of `assert::is_transmutable::::{constant#0}` failed + --> $DIR/wrong-type-assume.rs:26:15 + | +LL | { from_options(ASSUME_ALIGNMENT, ASSUME_LIFETIMES, ASSUME_SAFETY, ASSUME_VALIDITY) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors + +error: aborting due to 8 previous errors -For more information about this error, try `rustc --explain E0308`. +Some errors have detailed explanations: E0080, E0308. +For more information about an error, try `rustc --explain E0080`. diff --git a/src/test/ui/transmutability/primitives/bool.rs b/src/test/ui/transmutability/primitives/bool.rs index 4f79bc2533708..eebb74fff471c 100644 --- a/src/test/ui/transmutability/primitives/bool.rs +++ b/src/test/ui/transmutability/primitives/bool.rs @@ -4,17 +4,17 @@ #![allow(incomplete_features)] mod assert { - use std::mem::BikeshedIntrinsicFrom; + use std::mem::{Assume, BikeshedIntrinsicFrom}; pub struct Context; pub fn is_transmutable() where - Dst: BikeshedIntrinsicFrom + Dst: BikeshedIntrinsicFrom {} pub fn is_maybe_transmutable() where - Dst: BikeshedIntrinsicFrom + Dst: BikeshedIntrinsicFrom {} } diff --git a/src/test/ui/transmutability/primitives/bool.stderr b/src/test/ui/transmutability/primitives/bool.stderr index dc740251c871e..214b5e150edd2 100644 --- a/src/test/ui/transmutability/primitives/bool.stderr +++ b/src/test/ui/transmutability/primitives/bool.stderr @@ -4,15 +4,15 @@ error[E0277]: `u8` cannot be safely transmuted into `bool` in the defining scope LL | assert::is_transmutable::(); | ^^^^ `u8` cannot be safely transmuted into `bool` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `bool` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `bool` note: required by a bound in `is_transmutable` --> $DIR/bool.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error: aborting due to previous error diff --git a/src/test/ui/transmutability/primitives/numbers.rs b/src/test/ui/transmutability/primitives/numbers.rs index a5f79065d8aad..0df43d2045f72 100644 --- a/src/test/ui/transmutability/primitives/numbers.rs +++ b/src/test/ui/transmutability/primitives/numbers.rs @@ -9,7 +9,7 @@ mod assert { pub fn is_transmutable() where - Dst: BikeshedIntrinsicFrom + Dst: BikeshedIntrinsicFrom {} } diff --git a/src/test/ui/transmutability/primitives/numbers.stderr b/src/test/ui/transmutability/primitives/numbers.stderr index 9b802a444e86a..7cb7ca8e6db52 100644 --- a/src/test/ui/transmutability/primitives/numbers.stderr +++ b/src/test/ui/transmutability/primitives/numbers.stderr @@ -4,15 +4,15 @@ error[E0277]: `i8` cannot be safely transmuted into `i16` in the defining scope LL | assert::is_transmutable::< i8, i16>(); | ^^^ `i8` cannot be safely transmuted into `i16` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `i16` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `i16` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i8` cannot be safely transmuted into `u16` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:63:40 @@ -20,15 +20,15 @@ error[E0277]: `i8` cannot be safely transmuted into `u16` in the defining scope LL | assert::is_transmutable::< i8, u16>(); | ^^^ `i8` cannot be safely transmuted into `u16` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u16` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u16` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i8` cannot be safely transmuted into `i32` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:64:40 @@ -36,15 +36,15 @@ error[E0277]: `i8` cannot be safely transmuted into `i32` in the defining scope LL | assert::is_transmutable::< i8, i32>(); | ^^^ `i8` cannot be safely transmuted into `i32` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `i32` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `i32` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i8` cannot be safely transmuted into `f32` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:65:40 @@ -52,15 +52,15 @@ error[E0277]: `i8` cannot be safely transmuted into `f32` in the defining scope LL | assert::is_transmutable::< i8, f32>(); | ^^^ `i8` cannot be safely transmuted into `f32` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `f32` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `f32` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i8` cannot be safely transmuted into `u32` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:66:40 @@ -68,15 +68,15 @@ error[E0277]: `i8` cannot be safely transmuted into `u32` in the defining scope LL | assert::is_transmutable::< i8, u32>(); | ^^^ `i8` cannot be safely transmuted into `u32` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u32` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u32` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i8` cannot be safely transmuted into `u64` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:67:40 @@ -84,15 +84,15 @@ error[E0277]: `i8` cannot be safely transmuted into `u64` in the defining scope LL | assert::is_transmutable::< i8, u64>(); | ^^^ `i8` cannot be safely transmuted into `u64` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u64` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u64` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i8` cannot be safely transmuted into `i64` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:68:40 @@ -100,15 +100,15 @@ error[E0277]: `i8` cannot be safely transmuted into `i64` in the defining scope LL | assert::is_transmutable::< i8, i64>(); | ^^^ `i8` cannot be safely transmuted into `i64` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `i64` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `i64` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i8` cannot be safely transmuted into `f64` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:69:40 @@ -116,15 +116,15 @@ error[E0277]: `i8` cannot be safely transmuted into `f64` in the defining scope LL | assert::is_transmutable::< i8, f64>(); | ^^^ `i8` cannot be safely transmuted into `f64` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `f64` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `f64` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i8` cannot be safely transmuted into `u128` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:70:39 @@ -132,15 +132,15 @@ error[E0277]: `i8` cannot be safely transmuted into `u128` in the defining scope LL | assert::is_transmutable::< i8, u128>(); | ^^^^ `i8` cannot be safely transmuted into `u128` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u128` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u128` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i8` cannot be safely transmuted into `i128` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:71:39 @@ -148,15 +148,15 @@ error[E0277]: `i8` cannot be safely transmuted into `i128` in the defining scope LL | assert::is_transmutable::< i8, i128>(); | ^^^^ `i8` cannot be safely transmuted into `i128` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `i128` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `i128` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u8` cannot be safely transmuted into `i16` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:73:40 @@ -164,15 +164,15 @@ error[E0277]: `u8` cannot be safely transmuted into `i16` in the defining scope LL | assert::is_transmutable::< u8, i16>(); | ^^^ `u8` cannot be safely transmuted into `i16` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `i16` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `i16` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u8` cannot be safely transmuted into `u16` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:74:40 @@ -180,15 +180,15 @@ error[E0277]: `u8` cannot be safely transmuted into `u16` in the defining scope LL | assert::is_transmutable::< u8, u16>(); | ^^^ `u8` cannot be safely transmuted into `u16` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u16` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u16` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u8` cannot be safely transmuted into `i32` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:75:40 @@ -196,15 +196,15 @@ error[E0277]: `u8` cannot be safely transmuted into `i32` in the defining scope LL | assert::is_transmutable::< u8, i32>(); | ^^^ `u8` cannot be safely transmuted into `i32` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `i32` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `i32` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u8` cannot be safely transmuted into `f32` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:76:40 @@ -212,15 +212,15 @@ error[E0277]: `u8` cannot be safely transmuted into `f32` in the defining scope LL | assert::is_transmutable::< u8, f32>(); | ^^^ `u8` cannot be safely transmuted into `f32` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `f32` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `f32` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u8` cannot be safely transmuted into `u32` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:77:40 @@ -228,15 +228,15 @@ error[E0277]: `u8` cannot be safely transmuted into `u32` in the defining scope LL | assert::is_transmutable::< u8, u32>(); | ^^^ `u8` cannot be safely transmuted into `u32` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u32` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u32` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u8` cannot be safely transmuted into `u64` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:78:40 @@ -244,15 +244,15 @@ error[E0277]: `u8` cannot be safely transmuted into `u64` in the defining scope LL | assert::is_transmutable::< u8, u64>(); | ^^^ `u8` cannot be safely transmuted into `u64` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u64` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u64` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u8` cannot be safely transmuted into `i64` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:79:40 @@ -260,15 +260,15 @@ error[E0277]: `u8` cannot be safely transmuted into `i64` in the defining scope LL | assert::is_transmutable::< u8, i64>(); | ^^^ `u8` cannot be safely transmuted into `i64` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `i64` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `i64` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u8` cannot be safely transmuted into `f64` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:80:40 @@ -276,15 +276,15 @@ error[E0277]: `u8` cannot be safely transmuted into `f64` in the defining scope LL | assert::is_transmutable::< u8, f64>(); | ^^^ `u8` cannot be safely transmuted into `f64` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `f64` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `f64` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u8` cannot be safely transmuted into `u128` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:81:39 @@ -292,15 +292,15 @@ error[E0277]: `u8` cannot be safely transmuted into `u128` in the defining scope LL | assert::is_transmutable::< u8, u128>(); | ^^^^ `u8` cannot be safely transmuted into `u128` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u128` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u128` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u8` cannot be safely transmuted into `i128` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:82:39 @@ -308,15 +308,15 @@ error[E0277]: `u8` cannot be safely transmuted into `i128` in the defining scope LL | assert::is_transmutable::< u8, i128>(); | ^^^^ `u8` cannot be safely transmuted into `i128` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `i128` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `i128` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i16` cannot be safely transmuted into `i32` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:84:40 @@ -324,15 +324,15 @@ error[E0277]: `i16` cannot be safely transmuted into `i32` in the defining scope LL | assert::is_transmutable::< i16, i32>(); | ^^^ `i16` cannot be safely transmuted into `i32` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `i32` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `i32` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i16` cannot be safely transmuted into `f32` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:85:40 @@ -340,15 +340,15 @@ error[E0277]: `i16` cannot be safely transmuted into `f32` in the defining scope LL | assert::is_transmutable::< i16, f32>(); | ^^^ `i16` cannot be safely transmuted into `f32` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `f32` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `f32` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i16` cannot be safely transmuted into `u32` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:86:40 @@ -356,15 +356,15 @@ error[E0277]: `i16` cannot be safely transmuted into `u32` in the defining scope LL | assert::is_transmutable::< i16, u32>(); | ^^^ `i16` cannot be safely transmuted into `u32` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u32` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u32` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i16` cannot be safely transmuted into `u64` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:87:40 @@ -372,15 +372,15 @@ error[E0277]: `i16` cannot be safely transmuted into `u64` in the defining scope LL | assert::is_transmutable::< i16, u64>(); | ^^^ `i16` cannot be safely transmuted into `u64` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u64` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u64` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i16` cannot be safely transmuted into `i64` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:88:40 @@ -388,15 +388,15 @@ error[E0277]: `i16` cannot be safely transmuted into `i64` in the defining scope LL | assert::is_transmutable::< i16, i64>(); | ^^^ `i16` cannot be safely transmuted into `i64` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `i64` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `i64` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i16` cannot be safely transmuted into `f64` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:89:40 @@ -404,15 +404,15 @@ error[E0277]: `i16` cannot be safely transmuted into `f64` in the defining scope LL | assert::is_transmutable::< i16, f64>(); | ^^^ `i16` cannot be safely transmuted into `f64` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `f64` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `f64` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i16` cannot be safely transmuted into `u128` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:90:39 @@ -420,15 +420,15 @@ error[E0277]: `i16` cannot be safely transmuted into `u128` in the defining scop LL | assert::is_transmutable::< i16, u128>(); | ^^^^ `i16` cannot be safely transmuted into `u128` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u128` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u128` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i16` cannot be safely transmuted into `i128` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:91:39 @@ -436,15 +436,15 @@ error[E0277]: `i16` cannot be safely transmuted into `i128` in the defining scop LL | assert::is_transmutable::< i16, i128>(); | ^^^^ `i16` cannot be safely transmuted into `i128` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `i128` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `i128` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u16` cannot be safely transmuted into `i32` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:93:40 @@ -452,15 +452,15 @@ error[E0277]: `u16` cannot be safely transmuted into `i32` in the defining scope LL | assert::is_transmutable::< u16, i32>(); | ^^^ `u16` cannot be safely transmuted into `i32` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `i32` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `i32` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u16` cannot be safely transmuted into `f32` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:94:40 @@ -468,15 +468,15 @@ error[E0277]: `u16` cannot be safely transmuted into `f32` in the defining scope LL | assert::is_transmutable::< u16, f32>(); | ^^^ `u16` cannot be safely transmuted into `f32` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `f32` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `f32` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u16` cannot be safely transmuted into `u32` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:95:40 @@ -484,15 +484,15 @@ error[E0277]: `u16` cannot be safely transmuted into `u32` in the defining scope LL | assert::is_transmutable::< u16, u32>(); | ^^^ `u16` cannot be safely transmuted into `u32` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u32` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u32` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u16` cannot be safely transmuted into `u64` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:96:40 @@ -500,15 +500,15 @@ error[E0277]: `u16` cannot be safely transmuted into `u64` in the defining scope LL | assert::is_transmutable::< u16, u64>(); | ^^^ `u16` cannot be safely transmuted into `u64` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u64` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u64` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u16` cannot be safely transmuted into `i64` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:97:40 @@ -516,15 +516,15 @@ error[E0277]: `u16` cannot be safely transmuted into `i64` in the defining scope LL | assert::is_transmutable::< u16, i64>(); | ^^^ `u16` cannot be safely transmuted into `i64` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `i64` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `i64` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u16` cannot be safely transmuted into `f64` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:98:40 @@ -532,15 +532,15 @@ error[E0277]: `u16` cannot be safely transmuted into `f64` in the defining scope LL | assert::is_transmutable::< u16, f64>(); | ^^^ `u16` cannot be safely transmuted into `f64` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `f64` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `f64` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u16` cannot be safely transmuted into `u128` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:99:39 @@ -548,15 +548,15 @@ error[E0277]: `u16` cannot be safely transmuted into `u128` in the defining scop LL | assert::is_transmutable::< u16, u128>(); | ^^^^ `u16` cannot be safely transmuted into `u128` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u128` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u128` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u16` cannot be safely transmuted into `i128` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:100:39 @@ -564,15 +564,15 @@ error[E0277]: `u16` cannot be safely transmuted into `i128` in the defining scop LL | assert::is_transmutable::< u16, i128>(); | ^^^^ `u16` cannot be safely transmuted into `i128` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `i128` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `i128` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i32` cannot be safely transmuted into `u64` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:102:40 @@ -580,15 +580,15 @@ error[E0277]: `i32` cannot be safely transmuted into `u64` in the defining scope LL | assert::is_transmutable::< i32, u64>(); | ^^^ `i32` cannot be safely transmuted into `u64` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u64` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u64` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i32` cannot be safely transmuted into `i64` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:103:40 @@ -596,15 +596,15 @@ error[E0277]: `i32` cannot be safely transmuted into `i64` in the defining scope LL | assert::is_transmutable::< i32, i64>(); | ^^^ `i32` cannot be safely transmuted into `i64` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `i64` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `i64` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i32` cannot be safely transmuted into `f64` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:104:40 @@ -612,15 +612,15 @@ error[E0277]: `i32` cannot be safely transmuted into `f64` in the defining scope LL | assert::is_transmutable::< i32, f64>(); | ^^^ `i32` cannot be safely transmuted into `f64` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `f64` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `f64` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i32` cannot be safely transmuted into `u128` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:105:39 @@ -628,15 +628,15 @@ error[E0277]: `i32` cannot be safely transmuted into `u128` in the defining scop LL | assert::is_transmutable::< i32, u128>(); | ^^^^ `i32` cannot be safely transmuted into `u128` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u128` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u128` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i32` cannot be safely transmuted into `i128` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:106:39 @@ -644,15 +644,15 @@ error[E0277]: `i32` cannot be safely transmuted into `i128` in the defining scop LL | assert::is_transmutable::< i32, i128>(); | ^^^^ `i32` cannot be safely transmuted into `i128` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `i128` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `i128` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `f32` cannot be safely transmuted into `u64` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:108:40 @@ -660,15 +660,15 @@ error[E0277]: `f32` cannot be safely transmuted into `u64` in the defining scope LL | assert::is_transmutable::< f32, u64>(); | ^^^ `f32` cannot be safely transmuted into `u64` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u64` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u64` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `f32` cannot be safely transmuted into `i64` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:109:40 @@ -676,15 +676,15 @@ error[E0277]: `f32` cannot be safely transmuted into `i64` in the defining scope LL | assert::is_transmutable::< f32, i64>(); | ^^^ `f32` cannot be safely transmuted into `i64` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `i64` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `i64` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `f32` cannot be safely transmuted into `f64` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:110:40 @@ -692,15 +692,15 @@ error[E0277]: `f32` cannot be safely transmuted into `f64` in the defining scope LL | assert::is_transmutable::< f32, f64>(); | ^^^ `f32` cannot be safely transmuted into `f64` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `f64` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `f64` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `f32` cannot be safely transmuted into `u128` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:111:39 @@ -708,15 +708,15 @@ error[E0277]: `f32` cannot be safely transmuted into `u128` in the defining scop LL | assert::is_transmutable::< f32, u128>(); | ^^^^ `f32` cannot be safely transmuted into `u128` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u128` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u128` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `f32` cannot be safely transmuted into `i128` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:112:39 @@ -724,15 +724,15 @@ error[E0277]: `f32` cannot be safely transmuted into `i128` in the defining scop LL | assert::is_transmutable::< f32, i128>(); | ^^^^ `f32` cannot be safely transmuted into `i128` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `i128` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `i128` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u32` cannot be safely transmuted into `u64` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:114:40 @@ -740,15 +740,15 @@ error[E0277]: `u32` cannot be safely transmuted into `u64` in the defining scope LL | assert::is_transmutable::< u32, u64>(); | ^^^ `u32` cannot be safely transmuted into `u64` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u64` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u64` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u32` cannot be safely transmuted into `i64` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:115:40 @@ -756,15 +756,15 @@ error[E0277]: `u32` cannot be safely transmuted into `i64` in the defining scope LL | assert::is_transmutable::< u32, i64>(); | ^^^ `u32` cannot be safely transmuted into `i64` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `i64` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `i64` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u32` cannot be safely transmuted into `f64` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:116:40 @@ -772,15 +772,15 @@ error[E0277]: `u32` cannot be safely transmuted into `f64` in the defining scope LL | assert::is_transmutable::< u32, f64>(); | ^^^ `u32` cannot be safely transmuted into `f64` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `f64` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `f64` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u32` cannot be safely transmuted into `u128` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:117:39 @@ -788,15 +788,15 @@ error[E0277]: `u32` cannot be safely transmuted into `u128` in the defining scop LL | assert::is_transmutable::< u32, u128>(); | ^^^^ `u32` cannot be safely transmuted into `u128` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u128` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u128` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u32` cannot be safely transmuted into `i128` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:118:39 @@ -804,15 +804,15 @@ error[E0277]: `u32` cannot be safely transmuted into `i128` in the defining scop LL | assert::is_transmutable::< u32, i128>(); | ^^^^ `u32` cannot be safely transmuted into `i128` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `i128` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `i128` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u64` cannot be safely transmuted into `u128` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:120:39 @@ -820,15 +820,15 @@ error[E0277]: `u64` cannot be safely transmuted into `u128` in the defining scop LL | assert::is_transmutable::< u64, u128>(); | ^^^^ `u64` cannot be safely transmuted into `u128` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u128` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u128` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `u64` cannot be safely transmuted into `i128` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:121:39 @@ -836,15 +836,15 @@ error[E0277]: `u64` cannot be safely transmuted into `i128` in the defining scop LL | assert::is_transmutable::< u64, i128>(); | ^^^^ `u64` cannot be safely transmuted into `i128` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `i128` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `i128` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i64` cannot be safely transmuted into `u128` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:123:39 @@ -852,15 +852,15 @@ error[E0277]: `i64` cannot be safely transmuted into `u128` in the defining scop LL | assert::is_transmutable::< i64, u128>(); | ^^^^ `i64` cannot be safely transmuted into `u128` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u128` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u128` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `i64` cannot be safely transmuted into `i128` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:124:39 @@ -868,15 +868,15 @@ error[E0277]: `i64` cannot be safely transmuted into `i128` in the defining scop LL | assert::is_transmutable::< i64, i128>(); | ^^^^ `i64` cannot be safely transmuted into `i128` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `i128` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `i128` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `f64` cannot be safely transmuted into `u128` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:126:39 @@ -884,15 +884,15 @@ error[E0277]: `f64` cannot be safely transmuted into `u128` in the defining scop LL | assert::is_transmutable::< f64, u128>(); | ^^^^ `f64` cannot be safely transmuted into `u128` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u128` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u128` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `f64` cannot be safely transmuted into `i128` in the defining scope of `assert::Context`. --> $DIR/numbers.rs:127:39 @@ -900,15 +900,15 @@ error[E0277]: `f64` cannot be safely transmuted into `i128` in the defining scop LL | assert::is_transmutable::< f64, i128>(); | ^^^^ `f64` cannot be safely transmuted into `i128` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `i128` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `i128` note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:12:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error: aborting due to 57 previous errors diff --git a/src/test/ui/transmutability/primitives/unit.rs b/src/test/ui/transmutability/primitives/unit.rs index 86d4740300dff..1975a61de9882 100644 --- a/src/test/ui/transmutability/primitives/unit.rs +++ b/src/test/ui/transmutability/primitives/unit.rs @@ -5,11 +5,16 @@ #![allow(dead_code)] mod assert { - use std::mem::BikeshedIntrinsicFrom; + use std::mem::{Assume, BikeshedIntrinsicFrom}; pub fn is_transmutable() where - Dst: BikeshedIntrinsicFrom + Dst: BikeshedIntrinsicFrom {} } diff --git a/src/test/ui/transmutability/primitives/unit.stderr b/src/test/ui/transmutability/primitives/unit.stderr index cf27c0d17b337..8cabe44a0538c 100644 --- a/src/test/ui/transmutability/primitives/unit.stderr +++ b/src/test/ui/transmutability/primitives/unit.stderr @@ -1,18 +1,24 @@ error[E0277]: `()` cannot be safely transmuted into `u8` in the defining scope of `should_have_correct_size::Context`. - --> $DIR/unit.rs:23:35 + --> $DIR/unit.rs:28:35 | LL | assert::is_transmutable::<(), u8, Context>(); | ^^ `()` cannot be safely transmuted into `u8` in the defining scope of `should_have_correct_size::Context`. | - = help: the trait `BikeshedIntrinsicFrom<(), should_have_correct_size::Context, true, true, true, true>` is not implemented for `u8` + = help: the trait `BikeshedIntrinsicFrom<(), should_have_correct_size::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `u8` note: required by a bound in `is_transmutable` --> $DIR/unit.rs:12:14 | -LL | pub fn is_transmutable() - | --------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | pub fn is_transmutable() + | --------------- required by a bound in this +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_transmutable` error: aborting due to previous error diff --git a/src/test/ui/transmutability/references.rs b/src/test/ui/transmutability/references.rs index c6fd4c43e95c0..af3ff0ec1d205 100644 --- a/src/test/ui/transmutability/references.rs +++ b/src/test/ui/transmutability/references.rs @@ -5,12 +5,19 @@ #![allow(dead_code, incomplete_features, non_camel_case_types)] mod assert { - use std::mem::BikeshedIntrinsicFrom; + use std::mem::{Assume, BikeshedIntrinsicFrom}; pub struct Context; pub fn is_maybe_transmutable() where - Dst: BikeshedIntrinsicFrom + Dst: BikeshedIntrinsicFrom {} } diff --git a/src/test/ui/transmutability/references.stderr b/src/test/ui/transmutability/references.stderr index 17ffcf64177e3..e9c7b144a826c 100644 --- a/src/test/ui/transmutability/references.stderr +++ b/src/test/ui/transmutability/references.stderr @@ -1,18 +1,25 @@ error[E0277]: `&'static Unit` cannot be safely transmuted into `&'static Unit` in the defining scope of `assert::Context`. - --> $DIR/references.rs:19:52 + --> $DIR/references.rs:26:52 | LL | assert::is_maybe_transmutable::<&'static Unit, &'static Unit>(); | ^^^^^^^^^^^^^ `&'static Unit` cannot be safely transmuted into `&'static Unit` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom<&'static Unit, assert::Context, true, true, true, true>` is not implemented for `&'static Unit` + = help: the trait `BikeshedIntrinsicFrom<&'static Unit, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `&'static Unit` note: required by a bound in `is_maybe_transmutable` --> $DIR/references.rs:13:14 | -LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` +LL | pub fn is_maybe_transmutable() + | --------------------- required by a bound in this +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_maybe_transmutable` error: aborting due to previous error diff --git a/src/test/ui/transmutability/structs/repr/should_handle_align.rs b/src/test/ui/transmutability/structs/repr/should_handle_align.rs index 71720165ab063..ea9bf2a237ed3 100644 --- a/src/test/ui/transmutability/structs/repr/should_handle_align.rs +++ b/src/test/ui/transmutability/structs/repr/should_handle_align.rs @@ -6,12 +6,19 @@ #![allow(dead_code, incomplete_features, non_camel_case_types)] mod assert { - use std::mem::BikeshedIntrinsicFrom; + use std::mem::{Assume, BikeshedIntrinsicFrom}; pub struct Context; pub fn is_maybe_transmutable() where - Dst: BikeshedIntrinsicFrom + Dst: BikeshedIntrinsicFrom {} } diff --git a/src/test/ui/transmutability/structs/repr/should_handle_packed.rs b/src/test/ui/transmutability/structs/repr/should_handle_packed.rs index ae8acf5041897..17dc995fcd961 100644 --- a/src/test/ui/transmutability/structs/repr/should_handle_packed.rs +++ b/src/test/ui/transmutability/structs/repr/should_handle_packed.rs @@ -6,12 +6,19 @@ #![allow(dead_code, incomplete_features, non_camel_case_types)] mod assert { - use std::mem::BikeshedIntrinsicFrom; + use std::mem::{Assume, BikeshedIntrinsicFrom}; pub struct Context; pub fn is_maybe_transmutable() where - Dst: BikeshedIntrinsicFrom + Dst: BikeshedIntrinsicFrom {} } diff --git a/src/test/ui/transmutability/structs/repr/should_require_well_defined_layout.rs b/src/test/ui/transmutability/structs/repr/should_require_well_defined_layout.rs index 556be989dbc25..9a65b4d702da6 100644 --- a/src/test/ui/transmutability/structs/repr/should_require_well_defined_layout.rs +++ b/src/test/ui/transmutability/structs/repr/should_require_well_defined_layout.rs @@ -5,12 +5,19 @@ #![allow(dead_code, incomplete_features, non_camel_case_types)] mod assert { - use std::mem::BikeshedIntrinsicFrom; + use std::mem::{Assume, BikeshedIntrinsicFrom}; pub struct Context; pub fn is_maybe_transmutable() where - Dst: BikeshedIntrinsicFrom + Dst: BikeshedIntrinsicFrom {} } diff --git a/src/test/ui/transmutability/structs/repr/should_require_well_defined_layout.stderr b/src/test/ui/transmutability/structs/repr/should_require_well_defined_layout.stderr index 07355f7c2ad26..621dbee849f0c 100644 --- a/src/test/ui/transmutability/structs/repr/should_require_well_defined_layout.stderr +++ b/src/test/ui/transmutability/structs/repr/should_require_well_defined_layout.stderr @@ -1,194 +1,278 @@ error[E0277]: `should_reject_repr_rust::unit::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. - --> $DIR/should_require_well_defined_layout.rs:21:52 + --> $DIR/should_require_well_defined_layout.rs:28:52 | LL | assert::is_maybe_transmutable::(); | ^^ `should_reject_repr_rust::unit::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `()` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `()` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_require_well_defined_layout.rs:13:14 | -LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` +LL | pub fn is_maybe_transmutable() + | --------------------- required by a bound in this +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_maybe_transmutable` error[E0277]: `u128` cannot be safely transmuted into `should_reject_repr_rust::unit::repr_rust` in the defining scope of `assert::Context`. - --> $DIR/should_require_well_defined_layout.rs:22:47 + --> $DIR/should_require_well_defined_layout.rs:29:47 | LL | assert::is_maybe_transmutable::(); | ^^^^^^^^^ `u128` cannot be safely transmuted into `should_reject_repr_rust::unit::repr_rust` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `should_reject_repr_rust::unit::repr_rust` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `should_reject_repr_rust::unit::repr_rust` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_require_well_defined_layout.rs:13:14 | -LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` +LL | pub fn is_maybe_transmutable() + | --------------------- required by a bound in this +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_maybe_transmutable` error[E0277]: `should_reject_repr_rust::tuple::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. - --> $DIR/should_require_well_defined_layout.rs:27:52 + --> $DIR/should_require_well_defined_layout.rs:34:52 | LL | assert::is_maybe_transmutable::(); | ^^ `should_reject_repr_rust::tuple::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `()` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `()` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_require_well_defined_layout.rs:13:14 | -LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` +LL | pub fn is_maybe_transmutable() + | --------------------- required by a bound in this +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_maybe_transmutable` error[E0277]: `u128` cannot be safely transmuted into `should_reject_repr_rust::tuple::repr_rust` in the defining scope of `assert::Context`. - --> $DIR/should_require_well_defined_layout.rs:28:47 + --> $DIR/should_require_well_defined_layout.rs:35:47 | LL | assert::is_maybe_transmutable::(); | ^^^^^^^^^ `u128` cannot be safely transmuted into `should_reject_repr_rust::tuple::repr_rust` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `should_reject_repr_rust::tuple::repr_rust` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `should_reject_repr_rust::tuple::repr_rust` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_require_well_defined_layout.rs:13:14 | -LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` +LL | pub fn is_maybe_transmutable() + | --------------------- required by a bound in this +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_maybe_transmutable` error[E0277]: `should_reject_repr_rust::braces::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. - --> $DIR/should_require_well_defined_layout.rs:33:52 + --> $DIR/should_require_well_defined_layout.rs:40:52 | LL | assert::is_maybe_transmutable::(); | ^^ `should_reject_repr_rust::braces::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `()` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `()` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_require_well_defined_layout.rs:13:14 | -LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` +LL | pub fn is_maybe_transmutable() + | --------------------- required by a bound in this +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_maybe_transmutable` error[E0277]: `u128` cannot be safely transmuted into `should_reject_repr_rust::braces::repr_rust` in the defining scope of `assert::Context`. - --> $DIR/should_require_well_defined_layout.rs:34:47 + --> $DIR/should_require_well_defined_layout.rs:41:47 | LL | assert::is_maybe_transmutable::(); | ^^^^^^^^^ `u128` cannot be safely transmuted into `should_reject_repr_rust::braces::repr_rust` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `should_reject_repr_rust::braces::repr_rust` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `should_reject_repr_rust::braces::repr_rust` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_require_well_defined_layout.rs:13:14 | -LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` +LL | pub fn is_maybe_transmutable() + | --------------------- required by a bound in this +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_maybe_transmutable` error[E0277]: `aligned::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. - --> $DIR/should_require_well_defined_layout.rs:39:52 + --> $DIR/should_require_well_defined_layout.rs:46:52 | LL | assert::is_maybe_transmutable::(); | ^^ `aligned::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `()` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `()` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_require_well_defined_layout.rs:13:14 | -LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` +LL | pub fn is_maybe_transmutable() + | --------------------- required by a bound in this +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_maybe_transmutable` error[E0277]: `u128` cannot be safely transmuted into `aligned::repr_rust` in the defining scope of `assert::Context`. - --> $DIR/should_require_well_defined_layout.rs:40:47 + --> $DIR/should_require_well_defined_layout.rs:47:47 | LL | assert::is_maybe_transmutable::(); | ^^^^^^^^^ `u128` cannot be safely transmuted into `aligned::repr_rust` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `aligned::repr_rust` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `aligned::repr_rust` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_require_well_defined_layout.rs:13:14 | -LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` +LL | pub fn is_maybe_transmutable() + | --------------------- required by a bound in this +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_maybe_transmutable` error[E0277]: `packed::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. - --> $DIR/should_require_well_defined_layout.rs:45:52 + --> $DIR/should_require_well_defined_layout.rs:52:52 | LL | assert::is_maybe_transmutable::(); | ^^ `packed::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `()` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `()` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_require_well_defined_layout.rs:13:14 | -LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` +LL | pub fn is_maybe_transmutable() + | --------------------- required by a bound in this +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_maybe_transmutable` error[E0277]: `u128` cannot be safely transmuted into `packed::repr_rust` in the defining scope of `assert::Context`. - --> $DIR/should_require_well_defined_layout.rs:46:47 + --> $DIR/should_require_well_defined_layout.rs:53:47 | LL | assert::is_maybe_transmutable::(); | ^^^^^^^^^ `u128` cannot be safely transmuted into `packed::repr_rust` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `packed::repr_rust` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `packed::repr_rust` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_require_well_defined_layout.rs:13:14 | -LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` +LL | pub fn is_maybe_transmutable() + | --------------------- required by a bound in this +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_maybe_transmutable` error[E0277]: `nested::repr_c` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. - --> $DIR/should_require_well_defined_layout.rs:52:49 + --> $DIR/should_require_well_defined_layout.rs:59:49 | LL | assert::is_maybe_transmutable::(); | ^^ `nested::repr_c` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `()` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `()` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_require_well_defined_layout.rs:13:14 | -LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` +LL | pub fn is_maybe_transmutable() + | --------------------- required by a bound in this +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_maybe_transmutable` error[E0277]: `u128` cannot be safely transmuted into `nested::repr_c` in the defining scope of `assert::Context`. - --> $DIR/should_require_well_defined_layout.rs:53:47 + --> $DIR/should_require_well_defined_layout.rs:60:47 | LL | assert::is_maybe_transmutable::(); | ^^^^^^ `u128` cannot be safely transmuted into `nested::repr_c` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `nested::repr_c` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `nested::repr_c` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_require_well_defined_layout.rs:13:14 | -LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` +LL | pub fn is_maybe_transmutable() + | --------------------- required by a bound in this +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_maybe_transmutable` error: aborting due to 12 previous errors diff --git a/src/test/ui/transmutability/structs/should_order_fields_correctly.rs b/src/test/ui/transmutability/structs/should_order_fields_correctly.rs index db49b914fe065..28724562bad2c 100644 --- a/src/test/ui/transmutability/structs/should_order_fields_correctly.rs +++ b/src/test/ui/transmutability/structs/should_order_fields_correctly.rs @@ -6,12 +6,17 @@ #![allow(dead_code)] mod assert { - use std::mem::BikeshedIntrinsicFrom; + use std::mem::{Assume, BikeshedIntrinsicFrom}; pub struct Context; pub fn is_transmutable() where - Dst: BikeshedIntrinsicFrom + Dst: BikeshedIntrinsicFrom {} } diff --git a/src/test/ui/transmutability/unions/boolish.rs b/src/test/ui/transmutability/unions/boolish.rs index 975118b99b7ba..e469c497353bb 100644 --- a/src/test/ui/transmutability/unions/boolish.rs +++ b/src/test/ui/transmutability/unions/boolish.rs @@ -7,12 +7,12 @@ #![allow(incomplete_features)] mod assert { - use std::mem::BikeshedIntrinsicFrom; + use std::mem::{Assume, BikeshedIntrinsicFrom}; pub struct Context; pub fn is_transmutable() where - Dst: BikeshedIntrinsicFrom + Dst: BikeshedIntrinsicFrom {} } diff --git a/src/test/ui/transmutability/unions/repr/should_handle_align.rs b/src/test/ui/transmutability/unions/repr/should_handle_align.rs index e215799a23240..09c13cc4dc759 100644 --- a/src/test/ui/transmutability/unions/repr/should_handle_align.rs +++ b/src/test/ui/transmutability/unions/repr/should_handle_align.rs @@ -6,12 +6,19 @@ #![allow(dead_code, incomplete_features, non_camel_case_types)] mod assert { - use std::mem::BikeshedIntrinsicFrom; + use std::mem::{Assume, BikeshedIntrinsicFrom}; pub struct Context; pub fn is_maybe_transmutable() where - Dst: BikeshedIntrinsicFrom + Dst: BikeshedIntrinsicFrom {} } diff --git a/src/test/ui/transmutability/unions/repr/should_handle_packed.rs b/src/test/ui/transmutability/unions/repr/should_handle_packed.rs index 34a53c7a80c42..24c2abd698e70 100644 --- a/src/test/ui/transmutability/unions/repr/should_handle_packed.rs +++ b/src/test/ui/transmutability/unions/repr/should_handle_packed.rs @@ -6,12 +6,19 @@ #![allow(dead_code, incomplete_features, non_camel_case_types)] mod assert { - use std::mem::BikeshedIntrinsicFrom; + use std::mem::{Assume, BikeshedIntrinsicFrom}; pub struct Context; pub fn is_maybe_transmutable() where - Dst: BikeshedIntrinsicFrom + Dst: BikeshedIntrinsicFrom {} } diff --git a/src/test/ui/transmutability/unions/repr/should_require_well_defined_layout.rs b/src/test/ui/transmutability/unions/repr/should_require_well_defined_layout.rs index cec8e389f444e..b1d5f71dcc585 100644 --- a/src/test/ui/transmutability/unions/repr/should_require_well_defined_layout.rs +++ b/src/test/ui/transmutability/unions/repr/should_require_well_defined_layout.rs @@ -5,12 +5,19 @@ #![allow(dead_code, incomplete_features, non_camel_case_types)] mod assert { - use std::mem::BikeshedIntrinsicFrom; + use std::mem::{Assume, BikeshedIntrinsicFrom}; pub struct Context; pub fn is_maybe_transmutable() where - Dst: BikeshedIntrinsicFrom + Dst: BikeshedIntrinsicFrom {} } diff --git a/src/test/ui/transmutability/unions/repr/should_require_well_defined_layout.stderr b/src/test/ui/transmutability/unions/repr/should_require_well_defined_layout.stderr index 2ed01b159ab0b..523bde85adfa9 100644 --- a/src/test/ui/transmutability/unions/repr/should_require_well_defined_layout.stderr +++ b/src/test/ui/transmutability/unions/repr/should_require_well_defined_layout.stderr @@ -1,34 +1,48 @@ error[E0277]: `should_reject_repr_rust::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. - --> $DIR/should_require_well_defined_layout.rs:23:48 + --> $DIR/should_require_well_defined_layout.rs:30:48 | LL | assert::is_maybe_transmutable::(); | ^^ `should_reject_repr_rust::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `()` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `()` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_require_well_defined_layout.rs:13:14 | -LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` +LL | pub fn is_maybe_transmutable() + | --------------------- required by a bound in this +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_maybe_transmutable` error[E0277]: `u128` cannot be safely transmuted into `should_reject_repr_rust::repr_rust` in the defining scope of `assert::Context`. - --> $DIR/should_require_well_defined_layout.rs:24:43 + --> $DIR/should_require_well_defined_layout.rs:31:43 | LL | assert::is_maybe_transmutable::(); | ^^^^^^^^^ `u128` cannot be safely transmuted into `should_reject_repr_rust::repr_rust` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `should_reject_repr_rust::repr_rust` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `should_reject_repr_rust::repr_rust` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_require_well_defined_layout.rs:13:14 | -LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` +LL | pub fn is_maybe_transmutable() + | --------------------- required by a bound in this +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_maybe_transmutable` error: aborting due to 2 previous errors diff --git a/src/test/ui/transmutability/unions/should_pad_variants.rs b/src/test/ui/transmutability/unions/should_pad_variants.rs index c4757900f9c3e..cabe544677e0f 100644 --- a/src/test/ui/transmutability/unions/should_pad_variants.rs +++ b/src/test/ui/transmutability/unions/should_pad_variants.rs @@ -6,11 +6,16 @@ #![allow(dead_code)] mod assert { - use std::mem::BikeshedIntrinsicFrom; + use std::mem::{Assume, BikeshedIntrinsicFrom}; pub fn is_transmutable() where - Dst: BikeshedIntrinsicFrom + Dst: BikeshedIntrinsicFrom {} } diff --git a/src/test/ui/transmutability/unions/should_pad_variants.stderr b/src/test/ui/transmutability/unions/should_pad_variants.stderr index 429f7211d17a8..a823503d594e9 100644 --- a/src/test/ui/transmutability/unions/should_pad_variants.stderr +++ b/src/test/ui/transmutability/unions/should_pad_variants.stderr @@ -1,18 +1,24 @@ error[E0277]: `Src` cannot be safely transmuted into `Dst` in the defining scope of `should_pad_variants::Context`. - --> $DIR/should_pad_variants.rs:39:36 + --> $DIR/should_pad_variants.rs:44:36 | LL | assert::is_transmutable::(); | ^^^ `Src` cannot be safely transmuted into `Dst` in the defining scope of `should_pad_variants::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `Dst` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `Dst` note: required by a bound in `is_transmutable` --> $DIR/should_pad_variants.rs:13:14 | -LL | pub fn is_transmutable() - | --------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | pub fn is_transmutable() + | --------------- required by a bound in this +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_transmutable` error: aborting due to previous error diff --git a/src/test/ui/transmutability/unions/should_permit_intersecting_if_validity_is_assumed.rs b/src/test/ui/transmutability/unions/should_permit_intersecting_if_validity_is_assumed.rs index 2493d71554ad3..1007fdd795422 100644 --- a/src/test/ui/transmutability/unions/should_permit_intersecting_if_validity_is_assumed.rs +++ b/src/test/ui/transmutability/unions/should_permit_intersecting_if_validity_is_assumed.rs @@ -7,13 +7,12 @@ #![allow(dead_code, incomplete_features, non_camel_case_types)] mod assert { - use std::mem::BikeshedIntrinsicFrom; + use std::mem::{Assume, BikeshedIntrinsicFrom}; pub struct Context; pub fn is_maybe_transmutable() where - Dst: BikeshedIntrinsicFrom - // validity IS assumed --------------------------------^^^^ + Dst: BikeshedIntrinsicFrom {} } diff --git a/src/test/ui/transmutability/unions/should_reject_contraction.rs b/src/test/ui/transmutability/unions/should_reject_contraction.rs index e8138d0e046c5..a24dfccd3187d 100644 --- a/src/test/ui/transmutability/unions/should_reject_contraction.rs +++ b/src/test/ui/transmutability/unions/should_reject_contraction.rs @@ -5,12 +5,12 @@ #![allow(dead_code, incomplete_features, non_camel_case_types)] mod assert { - use std::mem::BikeshedIntrinsicFrom; + use std::mem::{Assume, BikeshedIntrinsicFrom}; pub struct Context; pub fn is_transmutable() where - Dst: BikeshedIntrinsicFrom + Dst: BikeshedIntrinsicFrom {} } diff --git a/src/test/ui/transmutability/unions/should_reject_contraction.stderr b/src/test/ui/transmutability/unions/should_reject_contraction.stderr index 99f5890081728..41f0cedc3a311 100644 --- a/src/test/ui/transmutability/unions/should_reject_contraction.stderr +++ b/src/test/ui/transmutability/unions/should_reject_contraction.stderr @@ -4,15 +4,15 @@ error[E0277]: `Superset` cannot be safely transmuted into `Subset` in the defini LL | assert::is_transmutable::(); | ^^^^^^ `Superset` cannot be safely transmuted into `Subset` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `Subset` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `Subset` note: required by a bound in `is_transmutable` --> $DIR/should_reject_contraction.rs:13:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error: aborting due to previous error diff --git a/src/test/ui/transmutability/unions/should_reject_disjoint.rs b/src/test/ui/transmutability/unions/should_reject_disjoint.rs index 16160e29a5469..43aaa6905fd4f 100644 --- a/src/test/ui/transmutability/unions/should_reject_disjoint.rs +++ b/src/test/ui/transmutability/unions/should_reject_disjoint.rs @@ -5,13 +5,12 @@ #![allow(dead_code, incomplete_features, non_camel_case_types)] mod assert { - use std::mem::BikeshedIntrinsicFrom; + use std::mem::{Assume, BikeshedIntrinsicFrom}; pub struct Context; pub fn is_maybe_transmutable() where - Dst: BikeshedIntrinsicFrom - // validity IS assumed --------------------------------^^^^ + Dst: BikeshedIntrinsicFrom {} } diff --git a/src/test/ui/transmutability/unions/should_reject_disjoint.stderr b/src/test/ui/transmutability/unions/should_reject_disjoint.stderr index 5714e2bf320c5..4323f9740665f 100644 --- a/src/test/ui/transmutability/unions/should_reject_disjoint.stderr +++ b/src/test/ui/transmutability/unions/should_reject_disjoint.stderr @@ -1,34 +1,34 @@ error[E0277]: `A` cannot be safely transmuted into `B` in the defining scope of `assert::Context`. - --> $DIR/should_reject_disjoint.rs:34:40 + --> $DIR/should_reject_disjoint.rs:33:40 | LL | assert::is_maybe_transmutable::(); | ^ `A` cannot be safely transmuted into `B` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `B` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `B` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_reject_disjoint.rs:13:14 | LL | pub fn is_maybe_transmutable() | --------------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` error[E0277]: `B` cannot be safely transmuted into `A` in the defining scope of `assert::Context`. - --> $DIR/should_reject_disjoint.rs:35:40 + --> $DIR/should_reject_disjoint.rs:34:40 | LL | assert::is_maybe_transmutable::(); | ^ `B` cannot be safely transmuted into `A` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `A` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `A` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_reject_disjoint.rs:13:14 | LL | pub fn is_maybe_transmutable() | --------------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` error: aborting due to 2 previous errors diff --git a/src/test/ui/transmutability/unions/should_reject_intersecting.rs b/src/test/ui/transmutability/unions/should_reject_intersecting.rs index 58e399fb96225..9cd4233ee7455 100644 --- a/src/test/ui/transmutability/unions/should_reject_intersecting.rs +++ b/src/test/ui/transmutability/unions/should_reject_intersecting.rs @@ -6,13 +6,13 @@ #![allow(dead_code, incomplete_features, non_camel_case_types)] mod assert { - use std::mem::BikeshedIntrinsicFrom; + use std::mem::{Assume, BikeshedIntrinsicFrom}; pub struct Context; pub fn is_transmutable() where - Dst: BikeshedIntrinsicFrom - // validity is NOT assumed ----------------------------^^^^^ + Dst: BikeshedIntrinsicFrom + // validity is NOT assumed --------------^^^^^^^^^^^^^^^^^^ {} } diff --git a/src/test/ui/transmutability/unions/should_reject_intersecting.stderr b/src/test/ui/transmutability/unions/should_reject_intersecting.stderr index 92689a5f828b4..e009888ae8d31 100644 --- a/src/test/ui/transmutability/unions/should_reject_intersecting.stderr +++ b/src/test/ui/transmutability/unions/should_reject_intersecting.stderr @@ -4,15 +4,15 @@ error[E0277]: `A` cannot be safely transmuted into `B` in the defining scope of LL | assert::is_transmutable::(); | ^ `A` cannot be safely transmuted into `B` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `B` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `B` note: required by a bound in `is_transmutable` --> $DIR/should_reject_intersecting.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error[E0277]: `B` cannot be safely transmuted into `A` in the defining scope of `assert::Context`. --> $DIR/should_reject_intersecting.rs:37:34 @@ -20,15 +20,15 @@ error[E0277]: `B` cannot be safely transmuted into `A` in the defining scope of LL | assert::is_transmutable::(); | ^ `B` cannot be safely transmuted into `A` in the defining scope of `assert::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `A` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `A` note: required by a bound in `is_transmutable` --> $DIR/should_reject_intersecting.rs:14:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error: aborting due to 2 previous errors diff --git a/src/test/ui/transmutability/visibility/assume/should_accept_if_dst_has_private_field.rs b/src/test/ui/transmutability/visibility/assume/should_accept_if_dst_has_private_field.rs index 5a8c810494c58..8a41669c65e74 100644 --- a/src/test/ui/transmutability/visibility/assume/should_accept_if_dst_has_private_field.rs +++ b/src/test/ui/transmutability/visibility/assume/should_accept_if_dst_has_private_field.rs @@ -7,12 +7,12 @@ #![allow(dead_code)] mod assert { - use std::mem::BikeshedIntrinsicFrom; + use std::mem::{Assume, BikeshedIntrinsicFrom}; pub fn is_transmutable() where - Dst: BikeshedIntrinsicFrom - // visibility IS assumed -------------------------------------^^^^ + Dst: BikeshedIntrinsicFrom + // safety IS assumed --------------------^^^^^^^^^^^^^^^^^^ {} } diff --git a/src/test/ui/transmutability/visibility/assume/should_accept_if_dst_has_private_variant.rs b/src/test/ui/transmutability/visibility/assume/should_accept_if_dst_has_private_variant.rs index 77ab4fa6bff4b..dd57b877d78c0 100644 --- a/src/test/ui/transmutability/visibility/assume/should_accept_if_dst_has_private_variant.rs +++ b/src/test/ui/transmutability/visibility/assume/should_accept_if_dst_has_private_variant.rs @@ -7,12 +7,12 @@ #![allow(dead_code)] mod assert { - use std::mem::BikeshedIntrinsicFrom; + use std::mem::{Assume, BikeshedIntrinsicFrom}; pub fn is_transmutable() where - Dst: BikeshedIntrinsicFrom - // visibility IS assumed -------------------------------------^^^^ + Dst: BikeshedIntrinsicFrom + // safety IS assumed --------------------^^^^^^^^^^^^^^^^^^ {} } diff --git a/src/test/ui/transmutability/visibility/assume/should_accept_if_dst_has_tricky_unreachable_field.rs b/src/test/ui/transmutability/visibility/assume/should_accept_if_dst_has_tricky_unreachable_field.rs index 2421b24cbf07f..ebce8ce87dfda 100644 --- a/src/test/ui/transmutability/visibility/assume/should_accept_if_dst_has_tricky_unreachable_field.rs +++ b/src/test/ui/transmutability/visibility/assume/should_accept_if_dst_has_tricky_unreachable_field.rs @@ -13,12 +13,12 @@ #![allow(dead_code)] mod assert { - use std::mem::BikeshedIntrinsicFrom; + use std::mem::{Assume, BikeshedIntrinsicFrom}; pub fn is_transmutable() where - Dst: BikeshedIntrinsicFrom - // visibility IS assumed -------------------------------------^^^^ + Dst: BikeshedIntrinsicFrom + // safety IS assumed --------------------^^^^^^^^^^^^^^^^^^ {} } diff --git a/src/test/ui/transmutability/visibility/assume/should_accept_if_dst_has_unreachable_field.rs b/src/test/ui/transmutability/visibility/assume/should_accept_if_dst_has_unreachable_field.rs index 80b454fda560f..546fcbaa3de23 100644 --- a/src/test/ui/transmutability/visibility/assume/should_accept_if_dst_has_unreachable_field.rs +++ b/src/test/ui/transmutability/visibility/assume/should_accept_if_dst_has_unreachable_field.rs @@ -8,12 +8,12 @@ #![allow(dead_code)] mod assert { - use std::mem::BikeshedIntrinsicFrom; + use std::mem::{Assume, BikeshedIntrinsicFrom}; pub fn is_transmutable() where - Dst: BikeshedIntrinsicFrom - // visibility IS assumed -------------------------------------^^^^ + Dst: BikeshedIntrinsicFrom + // safety IS assumed --------------------^^^^^^^^^^^^^^^^^^ {} } diff --git a/src/test/ui/transmutability/visibility/assume/should_accept_if_dst_has_unreachable_ty.rs b/src/test/ui/transmutability/visibility/assume/should_accept_if_dst_has_unreachable_ty.rs index 7c53c91e4eda7..b9b74d18338af 100644 --- a/src/test/ui/transmutability/visibility/assume/should_accept_if_dst_has_unreachable_ty.rs +++ b/src/test/ui/transmutability/visibility/assume/should_accept_if_dst_has_unreachable_ty.rs @@ -8,12 +8,12 @@ #![allow(dead_code)] mod assert { - use std::mem::BikeshedIntrinsicFrom; + use std::mem::{Assume, BikeshedIntrinsicFrom}; pub fn is_transmutable() where - Dst: BikeshedIntrinsicFrom - // visibility IS assumed -------------------------------------^^^^ + Dst: BikeshedIntrinsicFrom + // safety IS assumed --------------------^^^^^^^^^^^^^^^^^^ {} } diff --git a/src/test/ui/transmutability/visibility/should_accept_if_src_has_private_field.rs b/src/test/ui/transmutability/visibility/should_accept_if_src_has_private_field.rs index c3f298f016325..5a0df09d49262 100644 --- a/src/test/ui/transmutability/visibility/should_accept_if_src_has_private_field.rs +++ b/src/test/ui/transmutability/visibility/should_accept_if_src_has_private_field.rs @@ -11,8 +11,7 @@ mod assert { pub fn is_transmutable() where - Dst: BikeshedIntrinsicFrom - // visibility is NOT assumed ---------------------------------^^^^^ + Dst: BikeshedIntrinsicFrom // safety is NOT assumed {} } diff --git a/src/test/ui/transmutability/visibility/should_accept_if_src_has_private_variant.rs b/src/test/ui/transmutability/visibility/should_accept_if_src_has_private_variant.rs index 73f6aece51eb5..0f69630cc64fa 100644 --- a/src/test/ui/transmutability/visibility/should_accept_if_src_has_private_variant.rs +++ b/src/test/ui/transmutability/visibility/should_accept_if_src_has_private_variant.rs @@ -11,8 +11,7 @@ mod assert { pub fn is_transmutable() where - Dst: BikeshedIntrinsicFrom - // visibility is NOT assumed ---------------------------------^^^^^ + Dst: BikeshedIntrinsicFrom // safety is NOT assumed {} } diff --git a/src/test/ui/transmutability/visibility/should_accept_if_src_has_unreachable_field.rs b/src/test/ui/transmutability/visibility/should_accept_if_src_has_unreachable_field.rs index 6d602601e96ab..9c8345a8e91a9 100644 --- a/src/test/ui/transmutability/visibility/should_accept_if_src_has_unreachable_field.rs +++ b/src/test/ui/transmutability/visibility/should_accept_if_src_has_unreachable_field.rs @@ -11,8 +11,7 @@ mod assert { pub fn is_transmutable() where - Dst: BikeshedIntrinsicFrom - // visibility is NOT assumed ---------------------------------^^^^^ + Dst: BikeshedIntrinsicFrom // safety is NOT assumed {} } diff --git a/src/test/ui/transmutability/visibility/should_accept_if_src_has_unreachable_field.stderr b/src/test/ui/transmutability/visibility/should_accept_if_src_has_unreachable_field.stderr index 3f7d08d0ae248..39b73302e364d 100644 --- a/src/test/ui/transmutability/visibility/should_accept_if_src_has_unreachable_field.stderr +++ b/src/test/ui/transmutability/visibility/should_accept_if_src_has_unreachable_field.stderr @@ -1,5 +1,5 @@ error[E0446]: private type `src::Zst` in public interface - --> $DIR/should_accept_if_src_has_unreachable_field.rs:23:9 + --> $DIR/should_accept_if_src_has_unreachable_field.rs:22:9 | LL | #[repr(C)] pub(self) struct Zst; // <- unreachable type | -------------------- `src::Zst` declared as private diff --git a/src/test/ui/transmutability/visibility/should_accept_if_src_has_unreachable_ty.rs b/src/test/ui/transmutability/visibility/should_accept_if_src_has_unreachable_ty.rs index 1943fb8716a11..acf9f2302500a 100644 --- a/src/test/ui/transmutability/visibility/should_accept_if_src_has_unreachable_ty.rs +++ b/src/test/ui/transmutability/visibility/should_accept_if_src_has_unreachable_ty.rs @@ -11,8 +11,7 @@ mod assert { pub fn is_transmutable() where - Dst: BikeshedIntrinsicFrom - // visibility is NOT assumed ---------------------------------^^^^^ + Dst: BikeshedIntrinsicFrom // safety is NOT assumed {} } diff --git a/src/test/ui/transmutability/visibility/should_accept_if_src_has_unreachable_ty.stderr b/src/test/ui/transmutability/visibility/should_accept_if_src_has_unreachable_ty.stderr index e961984e18932..76dc7f3407555 100644 --- a/src/test/ui/transmutability/visibility/should_accept_if_src_has_unreachable_ty.stderr +++ b/src/test/ui/transmutability/visibility/should_accept_if_src_has_unreachable_ty.stderr @@ -1,11 +1,11 @@ error[E0603]: struct `Src` is private - --> $DIR/should_accept_if_src_has_unreachable_ty.rs:38:36 + --> $DIR/should_accept_if_src_has_unreachable_ty.rs:37:36 | LL | assert::is_transmutable::(); | ^^^ private struct | note: the struct `Src` is defined here - --> $DIR/should_accept_if_src_has_unreachable_ty.rs:23:16 + --> $DIR/should_accept_if_src_has_unreachable_ty.rs:22:16 | LL | #[repr(C)] pub(self) struct Src { | ^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/transmutability/visibility/should_reject_if_dst_has_private_field.rs b/src/test/ui/transmutability/visibility/should_reject_if_dst_has_private_field.rs index fcf3f3a527805..e8c3fbc9a0469 100644 --- a/src/test/ui/transmutability/visibility/should_reject_if_dst_has_private_field.rs +++ b/src/test/ui/transmutability/visibility/should_reject_if_dst_has_private_field.rs @@ -10,8 +10,7 @@ mod assert { pub fn is_transmutable() where - Dst: BikeshedIntrinsicFrom - // visibility is NOT assumed ---------------------------------^^^^^ + Dst: BikeshedIntrinsicFrom // safety is NOT assumed {} } diff --git a/src/test/ui/transmutability/visibility/should_reject_if_dst_has_private_field.stderr b/src/test/ui/transmutability/visibility/should_reject_if_dst_has_private_field.stderr index 85124019e7f03..d5d6d431b6f62 100644 --- a/src/test/ui/transmutability/visibility/should_reject_if_dst_has_private_field.stderr +++ b/src/test/ui/transmutability/visibility/should_reject_if_dst_has_private_field.stderr @@ -1,18 +1,18 @@ error[E0277]: `Src` cannot be safely transmuted into `Dst` in the defining scope of `test::Context`. - --> $DIR/should_reject_if_dst_has_private_field.rs:36:41 + --> $DIR/should_reject_if_dst_has_private_field.rs:35:41 | LL | assert::is_transmutable::(); | ^^^^^^^^ `Src` cannot be safely transmuted into `Dst` in the defining scope of `test::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `Dst` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `Dst` note: required by a bound in `is_transmutable` --> $DIR/should_reject_if_dst_has_private_field.rs:13:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom // safety is NOT assumed + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error: aborting due to previous error diff --git a/src/test/ui/transmutability/visibility/should_reject_if_dst_has_private_variant.rs b/src/test/ui/transmutability/visibility/should_reject_if_dst_has_private_variant.rs index 566b56467124f..47bca27abaa88 100644 --- a/src/test/ui/transmutability/visibility/should_reject_if_dst_has_private_variant.rs +++ b/src/test/ui/transmutability/visibility/should_reject_if_dst_has_private_variant.rs @@ -10,8 +10,7 @@ mod assert { pub fn is_transmutable() where - Dst: BikeshedIntrinsicFrom - // visibility is NOT assumed ---------------------------------^^^^^ + Dst: BikeshedIntrinsicFrom // safety is NOT assumed {} } diff --git a/src/test/ui/transmutability/visibility/should_reject_if_dst_has_private_variant.stderr b/src/test/ui/transmutability/visibility/should_reject_if_dst_has_private_variant.stderr index 0be564d93e2d8..a1ca2ced53f29 100644 --- a/src/test/ui/transmutability/visibility/should_reject_if_dst_has_private_variant.stderr +++ b/src/test/ui/transmutability/visibility/should_reject_if_dst_has_private_variant.stderr @@ -1,18 +1,18 @@ error[E0277]: `Src` cannot be safely transmuted into `Dst` in the defining scope of `test::Context`. - --> $DIR/should_reject_if_dst_has_private_variant.rs:37:41 + --> $DIR/should_reject_if_dst_has_private_variant.rs:36:41 | LL | assert::is_transmutable::(); | ^^^^^^^^ `Src` cannot be safely transmuted into `Dst` in the defining scope of `test::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `Dst` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `Dst` note: required by a bound in `is_transmutable` --> $DIR/should_reject_if_dst_has_private_variant.rs:13:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom // safety is NOT assumed + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error: aborting due to previous error diff --git a/src/test/ui/transmutability/visibility/should_reject_if_dst_has_tricky_unreachable_field.rs b/src/test/ui/transmutability/visibility/should_reject_if_dst_has_tricky_unreachable_field.rs index 35fff5966c85b..662c32af17aa8 100644 --- a/src/test/ui/transmutability/visibility/should_reject_if_dst_has_tricky_unreachable_field.rs +++ b/src/test/ui/transmutability/visibility/should_reject_if_dst_has_tricky_unreachable_field.rs @@ -23,8 +23,7 @@ mod assert { pub fn is_transmutable() where - Dst: BikeshedIntrinsicFrom - // visibility is NOT assumed ---------------------------------^^^^^ + Dst: BikeshedIntrinsicFrom // safety is NOT assumed {} } diff --git a/src/test/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_field.rs b/src/test/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_field.rs index 42799d803b028..d7e21676fd385 100644 --- a/src/test/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_field.rs +++ b/src/test/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_field.rs @@ -12,8 +12,7 @@ mod assert { pub fn is_transmutable() where - Dst: BikeshedIntrinsicFrom - // visibility is NOT assumed ---------------------------------^^^^^ + Dst: BikeshedIntrinsicFrom // safety is NOT assumed {} } diff --git a/src/test/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_field.stderr b/src/test/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_field.stderr index 95c68d452010b..4e648664d5abb 100644 --- a/src/test/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_field.stderr +++ b/src/test/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_field.stderr @@ -1,18 +1,18 @@ error[E0277]: `Src` cannot be safely transmuted into `Dst` in the defining scope of `test::Context`. - --> $DIR/should_reject_if_dst_has_unreachable_field.rs:38:41 + --> $DIR/should_reject_if_dst_has_unreachable_field.rs:37:41 | LL | assert::is_transmutable::(); | ^^^^^^^^ `Src` cannot be safely transmuted into `Dst` in the defining scope of `test::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `Dst` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `Dst` note: required by a bound in `is_transmutable` --> $DIR/should_reject_if_dst_has_unreachable_field.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom // safety is NOT assumed + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error: aborting due to previous error diff --git a/src/test/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_ty.rs b/src/test/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_ty.rs index e13b32b30d964..c7b59f15b99cc 100644 --- a/src/test/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_ty.rs +++ b/src/test/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_ty.rs @@ -12,8 +12,7 @@ mod assert { pub fn is_transmutable() where - Dst: BikeshedIntrinsicFrom - // visibility is NOT assumed ---------------------------------^^^^^ + Dst: BikeshedIntrinsicFrom // safety is NOT assumed {} } diff --git a/src/test/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_ty.stderr b/src/test/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_ty.stderr index 3391839e39e02..bd72d64ccd75f 100644 --- a/src/test/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_ty.stderr +++ b/src/test/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_ty.stderr @@ -1,30 +1,30 @@ error[E0603]: struct `Dst` is private - --> $DIR/should_reject_if_dst_has_unreachable_ty.rs:39:46 + --> $DIR/should_reject_if_dst_has_unreachable_ty.rs:38:46 | LL | assert::is_transmutable::(); | ^^^ private struct | note: the struct `Dst` is defined here - --> $DIR/should_reject_if_dst_has_unreachable_ty.rs:32:16 + --> $DIR/should_reject_if_dst_has_unreachable_ty.rs:31:16 | LL | #[repr(C)] pub(self) struct Dst { | ^^^^^^^^^^^^^^^^^^^^ error[E0277]: `Src` cannot be safely transmuted into `Dst` in the defining scope of `test::Context`. - --> $DIR/should_reject_if_dst_has_unreachable_ty.rs:39:41 + --> $DIR/should_reject_if_dst_has_unreachable_ty.rs:38:41 | LL | assert::is_transmutable::(); | ^^^^^^^^ `Src` cannot be safely transmuted into `Dst` in the defining scope of `test::Context`. | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `Dst` + = help: the trait `BikeshedIntrinsicFrom` is not implemented for `Dst` note: required by a bound in `is_transmutable` --> $DIR/should_reject_if_dst_has_unreachable_ty.rs:15:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this LL | where -LL | Dst: BikeshedIntrinsicFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` +LL | Dst: BikeshedIntrinsicFrom // safety is NOT assumed + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` error: aborting due to 2 previous errors From 1d844fe6293cea3d857a0057b636b59434477d87 Mon Sep 17 00:00:00 2001 From: Jack Wrenn Date: Tue, 23 Aug 2022 15:52:49 +0000 Subject: [PATCH 02/25] safe transmute: use `FxIndex{Map,Set}` instead of `FxHash{Map,Set}` resolves query instability issues, and probably better for performance --- compiler/rustc_transmute/Cargo.toml | 3 +-- compiler/rustc_transmute/src/layout/dfa.rs | 1 - compiler/rustc_transmute/src/layout/nfa.rs | 6 ------ compiler/rustc_transmute/src/lib.rs | 6 +----- 4 files changed, 2 insertions(+), 14 deletions(-) diff --git a/compiler/rustc_transmute/Cargo.toml b/compiler/rustc_transmute/Cargo.toml index fa3f45fa235f1..aa6fe7d241968 100644 --- a/compiler/rustc_transmute/Cargo.toml +++ b/compiler/rustc_transmute/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" [dependencies] tracing = "0.1" -rustc_data_structures = { path = "../rustc_data_structures", optional = true} +rustc_data_structures = { path = "../rustc_data_structures"} rustc_hir = { path = "../rustc_hir", optional = true} rustc_infer = { path = "../rustc_infer", optional = true} rustc_macros = { path = "../rustc_macros", optional = true} @@ -18,7 +18,6 @@ rustc_target = { path = "../rustc_target", optional = true} [features] rustc = [ "rustc_middle", - "rustc_data_structures", "rustc_hir", "rustc_infer", "rustc_macros", diff --git a/compiler/rustc_transmute/src/layout/dfa.rs b/compiler/rustc_transmute/src/layout/dfa.rs index b60ea6e7a24f2..b8922696e3067 100644 --- a/compiler/rustc_transmute/src/layout/dfa.rs +++ b/compiler/rustc_transmute/src/layout/dfa.rs @@ -104,7 +104,6 @@ where } #[instrument(level = "debug")] - #[cfg_attr(feature = "rustc", allow(rustc::potential_query_instability))] pub(crate) fn from_nfa(nfa: Nfa) -> Self { let Nfa { transitions: nfa_transitions, start: nfa_start, accepting: nfa_accepting } = nfa; diff --git a/compiler/rustc_transmute/src/layout/nfa.rs b/compiler/rustc_transmute/src/layout/nfa.rs index f25e3c1fd8a30..c2bc47bc043a0 100644 --- a/compiler/rustc_transmute/src/layout/nfa.rs +++ b/compiler/rustc_transmute/src/layout/nfa.rs @@ -119,8 +119,6 @@ where let mut transitions: Map, Set>> = self.transitions; - // the iteration order doesn't matter - #[cfg_attr(feature = "rustc", allow(rustc::potential_query_instability))] for (source, transition) in other.transitions { let fix_state = |state| if state == other.start { self.accepting } else { state }; let entry = transitions.entry(fix_state(source)).or_default(); @@ -142,8 +140,6 @@ where let mut transitions: Map, Set>> = self.transitions.clone(); - // the iteration order doesn't matter - #[cfg_attr(feature = "rustc", allow(rustc::potential_query_instability))] for (&(mut source), transition) in other.transitions.iter() { // if source is starting state of `other`, replace with starting state of `self` if source == other.start { @@ -152,8 +148,6 @@ where let entry = transitions.entry(source).or_default(); for (edge, destinations) in transition { let entry = entry.entry(edge.clone()).or_default(); - // the iteration order doesn't matter - #[cfg_attr(feature = "rustc", allow(rustc::potential_query_instability))] for &(mut destination) in destinations { // if dest is accepting state of `other`, replace with accepting state of `self` if destination == other.accepting { diff --git a/compiler/rustc_transmute/src/lib.rs b/compiler/rustc_transmute/src/lib.rs index d7c2119a1c440..68270a603a146 100644 --- a/compiler/rustc_transmute/src/lib.rs +++ b/compiler/rustc_transmute/src/lib.rs @@ -13,11 +13,7 @@ #[macro_use] extern crate tracing; -#[cfg(feature = "rustc")] -pub(crate) use rustc_data_structures::fx::{FxHashMap as Map, FxHashSet as Set}; - -#[cfg(not(feature = "rustc"))] -pub(crate) use std::collections::{HashMap as Map, HashSet as Set}; +pub(crate) use rustc_data_structures::fx::{FxIndexMap as Map, FxIndexSet as Set}; pub(crate) mod layout; pub(crate) mod maybe_transmutable; From 54645e880ff88b8c2d242423733e3e0d26e0c1ea Mon Sep 17 00:00:00 2001 From: Nathan Stocks Date: Tue, 23 Aug 2022 13:25:03 -0600 Subject: [PATCH 03/25] set up rustc_metadata for SessionDiagnostics, port dependency_format.rs --- .../locales/en-US/metadata.ftl | 21 +++++ compiler/rustc_error_messages/src/lib.rs | 1 + .../rustc_metadata/src/dependency_format.rs | 79 ++++++------------- compiler/rustc_metadata/src/errors.rs | 52 ++++++++++++ compiler/rustc_metadata/src/lib.rs | 3 + 5 files changed, 103 insertions(+), 53 deletions(-) create mode 100644 compiler/rustc_error_messages/locales/en-US/metadata.ftl create mode 100644 compiler/rustc_metadata/src/errors.rs diff --git a/compiler/rustc_error_messages/locales/en-US/metadata.ftl b/compiler/rustc_error_messages/locales/en-US/metadata.ftl new file mode 100644 index 0000000000000..a27e765446427 --- /dev/null +++ b/compiler/rustc_error_messages/locales/en-US/metadata.ftl @@ -0,0 +1,21 @@ +metadata_rlib_required = + crate `{$crate_name}` required to be available in rlib format, but was not found in this form + +metadata_lib_required = + crate `{$crate_name}` required to be available in {$kind} format, but was not found in this form + +metadata_crate_dep_multiple = + cannot satisfy dependencies so `{$crate_name}` only shows up once + .help = having upstream crates all available in one format will likely make this go away + +metadata_two_panic_runtimes = + cannot link together two panic runtimes: {$prev_name} and {$cur_name} + +metadata_bad_panic_strategy = + the linked panic runtime `{$runtime}` is not compiled with this crate's panic strategy `{$strategy}` + +metadata_required_panic_strategy = + the crate `{$crate_name}` requires panic strategy `{$found_strategy}` which is incompatible with this crate's strategy of `{$desired_strategy}` + +metadata_incompatible_panic_in_drop_strategy = + the crate `{$crate_name}` is compiled with the panic-in-drop strategy `{$found_strategy}` which is incompatible with this crate's strategy of `{$desired_strategy}` diff --git a/compiler/rustc_error_messages/src/lib.rs b/compiler/rustc_error_messages/src/lib.rs index 42fb2d538b04d..72174d1f75d12 100644 --- a/compiler/rustc_error_messages/src/lib.rs +++ b/compiler/rustc_error_messages/src/lib.rs @@ -46,6 +46,7 @@ fluent_messages! { infer => "../locales/en-US/infer.ftl", lint => "../locales/en-US/lint.ftl", monomorphize => "../locales/en-US/monomorphize.ftl", + metadata => "../locales/en-US/metadata.ftl", parser => "../locales/en-US/parser.ftl", passes => "../locales/en-US/passes.ftl", plugin_impl => "../locales/en-US/plugin_impl.ftl", diff --git a/compiler/rustc_metadata/src/dependency_format.rs b/compiler/rustc_metadata/src/dependency_format.rs index b765c34f8e364..5d1082acc0beb 100644 --- a/compiler/rustc_metadata/src/dependency_format.rs +++ b/compiler/rustc_metadata/src/dependency_format.rs @@ -52,6 +52,10 @@ //! than finding a number of solutions (there are normally quite a few). use crate::creader::CStore; +use crate::errors::{ + BadPanicStrategy, CrateDepMultiple, IncompatiblePanicInDropStrategy, LibRequired, + RequiredPanicStrategy, RlibRequired, TwoPanicRuntimes, +}; use rustc_data_structures::fx::FxHashMap; use rustc_hir::def_id::CrateNum; @@ -136,11 +140,7 @@ fn calculate_type(tcx: TyCtxt<'_>, ty: CrateType) -> DependencyList { if src.rlib.is_some() { continue; } - sess.err(&format!( - "crate `{}` required to be available in rlib format, \ - but was not found in this form", - tcx.crate_name(cnum) - )); + sess.emit_err(RlibRequired { crate_name: tcx.crate_name(cnum).to_string() }); } return Vec::new(); } @@ -224,12 +224,10 @@ fn calculate_type(tcx: TyCtxt<'_>, ty: CrateType) -> DependencyList { Linkage::Static => "rlib", _ => "dylib", }; - sess.err(&format!( - "crate `{}` required to be available in {} format, \ - but was not found in this form", - tcx.crate_name(cnum), - kind - )); + sess.emit_err(LibRequired { + crate_name: tcx.crate_name(cnum).to_string(), + kind: kind.to_string(), + }); } } } @@ -254,16 +252,7 @@ fn add_library( // can be refined over time. if link2 != link || link == RequireStatic { tcx.sess - .struct_err(&format!( - "cannot satisfy dependencies so `{}` only \ - shows up once", - tcx.crate_name(cnum) - )) - .help( - "having upstream crates all available in one format \ - will likely make this go away", - ) - .emit(); + .emit_err(CrateDepMultiple { crate_name: tcx.crate_name(cnum).to_string() }); } } None => { @@ -358,13 +347,9 @@ fn verify_ok(tcx: TyCtxt<'_>, list: &[Linkage]) { if tcx.is_panic_runtime(cnum) { if let Some((prev, _)) = panic_runtime { - let prev_name = tcx.crate_name(prev); - let cur_name = tcx.crate_name(cnum); - sess.err(&format!( - "cannot link together two \ - panic runtimes: {} and {}", - prev_name, cur_name - )); + let prev_name = tcx.crate_name(prev).to_string(); + let cur_name = tcx.crate_name(cnum).to_string(); + sess.emit_err(TwoPanicRuntimes { prev_name, cur_name }); } panic_runtime = Some(( cnum, @@ -384,13 +369,10 @@ fn verify_ok(tcx: TyCtxt<'_>, list: &[Linkage]) { // First up, validate that our selected panic runtime is indeed exactly // our same strategy. if found_strategy != desired_strategy { - sess.err(&format!( - "the linked panic runtime `{}` is \ - not compiled with this crate's \ - panic strategy `{}`", - tcx.crate_name(runtime_cnum), - desired_strategy.desc() - )); + sess.emit_err(BadPanicStrategy { + runtime: tcx.crate_name(runtime_cnum).to_string(), + strategy: desired_strategy.desc().to_string(), + }); } // Next up, verify that all other crates are compatible with this panic @@ -407,28 +389,19 @@ fn verify_ok(tcx: TyCtxt<'_>, list: &[Linkage]) { } if let Some(found_strategy) = tcx.required_panic_strategy(cnum) && desired_strategy != found_strategy { - sess.err(&format!( - "the crate `{}` requires \ - panic strategy `{}` which is \ - incompatible with this crate's \ - strategy of `{}`", - tcx.crate_name(cnum), - found_strategy.desc(), - desired_strategy.desc() - )); + sess.emit_err(RequiredPanicStrategy { + crate_name: tcx.crate_name(cnum).to_string(), + found_strategy: found_strategy.desc().to_string(), + desired_strategy: desired_strategy.desc().to_string() }); } let found_drop_strategy = tcx.panic_in_drop_strategy(cnum); if tcx.sess.opts.unstable_opts.panic_in_drop != found_drop_strategy { - sess.err(&format!( - "the crate `{}` is compiled with the \ - panic-in-drop strategy `{}` which is \ - incompatible with this crate's \ - strategy of `{}`", - tcx.crate_name(cnum), - found_drop_strategy.desc(), - tcx.sess.opts.unstable_opts.panic_in_drop.desc() - )); + sess.emit_err(IncompatiblePanicInDropStrategy { + crate_name: tcx.crate_name(cnum).to_string(), + found_strategy: found_drop_strategy.desc().to_string(), + desired_strategy: tcx.sess.opts.unstable_opts.panic_in_drop.desc().to_string(), + }); } } } diff --git a/compiler/rustc_metadata/src/errors.rs b/compiler/rustc_metadata/src/errors.rs new file mode 100644 index 0000000000000..702863c376b93 --- /dev/null +++ b/compiler/rustc_metadata/src/errors.rs @@ -0,0 +1,52 @@ +// use rustc_errors::ErrorGuaranteed; +use rustc_macros::SessionDiagnostic; + +#[derive(SessionDiagnostic)] +#[diag(metadata::rlib_required)] +pub struct RlibRequired { + pub crate_name: String, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::lib_required)] +pub struct LibRequired { + pub crate_name: String, + pub kind: String, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::crate_dep_multiple)] +#[help] +pub struct CrateDepMultiple { + pub crate_name: String, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::two_panic_runtimes)] +pub struct TwoPanicRuntimes { + pub prev_name: String, + pub cur_name: String, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::bad_panic_strategy)] +pub struct BadPanicStrategy { + pub runtime: String, + pub strategy: String, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::required_panic_strategy)] +pub struct RequiredPanicStrategy { + pub crate_name: String, + pub found_strategy: String, + pub desired_strategy: String, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::incompatible_panic_in_drop_strategy)] +pub struct IncompatiblePanicInDropStrategy { + pub crate_name: String, + pub found_strategy: String, + pub desired_strategy: String, +} diff --git a/compiler/rustc_metadata/src/lib.rs b/compiler/rustc_metadata/src/lib.rs index 6440f3e390cf1..fae5b664f4e43 100644 --- a/compiler/rustc_metadata/src/lib.rs +++ b/compiler/rustc_metadata/src/lib.rs @@ -16,6 +16,8 @@ #![feature(never_type)] #![recursion_limit = "256"] #![allow(rustc::potential_query_instability)] +#![deny(rustc::untranslatable_diagnostic)] +#![deny(rustc::diagnostic_outside_of_impl)] extern crate proc_macro; @@ -34,6 +36,7 @@ mod native_libs; mod rmeta; pub mod creader; +pub mod errors; pub mod fs; pub mod locator; From 3ed93107ff0f92a64391e3c0936fb17195d525aa Mon Sep 17 00:00:00 2001 From: Nathan Stocks Date: Tue, 23 Aug 2022 16:33:28 -0600 Subject: [PATCH 04/25] port native_libs.rs to SessionDiagnostics --- .../locales/en-US/metadata.ftl | 102 ++++++++ compiler/rustc_metadata/src/errors.rs | 232 ++++++++++++++++++ compiler/rustc_metadata/src/native_libs.rs | 182 ++++---------- 3 files changed, 388 insertions(+), 128 deletions(-) diff --git a/compiler/rustc_error_messages/locales/en-US/metadata.ftl b/compiler/rustc_error_messages/locales/en-US/metadata.ftl index a27e765446427..0685981f9bb49 100644 --- a/compiler/rustc_error_messages/locales/en-US/metadata.ftl +++ b/compiler/rustc_error_messages/locales/en-US/metadata.ftl @@ -19,3 +19,105 @@ metadata_required_panic_strategy = metadata_incompatible_panic_in_drop_strategy = the crate `{$crate_name}` is compiled with the panic-in-drop strategy `{$found_strategy}` which is incompatible with this crate's strategy of `{$desired_strategy}` + +metadata_multiple_names_in_link = + multiple `name` arguments in a single `#[link]` attribute + +metadata_multiple_kinds_in_link = + multiple `kind` arguments in a single `#[link]` attribute + +metadata_link_name_form = + link name must be of the form `name = "string"` + +metadata_link_kind_form = + link kind must be of the form `kind = "string"` + +metadata_link_modifiers_form = + link modifiers must be of the form `modifiers = "string"` + +metadata_link_cfg_form = + link cfg must be of the form `cfg(/* predicate */)` + +metadata_wasm_import_form = + wasm import module must be of the form `wasm_import_module = "string"` + +metadata_empty_link_name = + link name must not be empty + .label = empty link name + +metadata_link_framework_apple = + link kind `framework` is only supported on Apple targets + +metadata_framework_only_windows = + link kind `raw-dylib` is only supported on Windows targets + +metadata_unknown_link_kind = + unknown link kind `{$kind}`, expected one of: static, dylib, framework, raw-dylib + .label = unknown link kind + +metadata_multiple_link_modifiers = + multiple `modifiers` arguments in a single `#[link]` attribute + +metadata_multiple_cfgs = + multiple `cfg` arguments in a single `#[link]` attribute + +metadata_link_cfg_single_predicate = + link cfg must have a single predicate argument + +metadata_multiple_wasm_import = + multiple `wasm_import_module` arguments in a single `#[link]` attribute + +metadata_unexpected_link_arg = + unexpected `#[link]` argument, expected one of: name, kind, modifiers, cfg, wasm_import_module, import_name_type + +metadata_invalid_link_modifier = + invalid linking modifier syntax, expected '+' or '-' prefix before one of: bundle, verbatim, whole-archive, as-needed + +metadata_multiple_modifiers = + multiple `{$modifier}` modifiers in a single `modifiers` argument + +metadata_bundle_needs_static = + linking modifier `bundle` is only compatible with `static` linking kind + +metadata_whole_archive_needs_static = + linking modifier `whole-archive` is only compatible with `static` linking kind + +metadata_as_needed_compatibility = + linking modifier `as-needed` is only compatible with `dylib` and `framework` linking kinds + +metadata_unknown_link_modifier = + unknown linking modifier `{$modifier}`, expected one of: bundle, verbatim, whole-archive, as-needed + +metadata_incompatible_wasm_link = + `wasm_import_module` is incompatible with other arguments in `#[link]` attributes + +metadata_link_requires_name = + `#[link]` attribute requires a `name = "string"` argument + .label = missing `name` argument + +metadata_raw_dylib_no_nul = + link name must not contain NUL characters if link kind is `raw-dylib` + +metadata_link_ordinal_raw_dylib = + `#[link_ordinal]` is only supported if link kind is `raw-dylib` + +metadata_lib_framework_apple = + library kind `framework` is only supported on Apple targets + +metadata_empty_renaming_target = + an empty renaming target was specified for library `{$lib_name}` + +metadata_renaming_no_link = + renaming of the library `{$lib_name}` was specified, however this crate contains no `#[link(...)]` attributes referencing this library + +metadata_multiple_renamings = + multiple renamings were specified for library `{$lib_name}` + +metadata_no_link_mod_override = + overriding linking modifiers from command line is not supported + +metadata_unsupported_abi_i686 = + ABI not supported by `#[link(kind = "raw-dylib")]` on i686 + +metadata_unsupported_abi = + ABI not supported by `#[link(kind = "raw-dylib")]` on this architecture diff --git a/compiler/rustc_metadata/src/errors.rs b/compiler/rustc_metadata/src/errors.rs index 702863c376b93..7e3c9b66fbdf5 100644 --- a/compiler/rustc_metadata/src/errors.rs +++ b/compiler/rustc_metadata/src/errors.rs @@ -1,5 +1,6 @@ // use rustc_errors::ErrorGuaranteed; use rustc_macros::SessionDiagnostic; +use rustc_span::Span; #[derive(SessionDiagnostic)] #[diag(metadata::rlib_required)] @@ -50,3 +51,234 @@ pub struct IncompatiblePanicInDropStrategy { pub found_strategy: String, pub desired_strategy: String, } + +#[derive(SessionDiagnostic)] +#[diag(metadata::multiple_names_in_link)] +pub struct MultipleNamesInLink { + #[primary_span] + pub span: Span, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::multiple_kinds_in_link)] +pub struct MultipleKindsInLink { + #[primary_span] + pub span: Span, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::link_name_form)] +pub struct LinkNameForm { + #[primary_span] + pub span: Span, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::link_kind_form)] +pub struct LinkKindForm { + #[primary_span] + pub span: Span, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::link_modifiers_form)] +pub struct LinkModifiersForm { + #[primary_span] + pub span: Span, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::link_cfg_form)] +pub struct LinkCfgForm { + #[primary_span] + pub span: Span, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::wasm_import_form)] +pub struct WasmImportForm { + #[primary_span] + pub span: Span, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::empty_link_name, code = "E0454")] +pub struct EmptyLinkName { + #[label] + #[primary_span] + pub span: Span, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::link_framework_apple, code = "E0455")] +pub struct LinkFrameworkApple { + #[primary_span] + pub span: Span, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::framework_only_windows, code = "E0455")] +pub struct FrameworkOnlyWindows { + #[primary_span] + pub span: Span, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::unknown_link_kind, code = "E0458")] +pub struct UnknownLinkKind { + #[label] + #[primary_span] + pub span: Span, + pub kind: String, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::multiple_link_modifiers)] +pub struct MultipleLinkModifiers { + #[primary_span] + pub span: Span, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::multiple_cfgs)] +pub struct MultipleCfgs { + #[primary_span] + pub span: Span, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::link_cfg_single_predicate)] +pub struct LinkCfgSinglePredicate { + #[primary_span] + pub span: Span, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::multiple_wasm_import)] +pub struct MultipleWasmImport { + #[primary_span] + pub span: Span, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::unexpected_link_arg)] +pub struct UnexpectedLinkArg { + #[primary_span] + pub span: Span, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::invalid_link_modifier)] +pub struct InvalidLinkModifier { + #[primary_span] + pub span: Span, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::multiple_modifiers)] +pub struct MultipleModifiers { + #[primary_span] + pub span: Span, + pub modifier: String, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::bundle_needs_static)] +pub struct BundleNeedsStatic { + #[primary_span] + pub span: Span, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::whole_archive_needs_static)] +pub struct WholeArchiveNeedsStatic { + #[primary_span] + pub span: Span, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::as_needed_compatibility)] +pub struct AsNeededCompatibility { + #[primary_span] + pub span: Span, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::unknown_link_modifier)] +pub struct UnknownLinkModifier { + #[primary_span] + pub span: Span, + pub modifier: String, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::incompatible_wasm_link)] +pub struct IncompatibleWasmLink { + #[primary_span] + pub span: Span, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::link_requires_name, code = "E0459")] +pub struct LinkRequiresName { + #[label] + #[primary_span] + pub span: Span, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::raw_dylib_no_nul)] +pub struct RawDylibNoNul { + #[primary_span] + pub span: Span, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::link_ordinal_raw_dylib)] +pub struct LinkOrdinalRawDylib { + #[primary_span] + pub span: Span, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::lib_framework_apple)] +pub struct LibFrameworkApple; + +#[derive(SessionDiagnostic)] +#[diag(metadata::empty_renaming_target)] +pub struct EmptyRenamingTarget { + pub lib_name: String, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::renaming_no_link)] +pub struct RenamingNoLink { + pub lib_name: String, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::multiple_renamings)] +pub struct MultipleRenamings { + pub lib_name: String, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::no_link_mod_override)] +pub struct NoLinkModOverride { + #[primary_span] + pub span: Option, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::unsupported_abi_i686)] +pub struct UnsupportedAbiI686 { + #[primary_span] + pub span: Span, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::unsupported_abi)] +pub struct UnsupportedAbi { + #[primary_span] + pub span: Span, +} diff --git a/compiler/rustc_metadata/src/native_libs.rs b/compiler/rustc_metadata/src/native_libs.rs index 8bafe203748f3..e8489232fbda6 100644 --- a/compiler/rustc_metadata/src/native_libs.rs +++ b/compiler/rustc_metadata/src/native_libs.rs @@ -12,6 +12,17 @@ use rustc_session::Session; use rustc_span::symbol::{sym, Symbol}; use rustc_target::spec::abi::Abi; +use crate::errors::{ + AsNeededCompatibility, BundleNeedsStatic, EmptyLinkName, EmptyRenamingTarget, + FrameworkOnlyWindows, IncompatibleWasmLink, InvalidLinkModifier, LibFrameworkApple, + LinkCfgForm, LinkCfgSinglePredicate, LinkFrameworkApple, LinkKindForm, LinkModifiersForm, + LinkNameForm, LinkOrdinalRawDylib, LinkRequiresName, MultipleCfgs, MultipleKindsInLink, + MultipleLinkModifiers, MultipleModifiers, MultipleNamesInLink, MultipleRenamings, + MultipleWasmImport, NoLinkModOverride, RawDylibNoNul, RenamingNoLink, UnexpectedLinkArg, + UnknownLinkKind, UnknownLinkModifier, UnsupportedAbi, UnsupportedAbiI686, WasmImportForm, + WholeArchiveNeedsStatic, +}; + pub(crate) fn collect(tcx: TyCtxt<'_>) -> Vec { let mut collector = Collector { tcx, libs: Vec::new() }; for id in tcx.hir().items() { @@ -66,32 +77,26 @@ impl<'tcx> Collector<'tcx> { match item.name_or_empty() { sym::name => { if name.is_some() { - let msg = "multiple `name` arguments in a single `#[link]` attribute"; - sess.span_err(item.span(), msg); + sess.emit_err(MultipleNamesInLink { span: item.span() }); continue; } let Some(link_name) = item.value_str() else { - let msg = "link name must be of the form `name = \"string\"`"; - sess.span_err(item.span(), msg); + sess.emit_err(LinkNameForm { span: item.span() }); continue; }; let span = item.name_value_literal_span().unwrap(); if link_name.is_empty() { - struct_span_err!(sess, span, E0454, "link name must not be empty") - .span_label(span, "empty link name") - .emit(); + sess.emit_err(EmptyLinkName { span }); } name = Some((link_name, span)); } sym::kind => { if kind.is_some() { - let msg = "multiple `kind` arguments in a single `#[link]` attribute"; - sess.span_err(item.span(), msg); + sess.emit_err(MultipleKindsInLink { span: item.span() }); continue; } let Some(link_kind) = item.value_str() else { - let msg = "link kind must be of the form `kind = \"string\"`"; - sess.span_err(item.span(), msg); + sess.emit_err(LinkKindForm { span: item.span() }); continue; }; @@ -101,25 +106,13 @@ impl<'tcx> Collector<'tcx> { "dylib" => NativeLibKind::Dylib { as_needed: None }, "framework" => { if !sess.target.is_like_osx { - struct_span_err!( - sess, - span, - E0455, - "link kind `framework` is only supported on Apple targets" - ) - .emit(); + sess.emit_err(LinkFrameworkApple { span }); } NativeLibKind::Framework { as_needed: None } } "raw-dylib" => { if !sess.target.is_like_windows { - struct_span_err!( - sess, - span, - E0455, - "link kind `raw-dylib` is only supported on Windows targets" - ) - .emit(); + sess.emit_err(FrameworkOnlyWindows { span }); } else if !features.raw_dylib { feature_err( &sess.parse_sess, @@ -132,13 +125,7 @@ impl<'tcx> Collector<'tcx> { NativeLibKind::RawDylib } kind => { - let msg = format!( - "unknown link kind `{kind}`, expected one of: \ - static, dylib, framework, raw-dylib" - ); - struct_span_err!(sess, span, E0458, "{}", msg) - .span_label(span, "unknown link kind") - .emit(); + sess.emit_err(UnknownLinkKind { span, kind: kind.to_string() }); continue; } }; @@ -146,32 +133,26 @@ impl<'tcx> Collector<'tcx> { } sym::modifiers => { if modifiers.is_some() { - let msg = - "multiple `modifiers` arguments in a single `#[link]` attribute"; - sess.span_err(item.span(), msg); + sess.emit_err(MultipleLinkModifiers { span: item.span() }); continue; } let Some(link_modifiers) = item.value_str() else { - let msg = "link modifiers must be of the form `modifiers = \"string\"`"; - sess.span_err(item.span(), msg); + sess.emit_err(LinkModifiersForm { span: item.span() }); continue; }; modifiers = Some((link_modifiers, item.name_value_literal_span().unwrap())); } sym::cfg => { if cfg.is_some() { - let msg = "multiple `cfg` arguments in a single `#[link]` attribute"; - sess.span_err(item.span(), msg); + sess.emit_err(MultipleCfgs { span: item.span() }); continue; } let Some(link_cfg) = item.meta_item_list() else { - let msg = "link cfg must be of the form `cfg(/* predicate */)`"; - sess.span_err(item.span(), msg); + sess.emit_err(LinkCfgForm { span: item.span() }); continue; }; let [NestedMetaItem::MetaItem(link_cfg)] = link_cfg else { - let msg = "link cfg must have a single predicate argument"; - sess.span_err(item.span(), msg); + sess.emit_err(LinkCfgSinglePredicate { span: item.span() }); continue; }; if !features.link_cfg { @@ -187,15 +168,11 @@ impl<'tcx> Collector<'tcx> { } sym::wasm_import_module => { if wasm_import_module.is_some() { - let msg = "multiple `wasm_import_module` arguments \ - in a single `#[link]` attribute"; - sess.span_err(item.span(), msg); + sess.emit_err(MultipleWasmImport { span: item.span() }); continue; } let Some(link_wasm_import_module) = item.value_str() else { - let msg = "wasm import module must be of the form \ - `wasm_import_module = \"string\"`"; - sess.span_err(item.span(), msg); + sess.emit_err(WasmImportForm { span: item.span() }); continue; }; wasm_import_module = Some((link_wasm_import_module, item.span())); @@ -243,9 +220,7 @@ impl<'tcx> Collector<'tcx> { import_name_type = Some((link_import_name_type, item.span())); } _ => { - let msg = "unexpected `#[link]` argument, expected one of: \ - name, kind, modifiers, cfg, wasm_import_module, import_name_type"; - sess.span_err(item.span(), msg); + sess.emit_err(UnexpectedLinkArg { span: item.span() }); } } } @@ -257,11 +232,7 @@ impl<'tcx> Collector<'tcx> { let (modifier, value) = match modifier.strip_prefix(&['+', '-']) { Some(m) => (m, modifier.starts_with('+')), None => { - sess.span_err( - span, - "invalid linking modifier syntax, expected '+' or '-' prefix \ - before one of: bundle, verbatim, whole-archive, as-needed", - ); + sess.emit_err(InvalidLinkModifier { span }); continue; } }; @@ -279,10 +250,10 @@ impl<'tcx> Collector<'tcx> { } let assign_modifier = |dst: &mut Option| { if dst.is_some() { - let msg = format!( - "multiple `{modifier}` modifiers in a single `modifiers` argument" - ); - sess.span_err(span, &msg); + sess.emit_err(MultipleModifiers { + span, + modifier: modifier.to_string(), + }); } else { *dst = Some(value); } @@ -292,11 +263,7 @@ impl<'tcx> Collector<'tcx> { assign_modifier(bundle) } ("bundle", _) => { - sess.span_err( - span, - "linking modifier `bundle` is only compatible with \ - `static` linking kind", - ); + sess.emit_err(BundleNeedsStatic { span }); } ("verbatim", _) => { @@ -308,11 +275,7 @@ impl<'tcx> Collector<'tcx> { assign_modifier(whole_archive) } ("whole-archive", _) => { - sess.span_err( - span, - "linking modifier `whole-archive` is only compatible with \ - `static` linking kind", - ); + sess.emit_err(WholeArchiveNeedsStatic { span }); } ("as-needed", Some(NativeLibKind::Dylib { as_needed })) @@ -321,21 +284,14 @@ impl<'tcx> Collector<'tcx> { assign_modifier(as_needed) } ("as-needed", _) => { - sess.span_err( - span, - "linking modifier `as-needed` is only compatible with \ - `dylib` and `framework` linking kinds", - ); + sess.emit_err(AsNeededCompatibility { span }); } _ => { - sess.span_err( + sess.emit_err(UnknownLinkModifier { span, - format!( - "unknown linking modifier `{modifier}`, expected one of: \ - bundle, verbatim, whole-archive, as-needed" - ), - ); + modifier: modifier.to_string(), + }); } } } @@ -343,19 +299,10 @@ impl<'tcx> Collector<'tcx> { if let Some((_, span)) = wasm_import_module { if name.is_some() || kind.is_some() || modifiers.is_some() || cfg.is_some() { - let msg = "`wasm_import_module` is incompatible with \ - other arguments in `#[link]` attributes"; - sess.span_err(span, msg); + sess.emit_err(IncompatibleWasmLink { span }); } } else if name.is_none() { - struct_span_err!( - sess, - m.span, - E0459, - "`#[link]` attribute requires a `name = \"string\"` argument" - ) - .span_label(m.span, "missing `name` argument") - .emit(); + sess.emit_err(LinkRequiresName { span: m.span }); } // Do this outside of the loop so that `import_name_type` can be specified before `kind`. @@ -369,10 +316,7 @@ impl<'tcx> Collector<'tcx> { let dll_imports = match kind { Some(NativeLibKind::RawDylib) => { if let Some((name, span)) = name && name.as_str().contains('\0') { - sess.span_err( - span, - "link name must not contain NUL characters if link kind is `raw-dylib`", - ); + sess.emit_err(RawDylibNoNul { span }); } foreign_mod_items .iter() @@ -401,10 +345,7 @@ impl<'tcx> Collector<'tcx> { .iter() .find(|a| a.has_name(sym::link_ordinal)) .unwrap(); - sess.span_err( - link_ordinal_attr.span, - "`#[link_ordinal]` is only supported if link kind is `raw-dylib`", - ); + sess.emit_err(LinkOrdinalRawDylib { span: link_ordinal_attr.span }); } } @@ -430,7 +371,7 @@ impl<'tcx> Collector<'tcx> { for lib in &self.tcx.sess.opts.libs { if let NativeLibKind::Framework { .. } = lib.kind && !self.tcx.sess.target.is_like_osx { // Cannot check this when parsing options because the target is not yet available. - self.tcx.sess.err("library kind `framework` is only supported on Apple targets"); + self.tcx.sess.emit_err(LibFrameworkApple); } if let Some(ref new_name) = lib.new_name { let any_duplicate = self @@ -439,23 +380,11 @@ impl<'tcx> Collector<'tcx> { .filter_map(|lib| lib.name.as_ref()) .any(|n| n.as_str() == lib.name); if new_name.is_empty() { - self.tcx.sess.err(format!( - "an empty renaming target was specified for library `{}`", - lib.name - )); + self.tcx.sess.emit_err(EmptyRenamingTarget { lib_name: lib.name.clone() }); } else if !any_duplicate { - self.tcx.sess.err(format!( - "renaming of the library `{}` was specified, \ - however this crate contains no `#[link(...)]` \ - attributes referencing this library", - lib.name - )); + self.tcx.sess.emit_err(RenamingNoLink { lib_name: lib.name.clone() }); } else if !renames.insert(&lib.name) { - self.tcx.sess.err(format!( - "multiple renamings were \ - specified for library `{}`", - lib.name - )); + self.tcx.sess.emit_err(MultipleRenamings { lib_name: lib.name.clone() }); } } } @@ -480,10 +409,13 @@ impl<'tcx> Collector<'tcx> { // involved or not, library reordering and kind overriding without // explicit `:rename` in particular. if lib.has_modifiers() || passed_lib.has_modifiers() { - let msg = "overriding linking modifiers from command line is not supported"; match lib.foreign_module { - Some(def_id) => self.tcx.sess.span_err(self.tcx.def_span(def_id), msg), - None => self.tcx.sess.err(msg), + Some(def_id) => self.tcx.sess.emit_err(NoLinkModOverride { + span: Some(self.tcx.def_span(def_id)), + }), + None => { + self.tcx.sess.emit_err(NoLinkModOverride { span: None }) + } }; } if passed_lib.kind != NativeLibKind::Unspecified { @@ -562,20 +494,14 @@ impl<'tcx> Collector<'tcx> { DllCallingConvention::Vectorcall(self.i686_arg_list_size(item)) } _ => { - self.tcx.sess.span_fatal( - item.span, - r#"ABI not supported by `#[link(kind = "raw-dylib")]` on i686"#, - ); + self.tcx.sess.emit_fatal(UnsupportedAbiI686 { span: item.span }); } } } else { match abi { Abi::C { .. } | Abi::Win64 { .. } | Abi::System { .. } => DllCallingConvention::C, _ => { - self.tcx.sess.span_fatal( - item.span, - r#"ABI not supported by `#[link(kind = "raw-dylib")]` on this architecture"#, - ); + self.tcx.sess.emit_fatal(UnsupportedAbi { span: item.span }); } } }; From f7e462a6c7faaea4bfce236fb94b4622ea8260ef Mon Sep 17 00:00:00 2001 From: Nathan Stocks Date: Tue, 23 Aug 2022 16:40:43 -0600 Subject: [PATCH 05/25] port encoder.rs to SessionDiagnostics --- .../locales/en-US/metadata.ftl | 9 +++++++++ compiler/rustc_metadata/src/errors.rs | 18 ++++++++++++++++++ compiler/rustc_metadata/src/rmeta/encoder.rs | 7 ++++--- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_error_messages/locales/en-US/metadata.ftl b/compiler/rustc_error_messages/locales/en-US/metadata.ftl index 0685981f9bb49..8cce1f007e227 100644 --- a/compiler/rustc_error_messages/locales/en-US/metadata.ftl +++ b/compiler/rustc_error_messages/locales/en-US/metadata.ftl @@ -121,3 +121,12 @@ metadata_unsupported_abi_i686 = metadata_unsupported_abi = ABI not supported by `#[link(kind = "raw-dylib")]` on this architecture + +metadata_fail_create_file_encoder = + failed to create file encoder: {$err} + +metadata_fail_seek_file = + failed to seek the file: {$err} + +metadata_fail_write_file = + failed to write to the file: {$err} diff --git a/compiler/rustc_metadata/src/errors.rs b/compiler/rustc_metadata/src/errors.rs index 7e3c9b66fbdf5..5edc59bf9e923 100644 --- a/compiler/rustc_metadata/src/errors.rs +++ b/compiler/rustc_metadata/src/errors.rs @@ -282,3 +282,21 @@ pub struct UnsupportedAbi { #[primary_span] pub span: Span, } + +#[derive(SessionDiagnostic)] +#[diag(metadata::fail_create_file_encoder)] +pub struct FailCreateFileEncoder { + pub err: String, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::fail_seek_file)] +pub struct FailSeekFile { + pub err: String, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::fail_write_file)] +pub struct FailWriteFile { + pub err: String, +} diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index 3482d9f04514e..2b1f9f17a3c85 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -1,3 +1,4 @@ +use crate::errors::{FailCreateFileEncoder, FailSeekFile, FailWriteFile}; use crate::rmeta::def_path_hash_map::DefPathHashMapRef; use crate::rmeta::table::TableBuilder; use crate::rmeta::*; @@ -2269,7 +2270,7 @@ pub fn encode_metadata(tcx: TyCtxt<'_>, path: &Path) { fn encode_metadata_impl(tcx: TyCtxt<'_>, path: &Path) { let mut encoder = opaque::FileEncoder::new(path) - .unwrap_or_else(|err| tcx.sess.fatal(&format!("failed to create file encoder: {}", err))); + .unwrap_or_else(|err| tcx.sess.emit_fatal(FailCreateFileEncoder { err: err.to_string() })); encoder.emit_raw_bytes(METADATA_HEADER); // Will be filled with the root position after encoding everything. @@ -2314,10 +2315,10 @@ fn encode_metadata_impl(tcx: TyCtxt<'_>, path: &Path) { // Encode the root position. let header = METADATA_HEADER.len(); file.seek(std::io::SeekFrom::Start(header as u64)) - .unwrap_or_else(|err| tcx.sess.fatal(&format!("failed to seek the file: {}", err))); + .unwrap_or_else(|err| tcx.sess.emit_fatal(FailSeekFile { err: err.to_string() })); let pos = root.position.get(); file.write_all(&[(pos >> 24) as u8, (pos >> 16) as u8, (pos >> 8) as u8, (pos >> 0) as u8]) - .unwrap_or_else(|err| tcx.sess.fatal(&format!("failed to write to the file: {}", err))); + .unwrap_or_else(|err| tcx.sess.emit_fatal(FailWriteFile { err: err.to_string() })); // Return to the position where we are before writing the root position. file.seek(std::io::SeekFrom::Start(pos_before_seek)).unwrap(); From 32e1823b2275cf55a598e65c5093a28122b4039f Mon Sep 17 00:00:00 2001 From: Nathan Stocks Date: Tue, 23 Aug 2022 17:03:49 -0600 Subject: [PATCH 06/25] port creader.rs to SessionDiagnostics --- .../locales/en-US/metadata.ftl | 28 ++++++++++ compiler/rustc_metadata/src/creader.rs | 56 ++++++++----------- compiler/rustc_metadata/src/errors.rs | 52 +++++++++++++++++ 3 files changed, 102 insertions(+), 34 deletions(-) diff --git a/compiler/rustc_error_messages/locales/en-US/metadata.ftl b/compiler/rustc_error_messages/locales/en-US/metadata.ftl index 8cce1f007e227..3ce1275a89919 100644 --- a/compiler/rustc_error_messages/locales/en-US/metadata.ftl +++ b/compiler/rustc_error_messages/locales/en-US/metadata.ftl @@ -130,3 +130,31 @@ metadata_fail_seek_file = metadata_fail_write_file = failed to write to the file: {$err} + +metadata_crate_not_panic_runtime = + the crate `{$crate_name}` is not a panic runtime + +metadata_no_panic_strategy = + the crate `{$crate_name}` does not have the panic strategy `{$strategy}` + +metadata_profiler_builtins_needs_core = + `profiler_builtins` crate (required by compiler options) is not compatible with crate attribute `#![no_core]` + +metadata_not_profiler_runtime = + the crate `{$crate_name}` is not a profiler runtime + +metadata_no_multiple_global_alloc = + cannot define multiple global allocators + .label = cannot define a new global allocator + +metadata_prev_global_alloc = + previous global allocator defined here + +metadata_conflicting_global_alloc = + the `#[global_allocator]` in {$other_crate_name} conflicts with global allocator in: {$crate_name} + +metadata_global_alloc_required = + no global memory allocator found but one is required; link to std or add `#[global_allocator]` to a static item that implements the GlobalAlloc trait + +metadata_no_transitive_needs_dep = + the crate `{$crate_name}` cannot depend on a crate that needs {$needs_crate_name}, but it depends on `{$deps_crate_name}` diff --git a/compiler/rustc_metadata/src/creader.rs b/compiler/rustc_metadata/src/creader.rs index 708d0b1fd8a30..f9aa3733f6a37 100644 --- a/compiler/rustc_metadata/src/creader.rs +++ b/compiler/rustc_metadata/src/creader.rs @@ -1,5 +1,9 @@ //! Validates all used crates and extern libraries and loads their metadata +use crate::errors::{ + ConflictingGlobalAlloc, CrateNotPanicRuntime, GlobalAllocRequired, NoMultipleGlobalAlloc, + NoPanicStrategy, NoTransitiveNeedsDep, NotProfilerRuntime, ProfilerBuiltinsNeedsCore, +}; use crate::locator::{CrateError, CrateLocator, CratePaths}; use crate::rmeta::{CrateDep, CrateMetadata, CrateNumMap, CrateRoot, MetadataBlob}; @@ -746,15 +750,13 @@ impl<'a> CrateLoader<'a> { // Sanity check the loaded crate to ensure it is indeed a panic runtime // and the panic strategy is indeed what we thought it was. if !data.is_panic_runtime() { - self.sess.err(&format!("the crate `{}` is not a panic runtime", name)); + self.sess.emit_err(CrateNotPanicRuntime { crate_name: name.to_string() }); } if data.required_panic_strategy() != Some(desired_strategy) { - self.sess.err(&format!( - "the crate `{}` does not have the panic \ - strategy `{}`", - name, - desired_strategy.desc() - )); + self.sess.emit_err(NoPanicStrategy { + crate_name: name.to_string(), + strategy: desired_strategy.desc().to_string(), + }); } self.cstore.injected_panic_runtime = Some(cnum); @@ -774,10 +776,7 @@ impl<'a> CrateLoader<'a> { let name = Symbol::intern(&self.sess.opts.unstable_opts.profiler_runtime); if name == sym::profiler_builtins && self.sess.contains_name(&krate.attrs, sym::no_core) { - self.sess.err( - "`profiler_builtins` crate (required by compiler options) \ - is not compatible with crate attribute `#![no_core]`", - ); + self.sess.emit_err(ProfilerBuiltinsNeedsCore); } let Some(cnum) = self.resolve_crate(name, DUMMY_SP, CrateDepKind::Implicit) else { return; }; @@ -785,18 +784,14 @@ impl<'a> CrateLoader<'a> { // Sanity check the loaded crate to ensure it is indeed a profiler runtime if !data.is_profiler_runtime() { - self.sess.err(&format!("the crate `{}` is not a profiler runtime", name)); + self.sess.emit_err(NotProfilerRuntime { crate_name: name.to_string() }); } } fn inject_allocator_crate(&mut self, krate: &ast::Crate) { self.cstore.has_global_allocator = match &*global_allocator_spans(&self.sess, krate) { [span1, span2, ..] => { - self.sess - .struct_span_err(*span2, "cannot define multiple global allocators") - .span_label(*span2, "cannot define a new global allocator") - .span_label(*span1, "previous global allocator defined here") - .emit(); + self.sess.emit_err(NoMultipleGlobalAlloc { span2: *span2, span1: *span1 }); true } spans => !spans.is_empty(), @@ -832,11 +827,10 @@ impl<'a> CrateLoader<'a> { if data.has_global_allocator() { match global_allocator { Some(other_crate) => { - self.sess.err(&format!( - "the `#[global_allocator]` in {} conflicts with global allocator in: {}", - other_crate, - data.name() - )); + self.sess.emit_err(ConflictingGlobalAlloc { + crate_name: data.name().to_string(), + other_crate_name: other_crate.to_string(), + }); } None => global_allocator = Some(data.name()), } @@ -855,10 +849,7 @@ impl<'a> CrateLoader<'a> { if !self.sess.contains_name(&krate.attrs, sym::default_lib_allocator) && !self.cstore.iter_crate_data().any(|(_, data)| data.has_default_lib_allocator()) { - self.sess.err( - "no global memory allocator found but one is required; link to std or add \ - `#[global_allocator]` to a static item that implements the GlobalAlloc trait", - ); + self.sess.emit_err(GlobalAllocRequired); } self.cstore.allocator_kind = Some(AllocatorKind::Default); } @@ -882,14 +873,11 @@ impl<'a> CrateLoader<'a> { for dep in self.cstore.crate_dependencies_in_reverse_postorder(krate) { let data = self.cstore.get_crate_data(dep); if needs_dep(&data) { - self.sess.err(&format!( - "the crate `{}` cannot depend \ - on a crate that needs {}, but \ - it depends on `{}`", - self.cstore.get_crate_data(krate).name(), - what, - data.name() - )); + self.sess.emit_err(NoTransitiveNeedsDep { + crate_name: self.cstore.get_crate_data(krate).name().to_string(), + needs_crate_name: what.to_string(), + deps_crate_name: data.name().to_string(), + }); } } diff --git a/compiler/rustc_metadata/src/errors.rs b/compiler/rustc_metadata/src/errors.rs index 5edc59bf9e923..3d025e89857c9 100644 --- a/compiler/rustc_metadata/src/errors.rs +++ b/compiler/rustc_metadata/src/errors.rs @@ -300,3 +300,55 @@ pub struct FailSeekFile { pub struct FailWriteFile { pub err: String, } + +#[derive(SessionDiagnostic)] +#[diag(metadata::crate_not_panic_runtime)] +pub struct CrateNotPanicRuntime { + pub crate_name: String, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::no_panic_strategy)] +pub struct NoPanicStrategy { + pub crate_name: String, + pub strategy: String, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::profiler_builtins_needs_core)] +pub struct ProfilerBuiltinsNeedsCore; + +#[derive(SessionDiagnostic)] +#[diag(metadata::not_profiler_runtime)] +pub struct NotProfilerRuntime { + pub crate_name: String, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::no_multiple_global_alloc)] +pub struct NoMultipleGlobalAlloc { + #[primary_span] + #[label] + pub span2: Span, + #[label(metadata::prev_global_alloc)] + pub span1: Span, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::conflicting_global_alloc)] +pub struct ConflictingGlobalAlloc { + pub crate_name: String, + pub other_crate_name: String, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::global_alloc_required)] +pub struct GlobalAllocRequired; + +#[derive(SessionDiagnostic)] +#[diag(metadata::no_transitive_needs_dep)] +pub struct NoTransitiveNeedsDep { + pub crate_name: String, + pub needs_crate_name: String, + pub deps_crate_name: String, +} From bd8e312d73f07517e24a58a201e8524ebe4da8da Mon Sep 17 00:00:00 2001 From: Nathan Stocks Date: Tue, 23 Aug 2022 17:16:04 -0600 Subject: [PATCH 07/25] port fs.rs to SessionDiagnostics --- .../locales/en-US/metadata.ftl | 12 +++++++++ compiler/rustc_metadata/src/errors.rs | 26 +++++++++++++++++++ compiler/rustc_metadata/src/fs.rs | 26 ++++++++++++------- 3 files changed, 55 insertions(+), 9 deletions(-) diff --git a/compiler/rustc_error_messages/locales/en-US/metadata.ftl b/compiler/rustc_error_messages/locales/en-US/metadata.ftl index 3ce1275a89919..a4881dbc76455 100644 --- a/compiler/rustc_error_messages/locales/en-US/metadata.ftl +++ b/compiler/rustc_error_messages/locales/en-US/metadata.ftl @@ -158,3 +158,15 @@ metadata_global_alloc_required = metadata_no_transitive_needs_dep = the crate `{$crate_name}` cannot depend on a crate that needs {$needs_crate_name}, but it depends on `{$deps_crate_name}` + +metadata_failed_write_error = + failed to write {$filename}: {$err} + +metadata_failed_create_tempdir = + couldn't create a temp dir: {$err} + +metadata_failed_create_file = + failed to create the file {$filename}: {$err} + +metadata_failed_create_encoded_metadata = + failed to create encoded metadata from file: {$err} diff --git a/compiler/rustc_metadata/src/errors.rs b/compiler/rustc_metadata/src/errors.rs index 3d025e89857c9..c373e49ba4958 100644 --- a/compiler/rustc_metadata/src/errors.rs +++ b/compiler/rustc_metadata/src/errors.rs @@ -352,3 +352,29 @@ pub struct NoTransitiveNeedsDep { pub needs_crate_name: String, pub deps_crate_name: String, } + +#[derive(SessionDiagnostic)] +#[diag(metadata::failed_write_error)] +pub struct FailedWriteError { + pub filename: String, + pub err: String, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::failed_create_tempdir)] +pub struct FailedCreateTempdir { + pub err: String, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::failed_create_file)] +pub struct FailedCreateFile { + pub filename: String, + pub err: String, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::failed_create_encoded_metadata)] +pub struct FailedCreateEncodedMetadata { + pub err: String, +} diff --git a/compiler/rustc_metadata/src/fs.rs b/compiler/rustc_metadata/src/fs.rs index e6072901aaa43..67c18766c5959 100644 --- a/compiler/rustc_metadata/src/fs.rs +++ b/compiler/rustc_metadata/src/fs.rs @@ -1,3 +1,6 @@ +use crate::errors::{ + FailedCreateEncodedMetadata, FailedCreateFile, FailedCreateTempdir, FailedWriteError, +}; use crate::{encode_metadata, EncodedMetadata}; use rustc_data_structures::temp_dir::MaybeTempDir; @@ -24,7 +27,10 @@ pub fn emit_metadata(sess: &Session, metadata: &[u8], tmpdir: &MaybeTempDir) -> let result = fs::write(&out_filename, metadata); if let Err(e) = result { - sess.fatal(&format!("failed to write {}: {}", out_filename.display(), e)); + sess.emit_fatal(FailedWriteError { + filename: out_filename.display().to_string(), + err: e.to_string(), + }); } out_filename @@ -65,7 +71,7 @@ pub fn encode_and_write_metadata( let metadata_tmpdir = TempFileBuilder::new() .prefix("rmeta") .tempdir_in(out_filename.parent().unwrap_or_else(|| Path::new(""))) - .unwrap_or_else(|err| tcx.sess.fatal(&format!("couldn't create a temp dir: {}", err))); + .unwrap_or_else(|err| tcx.sess.emit_fatal(FailedCreateTempdir { err: err.to_string() })); let metadata_tmpdir = MaybeTempDir::new(metadata_tmpdir, tcx.sess.opts.cg.save_temps); let metadata_filename = metadata_tmpdir.as_ref().join(METADATA_FILENAME); @@ -74,11 +80,10 @@ pub fn encode_and_write_metadata( match metadata_kind { MetadataKind::None => { std::fs::File::create(&metadata_filename).unwrap_or_else(|e| { - tcx.sess.fatal(&format!( - "failed to create the file {}: {}", - metadata_filename.display(), - e - )) + tcx.sess.emit_fatal(FailedCreateFile { + filename: metadata_filename.display().to_string(), + err: e.to_string(), + }); }); } MetadataKind::Uncompressed | MetadataKind::Compressed => { @@ -94,7 +99,10 @@ pub fn encode_and_write_metadata( let need_metadata_file = tcx.sess.opts.output_types.contains_key(&OutputType::Metadata); let (metadata_filename, metadata_tmpdir) = if need_metadata_file { if let Err(e) = non_durable_rename(&metadata_filename, &out_filename) { - tcx.sess.fatal(&format!("failed to write {}: {}", out_filename.display(), e)); + tcx.sess.emit_fatal(FailedWriteError { + filename: out_filename.display().to_string(), + err: e.to_string(), + }); } if tcx.sess.opts.json_artifact_notifications { tcx.sess @@ -110,7 +118,7 @@ pub fn encode_and_write_metadata( // Load metadata back to memory: codegen may need to include it in object files. let metadata = EncodedMetadata::from_path(metadata_filename, metadata_tmpdir).unwrap_or_else(|e| { - tcx.sess.fatal(&format!("failed to create encoded metadata from file: {}", e)) + tcx.sess.emit_fatal(FailedCreateEncodedMetadata { err: e.to_string() }); }); let need_metadata_module = metadata_kind == MetadataKind::Compressed; From d0ba1fbaa4f73b6edf27346817b1f74fb352945e Mon Sep 17 00:00:00 2001 From: Nathan Stocks Date: Wed, 24 Aug 2022 12:14:41 -0600 Subject: [PATCH 08/25] port of locator.rs to SessionDiagnostics, fix some of the errors revealed by tests, manually add a panic to test for dead code --- .../locales/en-US/metadata.ftl | 55 +++ compiler/rustc_metadata/src/errors.rs | 257 ++++++++++++- compiler/rustc_metadata/src/locator.rs | 348 +++++++----------- compiler/rustc_metadata/src/native_libs.rs | 1 - 4 files changed, 448 insertions(+), 213 deletions(-) diff --git a/compiler/rustc_error_messages/locales/en-US/metadata.ftl b/compiler/rustc_error_messages/locales/en-US/metadata.ftl index a4881dbc76455..e3e58cf8bed7e 100644 --- a/compiler/rustc_error_messages/locales/en-US/metadata.ftl +++ b/compiler/rustc_error_messages/locales/en-US/metadata.ftl @@ -170,3 +170,58 @@ metadata_failed_create_file = metadata_failed_create_encoded_metadata = failed to create encoded metadata from file: {$err} + +metadata_non_ascii_name = + cannot load a crate with a non-ascii name `{$crate_name}` + +metadata_extern_location_not_exist = + extern location for {$crate_name} does not exist: {$location} + +metadata_extern_location_not_file = + extern location for {$crate_name} is not a file: {$location} + +metadata_multiple_candidates = + multiple {$flavor} candidates for `{$crate_name}` found + +metadata_multiple_matching_crates = + multiple matching crates for `{$crate_name}` + .note = candidates:{$candidates} + +metadata_symbol_conflicts_current = + the current crate is indistinguishable from one of its dependencies: it has the same crate-name `{$crate_name}` and was compiled with the same `-C metadata` arguments. This will result in symbol conflicts between the two. + +metadata_symbol_conflicts_others = + found two different crates with name `{$crate_name}` that are not distinguished by differing `-C metadata`. This will result in symbol conflicts between the two. + +metadata_stable_crate_id_collision = + found crates (`{$crate_name0}` and `{$crate_name1}`) with colliding StableCrateId values. + +metadata_dl_error = + {$err} + +metadata_newer_crate_version = + found possibly newer version of crate `{$crate_name}`{$add_info} + .note = perhaps that crate needs to be recompiled? + +metadata_found_crate_versions = + the following crate versions were found:{$found_crates} + +metadata_no_crate_with_triple = + couldn't find crate `{$crate_name}` with expected target triple {$locator_triple}{$add_info} + +metadata_found_staticlib = + found staticlib `{$crate_name}` instead of rlib or dylib{$add_info} + .help = please recompile that crate using --crate-type lib + +metadata_incompatible_rustc = + found crate `{$crate_name}` compiled by an incompatible version of rustc{$add_info} + .help = please recompile that crate using this compiler ({$rustc_version}) (consider running `cargo clean` first) + +metadata_invalid_meta_files = + found invalid metadata files for crate `{$crate_name}`{$add_info} + +metadata_cannot_find_crate = + can't find crate for `{$crate_name}`{$add_info} + +metadata_no_dylib_plugin = + plugin `{$crate_name}` only found in rlib format, but must be available in dylib format diff --git a/compiler/rustc_metadata/src/errors.rs b/compiler/rustc_metadata/src/errors.rs index c373e49ba4958..d3f35ca8d164f 100644 --- a/compiler/rustc_metadata/src/errors.rs +++ b/compiler/rustc_metadata/src/errors.rs @@ -1,6 +1,10 @@ -// use rustc_errors::ErrorGuaranteed; +use std::path::PathBuf; + +use rustc_errors::{DiagnosticId, ErrorGuaranteed}; use rustc_macros::SessionDiagnostic; -use rustc_span::Span; +use rustc_session::{config, SessionDiagnostic}; +use rustc_span::{sym, Span, Symbol}; +use rustc_target::spec::TargetTriple; #[derive(SessionDiagnostic)] #[diag(metadata::rlib_required)] @@ -104,8 +108,8 @@ pub struct WasmImportForm { #[derive(SessionDiagnostic)] #[diag(metadata::empty_link_name, code = "E0454")] pub struct EmptyLinkName { - #[label] #[primary_span] + #[label] pub span: Span, } @@ -126,8 +130,8 @@ pub struct FrameworkOnlyWindows { #[derive(SessionDiagnostic)] #[diag(metadata::unknown_link_kind, code = "E0458")] pub struct UnknownLinkKind { - #[label] #[primary_span] + #[label] pub span: Span, pub kind: String, } @@ -221,8 +225,8 @@ pub struct IncompatibleWasmLink { #[derive(SessionDiagnostic)] #[diag(metadata::link_requires_name, code = "E0459")] pub struct LinkRequiresName { - #[label] #[primary_span] + #[label] pub span: Span, } @@ -378,3 +382,246 @@ pub struct FailedCreateFile { pub struct FailedCreateEncodedMetadata { pub err: String, } + +#[derive(SessionDiagnostic)] +#[diag(metadata::non_ascii_name)] +pub struct NonAsciiName { + #[primary_span] + pub span: Span, + pub crate_name: String, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::extern_location_not_exist)] +pub struct ExternLocationNotExist { + #[primary_span] + pub span: Span, + pub crate_name: String, + pub location: String, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::extern_location_not_file)] +pub struct ExternLocationNotFile { + #[primary_span] + pub span: Span, + pub crate_name: String, + pub location: String, +} + +pub struct MultipleCandidates { + pub span: Span, + pub flavor: String, + pub crate_name: String, + pub candidates: Vec, +} + +impl SessionDiagnostic<'_> for MultipleCandidates { + fn into_diagnostic( + self, + sess: &'_ rustc_session::parse::ParseSess, + ) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> { + let mut diag = sess.struct_err(rustc_errors::fluent::metadata::multiple_candidates); + diag.set_arg("crate_name", self.crate_name); + diag.set_arg("flavor", self.flavor); + diag.code(DiagnosticId::Error("E0465".into())); + diag.set_span(self.span); + for (i, candidate) in self.candidates.iter().enumerate() { + diag.span_note(self.span, &format!("candidate #{}: {}", i + 1, candidate.display())); + } + diag + } +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::multiple_matching_crates, code = "E0464")] +#[note] +pub struct MultipleMatchingCrates { + #[primary_span] + pub span: Span, + pub crate_name: String, + pub candidates: String, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::symbol_conflicts_current, code = "E0519")] +pub struct SymbolConflictsCurrent { + #[primary_span] + pub span: Span, + pub crate_name: String, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::symbol_conflicts_others, code = "E0523")] +pub struct SymbolConflictsOthers { + #[primary_span] + pub span: Span, + pub crate_name: String, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::stable_crate_id_collision)] +pub struct StableCrateIdCollision { + #[primary_span] + pub span: Span, + pub crate_name0: String, + pub crate_name1: String, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::dl_error)] +pub struct DlError { + #[primary_span] + pub span: Span, + pub err: String, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::newer_crate_version, code = "E0460")] +#[note] +#[note(metadata::found_crate_versions)] +pub struct NewerCrateVersion { + #[primary_span] + pub span: Span, + pub crate_name: String, + pub add_info: String, + pub found_crates: String, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::no_crate_with_triple, code = "E0461")] +#[note(metadata::found_crate_versions)] +pub struct NoCrateWithTriple { + #[primary_span] + pub span: Span, + pub crate_name: String, + pub locator_triple: String, + pub add_info: String, + pub found_crates: String, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::found_staticlib, code = "E0462")] +#[note(metadata::found_crate_versions)] +#[help] +pub struct FoundStaticlib { + #[primary_span] + pub span: Span, + pub crate_name: String, + pub add_info: String, + pub found_crates: String, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::incompatible_rustc, code = "E0514")] +#[note(metadata::found_crate_versions)] +#[help] +pub struct IncompatibleRustc { + #[primary_span] + pub span: Span, + pub crate_name: String, + pub add_info: String, + pub found_crates: String, + pub rustc_version: String, +} + +pub struct InvalidMetadataFiles { + pub span: Span, + pub crate_name: String, + pub add_info: String, + pub crate_rejections: Vec, +} + +impl SessionDiagnostic<'_> for InvalidMetadataFiles { + fn into_diagnostic( + self, + sess: &'_ rustc_session::parse::ParseSess, + ) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> { + let mut diag = sess.struct_err(rustc_errors::fluent::metadata::invalid_meta_files); + diag.set_arg("crate_name", self.crate_name); + diag.set_arg("add_info", self.add_info); + diag.code(DiagnosticId::Error("E0786".into())); + diag.set_span(self.span); + for crate_rejection in self.crate_rejections { + diag.note(crate_rejection); + } + diag + } +} + +pub struct CannotFindCrate { + pub span: Span, + pub crate_name: String, + pub crate_name_symbol: Symbol, + pub add_info: String, + pub missing_core: bool, + pub current_crate: String, + pub is_nightly_build: bool, + pub profiler_runtime: Symbol, + pub locator_triple: TargetTriple, +} + +impl SessionDiagnostic<'_> for CannotFindCrate { + fn into_diagnostic( + self, + sess: &'_ rustc_session::parse::ParseSess, + ) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> { + let mut diag = sess.struct_err(rustc_errors::fluent::metadata::cannot_find_crate); + diag.set_arg("crate_name", self.crate_name.clone()); + diag.set_arg("add_info", self.add_info); + diag.code(DiagnosticId::Error("E0463".into())); + diag.set_span(self.span); + // FIXME: Find a way to distill this logic down into the derived SessionDiagnostic form + if (self.crate_name_symbol == sym::std || self.crate_name_symbol == sym::core) + && self.locator_triple != TargetTriple::from_triple(config::host_triple()) + { + if self.missing_core { + diag.note(&format!("the `{}` target may not be installed", self.locator_triple)); + } else { + diag.note(&format!( + "the `{}` target may not support the standard library", + self.locator_triple + )); + } + // NOTE: this suggests using rustup, even though the user may not have it installed. + // That's because they could choose to install it; or this may give them a hint which + // target they need to install from their distro. + if self.missing_core { + diag.help(&format!( + "consider downloading the target with `rustup target add {}`", + self.locator_triple + )); + } + // Suggest using #![no_std]. #[no_core] is unstable and not really supported anyway. + // NOTE: this is a dummy span if `extern crate std` was injected by the compiler. + // If it's not a dummy, that means someone added `extern crate std` explicitly and + // `#![no_std]` won't help. + if !self.missing_core && self.span.is_dummy() { + diag.note(&format!( + "`std` is required by `{}` because it does not declare `#![no_std]`", + self.current_crate + )); + } + if self.is_nightly_build { + diag.help("consider building the standard library from source with `cargo build -Zbuild-std`"); + } + } else if self.crate_name_symbol == self.profiler_runtime { + diag.note("the compiler may have been built without the profiler runtime"); + } else if self.crate_name.starts_with("rustc_") { + diag.help( + "maybe you need to install the missing components with: \ + `rustup component add rust-src rustc-dev llvm-tools-preview`", + ); + } + diag.span_label(self.span, "can't find crate"); + diag + } +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::no_dylib_plugin, code = "E0457")] +pub struct NoDylibPlugin { + #[primary_span] + pub span: Span, + pub crate_name: String, +} diff --git a/compiler/rustc_metadata/src/locator.rs b/compiler/rustc_metadata/src/locator.rs index 2c1c84b0be26a..83c8756078ec4 100644 --- a/compiler/rustc_metadata/src/locator.rs +++ b/compiler/rustc_metadata/src/locator.rs @@ -213,6 +213,12 @@ //! metadata::locator or metadata::creader for all the juicy details! use crate::creader::Library; +use crate::errors::{ + CannotFindCrate, DlError, ExternLocationNotExist, ExternLocationNotFile, FoundStaticlib, + IncompatibleRustc, InvalidMetadataFiles, MultipleCandidates, MultipleMatchingCrates, + NewerCrateVersion, NoCrateWithTriple, NoDylibPlugin, NonAsciiName, StableCrateIdCollision, + SymbolConflictsCurrent, SymbolConflictsOthers, +}; use crate::rmeta::{rustc_version, MetadataBlob, METADATA_HEADER}; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; @@ -220,14 +226,14 @@ use rustc_data_structures::memmap::Mmap; use rustc_data_structures::owning_ref::OwningRef; use rustc_data_structures::svh::Svh; use rustc_data_structures::sync::MetadataRef; -use rustc_errors::{struct_span_err, FatalError}; +use rustc_errors::FatalError; use rustc_session::config::{self, CrateType}; use rustc_session::cstore::{CrateSource, MetadataLoader}; use rustc_session::filesearch::FileSearch; use rustc_session::search_paths::PathKind; use rustc_session::utils::CanonicalizedPath; use rustc_session::Session; -use rustc_span::symbol::{sym, Symbol}; +use rustc_span::symbol::Symbol; use rustc_span::Span; use rustc_target::spec::{Target, TargetTriple}; @@ -938,41 +944,33 @@ impl fmt::Display for MetadataError<'_> { impl CrateError { pub(crate) fn report(self, sess: &Session, span: Span, missing_core: bool) { - let mut diag = match self { - CrateError::NonAsciiName(crate_name) => sess.struct_span_err( - span, - &format!("cannot load a crate with a non-ascii name `{}`", crate_name), - ), - CrateError::ExternLocationNotExist(crate_name, loc) => sess.struct_span_err( - span, - &format!("extern location for {} does not exist: {}", crate_name, loc.display()), - ), - CrateError::ExternLocationNotFile(crate_name, loc) => sess.struct_span_err( - span, - &format!("extern location for {} is not a file: {}", crate_name, loc.display()), - ), + match self { + CrateError::NonAsciiName(crate_name) => { + sess.emit_err(NonAsciiName { span, crate_name: crate_name.to_string() }); + } + CrateError::ExternLocationNotExist(crate_name, loc) => { + sess.emit_err(ExternLocationNotExist { + span, + crate_name: crate_name.to_string(), + location: loc.display().to_string(), + }); + } + CrateError::ExternLocationNotFile(crate_name, loc) => { + sess.emit_err(ExternLocationNotFile { + span, + crate_name: crate_name.to_string(), + location: loc.display().to_string(), + }); + } CrateError::MultipleCandidates(crate_name, flavor, candidates) => { - let mut err = struct_span_err!( - sess, + sess.emit_err(MultipleCandidates { span, - E0465, - "multiple {} candidates for `{}` found", - flavor, - crate_name, - ); - for (i, candidate) in candidates.iter().enumerate() { - err.span_note(span, &format!("candidate #{}: {}", i + 1, candidate.display())); - } - err + flavor: flavor.to_string(), + crate_name: crate_name.to_string(), + candidates, + }); } CrateError::MultipleMatchingCrates(crate_name, libraries) => { - let mut err = struct_span_err!( - sess, - span, - E0464, - "multiple matching crates for `{}`", - crate_name - ); let mut libraries: Vec<_> = libraries.into_values().collect(); // Make ordering of candidates deterministic. // This has to `clone()` to work around lifetime restrictions with `sort_by_key()`. @@ -1000,223 +998,159 @@ impl CrateError { s }) .collect::(); - err.note(&format!("candidates:{}", candidates)); - err + sess.emit_err(MultipleMatchingCrates { + span, + crate_name: crate_name.to_string(), + candidates, + }); + } + CrateError::SymbolConflictsCurrent(root_name) => { + sess.emit_err(SymbolConflictsCurrent { span, crate_name: root_name.to_string() }); + } + CrateError::SymbolConflictsOthers(root_name) => { + sess.emit_err(SymbolConflictsOthers { span, crate_name: root_name.to_string() }); } - CrateError::SymbolConflictsCurrent(root_name) => struct_span_err!( - sess, - span, - E0519, - "the current crate is indistinguishable from one of its dependencies: it has the \ - same crate-name `{}` and was compiled with the same `-C metadata` arguments. \ - This will result in symbol conflicts between the two.", - root_name, - ), - CrateError::SymbolConflictsOthers(root_name) => struct_span_err!( - sess, - span, - E0523, - "found two different crates with name `{}` that are not distinguished by differing \ - `-C metadata`. This will result in symbol conflicts between the two.", - root_name, - ), CrateError::StableCrateIdCollision(crate_name0, crate_name1) => { - let msg = format!( - "found crates (`{}` and `{}`) with colliding StableCrateId values.", - crate_name0, crate_name1 - ); - sess.struct_span_err(span, &msg) + sess.emit_err(StableCrateIdCollision { + span, + crate_name0: crate_name0.to_string(), + crate_name1: crate_name1.to_string(), + }); + } + CrateError::DlOpen(s) | CrateError::DlSym(s) => { + sess.emit_err(DlError { span, err: s.to_string() }); } - CrateError::DlOpen(s) | CrateError::DlSym(s) => sess.struct_span_err(span, &s), CrateError::LocatorCombined(locator) => { let crate_name = locator.crate_name; - let add = match &locator.root { + let add_info = match &locator.root { None => String::new(), Some(r) => format!(" which `{}` depends on", r.name), }; - let mut msg = "the following crate versions were found:".to_string(); - let mut err = if !locator.crate_rejections.via_hash.is_empty() { - let mut err = struct_span_err!( - sess, - span, - E0460, - "found possibly newer version of crate `{}`{}", - crate_name, - add, - ); - err.note("perhaps that crate needs to be recompiled?"); + // FIXME: Is there any way to get these notes and helps onto every diagnostic in this + // huge branch arm without changing them all to manual implementations? + let mut global_loc_notes = Vec::new(); + let mut global_loc_helps = Vec::new(); + if !locator.crate_rejections.via_filename.is_empty() { + let mismatches = locator.crate_rejections.via_filename.iter(); + for CrateMismatch { path, .. } in mismatches { + global_loc_notes.push(format!( + "extern location for {} is of an unknown type: {}", + crate_name, + path.display(), + )); + global_loc_helps.push(format!( + "file name should be lib*.rlib or {}*.{}", + locator.dll_prefix, locator.dll_suffix + )); + } + panic!("!!!!! REVERT THIS COMMIT !!!!!"); + } + let mut found_crates = String::new(); + if !locator.crate_rejections.via_hash.is_empty() { let mismatches = locator.crate_rejections.via_hash.iter(); for CrateMismatch { path, .. } in mismatches { - msg.push_str(&format!("\ncrate `{}`: {}", crate_name, path.display())); + found_crates.push_str(&format!( + "\ncrate `{}`: {}", + crate_name, + path.display() + )); } if let Some(r) = locator.root { for path in r.source.paths() { - msg.push_str(&format!("\ncrate `{}`: {}", r.name, path.display())); + found_crates.push_str(&format!( + "\ncrate `{}`: {}", + r.name, + path.display() + )); } } - err.note(&msg); - err - } else if !locator.crate_rejections.via_triple.is_empty() { - let mut err = struct_span_err!( - sess, + sess.emit_err(NewerCrateVersion { span, - E0461, - "couldn't find crate `{}` with expected target triple {}{}", - crate_name, - locator.triple, - add, - ); + crate_name: crate_name.to_string(), + add_info, + found_crates, + }); + } else if !locator.crate_rejections.via_triple.is_empty() { let mismatches = locator.crate_rejections.via_triple.iter(); for CrateMismatch { path, got } in mismatches { - msg.push_str(&format!( + found_crates.push_str(&format!( "\ncrate `{}`, target triple {}: {}", crate_name, got, path.display(), )); } - err.note(&msg); - err - } else if !locator.crate_rejections.via_kind.is_empty() { - let mut err = struct_span_err!( - sess, + sess.emit_err(NoCrateWithTriple { span, - E0462, - "found staticlib `{}` instead of rlib or dylib{}", - crate_name, - add, - ); - err.help("please recompile that crate using --crate-type lib"); + crate_name: crate_name.to_string(), + locator_triple: locator.triple.to_string(), + add_info, + found_crates, + }); + } else if !locator.crate_rejections.via_kind.is_empty() { let mismatches = locator.crate_rejections.via_kind.iter(); for CrateMismatch { path, .. } in mismatches { - msg.push_str(&format!("\ncrate `{}`: {}", crate_name, path.display())); + found_crates.push_str(&format!( + "\ncrate `{}`: {}", + crate_name, + path.display() + )); } - err.note(&msg); - err - } else if !locator.crate_rejections.via_version.is_empty() { - let mut err = struct_span_err!( - sess, + sess.emit_err(FoundStaticlib { span, - E0514, - "found crate `{}` compiled by an incompatible version of rustc{}", - crate_name, - add, - ); - err.help(&format!( - "please recompile that crate using this compiler ({}) \ - (consider running `cargo clean` first)", - rustc_version(), - )); + crate_name: crate_name.to_string(), + add_info, + found_crates, + }); + } else if !locator.crate_rejections.via_version.is_empty() { let mismatches = locator.crate_rejections.via_version.iter(); for CrateMismatch { path, got } in mismatches { - msg.push_str(&format!( + found_crates.push_str(&format!( "\ncrate `{}` compiled by {}: {}", crate_name, got, path.display(), )); } - err.note(&msg); - err - } else if !locator.crate_rejections.via_invalid.is_empty() { - let mut err = struct_span_err!( - sess, + sess.emit_err(IncompatibleRustc { span, - E0786, - "found invalid metadata files for crate `{}`{}", - crate_name, - add, - ); + crate_name: crate_name.to_string(), + add_info, + found_crates, + rustc_version: rustc_version(), + }); + } else if !locator.crate_rejections.via_invalid.is_empty() { + let mut crate_rejections = Vec::new(); for CrateMismatch { path: _, got } in locator.crate_rejections.via_invalid { - err.note(&got); + crate_rejections.push(got); } - err + sess.emit_err(InvalidMetadataFiles { + span, + crate_name: crate_name.to_string(), + add_info, + crate_rejections, + }); } else { - let mut err = struct_span_err!( - sess, + sess.emit_err(CannotFindCrate { span, - E0463, - "can't find crate for `{}`{}", - crate_name, - add, - ); - - if (crate_name == sym::std || crate_name == sym::core) - && locator.triple != TargetTriple::from_triple(config::host_triple()) - { - if missing_core { - err.note(&format!( - "the `{}` target may not be installed", - locator.triple - )); - } else { - err.note(&format!( - "the `{}` target may not support the standard library", - locator.triple - )); - } - // NOTE: this suggests using rustup, even though the user may not have it installed. - // That's because they could choose to install it; or this may give them a hint which - // target they need to install from their distro. - if missing_core { - err.help(&format!( - "consider downloading the target with `rustup target add {}`", - locator.triple - )); - } - // Suggest using #![no_std]. #[no_core] is unstable and not really supported anyway. - // NOTE: this is a dummy span if `extern crate std` was injected by the compiler. - // If it's not a dummy, that means someone added `extern crate std` explicitly and `#![no_std]` won't help. - if !missing_core && span.is_dummy() { - let current_crate = - sess.opts.crate_name.as_deref().unwrap_or(""); - err.note(&format!( - "`std` is required by `{}` because it does not declare `#![no_std]`", - current_crate - )); - } - if sess.is_nightly_build() { - err.help("consider building the standard library from source with `cargo build -Zbuild-std`"); - } - } else if crate_name - == Symbol::intern(&sess.opts.unstable_opts.profiler_runtime) - { - err.note("the compiler may have been built without the profiler runtime"); - } else if crate_name.as_str().starts_with("rustc_") { - err.help( - "maybe you need to install the missing components with: \ - `rustup component add rust-src rustc-dev llvm-tools-preview`", - ); - } - err.span_label(span, "can't find crate"); - err - }; - - if !locator.crate_rejections.via_filename.is_empty() { - let mismatches = locator.crate_rejections.via_filename.iter(); - for CrateMismatch { path, .. } in mismatches { - err.note(&format!( - "extern location for {} is of an unknown type: {}", - crate_name, - path.display(), - )) - .help(&format!( - "file name should be lib*.rlib or {}*.{}", - locator.dll_prefix, locator.dll_suffix - )); - } + crate_name: crate_name.to_string(), + crate_name_symbol: crate_name, + add_info, + missing_core, + current_crate: sess + .opts + .crate_name + .clone() + .unwrap_or("".to_string()), + is_nightly_build: sess.is_nightly_build(), + profiler_runtime: Symbol::intern(&sess.opts.unstable_opts.profiler_runtime), + locator_triple: locator.triple, + }); } - err } - CrateError::NonDylibPlugin(crate_name) => struct_span_err!( - sess, - span, - E0457, - "plugin `{}` only found in rlib format, but must be available in dylib format", - crate_name, - ), - }; - - diag.emit(); + CrateError::NonDylibPlugin(crate_name) => { + sess.emit_err(NoDylibPlugin { span, crate_name: crate_name.to_string() }); + } + } } } diff --git a/compiler/rustc_metadata/src/native_libs.rs b/compiler/rustc_metadata/src/native_libs.rs index e8489232fbda6..dbaa2e9defa1a 100644 --- a/compiler/rustc_metadata/src/native_libs.rs +++ b/compiler/rustc_metadata/src/native_libs.rs @@ -1,7 +1,6 @@ use rustc_ast::{NestedMetaItem, CRATE_NODE_ID}; use rustc_attr as attr; use rustc_data_structures::fx::FxHashSet; -use rustc_errors::struct_span_err; use rustc_hir as hir; use rustc_hir::def::DefKind; use rustc_middle::ty::{List, ParamEnv, ParamEnvAnd, Ty, TyCtxt}; From 0d65819d529f222e47164f6c8132d8134909f2a4 Mon Sep 17 00:00:00 2001 From: Nathan Stocks Date: Fri, 26 Aug 2022 14:39:59 -0600 Subject: [PATCH 09/25] respond to review feedback: mainly eliminate as many conversions as possible... - ... when creating diagnostics in rustc_metadata - use the error_code! macro - pass macro output to diag.code() - use fluent from within manual implementation of SessionDiagnostic - emit the untested errors in case they occur in the wild - stop panicking in the probably-not-dead code, add fixme to write test --- Cargo.lock | 1 + .../locales/en-US/metadata.ftl | 30 +++ compiler/rustc_errors/Cargo.toml | 5 +- compiler/rustc_errors/src/diagnostic.rs | 7 + compiler/rustc_metadata/src/creader.rs | 19 +- .../rustc_metadata/src/dependency_format.rs | 30 ++- compiler/rustc_metadata/src/errors.rs | 215 +++++++++--------- compiler/rustc_metadata/src/fs.rs | 27 +-- compiler/rustc_metadata/src/locator.rs | 102 ++++----- compiler/rustc_metadata/src/native_libs.rs | 18 +- compiler/rustc_metadata/src/rmeta/encoder.rs | 6 +- 11 files changed, 234 insertions(+), 226 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 002d73be7d1de..0ce329ff07086 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3514,6 +3514,7 @@ dependencies = [ "rustc_macros", "rustc_serialize", "rustc_span", + "rustc_target", "serde", "serde_json", "termcolor", diff --git a/compiler/rustc_error_messages/locales/en-US/metadata.ftl b/compiler/rustc_error_messages/locales/en-US/metadata.ftl index e3e58cf8bed7e..dee01bcad4bbc 100644 --- a/compiler/rustc_error_messages/locales/en-US/metadata.ftl +++ b/compiler/rustc_error_messages/locales/en-US/metadata.ftl @@ -225,3 +225,33 @@ metadata_cannot_find_crate = metadata_no_dylib_plugin = plugin `{$crate_name}` only found in rlib format, but must be available in dylib format + +metadata_target_not_installed = + the `{$locator_triple}` target may not be installed + +metadata_target_no_std_support = + the `{$locator_triple}` target may not support the standard library + +metadata_consider_downloading_target = + consider downloading the target with `rustup target add {$locator_triple}` + +metadata_std_required = + `std` is required by `{$current_crate}` because it does not declare `#![no_std]` + +metadata_consider_building_std = + consider building the standard library from source with `cargo build -Zbuild-std` + +metadata_compiler_missing_profiler = + the compiler may have been built without the profiler runtime + +metadata_install_missing_components = + maybe you need to install the missing components with: `rustup component add rust-src rustc-dev llvm-tools-preview` + +metadata_cant_find_crate = + can't find crate + +metadata_crate_location_unknown_type = + extern location for {$crate_name} is of an unknown type: {$path} + +metadata_lib_filename_form = + file name should be lib*.rlib or {dll_prefix}*.{dll_suffix} diff --git a/compiler/rustc_errors/Cargo.toml b/compiler/rustc_errors/Cargo.toml index 36805aa874fe7..4d207fd17fb2d 100644 --- a/compiler/rustc_errors/Cargo.toml +++ b/compiler/rustc_errors/Cargo.toml @@ -15,13 +15,14 @@ rustc_macros = { path = "../rustc_macros" } rustc_data_structures = { path = "../rustc_data_structures" } rustc_hir = { path = "../rustc_hir" } rustc_lint_defs = { path = "../rustc_lint_defs" } +rustc_target = { path = "../rustc_target" } unicode-width = "0.1.4" atty = "0.2" termcolor = "1.0" annotate-snippets = "0.9" termize = "0.1.1" -serde = { version = "1.0.125", features = ["derive"] } +serde = { version = "1.0.125", features = [ "derive" ] } serde_json = "1.0.59" [target.'cfg(windows)'.dependencies] -winapi = { version = "0.3", features = ["handleapi", "synchapi", "winbase"] } +winapi = { version = "0.3", features = [ "handleapi", "synchapi", "winbase" ] } diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs index f75e2596f361b..b569ef4fc2c91 100644 --- a/compiler/rustc_errors/src/diagnostic.rs +++ b/compiler/rustc_errors/src/diagnostic.rs @@ -10,6 +10,7 @@ use rustc_lint_defs::{Applicability, LintExpectationId}; use rustc_span::edition::LATEST_STABLE_EDITION; use rustc_span::symbol::{Ident, MacroRulesNormalizedIdent, Symbol}; use rustc_span::{edition::Edition, Span, DUMMY_SP}; +use rustc_target::spec::PanicStrategy; use std::borrow::Cow; use std::fmt; use std::hash::{Hash, Hasher}; @@ -144,6 +145,12 @@ impl IntoDiagnosticArg for usize { } } +impl IntoDiagnosticArg for PanicStrategy { + fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { + DiagnosticArgValue::Str(Cow::Owned(self.desc().to_string())) + } +} + impl<'source> Into> for DiagnosticArgValue<'source> { fn into(self) -> FluentValue<'source> { match self { diff --git a/compiler/rustc_metadata/src/creader.rs b/compiler/rustc_metadata/src/creader.rs index f9aa3733f6a37..edffec8ab55c4 100644 --- a/compiler/rustc_metadata/src/creader.rs +++ b/compiler/rustc_metadata/src/creader.rs @@ -750,13 +750,10 @@ impl<'a> CrateLoader<'a> { // Sanity check the loaded crate to ensure it is indeed a panic runtime // and the panic strategy is indeed what we thought it was. if !data.is_panic_runtime() { - self.sess.emit_err(CrateNotPanicRuntime { crate_name: name.to_string() }); + self.sess.emit_err(CrateNotPanicRuntime { crate_name: name }); } if data.required_panic_strategy() != Some(desired_strategy) { - self.sess.emit_err(NoPanicStrategy { - crate_name: name.to_string(), - strategy: desired_strategy.desc().to_string(), - }); + self.sess.emit_err(NoPanicStrategy { crate_name: name, strategy: desired_strategy }); } self.cstore.injected_panic_runtime = Some(cnum); @@ -784,7 +781,7 @@ impl<'a> CrateLoader<'a> { // Sanity check the loaded crate to ensure it is indeed a profiler runtime if !data.is_profiler_runtime() { - self.sess.emit_err(NotProfilerRuntime { crate_name: name.to_string() }); + self.sess.emit_err(NotProfilerRuntime { crate_name: name }); } } @@ -828,8 +825,8 @@ impl<'a> CrateLoader<'a> { match global_allocator { Some(other_crate) => { self.sess.emit_err(ConflictingGlobalAlloc { - crate_name: data.name().to_string(), - other_crate_name: other_crate.to_string(), + crate_name: data.name(), + other_crate_name: other_crate, }); } None => global_allocator = Some(data.name()), @@ -874,9 +871,9 @@ impl<'a> CrateLoader<'a> { let data = self.cstore.get_crate_data(dep); if needs_dep(&data) { self.sess.emit_err(NoTransitiveNeedsDep { - crate_name: self.cstore.get_crate_data(krate).name().to_string(), - needs_crate_name: what.to_string(), - deps_crate_name: data.name().to_string(), + crate_name: self.cstore.get_crate_data(krate).name(), + needs_crate_name: what, + deps_crate_name: data.name(), }); } } diff --git a/compiler/rustc_metadata/src/dependency_format.rs b/compiler/rustc_metadata/src/dependency_format.rs index 5d1082acc0beb..9ad0099ad251b 100644 --- a/compiler/rustc_metadata/src/dependency_format.rs +++ b/compiler/rustc_metadata/src/dependency_format.rs @@ -140,7 +140,7 @@ fn calculate_type(tcx: TyCtxt<'_>, ty: CrateType) -> DependencyList { if src.rlib.is_some() { continue; } - sess.emit_err(RlibRequired { crate_name: tcx.crate_name(cnum).to_string() }); + sess.emit_err(RlibRequired { crate_name: tcx.crate_name(cnum) }); } return Vec::new(); } @@ -224,10 +224,7 @@ fn calculate_type(tcx: TyCtxt<'_>, ty: CrateType) -> DependencyList { Linkage::Static => "rlib", _ => "dylib", }; - sess.emit_err(LibRequired { - crate_name: tcx.crate_name(cnum).to_string(), - kind: kind.to_string(), - }); + sess.emit_err(LibRequired { crate_name: tcx.crate_name(cnum), kind: kind }); } } } @@ -251,8 +248,7 @@ fn add_library( // This error is probably a little obscure, but I imagine that it // can be refined over time. if link2 != link || link == RequireStatic { - tcx.sess - .emit_err(CrateDepMultiple { crate_name: tcx.crate_name(cnum).to_string() }); + tcx.sess.emit_err(CrateDepMultiple { crate_name: tcx.crate_name(cnum) }); } } None => { @@ -347,8 +343,8 @@ fn verify_ok(tcx: TyCtxt<'_>, list: &[Linkage]) { if tcx.is_panic_runtime(cnum) { if let Some((prev, _)) = panic_runtime { - let prev_name = tcx.crate_name(prev).to_string(); - let cur_name = tcx.crate_name(cnum).to_string(); + let prev_name = tcx.crate_name(prev); + let cur_name = tcx.crate_name(cnum); sess.emit_err(TwoPanicRuntimes { prev_name, cur_name }); } panic_runtime = Some(( @@ -370,8 +366,8 @@ fn verify_ok(tcx: TyCtxt<'_>, list: &[Linkage]) { // our same strategy. if found_strategy != desired_strategy { sess.emit_err(BadPanicStrategy { - runtime: tcx.crate_name(runtime_cnum).to_string(), - strategy: desired_strategy.desc().to_string(), + runtime: tcx.crate_name(runtime_cnum), + strategy: desired_strategy, }); } @@ -390,17 +386,17 @@ fn verify_ok(tcx: TyCtxt<'_>, list: &[Linkage]) { if let Some(found_strategy) = tcx.required_panic_strategy(cnum) && desired_strategy != found_strategy { sess.emit_err(RequiredPanicStrategy { - crate_name: tcx.crate_name(cnum).to_string(), - found_strategy: found_strategy.desc().to_string(), - desired_strategy: desired_strategy.desc().to_string() }); + crate_name: tcx.crate_name(cnum), + found_strategy, + desired_strategy}); } let found_drop_strategy = tcx.panic_in_drop_strategy(cnum); if tcx.sess.opts.unstable_opts.panic_in_drop != found_drop_strategy { sess.emit_err(IncompatiblePanicInDropStrategy { - crate_name: tcx.crate_name(cnum).to_string(), - found_strategy: found_drop_strategy.desc().to_string(), - desired_strategy: tcx.sess.opts.unstable_opts.panic_in_drop.desc().to_string(), + crate_name: tcx.crate_name(cnum), + found_strategy: found_drop_strategy, + desired_strategy: tcx.sess.opts.unstable_opts.panic_in_drop, }); } } diff --git a/compiler/rustc_metadata/src/errors.rs b/compiler/rustc_metadata/src/errors.rs index d3f35ca8d164f..565c96917e2fc 100644 --- a/compiler/rustc_metadata/src/errors.rs +++ b/compiler/rustc_metadata/src/errors.rs @@ -1,59 +1,64 @@ -use std::path::PathBuf; +use std::{ + io::Error, + path::{Path, PathBuf}, +}; -use rustc_errors::{DiagnosticId, ErrorGuaranteed}; +use rustc_errors::{error_code, ErrorGuaranteed}; use rustc_macros::SessionDiagnostic; use rustc_session::{config, SessionDiagnostic}; use rustc_span::{sym, Span, Symbol}; -use rustc_target::spec::TargetTriple; +use rustc_target::spec::{PanicStrategy, TargetTriple}; + +use crate::locator::CrateFlavor; #[derive(SessionDiagnostic)] #[diag(metadata::rlib_required)] pub struct RlibRequired { - pub crate_name: String, + pub crate_name: Symbol, } #[derive(SessionDiagnostic)] #[diag(metadata::lib_required)] -pub struct LibRequired { - pub crate_name: String, - pub kind: String, +pub struct LibRequired<'a> { + pub crate_name: Symbol, + pub kind: &'a str, } #[derive(SessionDiagnostic)] #[diag(metadata::crate_dep_multiple)] #[help] pub struct CrateDepMultiple { - pub crate_name: String, + pub crate_name: Symbol, } #[derive(SessionDiagnostic)] #[diag(metadata::two_panic_runtimes)] pub struct TwoPanicRuntimes { - pub prev_name: String, - pub cur_name: String, + pub prev_name: Symbol, + pub cur_name: Symbol, } #[derive(SessionDiagnostic)] #[diag(metadata::bad_panic_strategy)] pub struct BadPanicStrategy { - pub runtime: String, - pub strategy: String, + pub runtime: Symbol, + pub strategy: PanicStrategy, } #[derive(SessionDiagnostic)] #[diag(metadata::required_panic_strategy)] pub struct RequiredPanicStrategy { - pub crate_name: String, - pub found_strategy: String, - pub desired_strategy: String, + pub crate_name: Symbol, + pub found_strategy: PanicStrategy, + pub desired_strategy: PanicStrategy, } #[derive(SessionDiagnostic)] #[diag(metadata::incompatible_panic_in_drop_strategy)] pub struct IncompatiblePanicInDropStrategy { - pub crate_name: String, - pub found_strategy: String, - pub desired_strategy: String, + pub crate_name: Symbol, + pub found_strategy: PanicStrategy, + pub desired_strategy: PanicStrategy, } #[derive(SessionDiagnostic)] @@ -129,11 +134,11 @@ pub struct FrameworkOnlyWindows { #[derive(SessionDiagnostic)] #[diag(metadata::unknown_link_kind, code = "E0458")] -pub struct UnknownLinkKind { +pub struct UnknownLinkKind<'a> { #[primary_span] #[label] pub span: Span, - pub kind: String, + pub kind: &'a str, } #[derive(SessionDiagnostic)] @@ -180,10 +185,10 @@ pub struct InvalidLinkModifier { #[derive(SessionDiagnostic)] #[diag(metadata::multiple_modifiers)] -pub struct MultipleModifiers { +pub struct MultipleModifiers<'a> { #[primary_span] pub span: Span, - pub modifier: String, + pub modifier: &'a str, } #[derive(SessionDiagnostic)] @@ -209,10 +214,10 @@ pub struct AsNeededCompatibility { #[derive(SessionDiagnostic)] #[diag(metadata::unknown_link_modifier)] -pub struct UnknownLinkModifier { +pub struct UnknownLinkModifier<'a> { #[primary_span] pub span: Span, - pub modifier: String, + pub modifier: &'a str, } #[derive(SessionDiagnostic)] @@ -250,20 +255,20 @@ pub struct LibFrameworkApple; #[derive(SessionDiagnostic)] #[diag(metadata::empty_renaming_target)] -pub struct EmptyRenamingTarget { - pub lib_name: String, +pub struct EmptyRenamingTarget<'a> { + pub lib_name: &'a str, } #[derive(SessionDiagnostic)] #[diag(metadata::renaming_no_link)] -pub struct RenamingNoLink { - pub lib_name: String, +pub struct RenamingNoLink<'a> { + pub lib_name: &'a str, } #[derive(SessionDiagnostic)] #[diag(metadata::multiple_renamings)] -pub struct MultipleRenamings { - pub lib_name: String, +pub struct MultipleRenamings<'a> { + pub lib_name: &'a str, } #[derive(SessionDiagnostic)] @@ -290,32 +295,32 @@ pub struct UnsupportedAbi { #[derive(SessionDiagnostic)] #[diag(metadata::fail_create_file_encoder)] pub struct FailCreateFileEncoder { - pub err: String, + pub err: Error, } #[derive(SessionDiagnostic)] #[diag(metadata::fail_seek_file)] pub struct FailSeekFile { - pub err: String, + pub err: Error, } #[derive(SessionDiagnostic)] #[diag(metadata::fail_write_file)] pub struct FailWriteFile { - pub err: String, + pub err: Error, } #[derive(SessionDiagnostic)] #[diag(metadata::crate_not_panic_runtime)] pub struct CrateNotPanicRuntime { - pub crate_name: String, + pub crate_name: Symbol, } #[derive(SessionDiagnostic)] #[diag(metadata::no_panic_strategy)] pub struct NoPanicStrategy { - pub crate_name: String, - pub strategy: String, + pub crate_name: Symbol, + pub strategy: PanicStrategy, } #[derive(SessionDiagnostic)] @@ -325,7 +330,7 @@ pub struct ProfilerBuiltinsNeedsCore; #[derive(SessionDiagnostic)] #[diag(metadata::not_profiler_runtime)] pub struct NotProfilerRuntime { - pub crate_name: String, + pub crate_name: Symbol, } #[derive(SessionDiagnostic)] @@ -341,8 +346,8 @@ pub struct NoMultipleGlobalAlloc { #[derive(SessionDiagnostic)] #[diag(metadata::conflicting_global_alloc)] pub struct ConflictingGlobalAlloc { - pub crate_name: String, - pub other_crate_name: String, + pub crate_name: Symbol, + pub other_crate_name: Symbol, } #[derive(SessionDiagnostic)] @@ -351,36 +356,36 @@ pub struct GlobalAllocRequired; #[derive(SessionDiagnostic)] #[diag(metadata::no_transitive_needs_dep)] -pub struct NoTransitiveNeedsDep { - pub crate_name: String, - pub needs_crate_name: String, - pub deps_crate_name: String, +pub struct NoTransitiveNeedsDep<'a> { + pub crate_name: Symbol, + pub needs_crate_name: &'a str, + pub deps_crate_name: Symbol, } #[derive(SessionDiagnostic)] #[diag(metadata::failed_write_error)] pub struct FailedWriteError { - pub filename: String, - pub err: String, + pub filename: PathBuf, + pub err: Error, } #[derive(SessionDiagnostic)] #[diag(metadata::failed_create_tempdir)] pub struct FailedCreateTempdir { - pub err: String, + pub err: Error, } #[derive(SessionDiagnostic)] #[diag(metadata::failed_create_file)] -pub struct FailedCreateFile { - pub filename: String, - pub err: String, +pub struct FailedCreateFile<'a> { + pub filename: &'a Path, + pub err: Error, } #[derive(SessionDiagnostic)] #[diag(metadata::failed_create_encoded_metadata)] pub struct FailedCreateEncodedMetadata { - pub err: String, + pub err: Error, } #[derive(SessionDiagnostic)] @@ -388,31 +393,31 @@ pub struct FailedCreateEncodedMetadata { pub struct NonAsciiName { #[primary_span] pub span: Span, - pub crate_name: String, + pub crate_name: Symbol, } #[derive(SessionDiagnostic)] #[diag(metadata::extern_location_not_exist)] -pub struct ExternLocationNotExist { +pub struct ExternLocationNotExist<'a> { #[primary_span] pub span: Span, - pub crate_name: String, - pub location: String, + pub crate_name: Symbol, + pub location: &'a Path, } #[derive(SessionDiagnostic)] #[diag(metadata::extern_location_not_file)] -pub struct ExternLocationNotFile { +pub struct ExternLocationNotFile<'a> { #[primary_span] pub span: Span, - pub crate_name: String, - pub location: String, + pub crate_name: Symbol, + pub location: &'a Path, } -pub struct MultipleCandidates { +pub(crate) struct MultipleCandidates { pub span: Span, - pub flavor: String, - pub crate_name: String, + pub flavor: CrateFlavor, + pub crate_name: Symbol, pub candidates: Vec, } @@ -424,7 +429,7 @@ impl SessionDiagnostic<'_> for MultipleCandidates { let mut diag = sess.struct_err(rustc_errors::fluent::metadata::multiple_candidates); diag.set_arg("crate_name", self.crate_name); diag.set_arg("flavor", self.flavor); - diag.code(DiagnosticId::Error("E0465".into())); + diag.code(error_code!(E0465)); diag.set_span(self.span); for (i, candidate) in self.candidates.iter().enumerate() { diag.span_note(self.span, &format!("candidate #{}: {}", i + 1, candidate.display())); @@ -439,7 +444,7 @@ impl SessionDiagnostic<'_> for MultipleCandidates { pub struct MultipleMatchingCrates { #[primary_span] pub span: Span, - pub crate_name: String, + pub crate_name: Symbol, pub candidates: String, } @@ -448,7 +453,7 @@ pub struct MultipleMatchingCrates { pub struct SymbolConflictsCurrent { #[primary_span] pub span: Span, - pub crate_name: String, + pub crate_name: Symbol, } #[derive(SessionDiagnostic)] @@ -456,7 +461,7 @@ pub struct SymbolConflictsCurrent { pub struct SymbolConflictsOthers { #[primary_span] pub span: Span, - pub crate_name: String, + pub crate_name: Symbol, } #[derive(SessionDiagnostic)] @@ -464,8 +469,8 @@ pub struct SymbolConflictsOthers { pub struct StableCrateIdCollision { #[primary_span] pub span: Span, - pub crate_name0: String, - pub crate_name1: String, + pub crate_name0: Symbol, + pub crate_name1: Symbol, } #[derive(SessionDiagnostic)] @@ -483,7 +488,7 @@ pub struct DlError { pub struct NewerCrateVersion { #[primary_span] pub span: Span, - pub crate_name: String, + pub crate_name: Symbol, pub add_info: String, pub found_crates: String, } @@ -491,11 +496,11 @@ pub struct NewerCrateVersion { #[derive(SessionDiagnostic)] #[diag(metadata::no_crate_with_triple, code = "E0461")] #[note(metadata::found_crate_versions)] -pub struct NoCrateWithTriple { +pub struct NoCrateWithTriple<'a> { #[primary_span] pub span: Span, - pub crate_name: String, - pub locator_triple: String, + pub crate_name: Symbol, + pub locator_triple: &'a str, pub add_info: String, pub found_crates: String, } @@ -507,7 +512,7 @@ pub struct NoCrateWithTriple { pub struct FoundStaticlib { #[primary_span] pub span: Span, - pub crate_name: String, + pub crate_name: Symbol, pub add_info: String, pub found_crates: String, } @@ -519,7 +524,7 @@ pub struct FoundStaticlib { pub struct IncompatibleRustc { #[primary_span] pub span: Span, - pub crate_name: String, + pub crate_name: Symbol, pub add_info: String, pub found_crates: String, pub rustc_version: String, @@ -527,7 +532,7 @@ pub struct IncompatibleRustc { pub struct InvalidMetadataFiles { pub span: Span, - pub crate_name: String, + pub crate_name: Symbol, pub add_info: String, pub crate_rejections: Vec, } @@ -540,7 +545,7 @@ impl SessionDiagnostic<'_> for InvalidMetadataFiles { let mut diag = sess.struct_err(rustc_errors::fluent::metadata::invalid_meta_files); diag.set_arg("crate_name", self.crate_name); diag.set_arg("add_info", self.add_info); - diag.code(DiagnosticId::Error("E0786".into())); + diag.code(error_code!(E0786)); diag.set_span(self.span); for crate_rejection in self.crate_rejections { diag.note(crate_rejection); @@ -551,8 +556,7 @@ impl SessionDiagnostic<'_> for InvalidMetadataFiles { pub struct CannotFindCrate { pub span: Span, - pub crate_name: String, - pub crate_name_symbol: Symbol, + pub crate_name: Symbol, pub add_info: String, pub missing_core: bool, pub current_crate: String, @@ -567,53 +571,41 @@ impl SessionDiagnostic<'_> for CannotFindCrate { sess: &'_ rustc_session::parse::ParseSess, ) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> { let mut diag = sess.struct_err(rustc_errors::fluent::metadata::cannot_find_crate); - diag.set_arg("crate_name", self.crate_name.clone()); + diag.set_arg("crate_name", self.crate_name); diag.set_arg("add_info", self.add_info); - diag.code(DiagnosticId::Error("E0463".into())); + diag.set_arg("locator_triple", self.locator_triple.triple()); + diag.code(error_code!(E0463)); diag.set_span(self.span); - // FIXME: Find a way to distill this logic down into the derived SessionDiagnostic form - if (self.crate_name_symbol == sym::std || self.crate_name_symbol == sym::core) + if (self.crate_name == sym::std || self.crate_name == sym::core) && self.locator_triple != TargetTriple::from_triple(config::host_triple()) { if self.missing_core { - diag.note(&format!("the `{}` target may not be installed", self.locator_triple)); + diag.note(rustc_errors::fluent::metadata::target_not_installed); } else { - diag.note(&format!( - "the `{}` target may not support the standard library", - self.locator_triple - )); + diag.note(rustc_errors::fluent::metadata::target_no_std_support); } // NOTE: this suggests using rustup, even though the user may not have it installed. // That's because they could choose to install it; or this may give them a hint which // target they need to install from their distro. if self.missing_core { - diag.help(&format!( - "consider downloading the target with `rustup target add {}`", - self.locator_triple - )); + diag.help(rustc_errors::fluent::metadata::consider_downloading_target); } // Suggest using #![no_std]. #[no_core] is unstable and not really supported anyway. // NOTE: this is a dummy span if `extern crate std` was injected by the compiler. // If it's not a dummy, that means someone added `extern crate std` explicitly and // `#![no_std]` won't help. if !self.missing_core && self.span.is_dummy() { - diag.note(&format!( - "`std` is required by `{}` because it does not declare `#![no_std]`", - self.current_crate - )); + diag.note(rustc_errors::fluent::metadata::std_required); } if self.is_nightly_build { - diag.help("consider building the standard library from source with `cargo build -Zbuild-std`"); + diag.help(rustc_errors::fluent::metadata::consider_building_std); } - } else if self.crate_name_symbol == self.profiler_runtime { - diag.note("the compiler may have been built without the profiler runtime"); - } else if self.crate_name.starts_with("rustc_") { - diag.help( - "maybe you need to install the missing components with: \ - `rustup component add rust-src rustc-dev llvm-tools-preview`", - ); + } else if self.crate_name == self.profiler_runtime { + diag.note(rustc_errors::fluent::metadata::compiler_missing_profiler); + } else if self.crate_name.as_str().starts_with("rustc_") { + diag.help(rustc_errors::fluent::metadata::install_missing_components); } - diag.span_label(self.span, "can't find crate"); + diag.span_label(self.span, rustc_errors::fluent::metadata::cant_find_crate); diag } } @@ -623,5 +615,22 @@ impl SessionDiagnostic<'_> for CannotFindCrate { pub struct NoDylibPlugin { #[primary_span] pub span: Span, - pub crate_name: String, + pub crate_name: Symbol, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::crate_location_unknown_type)] +pub struct CrateLocationUnknownType<'a> { + #[primary_span] + pub span: Span, + pub path: &'a Path, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::lib_filename_form)] +pub struct LibFilenameForm<'a> { + #[primary_span] + pub span: Span, + pub dll_prefix: &'a str, + pub dll_suffix: &'a str, } diff --git a/compiler/rustc_metadata/src/fs.rs b/compiler/rustc_metadata/src/fs.rs index 67c18766c5959..f360a586476e7 100644 --- a/compiler/rustc_metadata/src/fs.rs +++ b/compiler/rustc_metadata/src/fs.rs @@ -26,11 +26,8 @@ pub fn emit_metadata(sess: &Session, metadata: &[u8], tmpdir: &MaybeTempDir) -> let out_filename = tmpdir.as_ref().join(METADATA_FILENAME); let result = fs::write(&out_filename, metadata); - if let Err(e) = result { - sess.emit_fatal(FailedWriteError { - filename: out_filename.display().to_string(), - err: e.to_string(), - }); + if let Err(err) = result { + sess.emit_fatal(FailedWriteError { filename: out_filename, err }); } out_filename @@ -71,7 +68,7 @@ pub fn encode_and_write_metadata( let metadata_tmpdir = TempFileBuilder::new() .prefix("rmeta") .tempdir_in(out_filename.parent().unwrap_or_else(|| Path::new(""))) - .unwrap_or_else(|err| tcx.sess.emit_fatal(FailedCreateTempdir { err: err.to_string() })); + .unwrap_or_else(|err| tcx.sess.emit_fatal(FailedCreateTempdir { err })); let metadata_tmpdir = MaybeTempDir::new(metadata_tmpdir, tcx.sess.opts.cg.save_temps); let metadata_filename = metadata_tmpdir.as_ref().join(METADATA_FILENAME); @@ -79,11 +76,8 @@ pub fn encode_and_write_metadata( // This simplifies the creation of the output `out_filename` when requested. match metadata_kind { MetadataKind::None => { - std::fs::File::create(&metadata_filename).unwrap_or_else(|e| { - tcx.sess.emit_fatal(FailedCreateFile { - filename: metadata_filename.display().to_string(), - err: e.to_string(), - }); + std::fs::File::create(&metadata_filename).unwrap_or_else(|err| { + tcx.sess.emit_fatal(FailedCreateFile { filename: &metadata_filename, err }); }); } MetadataKind::Uncompressed | MetadataKind::Compressed => { @@ -98,11 +92,8 @@ pub fn encode_and_write_metadata( // this file always exists. let need_metadata_file = tcx.sess.opts.output_types.contains_key(&OutputType::Metadata); let (metadata_filename, metadata_tmpdir) = if need_metadata_file { - if let Err(e) = non_durable_rename(&metadata_filename, &out_filename) { - tcx.sess.emit_fatal(FailedWriteError { - filename: out_filename.display().to_string(), - err: e.to_string(), - }); + if let Err(err) = non_durable_rename(&metadata_filename, &out_filename) { + tcx.sess.emit_fatal(FailedWriteError { filename: out_filename, err }); } if tcx.sess.opts.json_artifact_notifications { tcx.sess @@ -117,8 +108,8 @@ pub fn encode_and_write_metadata( // Load metadata back to memory: codegen may need to include it in object files. let metadata = - EncodedMetadata::from_path(metadata_filename, metadata_tmpdir).unwrap_or_else(|e| { - tcx.sess.emit_fatal(FailedCreateEncodedMetadata { err: e.to_string() }); + EncodedMetadata::from_path(metadata_filename, metadata_tmpdir).unwrap_or_else(|err| { + tcx.sess.emit_fatal(FailedCreateEncodedMetadata { err }); }); let need_metadata_module = metadata_kind == MetadataKind::Compressed; diff --git a/compiler/rustc_metadata/src/locator.rs b/compiler/rustc_metadata/src/locator.rs index 83c8756078ec4..5edad819e7e3c 100644 --- a/compiler/rustc_metadata/src/locator.rs +++ b/compiler/rustc_metadata/src/locator.rs @@ -214,10 +214,11 @@ use crate::creader::Library; use crate::errors::{ - CannotFindCrate, DlError, ExternLocationNotExist, ExternLocationNotFile, FoundStaticlib, - IncompatibleRustc, InvalidMetadataFiles, MultipleCandidates, MultipleMatchingCrates, - NewerCrateVersion, NoCrateWithTriple, NoDylibPlugin, NonAsciiName, StableCrateIdCollision, - SymbolConflictsCurrent, SymbolConflictsOthers, + CannotFindCrate, CrateLocationUnknownType, DlError, ExternLocationNotExist, + ExternLocationNotFile, FoundStaticlib, IncompatibleRustc, InvalidMetadataFiles, + LibFilenameForm, MultipleCandidates, MultipleMatchingCrates, NewerCrateVersion, + NoCrateWithTriple, NoDylibPlugin, NonAsciiName, StableCrateIdCollision, SymbolConflictsCurrent, + SymbolConflictsOthers, }; use crate::rmeta::{rustc_version, MetadataBlob, METADATA_HEADER}; @@ -226,7 +227,7 @@ use rustc_data_structures::memmap::Mmap; use rustc_data_structures::owning_ref::OwningRef; use rustc_data_structures::svh::Svh; use rustc_data_structures::sync::MetadataRef; -use rustc_errors::FatalError; +use rustc_errors::{DiagnosticArgValue, FatalError, IntoDiagnosticArg}; use rustc_session::config::{self, CrateType}; use rustc_session::cstore::{CrateSource, MetadataLoader}; use rustc_session::filesearch::FileSearch; @@ -238,6 +239,7 @@ use rustc_span::Span; use rustc_target::spec::{Target, TargetTriple}; use snap::read::FrameDecoder; +use std::borrow::Cow; use std::fmt::Write as _; use std::io::{Read, Result as IoResult, Write}; use std::path::{Path, PathBuf}; @@ -294,6 +296,16 @@ impl fmt::Display for CrateFlavor { } } +impl IntoDiagnosticArg for CrateFlavor { + fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue<'static> { + match self { + CrateFlavor::Rlib => DiagnosticArgValue::Str(Cow::Borrowed("rlib")), + CrateFlavor::Rmeta => DiagnosticArgValue::Str(Cow::Borrowed("rmeta")), + CrateFlavor::Dylib => DiagnosticArgValue::Str(Cow::Borrowed("dylib")), + } + } +} + impl<'a> CrateLocator<'a> { pub(crate) fn new( sess: &'a Session, @@ -946,29 +958,16 @@ impl CrateError { pub(crate) fn report(self, sess: &Session, span: Span, missing_core: bool) { match self { CrateError::NonAsciiName(crate_name) => { - sess.emit_err(NonAsciiName { span, crate_name: crate_name.to_string() }); + sess.emit_err(NonAsciiName { span, crate_name }); } CrateError::ExternLocationNotExist(crate_name, loc) => { - sess.emit_err(ExternLocationNotExist { - span, - crate_name: crate_name.to_string(), - location: loc.display().to_string(), - }); + sess.emit_err(ExternLocationNotExist { span, crate_name, location: &loc }); } CrateError::ExternLocationNotFile(crate_name, loc) => { - sess.emit_err(ExternLocationNotFile { - span, - crate_name: crate_name.to_string(), - location: loc.display().to_string(), - }); + sess.emit_err(ExternLocationNotFile { span, crate_name, location: &loc }); } CrateError::MultipleCandidates(crate_name, flavor, candidates) => { - sess.emit_err(MultipleCandidates { - span, - flavor: flavor.to_string(), - crate_name: crate_name.to_string(), - candidates, - }); + sess.emit_err(MultipleCandidates { span, flavor: flavor, crate_name, candidates }); } CrateError::MultipleMatchingCrates(crate_name, libraries) => { let mut libraries: Vec<_> = libraries.into_values().collect(); @@ -998,27 +997,23 @@ impl CrateError { s }) .collect::(); - sess.emit_err(MultipleMatchingCrates { - span, - crate_name: crate_name.to_string(), - candidates, - }); + sess.emit_err(MultipleMatchingCrates { span, crate_name, candidates }); } CrateError::SymbolConflictsCurrent(root_name) => { - sess.emit_err(SymbolConflictsCurrent { span, crate_name: root_name.to_string() }); + sess.emit_err(SymbolConflictsCurrent { span, crate_name: root_name }); } CrateError::SymbolConflictsOthers(root_name) => { - sess.emit_err(SymbolConflictsOthers { span, crate_name: root_name.to_string() }); + sess.emit_err(SymbolConflictsOthers { span, crate_name: root_name }); } CrateError::StableCrateIdCollision(crate_name0, crate_name1) => { sess.emit_err(StableCrateIdCollision { span, - crate_name0: crate_name0.to_string(), - crate_name1: crate_name1.to_string(), + crate_name0: crate_name0, + crate_name1: crate_name1, }); } CrateError::DlOpen(s) | CrateError::DlSym(s) => { - sess.emit_err(DlError { span, err: s.to_string() }); + sess.emit_err(DlError { span, err: s }); } CrateError::LocatorCombined(locator) => { let crate_name = locator.crate_name; @@ -1026,24 +1021,17 @@ impl CrateError { None => String::new(), Some(r) => format!(" which `{}` depends on", r.name), }; - // FIXME: Is there any way to get these notes and helps onto every diagnostic in this - // huge branch arm without changing them all to manual implementations? - let mut global_loc_notes = Vec::new(); - let mut global_loc_helps = Vec::new(); + // FIXME: There are no tests for CrateLocationUnknownType or LibFilenameForm if !locator.crate_rejections.via_filename.is_empty() { let mismatches = locator.crate_rejections.via_filename.iter(); for CrateMismatch { path, .. } in mismatches { - global_loc_notes.push(format!( - "extern location for {} is of an unknown type: {}", - crate_name, - path.display(), - )); - global_loc_helps.push(format!( - "file name should be lib*.rlib or {}*.{}", - locator.dll_prefix, locator.dll_suffix - )); + sess.emit_err(CrateLocationUnknownType { span, path: &path }); + sess.emit_err(LibFilenameForm { + span, + dll_prefix: &locator.dll_prefix, + dll_suffix: &locator.dll_suffix, + }); } - panic!("!!!!! REVERT THIS COMMIT !!!!!"); } let mut found_crates = String::new(); if !locator.crate_rejections.via_hash.is_empty() { @@ -1066,7 +1054,7 @@ impl CrateError { } sess.emit_err(NewerCrateVersion { span, - crate_name: crate_name.to_string(), + crate_name: crate_name, add_info, found_crates, }); @@ -1082,8 +1070,8 @@ impl CrateError { } sess.emit_err(NoCrateWithTriple { span, - crate_name: crate_name.to_string(), - locator_triple: locator.triple.to_string(), + crate_name: crate_name, + locator_triple: locator.triple.triple(), add_info, found_crates, }); @@ -1096,12 +1084,7 @@ impl CrateError { path.display() )); } - sess.emit_err(FoundStaticlib { - span, - crate_name: crate_name.to_string(), - add_info, - found_crates, - }); + sess.emit_err(FoundStaticlib { span, crate_name, add_info, found_crates }); } else if !locator.crate_rejections.via_version.is_empty() { let mismatches = locator.crate_rejections.via_version.iter(); for CrateMismatch { path, got } in mismatches { @@ -1114,7 +1097,7 @@ impl CrateError { } sess.emit_err(IncompatibleRustc { span, - crate_name: crate_name.to_string(), + crate_name, add_info, found_crates, rustc_version: rustc_version(), @@ -1126,15 +1109,14 @@ impl CrateError { } sess.emit_err(InvalidMetadataFiles { span, - crate_name: crate_name.to_string(), + crate_name, add_info, crate_rejections, }); } else { sess.emit_err(CannotFindCrate { span, - crate_name: crate_name.to_string(), - crate_name_symbol: crate_name, + crate_name, add_info, missing_core, current_crate: sess @@ -1149,7 +1131,7 @@ impl CrateError { } } CrateError::NonDylibPlugin(crate_name) => { - sess.emit_err(NoDylibPlugin { span, crate_name: crate_name.to_string() }); + sess.emit_err(NoDylibPlugin { span, crate_name }); } } } diff --git a/compiler/rustc_metadata/src/native_libs.rs b/compiler/rustc_metadata/src/native_libs.rs index dbaa2e9defa1a..19f64ef70c9c6 100644 --- a/compiler/rustc_metadata/src/native_libs.rs +++ b/compiler/rustc_metadata/src/native_libs.rs @@ -124,7 +124,7 @@ impl<'tcx> Collector<'tcx> { NativeLibKind::RawDylib } kind => { - sess.emit_err(UnknownLinkKind { span, kind: kind.to_string() }); + sess.emit_err(UnknownLinkKind { span, kind }); continue; } }; @@ -249,10 +249,7 @@ impl<'tcx> Collector<'tcx> { } let assign_modifier = |dst: &mut Option| { if dst.is_some() { - sess.emit_err(MultipleModifiers { - span, - modifier: modifier.to_string(), - }); + sess.emit_err(MultipleModifiers { span, modifier }); } else { *dst = Some(value); } @@ -287,10 +284,7 @@ impl<'tcx> Collector<'tcx> { } _ => { - sess.emit_err(UnknownLinkModifier { - span, - modifier: modifier.to_string(), - }); + sess.emit_err(UnknownLinkModifier { span, modifier }); } } } @@ -379,11 +373,11 @@ impl<'tcx> Collector<'tcx> { .filter_map(|lib| lib.name.as_ref()) .any(|n| n.as_str() == lib.name); if new_name.is_empty() { - self.tcx.sess.emit_err(EmptyRenamingTarget { lib_name: lib.name.clone() }); + self.tcx.sess.emit_err(EmptyRenamingTarget { lib_name: &lib.name }); } else if !any_duplicate { - self.tcx.sess.emit_err(RenamingNoLink { lib_name: lib.name.clone() }); + self.tcx.sess.emit_err(RenamingNoLink { lib_name: &lib.name }); } else if !renames.insert(&lib.name) { - self.tcx.sess.emit_err(MultipleRenamings { lib_name: lib.name.clone() }); + self.tcx.sess.emit_err(MultipleRenamings { lib_name: &lib.name }); } } } diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index 2b1f9f17a3c85..8f55fb59f0bf8 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -2270,7 +2270,7 @@ pub fn encode_metadata(tcx: TyCtxt<'_>, path: &Path) { fn encode_metadata_impl(tcx: TyCtxt<'_>, path: &Path) { let mut encoder = opaque::FileEncoder::new(path) - .unwrap_or_else(|err| tcx.sess.emit_fatal(FailCreateFileEncoder { err: err.to_string() })); + .unwrap_or_else(|err| tcx.sess.emit_fatal(FailCreateFileEncoder { err })); encoder.emit_raw_bytes(METADATA_HEADER); // Will be filled with the root position after encoding everything. @@ -2315,10 +2315,10 @@ fn encode_metadata_impl(tcx: TyCtxt<'_>, path: &Path) { // Encode the root position. let header = METADATA_HEADER.len(); file.seek(std::io::SeekFrom::Start(header as u64)) - .unwrap_or_else(|err| tcx.sess.emit_fatal(FailSeekFile { err: err.to_string() })); + .unwrap_or_else(|err| tcx.sess.emit_fatal(FailSeekFile { err })); let pos = root.position.get(); file.write_all(&[(pos >> 24) as u8, (pos >> 16) as u8, (pos >> 8) as u8, (pos >> 0) as u8]) - .unwrap_or_else(|err| tcx.sess.emit_fatal(FailWriteFile { err: err.to_string() })); + .unwrap_or_else(|err| tcx.sess.emit_fatal(FailWriteFile { err })); // Return to the position where we are before writing the root position. file.seek(std::io::SeekFrom::Start(pos_before_seek)).unwrap(); From 30adfd6a17bd0d7c4d1302cc4a0f92962577de4a Mon Sep 17 00:00:00 2001 From: Nathan Stocks Date: Sat, 27 Aug 2022 17:50:11 -0600 Subject: [PATCH 10/25] port 5 new diagnostics that appeared in master --- .../locales/en-US/metadata.ftl | 15 ++++++++ compiler/rustc_metadata/src/errors.rs | 36 +++++++++++++++++++ compiler/rustc_metadata/src/native_libs.rs | 36 +++++++++---------- 3 files changed, 67 insertions(+), 20 deletions(-) diff --git a/compiler/rustc_error_messages/locales/en-US/metadata.ftl b/compiler/rustc_error_messages/locales/en-US/metadata.ftl index dee01bcad4bbc..00067a1bf6ad7 100644 --- a/compiler/rustc_error_messages/locales/en-US/metadata.ftl +++ b/compiler/rustc_error_messages/locales/en-US/metadata.ftl @@ -255,3 +255,18 @@ metadata_crate_location_unknown_type = metadata_lib_filename_form = file name should be lib*.rlib or {dll_prefix}*.{dll_suffix} + +metadata_multiple_import_name_type = + multiple `import_name_type` arguments in a single `#[link]` attribute + +metadata_import_name_type_form = + import name type must be of the form `import_name_type = "string"` + +metadata_import_name_type_x86 = + import name type is only supported on x86 + +metadata_unknown_import_name_type = + unknown import name type `{$import_name_type}`, expected one of: decorated, noprefix, undecorated + +metadata_import_name_type_raw = + import name type can only be used with link kind `raw-dylib` diff --git a/compiler/rustc_metadata/src/errors.rs b/compiler/rustc_metadata/src/errors.rs index 565c96917e2fc..18d0248333a51 100644 --- a/compiler/rustc_metadata/src/errors.rs +++ b/compiler/rustc_metadata/src/errors.rs @@ -634,3 +634,39 @@ pub struct LibFilenameForm<'a> { pub dll_prefix: &'a str, pub dll_suffix: &'a str, } + +#[derive(SessionDiagnostic)] +#[diag(metadata::multiple_import_name_type)] +pub struct MultipleImportNameType { + #[primary_span] + pub span: Span, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::import_name_type_form)] +pub struct ImportNameTypeForm { + #[primary_span] + pub span: Span, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::import_name_type_x86)] +pub struct ImportNameTypeX86 { + #[primary_span] + pub span: Span, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::unknown_import_name_type)] +pub struct UnknownImportNameType<'a> { + #[primary_span] + pub span: Span, + pub import_name_type: &'a str, +} + +#[derive(SessionDiagnostic)] +#[diag(metadata::import_name_type_raw)] +pub struct ImportNameTypeRaw { + #[primary_span] + pub span: Span, +} diff --git a/compiler/rustc_metadata/src/native_libs.rs b/compiler/rustc_metadata/src/native_libs.rs index 19f64ef70c9c6..87b5e750f1cb1 100644 --- a/compiler/rustc_metadata/src/native_libs.rs +++ b/compiler/rustc_metadata/src/native_libs.rs @@ -13,13 +13,14 @@ use rustc_target::spec::abi::Abi; use crate::errors::{ AsNeededCompatibility, BundleNeedsStatic, EmptyLinkName, EmptyRenamingTarget, - FrameworkOnlyWindows, IncompatibleWasmLink, InvalidLinkModifier, LibFrameworkApple, - LinkCfgForm, LinkCfgSinglePredicate, LinkFrameworkApple, LinkKindForm, LinkModifiersForm, - LinkNameForm, LinkOrdinalRawDylib, LinkRequiresName, MultipleCfgs, MultipleKindsInLink, - MultipleLinkModifiers, MultipleModifiers, MultipleNamesInLink, MultipleRenamings, - MultipleWasmImport, NoLinkModOverride, RawDylibNoNul, RenamingNoLink, UnexpectedLinkArg, - UnknownLinkKind, UnknownLinkModifier, UnsupportedAbi, UnsupportedAbiI686, WasmImportForm, - WholeArchiveNeedsStatic, + FrameworkOnlyWindows, ImportNameTypeForm, ImportNameTypeRaw, ImportNameTypeX86, + IncompatibleWasmLink, InvalidLinkModifier, LibFrameworkApple, LinkCfgForm, + LinkCfgSinglePredicate, LinkFrameworkApple, LinkKindForm, LinkModifiersForm, LinkNameForm, + LinkOrdinalRawDylib, LinkRequiresName, MultipleCfgs, MultipleImportNameType, + MultipleKindsInLink, MultipleLinkModifiers, MultipleModifiers, MultipleNamesInLink, + MultipleRenamings, MultipleWasmImport, NoLinkModOverride, RawDylibNoNul, RenamingNoLink, + UnexpectedLinkArg, UnknownImportNameType, UnknownLinkKind, UnknownLinkModifier, UnsupportedAbi, + UnsupportedAbiI686, WasmImportForm, WholeArchiveNeedsStatic, }; pub(crate) fn collect(tcx: TyCtxt<'_>) -> Vec { @@ -178,18 +179,15 @@ impl<'tcx> Collector<'tcx> { } sym::import_name_type => { if import_name_type.is_some() { - let msg = "multiple `import_name_type` arguments in a single `#[link]` attribute"; - sess.span_err(item.span(), msg); + sess.emit_err(MultipleImportNameType { span: item.span() }); continue; } let Some(link_import_name_type) = item.value_str() else { - let msg = "import name type must be of the form `import_name_type = \"string\"`"; - sess.span_err(item.span(), msg); + sess.emit_err(ImportNameTypeForm { span: item.span() }); continue; }; if self.tcx.sess.target.arch != "x86" { - let msg = "import name type is only supported on x86"; - sess.span_err(item.span(), msg); + sess.emit_err(ImportNameTypeX86 { span: item.span() }); continue; } @@ -198,11 +196,10 @@ impl<'tcx> Collector<'tcx> { "noprefix" => PeImportNameType::NoPrefix, "undecorated" => PeImportNameType::Undecorated, import_name_type => { - let msg = format!( - "unknown import name type `{import_name_type}`, expected one of: \ - decorated, noprefix, undecorated" - ); - sess.span_err(item.span(), msg); + sess.emit_err(UnknownImportNameType { + span: item.span(), + import_name_type, + }); continue; } }; @@ -301,8 +298,7 @@ impl<'tcx> Collector<'tcx> { // Do this outside of the loop so that `import_name_type` can be specified before `kind`. if let Some((_, span)) = import_name_type { if kind != Some(NativeLibKind::RawDylib) { - let msg = "import name type can only be used with link kind `raw-dylib`"; - sess.span_err(span, msg); + sess.emit_err(ImportNameTypeRaw { span }); } } From fbcc038a224e58f7d3aca25c7f2321f11ce5513d Mon Sep 17 00:00:00 2001 From: Jack Wrenn Date: Wed, 31 Aug 2022 18:17:32 +0000 Subject: [PATCH 11/25] safe transmute: use `to_valtree` to destructure const `Assume` ref: https://github.com/rust-lang/rust/pull/100726#discussion_r954813220 --- compiler/rustc_transmute/src/lib.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/compiler/rustc_transmute/src/lib.rs b/compiler/rustc_transmute/src/lib.rs index 68270a603a146..2a1a81315657c 100644 --- a/compiler/rustc_transmute/src/lib.rs +++ b/compiler/rustc_transmute/src/lib.rs @@ -123,7 +123,7 @@ mod rustc { param_env: ParamEnv<'tcx>, c: Const<'tcx>, ) -> Self { - use rustc_middle::ty::DestructuredConst; + use rustc_middle::ty::ScalarInt; use rustc_middle::ty::TypeVisitable; use rustc_span::symbol::sym; @@ -142,9 +142,8 @@ mod rustc { LangItem::TransmuteOpts.name(), ); - let DestructuredConst { variant, fields } = tcx.destructure_const(c); - let variant_idx = variant.expect("The given `Const` must be an ADT."); - let variant = adt_def.variant(variant_idx); + let variant = adt_def.non_enum_variant(); + let fields = c.to_valtree().unwrap_branch(); let get_field = |name| { let (field_idx, _) = variant @@ -153,9 +152,7 @@ mod rustc { .enumerate() .find(|(_, field_def)| name == field_def.name) .expect(&format!("There were no fields named `{name}`.")); - fields[field_idx].try_eval_bool(tcx, param_env).expect(&format!( - "The field named `{name}` lang item could not be evaluated to a bool." - )) + fields[field_idx].unwrap_leaf() == ScalarInt::TRUE }; Self { From e4e4114a772c53bed0a78bdedaa7826379e655a7 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sat, 27 Aug 2022 14:07:59 +0200 Subject: [PATCH 12/25] Only keep one version of ImplicitSelfKind. --- .../src/diagnostics/mutability_errors.rs | 9 +++------ compiler/rustc_hir/src/hir.rs | 2 +- compiler/rustc_middle/src/mir/mod.rs | 18 +----------------- compiler/rustc_mir_build/src/build/mod.rs | 10 ++-------- compiler/rustc_smir/src/mir.rs | 12 ++++++------ 5 files changed, 13 insertions(+), 38 deletions(-) diff --git a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs index dd9590016b990..2c3b19221298b 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs @@ -9,10 +9,7 @@ use rustc_middle::mir::{Mutability, Place, PlaceRef, ProjectionElem}; use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_middle::{ hir::place::PlaceBase, - mir::{ - self, BindingForm, ClearCrossCrate, ImplicitSelfKind, Local, LocalDecl, LocalInfo, - LocalKind, Location, - }, + mir::{self, BindingForm, ClearCrossCrate, Local, LocalDecl, LocalInfo, LocalKind, Location}, }; use rustc_span::source_map::DesugaringKind; use rustc_span::symbol::{kw, Symbol}; @@ -312,7 +309,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { && !matches!( decl.local_info, Some(box LocalInfo::User(ClearCrossCrate::Set(BindingForm::ImplicitSelf( - ImplicitSelfKind::MutRef + hir::ImplicitSelfKind::MutRef )))) ) { @@ -1077,7 +1074,7 @@ fn mut_borrow_of_mutable_ref(local_decl: &LocalDecl<'_>, local_name: Option { // Otherwise, check if the name is the `self` keyword - in which case diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index a069c49b0cc1e..dde51bb678d72 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -2642,7 +2642,7 @@ pub struct FnDecl<'hir> { } /// Represents what type of implicit self a function has, if any. -#[derive(Copy, Clone, Encodable, Decodable, Debug, HashStable_Generic)] +#[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Debug, HashStable_Generic)] pub enum ImplicitSelfKind { /// Represents a `fn x(self);`. Imm, diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs index f3676604bb0e6..b8b1557ea562b 100644 --- a/compiler/rustc_middle/src/mir/mod.rs +++ b/compiler/rustc_middle/src/mir/mod.rs @@ -18,7 +18,7 @@ use rustc_data_structures::captures::Captures; use rustc_errors::ErrorGuaranteed; use rustc_hir::def::{CtorKind, Namespace}; use rustc_hir::def_id::{DefId, LocalDefId, CRATE_DEF_ID}; -use rustc_hir::{self, GeneratorKind}; +use rustc_hir::{self, GeneratorKind, ImplicitSelfKind}; use rustc_hir::{self as hir, HirId}; use rustc_session::Session; use rustc_target::abi::{Size, VariantIdx}; @@ -653,22 +653,6 @@ pub enum BindingForm<'tcx> { RefForGuard, } -/// Represents what type of implicit self a function has, if any. -#[derive(Clone, Copy, PartialEq, Debug, TyEncodable, TyDecodable, HashStable)] -pub enum ImplicitSelfKind { - /// Represents a `fn x(self);`. - Imm, - /// Represents a `fn x(mut self);`. - Mut, - /// Represents a `fn x(&self);`. - ImmRef, - /// Represents a `fn x(&mut self);`. - MutRef, - /// Represents when a function does not have a self argument or - /// when a function has a `self: X` argument. - None, -} - TrivialTypeTraversalAndLiftImpls! { BindingForm<'tcx>, } mod binding_form_impl { diff --git a/compiler/rustc_mir_build/src/build/mod.rs b/compiler/rustc_mir_build/src/build/mod.rs index 684b228e87fa9..707a0a908a289 100644 --- a/compiler/rustc_mir_build/src/build/mod.rs +++ b/compiler/rustc_mir_build/src/build/mod.rs @@ -10,7 +10,7 @@ use rustc_errors::ErrorGuaranteed; use rustc_hir as hir; use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_hir::lang_items::LangItem; -use rustc_hir::{GeneratorKind, Node}; +use rustc_hir::{GeneratorKind, ImplicitSelfKind, Node}; use rustc_index::vec::{Idx, IndexVec}; use rustc_infer::infer::{InferCtxt, TyCtxtInferExt}; use rustc_middle::hir::place::PlaceBase as HirPlaceBase; @@ -169,13 +169,7 @@ fn mir_build(tcx: TyCtxt<'_>, def: ty::WithOptConstParam) -> Body<'_ // Make sure that inferred closure args have no type span .and_then(|ty| if arg.pat.span != ty.span { Some(ty.span) } else { None }); self_arg = if index == 0 && fn_decl.implicit_self.has_implicit_self() { - match fn_decl.implicit_self { - hir::ImplicitSelfKind::Imm => Some(ImplicitSelfKind::Imm), - hir::ImplicitSelfKind::Mut => Some(ImplicitSelfKind::Mut), - hir::ImplicitSelfKind::ImmRef => Some(ImplicitSelfKind::ImmRef), - hir::ImplicitSelfKind::MutRef => Some(ImplicitSelfKind::MutRef), - _ => None, - } + Some(fn_decl.implicit_self) } else { None }; diff --git a/compiler/rustc_smir/src/mir.rs b/compiler/rustc_smir/src/mir.rs index 855605b1a4f9d..887e657293066 100644 --- a/compiler/rustc_smir/src/mir.rs +++ b/compiler/rustc_smir/src/mir.rs @@ -1,10 +1,10 @@ +pub use crate::very_unstable::hir::ImplicitSelfKind; pub use crate::very_unstable::middle::mir::{ visit::MutVisitor, AggregateKind, AssertKind, BasicBlock, BasicBlockData, BinOp, BindingForm, BlockTailInfo, Body, BorrowKind, CastKind, ClearCrossCrate, Constant, ConstantKind, - CopyNonOverlapping, Coverage, FakeReadCause, Field, GeneratorInfo, ImplicitSelfKind, - InlineAsmOperand, Local, LocalDecl, LocalInfo, LocalKind, Location, MirPhase, MirSource, - NullOp, Operand, Place, PlaceRef, ProjectionElem, ProjectionKind, Promoted, RetagKind, Rvalue, - Safety, SourceInfo, SourceScope, SourceScopeData, SourceScopeLocalData, Statement, - StatementKind, UnOp, UserTypeProjection, UserTypeProjections, VarBindingForm, VarDebugInfo, - VarDebugInfoContents, + CopyNonOverlapping, Coverage, FakeReadCause, Field, GeneratorInfo, InlineAsmOperand, Local, + LocalDecl, LocalInfo, LocalKind, Location, MirPhase, MirSource, NullOp, Operand, Place, + PlaceRef, ProjectionElem, ProjectionKind, Promoted, RetagKind, Rvalue, Safety, SourceInfo, + SourceScope, SourceScopeData, SourceScopeLocalData, Statement, StatementKind, UnOp, + UserTypeProjection, UserTypeProjections, VarBindingForm, VarDebugInfo, VarDebugInfoContents, }; From f848d27a8d2bbc4fca4a04e619af351e68e0074c Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sat, 27 Aug 2022 14:36:14 +0200 Subject: [PATCH 13/25] Use tcx.hir() utils for spans in MIR building. This corrects the `span_with_body` in the case of closures, which was incorrectly shortened to the `def_span`. --- .../src/diagnostics/move_errors.rs | 2 +- .../src/diagnostics/mutability_errors.rs | 5 +- compiler/rustc_mir_build/src/build/mod.rs | 59 +++------ ...motion_extern_static.BAR.PromoteTemps.diff | 4 +- ..._promotion_extern_static.BOP.mir_map.0.mir | 2 +- ...motion_extern_static.FOO.PromoteTemps.diff | 4 +- ...anup.main-{closure#0}.generator_drop.0.mir | 56 ++++----- ...main-{closure#0}.StateTransform.before.mir | 116 +++++++++--------- ...ny.main-{closure#0}.generator_resume.0.mir | 76 ++++++------ ...line_closure_captures.foo.Inline.after.mir | 4 +- .../inline/inline_generator.main.Inline.diff | 36 +++--- ...e#0}.SimplifyCfg-elaborate-drops.after.mir | 20 +-- ...age_live_dead_in_statics.XXX.mir_map.0.mir | 2 +- ...0}-ASSOCIATED_CONSTANT.mir_map.0.32bit.mir | 2 +- ...0}-ASSOCIATED_CONSTANT.mir_map.0.64bit.mir | 2 +- .../defaults-cyclic-fail.stderr | 4 +- ...9-assoc-const-static-recursion-impl.stderr | 2 +- ...onst-static-recursion-trait-default.stderr | 2 +- ...-assoc-const-static-recursion-trait.stderr | 2 +- src/test/ui/consts/issue-36163.stderr | 2 +- src/test/ui/issues/issue-17252.stderr | 2 +- src/test/ui/issues/issue-23302-3.stderr | 4 +- .../escape-argument-callee.stderr | 2 +- .../escape-argument.stderr | 2 +- .../escape-upvar-nested.stderr | 10 +- .../escape-upvar-ref.stderr | 2 +- ...pagate-approximated-fail-no-postdom.stderr | 8 +- .../propagate-approximated-ref.stderr | 9 +- ...er-to-static-comparing-against-free.stderr | 15 ++- ...oximated-shorter-to-static-no-bound.stderr | 10 +- ...mated-shorter-to-static-wrong-bound.stderr | 10 +- .../propagate-approximated-val.stderr | 9 +- .../propagate-despite-same-free-region.stderr | 8 +- ...ail-to-approximate-longer-no-bounds.stderr | 9 +- ...-to-approximate-longer-wrong-bounds.stderr | 9 +- .../propagate-from-trait-match.stderr | 11 +- .../return-wrong-bound-region.stderr | 2 +- .../projection-no-regions-closure.stderr | 8 +- .../projection-one-region-closure.stderr | 8 +- ...tion-one-region-trait-bound-closure.stderr | 10 +- ...e-region-trait-bound-static-closure.stderr | 10 +- ...tion-two-region-trait-bound-closure.stderr | 16 +-- ...ram-closure-approximate-lower-bound.stderr | 4 +- ...m-closure-outlives-from-return-type.stderr | 2 +- ...-closure-outlives-from-where-clause.stderr | 39 ++++-- .../user-annotations/adt-nullary-enums.stderr | 5 +- .../adt-tuple-struct-calls.stderr | 10 +- src/test/ui/nll/user-annotations/fns.stderr | 6 +- .../nll/user-annotations/method-call.stderr | 5 +- .../nll/user-annotations/method-ufcs-3.stderr | 5 +- 50 files changed, 353 insertions(+), 299 deletions(-) diff --git a/compiler/rustc_borrowck/src/diagnostics/move_errors.rs b/compiler/rustc_borrowck/src/diagnostics/move_errors.rs index 16c2f9ccc6aa4..8d4c38d3a8e8c 100644 --- a/compiler/rustc_borrowck/src/diagnostics/move_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/move_errors.rs @@ -360,7 +360,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { diag.span_label(upvar_span, "captured outer variable"); diag.span_label( - self.body.span, + self.infcx.tcx.def_span(def_id), format!("captured by this `{closure_kind}` closure"), ); diff --git a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs index 2c3b19221298b..71175ba2d2174 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs @@ -973,6 +973,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { let hir = self.infcx.tcx.hir(); let closure_id = self.mir_hir_id(); + let closure_span = self.infcx.tcx.def_span(self.mir_def_id()); let fn_call_id = hir.get_parent_node(closure_id); let node = hir.get(fn_call_id); let def_id = hir.enclosing_body_owner(fn_call_id); @@ -1024,7 +1025,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { if let Some(span) = arg { err.span_label(span, "change this to accept `FnMut` instead of `Fn`"); err.span_label(func.span, "expects `Fn` instead of `FnMut`"); - err.span_label(self.body.span, "in this closure"); + err.span_label(closure_span, "in this closure"); look_at_return = false; } } @@ -1050,7 +1051,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { sig.decl.output.span(), "change this to return `FnMut` instead of `Fn`", ); - err.span_label(self.body.span, "in this closure"); + err.span_label(closure_span, "in this closure"); } _ => {} } diff --git a/compiler/rustc_mir_build/src/build/mod.rs b/compiler/rustc_mir_build/src/build/mod.rs index 707a0a908a289..3a6750531e1f2 100644 --- a/compiler/rustc_mir_build/src/build/mod.rs +++ b/compiler/rustc_mir_build/src/build/mod.rs @@ -67,50 +67,25 @@ fn mir_build(tcx: TyCtxt<'_>, def: ty::WithOptConstParam) -> Body<'_ } // Figure out what primary body this item has. - let (body_id, return_ty_span, span_with_body) = match tcx.hir().get(id) { - Node::Expr(hir::Expr { - kind: hir::ExprKind::Closure(hir::Closure { fn_decl, body, .. }), - .. - }) => (*body, fn_decl.output.span(), None), - Node::Item(hir::Item { - kind: hir::ItemKind::Fn(hir::FnSig { decl, .. }, _, body_id), - span, - .. - }) - | Node::ImplItem(hir::ImplItem { - kind: hir::ImplItemKind::Fn(hir::FnSig { decl, .. }, body_id), - span, - .. - }) - | Node::TraitItem(hir::TraitItem { - kind: hir::TraitItemKind::Fn(hir::FnSig { decl, .. }, hir::TraitFn::Provided(body_id)), - span, - .. - }) => { - // Use the `Span` of the `Item/ImplItem/TraitItem` as the body span, - // since the def span of a function does not include the body - (*body_id, decl.output.span(), Some(*span)) - } - Node::Item(hir::Item { - kind: hir::ItemKind::Static(ty, _, body_id) | hir::ItemKind::Const(ty, body_id), - .. - }) - | Node::ImplItem(hir::ImplItem { kind: hir::ImplItemKind::Const(ty, body_id), .. }) - | Node::TraitItem(hir::TraitItem { - kind: hir::TraitItemKind::Const(ty, Some(body_id)), - .. - }) => (*body_id, ty.span, None), - Node::AnonConst(hir::AnonConst { body, hir_id, .. }) => { - (*body, tcx.hir().span(*hir_id), None) + let body_id = tcx.hir().body_owned_by(def.did); + let span_with_body = tcx.hir().span_with_body(id); + let return_ty_span = if let Some(fn_decl) = tcx.hir().fn_decl_by_hir_id(id) { + fn_decl.output.span() + } else { + match tcx.hir().get(id) { + Node::Item(hir::Item { + kind: hir::ItemKind::Static(ty, _, _) | hir::ItemKind::Const(ty, _), + .. + }) + | Node::ImplItem(hir::ImplItem { kind: hir::ImplItemKind::Const(ty, _), .. }) + | Node::TraitItem(hir::TraitItem { kind: hir::TraitItemKind::Const(ty, _), .. }) => { + ty.span + } + Node::AnonConst(_) => tcx.def_span(def.did), + _ => span_bug!(tcx.def_span(def.did), "can't build MIR for {:?}", def.did), } - - _ => span_bug!(tcx.hir().span(id), "can't build MIR for {:?}", def.did), }; - // If we don't have a specialized span for the body, just use the - // normal def span. - let span_with_body = span_with_body.unwrap_or_else(|| tcx.hir().span(id)); - tcx.infer_ctxt().enter(|infcx| { let body = if let Some(error_reported) = typeck_results.tainted_by_errors { build::construct_error(&infcx, def, id, body_id, body_owner_kind, error_reported) @@ -244,8 +219,6 @@ fn mir_build(tcx: TyCtxt<'_>, def: ty::WithOptConstParam) -> Body<'_ // of `mir_build`, so now we can steal it let thir = thir.steal(); - let span_with_body = span_with_body.to(tcx.hir().span(body_id.hir_id)); - build::construct_const( &thir, &infcx, diff --git a/src/test/mir-opt/const_promotion_extern_static.BAR.PromoteTemps.diff b/src/test/mir-opt/const_promotion_extern_static.BAR.PromoteTemps.diff index b5439d9d23934..f3f5c39bc17d9 100644 --- a/src/test/mir-opt/const_promotion_extern_static.BAR.PromoteTemps.diff +++ b/src/test/mir-opt/const_promotion_extern_static.BAR.PromoteTemps.diff @@ -40,11 +40,11 @@ - StorageDead(_5); // scope 0 at $DIR/const-promotion-extern-static.rs:+0:43: +0:44 - StorageDead(_3); // scope 0 at $DIR/const-promotion-extern-static.rs:+0:43: +0:44 StorageDead(_1); // scope 0 at $DIR/const-promotion-extern-static.rs:+0:43: +0:44 - return; // scope 0 at $DIR/const-promotion-extern-static.rs:+0:1: +0:44 + return; // scope 0 at $DIR/const-promotion-extern-static.rs:+0:1: +0:45 } bb2 (cleanup): { - resume; // scope 0 at $DIR/const-promotion-extern-static.rs:+0:1: +0:44 + resume; // scope 0 at $DIR/const-promotion-extern-static.rs:+0:1: +0:45 } - } - diff --git a/src/test/mir-opt/const_promotion_extern_static.BOP.mir_map.0.mir b/src/test/mir-opt/const_promotion_extern_static.BOP.mir_map.0.mir index 20d73afda271e..90920fbe7f805 100644 --- a/src/test/mir-opt/const_promotion_extern_static.BOP.mir_map.0.mir +++ b/src/test/mir-opt/const_promotion_extern_static.BOP.mir_map.0.mir @@ -12,6 +12,6 @@ static BOP: &i32 = { _1 = &_2; // scope 0 at $DIR/const-promotion-extern-static.rs:+0:20: +0:23 _0 = &(*_1); // scope 0 at $DIR/const-promotion-extern-static.rs:+0:20: +0:23 StorageDead(_1); // scope 0 at $DIR/const-promotion-extern-static.rs:+0:22: +0:23 - return; // scope 0 at $DIR/const-promotion-extern-static.rs:+0:1: +0:23 + return; // scope 0 at $DIR/const-promotion-extern-static.rs:+0:1: +0:24 } } diff --git a/src/test/mir-opt/const_promotion_extern_static.FOO.PromoteTemps.diff b/src/test/mir-opt/const_promotion_extern_static.FOO.PromoteTemps.diff index 4df4c9636a543..a4caa20874e20 100644 --- a/src/test/mir-opt/const_promotion_extern_static.FOO.PromoteTemps.diff +++ b/src/test/mir-opt/const_promotion_extern_static.FOO.PromoteTemps.diff @@ -42,11 +42,11 @@ - StorageDead(_5); // scope 0 at $DIR/const-promotion-extern-static.rs:+0:54: +0:55 - StorageDead(_3); // scope 0 at $DIR/const-promotion-extern-static.rs:+0:54: +0:55 StorageDead(_1); // scope 0 at $DIR/const-promotion-extern-static.rs:+0:54: +0:55 - return; // scope 0 at $DIR/const-promotion-extern-static.rs:+0:1: +0:55 + return; // scope 0 at $DIR/const-promotion-extern-static.rs:+0:1: +0:56 } bb2 (cleanup): { - resume; // scope 0 at $DIR/const-promotion-extern-static.rs:+0:1: +0:55 + resume; // scope 0 at $DIR/const-promotion-extern-static.rs:+0:1: +0:56 } } - diff --git a/src/test/mir-opt/generator_drop_cleanup.main-{closure#0}.generator_drop.0.mir b/src/test/mir-opt/generator_drop_cleanup.main-{closure#0}.generator_drop.0.mir index 0d10f9b5ffb4d..c718138b6b37e 100644 --- a/src/test/mir-opt/generator_drop_cleanup.main-{closure#0}.generator_drop.0.mir +++ b/src/test/mir-opt/generator_drop_cleanup.main-{closure#0}.generator_drop.0.mir @@ -15,70 +15,70 @@ } */ fn main::{closure#0}(_1: *mut [generator@$DIR/generator-drop-cleanup.rs:10:15: 10:17]) -> () { - let mut _0: (); // return place in scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +0:17 - let mut _2: (); // in scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +0:17 - let _3: std::string::String; // in scope 0 at $DIR/generator-drop-cleanup.rs:11:13: 11:15 - let _4: (); // in scope 0 at $DIR/generator-drop-cleanup.rs:12:9: 12:14 - let mut _5: (); // in scope 0 at $DIR/generator-drop-cleanup.rs:12:9: 12:14 - let mut _6: (); // in scope 0 at $DIR/generator-drop-cleanup.rs:10:18: 10:18 - let mut _7: (); // in scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +0:17 - let mut _8: u32; // in scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +0:17 + let mut _0: (); // return place in scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +3:6 + let mut _2: (); // in scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +3:6 + let _3: std::string::String; // in scope 0 at $DIR/generator-drop-cleanup.rs:+1:13: +1:15 + let _4: (); // in scope 0 at $DIR/generator-drop-cleanup.rs:+2:9: +2:14 + let mut _5: (); // in scope 0 at $DIR/generator-drop-cleanup.rs:+2:9: +2:14 + let mut _6: (); // in scope 0 at $DIR/generator-drop-cleanup.rs:+0:18: +0:18 + let mut _7: (); // in scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +3:6 + let mut _8: u32; // in scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +3:6 scope 1 { - debug _s => (((*_1) as variant#3).0: std::string::String); // in scope 1 at $DIR/generator-drop-cleanup.rs:11:13: 11:15 + debug _s => (((*_1) as variant#3).0: std::string::String); // in scope 1 at $DIR/generator-drop-cleanup.rs:+1:13: +1:15 } bb0: { - _8 = discriminant((*_1)); // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +0:17 - switchInt(move _8) -> [0_u32: bb7, 3_u32: bb10, otherwise: bb11]; // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +0:17 + _8 = discriminant((*_1)); // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +3:6 + switchInt(move _8) -> [0_u32: bb7, 3_u32: bb10, otherwise: bb11]; // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +3:6 } bb1: { - StorageDead(_5); // scope 1 at $DIR/generator-drop-cleanup.rs:12:13: 12:14 - StorageDead(_4); // scope 1 at $DIR/generator-drop-cleanup.rs:12:14: 12:15 - drop((((*_1) as variant#3).0: std::string::String)) -> [return: bb2, unwind: bb5]; // scope 0 at $DIR/generator-drop-cleanup.rs:13:5: 13:6 + StorageDead(_5); // scope 1 at $DIR/generator-drop-cleanup.rs:+2:13: +2:14 + StorageDead(_4); // scope 1 at $DIR/generator-drop-cleanup.rs:+2:14: +2:15 + drop((((*_1) as variant#3).0: std::string::String)) -> [return: bb2, unwind: bb5]; // scope 0 at $DIR/generator-drop-cleanup.rs:+3:5: +3:6 } bb2: { - nop; // scope 0 at $DIR/generator-drop-cleanup.rs:13:5: 13:6 - goto -> bb8; // scope 0 at $DIR/generator-drop-cleanup.rs:13:5: 13:6 + nop; // scope 0 at $DIR/generator-drop-cleanup.rs:+3:5: +3:6 + goto -> bb8; // scope 0 at $DIR/generator-drop-cleanup.rs:+3:5: +3:6 } bb3: { - return; // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +0:17 + return; // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +3:6 } bb4 (cleanup): { - resume; // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +0:17 + resume; // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +3:6 } bb5 (cleanup): { - nop; // scope 0 at $DIR/generator-drop-cleanup.rs:13:5: 13:6 - goto -> bb4; // scope 0 at $DIR/generator-drop-cleanup.rs:13:5: 13:6 + nop; // scope 0 at $DIR/generator-drop-cleanup.rs:+3:5: +3:6 + goto -> bb4; // scope 0 at $DIR/generator-drop-cleanup.rs:+3:5: +3:6 } bb6: { - return; // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +0:17 + return; // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +3:6 } bb7: { - goto -> bb9; // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +0:17 + goto -> bb9; // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +3:6 } bb8: { - goto -> bb3; // scope 0 at $DIR/generator-drop-cleanup.rs:13:5: 13:6 + goto -> bb3; // scope 0 at $DIR/generator-drop-cleanup.rs:+3:5: +3:6 } bb9: { - goto -> bb6; // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +0:17 + goto -> bb6; // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +3:6 } bb10: { - StorageLive(_4); // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +0:17 - StorageLive(_5); // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +0:17 - goto -> bb1; // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +0:17 + StorageLive(_4); // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +3:6 + StorageLive(_5); // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +3:6 + goto -> bb1; // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +3:6 } bb11: { - return; // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +0:17 + return; // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +3:6 } } diff --git a/src/test/mir-opt/generator_storage_dead_unwind.main-{closure#0}.StateTransform.before.mir b/src/test/mir-opt/generator_storage_dead_unwind.main-{closure#0}.StateTransform.before.mir index 94f4a5a63178d..3184343f207b3 100644 --- a/src/test/mir-opt/generator_storage_dead_unwind.main-{closure#0}.StateTransform.before.mir +++ b/src/test/mir-opt/generator_storage_dead_unwind.main-{closure#0}.StateTransform.before.mir @@ -3,122 +3,122 @@ fn main::{closure#0}(_1: [generator@$DIR/generator-storage-dead-unwind.rs:22:16: 22:18], _2: ()) -> () yields () { - let mut _0: (); // return place in scope 0 at $DIR/generator-storage-dead-unwind.rs:22:19: 22:19 - let _3: Foo; // in scope 0 at $DIR/generator-storage-dead-unwind.rs:23:13: 23:14 - let _5: (); // in scope 0 at $DIR/generator-storage-dead-unwind.rs:25:9: 25:14 - let mut _6: (); // in scope 0 at $DIR/generator-storage-dead-unwind.rs:25:9: 25:14 - let _7: (); // in scope 0 at $DIR/generator-storage-dead-unwind.rs:26:9: 26:16 - let mut _8: Foo; // in scope 0 at $DIR/generator-storage-dead-unwind.rs:26:14: 26:15 - let _9: (); // in scope 0 at $DIR/generator-storage-dead-unwind.rs:27:9: 27:16 - let mut _10: Bar; // in scope 0 at $DIR/generator-storage-dead-unwind.rs:27:14: 27:15 + let mut _0: (); // return place in scope 0 at $DIR/generator-storage-dead-unwind.rs:+0:19: +0:19 + let _3: Foo; // in scope 0 at $DIR/generator-storage-dead-unwind.rs:+1:13: +1:14 + let _5: (); // in scope 0 at $DIR/generator-storage-dead-unwind.rs:+3:9: +3:14 + let mut _6: (); // in scope 0 at $DIR/generator-storage-dead-unwind.rs:+3:9: +3:14 + let _7: (); // in scope 0 at $DIR/generator-storage-dead-unwind.rs:+4:9: +4:16 + let mut _8: Foo; // in scope 0 at $DIR/generator-storage-dead-unwind.rs:+4:14: +4:15 + let _9: (); // in scope 0 at $DIR/generator-storage-dead-unwind.rs:+5:9: +5:16 + let mut _10: Bar; // in scope 0 at $DIR/generator-storage-dead-unwind.rs:+5:14: +5:15 scope 1 { - debug a => _3; // in scope 1 at $DIR/generator-storage-dead-unwind.rs:23:13: 23:14 - let _4: Bar; // in scope 1 at $DIR/generator-storage-dead-unwind.rs:24:13: 24:14 + debug a => _3; // in scope 1 at $DIR/generator-storage-dead-unwind.rs:+1:13: +1:14 + let _4: Bar; // in scope 1 at $DIR/generator-storage-dead-unwind.rs:+2:13: +2:14 scope 2 { - debug b => _4; // in scope 2 at $DIR/generator-storage-dead-unwind.rs:24:13: 24:14 + debug b => _4; // in scope 2 at $DIR/generator-storage-dead-unwind.rs:+2:13: +2:14 } } bb0: { - StorageLive(_3); // scope 0 at $DIR/generator-storage-dead-unwind.rs:23:13: 23:14 - _3 = Foo(const 5_i32); // scope 0 at $DIR/generator-storage-dead-unwind.rs:23:17: 23:23 - StorageLive(_4); // scope 1 at $DIR/generator-storage-dead-unwind.rs:24:13: 24:14 - _4 = Bar(const 6_i32); // scope 1 at $DIR/generator-storage-dead-unwind.rs:24:17: 24:23 - StorageLive(_5); // scope 2 at $DIR/generator-storage-dead-unwind.rs:25:9: 25:14 - StorageLive(_6); // scope 2 at $DIR/generator-storage-dead-unwind.rs:25:9: 25:14 - _6 = (); // scope 2 at $DIR/generator-storage-dead-unwind.rs:25:9: 25:14 - _5 = yield(move _6) -> [resume: bb1, drop: bb6]; // scope 2 at $DIR/generator-storage-dead-unwind.rs:25:9: 25:14 + StorageLive(_3); // scope 0 at $DIR/generator-storage-dead-unwind.rs:+1:13: +1:14 + _3 = Foo(const 5_i32); // scope 0 at $DIR/generator-storage-dead-unwind.rs:+1:17: +1:23 + StorageLive(_4); // scope 1 at $DIR/generator-storage-dead-unwind.rs:+2:13: +2:14 + _4 = Bar(const 6_i32); // scope 1 at $DIR/generator-storage-dead-unwind.rs:+2:17: +2:23 + StorageLive(_5); // scope 2 at $DIR/generator-storage-dead-unwind.rs:+3:9: +3:14 + StorageLive(_6); // scope 2 at $DIR/generator-storage-dead-unwind.rs:+3:9: +3:14 + _6 = (); // scope 2 at $DIR/generator-storage-dead-unwind.rs:+3:9: +3:14 + _5 = yield(move _6) -> [resume: bb1, drop: bb6]; // scope 2 at $DIR/generator-storage-dead-unwind.rs:+3:9: +3:14 } bb1: { - StorageDead(_6); // scope 2 at $DIR/generator-storage-dead-unwind.rs:25:13: 25:14 - StorageDead(_5); // scope 2 at $DIR/generator-storage-dead-unwind.rs:25:14: 25:15 - StorageLive(_7); // scope 2 at $DIR/generator-storage-dead-unwind.rs:26:9: 26:16 - StorageLive(_8); // scope 2 at $DIR/generator-storage-dead-unwind.rs:26:14: 26:15 - _8 = move _3; // scope 2 at $DIR/generator-storage-dead-unwind.rs:26:14: 26:15 - _7 = take::(move _8) -> [return: bb2, unwind: bb10]; // scope 2 at $DIR/generator-storage-dead-unwind.rs:26:9: 26:16 + StorageDead(_6); // scope 2 at $DIR/generator-storage-dead-unwind.rs:+3:13: +3:14 + StorageDead(_5); // scope 2 at $DIR/generator-storage-dead-unwind.rs:+3:14: +3:15 + StorageLive(_7); // scope 2 at $DIR/generator-storage-dead-unwind.rs:+4:9: +4:16 + StorageLive(_8); // scope 2 at $DIR/generator-storage-dead-unwind.rs:+4:14: +4:15 + _8 = move _3; // scope 2 at $DIR/generator-storage-dead-unwind.rs:+4:14: +4:15 + _7 = take::(move _8) -> [return: bb2, unwind: bb10]; // scope 2 at $DIR/generator-storage-dead-unwind.rs:+4:9: +4:16 // mir::Constant // + span: $DIR/generator-storage-dead-unwind.rs:26:9: 26:13 // + literal: Const { ty: fn(Foo) {take::}, val: Value() } } bb2: { - StorageDead(_8); // scope 2 at $DIR/generator-storage-dead-unwind.rs:26:15: 26:16 - StorageDead(_7); // scope 2 at $DIR/generator-storage-dead-unwind.rs:26:16: 26:17 - StorageLive(_9); // scope 2 at $DIR/generator-storage-dead-unwind.rs:27:9: 27:16 - StorageLive(_10); // scope 2 at $DIR/generator-storage-dead-unwind.rs:27:14: 27:15 - _10 = move _4; // scope 2 at $DIR/generator-storage-dead-unwind.rs:27:14: 27:15 - _9 = take::(move _10) -> [return: bb3, unwind: bb9]; // scope 2 at $DIR/generator-storage-dead-unwind.rs:27:9: 27:16 + StorageDead(_8); // scope 2 at $DIR/generator-storage-dead-unwind.rs:+4:15: +4:16 + StorageDead(_7); // scope 2 at $DIR/generator-storage-dead-unwind.rs:+4:16: +4:17 + StorageLive(_9); // scope 2 at $DIR/generator-storage-dead-unwind.rs:+5:9: +5:16 + StorageLive(_10); // scope 2 at $DIR/generator-storage-dead-unwind.rs:+5:14: +5:15 + _10 = move _4; // scope 2 at $DIR/generator-storage-dead-unwind.rs:+5:14: +5:15 + _9 = take::(move _10) -> [return: bb3, unwind: bb9]; // scope 2 at $DIR/generator-storage-dead-unwind.rs:+5:9: +5:16 // mir::Constant // + span: $DIR/generator-storage-dead-unwind.rs:27:9: 27:13 // + literal: Const { ty: fn(Bar) {take::}, val: Value() } } bb3: { - StorageDead(_10); // scope 2 at $DIR/generator-storage-dead-unwind.rs:27:15: 27:16 - StorageDead(_9); // scope 2 at $DIR/generator-storage-dead-unwind.rs:27:16: 27:17 - _0 = const (); // scope 0 at $DIR/generator-storage-dead-unwind.rs:22:19: 28:6 - StorageDead(_4); // scope 1 at $DIR/generator-storage-dead-unwind.rs:28:5: 28:6 - goto -> bb4; // scope 0 at $DIR/generator-storage-dead-unwind.rs:28:5: 28:6 + StorageDead(_10); // scope 2 at $DIR/generator-storage-dead-unwind.rs:+5:15: +5:16 + StorageDead(_9); // scope 2 at $DIR/generator-storage-dead-unwind.rs:+5:16: +5:17 + _0 = const (); // scope 0 at $DIR/generator-storage-dead-unwind.rs:+0:19: +6:6 + StorageDead(_4); // scope 1 at $DIR/generator-storage-dead-unwind.rs:+6:5: +6:6 + goto -> bb4; // scope 0 at $DIR/generator-storage-dead-unwind.rs:+6:5: +6:6 } bb4: { - StorageDead(_3); // scope 0 at $DIR/generator-storage-dead-unwind.rs:28:5: 28:6 - drop(_1) -> [return: bb5, unwind: bb14]; // scope 0 at $DIR/generator-storage-dead-unwind.rs:28:5: 28:6 + StorageDead(_3); // scope 0 at $DIR/generator-storage-dead-unwind.rs:+6:5: +6:6 + drop(_1) -> [return: bb5, unwind: bb14]; // scope 0 at $DIR/generator-storage-dead-unwind.rs:+6:5: +6:6 } bb5: { - return; // scope 0 at $DIR/generator-storage-dead-unwind.rs:+0:18: +0:18 + return; // scope 0 at $DIR/generator-storage-dead-unwind.rs:+6:6: +6:6 } bb6: { - StorageDead(_6); // scope 2 at $DIR/generator-storage-dead-unwind.rs:25:13: 25:14 - StorageDead(_5); // scope 2 at $DIR/generator-storage-dead-unwind.rs:25:14: 25:15 - StorageDead(_4); // scope 1 at $DIR/generator-storage-dead-unwind.rs:28:5: 28:6 - drop(_3) -> [return: bb7, unwind: bb15]; // scope 0 at $DIR/generator-storage-dead-unwind.rs:28:5: 28:6 + StorageDead(_6); // scope 2 at $DIR/generator-storage-dead-unwind.rs:+3:13: +3:14 + StorageDead(_5); // scope 2 at $DIR/generator-storage-dead-unwind.rs:+3:14: +3:15 + StorageDead(_4); // scope 1 at $DIR/generator-storage-dead-unwind.rs:+6:5: +6:6 + drop(_3) -> [return: bb7, unwind: bb15]; // scope 0 at $DIR/generator-storage-dead-unwind.rs:+6:5: +6:6 } bb7: { - StorageDead(_3); // scope 0 at $DIR/generator-storage-dead-unwind.rs:28:5: 28:6 - drop(_1) -> [return: bb8, unwind: bb14]; // scope 0 at $DIR/generator-storage-dead-unwind.rs:28:5: 28:6 + StorageDead(_3); // scope 0 at $DIR/generator-storage-dead-unwind.rs:+6:5: +6:6 + drop(_1) -> [return: bb8, unwind: bb14]; // scope 0 at $DIR/generator-storage-dead-unwind.rs:+6:5: +6:6 } bb8: { - generator_drop; // scope 0 at $DIR/generator-storage-dead-unwind.rs:+0:16: +0:18 + generator_drop; // scope 0 at $DIR/generator-storage-dead-unwind.rs:+0:16: +6:6 } bb9 (cleanup): { - StorageDead(_10); // scope 2 at $DIR/generator-storage-dead-unwind.rs:27:15: 27:16 - StorageDead(_9); // scope 2 at $DIR/generator-storage-dead-unwind.rs:27:16: 27:17 + StorageDead(_10); // scope 2 at $DIR/generator-storage-dead-unwind.rs:+5:15: +5:16 + StorageDead(_9); // scope 2 at $DIR/generator-storage-dead-unwind.rs:+5:16: +5:17 goto -> bb12; // scope 2 at no-location } bb10 (cleanup): { - goto -> bb11; // scope 2 at $DIR/generator-storage-dead-unwind.rs:26:15: 26:16 + goto -> bb11; // scope 2 at $DIR/generator-storage-dead-unwind.rs:+4:15: +4:16 } bb11 (cleanup): { - StorageDead(_8); // scope 2 at $DIR/generator-storage-dead-unwind.rs:26:15: 26:16 - StorageDead(_7); // scope 2 at $DIR/generator-storage-dead-unwind.rs:26:16: 26:17 + StorageDead(_8); // scope 2 at $DIR/generator-storage-dead-unwind.rs:+4:15: +4:16 + StorageDead(_7); // scope 2 at $DIR/generator-storage-dead-unwind.rs:+4:16: +4:17 goto -> bb12; // scope 2 at no-location } bb12 (cleanup): { - StorageDead(_4); // scope 1 at $DIR/generator-storage-dead-unwind.rs:28:5: 28:6 - goto -> bb13; // scope 0 at $DIR/generator-storage-dead-unwind.rs:28:5: 28:6 + StorageDead(_4); // scope 1 at $DIR/generator-storage-dead-unwind.rs:+6:5: +6:6 + goto -> bb13; // scope 0 at $DIR/generator-storage-dead-unwind.rs:+6:5: +6:6 } bb13 (cleanup): { - StorageDead(_3); // scope 0 at $DIR/generator-storage-dead-unwind.rs:28:5: 28:6 - drop(_1) -> bb14; // scope 0 at $DIR/generator-storage-dead-unwind.rs:28:5: 28:6 + StorageDead(_3); // scope 0 at $DIR/generator-storage-dead-unwind.rs:+6:5: +6:6 + drop(_1) -> bb14; // scope 0 at $DIR/generator-storage-dead-unwind.rs:+6:5: +6:6 } bb14 (cleanup): { - resume; // scope 0 at $DIR/generator-storage-dead-unwind.rs:+0:16: +0:18 + resume; // scope 0 at $DIR/generator-storage-dead-unwind.rs:+0:16: +6:6 } bb15 (cleanup): { - StorageDead(_3); // scope 0 at $DIR/generator-storage-dead-unwind.rs:28:5: 28:6 - drop(_1) -> bb14; // scope 0 at $DIR/generator-storage-dead-unwind.rs:28:5: 28:6 + StorageDead(_3); // scope 0 at $DIR/generator-storage-dead-unwind.rs:+6:5: +6:6 + drop(_1) -> bb14; // scope 0 at $DIR/generator-storage-dead-unwind.rs:+6:5: +6:6 } } diff --git a/src/test/mir-opt/generator_tiny.main-{closure#0}.generator_resume.0.mir b/src/test/mir-opt/generator_tiny.main-{closure#0}.generator_resume.0.mir index 927f10242d2fe..07aeeaae012c9 100644 --- a/src/test/mir-opt/generator_tiny.main-{closure#0}.generator_resume.0.mir +++ b/src/test/mir-opt/generator_tiny.main-{closure#0}.generator_resume.0.mir @@ -16,69 +16,69 @@ fn main::{closure#0}(_1: Pin<&mut [generator@$DIR/generator-tiny.rs:19:16: 19:24]>, _2: u8) -> GeneratorState<(), ()> { debug _x => _10; // in scope 0 at $DIR/generator-tiny.rs:+0:17: +0:19 - let mut _0: std::ops::GeneratorState<(), ()>; // return place in scope 0 at $DIR/generator-tiny.rs:+0:16: +0:24 - let _3: HasDrop; // in scope 0 at $DIR/generator-tiny.rs:20:13: 20:15 - let mut _4: !; // in scope 0 at $DIR/generator-tiny.rs:21:9: 24:10 - let mut _5: (); // in scope 0 at $DIR/generator-tiny.rs:+0:16: +0:24 - let _6: u8; // in scope 0 at $DIR/generator-tiny.rs:22:13: 22:18 - let mut _7: (); // in scope 0 at $DIR/generator-tiny.rs:22:13: 22:18 - let _8: (); // in scope 0 at $DIR/generator-tiny.rs:23:13: 23:21 - let mut _9: (); // in scope 0 at $DIR/generator-tiny.rs:19:25: 19:25 + let mut _0: std::ops::GeneratorState<(), ()>; // return place in scope 0 at $DIR/generator-tiny.rs:+0:16: +6:6 + let _3: HasDrop; // in scope 0 at $DIR/generator-tiny.rs:+1:13: +1:15 + let mut _4: !; // in scope 0 at $DIR/generator-tiny.rs:+2:9: +5:10 + let mut _5: (); // in scope 0 at $DIR/generator-tiny.rs:+0:16: +6:6 + let _6: u8; // in scope 0 at $DIR/generator-tiny.rs:+3:13: +3:18 + let mut _7: (); // in scope 0 at $DIR/generator-tiny.rs:+3:13: +3:18 + let _8: (); // in scope 0 at $DIR/generator-tiny.rs:+4:13: +4:21 + let mut _9: (); // in scope 0 at $DIR/generator-tiny.rs:+0:25: +0:25 let _10: u8; // in scope 0 at $DIR/generator-tiny.rs:+0:17: +0:19 - let mut _11: u32; // in scope 0 at $DIR/generator-tiny.rs:+0:16: +0:24 + let mut _11: u32; // in scope 0 at $DIR/generator-tiny.rs:+0:16: +6:6 scope 1 { - debug _d => (((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:19:16: 19:24])) as variant#3).0: HasDrop); // in scope 1 at $DIR/generator-tiny.rs:20:13: 20:15 + debug _d => (((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:19:16: 19:24])) as variant#3).0: HasDrop); // in scope 1 at $DIR/generator-tiny.rs:+1:13: +1:15 } bb0: { - _11 = discriminant((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:19:16: 19:24]))); // scope 0 at $DIR/generator-tiny.rs:+0:16: +0:24 - switchInt(move _11) -> [0_u32: bb1, 3_u32: bb5, otherwise: bb6]; // scope 0 at $DIR/generator-tiny.rs:+0:16: +0:24 + _11 = discriminant((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:19:16: 19:24]))); // scope 0 at $DIR/generator-tiny.rs:+0:16: +6:6 + switchInt(move _11) -> [0_u32: bb1, 3_u32: bb5, otherwise: bb6]; // scope 0 at $DIR/generator-tiny.rs:+0:16: +6:6 } bb1: { - _10 = move _2; // scope 0 at $DIR/generator-tiny.rs:+0:16: +0:24 - nop; // scope 0 at $DIR/generator-tiny.rs:20:13: 20:15 - (((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:19:16: 19:24])) as variant#3).0: HasDrop) = HasDrop; // scope 0 at $DIR/generator-tiny.rs:20:18: 20:25 - StorageLive(_4); // scope 1 at $DIR/generator-tiny.rs:21:9: 24:10 - goto -> bb2; // scope 1 at $DIR/generator-tiny.rs:21:9: 24:10 + _10 = move _2; // scope 0 at $DIR/generator-tiny.rs:+0:16: +6:6 + nop; // scope 0 at $DIR/generator-tiny.rs:+1:13: +1:15 + (((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:19:16: 19:24])) as variant#3).0: HasDrop) = HasDrop; // scope 0 at $DIR/generator-tiny.rs:+1:18: +1:25 + StorageLive(_4); // scope 1 at $DIR/generator-tiny.rs:+2:9: +5:10 + goto -> bb2; // scope 1 at $DIR/generator-tiny.rs:+2:9: +5:10 } bb2: { - StorageLive(_6); // scope 1 at $DIR/generator-tiny.rs:22:13: 22:18 - StorageLive(_7); // scope 1 at $DIR/generator-tiny.rs:22:13: 22:18 - _7 = (); // scope 1 at $DIR/generator-tiny.rs:22:13: 22:18 - Deinit(_0); // scope 1 at $DIR/generator-tiny.rs:22:13: 22:18 - ((_0 as Yielded).0: ()) = move _7; // scope 1 at $DIR/generator-tiny.rs:22:13: 22:18 - discriminant(_0) = 0; // scope 1 at $DIR/generator-tiny.rs:22:13: 22:18 - discriminant((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:19:16: 19:24]))) = 3; // scope 1 at $DIR/generator-tiny.rs:22:13: 22:18 - return; // scope 1 at $DIR/generator-tiny.rs:22:13: 22:18 + StorageLive(_6); // scope 1 at $DIR/generator-tiny.rs:+3:13: +3:18 + StorageLive(_7); // scope 1 at $DIR/generator-tiny.rs:+3:13: +3:18 + _7 = (); // scope 1 at $DIR/generator-tiny.rs:+3:13: +3:18 + Deinit(_0); // scope 1 at $DIR/generator-tiny.rs:+3:13: +3:18 + ((_0 as Yielded).0: ()) = move _7; // scope 1 at $DIR/generator-tiny.rs:+3:13: +3:18 + discriminant(_0) = 0; // scope 1 at $DIR/generator-tiny.rs:+3:13: +3:18 + discriminant((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:19:16: 19:24]))) = 3; // scope 1 at $DIR/generator-tiny.rs:+3:13: +3:18 + return; // scope 1 at $DIR/generator-tiny.rs:+3:13: +3:18 } bb3: { - StorageDead(_7); // scope 1 at $DIR/generator-tiny.rs:22:17: 22:18 - StorageDead(_6); // scope 1 at $DIR/generator-tiny.rs:22:18: 22:19 - StorageLive(_8); // scope 1 at $DIR/generator-tiny.rs:23:13: 23:21 - _8 = callee() -> bb4; // scope 1 at $DIR/generator-tiny.rs:23:13: 23:21 + StorageDead(_7); // scope 1 at $DIR/generator-tiny.rs:+3:17: +3:18 + StorageDead(_6); // scope 1 at $DIR/generator-tiny.rs:+3:18: +3:19 + StorageLive(_8); // scope 1 at $DIR/generator-tiny.rs:+4:13: +4:21 + _8 = callee() -> bb4; // scope 1 at $DIR/generator-tiny.rs:+4:13: +4:21 // mir::Constant // + span: $DIR/generator-tiny.rs:23:13: 23:19 // + literal: Const { ty: fn() {callee}, val: Value() } } bb4: { - StorageDead(_8); // scope 1 at $DIR/generator-tiny.rs:23:21: 23:22 - _5 = const (); // scope 1 at $DIR/generator-tiny.rs:21:14: 24:10 - goto -> bb2; // scope 1 at $DIR/generator-tiny.rs:21:9: 24:10 + StorageDead(_8); // scope 1 at $DIR/generator-tiny.rs:+4:21: +4:22 + _5 = const (); // scope 1 at $DIR/generator-tiny.rs:+2:14: +5:10 + goto -> bb2; // scope 1 at $DIR/generator-tiny.rs:+2:9: +5:10 } bb5: { - StorageLive(_4); // scope 0 at $DIR/generator-tiny.rs:+0:16: +0:24 - StorageLive(_6); // scope 0 at $DIR/generator-tiny.rs:+0:16: +0:24 - StorageLive(_7); // scope 0 at $DIR/generator-tiny.rs:+0:16: +0:24 - _6 = move _2; // scope 0 at $DIR/generator-tiny.rs:+0:16: +0:24 - goto -> bb3; // scope 0 at $DIR/generator-tiny.rs:+0:16: +0:24 + StorageLive(_4); // scope 0 at $DIR/generator-tiny.rs:+0:16: +6:6 + StorageLive(_6); // scope 0 at $DIR/generator-tiny.rs:+0:16: +6:6 + StorageLive(_7); // scope 0 at $DIR/generator-tiny.rs:+0:16: +6:6 + _6 = move _2; // scope 0 at $DIR/generator-tiny.rs:+0:16: +6:6 + goto -> bb3; // scope 0 at $DIR/generator-tiny.rs:+0:16: +6:6 } bb6: { - unreachable; // scope 0 at $DIR/generator-tiny.rs:+0:16: +0:24 + unreachable; // scope 0 at $DIR/generator-tiny.rs:+0:16: +6:6 } } diff --git a/src/test/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir b/src/test/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir index 4b075a8163bf1..a2234e7c1effd 100644 --- a/src/test/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir +++ b/src/test/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir @@ -19,8 +19,8 @@ fn foo(_1: T, _2: i32) -> (i32, T) { debug t => (*((*_6).1: &T)); // in scope 2 at $DIR/inline-closure-captures.rs:+0:17: +0:18 let mut _10: i32; // in scope 2 at $DIR/inline-closure-captures.rs:+1:19: +1:20 let mut _11: T; // in scope 2 at $DIR/inline-closure-captures.rs:+1:22: +1:23 - let mut _12: &i32; // in scope 2 at $DIR/inline-closure-captures.rs:+1:13: +1:17 - let mut _13: &T; // in scope 2 at $DIR/inline-closure-captures.rs:+1:13: +1:17 + let mut _12: &i32; // in scope 2 at $DIR/inline-closure-captures.rs:+1:13: +1:24 + let mut _13: &T; // in scope 2 at $DIR/inline-closure-captures.rs:+1:13: +1:24 } } diff --git a/src/test/mir-opt/inline/inline_generator.main.Inline.diff b/src/test/mir-opt/inline/inline_generator.main.Inline.diff index 669a787ae58fe..0b992e3c32ad1 100644 --- a/src/test/mir-opt/inline/inline_generator.main.Inline.diff +++ b/src/test/mir-opt/inline/inline_generator.main.Inline.diff @@ -29,10 +29,10 @@ + let mut _9: bool; // in scope 6 at $DIR/inline-generator.rs:15:20: 15:21 + let mut _10: bool; // in scope 6 at $DIR/inline-generator.rs:15:9: 15:9 + let _11: bool; // in scope 6 at $DIR/inline-generator.rs:15:6: 15:7 -+ let mut _12: u32; // in scope 6 at $DIR/inline-generator.rs:15:5: 15:8 -+ let mut _13: &mut [generator@$DIR/inline-generator.rs:15:5: 15:8]; // in scope 6 at $DIR/inline-generator.rs:15:5: 15:8 -+ let mut _14: &mut [generator@$DIR/inline-generator.rs:15:5: 15:8]; // in scope 6 at $DIR/inline-generator.rs:15:5: 15:8 -+ let mut _15: &mut [generator@$DIR/inline-generator.rs:15:5: 15:8]; // in scope 6 at $DIR/inline-generator.rs:15:5: 15:8 ++ let mut _12: u32; // in scope 6 at $DIR/inline-generator.rs:15:5: 15:41 ++ let mut _13: &mut [generator@$DIR/inline-generator.rs:15:5: 15:8]; // in scope 6 at $DIR/inline-generator.rs:15:5: 15:41 ++ let mut _14: &mut [generator@$DIR/inline-generator.rs:15:5: 15:8]; // in scope 6 at $DIR/inline-generator.rs:15:5: 15:41 ++ let mut _15: &mut [generator@$DIR/inline-generator.rs:15:5: 15:8]; // in scope 6 at $DIR/inline-generator.rs:15:5: 15:41 + } bb0: { @@ -75,9 +75,9 @@ + _7 = const false; // scope 0 at $DIR/inline-generator.rs:+1:14: +1:46 + StorageLive(_10); // scope 0 at $DIR/inline-generator.rs:+1:14: +1:46 + StorageLive(_11); // scope 0 at $DIR/inline-generator.rs:+1:14: +1:46 -+ _13 = deref_copy (_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:8]); // scope 6 at $DIR/inline-generator.rs:15:5: 15:8 -+ _12 = discriminant((*_13)); // scope 6 at $DIR/inline-generator.rs:15:5: 15:8 -+ switchInt(move _12) -> [0_u32: bb3, 1_u32: bb8, 3_u32: bb7, otherwise: bb9]; // scope 6 at $DIR/inline-generator.rs:15:5: 15:8 ++ _13 = deref_copy (_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:8]); // scope 6 at $DIR/inline-generator.rs:15:5: 15:41 ++ _12 = discriminant((*_13)); // scope 6 at $DIR/inline-generator.rs:15:5: 15:41 ++ switchInt(move _12) -> [0_u32: bb3, 1_u32: bb8, 3_u32: bb7, otherwise: bb9]; // scope 6 at $DIR/inline-generator.rs:15:5: 15:41 } - bb3: { @@ -98,7 +98,7 @@ + } + + bb3: { -+ _11 = move _7; // scope 6 at $DIR/inline-generator.rs:15:5: 15:8 ++ _11 = move _7; // scope 6 at $DIR/inline-generator.rs:15:5: 15:41 + StorageLive(_8); // scope 6 at $DIR/inline-generator.rs:15:17: 15:39 + StorageLive(_9); // scope 6 at $DIR/inline-generator.rs:15:20: 15:21 + _9 = _11; // scope 6 at $DIR/inline-generator.rs:15:20: 15:21 @@ -126,23 +126,23 @@ + } + + bb7: { -+ StorageLive(_8); // scope 6 at $DIR/inline-generator.rs:15:5: 15:8 -+ _10 = move _7; // scope 6 at $DIR/inline-generator.rs:15:5: 15:8 ++ StorageLive(_8); // scope 6 at $DIR/inline-generator.rs:15:5: 15:41 ++ _10 = move _7; // scope 6 at $DIR/inline-generator.rs:15:5: 15:41 + StorageDead(_8); // scope 6 at $DIR/inline-generator.rs:15:38: 15:39 -+ Deinit(_1); // scope 6 at $DIR/inline-generator.rs:15:8: 15:8 -+ ((_1 as Complete).0: bool) = move _10; // scope 6 at $DIR/inline-generator.rs:15:8: 15:8 -+ discriminant(_1) = 1; // scope 6 at $DIR/inline-generator.rs:15:8: 15:8 -+ _15 = deref_copy (_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:8]); // scope 6 at $DIR/inline-generator.rs:15:8: 15:8 -+ discriminant((*_15)) = 1; // scope 6 at $DIR/inline-generator.rs:15:8: 15:8 -+ goto -> bb1; // scope 0 at $DIR/inline-generator.rs:15:8: 15:8 ++ Deinit(_1); // scope 6 at $DIR/inline-generator.rs:15:41: 15:41 ++ ((_1 as Complete).0: bool) = move _10; // scope 6 at $DIR/inline-generator.rs:15:41: 15:41 ++ discriminant(_1) = 1; // scope 6 at $DIR/inline-generator.rs:15:41: 15:41 ++ _15 = deref_copy (_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:8]); // scope 6 at $DIR/inline-generator.rs:15:41: 15:41 ++ discriminant((*_15)) = 1; // scope 6 at $DIR/inline-generator.rs:15:41: 15:41 ++ goto -> bb1; // scope 0 at $DIR/inline-generator.rs:15:41: 15:41 + } + + bb8: { -+ assert(const false, "generator resumed after completion") -> [success: bb8, unwind: bb2]; // scope 6 at $DIR/inline-generator.rs:15:5: 15:8 ++ assert(const false, "generator resumed after completion") -> [success: bb8, unwind: bb2]; // scope 6 at $DIR/inline-generator.rs:15:5: 15:41 + } + + bb9: { -+ unreachable; // scope 6 at $DIR/inline-generator.rs:15:5: 15:8 ++ unreachable; // scope 6 at $DIR/inline-generator.rs:15:5: 15:41 } } diff --git a/src/test/mir-opt/retag.main-{closure#0}.SimplifyCfg-elaborate-drops.after.mir b/src/test/mir-opt/retag.main-{closure#0}.SimplifyCfg-elaborate-drops.after.mir index d254a95e06bea..44b1a267b3434 100644 --- a/src/test/mir-opt/retag.main-{closure#0}.SimplifyCfg-elaborate-drops.after.mir +++ b/src/test/mir-opt/retag.main-{closure#0}.SimplifyCfg-elaborate-drops.after.mir @@ -3,20 +3,20 @@ fn main::{closure#0}(_1: &[closure@main::{closure#0}], _2: &i32) -> &i32 { debug x => _2; // in scope 0 at $DIR/retag.rs:+0:32: +0:33 let mut _0: &i32; // return place in scope 0 at $DIR/retag.rs:+0:44: +0:48 - let _3: &i32; // in scope 0 at $DIR/retag.rs:42:13: 42:15 + let _3: &i32; // in scope 0 at $DIR/retag.rs:+1:13: +1:15 scope 1 { - debug _y => _3; // in scope 1 at $DIR/retag.rs:42:13: 42:15 + debug _y => _3; // in scope 1 at $DIR/retag.rs:+1:13: +1:15 } bb0: { - Retag([fn entry] _1); // scope 0 at $DIR/retag.rs:+0:31: +0:48 + Retag([fn entry] _1); // scope 0 at $DIR/retag.rs:+0:31: +3:6 Retag([fn entry] _2); // scope 0 at $DIR/retag.rs:+0:32: +0:33 - StorageLive(_3); // scope 0 at $DIR/retag.rs:42:13: 42:15 - _3 = _2; // scope 0 at $DIR/retag.rs:42:18: 42:19 - Retag(_3); // scope 0 at $DIR/retag.rs:42:18: 42:19 - _0 = _2; // scope 1 at $DIR/retag.rs:43:9: 43:10 - Retag(_0); // scope 1 at $DIR/retag.rs:43:9: 43:10 - StorageDead(_3); // scope 0 at $DIR/retag.rs:44:5: 44:6 - return; // scope 0 at $DIR/retag.rs:+0:48: +0:48 + StorageLive(_3); // scope 0 at $DIR/retag.rs:+1:13: +1:15 + _3 = _2; // scope 0 at $DIR/retag.rs:+1:18: +1:19 + Retag(_3); // scope 0 at $DIR/retag.rs:+1:18: +1:19 + _0 = _2; // scope 1 at $DIR/retag.rs:+2:9: +2:10 + Retag(_0); // scope 1 at $DIR/retag.rs:+2:9: +2:10 + StorageDead(_3); // scope 0 at $DIR/retag.rs:+3:5: +3:6 + return; // scope 0 at $DIR/retag.rs:+3:6: +3:6 } } diff --git a/src/test/mir-opt/storage_live_dead_in_statics.XXX.mir_map.0.mir b/src/test/mir-opt/storage_live_dead_in_statics.XXX.mir_map.0.mir index 4127a0c9555ea..e50067ea25ef4 100644 --- a/src/test/mir-opt/storage_live_dead_in_statics.XXX.mir_map.0.mir +++ b/src/test/mir-opt/storage_live_dead_in_statics.XXX.mir_map.0.mir @@ -198,6 +198,6 @@ static XXX: &Foo = { _0 = &(*_1); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+0:28: +18:2 StorageDead(_5); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+18:1: +18:2 StorageDead(_1); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+18:1: +18:2 - return; // scope 0 at $DIR/storage_live_dead_in_statics.rs:+0:1: +18:2 + return; // scope 0 at $DIR/storage_live_dead_in_statics.rs:+0:1: +18:3 } } diff --git a/src/test/mir-opt/unusual_item_types.{impl#0}-ASSOCIATED_CONSTANT.mir_map.0.32bit.mir b/src/test/mir-opt/unusual_item_types.{impl#0}-ASSOCIATED_CONSTANT.mir_map.0.32bit.mir index e2633f61b5fe4..5579d25a14fda 100644 --- a/src/test/mir-opt/unusual_item_types.{impl#0}-ASSOCIATED_CONSTANT.mir_map.0.32bit.mir +++ b/src/test/mir-opt/unusual_item_types.{impl#0}-ASSOCIATED_CONSTANT.mir_map.0.32bit.mir @@ -5,6 +5,6 @@ const ::ASSOCIATED_CONSTANT: i32 = bb0: { _0 = const 2_i32; // scope 0 at $DIR/unusual-item-types.rs:+0:38: +0:39 - return; // scope 0 at $DIR/unusual-item-types.rs:+0:5: +0:39 + return; // scope 0 at $DIR/unusual-item-types.rs:+0:5: +0:40 } } diff --git a/src/test/mir-opt/unusual_item_types.{impl#0}-ASSOCIATED_CONSTANT.mir_map.0.64bit.mir b/src/test/mir-opt/unusual_item_types.{impl#0}-ASSOCIATED_CONSTANT.mir_map.0.64bit.mir index e2633f61b5fe4..5579d25a14fda 100644 --- a/src/test/mir-opt/unusual_item_types.{impl#0}-ASSOCIATED_CONSTANT.mir_map.0.64bit.mir +++ b/src/test/mir-opt/unusual_item_types.{impl#0}-ASSOCIATED_CONSTANT.mir_map.0.64bit.mir @@ -5,6 +5,6 @@ const ::ASSOCIATED_CONSTANT: i32 = bb0: { _0 = const 2_i32; // scope 0 at $DIR/unusual-item-types.rs:+0:38: +0:39 - return; // scope 0 at $DIR/unusual-item-types.rs:+0:5: +0:39 + return; // scope 0 at $DIR/unusual-item-types.rs:+0:5: +0:40 } } diff --git a/src/test/ui/associated-consts/defaults-cyclic-fail.stderr b/src/test/ui/associated-consts/defaults-cyclic-fail.stderr index ab95137c630f2..c4cd9c2a49fd7 100644 --- a/src/test/ui/associated-consts/defaults-cyclic-fail.stderr +++ b/src/test/ui/associated-consts/defaults-cyclic-fail.stderr @@ -2,13 +2,13 @@ error[E0391]: cycle detected when const-evaluating + checking `Tr::A` --> $DIR/defaults-cyclic-fail.rs:5:5 | LL | const A: u8 = Self::B; - | ^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^ | note: ...which requires const-evaluating + checking `Tr::B`... --> $DIR/defaults-cyclic-fail.rs:8:5 | LL | const B: u8 = Self::A; - | ^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^ = note: ...which again requires const-evaluating + checking `Tr::A`, completing the cycle note: cycle used when const-evaluating + checking `main::promoted[1]` --> $DIR/defaults-cyclic-fail.rs:16:16 diff --git a/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-impl.stderr b/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-impl.stderr index e682b8e9e6d77..c8c57bccb5017 100644 --- a/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-impl.stderr +++ b/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-impl.stderr @@ -13,7 +13,7 @@ note: ...which requires const-evaluating + checking `IMPL_REF_BAR`... --> $DIR/issue-24949-assoc-const-static-recursion-impl.rs:7:1 | LL | const IMPL_REF_BAR: u32 = GlobalImplRef::BAR; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: ...which requires const-evaluating + checking `::BAR`... --> $DIR/issue-24949-assoc-const-static-recursion-impl.rs:12:5 | diff --git a/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait-default.stderr b/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait-default.stderr index 9b0c1b1490185..76ed8d4a6e864 100644 --- a/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait-default.stderr +++ b/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait-default.stderr @@ -13,7 +13,7 @@ note: ...which requires const-evaluating + checking `DEFAULT_REF_BAR`... --> $DIR/issue-24949-assoc-const-static-recursion-trait-default.rs:11:1 | LL | const DEFAULT_REF_BAR: u32 = ::BAR; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: ...which requires const-evaluating + checking `FooDefault::BAR`... --> $DIR/issue-24949-assoc-const-static-recursion-trait-default.rs:8:5 | diff --git a/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait.stderr b/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait.stderr index 48956dcedab8c..6a98f08f3d3ae 100644 --- a/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait.stderr +++ b/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait.stderr @@ -13,7 +13,7 @@ note: ...which requires const-evaluating + checking `TRAIT_REF_BAR`... --> $DIR/issue-24949-assoc-const-static-recursion-trait.rs:7:1 | LL | const TRAIT_REF_BAR: u32 = ::BAR; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: ...which requires const-evaluating + checking `::BAR`... --> $DIR/issue-24949-assoc-const-static-recursion-trait.rs:12:5 | diff --git a/src/test/ui/consts/issue-36163.stderr b/src/test/ui/consts/issue-36163.stderr index 0626ec4bcbe12..9ac6c984cb0cd 100644 --- a/src/test/ui/consts/issue-36163.stderr +++ b/src/test/ui/consts/issue-36163.stderr @@ -8,7 +8,7 @@ note: ...which requires const-evaluating + checking `A`... --> $DIR/issue-36163.rs:1:1 | LL | const A: isize = Foo::B as isize; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: ...which again requires const-evaluating + checking `Foo::B::{constant#0}`, completing the cycle note: cycle used when simplifying constant for the type system `Foo::B::{constant#0}` --> $DIR/issue-36163.rs:4:9 diff --git a/src/test/ui/issues/issue-17252.stderr b/src/test/ui/issues/issue-17252.stderr index b8f54416a0855..4856418ed6002 100644 --- a/src/test/ui/issues/issue-17252.stderr +++ b/src/test/ui/issues/issue-17252.stderr @@ -2,7 +2,7 @@ error[E0391]: cycle detected when const-evaluating + checking `FOO` --> $DIR/issue-17252.rs:1:1 | LL | const FOO: usize = FOO; - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^ | = note: ...which immediately requires const-evaluating + checking `FOO` again note: cycle used when const-evaluating + checking `main::{constant#0}` diff --git a/src/test/ui/issues/issue-23302-3.stderr b/src/test/ui/issues/issue-23302-3.stderr index e9314207537cd..074939f68a889 100644 --- a/src/test/ui/issues/issue-23302-3.stderr +++ b/src/test/ui/issues/issue-23302-3.stderr @@ -2,13 +2,13 @@ error[E0391]: cycle detected when const-evaluating + checking `A` --> $DIR/issue-23302-3.rs:1:1 | LL | const A: i32 = B; - | ^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^ | note: ...which requires const-evaluating + checking `B`... --> $DIR/issue-23302-3.rs:3:1 | LL | const B: i32 = A; - | ^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^ = note: ...which again requires const-evaluating + checking `A`, completing the cycle note: cycle used when simplifying constant for the type system `A` --> $DIR/issue-23302-3.rs:1:1 diff --git a/src/test/ui/nll/closure-requirements/escape-argument-callee.stderr b/src/test/ui/nll/closure-requirements/escape-argument-callee.stderr index f86a19fff8458..ff16bf0e078fc 100644 --- a/src/test/ui/nll/closure-requirements/escape-argument-callee.stderr +++ b/src/test/ui/nll/closure-requirements/escape-argument-callee.stderr @@ -2,7 +2,7 @@ note: no external requirements --> $DIR/escape-argument-callee.rs:26:38 | LL | let mut closure = expect_sig(|p, y| *p = y); - | ^^^^^^ + | ^^^^^^^^^^^^^ | = note: defining type: test::{closure#0} with closure substs [ i16, diff --git a/src/test/ui/nll/closure-requirements/escape-argument.stderr b/src/test/ui/nll/closure-requirements/escape-argument.stderr index 8cd8b43cabec6..49ec0dd931ac0 100644 --- a/src/test/ui/nll/closure-requirements/escape-argument.stderr +++ b/src/test/ui/nll/closure-requirements/escape-argument.stderr @@ -2,7 +2,7 @@ note: no external requirements --> $DIR/escape-argument.rs:26:38 | LL | let mut closure = expect_sig(|p, y| *p = y); - | ^^^^^^ + | ^^^^^^^^^^^^^ | = note: defining type: test::{closure#0} with closure substs [ i16, diff --git a/src/test/ui/nll/closure-requirements/escape-upvar-nested.stderr b/src/test/ui/nll/closure-requirements/escape-upvar-nested.stderr index abf80e0392899..f0ae4c7fb0492 100644 --- a/src/test/ui/nll/closure-requirements/escape-upvar-nested.stderr +++ b/src/test/ui/nll/closure-requirements/escape-upvar-nested.stderr @@ -2,7 +2,7 @@ note: external requirements --> $DIR/escape-upvar-nested.rs:21:32 | LL | let mut closure1 = || p = &y; - | ^^ + | ^^^^^^^^^ | = note: defining type: test::{closure#0}::{closure#0} with closure substs [ i16, @@ -15,8 +15,12 @@ LL | let mut closure1 = || p = &y; note: external requirements --> $DIR/escape-upvar-nested.rs:20:27 | -LL | let mut closure = || { - | ^^ +LL | let mut closure = || { + | ___________________________^ +LL | | let mut closure1 = || p = &y; +LL | | closure1(); +LL | | }; + | |_________^ | = note: defining type: test::{closure#0} with closure substs [ i16, diff --git a/src/test/ui/nll/closure-requirements/escape-upvar-ref.stderr b/src/test/ui/nll/closure-requirements/escape-upvar-ref.stderr index bc7546421731a..e99fc4b43a23d 100644 --- a/src/test/ui/nll/closure-requirements/escape-upvar-ref.stderr +++ b/src/test/ui/nll/closure-requirements/escape-upvar-ref.stderr @@ -2,7 +2,7 @@ note: external requirements --> $DIR/escape-upvar-ref.rs:23:27 | LL | let mut closure = || p = &y; - | ^^ + | ^^^^^^^^^ | = note: defining type: test::{closure#0} with closure substs [ i16, diff --git a/src/test/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr b/src/test/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr index b9b0f3ad25789..11420efaa066e 100644 --- a/src/test/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr @@ -1,8 +1,12 @@ note: no external requirements --> $DIR/propagate-approximated-fail-no-postdom.rs:43:9 | -LL | |_outlives1, _outlives2, _outlives3, x, y| { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | / |_outlives1, _outlives2, _outlives3, x, y| { +LL | | // Only works if 'x: 'y: +LL | | let p = x.get(); +LL | | demand_y(x, y, p) +LL | | }, + | |_________^ | = note: defining type: supply::{closure#0} with closure substs [ i16, diff --git a/src/test/ui/nll/closure-requirements/propagate-approximated-ref.stderr b/src/test/ui/nll/closure-requirements/propagate-approximated-ref.stderr index a2371ee314a77..98c3c28fb43ff 100644 --- a/src/test/ui/nll/closure-requirements/propagate-approximated-ref.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-approximated-ref.stderr @@ -1,8 +1,13 @@ note: external requirements --> $DIR/propagate-approximated-ref.rs:43:47 | -LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| { + | _______________________________________________^ +LL | | // Only works if 'x: 'y: +LL | | demand_y(x, y, x.get()) +LL | | +LL | | }); + | |_____^ | = note: defining type: supply::{closure#0} with closure substs [ i16, diff --git a/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr b/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr index e53ae167f12d6..3ab55b370c231 100644 --- a/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr @@ -1,8 +1,12 @@ note: no external requirements --> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:21:15 | -LL | foo(cell, |cell_a, cell_x| { - | ^^^^^^^^^^^^^^^^ +LL | foo(cell, |cell_a, cell_x| { + | _______________^ +LL | | cell_a.set(cell_x.get()); // forces 'x: 'a, error in closure +LL | | +LL | | }) + | |_____^ | = note: defining type: case1::{closure#0} with closure substs [ i32, @@ -37,8 +41,11 @@ LL | | } note: external requirements --> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:35:15 | -LL | foo(cell, |cell_a, cell_x| { - | ^^^^^^^^^^^^^^^^ +LL | foo(cell, |cell_a, cell_x| { + | _______________^ +LL | | cell_x.set(cell_a.get()); // forces 'a: 'x, implies 'a = 'static -> borrow error +LL | | }) + | |_____^ | = note: defining type: case2::{closure#0} with closure substs [ i32, diff --git a/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr b/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr index c3c7eb1bd9e5e..ec2c220b6b8a0 100644 --- a/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr @@ -1,8 +1,14 @@ note: external requirements --> $DIR/propagate-approximated-shorter-to-static-no-bound.rs:32:47 | -LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| { - | ^^^^^^^^^^^^^^^^^ +LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| { + | _______________________________________________^ +LL | | +LL | | +LL | | // Only works if 'x: 'y: +LL | | demand_y(x, y, x.get()) +LL | | }); + | |_____^ | = note: defining type: supply::{closure#0} with closure substs [ i16, diff --git a/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr b/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr index 846e5aedb3e73..234212c88767a 100644 --- a/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr @@ -1,8 +1,14 @@ note: external requirements --> $DIR/propagate-approximated-shorter-to-static-wrong-bound.rs:35:47 | -LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| { + | _______________________________________________^ +LL | | +LL | | +LL | | // Only works if 'x: 'y: +LL | | demand_y(x, y, x.get()) +LL | | }); + | |_____^ | = note: defining type: supply::{closure#0} with closure substs [ i16, diff --git a/src/test/ui/nll/closure-requirements/propagate-approximated-val.stderr b/src/test/ui/nll/closure-requirements/propagate-approximated-val.stderr index a570932eda9ad..2ec9d4d8db1a6 100644 --- a/src/test/ui/nll/closure-requirements/propagate-approximated-val.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-approximated-val.stderr @@ -1,8 +1,13 @@ note: external requirements --> $DIR/propagate-approximated-val.rs:36:45 | -LL | establish_relationships(cell_a, cell_b, |outlives1, outlives2, x, y| { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | establish_relationships(cell_a, cell_b, |outlives1, outlives2, x, y| { + | _____________________________________________^ +LL | | // Only works if 'x: 'y: +LL | | demand_y(outlives1, outlives2, x.get()) +LL | | +LL | | }); + | |_____^ | = note: defining type: test::{closure#0} with closure substs [ i16, diff --git a/src/test/ui/nll/closure-requirements/propagate-despite-same-free-region.stderr b/src/test/ui/nll/closure-requirements/propagate-despite-same-free-region.stderr index 407bc6764d6da..21e4232c788fb 100644 --- a/src/test/ui/nll/closure-requirements/propagate-despite-same-free-region.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-despite-same-free-region.stderr @@ -1,8 +1,12 @@ note: external requirements --> $DIR/propagate-despite-same-free-region.rs:42:9 | -LL | |_outlives1, _outlives2, x, y| { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | / |_outlives1, _outlives2, x, y| { +LL | | // Only works if 'x: 'y: +LL | | let p = x.get(); +LL | | demand_y(x, y, p) +LL | | }, + | |_________^ | = note: defining type: supply::{closure#0} with closure substs [ i16, diff --git a/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr b/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr index fcb55d37f310a..8b9b043542057 100644 --- a/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr @@ -1,8 +1,13 @@ note: no external requirements --> $DIR/propagate-fail-to-approximate-longer-no-bounds.rs:35:47 | -LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| { - | ^^^^^^^^^^^^^^^^^ +LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| { + | _______________________________________________^ +LL | | // Only works if 'x: 'y: +LL | | demand_y(x, y, x.get()) +LL | | +LL | | }); + | |_____^ | = note: defining type: supply::{closure#0} with closure substs [ i16, diff --git a/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr b/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr index 75beae39e2310..060ce690f0306 100644 --- a/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr @@ -1,8 +1,13 @@ note: no external requirements --> $DIR/propagate-fail-to-approximate-longer-wrong-bounds.rs:39:47 | -LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| { + | _______________________________________________^ +LL | | // Only works if 'x: 'y: +LL | | demand_y(x, y, x.get()) +LL | | +LL | | }); + | |_____^ | = note: defining type: supply::{closure#0} with closure substs [ i16, diff --git a/src/test/ui/nll/closure-requirements/propagate-from-trait-match.stderr b/src/test/ui/nll/closure-requirements/propagate-from-trait-match.stderr index 58aced2bfcdb1..08605efa2ea9c 100644 --- a/src/test/ui/nll/closure-requirements/propagate-from-trait-match.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-from-trait-match.stderr @@ -1,8 +1,15 @@ note: external requirements --> $DIR/propagate-from-trait-match.rs:32:36 | -LL | establish_relationships(value, |value| { - | ^^^^^^^ +LL | establish_relationships(value, |value| { + | ____________________________________^ +LL | | +LL | | +LL | | // This function call requires that +... | +LL | | require(value); +LL | | }); + | |_____^ | = note: defining type: supply::<'_#1r, T>::{closure#0} with closure substs [ i32, diff --git a/src/test/ui/nll/closure-requirements/return-wrong-bound-region.stderr b/src/test/ui/nll/closure-requirements/return-wrong-bound-region.stderr index 1c9d0c835494d..5fc1d5c436181 100644 --- a/src/test/ui/nll/closure-requirements/return-wrong-bound-region.stderr +++ b/src/test/ui/nll/closure-requirements/return-wrong-bound-region.stderr @@ -2,7 +2,7 @@ note: no external requirements --> $DIR/return-wrong-bound-region.rs:11:16 | LL | expect_sig(|a, b| b); // ought to return `a` - | ^^^^^^ + | ^^^^^^^^ | = note: defining type: test::{closure#0} with closure substs [ i16, diff --git a/src/test/ui/nll/ty-outlives/projection-no-regions-closure.stderr b/src/test/ui/nll/ty-outlives/projection-no-regions-closure.stderr index feab2476970a1..8fe25181da1a0 100644 --- a/src/test/ui/nll/ty-outlives/projection-no-regions-closure.stderr +++ b/src/test/ui/nll/ty-outlives/projection-no-regions-closure.stderr @@ -2,7 +2,7 @@ note: external requirements --> $DIR/projection-no-regions-closure.rs:25:23 | LL | with_signature(x, |mut y| Box::new(y.next())) - | ^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: no_region::<'_#1r, T>::{closure#0} with closure substs [ i32, @@ -39,7 +39,7 @@ note: external requirements --> $DIR/projection-no-regions-closure.rs:34:23 | LL | with_signature(x, |mut y| Box::new(y.next())) - | ^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: correct_region::<'_#1r, T>::{closure#0} with closure substs [ i32, @@ -66,7 +66,7 @@ note: external requirements --> $DIR/projection-no-regions-closure.rs:42:23 | LL | with_signature(x, |mut y| Box::new(y.next())) - | ^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: wrong_region::<'_#1r, '_#2r, T>::{closure#0} with closure substs [ i32, @@ -103,7 +103,7 @@ note: external requirements --> $DIR/projection-no-regions-closure.rs:52:23 | LL | with_signature(x, |mut y| Box::new(y.next())) - | ^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: outlives_region::<'_#1r, '_#2r, T>::{closure#0} with closure substs [ i32, diff --git a/src/test/ui/nll/ty-outlives/projection-one-region-closure.stderr b/src/test/ui/nll/ty-outlives/projection-one-region-closure.stderr index 98063bd0a7674..caf2e3c474755 100644 --- a/src/test/ui/nll/ty-outlives/projection-one-region-closure.stderr +++ b/src/test/ui/nll/ty-outlives/projection-one-region-closure.stderr @@ -2,7 +2,7 @@ note: external requirements --> $DIR/projection-one-region-closure.rs:45:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: no_relationships_late::<'_#1r, T>::{closure#0} with closure substs [ i32, @@ -56,7 +56,7 @@ note: external requirements --> $DIR/projection-one-region-closure.rs:56:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: no_relationships_early::<'_#1r, '_#2r, T>::{closure#0} with closure substs [ i32, @@ -109,7 +109,7 @@ note: external requirements --> $DIR/projection-one-region-closure.rs:70:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: projection_outlives::<'_#1r, '_#2r, T>::{closure#0} with closure substs [ i32, @@ -137,7 +137,7 @@ note: external requirements --> $DIR/projection-one-region-closure.rs:80:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: elements_outlive::<'_#1r, '_#2r, T>::{closure#0} with closure substs [ i32, diff --git a/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.stderr b/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.stderr index 45e61bcbda85e..4eebe682d4fbc 100644 --- a/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.stderr +++ b/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.stderr @@ -2,7 +2,7 @@ note: external requirements --> $DIR/projection-one-region-trait-bound-closure.rs:37:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: no_relationships_late::<'_#1r, T>::{closure#0} with closure substs [ i32, @@ -44,7 +44,7 @@ note: external requirements --> $DIR/projection-one-region-trait-bound-closure.rs:47:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: no_relationships_early::<'_#1r, '_#2r, T>::{closure#0} with closure substs [ i32, @@ -85,7 +85,7 @@ note: external requirements --> $DIR/projection-one-region-trait-bound-closure.rs:60:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: projection_outlives::<'_#1r, '_#2r, T>::{closure#0} with closure substs [ i32, @@ -113,7 +113,7 @@ note: external requirements --> $DIR/projection-one-region-trait-bound-closure.rs:69:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: elements_outlive::<'_#1r, '_#2r, T>::{closure#0} with closure substs [ i32, @@ -141,7 +141,7 @@ note: external requirements --> $DIR/projection-one-region-trait-bound-closure.rs:81:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: one_region::<'_#1r, T>::{closure#0} with closure substs [ i32, diff --git a/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-static-closure.stderr b/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-static-closure.stderr index f2549205b8120..46a02598e19bc 100644 --- a/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-static-closure.stderr +++ b/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-static-closure.stderr @@ -2,7 +2,7 @@ note: no external requirements --> $DIR/projection-one-region-trait-bound-static-closure.rs:36:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: no_relationships_late::<'_#1r, T>::{closure#0} with closure substs [ i32, @@ -28,7 +28,7 @@ note: no external requirements --> $DIR/projection-one-region-trait-bound-static-closure.rs:45:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: no_relationships_early::<'_#1r, '_#2r, T>::{closure#0} with closure substs [ i32, @@ -54,7 +54,7 @@ note: no external requirements --> $DIR/projection-one-region-trait-bound-static-closure.rs:64:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: projection_outlives::<'_#1r, '_#2r, T>::{closure#0} with closure substs [ i32, @@ -80,7 +80,7 @@ note: no external requirements --> $DIR/projection-one-region-trait-bound-static-closure.rs:73:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: elements_outlive::<'_#1r, '_#2r, T>::{closure#0} with closure substs [ i32, @@ -106,7 +106,7 @@ note: no external requirements --> $DIR/projection-one-region-trait-bound-static-closure.rs:85:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: one_region::<'_#1r, T>::{closure#0} with closure substs [ i32, diff --git a/src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr b/src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr index 8e1b6fa2e4630..1ee788b40ab9e 100644 --- a/src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr +++ b/src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr @@ -2,7 +2,7 @@ note: external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:38:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: no_relationships_late::<'_#1r, '_#2r, T>::{closure#0} with closure substs [ i32, @@ -40,7 +40,7 @@ note: external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:48:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: no_relationships_early::<'_#1r, '_#2r, '_#3r, T>::{closure#0} with closure substs [ i32, @@ -77,7 +77,7 @@ note: external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:61:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: projection_outlives::<'_#1r, '_#2r, '_#3r, T>::{closure#0} with closure substs [ i32, @@ -105,7 +105,7 @@ note: external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:70:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: elements_outlive1::<'_#1r, '_#2r, '_#3r, T>::{closure#0} with closure substs [ i32, @@ -133,7 +133,7 @@ note: external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:79:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: elements_outlive2::<'_#1r, '_#2r, '_#3r, T>::{closure#0} with closure substs [ i32, @@ -161,7 +161,7 @@ note: external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:87:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: two_regions::<'_#1r, T>::{closure#0} with closure substs [ i32, @@ -203,7 +203,7 @@ note: external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:97:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: two_regions_outlive::<'_#1r, '_#2r, T>::{closure#0} with closure substs [ i32, @@ -231,7 +231,7 @@ note: external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:109:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: one_region::<'_#1r, T>::{closure#0} with closure substs [ i32, diff --git a/src/test/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr b/src/test/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr index 12c76d198e780..a4588730b3f87 100644 --- a/src/test/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr +++ b/src/test/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr @@ -2,7 +2,7 @@ note: external requirements --> $DIR/ty-param-closure-approximate-lower-bound.rs:24:24 | LL | twice(cell, value, |a, b| invoke(a, b)); - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^ | = note: defining type: generic::::{closure#0} with closure substs [ i16, @@ -27,7 +27,7 @@ note: external requirements --> $DIR/ty-param-closure-approximate-lower-bound.rs:29:24 | LL | twice(cell, value, |a, b| invoke(a, b)); - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^ | = note: defining type: generic_fail::::{closure#0} with closure substs [ i16, diff --git a/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.stderr b/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.stderr index 35741859dffec..084dd93cb86b9 100644 --- a/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.stderr +++ b/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.stderr @@ -2,7 +2,7 @@ note: external requirements --> $DIR/ty-param-closure-outlives-from-return-type.rs:26:23 | LL | with_signature(x, |y| y) - | ^^^ + | ^^^^^ | = note: defining type: no_region::<'_#1r, T>::{closure#0} with closure substs [ i32, diff --git a/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.stderr b/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.stderr index 0261bc39e7127..11a737ba291f0 100644 --- a/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.stderr +++ b/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.stderr @@ -1,8 +1,15 @@ note: external requirements --> $DIR/ty-param-closure-outlives-from-where-clause.rs:27:26 | -LL | with_signature(a, b, |x, y| { - | ^^^^^^ +LL | with_signature(a, b, |x, y| { + | __________________________^ +LL | | +LL | | // +LL | | // See `correct_region`, which explains the point of this +... | +LL | | require(&x, &y) +LL | | }) + | |_____^ | = note: defining type: no_region::::{closure#0} with closure substs [ i32, @@ -48,8 +55,15 @@ LL | fn no_region<'a, T: 'a>(a: Cell<&'a ()>, b: T) { note: external requirements --> $DIR/ty-param-closure-outlives-from-where-clause.rs:43:26 | -LL | with_signature(a, b, |x, y| { - | ^^^^^^ +LL | with_signature(a, b, |x, y| { + | __________________________^ +LL | | // Key point of this test: +LL | | // +LL | | // The *closure* is being type-checked with all of its free +... | +LL | | require(&x, &y) +LL | | }) + | |_____^ | = note: defining type: correct_region::<'_#1r, T>::{closure#0} with closure substs [ i32, @@ -76,8 +90,13 @@ LL | | } note: external requirements --> $DIR/ty-param-closure-outlives-from-where-clause.rs:64:26 | -LL | with_signature(a, b, |x, y| { - | ^^^^^^ +LL | with_signature(a, b, |x, y| { + | __________________________^ +LL | | +LL | | // See `correct_region` +LL | | require(&x, &y) +LL | | }) + | |_____^ | = note: defining type: wrong_region::<'_#1r, T>::{closure#0} with closure substs [ i32, @@ -121,8 +140,12 @@ LL | T: 'b + 'a, note: external requirements --> $DIR/ty-param-closure-outlives-from-where-clause.rs:77:26 | -LL | with_signature(a, b, |x, y| { - | ^^^^^^ +LL | with_signature(a, b, |x, y| { + | __________________________^ +LL | | // See `correct_region` +LL | | require(&x, &y) +LL | | }) + | |_____^ | = note: defining type: outlives_region::<'_#1r, '_#2r, T>::{closure#0} with closure substs [ i32, diff --git a/src/test/ui/nll/user-annotations/adt-nullary-enums.stderr b/src/test/ui/nll/user-annotations/adt-nullary-enums.stderr index ee332278c30f5..3326fa521fc9c 100644 --- a/src/test/ui/nll/user-annotations/adt-nullary-enums.stderr +++ b/src/test/ui/nll/user-annotations/adt-nullary-enums.stderr @@ -30,14 +30,15 @@ error[E0597]: `c` does not live long enough | LL | fn annot_reference_named_lifetime_in_closure<'a>(_: &'a u32) { | -- lifetime `'a` defined here -LL | let _closure = || { - | - `c` dropped here while still borrowed ... LL | SomeEnum::SomeVariant(Cell::new(&c)), | ----------^^- | | | | | borrowed value does not live long enough | argument requires that `c` is borrowed for `'a` +... +LL | }; + | - `c` dropped here while still borrowed error: aborting due to 3 previous errors diff --git a/src/test/ui/nll/user-annotations/adt-tuple-struct-calls.stderr b/src/test/ui/nll/user-annotations/adt-tuple-struct-calls.stderr index 95bbd62c4fb0d..9664fb9f54831 100644 --- a/src/test/ui/nll/user-annotations/adt-tuple-struct-calls.stderr +++ b/src/test/ui/nll/user-annotations/adt-tuple-struct-calls.stderr @@ -28,28 +28,28 @@ error[E0597]: `c` does not live long enough | LL | fn annot_reference_named_lifetime_in_closure<'a>(_: &'a u32) { | -- lifetime `'a` defined here -LL | let _closure = || { - | - `c` dropped here while still borrowed ... LL | f(&c); | --^^- | | | | | borrowed value does not live long enough | argument requires that `c` is borrowed for `'a` +LL | }; + | - `c` dropped here while still borrowed error[E0597]: `c` does not live long enough --> $DIR/adt-tuple-struct-calls.rs:53:11 | LL | let f = SomeStruct::<&'a u32>; | - lifetime `'1` appears in the type of `f` -LL | let _closure = || { - | - `c` dropped here while still borrowed -LL | let c = 66; +... LL | f(&c); | --^^- | | | | | borrowed value does not live long enough | argument requires that `c` is borrowed for `'1` +LL | }; + | - `c` dropped here while still borrowed error: aborting due to 4 previous errors diff --git a/src/test/ui/nll/user-annotations/fns.stderr b/src/test/ui/nll/user-annotations/fns.stderr index bd4d121d56914..e0640da39e2b6 100644 --- a/src/test/ui/nll/user-annotations/fns.stderr +++ b/src/test/ui/nll/user-annotations/fns.stderr @@ -28,14 +28,14 @@ error[E0597]: `c` does not live long enough | LL | fn annot_reference_named_lifetime_in_closure<'a>(_: &'a u32) { | -- lifetime `'a` defined here -LL | let _closure = || { - | - `c` dropped here while still borrowed -LL | let c = 66; +... LL | some_fn::<&'a u32>(&c); | -------------------^^- | | | | | borrowed value does not live long enough | argument requires that `c` is borrowed for `'a` +LL | }; + | - `c` dropped here while still borrowed error: aborting due to 3 previous errors diff --git a/src/test/ui/nll/user-annotations/method-call.stderr b/src/test/ui/nll/user-annotations/method-call.stderr index fcaeb465d140e..10447e45a6d42 100644 --- a/src/test/ui/nll/user-annotations/method-call.stderr +++ b/src/test/ui/nll/user-annotations/method-call.stderr @@ -29,14 +29,13 @@ error[E0597]: `c` does not live long enough LL | fn annot_reference_named_lifetime_in_closure<'a>(_: &'a u32) { | -- lifetime `'a` defined here ... -LL | let _closure = || { - | - `c` dropped here while still borrowed -LL | let c = 66; LL | a.method::<&'a u32>(b, &c); | ------------------------^^- | | | | | borrowed value does not live long enough | argument requires that `c` is borrowed for `'a` +LL | }; + | - `c` dropped here while still borrowed error: aborting due to 3 previous errors diff --git a/src/test/ui/nll/user-annotations/method-ufcs-3.stderr b/src/test/ui/nll/user-annotations/method-ufcs-3.stderr index 328dde9805aae..e7851833e93b2 100644 --- a/src/test/ui/nll/user-annotations/method-ufcs-3.stderr +++ b/src/test/ui/nll/user-annotations/method-ufcs-3.stderr @@ -29,14 +29,13 @@ error[E0597]: `c` does not live long enough LL | fn annot_reference_named_lifetime_in_closure<'a>(_: &'a u32) { | -- lifetime `'a` defined here ... -LL | let _closure = || { - | - `c` dropped here while still borrowed -LL | let c = 66; LL | <_ as Bazoom<_>>::method::<&'a u32>(&a, b, &c); | -------------------------------------------^^- | | | | | borrowed value does not live long enough | argument requires that `c` is borrowed for `'a` +LL | }; + | - `c` dropped here while still borrowed error: aborting due to 3 previous errors From 26037b1ca870bba886bef400075347c3102da252 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sat, 27 Aug 2022 14:40:39 +0200 Subject: [PATCH 14/25] Simplify MIR building entry. --- compiler/rustc_mir_build/src/build/mod.rs | 531 +++++++++--------- src/test/ui/impl-trait/auto-trait-leak.stderr | 10 + 2 files changed, 260 insertions(+), 281 deletions(-) diff --git a/compiler/rustc_mir_build/src/build/mod.rs b/compiler/rustc_mir_build/src/build/mod.rs index 3a6750531e1f2..e9daafaa83af1 100644 --- a/compiler/rustc_mir_build/src/build/mod.rs +++ b/compiler/rustc_mir_build/src/build/mod.rs @@ -1,4 +1,3 @@ -use crate::build; pub(crate) use crate::build::expr::as_constant::lit_to_mir_constant; use crate::build::expr::as_place::PlaceBuilder; use crate::build::scope::DropKind; @@ -47,9 +46,7 @@ pub(crate) fn mir_built<'tcx>( /// Construct the MIR for a given `DefId`. fn mir_build(tcx: TyCtxt<'_>, def: ty::WithOptConstParam) -> Body<'_> { - let id = tcx.hir().local_def_id_to_hir_id(def.did); let body_owner_kind = tcx.hir().body_owner_kind(def.did); - let typeck_results = tcx.typeck_opt_const_arg(def); // Ensure unsafeck and abstract const building is ran before we steal the THIR. // We can't use `ensure()` for `thir_abstract_const` as it doesn't compute the query @@ -66,188 +63,37 @@ fn mir_build(tcx: TyCtxt<'_>, def: ty::WithOptConstParam) -> Body<'_ } } - // Figure out what primary body this item has. - let body_id = tcx.hir().body_owned_by(def.did); - let span_with_body = tcx.hir().span_with_body(id); - let return_ty_span = if let Some(fn_decl) = tcx.hir().fn_decl_by_hir_id(id) { - fn_decl.output.span() - } else { - match tcx.hir().get(id) { - Node::Item(hir::Item { - kind: hir::ItemKind::Static(ty, _, _) | hir::ItemKind::Const(ty, _), - .. - }) - | Node::ImplItem(hir::ImplItem { kind: hir::ImplItemKind::Const(ty, _), .. }) - | Node::TraitItem(hir::TraitItem { kind: hir::TraitItemKind::Const(ty, _), .. }) => { - ty.span - } - Node::AnonConst(_) => tcx.def_span(def.did), - _ => span_bug!(tcx.def_span(def.did), "can't build MIR for {:?}", def.did), - } - }; - - tcx.infer_ctxt().enter(|infcx| { - let body = if let Some(error_reported) = typeck_results.tainted_by_errors { - build::construct_error(&infcx, def, id, body_id, body_owner_kind, error_reported) - } else if body_owner_kind.is_fn_or_closure() { - // fetch the fully liberated fn signature (that is, all bound - // types/lifetimes replaced) - let fn_sig = typeck_results.liberated_fn_sigs()[id]; - let fn_def_id = tcx.hir().local_def_id(id); - - let safety = match fn_sig.unsafety { - hir::Unsafety::Normal => Safety::Safe, - hir::Unsafety::Unsafe => Safety::FnUnsafe, - }; - - let body = tcx.hir().body(body_id); - let (thir, expr) = tcx - .thir_body(def) - .unwrap_or_else(|_| (tcx.alloc_steal_thir(Thir::new()), ExprId::from_u32(0))); + let body = match tcx.thir_body(def) { + Err(error_reported) => construct_error(tcx, def.did, body_owner_kind, error_reported), + Ok((thir, expr)) => { // We ran all queries that depended on THIR at the beginning // of `mir_build`, so now we can steal it let thir = thir.steal(); - let ty = tcx.type_of(fn_def_id); - let mut abi = fn_sig.abi; - let implicit_argument = match ty.kind() { - ty::Closure(..) => { - // HACK(eddyb) Avoid having RustCall on closures, - // as it adds unnecessary (and wrong) auto-tupling. - abi = Abi::Rust; - vec![ArgInfo(liberated_closure_env_ty(tcx, id, body_id), None, None, None)] - } - ty::Generator(..) => { - let gen_ty = tcx.typeck_body(body_id).node_type(id); - - // The resume argument may be missing, in that case we need to provide it here. - // It will always be `()` in this case. - if body.params.is_empty() { - vec![ - ArgInfo(gen_ty, None, None, None), - ArgInfo(tcx.mk_unit(), None, None, None), - ] - } else { - vec![ArgInfo(gen_ty, None, None, None)] - } - } - _ => vec![], - }; - let explicit_arguments = body.params.iter().enumerate().map(|(index, arg)| { - let owner_id = tcx.hir().body_owner(body_id); - let opt_ty_info; - let self_arg; - if let Some(ref fn_decl) = tcx.hir().fn_decl_by_hir_id(owner_id) { - opt_ty_info = fn_decl - .inputs - .get(index) - // Make sure that inferred closure args have no type span - .and_then(|ty| if arg.pat.span != ty.span { Some(ty.span) } else { None }); - self_arg = if index == 0 && fn_decl.implicit_self.has_implicit_self() { - Some(fn_decl.implicit_self) - } else { - None - }; - } else { - opt_ty_info = None; - self_arg = None; - } - - // C-variadic fns also have a `VaList` input that's not listed in `fn_sig` - // (as it's created inside the body itself, not passed in from outside). - let ty = if fn_sig.c_variadic && index == fn_sig.inputs().len() { - let va_list_did = tcx.require_lang_item(LangItem::VaList, Some(arg.span)); - - tcx.bound_type_of(va_list_did).subst(tcx, &[tcx.lifetimes.re_erased.into()]) - } else { - fn_sig.inputs()[index] - }; - - ArgInfo(ty, opt_ty_info, Some(&arg), self_arg) - }); - - let arguments = implicit_argument.into_iter().chain(explicit_arguments); - - let (yield_ty, return_ty) = if body.generator_kind.is_some() { - let gen_ty = tcx.typeck_body(body_id).node_type(id); - let gen_sig = match gen_ty.kind() { - ty::Generator(_, gen_substs, ..) => gen_substs.as_generator().sig(), - _ => span_bug!(tcx.hir().span(id), "generator w/o generator type: {:?}", ty), - }; - (Some(gen_sig.yield_ty), gen_sig.return_ty) + if body_owner_kind.is_fn_or_closure() { + construct_fn(tcx, def, &thir, expr) } else { - (None, fn_sig.output()) - }; - - let mut mir = build::construct_fn( - &thir, - &infcx, - def, - id, - arguments, - safety, - abi, - return_ty, - return_ty_span, - body, - expr, - span_with_body, - ); - if yield_ty.is_some() { - mir.generator.as_mut().unwrap().yield_ty = yield_ty; + construct_const(tcx, def, &thir, expr) } - mir - } else { - // Get the revealed type of this const. This is *not* the adjusted - // type of its body, which may be a subtype of this type. For - // example: - // - // fn foo(_: &()) {} - // static X: fn(&'static ()) = foo; - // - // The adjusted type of the body of X is `for<'a> fn(&'a ())` which - // is not the same as the type of X. We need the type of the return - // place to be the type of the constant because NLL typeck will - // equate them. - - let return_ty = typeck_results.node_type(id); - - let (thir, expr) = tcx - .thir_body(def) - .unwrap_or_else(|_| (tcx.alloc_steal_thir(Thir::new()), ExprId::from_u32(0))); - // We ran all queries that depended on THIR at the beginning - // of `mir_build`, so now we can steal it - let thir = thir.steal(); - - build::construct_const( - &thir, - &infcx, - expr, - def, - id, - return_ty, - return_ty_span, - span_with_body, - ) - }; + } + }; - lints::check(tcx, &body); - - // The borrow checker will replace all the regions here with its own - // inference variables. There's no point having non-erased regions here. - // The exception is `body.user_type_annotations`, which is used unmodified - // by borrow checking. - debug_assert!( - !(body.local_decls.has_free_regions() - || body.basic_blocks.has_free_regions() - || body.var_debug_info.has_free_regions() - || body.yield_ty().has_free_regions()), - "Unexpected free regions in MIR: {:?}", - body, - ); + lints::check(tcx, &body); + + // The borrow checker will replace all the regions here with its own + // inference variables. There's no point having non-erased regions here. + // The exception is `body.user_type_annotations`, which is used unmodified + // by borrow checking. + debug_assert!( + !(body.local_decls.has_free_regions() + || body.basic_blocks.has_free_regions() + || body.var_debug_info.has_free_regions() + || body.yield_ty().has_free_regions()), + "Unexpected free regions in MIR: {:?}", + body, + ); - body - }) + body } /////////////////////////////////////////////////////////////////////////// @@ -330,7 +176,7 @@ struct BlockContext(Vec); struct Builder<'a, 'tcx> { tcx: TyCtxt<'tcx>, - infcx: &'a InferCtxt<'a, 'tcx>, + infcx: InferCtxt<'a, 'tcx>, typeck_results: &'tcx TypeckResults<'tcx>, region_scope_tree: &'tcx region::ScopeTree, param_env: ty::ParamEnv<'tcx>, @@ -600,141 +446,264 @@ struct ArgInfo<'tcx>( Option, ); -fn construct_fn<'tcx, A>( - thir: &Thir<'tcx>, - infcx: &InferCtxt<'_, 'tcx>, +fn construct_fn<'tcx>( + tcx: TyCtxt<'tcx>, fn_def: ty::WithOptConstParam, - fn_id: hir::HirId, - arguments: A, - safety: Safety, - abi: Abi, - return_ty: Ty<'tcx>, - return_ty_span: Span, - body: &'tcx hir::Body<'tcx>, + thir: &Thir<'tcx>, expr: ExprId, - span_with_body: Span, -) -> Body<'tcx> -where - A: Iterator>, -{ +) -> Body<'tcx> { + let span = tcx.def_span(fn_def.did); + let fn_id = tcx.hir().local_def_id_to_hir_id(fn_def.did); + let generator_kind = tcx.generator_kind(fn_def.did); + + // Figure out what primary body this item has. + let body_id = tcx.hir().body_owned_by(fn_def.did); + let span_with_body = tcx.hir().span_with_body(fn_id); + let return_ty_span = tcx + .hir() + .fn_decl_by_hir_id(fn_id) + .unwrap_or_else(|| span_bug!(span, "can't build MIR for {:?}", fn_def.did)) + .output + .span(); + + // fetch the fully liberated fn signature (that is, all bound + // types/lifetimes replaced) + let typeck_results = tcx.typeck_opt_const_arg(fn_def); + let fn_sig = typeck_results.liberated_fn_sigs()[fn_id]; + + let safety = match fn_sig.unsafety { + hir::Unsafety::Normal => Safety::Safe, + hir::Unsafety::Unsafe => Safety::FnUnsafe, + }; + + let body = tcx.hir().body(body_id); + let ty = tcx.type_of(fn_def.did); + let mut abi = fn_sig.abi; + let implicit_argument = match ty.kind() { + ty::Closure(..) => { + // HACK(eddyb) Avoid having RustCall on closures, + // as it adds unnecessary (and wrong) auto-tupling. + abi = Abi::Rust; + vec![ArgInfo(liberated_closure_env_ty(tcx, fn_id, body_id), None, None, None)] + } + ty::Generator(..) => { + let gen_ty = typeck_results.node_type(fn_id); + + // The resume argument may be missing, in that case we need to provide it here. + // It will always be `()` in this case. + if body.params.is_empty() { + vec![ArgInfo(gen_ty, None, None, None), ArgInfo(tcx.mk_unit(), None, None, None)] + } else { + vec![ArgInfo(gen_ty, None, None, None)] + } + } + _ => vec![], + }; + + let explicit_arguments = body.params.iter().enumerate().map(|(index, arg)| { + let owner_id = tcx.hir().body_owner(body_id); + let opt_ty_info; + let self_arg; + if let Some(ref fn_decl) = tcx.hir().fn_decl_by_hir_id(owner_id) { + opt_ty_info = fn_decl + .inputs + .get(index) + // Make sure that inferred closure args have no type span + .and_then(|ty| if arg.pat.span != ty.span { Some(ty.span) } else { None }); + self_arg = if index == 0 && fn_decl.implicit_self.has_implicit_self() { + Some(fn_decl.implicit_self) + } else { + None + }; + } else { + opt_ty_info = None; + self_arg = None; + } + + // C-variadic fns also have a `VaList` input that's not listed in `fn_sig` + // (as it's created inside the body itself, not passed in from outside). + let ty = if fn_sig.c_variadic && index == fn_sig.inputs().len() { + let va_list_did = tcx.require_lang_item(LangItem::VaList, Some(arg.span)); + + tcx.bound_type_of(va_list_did).subst(tcx, &[tcx.lifetimes.re_erased.into()]) + } else { + fn_sig.inputs()[index] + }; + + ArgInfo(ty, opt_ty_info, Some(&arg), self_arg) + }); + + let arguments = implicit_argument.into_iter().chain(explicit_arguments); + + let (yield_ty, return_ty) = if generator_kind.is_some() { + let gen_ty = typeck_results.node_type(fn_id); + let gen_sig = match gen_ty.kind() { + ty::Generator(_, gen_substs, ..) => gen_substs.as_generator().sig(), + _ => { + span_bug!(span, "generator w/o generator type: {:?}", ty) + } + }; + (Some(gen_sig.yield_ty), gen_sig.return_ty) + } else { + (None, fn_sig.output()) + }; + let arguments: Vec<_> = arguments.collect(); - let tcx = infcx.tcx; - let span = tcx.hir().span(fn_id); - - let mut builder = Builder::new( - thir, - infcx, - fn_def, - fn_id, - span_with_body, - arguments.len(), - safety, - return_ty, - return_ty_span, - body.generator_kind, - ); + let mut body = tcx.infer_ctxt().enter(|infcx| { + let mut builder = Builder::new( + thir, + infcx, + fn_def, + fn_id, + span_with_body, + arguments.len(), + safety, + return_ty, + return_ty_span, + generator_kind, + ); - let call_site_scope = - region::Scope { id: body.value.hir_id.local_id, data: region::ScopeData::CallSite }; - let arg_scope = - region::Scope { id: body.value.hir_id.local_id, data: region::ScopeData::Arguments }; - let source_info = builder.source_info(span); - let call_site_s = (call_site_scope, source_info); - unpack!(builder.in_scope(call_site_s, LintLevel::Inherited, |builder| { - let arg_scope_s = (arg_scope, source_info); - // Attribute epilogue to function's closing brace - let fn_end = span_with_body.shrink_to_hi(); - let return_block = - unpack!(builder.in_breakable_scope(None, Place::return_place(), fn_end, |builder| { - Some(builder.in_scope(arg_scope_s, LintLevel::Inherited, |builder| { - builder.args_and_body( - START_BLOCK, - fn_def.did, - &arguments, - arg_scope, - &thir[expr], - ) - })) - })); - let source_info = builder.source_info(fn_end); - builder.cfg.terminate(return_block, source_info, TerminatorKind::Return); - builder.build_drop_trees(); - return_block.unit() - })); + let call_site_scope = + region::Scope { id: body.value.hir_id.local_id, data: region::ScopeData::CallSite }; + let arg_scope = + region::Scope { id: body.value.hir_id.local_id, data: region::ScopeData::Arguments }; + let source_info = builder.source_info(span); + let call_site_s = (call_site_scope, source_info); + unpack!(builder.in_scope(call_site_s, LintLevel::Inherited, |builder| { + let arg_scope_s = (arg_scope, source_info); + // Attribute epilogue to function's closing brace + let fn_end = span_with_body.shrink_to_hi(); + let return_block = unpack!(builder.in_breakable_scope( + None, + Place::return_place(), + fn_end, + |builder| { + Some(builder.in_scope(arg_scope_s, LintLevel::Inherited, |builder| { + builder.args_and_body( + START_BLOCK, + fn_def.did, + &arguments, + arg_scope, + &thir[expr], + ) + })) + } + )); + let source_info = builder.source_info(fn_end); + builder.cfg.terminate(return_block, source_info, TerminatorKind::Return); + builder.build_drop_trees(); + return_block.unit() + })); + + builder.finish() + }); - let spread_arg = if abi == Abi::RustCall { + body.spread_arg = if abi == Abi::RustCall { // RustCall pseudo-ABI untuples the last argument. Some(Local::new(arguments.len())) } else { None }; - - let mut body = builder.finish(); - body.spread_arg = spread_arg; + if yield_ty.is_some() { + body.generator.as_mut().unwrap().yield_ty = yield_ty; + } body } fn construct_const<'a, 'tcx>( + tcx: TyCtxt<'tcx>, + def: ty::WithOptConstParam, thir: &'a Thir<'tcx>, - infcx: &'a InferCtxt<'a, 'tcx>, expr: ExprId, - def: ty::WithOptConstParam, - hir_id: hir::HirId, - const_ty: Ty<'tcx>, - const_ty_span: Span, - span: Span, ) -> Body<'tcx> { - let mut builder = Builder::new( - thir, - infcx, - def, - hir_id, - span, - 0, - Safety::Safe, - const_ty, - const_ty_span, - None, - ); + let hir_id = tcx.hir().local_def_id_to_hir_id(def.did); - let mut block = START_BLOCK; - unpack!(block = builder.expr_into_dest(Place::return_place(), block, &thir[expr])); + // Figure out what primary body this item has. + let (span, const_ty_span) = match tcx.hir().get(hir_id) { + Node::Item(hir::Item { + kind: hir::ItemKind::Static(ty, _, _) | hir::ItemKind::Const(ty, _), + span, + .. + }) + | Node::ImplItem(hir::ImplItem { kind: hir::ImplItemKind::Const(ty, _), span, .. }) + | Node::TraitItem(hir::TraitItem { + kind: hir::TraitItemKind::Const(ty, Some(_)), + span, + .. + }) => (*span, ty.span), + Node::AnonConst(_) => { + let span = tcx.def_span(def.did); + (span, span) + } + _ => span_bug!(tcx.def_span(def.did), "can't build MIR for {:?}", def.did), + }; - let source_info = builder.source_info(span); - builder.cfg.terminate(block, source_info, TerminatorKind::Return); + // Get the revealed type of this const. This is *not* the adjusted + // type of its body, which may be a subtype of this type. For + // example: + // + // fn foo(_: &()) {} + // static X: fn(&'static ()) = foo; + // + // The adjusted type of the body of X is `for<'a> fn(&'a ())` which + // is not the same as the type of X. We need the type of the return + // place to be the type of the constant because NLL typeck will + // equate them. + let typeck_results = tcx.typeck_opt_const_arg(def); + let const_ty = typeck_results.node_type(hir_id); - builder.build_drop_trees(); + tcx.infer_ctxt().enter(|infcx| { + let mut builder = Builder::new( + thir, + infcx, + def, + hir_id, + span, + 0, + Safety::Safe, + const_ty, + const_ty_span, + None, + ); + + let mut block = START_BLOCK; + unpack!(block = builder.expr_into_dest(Place::return_place(), block, &thir[expr])); - builder.finish() + let source_info = builder.source_info(span); + builder.cfg.terminate(block, source_info, TerminatorKind::Return); + + builder.build_drop_trees(); + + builder.finish() + }) } /// Construct MIR for an item that has had errors in type checking. /// /// This is required because we may still want to run MIR passes on an item /// with type errors, but normal MIR construction can't handle that in general. -fn construct_error<'a, 'tcx>( - infcx: &'a InferCtxt<'a, 'tcx>, - def: ty::WithOptConstParam, - hir_id: hir::HirId, - body_id: hir::BodyId, +fn construct_error<'tcx>( + tcx: TyCtxt<'tcx>, + def: LocalDefId, body_owner_kind: hir::BodyOwnerKind, err: ErrorGuaranteed, ) -> Body<'tcx> { - let tcx = infcx.tcx; - let span = tcx.hir().span(hir_id); + let span = tcx.def_span(def); + let hir_id = tcx.hir().local_def_id_to_hir_id(def); + let generator_kind = tcx.generator_kind(def); + let ty = tcx.ty_error(); - let generator_kind = tcx.hir().body(body_id).generator_kind; let num_params = match body_owner_kind { - hir::BodyOwnerKind::Fn => tcx.hir().fn_decl_by_hir_id(hir_id).unwrap().inputs.len(), + hir::BodyOwnerKind::Fn => tcx.fn_sig(def).inputs().skip_binder().len(), hir::BodyOwnerKind::Closure => { - if generator_kind.is_some() { - // Generators have an implicit `self` parameter *and* a possibly - // implicit resume parameter. - 2 - } else { - // The implicit self parameter adds another local in MIR. - 1 + tcx.hir().fn_decl_by_hir_id(hir_id).unwrap().inputs.len() + let ty = tcx.type_of(def); + match ty.kind() { + ty::Closure(_, substs) => { + 1 + substs.as_closure().sig().inputs().skip_binder().len() + } + ty::Generator(..) => 2, + _ => bug!("expected closure or generator, found {ty:?}"), } } hir::BodyOwnerKind::Const => 0, @@ -765,7 +734,7 @@ fn construct_error<'a, 'tcx>( cfg.terminate(START_BLOCK, source_info, TerminatorKind::Unreachable); let mut body = Body::new( - MirSource::item(def.did.to_def_id()), + MirSource::item(def.to_def_id()), cfg.basic_blocks, source_scopes, local_decls, @@ -783,7 +752,7 @@ fn construct_error<'a, 'tcx>( impl<'a, 'tcx> Builder<'a, 'tcx> { fn new( thir: &'a Thir<'tcx>, - infcx: &'a InferCtxt<'a, 'tcx>, + infcx: InferCtxt<'a, 'tcx>, def: ty::WithOptConstParam, hir_id: hir::HirId, span: Span, diff --git a/src/test/ui/impl-trait/auto-trait-leak.stderr b/src/test/ui/impl-trait/auto-trait-leak.stderr index 634ff14869eb4..b6e28364768ec 100644 --- a/src/test/ui/impl-trait/auto-trait-leak.stderr +++ b/src/test/ui/impl-trait/auto-trait-leak.stderr @@ -29,6 +29,11 @@ note: ...which requires building MIR for `cycle1`... | LL | fn cycle1() -> impl Clone { | ^^^^^^^^^^^^^^^^^^^^^^^^^ +note: ...which requires building THIR for `cycle1`... + --> $DIR/auto-trait-leak.rs:12:1 + | +LL | fn cycle1() -> impl Clone { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ note: ...which requires type-checking `cycle1`... --> $DIR/auto-trait-leak.rs:14:5 | @@ -65,6 +70,11 @@ note: ...which requires building MIR for `cycle2`... | LL | fn cycle2() -> impl Clone { | ^^^^^^^^^^^^^^^^^^^^^^^^^ +note: ...which requires building THIR for `cycle2`... + --> $DIR/auto-trait-leak.rs:19:1 + | +LL | fn cycle2() -> impl Clone { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ note: ...which requires type-checking `cycle2`... --> $DIR/auto-trait-leak.rs:20:5 | From 609a90dcb65396ca26e45b051dbe20d9c3b4a17b Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sat, 27 Aug 2022 12:21:02 +0200 Subject: [PATCH 15/25] Compute explicit MIR params on THIR. --- compiler/rustc_middle/src/thir.rs | 25 ++++++++ .../rustc_mir_build/src/build/matches/mod.rs | 4 +- compiler/rustc_mir_build/src/build/mod.rs | 62 ++++--------------- compiler/rustc_mir_build/src/thir/cx/mod.rs | 48 +++++++++++++- src/test/ui/thir-tree.stdout | 1 + 5 files changed, 87 insertions(+), 53 deletions(-) diff --git a/compiler/rustc_middle/src/thir.rs b/compiler/rustc_middle/src/thir.rs index 0f2504e3d9afe..fba940da27507 100644 --- a/compiler/rustc_middle/src/thir.rs +++ b/compiler/rustc_middle/src/thir.rs @@ -78,6 +78,22 @@ thir_with_elements! { blocks: BlockId => Block => "b{}", exprs: ExprId => Expr<'tcx> => "e{}", stmts: StmtId => Stmt<'tcx> => "s{}", + params: ParamId => Param<'tcx> => "p{}", +} + +/// Description of a type-checked function parameter. +#[derive(Clone, Debug, HashStable)] +pub struct Param<'tcx> { + /// The pattern that appears in the parameter list. + pub pat: Pat<'tcx>, + /// The possibly inferred type. + pub ty: Ty<'tcx>, + /// Span of the explicitly provided type, or None if inferred for closures. + pub ty_span: Option, + /// Whether this param is `self`, and how it is bound. + pub self_kind: Option, + /// HirId for lints. + pub hir_id: hir::HirId, } #[derive(Copy, Clone, Debug, HashStable)] @@ -548,6 +564,15 @@ impl<'tcx> Pat<'tcx> { pub fn wildcard_from_ty(ty: Ty<'tcx>) -> Self { Pat { ty, span: DUMMY_SP, kind: Box::new(PatKind::Wild) } } + + pub fn simple_ident(&self) -> Option { + match &*self.kind { + PatKind::Binding { name, mode: BindingMode::ByValue, subpattern: None, .. } => { + Some(*name) + } + _ => None, + } + } } #[derive(Clone, Debug, HashStable)] diff --git a/compiler/rustc_mir_build/src/build/matches/mod.rs b/compiler/rustc_mir_build/src/build/matches/mod.rs index 0e5cd6199ac9f..25890c648459b 100644 --- a/compiler/rustc_mir_build/src/build/matches/mod.rs +++ b/compiler/rustc_mir_build/src/build/matches/mod.rs @@ -573,7 +573,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { _ => { let place_builder = unpack!(block = self.as_place_builder(block, initializer)); - self.place_into_pattern(block, irrefutable_pat, place_builder, true) + self.place_into_pattern(block, &irrefutable_pat, place_builder, true) } } } @@ -581,7 +581,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { pub(crate) fn place_into_pattern( &mut self, block: BasicBlock, - irrefutable_pat: Pat<'tcx>, + irrefutable_pat: &Pat<'tcx>, initializer: PlaceBuilder<'tcx>, set_match_place: bool, ) -> BlockAnd<()> { diff --git a/compiler/rustc_mir_build/src/build/mod.rs b/compiler/rustc_mir_build/src/build/mod.rs index e9daafaa83af1..4aafd33c8a61a 100644 --- a/compiler/rustc_mir_build/src/build/mod.rs +++ b/compiler/rustc_mir_build/src/build/mod.rs @@ -1,14 +1,12 @@ pub(crate) use crate::build::expr::as_constant::lit_to_mir_constant; use crate::build::expr::as_place::PlaceBuilder; use crate::build::scope::DropKind; -use crate::thir::pattern::pat_from_hir; use rustc_apfloat::ieee::{Double, Single}; use rustc_apfloat::Float; use rustc_data_structures::fx::FxHashMap; use rustc_errors::ErrorGuaranteed; use rustc_hir as hir; use rustc_hir::def_id::{DefId, LocalDefId}; -use rustc_hir::lang_items::LangItem; use rustc_hir::{GeneratorKind, ImplicitSelfKind, Node}; use rustc_index::vec::{Idx, IndexVec}; use rustc_infer::infer::{InferCtxt, TyCtxtInferExt}; @@ -17,8 +15,7 @@ use rustc_middle::middle::region; use rustc_middle::mir::interpret::ConstValue; use rustc_middle::mir::interpret::Scalar; use rustc_middle::mir::*; -use rustc_middle::thir::{BindingMode, Expr, ExprId, LintLevel, LocalVarId, PatKind, Thir}; -use rustc_middle::ty::subst::Subst; +use rustc_middle::thir::{BindingMode, Expr, ExprId, LintLevel, LocalVarId, Param, PatKind, Thir}; use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitable, TypeckResults}; use rustc_span::symbol::sym; use rustc_span::Span; @@ -439,10 +436,10 @@ macro_rules! unpack { /////////////////////////////////////////////////////////////////////////// /// the main entry point for building MIR for a function -struct ArgInfo<'tcx>( +struct ArgInfo<'thir, 'tcx>( Ty<'tcx>, Option, - Option<&'tcx hir::Param<'tcx>>, + Option<&'thir Param<'tcx>>, Option, ); @@ -500,38 +497,8 @@ fn construct_fn<'tcx>( _ => vec![], }; - let explicit_arguments = body.params.iter().enumerate().map(|(index, arg)| { - let owner_id = tcx.hir().body_owner(body_id); - let opt_ty_info; - let self_arg; - if let Some(ref fn_decl) = tcx.hir().fn_decl_by_hir_id(owner_id) { - opt_ty_info = fn_decl - .inputs - .get(index) - // Make sure that inferred closure args have no type span - .and_then(|ty| if arg.pat.span != ty.span { Some(ty.span) } else { None }); - self_arg = if index == 0 && fn_decl.implicit_self.has_implicit_self() { - Some(fn_decl.implicit_self) - } else { - None - }; - } else { - opt_ty_info = None; - self_arg = None; - } - - // C-variadic fns also have a `VaList` input that's not listed in `fn_sig` - // (as it's created inside the body itself, not passed in from outside). - let ty = if fn_sig.c_variadic && index == fn_sig.inputs().len() { - let va_list_did = tcx.require_lang_item(LangItem::VaList, Some(arg.span)); - - tcx.bound_type_of(va_list_did).subst(tcx, &[tcx.lifetimes.re_erased.into()]) - } else { - fn_sig.inputs()[index] - }; - - ArgInfo(ty, opt_ty_info, Some(&arg), self_arg) - }); + let explicit_arguments = + thir.params.iter().map(|arg| ArgInfo(arg.ty, arg.ty_span, Some(&arg), arg.self_kind)); let arguments = implicit_argument.into_iter().chain(explicit_arguments); @@ -842,7 +809,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { &mut self, mut block: BasicBlock, fn_def_id: LocalDefId, - arguments: &[ArgInfo<'tcx>], + arguments: &[ArgInfo<'_, 'tcx>], argument_scope: region::Scope, expr: &Expr<'tcx>, ) -> BlockAnd<()> { @@ -853,9 +820,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let arg_local = self.local_decls.push(LocalDecl::with_source_info(ty, source_info)); // If this is a simple binding pattern, give debuginfo a nice name. - if let Some(arg) = arg_opt && let Some(ident) = arg.pat.simple_ident() { + if let Some(arg) = arg_opt && let Some(name) = arg.pat.simple_ident() { self.var_debug_info.push(VarDebugInfo { - name: ident.name, + name, source_info, value: VarDebugInfoContents::Place(arg_local.into()), }); @@ -943,15 +910,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let Some(arg) = arg_opt else { continue; }; - let pat = match tcx.hir().get(arg.pat.hir_id) { - Node::Pat(pat) => pat, - node => bug!("pattern became {:?}", node), - }; - let pattern = pat_from_hir(tcx, self.param_env, self.typeck_results, pat); let original_source_scope = self.source_scope; - let span = pattern.span; + let span = arg.pat.span; self.set_correct_source_scope_for_arg(arg.hir_id, original_source_scope, span); - match *pattern.kind { + match *arg.pat.kind { // Don't introduce extra copies for simple bindings PatKind::Binding { mutability, @@ -983,12 +945,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { scope = self.declare_bindings( scope, expr.span, - &pattern, + &arg.pat, matches::ArmHasGuard(false), Some((Some(&place), span)), ); let place_builder = PlaceBuilder::from(local); - unpack!(block = self.place_into_pattern(block, pattern, place_builder, false)); + unpack!(block = self.place_into_pattern(block, &arg.pat, place_builder, false)); } } self.source_scope = original_source_scope; diff --git a/compiler/rustc_mir_build/src/thir/cx/mod.rs b/compiler/rustc_mir_build/src/thir/cx/mod.rs index b84a84976c7d9..b65da94df8a0b 100644 --- a/compiler/rustc_mir_build/src/thir/cx/mod.rs +++ b/compiler/rustc_mir_build/src/thir/cx/mod.rs @@ -9,11 +9,12 @@ use rustc_data_structures::steal::Steal; use rustc_errors::ErrorGuaranteed; use rustc_hir as hir; use rustc_hir::def_id::{DefId, LocalDefId}; +use rustc_hir::lang_items::LangItem; use rustc_hir::HirId; use rustc_hir::Node; use rustc_middle::middle::region; use rustc_middle::thir::*; -use rustc_middle::ty::{self, RvalueScopes, TyCtxt}; +use rustc_middle::ty::{self, RvalueScopes, Subst, TyCtxt}; use rustc_span::Span; pub(crate) fn thir_body<'tcx>( @@ -27,6 +28,13 @@ pub(crate) fn thir_body<'tcx>( return Err(reported); } let expr = cx.mirror_expr(&body.value); + + let owner_id = hir.local_def_id_to_hir_id(owner_def.did); + if let Some(ref fn_decl) = hir.fn_decl_by_hir_id(owner_id) { + let explicit_params = cx.explicit_params(owner_id, fn_decl, body); + cx.thir.params = explicit_params.collect(); + } + Ok((tcx.alloc_steal_thir(cx.thir), expr)) } @@ -85,6 +93,44 @@ impl<'tcx> Cx<'tcx> { }; pat_from_hir(self.tcx, self.param_env, self.typeck_results(), p) } + + fn explicit_params<'a>( + &'a mut self, + owner_id: HirId, + fn_decl: &'tcx hir::FnDecl<'tcx>, + body: &'tcx hir::Body<'tcx>, + ) -> impl Iterator> + 'a { + let fn_sig = self.typeck_results.liberated_fn_sigs()[owner_id]; + + body.params.iter().enumerate().map(move |(index, param)| { + let ty_span = fn_decl + .inputs + .get(index) + // Make sure that inferred closure args have no type span + .and_then(|ty| if param.pat.span != ty.span { Some(ty.span) } else { None }); + + let self_kind = if index == 0 && fn_decl.implicit_self.has_implicit_self() { + Some(fn_decl.implicit_self) + } else { + None + }; + + // C-variadic fns also have a `VaList` input that's not listed in `fn_sig` + // (as it's created inside the body itself, not passed in from outside). + let ty = if fn_decl.c_variadic && index == fn_decl.inputs.len() { + let va_list_did = self.tcx.require_lang_item(LangItem::VaList, Some(param.span)); + + self.tcx + .bound_type_of(va_list_did) + .subst(self.tcx, &[self.tcx.lifetimes.re_erased.into()]) + } else { + fn_sig.inputs()[index] + }; + + let pat = self.pattern_from_hir(param.pat); + Param { pat, ty, ty_span, self_kind, hir_id: param.hir_id } + }) + } } impl<'tcx> UserAnnotatedTyHelpers<'tcx> for Cx<'tcx> { diff --git a/src/test/ui/thir-tree.stdout b/src/test/ui/thir-tree.stdout index 960b7f7f4ddea..5fcdfca18d69e 100644 --- a/src/test/ui/thir-tree.stdout +++ b/src/test/ui/thir-tree.stdout @@ -54,5 +54,6 @@ Thir { }, ], stmts: [], + params: [], } From 692064b00cdf449e60af23d5405544296107beff Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Mon, 22 Aug 2022 22:29:25 +0200 Subject: [PATCH 16/25] Also compute implicit params in THIR. --- compiler/rustc_middle/src/thir.rs | 8 +- compiler/rustc_mir_build/src/build/mod.rs | 114 ++++++-------------- compiler/rustc_mir_build/src/thir/cx/mod.rs | 60 ++++++++++- 3 files changed, 98 insertions(+), 84 deletions(-) diff --git a/compiler/rustc_middle/src/thir.rs b/compiler/rustc_middle/src/thir.rs index fba940da27507..ad491c1695345 100644 --- a/compiler/rustc_middle/src/thir.rs +++ b/compiler/rustc_middle/src/thir.rs @@ -73,6 +73,8 @@ macro_rules! thir_with_elements { } } +pub const UPVAR_ENV_PARAM: ParamId = ParamId::from_u32(0); + thir_with_elements! { arms: ArmId => Arm<'tcx> => "a{}", blocks: BlockId => Block => "b{}", @@ -84,8 +86,8 @@ thir_with_elements! { /// Description of a type-checked function parameter. #[derive(Clone, Debug, HashStable)] pub struct Param<'tcx> { - /// The pattern that appears in the parameter list. - pub pat: Pat<'tcx>, + /// The pattern that appears in the parameter list, or None for implicit parameters. + pub pat: Option>, /// The possibly inferred type. pub ty: Ty<'tcx>, /// Span of the explicitly provided type, or None if inferred for closures. @@ -93,7 +95,7 @@ pub struct Param<'tcx> { /// Whether this param is `self`, and how it is bound. pub self_kind: Option, /// HirId for lints. - pub hir_id: hir::HirId, + pub hir_id: Option, } #[derive(Copy, Clone, Debug, HashStable)] diff --git a/compiler/rustc_mir_build/src/build/mod.rs b/compiler/rustc_mir_build/src/build/mod.rs index 4aafd33c8a61a..17082e085a9bb 100644 --- a/compiler/rustc_mir_build/src/build/mod.rs +++ b/compiler/rustc_mir_build/src/build/mod.rs @@ -6,8 +6,9 @@ use rustc_apfloat::Float; use rustc_data_structures::fx::FxHashMap; use rustc_errors::ErrorGuaranteed; use rustc_hir as hir; +use rustc_hir::def::DefKind; use rustc_hir::def_id::{DefId, LocalDefId}; -use rustc_hir::{GeneratorKind, ImplicitSelfKind, Node}; +use rustc_hir::{GeneratorKind, Node}; use rustc_index::vec::{Idx, IndexVec}; use rustc_infer::infer::{InferCtxt, TyCtxtInferExt}; use rustc_middle::hir::place::PlaceBase as HirPlaceBase; @@ -15,7 +16,9 @@ use rustc_middle::middle::region; use rustc_middle::mir::interpret::ConstValue; use rustc_middle::mir::interpret::Scalar; use rustc_middle::mir::*; -use rustc_middle::thir::{BindingMode, Expr, ExprId, LintLevel, LocalVarId, Param, PatKind, Thir}; +use rustc_middle::thir::{ + self, BindingMode, Expr, ExprId, LintLevel, LocalVarId, Param, ParamId, PatKind, Thir, +}; use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitable, TypeckResults}; use rustc_span::symbol::sym; use rustc_span::Span; @@ -96,26 +99,6 @@ fn mir_build(tcx: TyCtxt<'_>, def: ty::WithOptConstParam) -> Body<'_ /////////////////////////////////////////////////////////////////////////// // BuildMir -- walks a crate, looking for fn items and methods to build MIR from -fn liberated_closure_env_ty( - tcx: TyCtxt<'_>, - closure_expr_id: hir::HirId, - body_id: hir::BodyId, -) -> Ty<'_> { - let closure_ty = tcx.typeck_body(body_id).node_type(closure_expr_id); - - let ty::Closure(closure_def_id, closure_substs) = *closure_ty.kind() else { - bug!("closure expr does not have closure type: {:?}", closure_ty); - }; - - let bound_vars = - tcx.mk_bound_variable_kinds(std::iter::once(ty::BoundVariableKind::Region(ty::BrEnv))); - let br = - ty::BoundRegion { var: ty::BoundVar::from_usize(bound_vars.len() - 1), kind: ty::BrEnv }; - let env_region = ty::ReLateBound(ty::INNERMOST, br); - let closure_env_ty = tcx.closure_env_ty(closure_def_id, closure_substs, env_region).unwrap(); - tcx.erase_late_bound_regions(ty::Binder::bind_with_vars(closure_env_ty, bound_vars)) -} - #[derive(Debug, PartialEq, Eq)] enum BlockFrame { /// Evaluation is currently within a statement. @@ -436,13 +419,6 @@ macro_rules! unpack { /////////////////////////////////////////////////////////////////////////// /// the main entry point for building MIR for a function -struct ArgInfo<'thir, 'tcx>( - Ty<'tcx>, - Option, - Option<&'thir Param<'tcx>>, - Option, -); - fn construct_fn<'tcx>( tcx: TyCtxt<'tcx>, fn_def: ty::WithOptConstParam, @@ -473,41 +449,21 @@ fn construct_fn<'tcx>( hir::Unsafety::Unsafe => Safety::FnUnsafe, }; - let body = tcx.hir().body(body_id); - let ty = tcx.type_of(fn_def.did); let mut abi = fn_sig.abi; - let implicit_argument = match ty.kind() { - ty::Closure(..) => { - // HACK(eddyb) Avoid having RustCall on closures, - // as it adds unnecessary (and wrong) auto-tupling. - abi = Abi::Rust; - vec![ArgInfo(liberated_closure_env_ty(tcx, fn_id, body_id), None, None, None)] - } - ty::Generator(..) => { - let gen_ty = typeck_results.node_type(fn_id); - - // The resume argument may be missing, in that case we need to provide it here. - // It will always be `()` in this case. - if body.params.is_empty() { - vec![ArgInfo(gen_ty, None, None, None), ArgInfo(tcx.mk_unit(), None, None, None)] - } else { - vec![ArgInfo(gen_ty, None, None, None)] - } - } - _ => vec![], - }; - - let explicit_arguments = - thir.params.iter().map(|arg| ArgInfo(arg.ty, arg.ty_span, Some(&arg), arg.self_kind)); + if let DefKind::Closure = tcx.def_kind(fn_def.did) { + // HACK(eddyb) Avoid having RustCall on closures, + // as it adds unnecessary (and wrong) auto-tupling. + abi = Abi::Rust; + } - let arguments = implicit_argument.into_iter().chain(explicit_arguments); + let arguments = &thir.params; let (yield_ty, return_ty) = if generator_kind.is_some() { - let gen_ty = typeck_results.node_type(fn_id); + let gen_ty = arguments[thir::UPVAR_ENV_PARAM].ty; let gen_sig = match gen_ty.kind() { ty::Generator(_, gen_substs, ..) => gen_substs.as_generator().sig(), _ => { - span_bug!(span, "generator w/o generator type: {:?}", ty) + span_bug!(span, "generator w/o generator type: {:?}", gen_ty) } }; (Some(gen_sig.yield_ty), gen_sig.return_ty) @@ -515,8 +471,6 @@ fn construct_fn<'tcx>( (None, fn_sig.output()) }; - let arguments: Vec<_> = arguments.collect(); - let mut body = tcx.infer_ctxt().enter(|infcx| { let mut builder = Builder::new( thir, @@ -532,9 +486,9 @@ fn construct_fn<'tcx>( ); let call_site_scope = - region::Scope { id: body.value.hir_id.local_id, data: region::ScopeData::CallSite }; + region::Scope { id: body_id.hir_id.local_id, data: region::ScopeData::CallSite }; let arg_scope = - region::Scope { id: body.value.hir_id.local_id, data: region::ScopeData::Arguments }; + region::Scope { id: body_id.hir_id.local_id, data: region::ScopeData::Arguments }; let source_info = builder.source_info(span); let call_site_s = (call_site_scope, source_info); unpack!(builder.in_scope(call_site_s, LintLevel::Inherited, |builder| { @@ -550,7 +504,7 @@ fn construct_fn<'tcx>( builder.args_and_body( START_BLOCK, fn_def.did, - &arguments, + arguments, arg_scope, &thir[expr], ) @@ -809,18 +763,19 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { &mut self, mut block: BasicBlock, fn_def_id: LocalDefId, - arguments: &[ArgInfo<'_, 'tcx>], + arguments: &IndexVec>, argument_scope: region::Scope, expr: &Expr<'tcx>, ) -> BlockAnd<()> { // Allocate locals for the function arguments - for &ArgInfo(ty, _, arg_opt, _) in arguments.iter() { + for param in arguments.iter() { let source_info = - SourceInfo::outermost(arg_opt.map_or(self.fn_span, |arg| arg.pat.span)); - let arg_local = self.local_decls.push(LocalDecl::with_source_info(ty, source_info)); + SourceInfo::outermost(param.pat.as_ref().map_or(self.fn_span, |pat| pat.span)); + let arg_local = + self.local_decls.push(LocalDecl::with_source_info(param.ty, source_info)); // If this is a simple binding pattern, give debuginfo a nice name. - if let Some(arg) = arg_opt && let Some(name) = arg.pat.simple_ident() { + if let Some(ref pat) = param.pat && let Some(name) = pat.simple_ident() { self.var_debug_info.push(VarDebugInfo { name, source_info, @@ -893,27 +848,28 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let mut scope = None; // Bind the argument patterns - for (index, arg_info) in arguments.iter().enumerate() { + for (index, param) in arguments.iter().enumerate() { // Function arguments always get the first Local indices after the return place let local = Local::new(index + 1); let place = Place::from(local); - let &ArgInfo(_, opt_ty_info, arg_opt, ref self_binding) = arg_info; // Make sure we drop (parts of) the argument even when not matched on. self.schedule_drop( - arg_opt.as_ref().map_or(expr.span, |arg| arg.pat.span), + param.pat.as_ref().map_or(expr.span, |pat| pat.span), argument_scope, local, DropKind::Value, ); - let Some(arg) = arg_opt else { + let Some(ref pat) = param.pat else { continue; }; let original_source_scope = self.source_scope; - let span = arg.pat.span; - self.set_correct_source_scope_for_arg(arg.hir_id, original_source_scope, span); - match *arg.pat.kind { + let span = pat.span; + if let Some(arg_hir_id) = param.hir_id { + self.set_correct_source_scope_for_arg(arg_hir_id, original_source_scope, span); + } + match *pat.kind { // Don't introduce extra copies for simple bindings PatKind::Binding { mutability, @@ -924,16 +880,16 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } => { self.local_decls[local].mutability = mutability; self.local_decls[local].source_info.scope = self.source_scope; - self.local_decls[local].local_info = if let Some(kind) = self_binding { + self.local_decls[local].local_info = if let Some(kind) = param.self_kind { Some(Box::new(LocalInfo::User(ClearCrossCrate::Set( - BindingForm::ImplicitSelf(*kind), + BindingForm::ImplicitSelf(kind), )))) } else { let binding_mode = ty::BindingMode::BindByValue(mutability); Some(Box::new(LocalInfo::User(ClearCrossCrate::Set(BindingForm::Var( VarBindingForm { binding_mode, - opt_ty_info, + opt_ty_info: param.ty_span, opt_match_place: Some((Some(place), span)), pat_span: span, }, @@ -945,12 +901,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { scope = self.declare_bindings( scope, expr.span, - &arg.pat, + &pat, matches::ArmHasGuard(false), Some((Some(&place), span)), ); let place_builder = PlaceBuilder::from(local); - unpack!(block = self.place_into_pattern(block, &arg.pat, place_builder, false)); + unpack!(block = self.place_into_pattern(block, &pat, place_builder, false)); } } self.source_scope = original_source_scope; diff --git a/compiler/rustc_mir_build/src/thir/cx/mod.rs b/compiler/rustc_mir_build/src/thir/cx/mod.rs index b65da94df8a0b..f48f2edf9d092 100644 --- a/compiler/rustc_mir_build/src/thir/cx/mod.rs +++ b/compiler/rustc_mir_build/src/thir/cx/mod.rs @@ -8,6 +8,7 @@ use crate::thir::util::UserAnnotatedTyHelpers; use rustc_data_structures::steal::Steal; use rustc_errors::ErrorGuaranteed; use rustc_hir as hir; +use rustc_hir::def::DefKind; use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_hir::lang_items::LangItem; use rustc_hir::HirId; @@ -31,8 +32,21 @@ pub(crate) fn thir_body<'tcx>( let owner_id = hir.local_def_id_to_hir_id(owner_def.did); if let Some(ref fn_decl) = hir.fn_decl_by_hir_id(owner_id) { + let closure_env_param = cx.closure_env_param(owner_def.did, owner_id); let explicit_params = cx.explicit_params(owner_id, fn_decl, body); - cx.thir.params = explicit_params.collect(); + cx.thir.params = closure_env_param.into_iter().chain(explicit_params).collect(); + + // The resume argument may be missing, in that case we need to provide it here. + // It will always be `()` in this case. + if tcx.def_kind(owner_def.did) == DefKind::Generator && body.params.is_empty() { + cx.thir.params.push(Param { + ty: tcx.mk_unit(), + pat: None, + ty_span: None, + self_kind: None, + hir_id: None, + }); + } } Ok((tcx.alloc_steal_thir(cx.thir), expr)) @@ -94,6 +108,48 @@ impl<'tcx> Cx<'tcx> { pat_from_hir(self.tcx, self.param_env, self.typeck_results(), p) } + fn closure_env_param(&self, owner_def: LocalDefId, owner_id: HirId) -> Option> { + match self.tcx.def_kind(owner_def) { + DefKind::Closure => { + let closure_ty = self.typeck_results.node_type(owner_id); + + let ty::Closure(closure_def_id, closure_substs) = *closure_ty.kind() else { + bug!("closure expr does not have closure type: {:?}", closure_ty); + }; + + let bound_vars = self.tcx.mk_bound_variable_kinds(std::iter::once( + ty::BoundVariableKind::Region(ty::BrEnv), + )); + let br = ty::BoundRegion { + var: ty::BoundVar::from_usize(bound_vars.len() - 1), + kind: ty::BrEnv, + }; + let env_region = ty::ReLateBound(ty::INNERMOST, br); + let closure_env_ty = + self.tcx.closure_env_ty(closure_def_id, closure_substs, env_region).unwrap(); + let liberated_closure_env_ty = self.tcx.erase_late_bound_regions( + ty::Binder::bind_with_vars(closure_env_ty, bound_vars), + ); + let env_param = Param { + ty: liberated_closure_env_ty, + pat: None, + ty_span: None, + self_kind: None, + hir_id: None, + }; + + Some(env_param) + } + DefKind::Generator => { + let gen_ty = self.typeck_results.node_type(owner_id); + let gen_param = + Param { ty: gen_ty, pat: None, ty_span: None, self_kind: None, hir_id: None }; + Some(gen_param) + } + _ => None, + } + } + fn explicit_params<'a>( &'a mut self, owner_id: HirId, @@ -128,7 +184,7 @@ impl<'tcx> Cx<'tcx> { }; let pat = self.pattern_from_hir(param.pat); - Param { pat, ty, ty_span, self_kind, hir_id: param.hir_id } + Param { pat: Some(pat), ty, ty_span, self_kind, hir_id: Some(param.hir_id) } }) } } From 8a594f0766cc31b303ae0ce73fefb34580d2840e Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Tue, 30 Aug 2022 00:10:40 +0200 Subject: [PATCH 17/25] Shrink some visibilities. --- compiler/rustc_mir_build/src/thir/cx/mod.rs | 10 ++++---- .../rustc_mir_build/src/thir/pattern/mod.rs | 24 +++++++++---------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/compiler/rustc_mir_build/src/thir/cx/mod.rs b/compiler/rustc_mir_build/src/thir/cx/mod.rs index f48f2edf9d092..38b75d2becf6b 100644 --- a/compiler/rustc_mir_build/src/thir/cx/mod.rs +++ b/compiler/rustc_mir_build/src/thir/cx/mod.rs @@ -66,11 +66,11 @@ struct Cx<'tcx> { tcx: TyCtxt<'tcx>, thir: Thir<'tcx>, - pub(crate) param_env: ty::ParamEnv<'tcx>, + param_env: ty::ParamEnv<'tcx>, - pub(crate) region_scope_tree: &'tcx region::ScopeTree, - pub(crate) typeck_results: &'tcx ty::TypeckResults<'tcx>, - pub(crate) rvalue_scopes: &'tcx RvalueScopes, + region_scope_tree: &'tcx region::ScopeTree, + typeck_results: &'tcx ty::TypeckResults<'tcx>, + rvalue_scopes: &'tcx RvalueScopes, /// When applying adjustments to the expression /// with the given `HirId`, use the given `Span`, @@ -100,7 +100,7 @@ impl<'tcx> Cx<'tcx> { } #[instrument(level = "debug", skip(self))] - pub(crate) fn pattern_from_hir(&mut self, p: &hir::Pat<'_>) -> Pat<'tcx> { + fn pattern_from_hir(&mut self, p: &hir::Pat<'_>) -> Pat<'tcx> { let p = match self.tcx.hir().get(p.hir_id) { Node::Pat(p) => p, node => bug!("pattern became {:?}", node), diff --git a/compiler/rustc_mir_build/src/thir/pattern/mod.rs b/compiler/rustc_mir_build/src/thir/pattern/mod.rs index a13748a2d474a..45f5e2235a909 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/mod.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/mod.rs @@ -29,22 +29,22 @@ use rustc_span::{Span, Symbol}; use std::cmp::Ordering; #[derive(Clone, Debug)] -pub(crate) enum PatternError { +enum PatternError { AssocConstInPattern(Span), ConstParamInPattern(Span), StaticInPattern(Span), NonConstPath(Span), } -pub(crate) struct PatCtxt<'a, 'tcx> { - pub(crate) tcx: TyCtxt<'tcx>, - pub(crate) param_env: ty::ParamEnv<'tcx>, - pub(crate) typeck_results: &'a ty::TypeckResults<'tcx>, - pub(crate) errors: Vec, +struct PatCtxt<'a, 'tcx> { + tcx: TyCtxt<'tcx>, + param_env: ty::ParamEnv<'tcx>, + typeck_results: &'a ty::TypeckResults<'tcx>, + errors: Vec, include_lint_checks: bool, } -pub(crate) fn pat_from_hir<'a, 'tcx>( +pub(super) fn pat_from_hir<'a, 'tcx>( tcx: TyCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>, typeck_results: &'a ty::TypeckResults<'tcx>, @@ -61,7 +61,7 @@ pub(crate) fn pat_from_hir<'a, 'tcx>( } impl<'a, 'tcx> PatCtxt<'a, 'tcx> { - pub(crate) fn new( + fn new( tcx: TyCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>, typeck_results: &'a ty::TypeckResults<'tcx>, @@ -69,12 +69,12 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> { PatCtxt { tcx, param_env, typeck_results, errors: vec![], include_lint_checks: false } } - pub(crate) fn include_lint_checks(&mut self) -> &mut Self { + fn include_lint_checks(&mut self) -> &mut Self { self.include_lint_checks = true; self } - pub(crate) fn lower_pattern(&mut self, pat: &'tcx hir::Pat<'tcx>) -> Pat<'tcx> { + fn lower_pattern(&mut self, pat: &'tcx hir::Pat<'tcx>) -> Pat<'tcx> { // When implicit dereferences have been inserted in this pattern, the unadjusted lowered // pattern has the type that results *after* dereferencing. For example, in this code: // @@ -615,7 +615,7 @@ impl<'tcx> UserAnnotatedTyHelpers<'tcx> for PatCtxt<'_, 'tcx> { } } -pub(crate) trait PatternFoldable<'tcx>: Sized { +trait PatternFoldable<'tcx>: Sized { fn fold_with>(&self, folder: &mut F) -> Self { self.super_fold_with(folder) } @@ -623,7 +623,7 @@ pub(crate) trait PatternFoldable<'tcx>: Sized { fn super_fold_with>(&self, folder: &mut F) -> Self; } -pub(crate) trait PatternFolder<'tcx>: Sized { +trait PatternFolder<'tcx>: Sized { fn fold_pattern(&mut self, pattern: &Pat<'tcx>) -> Pat<'tcx> { pattern.super_fold_with(self) } From d85dff73c089b5e51b730a1b3532403d59b4672d Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Tue, 30 Aug 2022 07:49:18 +0200 Subject: [PATCH 18/25] Bless codegen test. --- src/test/codegen/generator-debug.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/codegen/generator-debug.rs b/src/test/codegen/generator-debug.rs index 9c9f5518b6649..3ec860f2cbc06 100644 --- a/src/test/codegen/generator-debug.rs +++ b/src/test/codegen/generator-debug.rs @@ -33,11 +33,11 @@ fn generator_test() -> impl Generator { // CHECK-NOT: flags: DIFlagArtificial // CHECK-SAME: ) // CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "1", scope: [[VARIANT]], -// CHECK-SAME: file: [[FILE]], line: 14, +// CHECK-SAME: file: [[FILE]], line: 18, // CHECK-NOT: flags: DIFlagArtificial // CHECK-SAME: ) // CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "2", scope: [[VARIANT]], -// CHECK-SAME: file: [[FILE]], line: 14, +// CHECK-SAME: file: [[FILE]], line: 18, // CHECK-NOT: flags: DIFlagArtificial // CHECK-SAME: ) // CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "3", scope: [[VARIANT]], From b9e18065d19acf63b4589447569030d8a3a5b939 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Wed, 31 Aug 2022 20:17:32 +0200 Subject: [PATCH 19/25] Use def_span for external requirements. --- compiler/rustc_borrowck/src/nll.rs | 5 +- .../escape-argument-callee.stderr | 12 +--- .../escape-argument.stderr | 12 +--- .../escape-upvar-nested.stderr | 20 ++---- .../escape-upvar-ref.stderr | 12 +--- ...pagate-approximated-fail-no-postdom.stderr | 18 ++--- .../propagate-approximated-ref.stderr | 19 ++---- ...er-to-static-comparing-against-free.stderr | 35 +++------- ...oximated-shorter-to-static-no-bound.stderr | 20 ++---- ...mated-shorter-to-static-wrong-bound.stderr | 20 ++---- .../propagate-approximated-val.stderr | 19 ++---- .../propagate-despite-same-free-region.stderr | 18 ++--- ...ail-to-approximate-longer-no-bounds.stderr | 19 ++---- ...-to-approximate-longer-wrong-bounds.stderr | 19 ++---- .../propagate-from-trait-match.stderr | 17 +---- .../return-wrong-bound-region.stderr | 9 +-- .../projection-no-regions-closure.stderr | 30 +++------ .../projection-one-region-closure.stderr | 30 +++------ ...tion-one-region-trait-bound-closure.stderr | 37 +++-------- ...e-region-trait-bound-static-closure.stderr | 36 +++------- ...tion-two-region-trait-bound-closure.stderr | 59 +++++------------ ...ram-closure-approximate-lower-bound.stderr | 18 ++--- ...m-closure-outlives-from-return-type.stderr | 8 +-- ...-closure-outlives-from-where-clause.stderr | 66 ++++--------------- 24 files changed, 137 insertions(+), 421 deletions(-) diff --git a/compiler/rustc_borrowck/src/nll.rs b/compiler/rustc_borrowck/src/nll.rs index 0961203d76d7d..12b2481cc7907 100644 --- a/compiler/rustc_borrowck/src/nll.rs +++ b/compiler/rustc_borrowck/src/nll.rs @@ -389,8 +389,9 @@ pub(super) fn dump_annotation<'a, 'tcx>( // viewing the intraprocedural state, the -Zdump-mir output is // better. + let def_span = tcx.def_span(body.source.def_id()); let mut err = if let Some(closure_region_requirements) = closure_region_requirements { - let mut err = tcx.sess.diagnostic().span_note_diag(body.span, "external requirements"); + let mut err = tcx.sess.diagnostic().span_note_diag(def_span, "external requirements"); regioncx.annotate(tcx, &mut err); @@ -409,7 +410,7 @@ pub(super) fn dump_annotation<'a, 'tcx>( err } else { - let mut err = tcx.sess.diagnostic().span_note_diag(body.span, "no external requirements"); + let mut err = tcx.sess.diagnostic().span_note_diag(def_span, "no external requirements"); regioncx.annotate(tcx, &mut err); err diff --git a/src/test/ui/nll/closure-requirements/escape-argument-callee.stderr b/src/test/ui/nll/closure-requirements/escape-argument-callee.stderr index ff16bf0e078fc..59b848ea85ce1 100644 --- a/src/test/ui/nll/closure-requirements/escape-argument-callee.stderr +++ b/src/test/ui/nll/closure-requirements/escape-argument-callee.stderr @@ -2,7 +2,7 @@ note: no external requirements --> $DIR/escape-argument-callee.rs:26:38 | LL | let mut closure = expect_sig(|p, y| *p = y); - | ^^^^^^^^^^^^^ + | ^^^^^^ | = note: defining type: test::{closure#0} with closure substs [ i16, @@ -22,14 +22,8 @@ LL | let mut closure = expect_sig(|p, y| *p = y); note: no external requirements --> $DIR/escape-argument-callee.rs:20:1 | -LL | / fn test() { -LL | | let x = 44; -LL | | let mut p = &x; -LL | | -... | -LL | | deref(p); -LL | | } - | |_^ +LL | fn test() { + | ^^^^^^^^^ | = note: defining type: test diff --git a/src/test/ui/nll/closure-requirements/escape-argument.stderr b/src/test/ui/nll/closure-requirements/escape-argument.stderr index 49ec0dd931ac0..ff4e8e590e5a6 100644 --- a/src/test/ui/nll/closure-requirements/escape-argument.stderr +++ b/src/test/ui/nll/closure-requirements/escape-argument.stderr @@ -2,7 +2,7 @@ note: no external requirements --> $DIR/escape-argument.rs:26:38 | LL | let mut closure = expect_sig(|p, y| *p = y); - | ^^^^^^^^^^^^^ + | ^^^^^^ | = note: defining type: test::{closure#0} with closure substs [ i16, @@ -13,14 +13,8 @@ LL | let mut closure = expect_sig(|p, y| *p = y); note: no external requirements --> $DIR/escape-argument.rs:20:1 | -LL | / fn test() { -LL | | let x = 44; -LL | | let mut p = &x; -LL | | -... | -LL | | deref(p); -LL | | } - | |_^ +LL | fn test() { + | ^^^^^^^^^ | = note: defining type: test diff --git a/src/test/ui/nll/closure-requirements/escape-upvar-nested.stderr b/src/test/ui/nll/closure-requirements/escape-upvar-nested.stderr index f0ae4c7fb0492..4fbd5eb19a56c 100644 --- a/src/test/ui/nll/closure-requirements/escape-upvar-nested.stderr +++ b/src/test/ui/nll/closure-requirements/escape-upvar-nested.stderr @@ -2,7 +2,7 @@ note: external requirements --> $DIR/escape-upvar-nested.rs:21:32 | LL | let mut closure1 = || p = &y; - | ^^^^^^^^^ + | ^^ | = note: defining type: test::{closure#0}::{closure#0} with closure substs [ i16, @@ -15,12 +15,8 @@ LL | let mut closure1 = || p = &y; note: external requirements --> $DIR/escape-upvar-nested.rs:20:27 | -LL | let mut closure = || { - | ___________________________^ -LL | | let mut closure1 = || p = &y; -LL | | closure1(); -LL | | }; - | |_________^ +LL | let mut closure = || { + | ^^ | = note: defining type: test::{closure#0} with closure substs [ i16, @@ -33,14 +29,8 @@ LL | | }; note: no external requirements --> $DIR/escape-upvar-nested.rs:13:1 | -LL | / fn test() { -LL | | let x = 44; -LL | | let mut p = &x; -LL | | -... | -LL | | deref(p); -LL | | } - | |_^ +LL | fn test() { + | ^^^^^^^^^ | = note: defining type: test diff --git a/src/test/ui/nll/closure-requirements/escape-upvar-ref.stderr b/src/test/ui/nll/closure-requirements/escape-upvar-ref.stderr index e99fc4b43a23d..bc1ceac5bf01e 100644 --- a/src/test/ui/nll/closure-requirements/escape-upvar-ref.stderr +++ b/src/test/ui/nll/closure-requirements/escape-upvar-ref.stderr @@ -2,7 +2,7 @@ note: external requirements --> $DIR/escape-upvar-ref.rs:23:27 | LL | let mut closure = || p = &y; - | ^^^^^^^^^ + | ^^ | = note: defining type: test::{closure#0} with closure substs [ i16, @@ -15,14 +15,8 @@ LL | let mut closure = || p = &y; note: no external requirements --> $DIR/escape-upvar-ref.rs:17:1 | -LL | / fn test() { -LL | | let x = 44; -LL | | let mut p = &x; -LL | | -... | -LL | | deref(p); -LL | | } - | |_^ +LL | fn test() { + | ^^^^^^^^^ | = note: defining type: test diff --git a/src/test/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr b/src/test/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr index 11420efaa066e..0d94fca2823e5 100644 --- a/src/test/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr @@ -1,12 +1,8 @@ note: no external requirements --> $DIR/propagate-approximated-fail-no-postdom.rs:43:9 | -LL | / |_outlives1, _outlives2, _outlives3, x, y| { -LL | | // Only works if 'x: 'y: -LL | | let p = x.get(); -LL | | demand_y(x, y, p) -LL | | }, - | |_________^ +LL | |_outlives1, _outlives2, _outlives3, x, y| { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: supply::{closure#0} with closure substs [ i16, @@ -31,14 +27,8 @@ LL | demand_y(x, y, p) note: no external requirements --> $DIR/propagate-approximated-fail-no-postdom.rs:38:1 | -LL | / fn supply<'a, 'b, 'c>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>, cell_c: Cell<&'c u32>) { -LL | | establish_relationships( -LL | | cell_a, -LL | | cell_b, -... | -LL | | ); -LL | | } - | |_^ +LL | fn supply<'a, 'b, 'c>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>, cell_c: Cell<&'c u32>) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: supply diff --git a/src/test/ui/nll/closure-requirements/propagate-approximated-ref.stderr b/src/test/ui/nll/closure-requirements/propagate-approximated-ref.stderr index 98c3c28fb43ff..435a5353340da 100644 --- a/src/test/ui/nll/closure-requirements/propagate-approximated-ref.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-approximated-ref.stderr @@ -1,13 +1,8 @@ note: external requirements --> $DIR/propagate-approximated-ref.rs:43:47 | -LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| { - | _______________________________________________^ -LL | | // Only works if 'x: 'y: -LL | | demand_y(x, y, x.get()) -LL | | -LL | | }); - | |_____^ +LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: supply::{closure#0} with closure substs [ i16, @@ -22,14 +17,8 @@ LL | | }); note: no external requirements --> $DIR/propagate-approximated-ref.rs:42:1 | -LL | / fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { -LL | | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| { -LL | | // Only works if 'x: 'y: -LL | | demand_y(x, y, x.get()) -LL | | -LL | | }); -LL | | } - | |_^ +LL | fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: supply diff --git a/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr b/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr index 3ab55b370c231..6aafbe42c496c 100644 --- a/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr @@ -1,12 +1,8 @@ note: no external requirements --> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:21:15 | -LL | foo(cell, |cell_a, cell_x| { - | _______________^ -LL | | cell_a.set(cell_x.get()); // forces 'x: 'a, error in closure -LL | | -LL | | }) - | |_____^ +LL | foo(cell, |cell_a, cell_x| { + | ^^^^^^^^^^^^^^^^ | = note: defining type: case1::{closure#0} with closure substs [ i32, @@ -27,25 +23,16 @@ LL | cell_a.set(cell_x.get()); // forces 'x: 'a, error in closure note: no external requirements --> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:18:1 | -LL | / fn case1() { -LL | | let a = 0; -LL | | let cell = Cell::new(&a); -LL | | foo(cell, |cell_a, cell_x| { -... | -LL | | }) -LL | | } - | |_^ +LL | fn case1() { + | ^^^^^^^^^^ | = note: defining type: case1 note: external requirements --> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:35:15 | -LL | foo(cell, |cell_a, cell_x| { - | _______________^ -LL | | cell_x.set(cell_a.get()); // forces 'a: 'x, implies 'a = 'static -> borrow error -LL | | }) - | |_____^ +LL | foo(cell, |cell_a, cell_x| { + | ^^^^^^^^^^^^^^^^ | = note: defining type: case2::{closure#0} with closure substs [ i32, @@ -58,14 +45,8 @@ LL | | }) note: no external requirements --> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:28:1 | -LL | / fn case2() { -LL | | let a = 0; -LL | | let cell = Cell::new(&a); -LL | | -... | -LL | | }) -LL | | } - | |_^ +LL | fn case2() { + | ^^^^^^^^^^ | = note: defining type: case2 diff --git a/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr b/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr index ec2c220b6b8a0..ba6876ea58dc9 100644 --- a/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr @@ -1,14 +1,8 @@ note: external requirements --> $DIR/propagate-approximated-shorter-to-static-no-bound.rs:32:47 | -LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| { - | _______________________________________________^ -LL | | -LL | | -LL | | // Only works if 'x: 'y: -LL | | demand_y(x, y, x.get()) -LL | | }); - | |_____^ +LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| { + | ^^^^^^^^^^^^^^^^^ | = note: defining type: supply::{closure#0} with closure substs [ i16, @@ -23,14 +17,8 @@ LL | | }); note: no external requirements --> $DIR/propagate-approximated-shorter-to-static-no-bound.rs:31:1 | -LL | / fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { -LL | | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| { -LL | | -LL | | -... | -LL | | }); -LL | | } - | |_^ +LL | fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: supply diff --git a/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr b/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr index 234212c88767a..993f64ea4b7eb 100644 --- a/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr @@ -1,14 +1,8 @@ note: external requirements --> $DIR/propagate-approximated-shorter-to-static-wrong-bound.rs:35:47 | -LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| { - | _______________________________________________^ -LL | | -LL | | -LL | | // Only works if 'x: 'y: -LL | | demand_y(x, y, x.get()) -LL | | }); - | |_____^ +LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: supply::{closure#0} with closure substs [ i16, @@ -23,14 +17,8 @@ LL | | }); note: no external requirements --> $DIR/propagate-approximated-shorter-to-static-wrong-bound.rs:34:1 | -LL | / fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { -LL | | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| { -LL | | -LL | | -... | -LL | | }); -LL | | } - | |_^ +LL | fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: supply diff --git a/src/test/ui/nll/closure-requirements/propagate-approximated-val.stderr b/src/test/ui/nll/closure-requirements/propagate-approximated-val.stderr index 2ec9d4d8db1a6..be5f1e5ef1a68 100644 --- a/src/test/ui/nll/closure-requirements/propagate-approximated-val.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-approximated-val.stderr @@ -1,13 +1,8 @@ note: external requirements --> $DIR/propagate-approximated-val.rs:36:45 | -LL | establish_relationships(cell_a, cell_b, |outlives1, outlives2, x, y| { - | _____________________________________________^ -LL | | // Only works if 'x: 'y: -LL | | demand_y(outlives1, outlives2, x.get()) -LL | | -LL | | }); - | |_____^ +LL | establish_relationships(cell_a, cell_b, |outlives1, outlives2, x, y| { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: test::{closure#0} with closure substs [ i16, @@ -22,14 +17,8 @@ LL | | }); note: no external requirements --> $DIR/propagate-approximated-val.rs:35:1 | -LL | / fn test<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { -LL | | establish_relationships(cell_a, cell_b, |outlives1, outlives2, x, y| { -LL | | // Only works if 'x: 'y: -LL | | demand_y(outlives1, outlives2, x.get()) -LL | | -LL | | }); -LL | | } - | |_^ +LL | fn test<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: test diff --git a/src/test/ui/nll/closure-requirements/propagate-despite-same-free-region.stderr b/src/test/ui/nll/closure-requirements/propagate-despite-same-free-region.stderr index 21e4232c788fb..d18db97be5789 100644 --- a/src/test/ui/nll/closure-requirements/propagate-despite-same-free-region.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-despite-same-free-region.stderr @@ -1,12 +1,8 @@ note: external requirements --> $DIR/propagate-despite-same-free-region.rs:42:9 | -LL | / |_outlives1, _outlives2, x, y| { -LL | | // Only works if 'x: 'y: -LL | | let p = x.get(); -LL | | demand_y(x, y, p) -LL | | }, - | |_________^ +LL | |_outlives1, _outlives2, x, y| { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: supply::{closure#0} with closure substs [ i16, @@ -20,14 +16,8 @@ LL | | }, note: no external requirements --> $DIR/propagate-despite-same-free-region.rs:39:1 | -LL | / fn supply<'a>(cell_a: Cell<&'a u32>) { -LL | | establish_relationships( -LL | | cell_a, -LL | | |_outlives1, _outlives2, x, y| { -... | -LL | | ); -LL | | } - | |_^ +LL | fn supply<'a>(cell_a: Cell<&'a u32>) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: supply diff --git a/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr b/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr index 8b9b043542057..e6f88de4ee8d9 100644 --- a/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr @@ -1,13 +1,8 @@ note: no external requirements --> $DIR/propagate-fail-to-approximate-longer-no-bounds.rs:35:47 | -LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| { - | _______________________________________________^ -LL | | // Only works if 'x: 'y: -LL | | demand_y(x, y, x.get()) -LL | | -LL | | }); - | |_____^ +LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| { + | ^^^^^^^^^^^^^^^^^ | = note: defining type: supply::{closure#0} with closure substs [ i16, @@ -31,14 +26,8 @@ LL | demand_y(x, y, x.get()) note: no external requirements --> $DIR/propagate-fail-to-approximate-longer-no-bounds.rs:34:1 | -LL | / fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { -LL | | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| { -LL | | // Only works if 'x: 'y: -LL | | demand_y(x, y, x.get()) -LL | | -LL | | }); -LL | | } - | |_^ +LL | fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: supply diff --git a/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr b/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr index 060ce690f0306..5f5fce77137c1 100644 --- a/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr @@ -1,13 +1,8 @@ note: no external requirements --> $DIR/propagate-fail-to-approximate-longer-wrong-bounds.rs:39:47 | -LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| { - | _______________________________________________^ -LL | | // Only works if 'x: 'y: -LL | | demand_y(x, y, x.get()) -LL | | -LL | | }); - | |_____^ +LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: supply::{closure#0} with closure substs [ i16, @@ -31,14 +26,8 @@ LL | demand_y(x, y, x.get()) note: no external requirements --> $DIR/propagate-fail-to-approximate-longer-wrong-bounds.rs:38:1 | -LL | / fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { -LL | | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| { -LL | | // Only works if 'x: 'y: -LL | | demand_y(x, y, x.get()) -LL | | -LL | | }); -LL | | } - | |_^ +LL | fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: supply diff --git a/src/test/ui/nll/closure-requirements/propagate-from-trait-match.stderr b/src/test/ui/nll/closure-requirements/propagate-from-trait-match.stderr index 08605efa2ea9c..750b08bbe855c 100644 --- a/src/test/ui/nll/closure-requirements/propagate-from-trait-match.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-from-trait-match.stderr @@ -1,15 +1,8 @@ note: external requirements --> $DIR/propagate-from-trait-match.rs:32:36 | -LL | establish_relationships(value, |value| { - | ____________________________________^ -LL | | -LL | | -LL | | // This function call requires that -... | -LL | | require(value); -LL | | }); - | |_____^ +LL | establish_relationships(value, |value| { + | ^^^^^^^ | = note: defining type: supply::<'_#1r, T>::{closure#0} with closure substs [ i32, @@ -25,11 +18,7 @@ note: no external requirements LL | / fn supply<'a, T>(value: T) LL | | where LL | | T: Trait<'a>, -LL | | { -... | -LL | | }); -LL | | } - | |_^ + | |_________________^ | = note: defining type: supply::<'_#1r, T> diff --git a/src/test/ui/nll/closure-requirements/return-wrong-bound-region.stderr b/src/test/ui/nll/closure-requirements/return-wrong-bound-region.stderr index 5fc1d5c436181..da89071eabda9 100644 --- a/src/test/ui/nll/closure-requirements/return-wrong-bound-region.stderr +++ b/src/test/ui/nll/closure-requirements/return-wrong-bound-region.stderr @@ -2,7 +2,7 @@ note: no external requirements --> $DIR/return-wrong-bound-region.rs:11:16 | LL | expect_sig(|a, b| b); // ought to return `a` - | ^^^^^^^^ + | ^^^^^^ | = note: defining type: test::{closure#0} with closure substs [ i16, @@ -22,11 +22,8 @@ LL | expect_sig(|a, b| b); // ought to return `a` note: no external requirements --> $DIR/return-wrong-bound-region.rs:10:1 | -LL | / fn test() { -LL | | expect_sig(|a, b| b); // ought to return `a` -LL | | -LL | | } - | |_^ +LL | fn test() { + | ^^^^^^^^^ | = note: defining type: test diff --git a/src/test/ui/nll/ty-outlives/projection-no-regions-closure.stderr b/src/test/ui/nll/ty-outlives/projection-no-regions-closure.stderr index 8fe25181da1a0..ee1f7b64bb231 100644 --- a/src/test/ui/nll/ty-outlives/projection-no-regions-closure.stderr +++ b/src/test/ui/nll/ty-outlives/projection-no-regions-closure.stderr @@ -2,7 +2,7 @@ note: external requirements --> $DIR/projection-no-regions-closure.rs:25:23 | LL | with_signature(x, |mut y| Box::new(y.next())) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^ | = note: defining type: no_region::<'_#1r, T>::{closure#0} with closure substs [ i32, @@ -18,11 +18,7 @@ note: no external requirements LL | / fn no_region<'a, T>(x: Box) -> Box LL | | where LL | | T: Iterator, -LL | | { -LL | | with_signature(x, |mut y| Box::new(y.next())) -LL | | -LL | | } - | |_^ + | |________________^ | = note: defining type: no_region::<'_#1r, T> @@ -39,7 +35,7 @@ note: external requirements --> $DIR/projection-no-regions-closure.rs:34:23 | LL | with_signature(x, |mut y| Box::new(y.next())) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^ | = note: defining type: correct_region::<'_#1r, T>::{closure#0} with closure substs [ i32, @@ -55,10 +51,7 @@ note: no external requirements LL | / fn correct_region<'a, T>(x: Box) -> Box LL | | where LL | | T: 'a + Iterator, -LL | | { -LL | | with_signature(x, |mut y| Box::new(y.next())) -LL | | } - | |_^ + | |_____________________^ | = note: defining type: correct_region::<'_#1r, T> @@ -66,7 +59,7 @@ note: external requirements --> $DIR/projection-no-regions-closure.rs:42:23 | LL | with_signature(x, |mut y| Box::new(y.next())) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^ | = note: defining type: wrong_region::<'_#1r, '_#2r, T>::{closure#0} with closure substs [ i32, @@ -82,11 +75,7 @@ note: no external requirements LL | / fn wrong_region<'a, 'b, T>(x: Box) -> Box LL | | where LL | | T: 'b + Iterator, -LL | | { -LL | | with_signature(x, |mut y| Box::new(y.next())) -LL | | -LL | | } - | |_^ + | |_____________________^ | = note: defining type: wrong_region::<'_#1r, '_#2r, T> @@ -103,7 +92,7 @@ note: external requirements --> $DIR/projection-no-regions-closure.rs:52:23 | LL | with_signature(x, |mut y| Box::new(y.next())) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^ | = note: defining type: outlives_region::<'_#1r, '_#2r, T>::{closure#0} with closure substs [ i32, @@ -120,10 +109,7 @@ LL | / fn outlives_region<'a, 'b, T>(x: Box) -> Box LL | | where LL | | T: 'b + Iterator, LL | | 'b: 'a, -LL | | { -LL | | with_signature(x, |mut y| Box::new(y.next())) -LL | | } - | |_^ + | |___________^ | = note: defining type: outlives_region::<'_#1r, '_#2r, T> diff --git a/src/test/ui/nll/ty-outlives/projection-one-region-closure.stderr b/src/test/ui/nll/ty-outlives/projection-one-region-closure.stderr index caf2e3c474755..4e57dfad794e3 100644 --- a/src/test/ui/nll/ty-outlives/projection-one-region-closure.stderr +++ b/src/test/ui/nll/ty-outlives/projection-one-region-closure.stderr @@ -2,7 +2,7 @@ note: external requirements --> $DIR/projection-one-region-closure.rs:45:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^ | = note: defining type: no_relationships_late::<'_#1r, T>::{closure#0} with closure substs [ i32, @@ -20,11 +20,7 @@ note: no external requirements LL | / fn no_relationships_late<'a, 'b, T>(cell: Cell<&'a ()>, t: T) LL | | where LL | | T: Anything<'b>, -LL | | { -... | -LL | | -LL | | } - | |_^ + | |____________________^ | = note: defining type: no_relationships_late::<'_#1r, T> @@ -56,7 +52,7 @@ note: external requirements --> $DIR/projection-one-region-closure.rs:56:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^ | = note: defining type: no_relationships_early::<'_#1r, '_#2r, T>::{closure#0} with closure substs [ i32, @@ -74,10 +70,7 @@ LL | / fn no_relationships_early<'a, 'b, T>(cell: Cell<&'a ()>, t: T) LL | | where LL | | T: Anything<'b>, LL | | 'a: 'a, -... | -LL | | -LL | | } - | |_^ + | |___________^ | = note: defining type: no_relationships_early::<'_#1r, '_#2r, T> @@ -109,7 +102,7 @@ note: external requirements --> $DIR/projection-one-region-closure.rs:70:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^ | = note: defining type: projection_outlives::<'_#1r, '_#2r, T>::{closure#0} with closure substs [ i32, @@ -126,10 +119,7 @@ LL | / fn projection_outlives<'a, 'b, T>(cell: Cell<&'a ()>, t: T) LL | | where LL | | T: Anything<'b>, LL | | T::AssocType: 'a, -... | -LL | | with_signature(cell, t, |cell, t| require(cell, t)); -LL | | } - | |_^ + | |_____________________^ | = note: defining type: projection_outlives::<'_#1r, '_#2r, T> @@ -137,7 +127,7 @@ note: external requirements --> $DIR/projection-one-region-closure.rs:80:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^ | = note: defining type: elements_outlive::<'_#1r, '_#2r, T>::{closure#0} with closure substs [ i32, @@ -155,10 +145,8 @@ LL | / fn elements_outlive<'a, 'b, T>(cell: Cell<&'a ()>, t: T) LL | | where LL | | T: Anything<'b>, LL | | T: 'a, -... | -LL | | with_signature(cell, t, |cell, t| require(cell, t)); -LL | | } - | |_^ +LL | | 'b: 'a, + | |___________^ | = note: defining type: elements_outlive::<'_#1r, '_#2r, T> diff --git a/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.stderr b/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.stderr index 4eebe682d4fbc..250c796e2c71e 100644 --- a/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.stderr +++ b/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.stderr @@ -2,7 +2,7 @@ note: external requirements --> $DIR/projection-one-region-trait-bound-closure.rs:37:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^ | = note: defining type: no_relationships_late::<'_#1r, T>::{closure#0} with closure substs [ i32, @@ -19,11 +19,7 @@ note: no external requirements LL | / fn no_relationships_late<'a, 'b, T>(cell: Cell<&'a ()>, t: T) LL | | where LL | | T: Anything<'b>, -LL | | { -LL | | with_signature(cell, t, |cell, t| require(cell, t)); -LL | | -LL | | } - | |_^ + | |____________________^ | = note: defining type: no_relationships_late::<'_#1r, T> @@ -44,7 +40,7 @@ note: external requirements --> $DIR/projection-one-region-trait-bound-closure.rs:47:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^ | = note: defining type: no_relationships_early::<'_#1r, '_#2r, T>::{closure#0} with closure substs [ i32, @@ -61,10 +57,7 @@ LL | / fn no_relationships_early<'a, 'b, T>(cell: Cell<&'a ()>, t: T) LL | | where LL | | T: Anything<'b>, LL | | 'a: 'a, -... | -LL | | -LL | | } - | |_^ + | |___________^ | = note: defining type: no_relationships_early::<'_#1r, '_#2r, T> @@ -85,7 +78,7 @@ note: external requirements --> $DIR/projection-one-region-trait-bound-closure.rs:60:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^ | = note: defining type: projection_outlives::<'_#1r, '_#2r, T>::{closure#0} with closure substs [ i32, @@ -102,10 +95,7 @@ LL | / fn projection_outlives<'a, 'b, T>(cell: Cell<&'a ()>, t: T) LL | | where LL | | T: Anything<'b>, LL | | T::AssocType: 'a, -... | -LL | | with_signature(cell, t, |cell, t| require(cell, t)); -LL | | } - | |_^ + | |_____________________^ | = note: defining type: projection_outlives::<'_#1r, '_#2r, T> @@ -113,7 +103,7 @@ note: external requirements --> $DIR/projection-one-region-trait-bound-closure.rs:69:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^ | = note: defining type: elements_outlive::<'_#1r, '_#2r, T>::{closure#0} with closure substs [ i32, @@ -130,10 +120,7 @@ LL | / fn elements_outlive<'a, 'b, T>(cell: Cell<&'a ()>, t: T) LL | | where LL | | T: Anything<'b>, LL | | 'b: 'a, -LL | | { -LL | | with_signature(cell, t, |cell, t| require(cell, t)); -LL | | } - | |_^ + | |___________^ | = note: defining type: elements_outlive::<'_#1r, '_#2r, T> @@ -141,7 +128,7 @@ note: external requirements --> $DIR/projection-one-region-trait-bound-closure.rs:81:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^ | = note: defining type: one_region::<'_#1r, T>::{closure#0} with closure substs [ i32, @@ -157,11 +144,7 @@ note: no external requirements LL | / fn one_region<'a, T>(cell: Cell<&'a ()>, t: T) LL | | where LL | | T: Anything<'a>, -LL | | { -... | -LL | | with_signature(cell, t, |cell, t| require(cell, t)); -LL | | } - | |_^ + | |____________________^ | = note: defining type: one_region::<'_#1r, T> diff --git a/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-static-closure.stderr b/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-static-closure.stderr index 46a02598e19bc..b27186b053735 100644 --- a/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-static-closure.stderr +++ b/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-static-closure.stderr @@ -2,7 +2,7 @@ note: no external requirements --> $DIR/projection-one-region-trait-bound-static-closure.rs:36:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^ | = note: defining type: no_relationships_late::<'_#1r, T>::{closure#0} with closure substs [ i32, @@ -17,10 +17,7 @@ note: no external requirements LL | / fn no_relationships_late<'a, 'b, T>(cell: Cell<&'a ()>, t: T) LL | | where LL | | T: Anything<'b>, -LL | | { -LL | | with_signature(cell, t, |cell, t| require(cell, t)); -LL | | } - | |_^ + | |____________________^ | = note: defining type: no_relationships_late::<'_#1r, T> @@ -28,7 +25,7 @@ note: no external requirements --> $DIR/projection-one-region-trait-bound-static-closure.rs:45:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^ | = note: defining type: no_relationships_early::<'_#1r, '_#2r, T>::{closure#0} with closure substs [ i32, @@ -43,10 +40,7 @@ LL | / fn no_relationships_early<'a, 'b, T>(cell: Cell<&'a ()>, t: T) LL | | where LL | | T: Anything<'b>, LL | | 'a: 'a, -LL | | { -LL | | with_signature(cell, t, |cell, t| require(cell, t)); -LL | | } - | |_^ + | |___________^ | = note: defining type: no_relationships_early::<'_#1r, '_#2r, T> @@ -54,7 +48,7 @@ note: no external requirements --> $DIR/projection-one-region-trait-bound-static-closure.rs:64:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^ | = note: defining type: projection_outlives::<'_#1r, '_#2r, T>::{closure#0} with closure substs [ i32, @@ -69,10 +63,7 @@ LL | / fn projection_outlives<'a, 'b, T>(cell: Cell<&'a ()>, t: T) LL | | where LL | | T: Anything<'b>, LL | | T::AssocType: 'a, -... | -LL | | with_signature(cell, t, |cell, t| require(cell, t)); -LL | | } - | |_^ + | |_____________________^ | = note: defining type: projection_outlives::<'_#1r, '_#2r, T> @@ -80,7 +71,7 @@ note: no external requirements --> $DIR/projection-one-region-trait-bound-static-closure.rs:73:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^ | = note: defining type: elements_outlive::<'_#1r, '_#2r, T>::{closure#0} with closure substs [ i32, @@ -95,10 +86,7 @@ LL | / fn elements_outlive<'a, 'b, T>(cell: Cell<&'a ()>, t: T) LL | | where LL | | T: Anything<'b>, LL | | 'b: 'a, -LL | | { -LL | | with_signature(cell, t, |cell, t| require(cell, t)); -LL | | } - | |_^ + | |___________^ | = note: defining type: elements_outlive::<'_#1r, '_#2r, T> @@ -106,7 +94,7 @@ note: no external requirements --> $DIR/projection-one-region-trait-bound-static-closure.rs:85:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^ | = note: defining type: one_region::<'_#1r, T>::{closure#0} with closure substs [ i32, @@ -120,11 +108,7 @@ note: no external requirements LL | / fn one_region<'a, T>(cell: Cell<&'a ()>, t: T) LL | | where LL | | T: Anything<'a>, -LL | | { -... | -LL | | with_signature(cell, t, |cell, t| require(cell, t)); -LL | | } - | |_^ + | |____________________^ | = note: defining type: one_region::<'_#1r, T> diff --git a/src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr b/src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr index 1ee788b40ab9e..0195a693e5ffb 100644 --- a/src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr +++ b/src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr @@ -2,7 +2,7 @@ note: external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:38:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^ | = note: defining type: no_relationships_late::<'_#1r, '_#2r, T>::{closure#0} with closure substs [ i32, @@ -19,11 +19,7 @@ note: no external requirements LL | / fn no_relationships_late<'a, 'b, 'c, T>(cell: Cell<&'a ()>, t: T) LL | | where LL | | T: Anything<'b, 'c>, -LL | | { -LL | | with_signature(cell, t, |cell, t| require(cell, t)); -LL | | -LL | | } - | |_^ + | |________________________^ | = note: defining type: no_relationships_late::<'_#1r, '_#2r, T> @@ -40,7 +36,7 @@ note: external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:48:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^ | = note: defining type: no_relationships_early::<'_#1r, '_#2r, '_#3r, T>::{closure#0} with closure substs [ i32, @@ -57,10 +53,7 @@ LL | / fn no_relationships_early<'a, 'b, 'c, T>(cell: Cell<&'a ()>, t: T) LL | | where LL | | T: Anything<'b, 'c>, LL | | 'a: 'a, -... | -LL | | -LL | | } - | |_^ + | |___________^ | = note: defining type: no_relationships_early::<'_#1r, '_#2r, '_#3r, T> @@ -77,7 +70,7 @@ note: external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:61:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^ | = note: defining type: projection_outlives::<'_#1r, '_#2r, '_#3r, T>::{closure#0} with closure substs [ i32, @@ -94,10 +87,7 @@ LL | / fn projection_outlives<'a, 'b, 'c, T>(cell: Cell<&'a ()>, t: T) LL | | where LL | | T: Anything<'b, 'c>, LL | | T::AssocType: 'a, -... | -LL | | with_signature(cell, t, |cell, t| require(cell, t)); -LL | | } - | |_^ + | |_____________________^ | = note: defining type: projection_outlives::<'_#1r, '_#2r, '_#3r, T> @@ -105,7 +95,7 @@ note: external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:70:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^ | = note: defining type: elements_outlive1::<'_#1r, '_#2r, '_#3r, T>::{closure#0} with closure substs [ i32, @@ -122,10 +112,7 @@ LL | / fn elements_outlive1<'a, 'b, 'c, T>(cell: Cell<&'a ()>, t: T) LL | | where LL | | T: Anything<'b, 'c>, LL | | 'b: 'a, -LL | | { -LL | | with_signature(cell, t, |cell, t| require(cell, t)); -LL | | } - | |_^ + | |___________^ | = note: defining type: elements_outlive1::<'_#1r, '_#2r, '_#3r, T> @@ -133,7 +120,7 @@ note: external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:79:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^ | = note: defining type: elements_outlive2::<'_#1r, '_#2r, '_#3r, T>::{closure#0} with closure substs [ i32, @@ -150,10 +137,7 @@ LL | / fn elements_outlive2<'a, 'b, 'c, T>(cell: Cell<&'a ()>, t: T) LL | | where LL | | T: Anything<'b, 'c>, LL | | 'c: 'a, -LL | | { -LL | | with_signature(cell, t, |cell, t| require(cell, t)); -LL | | } - | |_^ + | |___________^ | = note: defining type: elements_outlive2::<'_#1r, '_#2r, '_#3r, T> @@ -161,7 +145,7 @@ note: external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:87:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^ | = note: defining type: two_regions::<'_#1r, T>::{closure#0} with closure substs [ i32, @@ -178,11 +162,7 @@ note: no external requirements LL | / fn two_regions<'a, 'b, T>(cell: Cell<&'a ()>, t: T) LL | | where LL | | T: Anything<'b, 'b>, -LL | | { -LL | | with_signature(cell, t, |cell, t| require(cell, t)); -LL | | -LL | | } - | |_^ + | |________________________^ | = note: defining type: two_regions::<'_#1r, T> @@ -203,7 +183,7 @@ note: external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:97:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^ | = note: defining type: two_regions_outlive::<'_#1r, '_#2r, T>::{closure#0} with closure substs [ i32, @@ -220,10 +200,7 @@ LL | / fn two_regions_outlive<'a, 'b, T>(cell: Cell<&'a ()>, t: T) LL | | where LL | | T: Anything<'b, 'b>, LL | | 'b: 'a, -LL | | { -LL | | with_signature(cell, t, |cell, t| require(cell, t)); -LL | | } - | |_^ + | |___________^ | = note: defining type: two_regions_outlive::<'_#1r, '_#2r, T> @@ -231,7 +208,7 @@ note: external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:109:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^ | = note: defining type: one_region::<'_#1r, T>::{closure#0} with closure substs [ i32, @@ -247,11 +224,7 @@ note: no external requirements LL | / fn one_region<'a, T>(cell: Cell<&'a ()>, t: T) LL | | where LL | | T: Anything<'a, 'a>, -LL | | { -... | -LL | | with_signature(cell, t, |cell, t| require(cell, t)); -LL | | } - | |_^ + | |________________________^ | = note: defining type: one_region::<'_#1r, T> diff --git a/src/test/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr b/src/test/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr index a4588730b3f87..5d9a044d107f9 100644 --- a/src/test/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr +++ b/src/test/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr @@ -2,7 +2,7 @@ note: external requirements --> $DIR/ty-param-closure-approximate-lower-bound.rs:24:24 | LL | twice(cell, value, |a, b| invoke(a, b)); - | ^^^^^^^^^^^^^^^^^^^ + | ^^^^^^ | = note: defining type: generic::::{closure#0} with closure substs [ i16, @@ -15,11 +15,8 @@ LL | twice(cell, value, |a, b| invoke(a, b)); note: no external requirements --> $DIR/ty-param-closure-approximate-lower-bound.rs:22:1 | -LL | / fn generic(value: T) { -LL | | let cell = Cell::new(&()); -LL | | twice(cell, value, |a, b| invoke(a, b)); -LL | | } - | |_^ +LL | fn generic(value: T) { + | ^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: generic:: @@ -27,7 +24,7 @@ note: external requirements --> $DIR/ty-param-closure-approximate-lower-bound.rs:29:24 | LL | twice(cell, value, |a, b| invoke(a, b)); - | ^^^^^^^^^^^^^^^^^^^ + | ^^^^^^ | = note: defining type: generic_fail::::{closure#0} with closure substs [ i16, @@ -41,11 +38,8 @@ LL | twice(cell, value, |a, b| invoke(a, b)); note: no external requirements --> $DIR/ty-param-closure-approximate-lower-bound.rs:28:1 | -LL | / fn generic_fail<'a, T>(cell: Cell<&'a ()>, value: T) { -LL | | twice(cell, value, |a, b| invoke(a, b)); -LL | | -LL | | } - | |_^ +LL | fn generic_fail<'a, T>(cell: Cell<&'a ()>, value: T) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: generic_fail:: diff --git a/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.stderr b/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.stderr index 084dd93cb86b9..50d9e3aabe2d4 100644 --- a/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.stderr +++ b/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.stderr @@ -2,7 +2,7 @@ note: external requirements --> $DIR/ty-param-closure-outlives-from-return-type.rs:26:23 | LL | with_signature(x, |y| y) - | ^^^^^ + | ^^^ | = note: defining type: no_region::<'_#1r, T>::{closure#0} with closure substs [ i32, @@ -18,11 +18,7 @@ note: no external requirements LL | / fn no_region<'a, T>(x: Box) -> Box LL | | where LL | | T: Debug, -LL | | { -... | -LL | | -LL | | } - | |_^ + | |_____________^ | = note: defining type: no_region::<'_#1r, T> diff --git a/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.stderr b/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.stderr index 11a737ba291f0..14c55e32a3ebe 100644 --- a/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.stderr +++ b/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.stderr @@ -1,15 +1,8 @@ note: external requirements --> $DIR/ty-param-closure-outlives-from-where-clause.rs:27:26 | -LL | with_signature(a, b, |x, y| { - | __________________________^ -LL | | -LL | | // -LL | | // See `correct_region`, which explains the point of this -... | -LL | | require(&x, &y) -LL | | }) - | |_____^ +LL | with_signature(a, b, |x, y| { + | ^^^^^^ | = note: defining type: no_region::::{closure#0} with closure substs [ i32, @@ -23,14 +16,8 @@ LL | | }) note: no external requirements --> $DIR/ty-param-closure-outlives-from-where-clause.rs:26:1 | -LL | / fn no_region<'a, T>(a: Cell<&'a ()>, b: T) { -LL | | with_signature(a, b, |x, y| { -LL | | -LL | | // -... | -LL | | }) -LL | | } - | |_^ +LL | fn no_region<'a, T>(a: Cell<&'a ()>, b: T) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: defining type: no_region:: @@ -55,15 +42,8 @@ LL | fn no_region<'a, T: 'a>(a: Cell<&'a ()>, b: T) { note: external requirements --> $DIR/ty-param-closure-outlives-from-where-clause.rs:43:26 | -LL | with_signature(a, b, |x, y| { - | __________________________^ -LL | | // Key point of this test: -LL | | // -LL | | // The *closure* is being type-checked with all of its free -... | -LL | | require(&x, &y) -LL | | }) - | |_____^ +LL | with_signature(a, b, |x, y| { + | ^^^^^^ | = note: defining type: correct_region::<'_#1r, T>::{closure#0} with closure substs [ i32, @@ -79,24 +59,15 @@ note: no external requirements LL | / fn correct_region<'a, T>(a: Cell<&'a ()>, b: T) LL | | where LL | | T: 'a, -LL | | { -... | -LL | | }) -LL | | } - | |_^ + | |__________^ | = note: defining type: correct_region::<'_#1r, T> note: external requirements --> $DIR/ty-param-closure-outlives-from-where-clause.rs:64:26 | -LL | with_signature(a, b, |x, y| { - | __________________________^ -LL | | -LL | | // See `correct_region` -LL | | require(&x, &y) -LL | | }) - | |_____^ +LL | with_signature(a, b, |x, y| { + | ^^^^^^ | = note: defining type: wrong_region::<'_#1r, T>::{closure#0} with closure substs [ i32, @@ -113,11 +84,7 @@ note: no external requirements LL | / fn wrong_region<'a, 'b, T>(a: Cell<&'a ()>, b: T) LL | | where LL | | T: 'b, -LL | | { -... | -LL | | }) -LL | | } - | |_^ + | |__________^ | = note: defining type: wrong_region::<'_#1r, T> @@ -140,12 +107,8 @@ LL | T: 'b + 'a, note: external requirements --> $DIR/ty-param-closure-outlives-from-where-clause.rs:77:26 | -LL | with_signature(a, b, |x, y| { - | __________________________^ -LL | | // See `correct_region` -LL | | require(&x, &y) -LL | | }) - | |_____^ +LL | with_signature(a, b, |x, y| { + | ^^^^^^ | = note: defining type: outlives_region::<'_#1r, '_#2r, T>::{closure#0} with closure substs [ i32, @@ -162,10 +125,7 @@ LL | / fn outlives_region<'a, 'b, T>(a: Cell<&'a ()>, b: T) LL | | where LL | | T: 'b, LL | | 'b: 'a, -... | -LL | | }) -LL | | } - | |_^ + | |___________^ | = note: defining type: outlives_region::<'_#1r, '_#2r, T> From bc793c9fb2ae45b1e93cdd6ad1cd4ffe30587674 Mon Sep 17 00:00:00 2001 From: Chris Denton Date: Fri, 2 Sep 2022 13:23:52 +0100 Subject: [PATCH 20/25] Use `BCRYPT_RNG_ALG_HANDLE` by default Also briefly document the history of `sys/windows/rand.rs` as they may be relevant to any future changes. --- library/std/src/sys/windows/c.rs | 2 +- library/std/src/sys/windows/rand.rs | 41 ++++++++++++++++++++++++++--- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/library/std/src/sys/windows/c.rs b/library/std/src/sys/windows/c.rs index c99c8efe4367f..270294d13df36 100644 --- a/library/std/src/sys/windows/c.rs +++ b/library/std/src/sys/windows/c.rs @@ -285,7 +285,7 @@ pub fn nt_success(status: NTSTATUS) -> bool { status >= 0 } -pub const BCRYPT_USE_SYSTEM_PREFERRED_RNG: DWORD = 0x00000002; +pub const BCRYPT_RNG_ALG_HANDLE: usize = 0x81; #[repr(C)] pub struct UNICODE_STRING { diff --git a/library/std/src/sys/windows/rand.rs b/library/std/src/sys/windows/rand.rs index f8fd93a7398e1..8b9697884364c 100644 --- a/library/std/src/sys/windows/rand.rs +++ b/library/std/src/sys/windows/rand.rs @@ -1,16 +1,49 @@ +//! # Random key generation +//! +//! This module wraps the RNG provided by the OS. There are a few different +//! ways to interface with the OS RNG so it's worth exploring each of the options. +//! Note that at the time of writing these all go through the (undocumented) +//! `bcryptPrimitives.dll` but they use different route to get there. +//! +//! Originally we were using [`RtlGenRandom`], however that function is +//! deprecated and warns it "may be altered or unavailable in subsequent versions". +//! +//! So we switched to [`BCryptGenRandom`] with the `BCRYPT_USE_SYSTEM_PREFERRED_RNG` +//! flag to query and find the system configured RNG. However, this change caused a small +//! but significant number of users to experience panics caused by a failure of +//! this function. See [#94098]. +//! +//! The current version changes this to use the `BCRYPT_RNG_ALG_HANDLE` +//! [Pseudo-handle], which gets the default RNG algorithm without querying the +//! system preference thus hopefully avoiding the previous issue. +//! This is only supported on Windows 10+ so a fallback is used for older versions. +//! +//! [#94098]: https://github.com/rust-lang/rust/issues/94098 +//! [`RtlGenRandom`]: https://docs.microsoft.com/en-us/windows/win32/api/ntsecapi/nf-ntsecapi-rtlgenrandom +//! [`BCryptGenRandom`]: https://docs.microsoft.com/en-us/windows/win32/api/bcrypt/nf-bcrypt-bcryptgenrandom +//! [Pseudo-handle]: https://docs.microsoft.com/en-us/windows/win32/seccng/cng-algorithm-pseudo-handles use crate::io; use crate::mem; use crate::ptr; use crate::sys::c; +/// Generates high quality secure random keys for use by [`HashMap`]. +/// +/// This is used to seed the default [`RandomState`]. +/// +/// [`HashMap`]: crate::collections::HashMap +/// [`RandomState`]: crate::collections::hash_map::RandomState pub fn hashmap_random_keys() -> (u64, u64) { let mut v = (0, 0); let ret = unsafe { + let size = mem::size_of_val(&v).try_into().unwrap(); c::BCryptGenRandom( - ptr::null_mut(), - &mut v as *mut _ as *mut u8, - mem::size_of_val(&v) as c::ULONG, - c::BCRYPT_USE_SYSTEM_PREFERRED_RNG, + // BCRYPT_RNG_ALG_HANDLE is only supported in Windows 10+. + // So for Windows 8.1 and Windows 7 we'll need a fallback when this fails. + ptr::invalid_mut(c::BCRYPT_RNG_ALG_HANDLE), + ptr::addr_of_mut!(v).cast(), + size, + 0, ) }; if ret != 0 { fallback_rng() } else { v } From 532d5f2320758e37bb6e9f851c5bc507933733c9 Mon Sep 17 00:00:00 2001 From: Wojciech Kordalski Date: Fri, 2 Sep 2022 16:35:40 +0200 Subject: [PATCH 21/25] Fix `std::collections::HashSet::drain` documentation --- library/std/src/collections/hash/set.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/src/collections/hash/set.rs b/library/std/src/collections/hash/set.rs index abff82788a38d..5b6a415fadc1e 100644 --- a/library/std/src/collections/hash/set.rs +++ b/library/std/src/collections/hash/set.rs @@ -239,7 +239,7 @@ impl HashSet { /// /// If the returned iterator is dropped before being fully consumed, it /// drops the remaining elements. The returned iterator keeps a mutable - /// borrow on the vector to optimize its implementation. + /// borrow on the set to optimize its implementation. /// /// # Examples /// From 6fbc4d91653c4b59ec40816166a7b908b43c57ce Mon Sep 17 00:00:00 2001 From: Matt Hamrick Date: Fri, 2 Sep 2022 11:14:22 -0700 Subject: [PATCH 22/25] Fix unsupported syntax in .manifest file Fuchsia .manifest files do not support a `#` comment syntax. Because of this, if you copy and paste the current example code for this file, and then remove the line you don't need, you still see an error. To make this a bit easier to follow, split this into two code blocks, one for rustc, and one for cargo. --- src/doc/rustc/src/platform-support/fuchsia.md | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/doc/rustc/src/platform-support/fuchsia.md b/src/doc/rustc/src/platform-support/fuchsia.md index 53a510f080ece..5a815635f4be2 100644 --- a/src/doc/rustc/src/platform-support/fuchsia.md +++ b/src/doc/rustc/src/platform-support/fuchsia.md @@ -330,10 +330,18 @@ Now, create the following files inside: The `package` file describes our package's name and version number. Every package must contain one. -**`pkg/hello_fuchsia.manifest`** +**`pkg/hello_fuchsia.manifest` if using cargo** ```txt -bin/hello_fuchsia=target/x86_64-fuchsia/debug/hello_fuchsia # If using cargo... -bin/hello_fuchsia=bin/hello_fuchsia # If using rustc... +bin/hello_fuchsia=target/x86_64-fuchsia/debug/hello_fuchsia +lib/ld.so.1=/arch/x64/sysroot/dist/lib/ld.so.1 +lib/libfdio.so=/arch/x64/dist/libfdio.so +meta/package=pkg/meta/package +meta/hello_fuchsia.cm=pkg/meta/hello_fuchsia.cm +``` + +**`pkg/hello_fuchsia.manifest` if using rustc** +```txt +bin/hello_fuchsia=bin/hello_fuchsia lib/ld.so.1=/arch/x64/sysroot/dist/lib/ld.so.1 lib/libfdio.so=/arch/x64/dist/libfdio.so meta/package=pkg/meta/package From df0904750dc7ef332930f77610e12ab03b28e9fd Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Fri, 2 Sep 2022 10:54:40 -0700 Subject: [PATCH 23/25] rustdoc: remove unused CSS selector `.methods > .item-info` It was added with e08a84a0c18739417a50c3e46917ced5037244eb (actually, it was called `.methods > .stability` at the time) and was directly nested that way. But with the switch to `
`, the code has changed drastically out from under it, to the point where you have to go out of your way to actually get it to render this way, and the result looks overly-tight and weird alongside the normal version where this code is not reachable. --- src/librustdoc/html/static/css/rustdoc.css | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index c7a9f247e2084..c4a1728151d10 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -782,10 +782,6 @@ pre, .rustdoc.source .example-wrap { margin-left: 40px; } -.methods > .item-info, .content .impl-items > .item-info { - margin-top: -8px; -} - .impl-items { flex-basis: 100%; } From 6f95c89c4d65a5579295e6490c4fa70e08424fcb Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Fri, 2 Sep 2022 11:50:19 -0700 Subject: [PATCH 24/25] rustdoc: remove incorrect CSS rule causing misaligned item-info --- src/librustdoc/html/static/css/rustdoc.css | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index c4a1728151d10..90c86750425f6 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -778,10 +778,6 @@ pre, .rustdoc.source .example-wrap { margin-bottom: .6em; } -.content .impl-items > .item-info { - margin-left: 40px; -} - .impl-items { flex-basis: 100%; } From 0f29824760eefd74aba742fc2c287c2d3901bd63 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Fri, 2 Sep 2022 12:15:06 -0700 Subject: [PATCH 25/25] rustdoc: put in rule to get alignment in desktop and mobile layouts --- src/librustdoc/html/static/css/rustdoc.css | 5 +++++ src/test/rustdoc-gui/item-info-alignment.goml | 10 ++++++++++ src/test/rustdoc-gui/src/lib2/lib.rs | 10 ++++++++++ 3 files changed, 25 insertions(+) create mode 100644 src/test/rustdoc-gui/item-info-alignment.goml diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index 90c86750425f6..147d2260964f2 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -2007,6 +2007,11 @@ in storage.js plus the media query with (min-width: 701px) #main-content > div > details.rustdoc-toggle > summary::before { left: -11px; } + + /* Align summary-nested and unnested item-info gizmos. */ + .content .impl-items > .item-info { + margin-left: 34px; + } } @media print { diff --git a/src/test/rustdoc-gui/item-info-alignment.goml b/src/test/rustdoc-gui/item-info-alignment.goml new file mode 100644 index 0000000000000..4d7b5045f7c15 --- /dev/null +++ b/src/test/rustdoc-gui/item-info-alignment.goml @@ -0,0 +1,10 @@ +// This test ensures that the "item-info" looks about the same +// whether or not it's inside a toggle. +goto: file://|DOC_PATH|/lib2/struct.ItemInfoAlignmentTest.html + +// First, we try it in "desktop" mode. +size: (1200, 870) +compare-elements-position: (".impl-items > .item-info", "summary > .item-info", ("x")) +// Next, we try it in "mobile" mode (max-width: 700px). +size: (650, 650) +compare-elements-position: (".impl-items > .item-info", "summary > .item-info", ("x")) diff --git a/src/test/rustdoc-gui/src/lib2/lib.rs b/src/test/rustdoc-gui/src/lib2/lib.rs index 7f3172878bfb5..5a151ed7b687a 100644 --- a/src/test/rustdoc-gui/src/lib2/lib.rs +++ b/src/test/rustdoc-gui/src/lib2/lib.rs @@ -170,3 +170,13 @@ where type Output; fn index(&self, index: Idx) -> &Self::Output; } + +pub struct ItemInfoAlignmentTest; + +impl ItemInfoAlignmentTest { + /// This method has docs + #[deprecated] + pub fn foo() {} + #[deprecated] + pub fn bar() {} +}