| author | bors <bors@rust-lang.org> 2025-07-10 13:49:36 UTC |
| committer | bors <bors@rust-lang.org> 2025-07-10 13:49:36 UTC |
| log | 78a6e132984dba0303ebad7dcfd1305c93ad5835 |
| tree | d750951d6c3044d202ada72e87b9c35cb0dc74f1 |
| parent | 119574f83576dc1f3ae067f9a97986d4e2b0826c |
| parent | bd2a3517881de6026cac53262e14275758e70b7b |
Rollup of 12 pull requests
Successful merges:
- rust-lang/rust#136906 (Add checking for unnecessary delims in closure body)
- rust-lang/rust#143652 (docs: document trait upcasting rules in `Unsize` trait)
- rust-lang/rust#143657 (Resolver: refact macro map into external and local maps)
- rust-lang/rust#143659 (Use "Innermost" & "Outermost" terminology for `AttributeOrder`)
- rust-lang/rust#143663 (fix: correct typo in attr_parsing_previously_accepted message key)
- rust-lang/rust#143666 (Re-expose nested bodies in rustc_borrowck::consumers)
- rust-lang/rust#143668 (Fix VxWorks build errors)
- rust-lang/rust#143670 (Add a new maintainer to the wasm32-wasip1 target)
- rust-lang/rust#143675 (improve lint doc text)
- rust-lang/rust#143683 (Assorted `run-make-support` maintenance)
- rust-lang/rust#143695 (Auto-add `S-waiting-on-author` when the PR is/switches to draft state)
- rust-lang/rust#143706 (triagebot.toml: ping lolbinarycat if tidy extra checks were modified)
r? `@ghost`
`@rustbot` modify labels: rollup80 files changed, 512 insertions(+), 415 deletions(-)
Cargo.lock+1-1| ... | ... | @@ -3214,7 +3214,7 @@ dependencies = [ |
| 3214 | 3214 | |
| 3215 | 3215 | [[package]] |
| 3216 | 3216 | name = "run_make_support" |
| 3217 | version = "0.2.0" | |
| 3217 | version = "0.0.0" | |
| 3218 | 3218 | dependencies = [ |
| 3219 | 3219 | "bstr", |
| 3220 | 3220 | "build_helper", |
compiler/rustc_attr_parsing/messages.ftl+2-2| ... | ... | @@ -146,12 +146,12 @@ attr_parsing_unused_duplicate = |
| 146 | 146 | unused attribute |
| 147 | 147 | .suggestion = remove this attribute |
| 148 | 148 | .note = attribute also specified here |
| 149 | .warn = {-passes_previously_accepted} | |
| 149 | .warn = {-attr_parsing_previously_accepted} | |
| 150 | 150 | |
| 151 | 151 | attr_parsing_unused_multiple = |
| 152 | 152 | multiple `{$name}` attributes |
| 153 | 153 | .suggestion = remove this attribute |
| 154 | 154 | .note = attribute also specified here |
| 155 | 155 | |
| 156 | -attr_parsing_perviously_accepted = | |
| 156 | -attr_parsing_previously_accepted = | |
| 157 | 157 | this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! |
compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs+2-2| ... | ... | @@ -15,7 +15,7 @@ pub(crate) struct OptimizeParser; |
| 15 | 15 | |
| 16 | 16 | impl<S: Stage> SingleAttributeParser<S> for OptimizeParser { |
| 17 | 17 | const PATH: &[Symbol] = &[sym::optimize]; |
| 18 | const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepLast; | |
| 18 | const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepOutermost; | |
| 19 | 19 | const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::WarnButFutureError; |
| 20 | 20 | const TEMPLATE: AttributeTemplate = template!(List: "size|speed|none"); |
| 21 | 21 | |
| ... | ... | @@ -56,7 +56,7 @@ pub(crate) struct ExportNameParser; |
| 56 | 56 | |
| 57 | 57 | impl<S: Stage> SingleAttributeParser<S> for ExportNameParser { |
| 58 | 58 | const PATH: &[rustc_span::Symbol] = &[sym::export_name]; |
| 59 | const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepFirst; | |
| 59 | const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepInnermost; | |
| 60 | 60 | const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::WarnButFutureError; |
| 61 | 61 | const TEMPLATE: AttributeTemplate = template!(NameValueStr: "name"); |
| 62 | 62 |
compiler/rustc_attr_parsing/src/attributes/deprecation.rs+1-1| ... | ... | @@ -36,7 +36,7 @@ fn get<S: Stage>( |
| 36 | 36 | |
| 37 | 37 | impl<S: Stage> SingleAttributeParser<S> for DeprecationParser { |
| 38 | 38 | const PATH: &[Symbol] = &[sym::deprecated]; |
| 39 | const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepFirst; | |
| 39 | const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepInnermost; | |
| 40 | 40 | const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error; |
| 41 | 41 | const TEMPLATE: AttributeTemplate = template!( |
| 42 | 42 | Word, |
compiler/rustc_attr_parsing/src/attributes/dummy.rs+1-1| ... | ... | @@ -9,7 +9,7 @@ use crate::parser::ArgParser; |
| 9 | 9 | pub(crate) struct DummyParser; |
| 10 | 10 | impl<S: Stage> SingleAttributeParser<S> for DummyParser { |
| 11 | 11 | const PATH: &[Symbol] = &[sym::rustc_dummy]; |
| 12 | const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepFirst; | |
| 12 | const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepInnermost; | |
| 13 | 13 | const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Ignore; |
| 14 | 14 | const TEMPLATE: AttributeTemplate = template!(Word); // Anything, really |
| 15 | 15 |
compiler/rustc_attr_parsing/src/attributes/inline.rs+2-2| ... | ... | @@ -16,7 +16,7 @@ pub(crate) struct InlineParser; |
| 16 | 16 | |
| 17 | 17 | impl<S: Stage> SingleAttributeParser<S> for InlineParser { |
| 18 | 18 | const PATH: &'static [Symbol] = &[sym::inline]; |
| 19 | const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepLast; | |
| 19 | const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepOutermost; | |
| 20 | 20 | const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::WarnButFutureError; |
| 21 | 21 | const TEMPLATE: AttributeTemplate = template!(Word, List: "always|never"); |
| 22 | 22 | |
| ... | ... | @@ -57,7 +57,7 @@ pub(crate) struct RustcForceInlineParser; |
| 57 | 57 | |
| 58 | 58 | impl<S: Stage> SingleAttributeParser<S> for RustcForceInlineParser { |
| 59 | 59 | const PATH: &'static [Symbol] = &[sym::rustc_force_inline]; |
| 60 | const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepLast; | |
| 60 | const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepOutermost; | |
| 61 | 61 | const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::WarnButFutureError; |
| 62 | 62 | const TEMPLATE: AttributeTemplate = template!(Word, List: "reason", NameValueStr: "reason"); |
| 63 | 63 |
compiler/rustc_attr_parsing/src/attributes/link_attrs.rs+2-2| ... | ... | @@ -14,7 +14,7 @@ pub(crate) struct LinkNameParser; |
| 14 | 14 | |
| 15 | 15 | impl<S: Stage> SingleAttributeParser<S> for LinkNameParser { |
| 16 | 16 | const PATH: &[Symbol] = &[sym::link_name]; |
| 17 | const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepFirst; | |
| 17 | const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepInnermost; | |
| 18 | 18 | const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::WarnButFutureError; |
| 19 | 19 | const TEMPLATE: AttributeTemplate = template!(NameValueStr: "name"); |
| 20 | 20 | |
| ... | ... | @@ -36,7 +36,7 @@ pub(crate) struct LinkSectionParser; |
| 36 | 36 | |
| 37 | 37 | impl<S: Stage> SingleAttributeParser<S> for LinkSectionParser { |
| 38 | 38 | const PATH: &[Symbol] = &[sym::link_section]; |
| 39 | const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepFirst; | |
| 39 | const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepInnermost; | |
| 40 | 40 | const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::WarnButFutureError; |
| 41 | 41 | const TEMPLATE: AttributeTemplate = template!(NameValueStr: "name"); |
| 42 | 42 |
compiler/rustc_attr_parsing/src/attributes/mod.rs+13-26| ... | ... | @@ -140,7 +140,7 @@ impl<T: SingleAttributeParser<S>, S: Stage> AttributeParser<S> for Single<T, S> |
| 140 | 140 | if let Some(pa) = T::convert(cx, args) { |
| 141 | 141 | match T::ATTRIBUTE_ORDER { |
| 142 | 142 | // keep the first and report immediately. ignore this attribute |
| 143 | AttributeOrder::KeepFirst => { | |
| 143 | AttributeOrder::KeepInnermost => { | |
| 144 | 144 | if let Some((_, unused)) = group.1 { |
| 145 | 145 | T::ON_DUPLICATE.exec::<T>(cx, cx.attr_span, unused); |
| 146 | 146 | return; |
| ... | ... | @@ -148,7 +148,7 @@ impl<T: SingleAttributeParser<S>, S: Stage> AttributeParser<S> for Single<T, S> |
| 148 | 148 | } |
| 149 | 149 | // keep the new one and warn about the previous, |
| 150 | 150 | // then replace |
| 151 | AttributeOrder::KeepLast => { | |
| 151 | AttributeOrder::KeepOutermost => { | |
| 152 | 152 | if let Some((_, used)) = group.1 { |
| 153 | 153 | T::ON_DUPLICATE.exec::<T>(cx, used, cx.attr_span); |
| 154 | 154 | } |
| ... | ... | @@ -165,9 +165,6 @@ impl<T: SingleAttributeParser<S>, S: Stage> AttributeParser<S> for Single<T, S> |
| 165 | 165 | } |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | // FIXME(jdonszelmann): logic is implemented but the attribute parsers needing | |
| 169 | // them will be merged in another PR | |
| 170 | #[allow(unused)] | |
| 171 | 168 | pub(crate) enum OnDuplicate<S: Stage> { |
| 172 | 169 | /// Give a default warning |
| 173 | 170 | Warn, |
| ... | ... | @@ -213,39 +210,29 @@ impl<S: Stage> OnDuplicate<S> { |
| 213 | 210 | } |
| 214 | 211 | } |
| 215 | 212 | } |
| 216 | // | |
| 217 | // FIXME(jdonszelmann): logic is implemented but the attribute parsers needing | |
| 218 | // them will be merged in another PR | |
| 219 | #[allow(unused)] | |
| 213 | ||
| 220 | 214 | pub(crate) enum AttributeOrder { |
| 221 | /// Duplicates after the first attribute will be an error. I.e. only keep the lowest attribute. | |
| 215 | /// Duplicates after the innermost instance of the attribute will be an error/warning. | |
| 216 | /// Only keep the lowest attribute. | |
| 222 | 217 | /// |
| 223 | /// Attributes are processed from bottom to top, so this raises an error on all the attributes | |
| 218 | /// Attributes are processed from bottom to top, so this raises a warning/error on all the attributes | |
| 224 | 219 | /// further above the lowest one: |
| 225 | 220 | /// ``` |
| 226 | 221 | /// #[stable(since="1.0")] //~ WARNING duplicated attribute |
| 227 | 222 | /// #[stable(since="2.0")] |
| 228 | 223 | /// ``` |
| 229 | /// | |
| 230 | /// This should be used where duplicates would be ignored, but carry extra | |
| 231 | /// meaning that could cause confusion. For example, `#[stable(since="1.0")] | |
| 232 | /// #[stable(since="2.0")]`, which version should be used for `stable`? | |
| 233 | KeepFirst, | |
| 224 | KeepInnermost, | |
| 234 | 225 | |
| 235 | /// Duplicates preceding the last instance of the attribute will be a | |
| 236 | /// warning, with a note that this will be an error in the future. | |
| 226 | /// Duplicates before the outermost instance of the attribute will be an error/warning. | |
| 227 | /// Only keep the highest attribute. | |
| 237 | 228 | /// |
| 238 | /// Attributes are processed from bottom to top, so this raises a warning on all the attributes | |
| 239 | /// below the higher one: | |
| 229 | /// Attributes are processed from bottom to top, so this raises a warning/error on all the attributes | |
| 230 | /// below the highest one: | |
| 240 | 231 | /// ``` |
| 241 | 232 | /// #[path="foo.rs"] |
| 242 | 233 | /// #[path="bar.rs"] //~ WARNING duplicated attribute |
| 243 | 234 | /// ``` |
| 244 | /// | |
| 245 | /// This is the same as `FutureWarnFollowing`, except the last attribute is | |
| 246 | /// the one that is "used". Ideally these can eventually migrate to | |
| 247 | /// `ErrorPreceding`. | |
| 248 | KeepLast, | |
| 235 | KeepOutermost, | |
| 249 | 236 | } |
| 250 | 237 | |
| 251 | 238 | /// An even simpler version of [`SingleAttributeParser`]: |
| ... | ... | @@ -271,7 +258,7 @@ impl<T: NoArgsAttributeParser<S>, S: Stage> Default for WithoutArgs<T, S> { |
| 271 | 258 | |
| 272 | 259 | impl<T: NoArgsAttributeParser<S>, S: Stage> SingleAttributeParser<S> for WithoutArgs<T, S> { |
| 273 | 260 | const PATH: &[Symbol] = T::PATH; |
| 274 | const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepLast; | |
| 261 | const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepOutermost; | |
| 275 | 262 | const ON_DUPLICATE: OnDuplicate<S> = T::ON_DUPLICATE; |
| 276 | 263 | const TEMPLATE: AttributeTemplate = template!(Word); |
| 277 | 264 |
compiler/rustc_attr_parsing/src/attributes/must_use.rs+1-1| ... | ... | @@ -12,7 +12,7 @@ pub(crate) struct MustUseParser; |
| 12 | 12 | |
| 13 | 13 | impl<S: Stage> SingleAttributeParser<S> for MustUseParser { |
| 14 | 14 | const PATH: &[Symbol] = &[sym::must_use]; |
| 15 | const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepLast; | |
| 15 | const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepOutermost; | |
| 16 | 16 | const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::WarnButFutureError; |
| 17 | 17 | const TEMPLATE: AttributeTemplate = template!(Word, NameValueStr: "reason"); |
| 18 | 18 |
compiler/rustc_attr_parsing/src/attributes/path.rs+1-1| ... | ... | @@ -10,7 +10,7 @@ pub(crate) struct PathParser; |
| 10 | 10 | |
| 11 | 11 | impl<S: Stage> SingleAttributeParser<S> for PathParser { |
| 12 | 12 | const PATH: &[Symbol] = &[sym::path]; |
| 13 | const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepLast; | |
| 13 | const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepOutermost; | |
| 14 | 14 | const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::WarnButFutureError; |
| 15 | 15 | const TEMPLATE: AttributeTemplate = template!(NameValueStr: "file"); |
| 16 | 16 |
compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs+3-3| ... | ... | @@ -11,7 +11,7 @@ pub(crate) struct RustcLayoutScalarValidRangeStart; |
| 11 | 11 | |
| 12 | 12 | impl<S: Stage> SingleAttributeParser<S> for RustcLayoutScalarValidRangeStart { |
| 13 | 13 | const PATH: &'static [Symbol] = &[sym::rustc_layout_scalar_valid_range_start]; |
| 14 | const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepFirst; | |
| 14 | const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepInnermost; | |
| 15 | 15 | const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error; |
| 16 | 16 | const TEMPLATE: AttributeTemplate = template!(List: "start"); |
| 17 | 17 | |
| ... | ... | @@ -25,7 +25,7 @@ pub(crate) struct RustcLayoutScalarValidRangeEnd; |
| 25 | 25 | |
| 26 | 26 | impl<S: Stage> SingleAttributeParser<S> for RustcLayoutScalarValidRangeEnd { |
| 27 | 27 | const PATH: &'static [Symbol] = &[sym::rustc_layout_scalar_valid_range_end]; |
| 28 | const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepFirst; | |
| 28 | const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepInnermost; | |
| 29 | 29 | const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error; |
| 30 | 30 | const TEMPLATE: AttributeTemplate = template!(List: "end"); |
| 31 | 31 | |
| ... | ... | @@ -62,7 +62,7 @@ pub(crate) struct RustcObjectLifetimeDefaultParser; |
| 62 | 62 | |
| 63 | 63 | impl<S: Stage> SingleAttributeParser<S> for RustcObjectLifetimeDefaultParser { |
| 64 | 64 | const PATH: &[rustc_span::Symbol] = &[sym::rustc_object_lifetime_default]; |
| 65 | const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepFirst; | |
| 65 | const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepInnermost; | |
| 66 | 66 | const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error; |
| 67 | 67 | const TEMPLATE: AttributeTemplate = template!(Word); |
| 68 | 68 |
compiler/rustc_attr_parsing/src/attributes/test_attrs.rs+1-1| ... | ... | @@ -11,7 +11,7 @@ pub(crate) struct IgnoreParser; |
| 11 | 11 | |
| 12 | 12 | impl<S: Stage> SingleAttributeParser<S> for IgnoreParser { |
| 13 | 13 | const PATH: &[Symbol] = &[sym::ignore]; |
| 14 | const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepLast; | |
| 14 | const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepOutermost; | |
| 15 | 15 | const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn; |
| 16 | 16 | const TEMPLATE: AttributeTemplate = template!(Word, NameValueStr: "reason"); |
| 17 | 17 |
compiler/rustc_attr_parsing/src/attributes/traits.rs+1-1| ... | ... | @@ -12,7 +12,7 @@ pub(crate) struct SkipDuringMethodDispatchParser; |
| 12 | 12 | |
| 13 | 13 | impl<S: Stage> SingleAttributeParser<S> for SkipDuringMethodDispatchParser { |
| 14 | 14 | const PATH: &[Symbol] = &[sym::rustc_skip_during_method_dispatch]; |
| 15 | const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepFirst; | |
| 15 | const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepInnermost; | |
| 16 | 16 | const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error; |
| 17 | 17 | |
| 18 | 18 | const TEMPLATE: AttributeTemplate = template!(List: "array, boxed_slice"); |
compiler/rustc_attr_parsing/src/attributes/transparency.rs+1-1| ... | ... | @@ -14,7 +14,7 @@ pub(crate) struct TransparencyParser; |
| 14 | 14 | #[allow(rustc::diagnostic_outside_of_impl)] |
| 15 | 15 | impl<S: Stage> SingleAttributeParser<S> for TransparencyParser { |
| 16 | 16 | const PATH: &[Symbol] = &[sym::rustc_macro_transparency]; |
| 17 | const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepFirst; | |
| 17 | const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepInnermost; | |
| 18 | 18 | const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Custom(|cx, used, unused| { |
| 19 | 19 | cx.dcx().span_err(vec![used, unused], "multiple macro transparency attributes"); |
| 20 | 20 | }); |
compiler/rustc_borrowck/src/consumers.rs+57-24| ... | ... | @@ -1,7 +1,9 @@ |
| 1 | 1 | //! This file provides API for compiler consumers. |
| 2 | 2 | |
| 3 | use rustc_data_structures::fx::FxHashMap; | |
| 3 | 4 | use rustc_hir::def_id::LocalDefId; |
| 4 | 5 | use rustc_index::IndexVec; |
| 6 | use rustc_middle::bug; | |
| 5 | 7 | use rustc_middle::mir::{Body, Promoted}; |
| 6 | 8 | use rustc_middle::ty::TyCtxt; |
| 7 | 9 | |
| ... | ... | @@ -17,7 +19,39 @@ pub use super::polonius::legacy::{ |
| 17 | 19 | pub use super::region_infer::RegionInferenceContext; |
| 18 | 20 | use crate::{BorrowCheckRootCtxt, do_mir_borrowck}; |
| 19 | 21 | |
| 20 | /// Options determining the output behavior of [`get_body_with_borrowck_facts`]. | |
| 22 | /// Struct used during mir borrowck to collect bodies with facts for a typeck root and all | |
| 23 | /// its nested bodies. | |
| 24 | pub(crate) struct BorrowckConsumer<'tcx> { | |
| 25 | options: ConsumerOptions, | |
| 26 | bodies: FxHashMap<LocalDefId, BodyWithBorrowckFacts<'tcx>>, | |
| 27 | } | |
| 28 | ||
| 29 | impl<'tcx> BorrowckConsumer<'tcx> { | |
| 30 | pub(crate) fn new(options: ConsumerOptions) -> Self { | |
| 31 | Self { options, bodies: Default::default() } | |
| 32 | } | |
| 33 | ||
| 34 | pub(crate) fn insert_body(&mut self, def_id: LocalDefId, body: BodyWithBorrowckFacts<'tcx>) { | |
| 35 | if self.bodies.insert(def_id, body).is_some() { | |
| 36 | bug!("unexpected previous body for {def_id:?}"); | |
| 37 | } | |
| 38 | } | |
| 39 | ||
| 40 | /// Should the Polonius input facts be computed? | |
| 41 | pub(crate) fn polonius_input(&self) -> bool { | |
| 42 | matches!( | |
| 43 | self.options, | |
| 44 | ConsumerOptions::PoloniusInputFacts | ConsumerOptions::PoloniusOutputFacts | |
| 45 | ) | |
| 46 | } | |
| 47 | ||
| 48 | /// Should we run Polonius and collect the output facts? | |
| 49 | pub(crate) fn polonius_output(&self) -> bool { | |
| 50 | matches!(self.options, ConsumerOptions::PoloniusOutputFacts) | |
| 51 | } | |
| 52 | } | |
| 53 | ||
| 54 | /// Options determining the output behavior of [`get_bodies_with_borrowck_facts`]. | |
| 21 | 55 | /// |
| 22 | 56 | /// If executing under `-Z polonius` the choice here has no effect, and everything as if |
| 23 | 57 | /// [`PoloniusOutputFacts`](ConsumerOptions::PoloniusOutputFacts) had been selected |
| ... | ... | @@ -43,17 +77,6 @@ pub enum ConsumerOptions { |
| 43 | 77 | PoloniusOutputFacts, |
| 44 | 78 | } |
| 45 | 79 | |
| 46 | impl ConsumerOptions { | |
| 47 | /// Should the Polonius input facts be computed? | |
| 48 | pub(crate) fn polonius_input(&self) -> bool { | |
| 49 | matches!(self, Self::PoloniusInputFacts | Self::PoloniusOutputFacts) | |
| 50 | } | |
| 51 | /// Should we run Polonius and collect the output facts? | |
| 52 | pub(crate) fn polonius_output(&self) -> bool { | |
| 53 | matches!(self, Self::PoloniusOutputFacts) | |
| 54 | } | |
| 55 | } | |
| 56 | ||
| 57 | 80 | /// A `Body` with information computed by the borrow checker. This struct is |
| 58 | 81 | /// intended to be consumed by compiler consumers. |
| 59 | 82 | /// |
| ... | ... | @@ -82,25 +105,35 @@ pub struct BodyWithBorrowckFacts<'tcx> { |
| 82 | 105 | pub output_facts: Option<Box<PoloniusOutput>>, |
| 83 | 106 | } |
| 84 | 107 | |
| 85 | /// This function computes borrowck facts for the given body. The [`ConsumerOptions`] | |
| 86 | /// determine which facts are returned. This function makes a copy of the body because | |
| 87 | /// it needs to regenerate the region identifiers. It should never be invoked during a | |
| 88 | /// typical compilation session due to the unnecessary overhead of returning | |
| 89 | /// [`BodyWithBorrowckFacts`]. | |
| 108 | /// This function computes borrowck facts for the given def id and all its nested bodies. | |
| 109 | /// It must be called with a typeck root which will then borrowck all nested bodies as well. | |
| 110 | /// The [`ConsumerOptions`] determine which facts are returned. This function makes a copy | |
| 111 | /// of the bodies because it needs to regenerate the region identifiers. It should never be | |
| 112 | /// invoked during a typical compilation session due to the unnecessary overhead of | |
| 113 | /// returning [`BodyWithBorrowckFacts`]. | |
| 90 | 114 | /// |
| 91 | 115 | /// Note: |
| 92 | /// * This function will panic if the required body was already stolen. This | |
| 116 | /// * This function will panic if the required bodies were already stolen. This | |
| 93 | 117 | /// can, for example, happen when requesting a body of a `const` function |
| 94 | 118 | /// because they are evaluated during typechecking. The panic can be avoided |
| 95 | 119 | /// by overriding the `mir_borrowck` query. You can find a complete example |
| 96 | /// that shows how to do this at `tests/run-make/obtain-borrowck/`. | |
| 120 | /// that shows how to do this at `tests/ui-fulldeps/obtain-borrowck.rs`. | |
| 97 | 121 | /// |
| 98 | 122 | /// * Polonius is highly unstable, so expect regular changes in its signature or other details. |
| 99 | pub fn get_body_with_borrowck_facts( | |
| 123 | pub fn get_bodies_with_borrowck_facts( | |
| 100 | 124 | tcx: TyCtxt<'_>, |
| 101 | def_id: LocalDefId, | |
| 125 | root_def_id: LocalDefId, | |
| 102 | 126 | options: ConsumerOptions, |
| 103 | ) -> BodyWithBorrowckFacts<'_> { | |
| 104 | let mut root_cx = BorrowCheckRootCtxt::new(tcx, def_id); | |
| 105 | *do_mir_borrowck(&mut root_cx, def_id, Some(options)).1.unwrap() | |
| 127 | ) -> FxHashMap<LocalDefId, BodyWithBorrowckFacts<'_>> { | |
| 128 | let mut root_cx = | |
| 129 | BorrowCheckRootCtxt::new(tcx, root_def_id, Some(BorrowckConsumer::new(options))); | |
| 130 | ||
| 131 | // See comment in `rustc_borrowck::mir_borrowck` | |
| 132 | let nested_bodies = tcx.nested_bodies_within(root_def_id); | |
| 133 | for def_id in nested_bodies { | |
| 134 | root_cx.get_or_insert_nested(def_id); | |
| 135 | } | |
| 136 | ||
| 137 | do_mir_borrowck(&mut root_cx, root_def_id); | |
| 138 | root_cx.consumer.unwrap().bodies | |
| 106 | 139 | } |
compiler/rustc_borrowck/src/lib.rs+19-24| ... | ... | @@ -51,7 +51,7 @@ use smallvec::SmallVec; |
| 51 | 51 | use tracing::{debug, instrument}; |
| 52 | 52 | |
| 53 | 53 | use crate::borrow_set::{BorrowData, BorrowSet}; |
| 54 | use crate::consumers::{BodyWithBorrowckFacts, ConsumerOptions}; | |
| 54 | use crate::consumers::BodyWithBorrowckFacts; | |
| 55 | 55 | use crate::dataflow::{BorrowIndex, Borrowck, BorrowckDomain, Borrows}; |
| 56 | 56 | use crate::diagnostics::{ |
| 57 | 57 | AccessKind, BorrowckDiagnosticsBuffer, IllegalMoveOriginKind, MoveError, RegionName, |
| ... | ... | @@ -124,7 +124,7 @@ fn mir_borrowck( |
| 124 | 124 | let opaque_types = ConcreteOpaqueTypes(Default::default()); |
| 125 | 125 | Ok(tcx.arena.alloc(opaque_types)) |
| 126 | 126 | } else { |
| 127 | let mut root_cx = BorrowCheckRootCtxt::new(tcx, def); | |
| 127 | let mut root_cx = BorrowCheckRootCtxt::new(tcx, def, None); | |
| 128 | 128 | // We need to manually borrowck all nested bodies from the HIR as |
| 129 | 129 | // we do not generate MIR for dead code. Not doing so causes us to |
| 130 | 130 | // never check closures in dead code. |
| ... | ... | @@ -134,7 +134,7 @@ fn mir_borrowck( |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | let PropagatedBorrowCheckResults { closure_requirements, used_mut_upvars } = |
| 137 | do_mir_borrowck(&mut root_cx, def, None).0; | |
| 137 | do_mir_borrowck(&mut root_cx, def); | |
| 138 | 138 | debug_assert!(closure_requirements.is_none()); |
| 139 | 139 | debug_assert!(used_mut_upvars.is_empty()); |
| 140 | 140 | root_cx.finalize() |
| ... | ... | @@ -289,17 +289,12 @@ impl<'tcx> ClosureOutlivesSubjectTy<'tcx> { |
| 289 | 289 | |
| 290 | 290 | /// Perform the actual borrow checking. |
| 291 | 291 | /// |
| 292 | /// Use `consumer_options: None` for the default behavior of returning | |
| 293 | /// [`PropagatedBorrowCheckResults`] only. Otherwise, return [`BodyWithBorrowckFacts`] | |
| 294 | /// according to the given [`ConsumerOptions`]. | |
| 295 | /// | |
| 296 | 292 | /// For nested bodies this should only be called through `root_cx.get_or_insert_nested`. |
| 297 | 293 | #[instrument(skip(root_cx), level = "debug")] |
| 298 | 294 | fn do_mir_borrowck<'tcx>( |
| 299 | 295 | root_cx: &mut BorrowCheckRootCtxt<'tcx>, |
| 300 | 296 | def: LocalDefId, |
| 301 | consumer_options: Option<ConsumerOptions>, | |
| 302 | ) -> (PropagatedBorrowCheckResults<'tcx>, Option<Box<BodyWithBorrowckFacts<'tcx>>>) { | |
| 297 | ) -> PropagatedBorrowCheckResults<'tcx> { | |
| 303 | 298 | let tcx = root_cx.tcx; |
| 304 | 299 | let infcx = BorrowckInferCtxt::new(tcx, def); |
| 305 | 300 | let (input_body, promoted) = tcx.mir_promoted(def); |
| ... | ... | @@ -343,7 +338,6 @@ fn do_mir_borrowck<'tcx>( |
| 343 | 338 | &location_table, |
| 344 | 339 | &move_data, |
| 345 | 340 | &borrow_set, |
| 346 | consumer_options, | |
| 347 | 341 | ); |
| 348 | 342 | |
| 349 | 343 | // Dump MIR results into a file, if that is enabled. This lets us |
| ... | ... | @@ -483,23 +477,24 @@ fn do_mir_borrowck<'tcx>( |
| 483 | 477 | used_mut_upvars: mbcx.used_mut_upvars, |
| 484 | 478 | }; |
| 485 | 479 | |
| 486 | let body_with_facts = if consumer_options.is_some() { | |
| 487 | Some(Box::new(BodyWithBorrowckFacts { | |
| 488 | body: body_owned, | |
| 489 | promoted, | |
| 490 | borrow_set, | |
| 491 | region_inference_context: regioncx, | |
| 492 | location_table: polonius_input.as_ref().map(|_| location_table), | |
| 493 | input_facts: polonius_input, | |
| 494 | output_facts: polonius_output, | |
| 495 | })) | |
| 496 | } else { | |
| 497 | None | |
| 498 | }; | |
| 480 | if let Some(consumer) = &mut root_cx.consumer { | |
| 481 | consumer.insert_body( | |
| 482 | def, | |
| 483 | BodyWithBorrowckFacts { | |
| 484 | body: body_owned, | |
| 485 | promoted, | |
| 486 | borrow_set, | |
| 487 | region_inference_context: regioncx, | |
| 488 | location_table: polonius_input.as_ref().map(|_| location_table), | |
| 489 | input_facts: polonius_input, | |
| 490 | output_facts: polonius_output, | |
| 491 | }, | |
| 492 | ); | |
| 493 | } | |
| 499 | 494 | |
| 500 | 495 | debug!("do_mir_borrowck: result = {:#?}", result); |
| 501 | 496 | |
| 502 | (result, body_with_facts) | |
| 497 | result | |
| 503 | 498 | } |
| 504 | 499 | |
| 505 | 500 | fn get_flow_results<'a, 'tcx>( |
compiler/rustc_borrowck/src/nll.rs+2-4| ... | ... | @@ -18,7 +18,6 @@ use rustc_span::sym; |
| 18 | 18 | use tracing::{debug, instrument}; |
| 19 | 19 | |
| 20 | 20 | use crate::borrow_set::BorrowSet; |
| 21 | use crate::consumers::ConsumerOptions; | |
| 22 | 21 | use crate::diagnostics::RegionErrors; |
| 23 | 22 | use crate::handle_placeholders::compute_sccs_applying_placeholder_outlives_constraints; |
| 24 | 23 | use crate::polonius::PoloniusDiagnosticsContext; |
| ... | ... | @@ -83,12 +82,11 @@ pub(crate) fn compute_regions<'tcx>( |
| 83 | 82 | location_table: &PoloniusLocationTable, |
| 84 | 83 | move_data: &MoveData<'tcx>, |
| 85 | 84 | borrow_set: &BorrowSet<'tcx>, |
| 86 | consumer_options: Option<ConsumerOptions>, | |
| 87 | 85 | ) -> NllOutput<'tcx> { |
| 88 | 86 | let is_polonius_legacy_enabled = infcx.tcx.sess.opts.unstable_opts.polonius.is_legacy_enabled(); |
| 89 | let polonius_input = consumer_options.map(|c| c.polonius_input()).unwrap_or_default() | |
| 87 | let polonius_input = root_cx.consumer.as_ref().map_or(false, |c| c.polonius_input()) | |
| 90 | 88 | || is_polonius_legacy_enabled; |
| 91 | let polonius_output = consumer_options.map(|c| c.polonius_output()).unwrap_or_default() | |
| 89 | let polonius_output = root_cx.consumer.as_ref().map_or(false, |c| c.polonius_output()) | |
| 92 | 90 | || is_polonius_legacy_enabled; |
| 93 | 91 | let mut polonius_facts = |
| 94 | 92 | (polonius_input || PoloniusFacts::enabled(infcx.tcx)).then_some(PoloniusFacts::default()); |
compiler/rustc_borrowck/src/root_cx.rs+11-2| ... | ... | @@ -6,6 +6,7 @@ use rustc_middle::ty::{OpaqueHiddenType, Ty, TyCtxt, TypeVisitableExt}; |
| 6 | 6 | use rustc_span::ErrorGuaranteed; |
| 7 | 7 | use smallvec::SmallVec; |
| 8 | 8 | |
| 9 | use crate::consumers::BorrowckConsumer; | |
| 9 | 10 | use crate::{ClosureRegionRequirements, ConcreteOpaqueTypes, PropagatedBorrowCheckResults}; |
| 10 | 11 | |
| 11 | 12 | /// The shared context used by both the root as well as all its nested |
| ... | ... | @@ -16,16 +17,24 @@ pub(super) struct BorrowCheckRootCtxt<'tcx> { |
| 16 | 17 | concrete_opaque_types: ConcreteOpaqueTypes<'tcx>, |
| 17 | 18 | nested_bodies: FxHashMap<LocalDefId, PropagatedBorrowCheckResults<'tcx>>, |
| 18 | 19 | tainted_by_errors: Option<ErrorGuaranteed>, |
| 20 | /// This should be `None` during normal compilation. See [`crate::consumers`] for more | |
| 21 | /// information on how this is used. | |
| 22 | pub(crate) consumer: Option<BorrowckConsumer<'tcx>>, | |
| 19 | 23 | } |
| 20 | 24 | |
| 21 | 25 | impl<'tcx> BorrowCheckRootCtxt<'tcx> { |
| 22 | pub(super) fn new(tcx: TyCtxt<'tcx>, root_def_id: LocalDefId) -> BorrowCheckRootCtxt<'tcx> { | |
| 26 | pub(super) fn new( | |
| 27 | tcx: TyCtxt<'tcx>, | |
| 28 | root_def_id: LocalDefId, | |
| 29 | consumer: Option<BorrowckConsumer<'tcx>>, | |
| 30 | ) -> BorrowCheckRootCtxt<'tcx> { | |
| 23 | 31 | BorrowCheckRootCtxt { |
| 24 | 32 | tcx, |
| 25 | 33 | root_def_id, |
| 26 | 34 | concrete_opaque_types: Default::default(), |
| 27 | 35 | nested_bodies: Default::default(), |
| 28 | 36 | tainted_by_errors: None, |
| 37 | consumer, | |
| 29 | 38 | } |
| 30 | 39 | } |
| 31 | 40 | |
| ... | ... | @@ -71,7 +80,7 @@ impl<'tcx> BorrowCheckRootCtxt<'tcx> { |
| 71 | 80 | self.root_def_id.to_def_id() |
| 72 | 81 | ); |
| 73 | 82 | if !self.nested_bodies.contains_key(&def_id) { |
| 74 | let result = super::do_mir_borrowck(self, def_id, None).0; | |
| 83 | let result = super::do_mir_borrowck(self, def_id); | |
| 75 | 84 | if let Some(prev) = self.nested_bodies.insert(def_id, result) { |
| 76 | 85 | bug!("unexpected previous nested body: {prev:?}"); |
| 77 | 86 | } |
compiler/rustc_errors/src/emitter.rs+1-1| ... | ... | @@ -3526,7 +3526,7 @@ pub fn is_case_difference(sm: &SourceMap, suggested: &str, sp: Span) -> bool { |
| 3526 | 3526 | // All the chars that differ in capitalization are confusable (above): |
| 3527 | 3527 | let confusable = iter::zip(found.chars(), suggested.chars()) |
| 3528 | 3528 | .filter(|(f, s)| f != s) |
| 3529 | .all(|(f, s)| (ascii_confusables.contains(&f) || ascii_confusables.contains(&s))); | |
| 3529 | .all(|(f, s)| ascii_confusables.contains(&f) || ascii_confusables.contains(&s)); | |
| 3530 | 3530 | confusable && found.to_lowercase() == suggested.to_lowercase() |
| 3531 | 3531 | // FIXME: We sometimes suggest the same thing we already have, which is a |
| 3532 | 3532 | // bug, but be defensive against that here. |
compiler/rustc_lint/src/types.rs+4-5| ... | ... | @@ -59,8 +59,7 @@ declare_lint! { |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | declare_lint! { |
| 62 | /// The `overflowing_literals` lint detects literal out of range for its | |
| 63 | /// type. | |
| 62 | /// The `overflowing_literals` lint detects literals out of range for their type. | |
| 64 | 63 | /// |
| 65 | 64 | /// ### Example |
| 66 | 65 | /// |
| ... | ... | @@ -72,9 +71,9 @@ declare_lint! { |
| 72 | 71 | /// |
| 73 | 72 | /// ### Explanation |
| 74 | 73 | /// |
| 75 | /// It is usually a mistake to use a literal that overflows the type where | |
| 76 | /// it is used. Either use a literal that is within range, or change the | |
| 77 | /// type to be within the range of the literal. | |
| 74 | /// It is usually a mistake to use a literal that overflows its type | |
| 75 | /// Change either the literal or its type such that the literal is | |
| 76 | /// within the range of its type. | |
| 78 | 77 | OVERFLOWING_LITERALS, |
| 79 | 78 | Deny, |
| 80 | 79 | "literal out of range for its type" |
compiler/rustc_lint/src/unused.rs+9-1| ... | ... | @@ -1,7 +1,7 @@ |
| 1 | 1 | use std::iter; |
| 2 | 2 | |
| 3 | 3 | use rustc_ast::util::{classify, parser}; |
| 4 | use rustc_ast::{self as ast, ExprKind, HasAttrs as _, StmtKind}; | |
| 4 | use rustc_ast::{self as ast, ExprKind, FnRetTy, HasAttrs as _, StmtKind}; | |
| 5 | 5 | use rustc_attr_data_structures::{AttributeKind, find_attr}; |
| 6 | 6 | use rustc_data_structures::fx::FxHashMap; |
| 7 | 7 | use rustc_errors::{MultiSpan, pluralize}; |
| ... | ... | @@ -599,6 +599,7 @@ enum UnusedDelimsCtx { |
| 599 | 599 | AnonConst, |
| 600 | 600 | MatchArmExpr, |
| 601 | 601 | IndexExpr, |
| 602 | ClosureBody, | |
| 602 | 603 | } |
| 603 | 604 | |
| 604 | 605 | impl From<UnusedDelimsCtx> for &'static str { |
| ... | ... | @@ -620,6 +621,7 @@ impl From<UnusedDelimsCtx> for &'static str { |
| 620 | 621 | UnusedDelimsCtx::ArrayLenExpr | UnusedDelimsCtx::AnonConst => "const expression", |
| 621 | 622 | UnusedDelimsCtx::MatchArmExpr => "match arm expression", |
| 622 | 623 | UnusedDelimsCtx::IndexExpr => "index expression", |
| 624 | UnusedDelimsCtx::ClosureBody => "closure body", | |
| 623 | 625 | } |
| 624 | 626 | } |
| 625 | 627 | } |
| ... | ... | @@ -919,6 +921,11 @@ trait UnusedDelimLint { |
| 919 | 921 | let (args_to_check, ctx) = match *call_or_other { |
| 920 | 922 | Call(_, ref args) => (&args[..], UnusedDelimsCtx::FunctionArg), |
| 921 | 923 | MethodCall(ref call) => (&call.args[..], UnusedDelimsCtx::MethodArg), |
| 924 | Closure(ref closure) | |
| 925 | if matches!(closure.fn_decl.output, FnRetTy::Default(_)) => | |
| 926 | { | |
| 927 | (&[closure.body.clone()][..], UnusedDelimsCtx::ClosureBody) | |
| 928 | } | |
| 922 | 929 | // actual catch-all arm |
| 923 | 930 | _ => { |
| 924 | 931 | return; |
| ... | ... | @@ -1508,6 +1515,7 @@ impl UnusedDelimLint for UnusedBraces { |
| 1508 | 1515 | && (ctx != UnusedDelimsCtx::AnonConst |
| 1509 | 1516 | || (matches!(expr.kind, ast::ExprKind::Lit(_)) |
| 1510 | 1517 | && !expr.span.from_expansion())) |
| 1518 | && ctx != UnusedDelimsCtx::ClosureBody | |
| 1511 | 1519 | && !cx.sess().source_map().is_multiline(value.span) |
| 1512 | 1520 | && value.attrs.is_empty() |
| 1513 | 1521 | && !value.span.from_expansion() |
compiler/rustc_parse/src/parser/item.rs+1-1| ... | ... | @@ -2206,7 +2206,7 @@ impl<'a> Parser<'a> { |
| 2206 | 2206 | |
| 2207 | 2207 | if self.look_ahead(1, |t| *t == token::Bang) && self.look_ahead(2, |t| t.is_ident()) { |
| 2208 | 2208 | return IsMacroRulesItem::Yes { has_bang: true }; |
| 2209 | } else if self.look_ahead(1, |t| (t.is_ident())) { | |
| 2209 | } else if self.look_ahead(1, |t| t.is_ident()) { | |
| 2210 | 2210 | // macro_rules foo |
| 2211 | 2211 | self.dcx().emit_err(errors::MacroRulesMissingBang { |
| 2212 | 2212 | span: macro_rules_span, |
compiler/rustc_resolve/src/build_reduced_graph.rs+19-17| ... | ... | @@ -162,28 +162,30 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { |
| 162 | 162 | } |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | pub(crate) fn get_macro(&mut self, res: Res) -> Option<&MacroData> { | |
| 165 | pub(crate) fn get_macro(&self, res: Res) -> Option<&'ra MacroData> { | |
| 166 | 166 | match res { |
| 167 | 167 | Res::Def(DefKind::Macro(..), def_id) => Some(self.get_macro_by_def_id(def_id)), |
| 168 | Res::NonMacroAttr(_) => Some(&self.non_macro_attr), | |
| 168 | Res::NonMacroAttr(_) => Some(self.non_macro_attr), | |
| 169 | 169 | _ => None, |
| 170 | 170 | } |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | pub(crate) fn get_macro_by_def_id(&mut self, def_id: DefId) -> &MacroData { | |
| 174 | if self.macro_map.contains_key(&def_id) { | |
| 175 | return &self.macro_map[&def_id]; | |
| 176 | } | |
| 177 | ||
| 178 | let loaded_macro = self.cstore().load_macro_untracked(def_id, self.tcx); | |
| 179 | let macro_data = match loaded_macro { | |
| 180 | LoadedMacro::MacroDef { def, ident, attrs, span, edition } => { | |
| 181 | self.compile_macro(&def, ident, &attrs, span, ast::DUMMY_NODE_ID, edition) | |
| 182 | } | |
| 183 | LoadedMacro::ProcMacro(ext) => MacroData::new(Arc::new(ext)), | |
| 184 | }; | |
| 173 | pub(crate) fn get_macro_by_def_id(&self, def_id: DefId) -> &'ra MacroData { | |
| 174 | // Local macros are always compiled. | |
| 175 | match def_id.as_local() { | |
| 176 | Some(local_def_id) => self.local_macro_map[&local_def_id], | |
| 177 | None => *self.extern_macro_map.borrow_mut().entry(def_id).or_insert_with(|| { | |
| 178 | let loaded_macro = self.cstore().load_macro_untracked(def_id, self.tcx); | |
| 179 | let macro_data = match loaded_macro { | |
| 180 | LoadedMacro::MacroDef { def, ident, attrs, span, edition } => { | |
| 181 | self.compile_macro(&def, ident, &attrs, span, ast::DUMMY_NODE_ID, edition) | |
| 182 | } | |
| 183 | LoadedMacro::ProcMacro(ext) => MacroData::new(Arc::new(ext)), | |
| 184 | }; | |
| 185 | 185 | |
| 186 | self.macro_map.entry(def_id).or_insert(macro_data) | |
| 186 | self.arenas.alloc_macro(macro_data) | |
| 187 | }), | |
| 188 | } | |
| 187 | 189 | } |
| 188 | 190 | |
| 189 | 191 | pub(crate) fn build_reduced_graph( |
| ... | ... | @@ -1203,7 +1205,7 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> { |
| 1203 | 1205 | fn insert_unused_macro(&mut self, ident: Ident, def_id: LocalDefId, node_id: NodeId) { |
| 1204 | 1206 | if !ident.as_str().starts_with('_') { |
| 1205 | 1207 | self.r.unused_macros.insert(def_id, (node_id, ident)); |
| 1206 | let nrules = self.r.macro_map[&def_id.to_def_id()].nrules; | |
| 1208 | let nrules = self.r.local_macro_map[&def_id].nrules; | |
| 1207 | 1209 | self.r.unused_macro_rules.insert(node_id, DenseBitSet::new_filled(nrules)); |
| 1208 | 1210 | } |
| 1209 | 1211 | } |
| ... | ... | @@ -1222,7 +1224,7 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> { |
| 1222 | 1224 | Some((macro_kind, ident, span)) => { |
| 1223 | 1225 | let res = Res::Def(DefKind::Macro(macro_kind), def_id.to_def_id()); |
| 1224 | 1226 | let macro_data = MacroData::new(self.r.dummy_ext(macro_kind)); |
| 1225 | self.r.macro_map.insert(def_id.to_def_id(), macro_data); | |
| 1227 | self.r.new_local_macro(def_id, macro_data); | |
| 1226 | 1228 | self.r.proc_macro_stubs.insert(def_id); |
| 1227 | 1229 | (res, ident, span, false) |
| 1228 | 1230 | } |
compiler/rustc_resolve/src/def_collector.rs+1-1| ... | ... | @@ -165,7 +165,7 @@ impl<'a, 'ra, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'ra, 'tcx> { |
| 165 | 165 | self.create_def(i.id, i.kind.ident().map(|ident| ident.name), def_kind, i.span); |
| 166 | 166 | |
| 167 | 167 | if let Some(macro_data) = opt_macro_data { |
| 168 | self.resolver.macro_map.insert(def_id.to_def_id(), macro_data); | |
| 168 | self.resolver.new_local_macro(def_id, macro_data); | |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | self.with_parent(def_id, |this| { |
compiler/rustc_resolve/src/diagnostics.rs+7-2| ... | ... | @@ -1669,9 +1669,14 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { |
| 1669 | 1669 | let mut all_attrs: UnordMap<Symbol, Vec<_>> = UnordMap::default(); |
| 1670 | 1670 | // We're collecting these in a hashmap, and handle ordering the output further down. |
| 1671 | 1671 | #[allow(rustc::potential_query_instability)] |
| 1672 | for (def_id, data) in &self.macro_map { | |
| 1672 | for (def_id, data) in self | |
| 1673 | .local_macro_map | |
| 1674 | .iter() | |
| 1675 | .map(|(local_id, data)| (local_id.to_def_id(), data)) | |
| 1676 | .chain(self.extern_macro_map.borrow().iter().map(|(id, d)| (*id, d))) | |
| 1677 | { | |
| 1673 | 1678 | for helper_attr in &data.ext.helper_attrs { |
| 1674 | let item_name = self.tcx.item_name(*def_id); | |
| 1679 | let item_name = self.tcx.item_name(def_id); | |
| 1675 | 1680 | all_attrs.entry(*helper_attr).or_default().push(item_name); |
| 1676 | 1681 | if helper_attr == &ident.name { |
| 1677 | 1682 | derives.push(item_name); |
compiler/rustc_resolve/src/late/diagnostics.rs+1-2| ... | ... | @@ -328,8 +328,7 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { |
| 328 | 328 | let module_did = mod_prefix.as_ref().and_then(Res::mod_def_id); |
| 329 | 329 | |
| 330 | 330 | let mod_prefix = |
| 331 | mod_prefix.map_or_else(String::new, |res| (format!("{} ", res.descr()))); | |
| 332 | ||
| 331 | mod_prefix.map_or_else(String::new, |res| format!("{} ", res.descr())); | |
| 333 | 332 | (mod_prefix, format!("`{}`", Segment::names_to_string(mod_path)), module_did, None) |
| 334 | 333 | }; |
| 335 | 334 |
compiler/rustc_resolve/src/lib.rs+20-6| ... | ... | @@ -1128,10 +1128,12 @@ pub struct Resolver<'ra, 'tcx> { |
| 1128 | 1128 | builtin_macros: FxHashMap<Symbol, SyntaxExtensionKind>, |
| 1129 | 1129 | registered_tools: &'tcx RegisteredTools, |
| 1130 | 1130 | macro_use_prelude: FxIndexMap<Symbol, NameBinding<'ra>>, |
| 1131 | macro_map: FxHashMap<DefId, MacroData>, | |
| 1131 | local_macro_map: FxHashMap<LocalDefId, &'ra MacroData>, | |
| 1132 | /// Lazily populated cache of macros loaded from external crates. | |
| 1133 | extern_macro_map: RefCell<FxHashMap<DefId, &'ra MacroData>>, | |
| 1132 | 1134 | dummy_ext_bang: Arc<SyntaxExtension>, |
| 1133 | 1135 | dummy_ext_derive: Arc<SyntaxExtension>, |
| 1134 | non_macro_attr: MacroData, | |
| 1136 | non_macro_attr: &'ra MacroData, | |
| 1135 | 1137 | local_macro_def_scopes: FxHashMap<LocalDefId, Module<'ra>>, |
| 1136 | 1138 | ast_transform_scopes: FxHashMap<LocalExpnId, Module<'ra>>, |
| 1137 | 1139 | unused_macros: FxIndexMap<LocalDefId, (NodeId, Ident)>, |
| ... | ... | @@ -1241,6 +1243,7 @@ pub struct ResolverArenas<'ra> { |
| 1241 | 1243 | imports: TypedArena<ImportData<'ra>>, |
| 1242 | 1244 | name_resolutions: TypedArena<RefCell<NameResolution<'ra>>>, |
| 1243 | 1245 | ast_paths: TypedArena<ast::Path>, |
| 1246 | macros: TypedArena<MacroData>, | |
| 1244 | 1247 | dropless: DroplessArena, |
| 1245 | 1248 | } |
| 1246 | 1249 | |
| ... | ... | @@ -1287,7 +1290,7 @@ impl<'ra> ResolverArenas<'ra> { |
| 1287 | 1290 | self.name_resolutions.alloc(Default::default()) |
| 1288 | 1291 | } |
| 1289 | 1292 | fn alloc_macro_rules_scope(&'ra self, scope: MacroRulesScope<'ra>) -> MacroRulesScopeRef<'ra> { |
| 1290 | Interned::new_unchecked(self.dropless.alloc(Cell::new(scope))) | |
| 1293 | self.dropless.alloc(Cell::new(scope)) | |
| 1291 | 1294 | } |
| 1292 | 1295 | fn alloc_macro_rules_binding( |
| 1293 | 1296 | &'ra self, |
| ... | ... | @@ -1298,6 +1301,9 @@ impl<'ra> ResolverArenas<'ra> { |
| 1298 | 1301 | fn alloc_ast_paths(&'ra self, paths: &[ast::Path]) -> &'ra [ast::Path] { |
| 1299 | 1302 | self.ast_paths.alloc_from_iter(paths.iter().cloned()) |
| 1300 | 1303 | } |
| 1304 | fn alloc_macro(&'ra self, macro_data: MacroData) -> &'ra MacroData { | |
| 1305 | self.macros.alloc(macro_data) | |
| 1306 | } | |
| 1301 | 1307 | fn alloc_pattern_spans(&'ra self, spans: impl Iterator<Item = Span>) -> &'ra [Span] { |
| 1302 | 1308 | self.dropless.alloc_from_iter(spans) |
| 1303 | 1309 | } |
| ... | ... | @@ -1540,10 +1546,12 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { |
| 1540 | 1546 | builtin_macros: Default::default(), |
| 1541 | 1547 | registered_tools, |
| 1542 | 1548 | macro_use_prelude: Default::default(), |
| 1543 | macro_map: FxHashMap::default(), | |
| 1549 | local_macro_map: Default::default(), | |
| 1550 | extern_macro_map: Default::default(), | |
| 1544 | 1551 | dummy_ext_bang: Arc::new(SyntaxExtension::dummy_bang(edition)), |
| 1545 | 1552 | dummy_ext_derive: Arc::new(SyntaxExtension::dummy_derive(edition)), |
| 1546 | non_macro_attr: MacroData::new(Arc::new(SyntaxExtension::non_macro_attr(edition))), | |
| 1553 | non_macro_attr: arenas | |
| 1554 | .alloc_macro(MacroData::new(Arc::new(SyntaxExtension::non_macro_attr(edition)))), | |
| 1547 | 1555 | invocation_parent_scopes: Default::default(), |
| 1548 | 1556 | output_macro_rules_scopes: Default::default(), |
| 1549 | 1557 | macro_rules_scopes: Default::default(), |
| ... | ... | @@ -1616,6 +1624,12 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { |
| 1616 | 1624 | ) |
| 1617 | 1625 | } |
| 1618 | 1626 | |
| 1627 | fn new_local_macro(&mut self, def_id: LocalDefId, macro_data: MacroData) -> &'ra MacroData { | |
| 1628 | let mac = self.arenas.alloc_macro(macro_data); | |
| 1629 | self.local_macro_map.insert(def_id, mac); | |
| 1630 | mac | |
| 1631 | } | |
| 1632 | ||
| 1619 | 1633 | fn next_node_id(&mut self) -> NodeId { |
| 1620 | 1634 | let start = self.next_node_id; |
| 1621 | 1635 | let next = start.as_u32().checked_add(1).expect("input too large; ran out of NodeIds"); |
| ... | ... | @@ -1734,7 +1748,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { |
| 1734 | 1748 | f(self, MacroNS); |
| 1735 | 1749 | } |
| 1736 | 1750 | |
| 1737 | fn is_builtin_macro(&mut self, res: Res) -> bool { | |
| 1751 | fn is_builtin_macro(&self, res: Res) -> bool { | |
| 1738 | 1752 | self.get_macro(res).is_some_and(|macro_data| macro_data.ext.builtin_name.is_some()) |
| 1739 | 1753 | } |
| 1740 | 1754 |
compiler/rustc_resolve/src/macros.rs+5-6| ... | ... | @@ -9,7 +9,6 @@ use rustc_ast::expand::StrippedCfgItem; |
| 9 | 9 | use rustc_ast::{self as ast, Crate, NodeId, attr}; |
| 10 | 10 | use rustc_ast_pretty::pprust; |
| 11 | 11 | use rustc_attr_data_structures::StabilityLevel; |
| 12 | use rustc_data_structures::intern::Interned; | |
| 13 | 12 | use rustc_errors::{Applicability, DiagCtxtHandle, StashKey}; |
| 14 | 13 | use rustc_expand::base::{ |
| 15 | 14 | Annotatable, DeriveResolution, Indeterminate, ResolverExpand, SyntaxExtension, |
| ... | ... | @@ -80,7 +79,7 @@ pub(crate) enum MacroRulesScope<'ra> { |
| 80 | 79 | /// This helps to avoid uncontrollable growth of `macro_rules!` scope chains, |
| 81 | 80 | /// which usually grow linearly with the number of macro invocations |
| 82 | 81 | /// in a module (including derives) and hurt performance. |
| 83 | pub(crate) type MacroRulesScopeRef<'ra> = Interned<'ra, Cell<MacroRulesScope<'ra>>>; | |
| 82 | pub(crate) type MacroRulesScopeRef<'ra> = &'ra Cell<MacroRulesScope<'ra>>; | |
| 84 | 83 | |
| 85 | 84 | /// Macro namespace is separated into two sub-namespaces, one for bang macros and |
| 86 | 85 | /// one for attribute-like macros (attributes, derives). |
| ... | ... | @@ -354,8 +353,8 @@ impl<'ra, 'tcx> ResolverExpand for Resolver<'ra, 'tcx> { |
| 354 | 353 | if unused_arms.is_empty() { |
| 355 | 354 | continue; |
| 356 | 355 | } |
| 357 | let def_id = self.local_def_id(node_id).to_def_id(); | |
| 358 | let m = &self.macro_map[&def_id]; | |
| 356 | let def_id = self.local_def_id(node_id); | |
| 357 | let m = &self.local_macro_map[&def_id]; | |
| 359 | 358 | let SyntaxExtensionKind::LegacyBang(ref ext) = m.ext.kind else { |
| 360 | 359 | continue; |
| 361 | 360 | }; |
| ... | ... | @@ -1132,7 +1131,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { |
| 1132 | 1131 | } |
| 1133 | 1132 | } |
| 1134 | 1133 | |
| 1135 | pub(crate) fn check_reserved_macro_name(&mut self, ident: Ident, res: Res) { | |
| 1134 | pub(crate) fn check_reserved_macro_name(&self, ident: Ident, res: Res) { | |
| 1136 | 1135 | // Reserve some names that are not quite covered by the general check |
| 1137 | 1136 | // performed on `Resolver::builtin_attrs`. |
| 1138 | 1137 | if ident.name == sym::cfg || ident.name == sym::cfg_attr { |
| ... | ... | @@ -1148,7 +1147,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { |
| 1148 | 1147 | /// |
| 1149 | 1148 | /// Possibly replace its expander to a pre-defined one for built-in macros. |
| 1150 | 1149 | pub(crate) fn compile_macro( |
| 1151 | &mut self, | |
| 1150 | &self, | |
| 1152 | 1151 | macro_def: &ast::MacroDef, |
| 1153 | 1152 | ident: Ident, |
| 1154 | 1153 | attrs: &[rustc_hir::Attribute], |
library/core/src/marker.rs+5| ... | ... | @@ -210,6 +210,11 @@ pub trait PointeeSized { |
| 210 | 210 | /// - `Trait` is dyn-compatible[^1]. |
| 211 | 211 | /// - The type is sized. |
| 212 | 212 | /// - The type outlives `'a`. |
| 213 | /// - Trait objects `dyn TraitA + AutoA... + 'a` implement `Unsize<dyn TraitB + AutoB... + 'b>` | |
| 214 | /// if all of these conditions are met: | |
| 215 | /// - `TraitB` is a supertrait of `TraitA`. | |
| 216 | /// - `AutoB...` is a subset of `AutoA...`. | |
| 217 | /// - `'a` outlives `'b`. | |
| 213 | 218 | /// - Structs `Foo<..., T1, ..., Tn, ...>` implement `Unsize<Foo<..., U1, ..., Un, ...>>` |
| 214 | 219 | /// where any number of (type and const) parameters may be changed if all of these conditions |
| 215 | 220 | /// are met: |
library/core/src/unicode/unicode_data.rs+1-1| ... | ... | @@ -82,7 +82,7 @@ unsafe fn skip_search<const SOR: usize, const OFFSETS: usize>( |
| 82 | 82 | let needle = needle as u32; |
| 83 | 83 | |
| 84 | 84 | let last_idx = |
| 85 | match short_offset_runs.binary_search_by_key(&(needle << 11), |header| (header.0 << 11)) { | |
| 85 | match short_offset_runs.binary_search_by_key(&(needle << 11), |header| header.0 << 11) { | |
| 86 | 86 | Ok(idx) => idx + 1, |
| 87 | 87 | Err(idx) => idx, |
| 88 | 88 | }; |
library/std/src/sys/fs/unix.rs-1| ... | ... | @@ -1491,7 +1491,6 @@ impl File { |
| 1491 | 1491 | target_os = "redox", |
| 1492 | 1492 | target_os = "espidf", |
| 1493 | 1493 | target_os = "horizon", |
| 1494 | target_os = "vxworks", | |
| 1495 | 1494 | target_os = "nuttx", |
| 1496 | 1495 | )))] |
| 1497 | 1496 | let to_timespec = |time: Option<SystemTime>| match time { |
library/std/src/sys/pal/unix/thread.rs+1-1| ... | ... | @@ -222,7 +222,7 @@ impl Thread { |
| 222 | 222 | |
| 223 | 223 | #[cfg(target_os = "vxworks")] |
| 224 | 224 | pub fn set_name(name: &CStr) { |
| 225 | let mut name = truncate_cstr::<{ libc::VX_TASK_RENAME_LENGTH - 1 }>(name); | |
| 225 | let mut name = truncate_cstr::<{ (libc::VX_TASK_RENAME_LENGTH - 1) as usize }>(name); | |
| 226 | 226 | let res = unsafe { libc::taskNameSet(libc::taskIdSelf(), name.as_mut_ptr()) }; |
| 227 | 227 | debug_assert_eq!(res, libc::OK); |
| 228 | 228 | } |
src/doc/rustc/src/platform-support/wasm32-wasip1.md+1| ... | ... | @@ -42,6 +42,7 @@ said since when this document was last updated those interested in maintaining |
| 42 | 42 | this target are: |
| 43 | 43 | |
| 44 | 44 | [@alexcrichton](https://github.com/alexcrichton) |
| 45 | [@loganek](https://github.com/loganek) | |
| 45 | 46 | |
| 46 | 47 | ## Requirements |
| 47 | 48 |
src/tools/clippy/clippy_lints/src/unused_async.rs+1-1| ... | ... | @@ -169,7 +169,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedAsync { |
| 169 | 169 | let iter = self |
| 170 | 170 | .unused_async_fns |
| 171 | 171 | .iter() |
| 172 | .filter(|UnusedAsyncFn { def_id, .. }| (!self.async_fns_as_value.contains(def_id))); | |
| 172 | .filter(|UnusedAsyncFn { def_id, .. }| !self.async_fns_as_value.contains(def_id)); | |
| 173 | 173 | |
| 174 | 174 | for fun in iter { |
| 175 | 175 | span_lint_hir_and_then( |
src/tools/clippy/clippy_utils/src/ty/mod.rs+2-2| ... | ... | @@ -889,7 +889,7 @@ impl AdtVariantInfo { |
| 889 | 889 | .enumerate() |
| 890 | 890 | .map(|(i, f)| (i, approx_ty_size(cx, f.ty(cx.tcx, subst)))) |
| 891 | 891 | .collect::<Vec<_>>(); |
| 892 | fields_size.sort_by(|(_, a_size), (_, b_size)| (a_size.cmp(b_size))); | |
| 892 | fields_size.sort_by(|(_, a_size), (_, b_size)| a_size.cmp(b_size)); | |
| 893 | 893 | |
| 894 | 894 | Self { |
| 895 | 895 | ind: i, |
| ... | ... | @@ -898,7 +898,7 @@ impl AdtVariantInfo { |
| 898 | 898 | } |
| 899 | 899 | }) |
| 900 | 900 | .collect::<Vec<_>>(); |
| 901 | variants_size.sort_by(|a, b| (b.size.cmp(&a.size))); | |
| 901 | variants_size.sort_by(|a, b| b.size.cmp(&a.size)); | |
| 902 | 902 | variants_size |
| 903 | 903 | } |
| 904 | 904 | } |
src/tools/compiletest/src/runtest.rs+6| ... | ... | @@ -1777,6 +1777,12 @@ impl<'test> TestCx<'test> { |
| 1777 | 1777 | // Allow tests to use internal features. |
| 1778 | 1778 | rustc.args(&["-A", "internal_features"]); |
| 1779 | 1779 | |
| 1780 | // Allow tests to have unused parens and braces. | |
| 1781 | // Add #![deny(unused_parens, unused_braces)] to the test file if you want to | |
| 1782 | // test that these lints are working. | |
| 1783 | rustc.args(&["-A", "unused_parens"]); | |
| 1784 | rustc.args(&["-A", "unused_braces"]); | |
| 1785 | ||
| 1780 | 1786 | if self.props.force_host { |
| 1781 | 1787 | self.maybe_add_external_args(&mut rustc, &self.config.host_rustcflags); |
| 1782 | 1788 | if !is_rustdoc { |
src/tools/run-make-support/CHANGELOG.md deleted-83| ... | ... | @@ -1,83 +0,0 @@ |
| 1 | # Changelog | |
| 2 | ||
| 3 | All notable changes to the `run_make_support` library should be documented in this file. | |
| 4 | ||
| 5 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the support | |
| 6 | library should adhere to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) even if it's | |
| 7 | not intended for public consumption (it's moreso to help internally, to help test writers track | |
| 8 | changes to the support library). | |
| 9 | ||
| 10 | This support library will probably never reach 1.0. Please bump the minor version in `Cargo.toml` if | |
| 11 | you make any breaking changes or other significant changes, or bump the patch version for bug fixes. | |
| 12 | ||
| 13 | ## [0.2.0] - 2024-06-11 | |
| 14 | ||
| 15 | ### Added | |
| 16 | ||
| 17 | - Added `fs_wrapper` module which provides panic-on-fail helpers for their respective `std::fs` | |
| 18 | counterparts, the motivation is to: | |
| 19 | - Reduce littering `.unwrap()` or `.expect()` everywhere for fs operations | |
| 20 | - Help the test writer avoid forgetting to check fs results (even though enforced by | |
| 21 | `-Dunused_must_use`) | |
| 22 | - Provide better panic messages by default | |
| 23 | - Added `path()` helper which creates a `Path` relative to `cwd()` (but is less noisy). | |
| 24 | ||
| 25 | ### Changed | |
| 26 | ||
| 27 | - Marked many functions with `#[must_use]`, and rmake.rs are now compiled with `-Dunused_must_use`. | |
| 28 | ||
| 29 | ## [0.1.0] - 2024-06-09 | |
| 30 | ||
| 31 | ### Changed | |
| 32 | ||
| 33 | - Use *drop bombs* to enforce that commands are executed; a command invocation will panic if it is | |
| 34 | constructed but never executed. Execution methods `Command::{run, run_fail}` will defuse the drop | |
| 35 | bomb. | |
| 36 | - Added `Command` helpers that forward to `std::process::Command` counterparts. | |
| 37 | ||
| 38 | ### Removed | |
| 39 | ||
| 40 | - The `env_var` method which was incorrectly named and is `env_clear` underneath and is a footgun | |
| 41 | from `impl_common_helpers`. For example, removing `TMPDIR` on Unix and `TMP`/`TEMP` breaks | |
| 42 | `std::env::temp_dir` and wrecks anything using that, such as rustc's codgen. | |
| 43 | - Removed `Deref`/`DerefMut` for `run_make_support::Command` -> `std::process::Command` because it | |
| 44 | causes a method chain like `htmldocck().arg().run()` to fail, because `arg()` resolves to | |
| 45 | `std::process::Command` which also returns a `&mut std::process::Command`, causing the `run()` to | |
| 46 | be not found. | |
| 47 | ||
| 48 | ## [0.0.0] - 2024-06-09 | |
| 49 | ||
| 50 | Consider this version to contain all changes made to the support library before we started to track | |
| 51 | changes in this changelog. | |
| 52 | ||
| 53 | ### Added | |
| 54 | ||
| 55 | - Custom command wrappers around `std::process::Command` (`run_make_support::Command`) and custom | |
| 56 | wrapper around `std::process::Output` (`CompletedProcess`) to make it more convenient to work with | |
| 57 | commands and their output, and help avoid forgetting to check for exit status. | |
| 58 | - `Command`: `set_stdin`, `run`, `run_fail`. | |
| 59 | - `CompletedProcess`: `std{err,out}_utf8`, `status`, `assert_std{err,out}_{equals, contains, | |
| 60 | not_contains}`, `assert_exit_code`. | |
| 61 | - `impl_common_helpers` macro to avoid repeating adding common convenience methods, including: | |
| 62 | - Environment manipulation methods: `env`, `env_remove` | |
| 63 | - Command argument providers: `arg`, `args` | |
| 64 | - Common invocation inspection (of the command invocation up until `inspect` is called): | |
| 65 | `inspect` | |
| 66 | - Execution methods: `run` (for commands expected to succeed execution, exit status `0`) and | |
| 67 | `run_fail` (for commands expected to fail execution, exit status non-zero). | |
| 68 | - Command wrappers around: `rustc`, `clang`, `cc`, `rustc`, `rustdoc`, `llvm-readobj`. | |
| 69 | - Thin helpers to construct `python` and `htmldocck` commands. | |
| 70 | - `run` and `run_fail` (like `Command::{run, run_fail}`) for running binaries, which sets suitable | |
| 71 | env vars (like `LD_LIB_PATH` or equivalent, `TARGET_RPATH_ENV`, `PATH` on Windows). | |
| 72 | - Pseudo command `diff` which has similar functionality as the cli util but not the same API. | |
| 73 | - Convenience panic-on-fail helpers `env_var`, `env_var_os`, `cwd` for their `std::env` conterparts. | |
| 74 | - Convenience panic-on-fail helpers for reading respective env vars: `target`, `source_root`. | |
| 75 | - Platform check helpers: `is_windows`, `is_msvc`, `cygpath_windows`, `uname`. | |
| 76 | - fs helpers: `copy_dir_all`. | |
| 77 | - `recursive_diff` helper. | |
| 78 | - Generic `assert_not_contains` helper. | |
| 79 | - Scoped run-with-teardown helper `run_in_tmpdir` which is designed to run commands in a temporary | |
| 80 | directory that is cleared when closure returns. | |
| 81 | - Helpers for constructing the name of binaries and libraries: `rust_lib_name`, `static_lib_name`, | |
| 82 | `bin_name`, `dynamic_lib_name`. | |
| 83 | - Re-export libraries: `gimli`, `object`, `regex`, `wasmparsmer`. |
src/tools/run-make-support/Cargo.toml+15-6| ... | ... | @@ -1,18 +1,27 @@ |
| 1 | 1 | [package] |
| 2 | 2 | name = "run_make_support" |
| 3 | version = "0.2.0" | |
| 4 | edition = "2021" | |
| 3 | version = "0.0.0" | |
| 4 | edition = "2024" | |
| 5 | 5 | |
| 6 | 6 | [dependencies] |
| 7 | ||
| 8 | # These dependencies are either used to implement part of support library | |
| 9 | # functionality, or re-exported to test recipe programs via the support library, | |
| 10 | # or both. | |
| 11 | ||
| 12 | # tidy-alphabetical-start | |
| 7 | 13 | bstr = "1.12" |
| 14 | gimli = "0.32" | |
| 15 | libc = "0.2" | |
| 8 | 16 | object = "0.37" |
| 17 | regex = "1.11" | |
| 18 | serde_json = "1.0" | |
| 9 | 19 | similar = "2.7" |
| 10 | 20 | wasmparser = { version = "0.219", default-features = false, features = ["std"] } |
| 11 | regex = "1.11" | |
| 12 | gimli = "0.32" | |
| 21 | # tidy-alphabetical-end | |
| 22 | ||
| 23 | # Shared with bootstrap and compiletest | |
| 13 | 24 | build_helper = { path = "../../build_helper" } |
| 14 | serde_json = "1.0" | |
| 15 | libc = "0.2" | |
| 16 | 25 | |
| 17 | 26 | [lib] |
| 18 | 27 | crate-type = ["lib", "dylib"] |
src/tools/run-make-support/src/artifact_names.rs+3-3| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | //! libraries which are target-dependent. |
| 3 | 3 | |
| 4 | 4 | use crate::target; |
| 5 | use crate::targets::is_msvc; | |
| 5 | use crate::targets::is_windows_msvc; | |
| 6 | 6 | |
| 7 | 7 | /// Construct the static library name based on the target. |
| 8 | 8 | #[track_caller] |
| ... | ... | @@ -10,7 +10,7 @@ use crate::targets::is_msvc; |
| 10 | 10 | pub fn static_lib_name(name: &str) -> String { |
| 11 | 11 | assert!(!name.contains(char::is_whitespace), "static library name cannot contain whitespace"); |
| 12 | 12 | |
| 13 | if is_msvc() { format!("{name}.lib") } else { format!("lib{name}.a") } | |
| 13 | if is_windows_msvc() { format!("{name}.lib") } else { format!("lib{name}.a") } | |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | /// Construct the dynamic library name based on the target. |
| ... | ... | @@ -45,7 +45,7 @@ pub fn dynamic_lib_extension() -> &'static str { |
| 45 | 45 | #[track_caller] |
| 46 | 46 | #[must_use] |
| 47 | 47 | pub fn msvc_import_dynamic_lib_name(name: &str) -> String { |
| 48 | assert!(is_msvc(), "this function is exclusive to MSVC"); | |
| 48 | assert!(is_windows_msvc(), "this function is exclusive to MSVC"); | |
| 49 | 49 | assert!(!name.contains(char::is_whitespace), "import library name cannot contain whitespace"); |
| 50 | 50 | |
| 51 | 51 | format!("{name}.dll.lib") |
src/tools/run-make-support/src/external_deps/c_build.rs+12-11| ... | ... | @@ -4,7 +4,7 @@ use crate::artifact_names::{dynamic_lib_name, static_lib_name}; |
| 4 | 4 | use crate::external_deps::c_cxx_compiler::{cc, cxx}; |
| 5 | 5 | use crate::external_deps::llvm::llvm_ar; |
| 6 | 6 | use crate::path_helpers::path; |
| 7 | use crate::targets::{is_darwin, is_msvc, is_windows}; | |
| 7 | use crate::targets::{is_darwin, is_windows, is_windows_msvc}; | |
| 8 | 8 | |
| 9 | 9 | // FIXME(Oneirical): These native build functions should take a Path-based generic. |
| 10 | 10 | |
| ... | ... | @@ -24,12 +24,12 @@ pub fn build_native_static_lib_optimized(lib_name: &str) -> PathBuf { |
| 24 | 24 | |
| 25 | 25 | #[track_caller] |
| 26 | 26 | fn build_native_static_lib_internal(lib_name: &str, optimzed: bool) -> PathBuf { |
| 27 | let obj_file = if is_msvc() { format!("{lib_name}") } else { format!("{lib_name}.o") }; | |
| 27 | let obj_file = if is_windows_msvc() { format!("{lib_name}") } else { format!("{lib_name}.o") }; | |
| 28 | 28 | let src = format!("{lib_name}.c"); |
| 29 | 29 | let lib_path = static_lib_name(lib_name); |
| 30 | 30 | |
| 31 | 31 | let mut cc = cc(); |
| 32 | if !is_msvc() { | |
| 32 | if !is_windows_msvc() { | |
| 33 | 33 | cc.arg("-v"); |
| 34 | 34 | } |
| 35 | 35 | if optimzed { |
| ... | ... | @@ -37,7 +37,7 @@ fn build_native_static_lib_internal(lib_name: &str, optimzed: bool) -> PathBuf { |
| 37 | 37 | } |
| 38 | 38 | cc.arg("-c").out_exe(&obj_file).input(src).optimize().run(); |
| 39 | 39 | |
| 40 | let obj_file = if is_msvc() { | |
| 40 | let obj_file = if is_windows_msvc() { | |
| 41 | 41 | PathBuf::from(format!("{lib_name}.obj")) |
| 42 | 42 | } else { |
| 43 | 43 | PathBuf::from(format!("{lib_name}.o")) |
| ... | ... | @@ -50,16 +50,17 @@ fn build_native_static_lib_internal(lib_name: &str, optimzed: bool) -> PathBuf { |
| 50 | 50 | /// [`std::env::consts::DLL_PREFIX`] and [`std::env::consts::DLL_EXTENSION`]. |
| 51 | 51 | #[track_caller] |
| 52 | 52 | pub fn build_native_dynamic_lib(lib_name: &str) -> PathBuf { |
| 53 | let obj_file = if is_msvc() { format!("{lib_name}") } else { format!("{lib_name}.o") }; | |
| 53 | let obj_file = if is_windows_msvc() { format!("{lib_name}") } else { format!("{lib_name}.o") }; | |
| 54 | 54 | let src = format!("{lib_name}.c"); |
| 55 | 55 | let lib_path = dynamic_lib_name(lib_name); |
| 56 | if is_msvc() { | |
| 56 | if is_windows_msvc() { | |
| 57 | 57 | cc().arg("-c").out_exe(&obj_file).input(src).run(); |
| 58 | 58 | } else { |
| 59 | 59 | cc().arg("-v").arg("-c").out_exe(&obj_file).input(src).run(); |
| 60 | 60 | }; |
| 61 | let obj_file = if is_msvc() { format!("{lib_name}.obj") } else { format!("{lib_name}.o") }; | |
| 62 | if is_msvc() { | |
| 61 | let obj_file = | |
| 62 | if is_windows_msvc() { format!("{lib_name}.obj") } else { format!("{lib_name}.o") }; | |
| 63 | if is_windows_msvc() { | |
| 63 | 64 | let out_arg = format!("-out:{lib_path}"); |
| 64 | 65 | cc().input(&obj_file).args(&["-link", "-dll", &out_arg]).run(); |
| 65 | 66 | } else if is_darwin() { |
| ... | ... | @@ -79,15 +80,15 @@ pub fn build_native_dynamic_lib(lib_name: &str) -> PathBuf { |
| 79 | 80 | /// Built from a C++ file. |
| 80 | 81 | #[track_caller] |
| 81 | 82 | pub fn build_native_static_lib_cxx(lib_name: &str) -> PathBuf { |
| 82 | let obj_file = if is_msvc() { format!("{lib_name}") } else { format!("{lib_name}.o") }; | |
| 83 | let obj_file = if is_windows_msvc() { format!("{lib_name}") } else { format!("{lib_name}.o") }; | |
| 83 | 84 | let src = format!("{lib_name}.cpp"); |
| 84 | 85 | let lib_path = static_lib_name(lib_name); |
| 85 | if is_msvc() { | |
| 86 | if is_windows_msvc() { | |
| 86 | 87 | cxx().arg("-EHs").arg("-c").out_exe(&obj_file).input(src).run(); |
| 87 | 88 | } else { |
| 88 | 89 | cxx().arg("-c").out_exe(&obj_file).input(src).run(); |
| 89 | 90 | }; |
| 90 | let obj_file = if is_msvc() { | |
| 91 | let obj_file = if is_windows_msvc() { | |
| 91 | 92 | PathBuf::from(format!("{lib_name}.obj")) |
| 92 | 93 | } else { |
| 93 | 94 | PathBuf::from(format!("{lib_name}.o")) |
src/tools/run-make-support/src/external_deps/c_cxx_compiler/cc.rs+3-3| ... | ... | @@ -1,7 +1,7 @@ |
| 1 | 1 | use std::path::Path; |
| 2 | 2 | |
| 3 | 3 | use crate::command::Command; |
| 4 | use crate::{env_var, is_msvc}; | |
| 4 | use crate::{env_var, is_windows_msvc}; | |
| 5 | 5 | |
| 6 | 6 | /// Construct a new platform-specific C compiler invocation. |
| 7 | 7 | /// |
| ... | ... | @@ -82,7 +82,7 @@ impl Cc { |
| 82 | 82 | pub fn out_exe(&mut self, name: &str) -> &mut Self { |
| 83 | 83 | let mut path = std::path::PathBuf::from(name); |
| 84 | 84 | |
| 85 | if is_msvc() { | |
| 85 | if is_windows_msvc() { | |
| 86 | 86 | path.set_extension("exe"); |
| 87 | 87 | let fe_path = path.clone(); |
| 88 | 88 | path.set_extension(""); |
| ... | ... | @@ -108,7 +108,7 @@ impl Cc { |
| 108 | 108 | /// Optimize the output. |
| 109 | 109 | /// Equivalent to `-O3` for GNU-compatible linkers or `-O2` for MSVC linkers. |
| 110 | 110 | pub fn optimize(&mut self) -> &mut Self { |
| 111 | if is_msvc() { | |
| 111 | if is_windows_msvc() { | |
| 112 | 112 | self.cmd.arg("-O2"); |
| 113 | 113 | } else { |
| 114 | 114 | self.cmd.arg("-O3"); |
src/tools/run-make-support/src/external_deps/c_cxx_compiler/extras.rs+3-3| ... | ... | @@ -1,9 +1,9 @@ |
| 1 | use crate::{is_msvc, is_win7, is_windows, uname}; | |
| 1 | use crate::{is_win7, is_windows, is_windows_msvc, uname}; | |
| 2 | 2 | |
| 3 | 3 | /// `EXTRACFLAGS` |
| 4 | 4 | pub fn extra_c_flags() -> Vec<&'static str> { |
| 5 | 5 | if is_windows() { |
| 6 | if is_msvc() { | |
| 6 | if is_windows_msvc() { | |
| 7 | 7 | let mut libs = |
| 8 | 8 | vec!["ws2_32.lib", "userenv.lib", "bcrypt.lib", "ntdll.lib", "synchronization.lib"]; |
| 9 | 9 | if is_win7() { |
| ... | ... | @@ -29,7 +29,7 @@ pub fn extra_c_flags() -> Vec<&'static str> { |
| 29 | 29 | /// `EXTRACXXFLAGS` |
| 30 | 30 | pub fn extra_cxx_flags() -> Vec<&'static str> { |
| 31 | 31 | if is_windows() { |
| 32 | if is_msvc() { vec![] } else { vec!["-lstdc++"] } | |
| 32 | if is_windows_msvc() { vec![] } else { vec!["-lstdc++"] } | |
| 33 | 33 | } else { |
| 34 | 34 | match &uname()[..] { |
| 35 | 35 | "Darwin" => vec!["-lc++"], |
src/tools/run-make-support/src/external_deps/rustc.rs+2-2| ... | ... | @@ -6,7 +6,7 @@ use crate::command::Command; |
| 6 | 6 | use crate::env::env_var; |
| 7 | 7 | use crate::path_helpers::cwd; |
| 8 | 8 | use crate::util::set_host_compiler_dylib_path; |
| 9 | use crate::{is_aix, is_darwin, is_msvc, is_windows, target, uname}; | |
| 9 | use crate::{is_aix, is_darwin, is_windows, is_windows_msvc, target, uname}; | |
| 10 | 10 | |
| 11 | 11 | /// Construct a new `rustc` invocation. This will automatically set the library |
| 12 | 12 | /// search path as `-L cwd()`. Use [`bare_rustc`] to avoid this. |
| ... | ... | @@ -377,7 +377,7 @@ impl Rustc { |
| 377 | 377 | // So we end up with the following hack: we link use static:-bundle to only |
| 378 | 378 | // link the parts of libstdc++ that we actually use, which doesn't include |
| 379 | 379 | // the dependency on the pthreads DLL. |
| 380 | if !is_msvc() { | |
| 380 | if !is_windows_msvc() { | |
| 381 | 381 | self.cmd.arg("-lstatic:-bundle=stdc++"); |
| 382 | 382 | }; |
| 383 | 383 | } else if is_darwin() { |
src/tools/run-make-support/src/lib.rs+42-66| ... | ... | @@ -3,9 +3,6 @@ |
| 3 | 3 | //! notably is built via cargo: this means that if your test wants some non-trivial utility, such |
| 4 | 4 | //! as `object` or `wasmparser`, they can be re-exported and be made available through this library. |
| 5 | 5 | |
| 6 | // We want to control use declaration ordering and spacing (and preserve use group comments), so | |
| 7 | // skip rustfmt on this file. | |
| 8 | #![cfg_attr(rustfmt, rustfmt::skip)] | |
| 9 | 6 | #![warn(unreachable_pub)] |
| 10 | 7 | |
| 11 | 8 | mod command; |
| ... | ... | @@ -22,8 +19,8 @@ pub mod path_helpers; |
| 22 | 19 | pub mod run; |
| 23 | 20 | pub mod scoped_run; |
| 24 | 21 | pub mod string; |
| 25 | pub mod targets; | |
| 26 | 22 | pub mod symbols; |
| 23 | pub mod targets; | |
| 27 | 24 | |
| 28 | 25 | // Internally we call our fs-related support module as `fs`, but re-export its content as `rfs` |
| 29 | 26 | // to tests to avoid colliding with commonly used `use std::fs;`. |
| ... | ... | @@ -36,77 +33,56 @@ pub mod rfs { |
| 36 | 33 | } |
| 37 | 34 | |
| 38 | 35 | // Re-exports of third-party library crates. |
| 39 | // tidy-alphabetical-start | |
| 40 | pub use bstr; | |
| 41 | pub use gimli; | |
| 42 | pub use libc; | |
| 43 | pub use object; | |
| 44 | pub use regex; | |
| 45 | pub use serde_json; | |
| 46 | pub use similar; | |
| 47 | pub use wasmparser; | |
| 48 | // tidy-alphabetical-end | |
| 36 | pub use {bstr, gimli, libc, object, regex, serde_json, similar, wasmparser}; | |
| 49 | 37 | |
| 50 | // Re-exports of external dependencies. | |
| 51 | pub use external_deps::{ | |
| 52 | cargo, c_build, c_cxx_compiler, clang, htmldocck, llvm, python, rustc, rustdoc | |
| 38 | // Helpers for building names of output artifacts that are potentially target-specific. | |
| 39 | pub use crate::artifact_names::{ | |
| 40 | bin_name, dynamic_lib_extension, dynamic_lib_name, msvc_import_dynamic_lib_name, rust_lib_name, | |
| 41 | static_lib_name, | |
| 53 | 42 | }; |
| 54 | ||
| 55 | // These rely on external dependencies. | |
| 56 | pub use c_cxx_compiler::{Cc, Gcc, cc, cxx, extra_c_flags, extra_cxx_flags, gcc}; | |
| 57 | pub use c_build::{ | |
| 43 | pub use crate::assertion_helpers::{ | |
| 44 | assert_contains, assert_contains_regex, assert_count_is, assert_dirs_are_equal, assert_equals, | |
| 45 | assert_not_contains, assert_not_contains_regex, | |
| 46 | }; | |
| 47 | // `diff` is implemented in terms of the [similar] library. | |
| 48 | // | |
| 49 | // [similar]: https://github.com/mitsuhiko/similar | |
| 50 | pub use crate::diff::{Diff, diff}; | |
| 51 | // Panic-on-fail [`std::env::var`] and [`std::env::var_os`] wrappers. | |
| 52 | pub use crate::env::{env_var, env_var_os, set_current_dir}; | |
| 53 | pub use crate::external_deps::c_build::{ | |
| 58 | 54 | build_native_dynamic_lib, build_native_static_lib, build_native_static_lib_cxx, |
| 59 | 55 | build_native_static_lib_optimized, |
| 60 | 56 | }; |
| 61 | pub use cargo::cargo; | |
| 62 | pub use clang::{clang, Clang}; | |
| 63 | pub use htmldocck::htmldocck; | |
| 64 | pub use llvm::{ | |
| 65 | llvm_ar, llvm_bcanalyzer, llvm_dis, llvm_dwarfdump, llvm_filecheck, llvm_nm, llvm_objcopy, | |
| 66 | llvm_objdump, llvm_profdata, llvm_readobj, LlvmAr, LlvmBcanalyzer, LlvmDis, LlvmDwarfdump, | |
| 67 | LlvmFilecheck, LlvmNm, LlvmObjcopy, LlvmObjdump, LlvmProfdata, LlvmReadobj, | |
| 68 | }; | |
| 69 | pub use python::python_command; | |
| 70 | pub use rustc::{bare_rustc, rustc, rustc_path, Rustc}; | |
| 71 | pub use rustdoc::{bare_rustdoc, rustdoc, Rustdoc}; | |
| 72 | ||
| 73 | /// [`diff`][mod@diff] is implemented in terms of the [similar] library. | |
| 74 | /// | |
| 75 | /// [similar]: https://github.com/mitsuhiko/similar | |
| 76 | pub use diff::{diff, Diff}; | |
| 77 | ||
| 78 | /// Panic-on-fail [`std::env::var`] and [`std::env::var_os`] wrappers. | |
| 79 | pub use env::{env_var, env_var_os, set_current_dir}; | |
| 80 | ||
| 81 | /// Convenience helpers for running binaries and other commands. | |
| 82 | pub use run::{cmd, run, run_fail, run_with_args}; | |
| 83 | ||
| 84 | /// Helpers for checking target information. | |
| 85 | pub use targets::{ | |
| 86 | apple_os, is_aix, is_darwin, is_msvc, is_windows, is_windows_gnu, is_windows_msvc, is_win7, llvm_components_contain, | |
| 87 | target, uname, | |
| 57 | // Re-exports of external dependencies. | |
| 58 | pub use crate::external_deps::c_cxx_compiler::{ | |
| 59 | Cc, Gcc, cc, cxx, extra_c_flags, extra_cxx_flags, gcc, | |
| 88 | 60 | }; |
| 89 | ||
| 90 | /// Helpers for building names of output artifacts that are potentially target-specific. | |
| 91 | pub use artifact_names::{ | |
| 92 | bin_name, dynamic_lib_extension, dynamic_lib_name, msvc_import_dynamic_lib_name, rust_lib_name, | |
| 93 | static_lib_name, | |
| 61 | pub use crate::external_deps::cargo::cargo; | |
| 62 | pub use crate::external_deps::clang::{Clang, clang}; | |
| 63 | pub use crate::external_deps::htmldocck::htmldocck; | |
| 64 | pub use crate::external_deps::llvm::{ | |
| 65 | self, LlvmAr, LlvmBcanalyzer, LlvmDis, LlvmDwarfdump, LlvmFilecheck, LlvmNm, LlvmObjcopy, | |
| 66 | LlvmObjdump, LlvmProfdata, LlvmReadobj, llvm_ar, llvm_bcanalyzer, llvm_dis, llvm_dwarfdump, | |
| 67 | llvm_filecheck, llvm_nm, llvm_objcopy, llvm_objdump, llvm_profdata, llvm_readobj, | |
| 94 | 68 | }; |
| 95 | ||
| 96 | /// Path-related helpers. | |
| 97 | pub use path_helpers::{ | |
| 69 | pub use crate::external_deps::python::python_command; | |
| 70 | pub use crate::external_deps::rustc::{self, Rustc, bare_rustc, rustc, rustc_path}; | |
| 71 | pub use crate::external_deps::rustdoc::{Rustdoc, bare_rustdoc, rustdoc}; | |
| 72 | // Path-related helpers. | |
| 73 | pub use crate::path_helpers::{ | |
| 98 | 74 | build_root, cwd, filename_contains, filename_not_in_denylist, has_extension, has_prefix, |
| 99 | 75 | has_suffix, not_contains, path, shallow_find_directories, shallow_find_files, source_root, |
| 100 | 76 | }; |
| 101 | ||
| 102 | /// Helpers for scoped test execution where certain properties are attempted to be maintained. | |
| 103 | pub use scoped_run::{run_in_tmpdir, test_while_readonly}; | |
| 104 | ||
| 105 | pub use assertion_helpers::{ | |
| 106 | assert_contains, assert_contains_regex, assert_count_is, assert_dirs_are_equal, assert_equals, | |
| 107 | assert_not_contains, assert_not_contains_regex, | |
| 108 | }; | |
| 109 | ||
| 110 | pub use string::{ | |
| 77 | // Convenience helpers for running binaries and other commands. | |
| 78 | pub use crate::run::{cmd, run, run_fail, run_with_args}; | |
| 79 | // Helpers for scoped test execution where certain properties are attempted to be maintained. | |
| 80 | pub use crate::scoped_run::{run_in_tmpdir, test_while_readonly}; | |
| 81 | pub use crate::string::{ | |
| 111 | 82 | count_regex_matches_in_files_with_extension, invalid_utf8_contains, invalid_utf8_not_contains, |
| 112 | 83 | }; |
| 84 | // Helpers for checking target information. | |
| 85 | pub use crate::targets::{ | |
| 86 | apple_os, is_aix, is_darwin, is_win7, is_windows, is_windows_gnu, is_windows_msvc, | |
| 87 | llvm_components_contain, target, uname, | |
| 88 | }; |
src/tools/run-make-support/src/linker.rs+2-2| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 | use regex::Regex; |
| 2 | 2 | |
| 3 | use crate::{Rustc, is_msvc}; | |
| 3 | use crate::{Rustc, is_windows_msvc}; | |
| 4 | 4 | |
| 5 | 5 | /// Asserts that `rustc` uses LLD for linking when executed. |
| 6 | 6 | pub fn assert_rustc_uses_lld(rustc: &mut Rustc) { |
| ... | ... | @@ -22,7 +22,7 @@ pub fn assert_rustc_doesnt_use_lld(rustc: &mut Rustc) { |
| 22 | 22 | |
| 23 | 23 | fn get_stderr_with_linker_messages(rustc: &mut Rustc) -> String { |
| 24 | 24 | // lld-link is used if msvc, otherwise a gnu-compatible lld is used. |
| 25 | let linker_version_flag = if is_msvc() { "--version" } else { "-Wl,-v" }; | |
| 25 | let linker_version_flag = if is_windows_msvc() { "--version" } else { "-Wl,-v" }; | |
| 26 | 26 | |
| 27 | 27 | let output = rustc.arg("-Wlinker-messages").link_arg(linker_version_flag).run(); |
| 28 | 28 | output.stderr_utf8() |
src/tools/run-make-support/src/targets.rs+3-9| ... | ... | @@ -16,10 +16,10 @@ pub fn is_windows() -> bool { |
| 16 | 16 | target().contains("windows") |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | /// Check if target uses msvc. | |
| 19 | /// Check if target is windows-msvc. | |
| 20 | 20 | #[must_use] |
| 21 | pub fn is_msvc() -> bool { | |
| 22 | target().contains("msvc") | |
| 21 | pub fn is_windows_msvc() -> bool { | |
| 22 | target().ends_with("windows-msvc") | |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | /// Check if target is windows-gnu. |
| ... | ... | @@ -28,12 +28,6 @@ pub fn is_windows_gnu() -> bool { |
| 28 | 28 | target().ends_with("windows-gnu") |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | /// Check if target is windows-msvc. | |
| 32 | #[must_use] | |
| 33 | pub fn is_windows_msvc() -> bool { | |
| 34 | target().ends_with("windows-msvc") | |
| 35 | } | |
| 36 | ||
| 37 | 31 | /// Check if target is win7. |
| 38 | 32 | #[must_use] |
| 39 | 33 | pub fn is_win7() -> bool { |
src/tools/rust-analyzer/crates/rust-analyzer/src/cli/scip.rs+1-1| ... | ... | @@ -25,7 +25,7 @@ impl flags::Scip { |
| 25 | 25 | eprintln!("Generating SCIP start..."); |
| 26 | 26 | let now = Instant::now(); |
| 27 | 27 | |
| 28 | let no_progress = &|s| (eprintln!("rust-analyzer: Loading {s}")); | |
| 28 | let no_progress = &|s| eprintln!("rust-analyzer: Loading {s}"); | |
| 29 | 29 | let root = |
| 30 | 30 | vfs::AbsPathBuf::assert_utf8(std::env::current_dir()?.join(&self.path)).normalize(); |
| 31 | 31 |
src/tools/test-float-parse/src/lib.rs+1-1| ... | ... | @@ -340,7 +340,7 @@ fn launch_tests(tests: &mut [TestInfo], cfg: &Config) -> Duration { |
| 340 | 340 | for test in tests.iter_mut() { |
| 341 | 341 | test.progress = Some(ui::Progress::new(test, &mut all_progress_bars)); |
| 342 | 342 | ui::set_panic_hook(&all_progress_bars); |
| 343 | ((test.launch)(test, cfg)); | |
| 343 | (test.launch)(test, cfg); | |
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | start.elapsed() |
src/tools/unicode-table-generator/src/range_search.rs+1-1| ... | ... | @@ -80,7 +80,7 @@ unsafe fn skip_search<const SOR: usize, const OFFSETS: usize>( |
| 80 | 80 | let needle = needle as u32; |
| 81 | 81 | |
| 82 | 82 | let last_idx = |
| 83 | match short_offset_runs.binary_search_by_key(&(needle << 11), |header| (header.0 << 11)) { | |
| 83 | match short_offset_runs.binary_search_by_key(&(needle << 11), |header| header.0 << 11) { | |
| 84 | 84 | Ok(idx) => idx + 1, |
| 85 | 85 | Err(idx) => idx, |
| 86 | 86 | }; |
tests/run-make/archive-duplicate-names/rmake.rs+4-4| ... | ... | @@ -6,7 +6,7 @@ |
| 6 | 6 | //@ ignore-cross-compile |
| 7 | 7 | // Reason: the compiled binary is executed |
| 8 | 8 | |
| 9 | use run_make_support::{cc, is_msvc, llvm_ar, rfs, run, rustc}; | |
| 9 | use run_make_support::{cc, is_windows_msvc, llvm_ar, rfs, run, rustc}; | |
| 10 | 10 | |
| 11 | 11 | fn main() { |
| 12 | 12 | rfs::create_dir("a"); |
| ... | ... | @@ -15,7 +15,7 @@ fn main() { |
| 15 | 15 | compile_obj_force_foo("b", "bar"); |
| 16 | 16 | let mut ar = llvm_ar(); |
| 17 | 17 | ar.obj_to_ar().arg("libfoo.a"); |
| 18 | if is_msvc() { | |
| 18 | if is_windows_msvc() { | |
| 19 | 19 | ar.arg("a/foo.obj").arg("b/foo.obj").run(); |
| 20 | 20 | } else { |
| 21 | 21 | ar.arg("a/foo.o").arg("b/foo.o").run(); |
| ... | ... | @@ -27,9 +27,9 @@ fn main() { |
| 27 | 27 | |
| 28 | 28 | #[track_caller] |
| 29 | 29 | pub fn compile_obj_force_foo(dir: &str, lib_name: &str) { |
| 30 | let obj_file = if is_msvc() { format!("{dir}/foo") } else { format!("{dir}/foo.o") }; | |
| 30 | let obj_file = if is_windows_msvc() { format!("{dir}/foo") } else { format!("{dir}/foo.o") }; | |
| 31 | 31 | let src = format!("{lib_name}.c"); |
| 32 | if is_msvc() { | |
| 32 | if is_windows_msvc() { | |
| 33 | 33 | cc().arg("-c").out_exe(&obj_file).input(src).run(); |
| 34 | 34 | } else { |
| 35 | 35 | cc().arg("-v").arg("-c").out_exe(&obj_file).input(src).run(); |
tests/run-make/c-link-to-rust-dylib/rmake.rs+4-2| ... | ... | @@ -3,12 +3,14 @@ |
| 3 | 3 | |
| 4 | 4 | //@ ignore-cross-compile |
| 5 | 5 | |
| 6 | use run_make_support::{cc, cwd, dynamic_lib_extension, is_msvc, rfs, run, run_fail, rustc}; | |
| 6 | use run_make_support::{ | |
| 7 | cc, cwd, dynamic_lib_extension, is_windows_msvc, rfs, run, run_fail, rustc, | |
| 8 | }; | |
| 7 | 9 | |
| 8 | 10 | fn main() { |
| 9 | 11 | rustc().input("foo.rs").run(); |
| 10 | 12 | |
| 11 | if is_msvc() { | |
| 13 | if is_windows_msvc() { | |
| 12 | 14 | let lib = "foo.dll.lib"; |
| 13 | 15 | |
| 14 | 16 | cc().input("bar.c").arg(lib).out_exe("bar").run(); |
tests/run-make/c-unwind-abi-catch-lib-panic/rmake.rs+3-3| ... | ... | @@ -8,11 +8,11 @@ |
| 8 | 8 | //@ needs-unwind |
| 9 | 9 | // Reason: this test exercises unwinding a panic |
| 10 | 10 | |
| 11 | use run_make_support::{cc, is_msvc, llvm_ar, run, rustc, static_lib_name}; | |
| 11 | use run_make_support::{cc, is_windows_msvc, llvm_ar, run, rustc, static_lib_name}; | |
| 12 | 12 | |
| 13 | 13 | fn main() { |
| 14 | 14 | // Compile `add.c` into an object file. |
| 15 | if is_msvc() { | |
| 15 | if is_windows_msvc() { | |
| 16 | 16 | cc().arg("-c").out_exe("add").input("add.c").run(); |
| 17 | 17 | } else { |
| 18 | 18 | cc().arg("-v").arg("-c").out_exe("add.o").input("add.c").run(); |
| ... | ... | @@ -24,7 +24,7 @@ fn main() { |
| 24 | 24 | rustc().emit("obj").input("panic.rs").run(); |
| 25 | 25 | |
| 26 | 26 | // Now, create an archive using these two objects. |
| 27 | if is_msvc() { | |
| 27 | if is_windows_msvc() { | |
| 28 | 28 | llvm_ar().obj_to_ar().args(&[&static_lib_name("add"), "add.obj", "panic.o"]).run(); |
| 29 | 29 | } else { |
| 30 | 30 | llvm_ar().obj_to_ar().args(&[&static_lib_name("add"), "add.o", "panic.o"]).run(); |
tests/run-make/cdylib-dylib-linkage/rmake.rs+2-2| ... | ... | @@ -9,7 +9,7 @@ |
| 9 | 9 | |
| 10 | 10 | use run_make_support::{ |
| 11 | 11 | bin_name, cc, dynamic_lib_extension, dynamic_lib_name, filename_contains, has_extension, |
| 12 | has_prefix, has_suffix, is_msvc, msvc_import_dynamic_lib_name, path, run, rustc, | |
| 12 | has_prefix, has_suffix, is_windows_msvc, msvc_import_dynamic_lib_name, path, run, rustc, | |
| 13 | 13 | shallow_find_files, target, |
| 14 | 14 | }; |
| 15 | 15 | |
| ... | ... | @@ -19,7 +19,7 @@ fn main() { |
| 19 | 19 | let sysroot = rustc().print("sysroot").run().stdout_utf8(); |
| 20 | 20 | let sysroot = sysroot.trim(); |
| 21 | 21 | let target_sysroot = path(sysroot).join("lib/rustlib").join(target()).join("lib"); |
| 22 | if is_msvc() { | |
| 22 | if is_windows_msvc() { | |
| 23 | 23 | let mut libs = shallow_find_files(&target_sysroot, |path| { |
| 24 | 24 | has_prefix(path, "libstd-") && has_suffix(path, ".dll.lib") |
| 25 | 25 | }); |
tests/run-make/cdylib/rmake.rs+2-2| ... | ... | @@ -10,13 +10,13 @@ |
| 10 | 10 | |
| 11 | 11 | //@ ignore-cross-compile |
| 12 | 12 | |
| 13 | use run_make_support::{cc, cwd, dynamic_lib_name, is_msvc, rfs, run, rustc}; | |
| 13 | use run_make_support::{cc, cwd, dynamic_lib_name, is_windows_msvc, rfs, run, rustc}; | |
| 14 | 14 | |
| 15 | 15 | fn main() { |
| 16 | 16 | rustc().input("bar.rs").run(); |
| 17 | 17 | rustc().input("foo.rs").run(); |
| 18 | 18 | |
| 19 | if is_msvc() { | |
| 19 | if is_windows_msvc() { | |
| 20 | 20 | cc().input("foo.c").arg("foo.dll.lib").out_exe("foo").run(); |
| 21 | 21 | } else { |
| 22 | 22 | cc().input("foo.c").arg("-lfoo").library_search_path(cwd()).output("foo").run(); |
tests/run-make/compiler-rt-works-on-mingw/rmake.rs+1-1| ... | ... | @@ -5,7 +5,7 @@ |
| 5 | 5 | |
| 6 | 6 | //@ only-windows-gnu |
| 7 | 7 | |
| 8 | use run_make_support::{cxx, is_msvc, llvm_ar, run, rustc, static_lib_name}; | |
| 8 | use run_make_support::{cxx, llvm_ar, run, rustc, static_lib_name}; | |
| 9 | 9 | |
| 10 | 10 | fn main() { |
| 11 | 11 | cxx().input("foo.cpp").arg("-c").out_exe("foo.o").run(); |
tests/run-make/link-args-order/rmake.rs+2-2| ... | ... | @@ -6,10 +6,10 @@ |
| 6 | 6 | // checks that linker arguments remain intact and in the order they were originally passed in. |
| 7 | 7 | // See https://github.com/rust-lang/rust/pull/70665 |
| 8 | 8 | |
| 9 | use run_make_support::{is_msvc, rustc}; | |
| 9 | use run_make_support::{is_windows_msvc, rustc}; | |
| 10 | 10 | |
| 11 | 11 | fn main() { |
| 12 | let linker = if is_msvc() { "msvc" } else { "ld" }; | |
| 12 | let linker = if is_windows_msvc() { "msvc" } else { "ld" }; | |
| 13 | 13 | |
| 14 | 14 | rustc() |
| 15 | 15 | .input("empty.rs") |
tests/run-make/link-dedup/rmake.rs+2-2| ... | ... | @@ -9,7 +9,7 @@ |
| 9 | 9 | |
| 10 | 10 | use std::fmt::Write; |
| 11 | 11 | |
| 12 | use run_make_support::{is_msvc, rustc, target}; | |
| 12 | use run_make_support::{is_windows_msvc, rustc, target}; | |
| 13 | 13 | |
| 14 | 14 | fn main() { |
| 15 | 15 | rustc().input("depa.rs").run(); |
| ... | ... | @@ -32,7 +32,7 @@ fn main() { |
| 32 | 32 | fn needle_from_libs(libs: &[&str]) -> String { |
| 33 | 33 | let mut needle = String::new(); |
| 34 | 34 | for lib in libs { |
| 35 | if is_msvc() { | |
| 35 | if is_windows_msvc() { | |
| 36 | 36 | needle.write_fmt(format_args!(r#""{lib}.lib" "#)).unwrap(); |
| 37 | 37 | } else if target().contains("wasm") { |
| 38 | 38 | needle.write_fmt(format_args!(r#""-l" "{lib}" "#)).unwrap(); |
tests/run-make/native-link-modifier-bundle/rmake.rs+2-2| ... | ... | @@ -20,7 +20,7 @@ |
| 20 | 20 | // Reason: cross-compilation fails to export native symbols |
| 21 | 21 | |
| 22 | 22 | use run_make_support::{ |
| 23 | build_native_static_lib, dynamic_lib_name, is_msvc, llvm_nm, rust_lib_name, rustc, | |
| 23 | build_native_static_lib, dynamic_lib_name, is_windows_msvc, llvm_nm, rust_lib_name, rustc, | |
| 24 | 24 | static_lib_name, |
| 25 | 25 | }; |
| 26 | 26 | |
| ... | ... | @@ -60,7 +60,7 @@ fn main() { |
| 60 | 60 | .assert_stdout_contains_regex("U _*native_func"); |
| 61 | 61 | |
| 62 | 62 | // This part of the test does not function on Windows MSVC - no symbols are printed. |
| 63 | if !is_msvc() { | |
| 63 | if !is_windows_msvc() { | |
| 64 | 64 | // Build a cdylib, `native-staticlib` will not appear on the linker line because it was |
| 65 | 65 | // bundled previously. The cdylib will contain the `native_func` symbol in the end. |
| 66 | 66 | rustc() |
tests/run-make/native-link-modifier-whole-archive/rmake.rs+3-3| ... | ... | @@ -10,11 +10,11 @@ |
| 10 | 10 | // Reason: compiling C++ code does not work well when cross-compiling |
| 11 | 11 | // plus, the compiled binary is executed |
| 12 | 12 | |
| 13 | use run_make_support::{cxx, is_msvc, llvm_ar, run, run_with_args, rustc, static_lib_name}; | |
| 13 | use run_make_support::{cxx, is_windows_msvc, llvm_ar, run, run_with_args, rustc, static_lib_name}; | |
| 14 | 14 | |
| 15 | 15 | fn main() { |
| 16 | 16 | let mut cxx = cxx(); |
| 17 | if is_msvc() { | |
| 17 | if is_windows_msvc() { | |
| 18 | 18 | cxx.arg("-EHs"); |
| 19 | 19 | } |
| 20 | 20 | cxx.input("c_static_lib_with_constructor.cpp") |
| ... | ... | @@ -24,7 +24,7 @@ fn main() { |
| 24 | 24 | |
| 25 | 25 | let mut llvm_ar = llvm_ar(); |
| 26 | 26 | llvm_ar.obj_to_ar(); |
| 27 | if is_msvc() { | |
| 27 | if is_windows_msvc() { | |
| 28 | 28 | llvm_ar |
| 29 | 29 | .output_input( |
| 30 | 30 | static_lib_name("c_static_lib_with_constructor"), |
tests/run-make/pointer-auth-link-with-c/rmake.rs+3-3| ... | ... | @@ -9,7 +9,7 @@ |
| 9 | 9 | //@ ignore-cross-compile |
| 10 | 10 | // Reason: the compiled binary is executed |
| 11 | 11 | |
| 12 | use run_make_support::{build_native_static_lib, cc, is_msvc, llvm_ar, run, rustc}; | |
| 12 | use run_make_support::{build_native_static_lib, cc, is_windows_msvc, llvm_ar, run, rustc}; | |
| 13 | 13 | |
| 14 | 14 | fn main() { |
| 15 | 15 | build_native_static_lib("test"); |
| ... | ... | @@ -21,7 +21,7 @@ fn main() { |
| 21 | 21 | .input("test.c") |
| 22 | 22 | .arg("-mbranch-protection=bti+pac-ret+leaf") |
| 23 | 23 | .run(); |
| 24 | let obj_file = if is_msvc() { "test.obj" } else { "test" }; | |
| 24 | let obj_file = if is_windows_msvc() { "test.obj" } else { "test" }; | |
| 25 | 25 | llvm_ar().obj_to_ar().output_input("libtest.a", &obj_file).run(); |
| 26 | 26 | rustc().arg("-Zbranch-protection=bti,pac-ret,leaf").input("test.rs").run(); |
| 27 | 27 | run("test"); |
| ... | ... | @@ -33,7 +33,7 @@ fn main() { |
| 33 | 33 | // .input("test.c") |
| 34 | 34 | // .arg("-mbranch-protection=bti+pac-ret+pc+leaf") |
| 35 | 35 | // .run(); |
| 36 | // let obj_file = if is_msvc() { "test.obj" } else { "test" }; | |
| 36 | // let obj_file = if is_windows_msvc() { "test.obj" } else { "test" }; | |
| 37 | 37 | // llvm_ar().obj_to_ar().output_input("libtest.a", &obj_file).run(); |
| 38 | 38 | // rustc().arg("-Zbranch-protection=bti,pac-ret,pc,leaf").input("test.rs").run(); |
| 39 | 39 | // run("test"); |
tests/run-make/print-native-static-libs/rmake.rs+3-3| ... | ... | @@ -12,7 +12,7 @@ |
| 12 | 12 | //@ ignore-cross-compile |
| 13 | 13 | //@ ignore-wasm |
| 14 | 14 | |
| 15 | use run_make_support::{is_msvc, rustc}; | |
| 15 | use run_make_support::{is_windows_msvc, rustc}; | |
| 16 | 16 | |
| 17 | 17 | fn main() { |
| 18 | 18 | // build supporting crate |
| ... | ... | @@ -41,9 +41,9 @@ fn main() { |
| 41 | 41 | ($lib:literal in $args:ident) => {{ |
| 42 | 42 | let lib = format!( |
| 43 | 43 | "{}{}{}", |
| 44 | if !is_msvc() { "-l" } else { "" }, | |
| 44 | if !is_windows_msvc() { "-l" } else { "" }, | |
| 45 | 45 | $lib, |
| 46 | if !is_msvc() { "" } else { ".lib" }, | |
| 46 | if !is_windows_msvc() { "" } else { ".lib" }, | |
| 47 | 47 | ); |
| 48 | 48 | let found = $args.contains(&&*lib); |
| 49 | 49 | assert!(found, "unable to find lib `{}` in those linker args: {:?}", lib, $args); |
tests/run-make/raw-dylib-alt-calling-convention/rmake.rs+4-2| ... | ... | @@ -9,7 +9,9 @@ |
| 9 | 9 | //@ only-x86 |
| 10 | 10 | //@ only-windows |
| 11 | 11 | |
| 12 | use run_make_support::{build_native_dynamic_lib, diff, is_msvc, run, run_with_args, rustc}; | |
| 12 | use run_make_support::{ | |
| 13 | build_native_dynamic_lib, diff, is_windows_msvc, run, run_with_args, rustc, | |
| 14 | }; | |
| 13 | 15 | |
| 14 | 16 | fn main() { |
| 15 | 17 | rustc() |
| ... | ... | @@ -21,7 +23,7 @@ fn main() { |
| 21 | 23 | build_native_dynamic_lib("extern"); |
| 22 | 24 | let out = run("driver").stdout_utf8(); |
| 23 | 25 | diff().expected_file("output.txt").actual_text("actual", out).normalize(r#"\r"#, "").run(); |
| 24 | if is_msvc() { | |
| 26 | if is_windows_msvc() { | |
| 25 | 27 | let out_msvc = run_with_args("driver", &["true"]).stdout_utf8(); |
| 26 | 28 | diff() |
| 27 | 29 | .expected_file("output.msvc.txt") |
tests/run-make/raw-dylib-import-name-type/rmake.rs+2-2| ... | ... | @@ -11,14 +11,14 @@ |
| 11 | 11 | //@ only-windows |
| 12 | 12 | // Reason: this test specifically exercises a 32bit Windows calling convention. |
| 13 | 13 | |
| 14 | use run_make_support::{cc, diff, is_msvc, run, rustc}; | |
| 14 | use run_make_support::{cc, diff, is_windows_msvc, run, rustc}; | |
| 15 | 15 | |
| 16 | 16 | // NOTE: build_native_dynamic lib is not used, as the special `def` files |
| 17 | 17 | // must be passed to the CC compiler. |
| 18 | 18 | |
| 19 | 19 | fn main() { |
| 20 | 20 | rustc().crate_type("bin").input("driver.rs").run(); |
| 21 | if is_msvc() { | |
| 21 | if is_windows_msvc() { | |
| 22 | 22 | cc().arg("-c").out_exe("extern").input("extern.c").run(); |
| 23 | 23 | cc().input("extern.obj") |
| 24 | 24 | .arg("extern.msvc.def") |
tests/run-make/raw-dylib-inline-cross-dylib/rmake.rs+2-2| ... | ... | @@ -7,7 +7,7 @@ |
| 7 | 7 | |
| 8 | 8 | //@ only-windows |
| 9 | 9 | |
| 10 | use run_make_support::{cc, diff, is_msvc, llvm_objdump, run, rustc}; | |
| 10 | use run_make_support::{cc, diff, is_windows_msvc, llvm_objdump, run, rustc}; | |
| 11 | 11 | |
| 12 | 12 | fn main() { |
| 13 | 13 | rustc() |
| ... | ... | @@ -31,7 +31,7 @@ fn main() { |
| 31 | 31 | .assert_stdout_not_contains("inline_library_function") |
| 32 | 32 | // Make sure we do find an import to the functions we expect to be imported. |
| 33 | 33 | .assert_stdout_contains("library_function"); |
| 34 | if is_msvc() { | |
| 34 | if is_windows_msvc() { | |
| 35 | 35 | cc().arg("-c").out_exe("extern_1").input("extern_1.c").run(); |
| 36 | 36 | cc().arg("-c").out_exe("extern_2").input("extern_2.c").run(); |
| 37 | 37 | cc().input("extern_1.obj") |
tests/run-make/raw-dylib-link-ordinal/rmake.rs+2-2| ... | ... | @@ -11,7 +11,7 @@ |
| 11 | 11 | |
| 12 | 12 | //@ only-windows |
| 13 | 13 | |
| 14 | use run_make_support::{cc, diff, is_msvc, run, rustc}; | |
| 14 | use run_make_support::{cc, diff, is_windows_msvc, run, rustc}; | |
| 15 | 15 | |
| 16 | 16 | // NOTE: build_native_dynamic lib is not used, as the special `def` files |
| 17 | 17 | // must be passed to the CC compiler. |
| ... | ... | @@ -19,7 +19,7 @@ use run_make_support::{cc, diff, is_msvc, run, rustc}; |
| 19 | 19 | fn main() { |
| 20 | 20 | rustc().crate_type("lib").crate_name("raw_dylib_test").input("lib.rs").run(); |
| 21 | 21 | rustc().crate_type("bin").input("driver.rs").run(); |
| 22 | if is_msvc() { | |
| 22 | if is_windows_msvc() { | |
| 23 | 23 | cc().arg("-c").out_exe("exporter").input("exporter.c").run(); |
| 24 | 24 | cc().input("exporter.obj") |
| 25 | 25 | .arg("exporter.def") |
tests/run-make/raw-dylib-stdcall-ordinal/rmake.rs+2-2| ... | ... | @@ -10,7 +10,7 @@ |
| 10 | 10 | //@ only-windows |
| 11 | 11 | // Reason: this test specifically exercises a 32bit Windows calling convention. |
| 12 | 12 | |
| 13 | use run_make_support::{cc, diff, is_msvc, run, rustc}; | |
| 13 | use run_make_support::{cc, diff, is_windows_msvc, run, rustc}; | |
| 14 | 14 | |
| 15 | 15 | // NOTE: build_native_dynamic lib is not used, as the special `def` files |
| 16 | 16 | // must be passed to the CC compiler. |
| ... | ... | @@ -18,7 +18,7 @@ use run_make_support::{cc, diff, is_msvc, run, rustc}; |
| 18 | 18 | fn main() { |
| 19 | 19 | rustc().crate_type("lib").crate_name("raw_dylib_test").input("lib.rs").run(); |
| 20 | 20 | rustc().crate_type("bin").input("driver.rs").run(); |
| 21 | if is_msvc() { | |
| 21 | if is_windows_msvc() { | |
| 22 | 22 | cc().arg("-c").out_exe("exporter").input("exporter.c").run(); |
| 23 | 23 | cc().input("exporter.obj") |
| 24 | 24 | .arg("exporter-msvc.def") |
tests/run-make/rlib-format-packed-bundled-libs/rmake.rs+3-3| ... | ... | @@ -8,8 +8,8 @@ |
| 8 | 8 | // Reason: cross-compilation fails to export native symbols |
| 9 | 9 | |
| 10 | 10 | use run_make_support::{ |
| 11 | bin_name, build_native_static_lib, cwd, filename_contains, is_msvc, llvm_ar, llvm_nm, rfs, | |
| 12 | rust_lib_name, rustc, shallow_find_files, | |
| 11 | bin_name, build_native_static_lib, cwd, filename_contains, is_windows_msvc, llvm_ar, llvm_nm, | |
| 12 | rfs, rust_lib_name, rustc, shallow_find_files, | |
| 13 | 13 | }; |
| 14 | 14 | |
| 15 | 15 | fn main() { |
| ... | ... | @@ -74,7 +74,7 @@ fn main() { |
| 74 | 74 | .assert_stdout_contains_regex("native_dep_1.*native_dep_2.*native_dep_3"); |
| 75 | 75 | |
| 76 | 76 | // The binary "main" will not contain any symbols on MSVC. |
| 77 | if !is_msvc() { | |
| 77 | if !is_windows_msvc() { | |
| 78 | 78 | llvm_nm().input(bin_name("main")).run().assert_stdout_contains_regex("T.*native_f1"); |
| 79 | 79 | llvm_nm().input(bin_name("main")).run().assert_stdout_contains_regex("T.*native_f2"); |
| 80 | 80 | llvm_nm().input(bin_name("main")).run().assert_stdout_contains_regex("T.*native_f3"); |
tests/run-make/split-debuginfo/rmake.rs+3-3| ... | ... | @@ -61,8 +61,8 @@ use std::collections::BTreeSet; |
| 61 | 61 | |
| 62 | 62 | use run_make_support::rustc::Rustc; |
| 63 | 63 | use run_make_support::{ |
| 64 | cwd, has_extension, is_darwin, is_msvc, is_windows, llvm_dwarfdump, run_in_tmpdir, rustc, | |
| 65 | shallow_find_directories, shallow_find_files, uname, | |
| 64 | cwd, has_extension, is_darwin, is_windows, is_windows_msvc, llvm_dwarfdump, run_in_tmpdir, | |
| 65 | rustc, shallow_find_directories, shallow_find_files, uname, | |
| 66 | 66 | }; |
| 67 | 67 | |
| 68 | 68 | /// `-C debuginfo`. See <https://doc.rust-lang.org/rustc/codegen-options/index.html#debuginfo>. |
| ... | ... | @@ -1296,7 +1296,7 @@ fn main() { |
| 1296 | 1296 | // identify which combination isn't exercised with a 6-layers nested for loop iterating through |
| 1297 | 1297 | // each of the cli flag enum variants. |
| 1298 | 1298 | |
| 1299 | if is_msvc() { | |
| 1299 | if is_windows_msvc() { | |
| 1300 | 1300 | // FIXME: the windows-msvc test coverage is sparse at best. |
| 1301 | 1301 | |
| 1302 | 1302 | windows_msvc_tests::split_debuginfo(SplitDebuginfo::Off, DebuginfoLevel::Unspecified); |
tests/run-make/static-dylib-by-default/rmake.rs+3-3| ... | ... | @@ -9,7 +9,7 @@ |
| 9 | 9 | // Reason: the compiled binary is executed |
| 10 | 10 | |
| 11 | 11 | use run_make_support::{ |
| 12 | cc, cwd, dynamic_lib_name, extra_c_flags, has_extension, is_msvc, rfs, run, rustc, | |
| 12 | cc, cwd, dynamic_lib_name, extra_c_flags, has_extension, is_windows_msvc, rfs, run, rustc, | |
| 13 | 13 | shallow_find_files, |
| 14 | 14 | }; |
| 15 | 15 | |
| ... | ... | @@ -22,13 +22,13 @@ fn main() { |
| 22 | 22 | // bar.dll.exp // export library for the dylib |
| 23 | 23 | // msvc's underlying link.exe requires the import library for the dynamic library as input. |
| 24 | 24 | // That is why the library is bar.dll.lib, not bar.dll. |
| 25 | let library = if is_msvc() { "bar.dll.lib" } else { &dynamic_lib_name("bar") }; | |
| 25 | let library = if is_windows_msvc() { "bar.dll.lib" } else { &dynamic_lib_name("bar") }; | |
| 26 | 26 | cc().input("main.c").out_exe("main").arg(library).args(extra_c_flags()).run(); |
| 27 | 27 | for rlib in shallow_find_files(cwd(), |path| has_extension(path, "rlib")) { |
| 28 | 28 | rfs::remove_file(rlib); |
| 29 | 29 | } |
| 30 | 30 | rfs::remove_file(dynamic_lib_name("foo")); |
| 31 | if is_msvc() { | |
| 31 | if is_windows_msvc() { | |
| 32 | 32 | rfs::remove_file("foo.dll.lib"); |
| 33 | 33 | } |
| 34 | 34 | run("main"); |
tests/run-make/staticlib-dylib-linkage/rmake.rs+2-2| ... | ... | @@ -9,7 +9,7 @@ |
| 9 | 9 | //@ ignore-wasm |
| 10 | 10 | // Reason: WASM does not support dynamic libraries |
| 11 | 11 | |
| 12 | use run_make_support::{cc, is_msvc, regex, run, rustc, static_lib_name}; | |
| 12 | use run_make_support::{cc, is_windows_msvc, regex, run, rustc, static_lib_name}; | |
| 13 | 13 | |
| 14 | 14 | fn main() { |
| 15 | 15 | rustc().arg("-Cprefer-dynamic").input("bar.rs").run(); |
| ... | ... | @@ -27,7 +27,7 @@ fn main() { |
| 27 | 27 | let (_, native_link_args) = libs.split_once("note: native-static-libs: ").unwrap(); |
| 28 | 28 | // divide the command-line arguments in a vec |
| 29 | 29 | let mut native_link_args = native_link_args.split(' ').collect::<Vec<&str>>(); |
| 30 | if is_msvc() { | |
| 30 | if is_windows_msvc() { | |
| 31 | 31 | // For MSVC pass the arguments on to the linker. |
| 32 | 32 | native_link_args.insert(0, "-link"); |
| 33 | 33 | } |
tests/run-make/symbol-visibility/rmake.rs+3-3| ... | ... | @@ -9,7 +9,7 @@ |
| 9 | 9 | // See https://github.com/rust-lang/rust/issues/37530 |
| 10 | 10 | |
| 11 | 11 | use run_make_support::object::read::Object; |
| 12 | use run_make_support::{bin_name, dynamic_lib_name, is_msvc, object, regex, rfs, rustc}; | |
| 12 | use run_make_support::{bin_name, dynamic_lib_name, is_windows_msvc, object, regex, rfs, rustc}; | |
| 13 | 13 | |
| 14 | 14 | fn main() { |
| 15 | 15 | let cdylib_name = dynamic_lib_name("a_cdylib"); |
| ... | ... | @@ -64,7 +64,7 @@ fn main() { |
| 64 | 64 | ); |
| 65 | 65 | |
| 66 | 66 | // FIXME(nbdd0121): This is broken in MinGW, see https://github.com/rust-lang/rust/pull/95604#issuecomment-1101564032 |
| 67 | if is_msvc() { | |
| 67 | if is_windows_msvc() { | |
| 68 | 68 | // Check that an executable does not export any dynamic symbols |
| 69 | 69 | symbols_check(&exe_name, SymbolCheckType::StrSymbol("public_c_function_from_rlib"), false); |
| 70 | 70 | symbols_check( |
| ... | ... | @@ -130,7 +130,7 @@ fn main() { |
| 130 | 130 | ); |
| 131 | 131 | |
| 132 | 132 | // FIXME(nbdd0121): This is broken in MinGW, see https://github.com/rust-lang/rust/pull/95604#issuecomment-1101564032 |
| 133 | if is_msvc() { | |
| 133 | if is_windows_msvc() { | |
| 134 | 134 | // Check that an executable does not export any dynamic symbols |
| 135 | 135 | symbols_check(&exe_name, SymbolCheckType::StrSymbol("public_c_function_from_rlib"), false); |
| 136 | 136 | symbols_check( |
tests/ui-fulldeps/auxiliary/obtain-borrowck-input.rs+4| ... | ... | @@ -28,6 +28,10 @@ const fn foo() -> usize { |
| 28 | 28 | 1 |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | fn with_nested_body(opt: Option<i32>) -> Option<i32> { | |
| 32 | opt.map(|x| x + 1) | |
| 33 | } | |
| 34 | ||
| 31 | 35 | fn main() { |
| 32 | 36 | let bar: [Bar; foo()] = [Bar::new()]; |
| 33 | 37 | assert_eq!(bar[0].provided(), foo()); |
tests/ui-fulldeps/obtain-borrowck.rs+12-8| ... | ... | @@ -9,16 +9,17 @@ |
| 9 | 9 | |
| 10 | 10 | //! This program implements a rustc driver that retrieves MIR bodies with |
| 11 | 11 | //! borrowck information. This cannot be done in a straightforward way because |
| 12 | //! `get_body_with_borrowck_facts`–the function for retrieving a MIR body with | |
| 13 | //! borrowck facts–can panic if the body is stolen before it is invoked. | |
| 12 | //! `get_bodies_with_borrowck_facts`–the function for retrieving MIR bodies with | |
| 13 | //! borrowck facts–can panic if the bodies are stolen before it is invoked. | |
| 14 | 14 | //! Therefore, the driver overrides `mir_borrowck` query (this is done in the |
| 15 | //! `config` callback), which retrieves the body that is about to be borrow | |
| 16 | //! checked and stores it in a thread local `MIR_BODIES`. Then, `after_analysis` | |
| 15 | //! `config` callback), which retrieves the bodies that are about to be borrow | |
| 16 | //! checked and stores them in a thread local `MIR_BODIES`. Then, `after_analysis` | |
| 17 | 17 | //! callback triggers borrow checking of all MIR bodies by retrieving |
| 18 | 18 | //! `optimized_mir` and pulls out the MIR bodies with the borrowck information |
| 19 | 19 | //! from the thread local storage. |
| 20 | 20 | |
| 21 | 21 | extern crate rustc_borrowck; |
| 22 | extern crate rustc_data_structures; | |
| 22 | 23 | extern crate rustc_driver; |
| 23 | 24 | extern crate rustc_hir; |
| 24 | 25 | extern crate rustc_interface; |
| ... | ... | @@ -30,6 +31,7 @@ use std::collections::HashMap; |
| 30 | 31 | use std::thread_local; |
| 31 | 32 | |
| 32 | 33 | use rustc_borrowck::consumers::{self, BodyWithBorrowckFacts, ConsumerOptions}; |
| 34 | use rustc_data_structures::fx::FxHashMap; | |
| 33 | 35 | use rustc_driver::Compilation; |
| 34 | 36 | use rustc_hir::def::DefKind; |
| 35 | 37 | use rustc_hir::def_id::LocalDefId; |
| ... | ... | @@ -129,13 +131,15 @@ thread_local! { |
| 129 | 131 | |
| 130 | 132 | fn mir_borrowck<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> ProvidedValue<'tcx> { |
| 131 | 133 | let opts = ConsumerOptions::PoloniusInputFacts; |
| 132 | let body_with_facts = consumers::get_body_with_borrowck_facts(tcx, def_id, opts); | |
| 134 | let bodies_with_facts = consumers::get_bodies_with_borrowck_facts(tcx, def_id, opts); | |
| 133 | 135 | // SAFETY: The reader casts the 'static lifetime to 'tcx before using it. |
| 134 | let body_with_facts: BodyWithBorrowckFacts<'static> = | |
| 135 | unsafe { std::mem::transmute(body_with_facts) }; | |
| 136 | let bodies_with_facts: FxHashMap<LocalDefId, BodyWithBorrowckFacts<'static>> = | |
| 137 | unsafe { std::mem::transmute(bodies_with_facts) }; | |
| 136 | 138 | MIR_BODIES.with(|state| { |
| 137 | 139 | let mut map = state.borrow_mut(); |
| 138 | assert!(map.insert(def_id, body_with_facts).is_none()); | |
| 140 | for (def_id, body_with_facts) in bodies_with_facts { | |
| 141 | assert!(map.insert(def_id, body_with_facts).is_none()); | |
| 142 | } | |
| 139 | 143 | }); |
| 140 | 144 | let mut providers = Providers::default(); |
| 141 | 145 | rustc_borrowck::provide(&mut providers); |
tests/ui-fulldeps/obtain-borrowck.run.stdout+2| ... | ... | @@ -3,6 +3,8 @@ Bodies retrieved for: |
| 3 | 3 | ::foo |
| 4 | 4 | ::main |
| 5 | 5 | ::main::{constant#0} |
| 6 | ::with_nested_body | |
| 7 | ::with_nested_body::{closure#0} | |
| 6 | 8 | ::{impl#0}::new |
| 7 | 9 | ::{impl#1}::provided |
| 8 | 10 | ::{impl#1}::required |
tests/ui/async-await/issues/issue-54752-async-block.rs-1| ... | ... | @@ -4,4 +4,3 @@ |
| 4 | 4 | //@ pp-exact |
| 5 | 5 | |
| 6 | 6 | fn main() { let _a = (async { }); } |
| 7 | //~^ WARNING unnecessary parentheses around assigned value |
tests/ui/async-await/issues/issue-54752-async-block.stderr deleted-15| ... | ... | @@ -1,15 +0,0 @@ |
| 1 | warning: unnecessary parentheses around assigned value | |
| 2 | --> $DIR/issue-54752-async-block.rs:6:22 | |
| 3 | | | |
| 4 | LL | fn main() { let _a = (async { }); } | |
| 5 | | ^ ^ | |
| 6 | | | |
| 7 | = note: `#[warn(unused_parens)]` on by default | |
| 8 | help: remove these parentheses | |
| 9 | | | |
| 10 | LL - fn main() { let _a = (async { }); } | |
| 11 | LL + fn main() { let _a = async { }; } | |
| 12 | | | |
| 13 | ||
| 14 | warning: 1 warning emitted | |
| 15 |
tests/ui/lint/unused/closure-body-issue-136741.fixed created+36| ... | ... | @@ -0,0 +1,36 @@ |
| 1 | //@ run-rustfix | |
| 2 | // ignore-tidy-linelength | |
| 3 | #![deny(unused_parens)] | |
| 4 | #![deny(unused_braces)] | |
| 5 | ||
| 6 | fn long_expr_that_does_not_require_braces_long_expr_that_does_not_require_braces_long_expr_that_does_not_require_braces() | |
| 7 | {} | |
| 8 | ||
| 9 | fn func(f: impl FnOnce()) { | |
| 10 | f() | |
| 11 | } | |
| 12 | ||
| 13 | pub fn main() { | |
| 14 | let _closure = |x: i32, y: i32| { x * (x + (y * 2)) }; | |
| 15 | let _ = || 0 == 0; //~ ERROR unnecessary parentheses around closure body | |
| 16 | let _ = (0..).find(|n| n % 2 == 0); //~ ERROR unnecessary parentheses around closure body | |
| 17 | let _ = (0..).find(|n| {n % 2 == 0}); | |
| 18 | ||
| 19 | // multiple lines of code will not lint with braces | |
| 20 | let _ = (0..).find(|n| { | |
| 21 | n % 2 == 0 | |
| 22 | }); | |
| 23 | ||
| 24 | // multiple lines of code will lint with parentheses | |
| 25 | let _ = (0..).find(|n| n % 2 == 0); | |
| 26 | ||
| 27 | let _ = || { | |
| 28 | _ = 0; | |
| 29 | 0 == 0 //~ ERROR unnecessary parentheses around block return value | |
| 30 | }; | |
| 31 | ||
| 32 | // long expressions will not lint with braces | |
| 33 | func(|| { | |
| 34 | long_expr_that_does_not_require_braces_long_expr_that_does_not_require_braces_long_expr_that_does_not_require_braces() | |
| 35 | }) | |
| 36 | } |
tests/ui/lint/unused/closure-body-issue-136741.rs created+38| ... | ... | @@ -0,0 +1,38 @@ |
| 1 | //@ run-rustfix | |
| 2 | // ignore-tidy-linelength | |
| 3 | #![deny(unused_parens)] | |
| 4 | #![deny(unused_braces)] | |
| 5 | ||
| 6 | fn long_expr_that_does_not_require_braces_long_expr_that_does_not_require_braces_long_expr_that_does_not_require_braces() | |
| 7 | {} | |
| 8 | ||
| 9 | fn func(f: impl FnOnce()) { | |
| 10 | f() | |
| 11 | } | |
| 12 | ||
| 13 | pub fn main() { | |
| 14 | let _closure = |x: i32, y: i32| { x * (x + (y * 2)) }; | |
| 15 | let _ = || (0 == 0); //~ ERROR unnecessary parentheses around closure body | |
| 16 | let _ = (0..).find(|n| (n % 2 == 0)); //~ ERROR unnecessary parentheses around closure body | |
| 17 | let _ = (0..).find(|n| {n % 2 == 0}); | |
| 18 | ||
| 19 | // multiple lines of code will not lint with braces | |
| 20 | let _ = (0..).find(|n| { | |
| 21 | n % 2 == 0 | |
| 22 | }); | |
| 23 | ||
| 24 | // multiple lines of code will lint with parentheses | |
| 25 | let _ = (0..).find(|n| ( //~ ERROR unnecessary parentheses around closure body | |
| 26 | n % 2 == 0 | |
| 27 | )); | |
| 28 | ||
| 29 | let _ = || { | |
| 30 | _ = 0; | |
| 31 | (0 == 0) //~ ERROR unnecessary parentheses around block return value | |
| 32 | }; | |
| 33 | ||
| 34 | // long expressions will not lint with braces | |
| 35 | func(|| { | |
| 36 | long_expr_that_does_not_require_braces_long_expr_that_does_not_require_braces_long_expr_that_does_not_require_braces() | |
| 37 | }) | |
| 38 | } |
tests/ui/lint/unused/closure-body-issue-136741.stderr created+62| ... | ... | @@ -0,0 +1,62 @@ |
| 1 | error: unnecessary parentheses around closure body | |
| 2 | --> $DIR/closure-body-issue-136741.rs:15:16 | |
| 3 | | | |
| 4 | LL | let _ = || (0 == 0); | |
| 5 | | ^ ^ | |
| 6 | | | |
| 7 | note: the lint level is defined here | |
| 8 | --> $DIR/closure-body-issue-136741.rs:3:9 | |
| 9 | | | |
| 10 | LL | #![deny(unused_parens)] | |
| 11 | | ^^^^^^^^^^^^^ | |
| 12 | help: remove these parentheses | |
| 13 | | | |
| 14 | LL - let _ = || (0 == 0); | |
| 15 | LL + let _ = || 0 == 0; | |
| 16 | | | |
| 17 | ||
| 18 | error: unnecessary parentheses around closure body | |
| 19 | --> $DIR/closure-body-issue-136741.rs:16:28 | |
| 20 | | | |
| 21 | LL | let _ = (0..).find(|n| (n % 2 == 0)); | |
| 22 | | ^ ^ | |
| 23 | | | |
| 24 | help: remove these parentheses | |
| 25 | | | |
| 26 | LL - let _ = (0..).find(|n| (n % 2 == 0)); | |
| 27 | LL + let _ = (0..).find(|n| n % 2 == 0); | |
| 28 | | | |
| 29 | ||
| 30 | error: unnecessary parentheses around closure body | |
| 31 | --> $DIR/closure-body-issue-136741.rs:25:28 | |
| 32 | | | |
| 33 | LL | let _ = (0..).find(|n| ( | |
| 34 | | _____________________________^ | |
| 35 | LL | | n % 2 == 0 | |
| 36 | | | ________^__________^ | |
| 37 | | ||________| | |
| 38 | | | | |
| 39 | LL | | )); | |
| 40 | | |_____^ | |
| 41 | | | |
| 42 | help: remove these parentheses | |
| 43 | | | |
| 44 | LL - let _ = (0..).find(|n| ( | |
| 45 | LL - n % 2 == 0 | |
| 46 | LL + let _ = (0..).find(|n| n % 2 == 0); | |
| 47 | | | |
| 48 | ||
| 49 | error: unnecessary parentheses around block return value | |
| 50 | --> $DIR/closure-body-issue-136741.rs:31:9 | |
| 51 | | | |
| 52 | LL | (0 == 0) | |
| 53 | | ^ ^ | |
| 54 | | | |
| 55 | help: remove these parentheses | |
| 56 | | | |
| 57 | LL - (0 == 0) | |
| 58 | LL + 0 == 0 | |
| 59 | | | |
| 60 | ||
| 61 | error: aborting due to 4 previous errors | |
| 62 |
triagebot.toml+7| ... | ... | @@ -535,6 +535,9 @@ trigger_files = [ |
| 535 | 535 | [autolabel."S-waiting-on-review"] |
| 536 | 536 | new_pr = true |
| 537 | 537 | |
| 538 | [autolabel."S-waiting-on-author"] | |
| 539 | new_draft = true | |
| 540 | ||
| 538 | 541 | [autolabel."needs-triage"] |
| 539 | 542 | new_issue = true |
| 540 | 543 | exclude_labels = [ |
| ... | ... | @@ -1089,6 +1092,10 @@ cc = ["@jieyouxu"] |
| 1089 | 1092 | message = "The list of allowed third-party dependencies may have been modified! You must ensure that any new dependencies have compatible licenses before merging." |
| 1090 | 1093 | cc = ["@davidtwco", "@wesleywiser"] |
| 1091 | 1094 | |
| 1095 | [mentions."src/tools/tidy/src/ext_tool_checks.rs"] | |
| 1096 | message = "`tidy` extra checks were modified." | |
| 1097 | cc = ["@lolbinarycat"] | |
| 1098 | ||
| 1092 | 1099 | [mentions."src/bootstrap/src/core/config"] |
| 1093 | 1100 | message = """ |
| 1094 | 1101 | This PR modifies `src/bootstrap/src/core/config`. |