From 1767f9f9bfd63676cee998ea086968ab5f047866 Mon Sep 17 00:00:00 2001 From: Sarthak Singh Date: Mon, 21 Nov 2022 20:15:07 +0530 Subject: [PATCH 1/9] Unsupported query error now specifies if its unsupported for local or external crate --- compiler/rustc_middle/src/ty/query.rs | 7 +++++-- compiler/rustc_query_impl/src/lib.rs | 3 +-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_middle/src/ty/query.rs b/compiler/rustc_middle/src/ty/query.rs index 0f62da9992f31..afbc9eb0512be 100644 --- a/compiler/rustc_middle/src/ty/query.rs +++ b/compiler/rustc_middle/src/ty/query.rs @@ -276,13 +276,16 @@ macro_rules! define_callbacks { impl Default for Providers { fn default() -> Self { + use crate::query::Key; + Providers { $($name: |_, key| bug!( - "`tcx.{}({:?})` is not supported for external or local crate;\n - hint: Queries can be either made to the local crate, or the external crate. This error means you tried to use it for one that's not supported (likely the local crate).\n + "`tcx.{}({:?})` is not supported for {} crate;\n + hint: Queries can be either made to the local crate, or the external crate. This error means you tried to use it for one that's not supported.\n If that's not the case, {} was likely never assigned to a provider function.\n", stringify!($name), key, + if key.query_crate_is_local() { "local" } else { "external" }, stringify!($name), ),)* } diff --git a/compiler/rustc_query_impl/src/lib.rs b/compiler/rustc_query_impl/src/lib.rs index e6df6956158bf..d426a2b6b78a0 100644 --- a/compiler/rustc_query_impl/src/lib.rs +++ b/compiler/rustc_query_impl/src/lib.rs @@ -20,6 +20,7 @@ extern crate rustc_middle; use rustc_data_structures::sync::AtomicU64; use rustc_middle::arena::Arena; use rustc_middle::dep_graph::{self, DepKindStruct}; +use rustc_middle::query::Key; use rustc_middle::ty::query::{query_keys, query_storage, query_stored, query_values}; use rustc_middle::ty::query::{ExternProviders, Providers, QueryEngine}; use rustc_middle::ty::TyCtxt; @@ -32,8 +33,6 @@ use rustc_query_system::query::*; #[cfg(parallel_compiler)] pub use rustc_query_system::query::{deadlock, QueryContext}; -use rustc_middle::query::Key; - pub use rustc_query_system::query::QueryConfig; pub(crate) use rustc_query_system::query::QueryVTable; From 480f850868e581cf51dab1ab8bce67f371c4db64 Mon Sep 17 00:00:00 2001 From: Fabian Hintringer Date: Thu, 24 Nov 2022 19:24:37 +0100 Subject: [PATCH 2/9] improve array_from_fn documenation --- library/core/src/array/mod.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/library/core/src/array/mod.rs b/library/core/src/array/mod.rs index 2090756d7a3ec..773fd0b4a1847 100644 --- a/library/core/src/array/mod.rs +++ b/library/core/src/array/mod.rs @@ -23,7 +23,8 @@ mod iter; #[stable(feature = "array_value_iter", since = "1.51.0")] pub use iter::IntoIter; -/// Creates an array `[T; N]` where each array element `T` is returned by the `cb` call. +/// Creates an array of type [T; N], where each element `T` is the returned value from `cb` +/// using that element's index. /// /// # Arguments /// @@ -36,8 +37,18 @@ pub use iter::IntoIter; /// // elements to produce is the length of array down there: only arrays of /// // equal lengths can be compared, so the const generic parameter `N` is /// // inferred to be 5, thus creating array of 5 elements. -/// let array = core::array::from_fn(|i| i); +/// +/// let array: [_; 5] = core::array::from_fn(|i| i); +/// // indexes are: 0 1 2 3 4 /// assert_eq!(array, [0, 1, 2, 3, 4]); +/// +/// let array2: [_; 8] = core::array::from_fn(|i| i * 2); +/// // indexes are: 0 1 2 3 4 5 6 7 +/// assert_eq!(array2, [0, 2, 4, 6, 8, 10, 12, 14]); +/// +/// let bool_arr: [bool; 5] = core::array::from_fn(|i| i % 2 == 0); +/// // indexes are: 0 1 2 3 4 +/// assert_eq!(bool_arr, [true, false, true, false, true]); /// ``` #[inline] #[stable(feature = "array_from_fn", since = "1.63.0")] From 69d562d68493453c696ba6d2c10342df13d5fd95 Mon Sep 17 00:00:00 2001 From: Fabian Hintringer Date: Fri, 25 Nov 2022 10:05:07 +0100 Subject: [PATCH 3/9] change example of array_from_fn to match suggestion --- library/core/src/array/mod.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/core/src/array/mod.rs b/library/core/src/array/mod.rs index 773fd0b4a1847..94a1a1d32bcd6 100644 --- a/library/core/src/array/mod.rs +++ b/library/core/src/array/mod.rs @@ -38,15 +38,15 @@ pub use iter::IntoIter; /// // equal lengths can be compared, so the const generic parameter `N` is /// // inferred to be 5, thus creating array of 5 elements. /// -/// let array: [_; 5] = core::array::from_fn(|i| i); +/// let array = core::array::from_fn(|i| i); /// // indexes are: 0 1 2 3 4 /// assert_eq!(array, [0, 1, 2, 3, 4]); /// -/// let array2: [_; 8] = core::array::from_fn(|i| i * 2); +/// let array2: [usize; 8] = core::array::from_fn(|i| i * 2); /// // indexes are: 0 1 2 3 4 5 6 7 /// assert_eq!(array2, [0, 2, 4, 6, 8, 10, 12, 14]); /// -/// let bool_arr: [bool; 5] = core::array::from_fn(|i| i % 2 == 0); +/// let bool_arr = core::array::from_fn::<_, 5, _>(|i| i % 2 == 0); /// // indexes are: 0 1 2 3 4 /// assert_eq!(bool_arr, [true, false, true, false, true]); /// ``` From e5ccd27e679d44e9251bc7f5a879f14c23eb8c25 Mon Sep 17 00:00:00 2001 From: Krasimir Georgiev Date: Fri, 25 Nov 2022 11:29:00 +0000 Subject: [PATCH 4/9] [llvm-wrapper] adapt for LLVM API change Adapt for the LLVM API changes from https://github.com/llvm/llvm-project/commit/721f975d3518403502f770ce11f3f02509b30c5b#diff-5a347903b8412ed1b1b1948c3fce47f9a6ff05dc70bfaeedb6d06b622e399d91. --- compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp index 5f02bb6c3070f..7f4d63eed8bdf 100644 --- a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp @@ -627,7 +627,11 @@ LLVMRustOptimize( bool DebugPassManager = false; PassInstrumentationCallbacks PIC; +#if LLVM_VERSION_LT(16, 0) StandardInstrumentations SI(DebugPassManager); +#else + StandardInstrumentations SI(TheModule->getContext(), DebugPassManager); +#endif SI.registerCallbacks(PIC); if (LlvmSelfProfiler){ From 20cb41f4668830527d9d5b81290b0d25f94526b5 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Fri, 25 Nov 2022 10:07:21 -0700 Subject: [PATCH 5/9] rustdoc: remove no-op CSS `#help dt { display: block }` `display: block` is the [default UA style] for dt. [default UA style]: https://html.spec.whatwg.org/multipage/rendering.html#lists --- src/librustdoc/html/static/css/rustdoc.css | 1 - 1 file changed, 1 deletion(-) diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index c1f7a8338342d..d87635f1e9a33 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -949,7 +949,6 @@ so that we can apply CSS-filters to change the arrow color in themes */ #help dt { float: left; clear: left; - display: block; margin-right: 0.5rem; } #help span.top, #help span.bottom { From aaa1db63ce2b92240272a1db303fa292d58373ee Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Fri, 25 Nov 2022 15:07:19 -0300 Subject: [PATCH 6/9] Remove AscribeUserTypeCx --- compiler/rustc_traits/src/type_op.rs | 159 +++++++++------------------ 1 file changed, 52 insertions(+), 107 deletions(-) diff --git a/compiler/rustc_traits/src/type_op.rs b/compiler/rustc_traits/src/type_op.rs index 9eceae8b44f8e..fffa666cd5834 100644 --- a/compiler/rustc_traits/src/type_op.rs +++ b/compiler/rustc_traits/src/type_op.rs @@ -1,6 +1,4 @@ use rustc_hir as hir; -use rustc_hir::def_id::DefId; -use rustc_infer::infer::at::ToTrace; use rustc_infer::infer::canonical::{Canonical, QueryResponse}; use rustc_infer::infer::{DefiningAnchor, TyCtxtInferExt}; use rustc_infer::traits::ObligationCauseCode; @@ -57,122 +55,69 @@ pub fn type_op_ascribe_user_type_with_span<'tcx>( "type_op_ascribe_user_type: mir_ty={:?} def_id={:?} user_substs={:?}", mir_ty, def_id, user_substs ); - let cx = AscribeUserTypeCx { ocx, param_env, span: span.unwrap_or(DUMMY_SP) }; - cx.relate_mir_and_user_ty(mir_ty, def_id, user_substs)?; - Ok(()) -} - -struct AscribeUserTypeCx<'me, 'tcx> { - ocx: &'me ObligationCtxt<'me, 'tcx>, - param_env: ty::ParamEnv<'tcx>, - span: Span, -} + let span = span.unwrap_or(DUMMY_SP); -impl<'me, 'tcx> AscribeUserTypeCx<'me, 'tcx> { - fn normalize(&self, value: T) -> T - where - T: TypeFoldable<'tcx>, - { - self.normalize_with_cause(value, ObligationCause::misc(self.span, hir::CRATE_HIR_ID)) - } + let UserSubsts { user_self_ty, substs } = user_substs; + let tcx = ocx.infcx.tcx; - fn normalize_with_cause(&self, value: T, cause: ObligationCause<'tcx>) -> T - where - T: TypeFoldable<'tcx>, - { - self.ocx.normalize(cause, self.param_env, value) - } + let ty = tcx.bound_type_of(def_id).subst(tcx, substs); + let ty = ocx.normalize(ObligationCause::misc(span, hir::CRATE_HIR_ID), param_env, ty); + debug!("relate_type_and_user_type: ty of def-id is {:?}", ty); - fn eq(&self, a: T, b: T) -> Result<(), NoSolution> - where - T: ToTrace<'tcx>, - { - Ok(self.ocx.eq(&ObligationCause::dummy_with_span(self.span), self.param_env, a, b)?) - } + ocx.eq(&ObligationCause::dummy_with_span(span), param_env, mir_ty, ty)?; - fn prove_predicate(&self, predicate: Predicate<'tcx>, cause: ObligationCause<'tcx>) { - self.ocx.register_obligation(Obligation::new( - self.ocx.infcx.tcx, - cause, - self.param_env, - predicate, - )); - } + // Prove the predicates coming along with `def_id`. + // + // Also, normalize the `instantiated_predicates` + // because otherwise we wind up with duplicate "type + // outlives" error messages. + let instantiated_predicates = tcx.predicates_of(def_id).instantiate(tcx, substs); - fn tcx(&self) -> TyCtxt<'tcx> { - self.ocx.infcx.tcx - } + let cause = ObligationCause::dummy_with_span(span); - #[instrument(level = "debug", skip(self))] - fn relate_mir_and_user_ty( - &self, - mir_ty: Ty<'tcx>, - def_id: DefId, - user_substs: UserSubsts<'tcx>, - ) -> Result<(), NoSolution> { - let UserSubsts { user_self_ty, substs } = user_substs; - let tcx = self.tcx(); - - let ty = tcx.bound_type_of(def_id).subst(tcx, substs); - let ty = self.normalize(ty); - debug!("relate_type_and_user_type: ty of def-id is {:?}", ty); - - self.eq(mir_ty, ty)?; - - // Prove the predicates coming along with `def_id`. - // - // Also, normalize the `instantiated_predicates` - // because otherwise we wind up with duplicate "type - // outlives" error messages. - let instantiated_predicates = tcx.predicates_of(def_id).instantiate(tcx, substs); - - let cause = ObligationCause::dummy_with_span(self.span); - - debug!(?instantiated_predicates); - for (instantiated_predicate, predicate_span) in - zip(instantiated_predicates.predicates, instantiated_predicates.spans) - { - let span = if self.span == DUMMY_SP { predicate_span } else { self.span }; - let cause = ObligationCause::new( - span, - hir::CRATE_HIR_ID, - ObligationCauseCode::AscribeUserTypeProvePredicate(predicate_span), - ); - let instantiated_predicate = - self.normalize_with_cause(instantiated_predicate, cause.clone()); - self.prove_predicate(instantiated_predicate, cause); - } + debug!(?instantiated_predicates); + for (instantiated_predicate, predicate_span) in + zip(instantiated_predicates.predicates, instantiated_predicates.spans) + { + let span = if span == DUMMY_SP { predicate_span } else { span }; + let cause = ObligationCause::new( + span, + hir::CRATE_HIR_ID, + ObligationCauseCode::AscribeUserTypeProvePredicate(predicate_span), + ); + let instantiated_predicate = + ocx.normalize(cause.clone(), param_env, instantiated_predicate); - if let Some(UserSelfTy { impl_def_id, self_ty }) = user_self_ty { - let impl_self_ty = tcx.bound_type_of(impl_def_id).subst(tcx, substs); - let impl_self_ty = self.normalize(impl_self_ty); + ocx.register_obligation(Obligation::new(tcx, cause, param_env, instantiated_predicate)); + } - self.eq(self_ty, impl_self_ty)?; + if let Some(UserSelfTy { impl_def_id, self_ty }) = user_self_ty { + let impl_self_ty = tcx.bound_type_of(impl_def_id).subst(tcx, substs); + let impl_self_ty = + ocx.normalize(ObligationCause::misc(span, hir::CRATE_HIR_ID), param_env, impl_self_ty); - self.prove_predicate( - ty::Binder::dummy(ty::PredicateKind::WellFormed(impl_self_ty.into())) - .to_predicate(tcx), - cause.clone(), - ); - } + ocx.eq(&ObligationCause::dummy_with_span(span), param_env, self_ty, impl_self_ty)?; - // In addition to proving the predicates, we have to - // prove that `ty` is well-formed -- this is because - // the WF of `ty` is predicated on the substs being - // well-formed, and we haven't proven *that*. We don't - // want to prove the WF of types from `substs` directly because they - // haven't been normalized. - // - // FIXME(nmatsakis): Well, perhaps we should normalize - // them? This would only be relevant if some input - // type were ill-formed but did not appear in `ty`, - // which...could happen with normalization... - self.prove_predicate( - ty::Binder::dummy(ty::PredicateKind::WellFormed(ty.into())).to_predicate(tcx), - cause, - ); - Ok(()) + let predicate: Predicate<'tcx> = + ty::Binder::dummy(ty::PredicateKind::WellFormed(impl_self_ty.into())).to_predicate(tcx); + ocx.register_obligation(Obligation::new(tcx, cause.clone(), param_env, predicate)); } + + // In addition to proving the predicates, we have to + // prove that `ty` is well-formed -- this is because + // the WF of `ty` is predicated on the substs being + // well-formed, and we haven't proven *that*. We don't + // want to prove the WF of types from `substs` directly because they + // haven't been normalized. + // + // FIXME(nmatsakis): Well, perhaps we should normalize + // them? This would only be relevant if some input + // type were ill-formed but did not appear in `ty`, + // which...could happen with normalization... + let predicate: Predicate<'tcx> = + ty::Binder::dummy(ty::PredicateKind::WellFormed(ty.into())).to_predicate(tcx); + ocx.register_obligation(Obligation::new(tcx, cause, param_env, predicate)); + Ok(()) } fn type_op_eq<'tcx>( From 3c9b30e65876090b2e1e4944dac24d7e9e182d1f Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Fri, 25 Nov 2022 15:36:15 -0300 Subject: [PATCH 7/9] Define all clauses as dummy_with_span as the usages are all equivalent --- compiler/rustc_traits/src/type_op.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/compiler/rustc_traits/src/type_op.rs b/compiler/rustc_traits/src/type_op.rs index fffa666cd5834..c6c072ea3d2bd 100644 --- a/compiler/rustc_traits/src/type_op.rs +++ b/compiler/rustc_traits/src/type_op.rs @@ -59,12 +59,13 @@ pub fn type_op_ascribe_user_type_with_span<'tcx>( let UserSubsts { user_self_ty, substs } = user_substs; let tcx = ocx.infcx.tcx; + let cause = ObligationCause::dummy_with_span(span); let ty = tcx.bound_type_of(def_id).subst(tcx, substs); - let ty = ocx.normalize(ObligationCause::misc(span, hir::CRATE_HIR_ID), param_env, ty); + let ty = ocx.normalize(cause.clone(), param_env, ty); debug!("relate_type_and_user_type: ty of def-id is {:?}", ty); - ocx.eq(&ObligationCause::dummy_with_span(span), param_env, mir_ty, ty)?; + ocx.eq(&cause, param_env, mir_ty, ty)?; // Prove the predicates coming along with `def_id`. // @@ -73,8 +74,6 @@ pub fn type_op_ascribe_user_type_with_span<'tcx>( // outlives" error messages. let instantiated_predicates = tcx.predicates_of(def_id).instantiate(tcx, substs); - let cause = ObligationCause::dummy_with_span(span); - debug!(?instantiated_predicates); for (instantiated_predicate, predicate_span) in zip(instantiated_predicates.predicates, instantiated_predicates.spans) @@ -93,10 +92,9 @@ pub fn type_op_ascribe_user_type_with_span<'tcx>( if let Some(UserSelfTy { impl_def_id, self_ty }) = user_self_ty { let impl_self_ty = tcx.bound_type_of(impl_def_id).subst(tcx, substs); - let impl_self_ty = - ocx.normalize(ObligationCause::misc(span, hir::CRATE_HIR_ID), param_env, impl_self_ty); + let impl_self_ty = ocx.normalize(cause.clone(), param_env, impl_self_ty); - ocx.eq(&ObligationCause::dummy_with_span(span), param_env, self_ty, impl_self_ty)?; + ocx.eq(&cause, param_env, self_ty, impl_self_ty)?; let predicate: Predicate<'tcx> = ty::Binder::dummy(ty::PredicateKind::WellFormed(impl_self_ty.into())).to_predicate(tcx); From ea4794321224964060b931d962a9a6ee7e59ac7c Mon Sep 17 00:00:00 2001 From: Lokathor Date: Mon, 7 Nov 2022 12:07:07 -0700 Subject: [PATCH 8/9] Refine instruction_set inline rules Previously an exact match of the `instruction_set` attribute was required for an MIR inline to be considered. This change checks for an exact match *only* if the callee sets an `instruction_set` in the first place. When the callee does not declare an instruction set then it is considered to be platform agnostic code and it's allowed to be inline'd into the caller. --- compiler/rustc_mir_transform/src/inline.rs | 16 +++++++- ...inline_instruction_set.default.Inline.diff | 28 +++++++++++--- .../mir-opt/inline/inline_instruction_set.rs | 11 +++++- .../inline_instruction_set.t32.Inline.diff | 38 ++++++++++++------- 4 files changed, 71 insertions(+), 22 deletions(-) diff --git a/compiler/rustc_mir_transform/src/inline.rs b/compiler/rustc_mir_transform/src/inline.rs index 780b91d9215d5..b1b527b569a88 100644 --- a/compiler/rustc_mir_transform/src/inline.rs +++ b/compiler/rustc_mir_transform/src/inline.rs @@ -375,7 +375,12 @@ impl<'tcx> Inliner<'tcx> { return Err("incompatible sanitizer set"); } - if callee_attrs.instruction_set != self.codegen_fn_attrs.instruction_set { + // Two functions are compatible if the callee has no attribute (meaning + // that it's codegen agnostic), or sets an attribute that is identical + // to this function's attribute. + if callee_attrs.instruction_set.is_some() + && callee_attrs.instruction_set != self.codegen_fn_attrs.instruction_set + { return Err("incompatible instruction set"); } @@ -453,6 +458,15 @@ impl<'tcx> Inliner<'tcx> { if ty.needs_drop(tcx, self.param_env) && let Some(unwind) = unwind { work_list.push(unwind); } + } else if callee_attrs.instruction_set != self.codegen_fn_attrs.instruction_set + && matches!(term.kind, TerminatorKind::InlineAsm { .. }) + { + // During the attribute checking stage we allow a callee with no + // instruction_set assigned to count as compatible with a function that does + // assign one. However, during this stage we require an exact match when any + // inline-asm is detected. LLVM will still possibly do an inline later on + // if the no-attribute function ends up with the same instruction set anyway. + return Err("Cannot move inline-asm across instruction sets"); } else { work_list.extend(term.successors()) } diff --git a/src/test/mir-opt/inline/inline_instruction_set.default.Inline.diff b/src/test/mir-opt/inline/inline_instruction_set.default.Inline.diff index e421428dcdff5..f1988ea4bd678 100644 --- a/src/test/mir-opt/inline/inline_instruction_set.default.Inline.diff +++ b/src/test/mir-opt/inline/inline_instruction_set.default.Inline.diff @@ -6,14 +6,19 @@ let _1: (); // in scope 0 at $DIR/inline_instruction_set.rs:+1:5: +1:26 let _2: (); // in scope 0 at $DIR/inline_instruction_set.rs:+2:5: +2:26 let _3: (); // in scope 0 at $DIR/inline_instruction_set.rs:+3:5: +3:30 -+ scope 1 (inlined instruction_set_default) { // at $DIR/inline_instruction_set.rs:53:5: 53:30 + let _4: (); // in scope 0 at $DIR/inline_instruction_set.rs:+4:5: +4:41 ++ scope 1 (inlined instruction_set_default) { // at $DIR/inline_instruction_set.rs:59:5: 59:30 ++ } ++ scope 2 (inlined inline_always_and_using_inline_asm) { // at $DIR/inline_instruction_set.rs:60:5: 60:41 ++ scope 3 { ++ } + } bb0: { StorageLive(_1); // scope 0 at $DIR/inline_instruction_set.rs:+1:5: +1:26 _1 = instruction_set_a32() -> bb1; // scope 0 at $DIR/inline_instruction_set.rs:+1:5: +1:26 // mir::Constant - // + span: $DIR/inline_instruction_set.rs:51:5: 51:24 + // + span: $DIR/inline_instruction_set.rs:57:5: 57:24 // + literal: Const { ty: fn() {instruction_set_a32}, val: Value() } } @@ -22,7 +27,7 @@ StorageLive(_2); // scope 0 at $DIR/inline_instruction_set.rs:+2:5: +2:26 _2 = instruction_set_t32() -> bb2; // scope 0 at $DIR/inline_instruction_set.rs:+2:5: +2:26 // mir::Constant - // + span: $DIR/inline_instruction_set.rs:52:5: 52:24 + // + span: $DIR/inline_instruction_set.rs:58:5: 58:24 // + literal: Const { ty: fn() {instruction_set_t32}, val: Value() } } @@ -31,14 +36,25 @@ StorageLive(_3); // scope 0 at $DIR/inline_instruction_set.rs:+3:5: +3:30 - _3 = instruction_set_default() -> bb3; // scope 0 at $DIR/inline_instruction_set.rs:+3:5: +3:30 - // mir::Constant -- // + span: $DIR/inline_instruction_set.rs:53:5: 53:28 +- // + span: $DIR/inline_instruction_set.rs:59:5: 59:28 - // + literal: Const { ty: fn() {instruction_set_default}, val: Value() } - } - - bb3: { StorageDead(_3); // scope 0 at $DIR/inline_instruction_set.rs:+3:30: +3:31 - _0 = const (); // scope 0 at $DIR/inline_instruction_set.rs:+0:18: +4:2 - return; // scope 0 at $DIR/inline_instruction_set.rs:+4:2: +4:2 + StorageLive(_4); // scope 0 at $DIR/inline_instruction_set.rs:+4:5: +4:41 +- _4 = inline_always_and_using_inline_asm() -> bb4; // scope 0 at $DIR/inline_instruction_set.rs:+4:5: +4:41 +- // mir::Constant +- // + span: $DIR/inline_instruction_set.rs:60:5: 60:39 +- // + literal: Const { ty: fn() {inline_always_and_using_inline_asm}, val: Value() } ++ asm!("/* do nothing */", options((empty))) -> bb3; // scope 3 at $DIR/inline_instruction_set.rs:43:14: 43:38 + } + +- bb4: { ++ bb3: { + StorageDead(_4); // scope 0 at $DIR/inline_instruction_set.rs:+4:41: +4:42 + _0 = const (); // scope 0 at $DIR/inline_instruction_set.rs:+0:18: +5:2 + return; // scope 0 at $DIR/inline_instruction_set.rs:+5:2: +5:2 } } diff --git a/src/test/mir-opt/inline/inline_instruction_set.rs b/src/test/mir-opt/inline/inline_instruction_set.rs index be36ff50c7ef1..5dfb04943e39f 100644 --- a/src/test/mir-opt/inline/inline_instruction_set.rs +++ b/src/test/mir-opt/inline/inline_instruction_set.rs @@ -1,5 +1,7 @@ // Checks that only functions with the compatible instruction_set attributes are inlined. // +// A function is "compatible" when the *callee* has the same attribute or no attribute. +// // compile-flags: --target thumbv4t-none-eabi // needs-llvm-components: arm @@ -36,14 +38,18 @@ fn instruction_set_t32() {} #[inline] fn instruction_set_default() {} +#[inline(always)] +fn inline_always_and_using_inline_asm() { + unsafe { asm!("/* do nothing */") }; +} + // EMIT_MIR inline_instruction_set.t32.Inline.diff #[instruction_set(arm::t32)] pub fn t32() { instruction_set_a32(); instruction_set_t32(); - // The default instruction set is currently - // conservatively assumed to be incompatible. instruction_set_default(); + inline_always_and_using_inline_asm(); } // EMIT_MIR inline_instruction_set.default.Inline.diff @@ -51,4 +57,5 @@ pub fn default() { instruction_set_a32(); instruction_set_t32(); instruction_set_default(); + inline_always_and_using_inline_asm(); } diff --git a/src/test/mir-opt/inline/inline_instruction_set.t32.Inline.diff b/src/test/mir-opt/inline/inline_instruction_set.t32.Inline.diff index 1ea2b87e53acd..e777b2cc29eb3 100644 --- a/src/test/mir-opt/inline/inline_instruction_set.t32.Inline.diff +++ b/src/test/mir-opt/inline/inline_instruction_set.t32.Inline.diff @@ -5,15 +5,18 @@ let mut _0: (); // return place in scope 0 at $DIR/inline_instruction_set.rs:+0:14: +0:14 let _1: (); // in scope 0 at $DIR/inline_instruction_set.rs:+1:5: +1:26 let _2: (); // in scope 0 at $DIR/inline_instruction_set.rs:+2:5: +2:26 - let _3: (); // in scope 0 at $DIR/inline_instruction_set.rs:+5:5: +5:30 -+ scope 1 (inlined instruction_set_t32) { // at $DIR/inline_instruction_set.rs:43:5: 43:26 + let _3: (); // in scope 0 at $DIR/inline_instruction_set.rs:+3:5: +3:30 + let _4: (); // in scope 0 at $DIR/inline_instruction_set.rs:+4:5: +4:41 ++ scope 1 (inlined instruction_set_t32) { // at $DIR/inline_instruction_set.rs:50:5: 50:26 ++ } ++ scope 2 (inlined instruction_set_default) { // at $DIR/inline_instruction_set.rs:51:5: 51:30 + } bb0: { StorageLive(_1); // scope 0 at $DIR/inline_instruction_set.rs:+1:5: +1:26 _1 = instruction_set_a32() -> bb1; // scope 0 at $DIR/inline_instruction_set.rs:+1:5: +1:26 // mir::Constant - // + span: $DIR/inline_instruction_set.rs:42:5: 42:24 + // + span: $DIR/inline_instruction_set.rs:49:5: 49:24 // + literal: Const { ty: fn() {instruction_set_a32}, val: Value() } } @@ -22,25 +25,34 @@ StorageLive(_2); // scope 0 at $DIR/inline_instruction_set.rs:+2:5: +2:26 - _2 = instruction_set_t32() -> bb2; // scope 0 at $DIR/inline_instruction_set.rs:+2:5: +2:26 - // mir::Constant -- // + span: $DIR/inline_instruction_set.rs:43:5: 43:24 +- // + span: $DIR/inline_instruction_set.rs:50:5: 50:24 - // + literal: Const { ty: fn() {instruction_set_t32}, val: Value() } - } - - bb2: { StorageDead(_2); // scope 0 at $DIR/inline_instruction_set.rs:+2:26: +2:27 - StorageLive(_3); // scope 0 at $DIR/inline_instruction_set.rs:+5:5: +5:30 -- _3 = instruction_set_default() -> bb3; // scope 0 at $DIR/inline_instruction_set.rs:+5:5: +5:30 -+ _3 = instruction_set_default() -> bb2; // scope 0 at $DIR/inline_instruction_set.rs:+5:5: +5:30 + StorageLive(_3); // scope 0 at $DIR/inline_instruction_set.rs:+3:5: +3:30 +- _3 = instruction_set_default() -> bb3; // scope 0 at $DIR/inline_instruction_set.rs:+3:5: +3:30 +- // mir::Constant +- // + span: $DIR/inline_instruction_set.rs:51:5: 51:28 +- // + literal: Const { ty: fn() {instruction_set_default}, val: Value() } +- } +- +- bb3: { + StorageDead(_3); // scope 0 at $DIR/inline_instruction_set.rs:+3:30: +3:31 + StorageLive(_4); // scope 0 at $DIR/inline_instruction_set.rs:+4:5: +4:41 +- _4 = inline_always_and_using_inline_asm() -> bb4; // scope 0 at $DIR/inline_instruction_set.rs:+4:5: +4:41 ++ _4 = inline_always_and_using_inline_asm() -> bb2; // scope 0 at $DIR/inline_instruction_set.rs:+4:5: +4:41 // mir::Constant - // + span: $DIR/inline_instruction_set.rs:46:5: 46:28 - // + literal: Const { ty: fn() {instruction_set_default}, val: Value() } + // + span: $DIR/inline_instruction_set.rs:52:5: 52:39 + // + literal: Const { ty: fn() {inline_always_and_using_inline_asm}, val: Value() } } -- bb3: { +- bb4: { + bb2: { - StorageDead(_3); // scope 0 at $DIR/inline_instruction_set.rs:+5:30: +5:31 - _0 = const (); // scope 0 at $DIR/inline_instruction_set.rs:+0:14: +6:2 - return; // scope 0 at $DIR/inline_instruction_set.rs:+6:2: +6:2 + StorageDead(_4); // scope 0 at $DIR/inline_instruction_set.rs:+4:41: +4:42 + _0 = const (); // scope 0 at $DIR/inline_instruction_set.rs:+0:14: +5:2 + return; // scope 0 at $DIR/inline_instruction_set.rs:+5:2: +5:2 } } From 083d6eb3fb42a3e54bbd9d436da30321eb18fee1 Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Fri, 25 Nov 2022 22:37:04 +0000 Subject: [PATCH 9/9] Update cargo 5 commits in ba607b23db8398723d659249d9abf5536bc322e5..e027c4b5d25af2119b1956fac42863b9b3242744 2022-11-22 20:52:39 +0000 to 2022-11-25 19:44:46 +0000 - fix: Move off atty to resolve soundness issue (rust-lang/cargo#11420) - add newline char to `cargo install .` error message for easier reading. (rust-lang/cargo#11401) - chore: Upgrade to env_logger (rust-lang/cargo#11417) - Change rustdoc-scrape-examples to be a target-level configuration (rust-lang/cargo#10343) - temporarily disable test `lto::test_profile` (rust-lang/cargo#11419) --- Cargo.lock | 80 +++++++++++++++++++++++++++++++++++++++++++++++-- src/tools/cargo | 2 +- 2 files changed, 79 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d8612b3a2561b..55956c1356a8c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -288,7 +288,6 @@ name = "cargo" version = "0.68.0" dependencies = [ "anyhow", - "atty", "bytesize", "cargo-platform 0.1.2", "cargo-test-macro", @@ -298,7 +297,7 @@ dependencies = [ "crates-io", "curl", "curl-sys", - "env_logger 0.9.0", + "env_logger 0.10.0", "filetime", "flate2", "fwdansi", @@ -312,6 +311,7 @@ dependencies = [ "ignore", "im-rc", "indexmap", + "is-terminal", "itertools", "jobserver", "lazy_static", @@ -1213,6 +1213,40 @@ dependencies = [ "termcolor", ] +[[package]] +name = "env_logger" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" +dependencies = [ + "humantime 2.0.1", + "is-terminal", + "log", + "regex", + "termcolor", +] + +[[package]] +name = "errno" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" +dependencies = [ + "errno-dragonfly", + "libc", + "winapi", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + [[package]] name = "error_index_generator" version = "0.0.0" @@ -1907,6 +1941,28 @@ dependencies = [ "unic-langid", ] +[[package]] +name = "io-lifetimes" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e394faa0efb47f9f227f1cd89978f854542b318a6f64fa695489c9c993056656" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "is-terminal" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aae5bc6e2eb41c9def29a3e0f1306382807764b9b53112030eff57435667352d" +dependencies = [ + "hermit-abi 0.2.6", + "io-lifetimes", + "rustix", + "windows-sys", +] + [[package]] name = "itertools" version = "0.10.5" @@ -2116,6 +2172,12 @@ dependencies = [ "walkdir", ] +[[package]] +name = "linux-raw-sys" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f9f08d8963a6c613f4b1a78f4f4a4dbfadf8e6545b2d72861731e4858b8b47f" + [[package]] name = "litemap" version = "0.6.0" @@ -4508,6 +4570,20 @@ dependencies = [ "unicode_categories", ] +[[package]] +name = "rustix" +version = "0.36.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b1fbb4dfc4eb1d390c02df47760bb19a84bb80b301ecc947ab5406394d8223e" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys", + "windows-sys", +] + [[package]] name = "rustversion" version = "1.0.5" diff --git a/src/tools/cargo b/src/tools/cargo index ba607b23db839..e027c4b5d25af 160000 --- a/src/tools/cargo +++ b/src/tools/cargo @@ -1 +1 @@ -Subproject commit ba607b23db8398723d659249d9abf5536bc322e5 +Subproject commit e027c4b5d25af2119b1956fac42863b9b3242744