authorbors <bors@rust-lang.org> 2025-07-10 13:49:36 UTC
committerbors <bors@rust-lang.org> 2025-07-10 13:49:36 UTC
log78a6e132984dba0303ebad7dcfd1305c93ad5835
treed750951d6c3044d202ada72e87b9c35cb0dc74f1
parent119574f83576dc1f3ae067f9a97986d4e2b0826c
parentbd2a3517881de6026cac53262e14275758e70b7b

Auto merge of #143731 - matthiaskrgr:rollup-lm9q7vc, r=matthiaskrgr

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: rollup

80 files changed, 512 insertions(+), 415 deletions(-)

Cargo.lock+1-1
......@@ -3214,7 +3214,7 @@ dependencies = [
32143214
32153215[[package]]
32163216name = "run_make_support"
3217version = "0.2.0"
3217version = "0.0.0"
32183218dependencies = [
32193219 "bstr",
32203220 "build_helper",
compiler/rustc_attr_parsing/messages.ftl+2-2
......@@ -146,12 +146,12 @@ attr_parsing_unused_duplicate =
146146 unused attribute
147147 .suggestion = remove this attribute
148148 .note = attribute also specified here
149 .warn = {-passes_previously_accepted}
149 .warn = {-attr_parsing_previously_accepted}
150150
151151attr_parsing_unused_multiple =
152152 multiple `{$name}` attributes
153153 .suggestion = remove this attribute
154154 .note = attribute also specified here
155155
156-attr_parsing_perviously_accepted =
156-attr_parsing_previously_accepted =
157157 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;
1515
1616impl<S: Stage> SingleAttributeParser<S> for OptimizeParser {
1717 const PATH: &[Symbol] = &[sym::optimize];
18 const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepLast;
18 const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepOutermost;
1919 const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::WarnButFutureError;
2020 const TEMPLATE: AttributeTemplate = template!(List: "size|speed|none");
2121
......@@ -56,7 +56,7 @@ pub(crate) struct ExportNameParser;
5656
5757impl<S: Stage> SingleAttributeParser<S> for ExportNameParser {
5858 const PATH: &[rustc_span::Symbol] = &[sym::export_name];
59 const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepFirst;
59 const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepInnermost;
6060 const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::WarnButFutureError;
6161 const TEMPLATE: AttributeTemplate = template!(NameValueStr: "name");
6262
compiler/rustc_attr_parsing/src/attributes/deprecation.rs+1-1
......@@ -36,7 +36,7 @@ fn get<S: Stage>(
3636
3737impl<S: Stage> SingleAttributeParser<S> for DeprecationParser {
3838 const PATH: &[Symbol] = &[sym::deprecated];
39 const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepFirst;
39 const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepInnermost;
4040 const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
4141 const TEMPLATE: AttributeTemplate = template!(
4242 Word,
compiler/rustc_attr_parsing/src/attributes/dummy.rs+1-1
......@@ -9,7 +9,7 @@ use crate::parser::ArgParser;
99pub(crate) struct DummyParser;
1010impl<S: Stage> SingleAttributeParser<S> for DummyParser {
1111 const PATH: &[Symbol] = &[sym::rustc_dummy];
12 const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepFirst;
12 const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepInnermost;
1313 const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Ignore;
1414 const TEMPLATE: AttributeTemplate = template!(Word); // Anything, really
1515
compiler/rustc_attr_parsing/src/attributes/inline.rs+2-2
......@@ -16,7 +16,7 @@ pub(crate) struct InlineParser;
1616
1717impl<S: Stage> SingleAttributeParser<S> for InlineParser {
1818 const PATH: &'static [Symbol] = &[sym::inline];
19 const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepLast;
19 const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepOutermost;
2020 const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::WarnButFutureError;
2121 const TEMPLATE: AttributeTemplate = template!(Word, List: "always|never");
2222
......@@ -57,7 +57,7 @@ pub(crate) struct RustcForceInlineParser;
5757
5858impl<S: Stage> SingleAttributeParser<S> for RustcForceInlineParser {
5959 const PATH: &'static [Symbol] = &[sym::rustc_force_inline];
60 const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepLast;
60 const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepOutermost;
6161 const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::WarnButFutureError;
6262 const TEMPLATE: AttributeTemplate = template!(Word, List: "reason", NameValueStr: "reason");
6363
compiler/rustc_attr_parsing/src/attributes/link_attrs.rs+2-2
......@@ -14,7 +14,7 @@ pub(crate) struct LinkNameParser;
1414
1515impl<S: Stage> SingleAttributeParser<S> for LinkNameParser {
1616 const PATH: &[Symbol] = &[sym::link_name];
17 const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepFirst;
17 const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepInnermost;
1818 const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::WarnButFutureError;
1919 const TEMPLATE: AttributeTemplate = template!(NameValueStr: "name");
2020
......@@ -36,7 +36,7 @@ pub(crate) struct LinkSectionParser;
3636
3737impl<S: Stage> SingleAttributeParser<S> for LinkSectionParser {
3838 const PATH: &[Symbol] = &[sym::link_section];
39 const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepFirst;
39 const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepInnermost;
4040 const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::WarnButFutureError;
4141 const TEMPLATE: AttributeTemplate = template!(NameValueStr: "name");
4242
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>
140140 if let Some(pa) = T::convert(cx, args) {
141141 match T::ATTRIBUTE_ORDER {
142142 // keep the first and report immediately. ignore this attribute
143 AttributeOrder::KeepFirst => {
143 AttributeOrder::KeepInnermost => {
144144 if let Some((_, unused)) = group.1 {
145145 T::ON_DUPLICATE.exec::<T>(cx, cx.attr_span, unused);
146146 return;
......@@ -148,7 +148,7 @@ impl<T: SingleAttributeParser<S>, S: Stage> AttributeParser<S> for Single<T, S>
148148 }
149149 // keep the new one and warn about the previous,
150150 // then replace
151 AttributeOrder::KeepLast => {
151 AttributeOrder::KeepOutermost => {
152152 if let Some((_, used)) = group.1 {
153153 T::ON_DUPLICATE.exec::<T>(cx, used, cx.attr_span);
154154 }
......@@ -165,9 +165,6 @@ impl<T: SingleAttributeParser<S>, S: Stage> AttributeParser<S> for Single<T, S>
165165 }
166166}
167167
168// FIXME(jdonszelmann): logic is implemented but the attribute parsers needing
169// them will be merged in another PR
170#[allow(unused)]
171168pub(crate) enum OnDuplicate<S: Stage> {
172169 /// Give a default warning
173170 Warn,
......@@ -213,39 +210,29 @@ impl<S: Stage> OnDuplicate<S> {
213210 }
214211 }
215212}
216//
217// FIXME(jdonszelmann): logic is implemented but the attribute parsers needing
218// them will be merged in another PR
219#[allow(unused)]
213
220214pub(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.
222217 ///
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
224219 /// further above the lowest one:
225220 /// ```
226221 /// #[stable(since="1.0")] //~ WARNING duplicated attribute
227222 /// #[stable(since="2.0")]
228223 /// ```
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,
234225
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.
237228 ///
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:
240231 /// ```
241232 /// #[path="foo.rs"]
242233 /// #[path="bar.rs"] //~ WARNING duplicated attribute
243234 /// ```
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,
249236}
250237
251238/// An even simpler version of [`SingleAttributeParser`]:
......@@ -271,7 +258,7 @@ impl<T: NoArgsAttributeParser<S>, S: Stage> Default for WithoutArgs<T, S> {
271258
272259impl<T: NoArgsAttributeParser<S>, S: Stage> SingleAttributeParser<S> for WithoutArgs<T, S> {
273260 const PATH: &[Symbol] = T::PATH;
274 const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepLast;
261 const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepOutermost;
275262 const ON_DUPLICATE: OnDuplicate<S> = T::ON_DUPLICATE;
276263 const TEMPLATE: AttributeTemplate = template!(Word);
277264
compiler/rustc_attr_parsing/src/attributes/must_use.rs+1-1
......@@ -12,7 +12,7 @@ pub(crate) struct MustUseParser;
1212
1313impl<S: Stage> SingleAttributeParser<S> for MustUseParser {
1414 const PATH: &[Symbol] = &[sym::must_use];
15 const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepLast;
15 const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepOutermost;
1616 const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::WarnButFutureError;
1717 const TEMPLATE: AttributeTemplate = template!(Word, NameValueStr: "reason");
1818
compiler/rustc_attr_parsing/src/attributes/path.rs+1-1
......@@ -10,7 +10,7 @@ pub(crate) struct PathParser;
1010
1111impl<S: Stage> SingleAttributeParser<S> for PathParser {
1212 const PATH: &[Symbol] = &[sym::path];
13 const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepLast;
13 const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepOutermost;
1414 const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::WarnButFutureError;
1515 const TEMPLATE: AttributeTemplate = template!(NameValueStr: "file");
1616
compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs+3-3
......@@ -11,7 +11,7 @@ pub(crate) struct RustcLayoutScalarValidRangeStart;
1111
1212impl<S: Stage> SingleAttributeParser<S> for RustcLayoutScalarValidRangeStart {
1313 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;
1515 const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
1616 const TEMPLATE: AttributeTemplate = template!(List: "start");
1717
......@@ -25,7 +25,7 @@ pub(crate) struct RustcLayoutScalarValidRangeEnd;
2525
2626impl<S: Stage> SingleAttributeParser<S> for RustcLayoutScalarValidRangeEnd {
2727 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;
2929 const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
3030 const TEMPLATE: AttributeTemplate = template!(List: "end");
3131
......@@ -62,7 +62,7 @@ pub(crate) struct RustcObjectLifetimeDefaultParser;
6262
6363impl<S: Stage> SingleAttributeParser<S> for RustcObjectLifetimeDefaultParser {
6464 const PATH: &[rustc_span::Symbol] = &[sym::rustc_object_lifetime_default];
65 const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepFirst;
65 const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepInnermost;
6666 const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
6767 const TEMPLATE: AttributeTemplate = template!(Word);
6868
compiler/rustc_attr_parsing/src/attributes/test_attrs.rs+1-1
......@@ -11,7 +11,7 @@ pub(crate) struct IgnoreParser;
1111
1212impl<S: Stage> SingleAttributeParser<S> for IgnoreParser {
1313 const PATH: &[Symbol] = &[sym::ignore];
14 const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepLast;
14 const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepOutermost;
1515 const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
1616 const TEMPLATE: AttributeTemplate = template!(Word, NameValueStr: "reason");
1717
compiler/rustc_attr_parsing/src/attributes/traits.rs+1-1
......@@ -12,7 +12,7 @@ pub(crate) struct SkipDuringMethodDispatchParser;
1212
1313impl<S: Stage> SingleAttributeParser<S> for SkipDuringMethodDispatchParser {
1414 const PATH: &[Symbol] = &[sym::rustc_skip_during_method_dispatch];
15 const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepFirst;
15 const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepInnermost;
1616 const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
1717
1818 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;
1414#[allow(rustc::diagnostic_outside_of_impl)]
1515impl<S: Stage> SingleAttributeParser<S> for TransparencyParser {
1616 const PATH: &[Symbol] = &[sym::rustc_macro_transparency];
17 const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepFirst;
17 const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepInnermost;
1818 const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Custom(|cx, used, unused| {
1919 cx.dcx().span_err(vec![used, unused], "multiple macro transparency attributes");
2020 });
compiler/rustc_borrowck/src/consumers.rs+57-24
......@@ -1,7 +1,9 @@
11//! This file provides API for compiler consumers.
22
3use rustc_data_structures::fx::FxHashMap;
34use rustc_hir::def_id::LocalDefId;
45use rustc_index::IndexVec;
6use rustc_middle::bug;
57use rustc_middle::mir::{Body, Promoted};
68use rustc_middle::ty::TyCtxt;
79
......@@ -17,7 +19,39 @@ pub use super::polonius::legacy::{
1719pub use super::region_infer::RegionInferenceContext;
1820use crate::{BorrowCheckRootCtxt, do_mir_borrowck};
1921
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.
24pub(crate) struct BorrowckConsumer<'tcx> {
25 options: ConsumerOptions,
26 bodies: FxHashMap<LocalDefId, BodyWithBorrowckFacts<'tcx>>,
27}
28
29impl<'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`].
2155///
2256/// If executing under `-Z polonius` the choice here has no effect, and everything as if
2357/// [`PoloniusOutputFacts`](ConsumerOptions::PoloniusOutputFacts) had been selected
......@@ -43,17 +77,6 @@ pub enum ConsumerOptions {
4377 PoloniusOutputFacts,
4478}
4579
46impl 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
5780/// A `Body` with information computed by the borrow checker. This struct is
5881/// intended to be consumed by compiler consumers.
5982///
......@@ -82,25 +105,35 @@ pub struct BodyWithBorrowckFacts<'tcx> {
82105 pub output_facts: Option<Box<PoloniusOutput>>,
83106}
84107
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`].
90114///
91115/// 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
93117/// can, for example, happen when requesting a body of a `const` function
94118/// because they are evaluated during typechecking. The panic can be avoided
95119/// 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`.
97121///
98122/// * Polonius is highly unstable, so expect regular changes in its signature or other details.
99pub fn get_body_with_borrowck_facts(
123pub fn get_bodies_with_borrowck_facts(
100124 tcx: TyCtxt<'_>,
101 def_id: LocalDefId,
125 root_def_id: LocalDefId,
102126 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
106139}
compiler/rustc_borrowck/src/lib.rs+19-24
......@@ -51,7 +51,7 @@ use smallvec::SmallVec;
5151use tracing::{debug, instrument};
5252
5353use crate::borrow_set::{BorrowData, BorrowSet};
54use crate::consumers::{BodyWithBorrowckFacts, ConsumerOptions};
54use crate::consumers::BodyWithBorrowckFacts;
5555use crate::dataflow::{BorrowIndex, Borrowck, BorrowckDomain, Borrows};
5656use crate::diagnostics::{
5757 AccessKind, BorrowckDiagnosticsBuffer, IllegalMoveOriginKind, MoveError, RegionName,
......@@ -124,7 +124,7 @@ fn mir_borrowck(
124124 let opaque_types = ConcreteOpaqueTypes(Default::default());
125125 Ok(tcx.arena.alloc(opaque_types))
126126 } else {
127 let mut root_cx = BorrowCheckRootCtxt::new(tcx, def);
127 let mut root_cx = BorrowCheckRootCtxt::new(tcx, def, None);
128128 // We need to manually borrowck all nested bodies from the HIR as
129129 // we do not generate MIR for dead code. Not doing so causes us to
130130 // never check closures in dead code.
......@@ -134,7 +134,7 @@ fn mir_borrowck(
134134 }
135135
136136 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);
138138 debug_assert!(closure_requirements.is_none());
139139 debug_assert!(used_mut_upvars.is_empty());
140140 root_cx.finalize()
......@@ -289,17 +289,12 @@ impl<'tcx> ClosureOutlivesSubjectTy<'tcx> {
289289
290290/// Perform the actual borrow checking.
291291///
292/// Use `consumer_options: None` for the default behavior of returning
293/// [`PropagatedBorrowCheckResults`] only. Otherwise, return [`BodyWithBorrowckFacts`]
294/// according to the given [`ConsumerOptions`].
295///
296292/// For nested bodies this should only be called through `root_cx.get_or_insert_nested`.
297293#[instrument(skip(root_cx), level = "debug")]
298294fn do_mir_borrowck<'tcx>(
299295 root_cx: &mut BorrowCheckRootCtxt<'tcx>,
300296 def: LocalDefId,
301 consumer_options: Option<ConsumerOptions>,
302) -> (PropagatedBorrowCheckResults<'tcx>, Option<Box<BodyWithBorrowckFacts<'tcx>>>) {
297) -> PropagatedBorrowCheckResults<'tcx> {
303298 let tcx = root_cx.tcx;
304299 let infcx = BorrowckInferCtxt::new(tcx, def);
305300 let (input_body, promoted) = tcx.mir_promoted(def);
......@@ -343,7 +338,6 @@ fn do_mir_borrowck<'tcx>(
343338 &location_table,
344339 &move_data,
345340 &borrow_set,
346 consumer_options,
347341 );
348342
349343 // Dump MIR results into a file, if that is enabled. This lets us
......@@ -483,23 +477,24 @@ fn do_mir_borrowck<'tcx>(
483477 used_mut_upvars: mbcx.used_mut_upvars,
484478 };
485479
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 }
499494
500495 debug!("do_mir_borrowck: result = {:#?}", result);
501496
502 (result, body_with_facts)
497 result
503498}
504499
505500fn get_flow_results<'a, 'tcx>(
compiler/rustc_borrowck/src/nll.rs+2-4
......@@ -18,7 +18,6 @@ use rustc_span::sym;
1818use tracing::{debug, instrument};
1919
2020use crate::borrow_set::BorrowSet;
21use crate::consumers::ConsumerOptions;
2221use crate::diagnostics::RegionErrors;
2322use crate::handle_placeholders::compute_sccs_applying_placeholder_outlives_constraints;
2423use crate::polonius::PoloniusDiagnosticsContext;
......@@ -83,12 +82,11 @@ pub(crate) fn compute_regions<'tcx>(
8382 location_table: &PoloniusLocationTable,
8483 move_data: &MoveData<'tcx>,
8584 borrow_set: &BorrowSet<'tcx>,
86 consumer_options: Option<ConsumerOptions>,
8785) -> NllOutput<'tcx> {
8886 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())
9088 || 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())
9290 || is_polonius_legacy_enabled;
9391 let mut polonius_facts =
9492 (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};
66use rustc_span::ErrorGuaranteed;
77use smallvec::SmallVec;
88
9use crate::consumers::BorrowckConsumer;
910use crate::{ClosureRegionRequirements, ConcreteOpaqueTypes, PropagatedBorrowCheckResults};
1011
1112/// The shared context used by both the root as well as all its nested
......@@ -16,16 +17,24 @@ pub(super) struct BorrowCheckRootCtxt<'tcx> {
1617 concrete_opaque_types: ConcreteOpaqueTypes<'tcx>,
1718 nested_bodies: FxHashMap<LocalDefId, PropagatedBorrowCheckResults<'tcx>>,
1819 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>>,
1923}
2024
2125impl<'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> {
2331 BorrowCheckRootCtxt {
2432 tcx,
2533 root_def_id,
2634 concrete_opaque_types: Default::default(),
2735 nested_bodies: Default::default(),
2836 tainted_by_errors: None,
37 consumer,
2938 }
3039 }
3140
......@@ -71,7 +80,7 @@ impl<'tcx> BorrowCheckRootCtxt<'tcx> {
7180 self.root_def_id.to_def_id()
7281 );
7382 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);
7584 if let Some(prev) = self.nested_bodies.insert(def_id, result) {
7685 bug!("unexpected previous nested body: {prev:?}");
7786 }
compiler/rustc_errors/src/emitter.rs+1-1
......@@ -3526,7 +3526,7 @@ pub fn is_case_difference(sm: &SourceMap, suggested: &str, sp: Span) -> bool {
35263526 // All the chars that differ in capitalization are confusable (above):
35273527 let confusable = iter::zip(found.chars(), suggested.chars())
35283528 .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));
35303530 confusable && found.to_lowercase() == suggested.to_lowercase()
35313531 // FIXME: We sometimes suggest the same thing we already have, which is a
35323532 // bug, but be defensive against that here.
compiler/rustc_lint/src/types.rs+4-5
......@@ -59,8 +59,7 @@ declare_lint! {
5959}
6060
6161declare_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.
6463 ///
6564 /// ### Example
6665 ///
......@@ -72,9 +71,9 @@ declare_lint! {
7271 ///
7372 /// ### Explanation
7473 ///
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.
7877 OVERFLOWING_LITERALS,
7978 Deny,
8079 "literal out of range for its type"
compiler/rustc_lint/src/unused.rs+9-1
......@@ -1,7 +1,7 @@
11use std::iter;
22
33use rustc_ast::util::{classify, parser};
4use rustc_ast::{self as ast, ExprKind, HasAttrs as _, StmtKind};
4use rustc_ast::{self as ast, ExprKind, FnRetTy, HasAttrs as _, StmtKind};
55use rustc_attr_data_structures::{AttributeKind, find_attr};
66use rustc_data_structures::fx::FxHashMap;
77use rustc_errors::{MultiSpan, pluralize};
......@@ -599,6 +599,7 @@ enum UnusedDelimsCtx {
599599 AnonConst,
600600 MatchArmExpr,
601601 IndexExpr,
602 ClosureBody,
602603}
603604
604605impl From<UnusedDelimsCtx> for &'static str {
......@@ -620,6 +621,7 @@ impl From<UnusedDelimsCtx> for &'static str {
620621 UnusedDelimsCtx::ArrayLenExpr | UnusedDelimsCtx::AnonConst => "const expression",
621622 UnusedDelimsCtx::MatchArmExpr => "match arm expression",
622623 UnusedDelimsCtx::IndexExpr => "index expression",
624 UnusedDelimsCtx::ClosureBody => "closure body",
623625 }
624626 }
625627}
......@@ -919,6 +921,11 @@ trait UnusedDelimLint {
919921 let (args_to_check, ctx) = match *call_or_other {
920922 Call(_, ref args) => (&args[..], UnusedDelimsCtx::FunctionArg),
921923 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 }
922929 // actual catch-all arm
923930 _ => {
924931 return;
......@@ -1508,6 +1515,7 @@ impl UnusedDelimLint for UnusedBraces {
15081515 && (ctx != UnusedDelimsCtx::AnonConst
15091516 || (matches!(expr.kind, ast::ExprKind::Lit(_))
15101517 && !expr.span.from_expansion()))
1518 && ctx != UnusedDelimsCtx::ClosureBody
15111519 && !cx.sess().source_map().is_multiline(value.span)
15121520 && value.attrs.is_empty()
15131521 && !value.span.from_expansion()
compiler/rustc_parse/src/parser/item.rs+1-1
......@@ -2206,7 +2206,7 @@ impl<'a> Parser<'a> {
22062206
22072207 if self.look_ahead(1, |t| *t == token::Bang) && self.look_ahead(2, |t| t.is_ident()) {
22082208 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()) {
22102210 // macro_rules foo
22112211 self.dcx().emit_err(errors::MacroRulesMissingBang {
22122212 span: macro_rules_span,
compiler/rustc_resolve/src/build_reduced_graph.rs+19-17
......@@ -162,28 +162,30 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
162162 }
163163 }
164164
165 pub(crate) fn get_macro(&mut self, res: Res) -> Option<&MacroData> {
165 pub(crate) fn get_macro(&self, res: Res) -> Option<&'ra MacroData> {
166166 match res {
167167 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),
169169 _ => None,
170170 }
171171 }
172172
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 };
185185
186 self.macro_map.entry(def_id).or_insert(macro_data)
186 self.arenas.alloc_macro(macro_data)
187 }),
188 }
187189 }
188190
189191 pub(crate) fn build_reduced_graph(
......@@ -1203,7 +1205,7 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
12031205 fn insert_unused_macro(&mut self, ident: Ident, def_id: LocalDefId, node_id: NodeId) {
12041206 if !ident.as_str().starts_with('_') {
12051207 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;
12071209 self.r.unused_macro_rules.insert(node_id, DenseBitSet::new_filled(nrules));
12081210 }
12091211 }
......@@ -1222,7 +1224,7 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
12221224 Some((macro_kind, ident, span)) => {
12231225 let res = Res::Def(DefKind::Macro(macro_kind), def_id.to_def_id());
12241226 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);
12261228 self.r.proc_macro_stubs.insert(def_id);
12271229 (res, ident, span, false)
12281230 }
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> {
165165 self.create_def(i.id, i.kind.ident().map(|ident| ident.name), def_kind, i.span);
166166
167167 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);
169169 }
170170
171171 self.with_parent(def_id, |this| {
compiler/rustc_resolve/src/diagnostics.rs+7-2
......@@ -1669,9 +1669,14 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
16691669 let mut all_attrs: UnordMap<Symbol, Vec<_>> = UnordMap::default();
16701670 // We're collecting these in a hashmap, and handle ordering the output further down.
16711671 #[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 {
16731678 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);
16751680 all_attrs.entry(*helper_attr).or_default().push(item_name);
16761681 if helper_attr == &ident.name {
16771682 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> {
328328 let module_did = mod_prefix.as_ref().and_then(Res::mod_def_id);
329329
330330 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()));
333332 (mod_prefix, format!("`{}`", Segment::names_to_string(mod_path)), module_did, None)
334333 };
335334
compiler/rustc_resolve/src/lib.rs+20-6
......@@ -1128,10 +1128,12 @@ pub struct Resolver<'ra, 'tcx> {
11281128 builtin_macros: FxHashMap<Symbol, SyntaxExtensionKind>,
11291129 registered_tools: &'tcx RegisteredTools,
11301130 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>>,
11321134 dummy_ext_bang: Arc<SyntaxExtension>,
11331135 dummy_ext_derive: Arc<SyntaxExtension>,
1134 non_macro_attr: MacroData,
1136 non_macro_attr: &'ra MacroData,
11351137 local_macro_def_scopes: FxHashMap<LocalDefId, Module<'ra>>,
11361138 ast_transform_scopes: FxHashMap<LocalExpnId, Module<'ra>>,
11371139 unused_macros: FxIndexMap<LocalDefId, (NodeId, Ident)>,
......@@ -1241,6 +1243,7 @@ pub struct ResolverArenas<'ra> {
12411243 imports: TypedArena<ImportData<'ra>>,
12421244 name_resolutions: TypedArena<RefCell<NameResolution<'ra>>>,
12431245 ast_paths: TypedArena<ast::Path>,
1246 macros: TypedArena<MacroData>,
12441247 dropless: DroplessArena,
12451248}
12461249
......@@ -1287,7 +1290,7 @@ impl<'ra> ResolverArenas<'ra> {
12871290 self.name_resolutions.alloc(Default::default())
12881291 }
12891292 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))
12911294 }
12921295 fn alloc_macro_rules_binding(
12931296 &'ra self,
......@@ -1298,6 +1301,9 @@ impl<'ra> ResolverArenas<'ra> {
12981301 fn alloc_ast_paths(&'ra self, paths: &[ast::Path]) -> &'ra [ast::Path] {
12991302 self.ast_paths.alloc_from_iter(paths.iter().cloned())
13001303 }
1304 fn alloc_macro(&'ra self, macro_data: MacroData) -> &'ra MacroData {
1305 self.macros.alloc(macro_data)
1306 }
13011307 fn alloc_pattern_spans(&'ra self, spans: impl Iterator<Item = Span>) -> &'ra [Span] {
13021308 self.dropless.alloc_from_iter(spans)
13031309 }
......@@ -1540,10 +1546,12 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
15401546 builtin_macros: Default::default(),
15411547 registered_tools,
15421548 macro_use_prelude: Default::default(),
1543 macro_map: FxHashMap::default(),
1549 local_macro_map: Default::default(),
1550 extern_macro_map: Default::default(),
15441551 dummy_ext_bang: Arc::new(SyntaxExtension::dummy_bang(edition)),
15451552 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)))),
15471555 invocation_parent_scopes: Default::default(),
15481556 output_macro_rules_scopes: Default::default(),
15491557 macro_rules_scopes: Default::default(),
......@@ -1616,6 +1624,12 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
16161624 )
16171625 }
16181626
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
16191633 fn next_node_id(&mut self) -> NodeId {
16201634 let start = self.next_node_id;
16211635 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> {
17341748 f(self, MacroNS);
17351749 }
17361750
1737 fn is_builtin_macro(&mut self, res: Res) -> bool {
1751 fn is_builtin_macro(&self, res: Res) -> bool {
17381752 self.get_macro(res).is_some_and(|macro_data| macro_data.ext.builtin_name.is_some())
17391753 }
17401754
compiler/rustc_resolve/src/macros.rs+5-6
......@@ -9,7 +9,6 @@ use rustc_ast::expand::StrippedCfgItem;
99use rustc_ast::{self as ast, Crate, NodeId, attr};
1010use rustc_ast_pretty::pprust;
1111use rustc_attr_data_structures::StabilityLevel;
12use rustc_data_structures::intern::Interned;
1312use rustc_errors::{Applicability, DiagCtxtHandle, StashKey};
1413use rustc_expand::base::{
1514 Annotatable, DeriveResolution, Indeterminate, ResolverExpand, SyntaxExtension,
......@@ -80,7 +79,7 @@ pub(crate) enum MacroRulesScope<'ra> {
8079/// This helps to avoid uncontrollable growth of `macro_rules!` scope chains,
8180/// which usually grow linearly with the number of macro invocations
8281/// in a module (including derives) and hurt performance.
83pub(crate) type MacroRulesScopeRef<'ra> = Interned<'ra, Cell<MacroRulesScope<'ra>>>;
82pub(crate) type MacroRulesScopeRef<'ra> = &'ra Cell<MacroRulesScope<'ra>>;
8483
8584/// Macro namespace is separated into two sub-namespaces, one for bang macros and
8685/// one for attribute-like macros (attributes, derives).
......@@ -354,8 +353,8 @@ impl<'ra, 'tcx> ResolverExpand for Resolver<'ra, 'tcx> {
354353 if unused_arms.is_empty() {
355354 continue;
356355 }
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];
359358 let SyntaxExtensionKind::LegacyBang(ref ext) = m.ext.kind else {
360359 continue;
361360 };
......@@ -1132,7 +1131,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
11321131 }
11331132 }
11341133
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) {
11361135 // Reserve some names that are not quite covered by the general check
11371136 // performed on `Resolver::builtin_attrs`.
11381137 if ident.name == sym::cfg || ident.name == sym::cfg_attr {
......@@ -1148,7 +1147,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
11481147 ///
11491148 /// Possibly replace its expander to a pre-defined one for built-in macros.
11501149 pub(crate) fn compile_macro(
1151 &mut self,
1150 &self,
11521151 macro_def: &ast::MacroDef,
11531152 ident: Ident,
11541153 attrs: &[rustc_hir::Attribute],
library/core/src/marker.rs+5
......@@ -210,6 +210,11 @@ pub trait PointeeSized {
210210/// - `Trait` is dyn-compatible[^1].
211211/// - The type is sized.
212212/// - 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`.
213218/// - Structs `Foo<..., T1, ..., Tn, ...>` implement `Unsize<Foo<..., U1, ..., Un, ...>>`
214219/// where any number of (type and const) parameters may be changed if all of these conditions
215220/// 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>(
8282 let needle = needle as u32;
8383
8484 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) {
8686 Ok(idx) => idx + 1,
8787 Err(idx) => idx,
8888 };
library/std/src/sys/fs/unix.rs-1
......@@ -1491,7 +1491,6 @@ impl File {
14911491 target_os = "redox",
14921492 target_os = "espidf",
14931493 target_os = "horizon",
1494 target_os = "vxworks",
14951494 target_os = "nuttx",
14961495 )))]
14971496 let to_timespec = |time: Option<SystemTime>| match time {
library/std/src/sys/pal/unix/thread.rs+1-1
......@@ -222,7 +222,7 @@ impl Thread {
222222
223223 #[cfg(target_os = "vxworks")]
224224 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);
226226 let res = unsafe { libc::taskNameSet(libc::taskIdSelf(), name.as_mut_ptr()) };
227227 debug_assert_eq!(res, libc::OK);
228228 }
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
4242this target are:
4343
4444[@alexcrichton](https://github.com/alexcrichton)
45[@loganek](https://github.com/loganek)
4546
4647## Requirements
4748
src/tools/clippy/clippy_lints/src/unused_async.rs+1-1
......@@ -169,7 +169,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedAsync {
169169 let iter = self
170170 .unused_async_fns
171171 .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));
173173
174174 for fun in iter {
175175 span_lint_hir_and_then(
src/tools/clippy/clippy_utils/src/ty/mod.rs+2-2
......@@ -889,7 +889,7 @@ impl AdtVariantInfo {
889889 .enumerate()
890890 .map(|(i, f)| (i, approx_ty_size(cx, f.ty(cx.tcx, subst))))
891891 .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));
893893
894894 Self {
895895 ind: i,
......@@ -898,7 +898,7 @@ impl AdtVariantInfo {
898898 }
899899 })
900900 .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));
902902 variants_size
903903 }
904904}
src/tools/compiletest/src/runtest.rs+6
......@@ -1777,6 +1777,12 @@ impl<'test> TestCx<'test> {
17771777 // Allow tests to use internal features.
17781778 rustc.args(&["-A", "internal_features"]);
17791779
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
17801786 if self.props.force_host {
17811787 self.maybe_add_external_args(&mut rustc, &self.config.host_rustcflags);
17821788 if !is_rustdoc {
src/tools/run-make-support/CHANGELOG.md deleted-83
......@@ -1,83 +0,0 @@
1# Changelog
2
3All notable changes to the `run_make_support` library should be documented in this file.
4
5The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the support
6library should adhere to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) even if it's
7not intended for public consumption (it's moreso to help internally, to help test writers track
8changes to the support library).
9
10This support library will probably never reach 1.0. Please bump the minor version in `Cargo.toml` if
11you 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
50Consider this version to contain all changes made to the support library before we started to track
51changes 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 @@
11[package]
22name = "run_make_support"
3version = "0.2.0"
4edition = "2021"
3version = "0.0.0"
4edition = "2024"
55
66[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
713bstr = "1.12"
14gimli = "0.32"
15libc = "0.2"
816object = "0.37"
17regex = "1.11"
18serde_json = "1.0"
919similar = "2.7"
1020wasmparser = { version = "0.219", default-features = false, features = ["std"] }
11regex = "1.11"
12gimli = "0.32"
21# tidy-alphabetical-end
22
23# Shared with bootstrap and compiletest
1324build_helper = { path = "../../build_helper" }
14serde_json = "1.0"
15libc = "0.2"
1625
1726[lib]
1827crate-type = ["lib", "dylib"]
src/tools/run-make-support/src/artifact_names.rs+3-3
......@@ -2,7 +2,7 @@
22//! libraries which are target-dependent.
33
44use crate::target;
5use crate::targets::is_msvc;
5use crate::targets::is_windows_msvc;
66
77/// Construct the static library name based on the target.
88#[track_caller]
......@@ -10,7 +10,7 @@ use crate::targets::is_msvc;
1010pub fn static_lib_name(name: &str) -> String {
1111 assert!(!name.contains(char::is_whitespace), "static library name cannot contain whitespace");
1212
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") }
1414}
1515
1616/// Construct the dynamic library name based on the target.
......@@ -45,7 +45,7 @@ pub fn dynamic_lib_extension() -> &'static str {
4545#[track_caller]
4646#[must_use]
4747pub 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");
4949 assert!(!name.contains(char::is_whitespace), "import library name cannot contain whitespace");
5050
5151 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};
44use crate::external_deps::c_cxx_compiler::{cc, cxx};
55use crate::external_deps::llvm::llvm_ar;
66use crate::path_helpers::path;
7use crate::targets::{is_darwin, is_msvc, is_windows};
7use crate::targets::{is_darwin, is_windows, is_windows_msvc};
88
99// FIXME(Oneirical): These native build functions should take a Path-based generic.
1010
......@@ -24,12 +24,12 @@ pub fn build_native_static_lib_optimized(lib_name: &str) -> PathBuf {
2424
2525#[track_caller]
2626fn 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") };
2828 let src = format!("{lib_name}.c");
2929 let lib_path = static_lib_name(lib_name);
3030
3131 let mut cc = cc();
32 if !is_msvc() {
32 if !is_windows_msvc() {
3333 cc.arg("-v");
3434 }
3535 if optimzed {
......@@ -37,7 +37,7 @@ fn build_native_static_lib_internal(lib_name: &str, optimzed: bool) -> PathBuf {
3737 }
3838 cc.arg("-c").out_exe(&obj_file).input(src).optimize().run();
3939
40 let obj_file = if is_msvc() {
40 let obj_file = if is_windows_msvc() {
4141 PathBuf::from(format!("{lib_name}.obj"))
4242 } else {
4343 PathBuf::from(format!("{lib_name}.o"))
......@@ -50,16 +50,17 @@ fn build_native_static_lib_internal(lib_name: &str, optimzed: bool) -> PathBuf {
5050/// [`std::env::consts::DLL_PREFIX`] and [`std::env::consts::DLL_EXTENSION`].
5151#[track_caller]
5252pub 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") };
5454 let src = format!("{lib_name}.c");
5555 let lib_path = dynamic_lib_name(lib_name);
56 if is_msvc() {
56 if is_windows_msvc() {
5757 cc().arg("-c").out_exe(&obj_file).input(src).run();
5858 } else {
5959 cc().arg("-v").arg("-c").out_exe(&obj_file).input(src).run();
6060 };
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() {
6364 let out_arg = format!("-out:{lib_path}");
6465 cc().input(&obj_file).args(&["-link", "-dll", &out_arg]).run();
6566 } else if is_darwin() {
......@@ -79,15 +80,15 @@ pub fn build_native_dynamic_lib(lib_name: &str) -> PathBuf {
7980/// Built from a C++ file.
8081#[track_caller]
8182pub 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") };
8384 let src = format!("{lib_name}.cpp");
8485 let lib_path = static_lib_name(lib_name);
85 if is_msvc() {
86 if is_windows_msvc() {
8687 cxx().arg("-EHs").arg("-c").out_exe(&obj_file).input(src).run();
8788 } else {
8889 cxx().arg("-c").out_exe(&obj_file).input(src).run();
8990 };
90 let obj_file = if is_msvc() {
91 let obj_file = if is_windows_msvc() {
9192 PathBuf::from(format!("{lib_name}.obj"))
9293 } else {
9394 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 @@
11use std::path::Path;
22
33use crate::command::Command;
4use crate::{env_var, is_msvc};
4use crate::{env_var, is_windows_msvc};
55
66/// Construct a new platform-specific C compiler invocation.
77///
......@@ -82,7 +82,7 @@ impl Cc {
8282 pub fn out_exe(&mut self, name: &str) -> &mut Self {
8383 let mut path = std::path::PathBuf::from(name);
8484
85 if is_msvc() {
85 if is_windows_msvc() {
8686 path.set_extension("exe");
8787 let fe_path = path.clone();
8888 path.set_extension("");
......@@ -108,7 +108,7 @@ impl Cc {
108108 /// Optimize the output.
109109 /// Equivalent to `-O3` for GNU-compatible linkers or `-O2` for MSVC linkers.
110110 pub fn optimize(&mut self) -> &mut Self {
111 if is_msvc() {
111 if is_windows_msvc() {
112112 self.cmd.arg("-O2");
113113 } else {
114114 self.cmd.arg("-O3");
src/tools/run-make-support/src/external_deps/c_cxx_compiler/extras.rs+3-3
......@@ -1,9 +1,9 @@
1use crate::{is_msvc, is_win7, is_windows, uname};
1use crate::{is_win7, is_windows, is_windows_msvc, uname};
22
33/// `EXTRACFLAGS`
44pub fn extra_c_flags() -> Vec<&'static str> {
55 if is_windows() {
6 if is_msvc() {
6 if is_windows_msvc() {
77 let mut libs =
88 vec!["ws2_32.lib", "userenv.lib", "bcrypt.lib", "ntdll.lib", "synchronization.lib"];
99 if is_win7() {
......@@ -29,7 +29,7 @@ pub fn extra_c_flags() -> Vec<&'static str> {
2929/// `EXTRACXXFLAGS`
3030pub fn extra_cxx_flags() -> Vec<&'static str> {
3131 if is_windows() {
32 if is_msvc() { vec![] } else { vec!["-lstdc++"] }
32 if is_windows_msvc() { vec![] } else { vec!["-lstdc++"] }
3333 } else {
3434 match &uname()[..] {
3535 "Darwin" => vec!["-lc++"],
src/tools/run-make-support/src/external_deps/rustc.rs+2-2
......@@ -6,7 +6,7 @@ use crate::command::Command;
66use crate::env::env_var;
77use crate::path_helpers::cwd;
88use crate::util::set_host_compiler_dylib_path;
9use crate::{is_aix, is_darwin, is_msvc, is_windows, target, uname};
9use crate::{is_aix, is_darwin, is_windows, is_windows_msvc, target, uname};
1010
1111/// Construct a new `rustc` invocation. This will automatically set the library
1212/// search path as `-L cwd()`. Use [`bare_rustc`] to avoid this.
......@@ -377,7 +377,7 @@ impl Rustc {
377377 // So we end up with the following hack: we link use static:-bundle to only
378378 // link the parts of libstdc++ that we actually use, which doesn't include
379379 // the dependency on the pthreads DLL.
380 if !is_msvc() {
380 if !is_windows_msvc() {
381381 self.cmd.arg("-lstatic:-bundle=stdc++");
382382 };
383383 } else if is_darwin() {
src/tools/run-make-support/src/lib.rs+42-66
......@@ -3,9 +3,6 @@
33//! notably is built via cargo: this means that if your test wants some non-trivial utility, such
44//! as `object` or `wasmparser`, they can be re-exported and be made available through this library.
55
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)]
96#![warn(unreachable_pub)]
107
118mod command;
......@@ -22,8 +19,8 @@ pub mod path_helpers;
2219pub mod run;
2320pub mod scoped_run;
2421pub mod string;
25pub mod targets;
2622pub mod symbols;
23pub mod targets;
2724
2825// Internally we call our fs-related support module as `fs`, but re-export its content as `rfs`
2926// to tests to avoid colliding with commonly used `use std::fs;`.
......@@ -36,77 +33,56 @@ pub mod rfs {
3633}
3734
3835// Re-exports of third-party library crates.
39// tidy-alphabetical-start
40pub use bstr;
41pub use gimli;
42pub use libc;
43pub use object;
44pub use regex;
45pub use serde_json;
46pub use similar;
47pub use wasmparser;
48// tidy-alphabetical-end
36pub use {bstr, gimli, libc, object, regex, serde_json, similar, wasmparser};
4937
50// Re-exports of external dependencies.
51pub 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.
39pub 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,
5342};
54
55// These rely on external dependencies.
56pub use c_cxx_compiler::{Cc, Gcc, cc, cxx, extra_c_flags, extra_cxx_flags, gcc};
57pub use c_build::{
43pub 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
50pub use crate::diff::{Diff, diff};
51// Panic-on-fail [`std::env::var`] and [`std::env::var_os`] wrappers.
52pub use crate::env::{env_var, env_var_os, set_current_dir};
53pub use crate::external_deps::c_build::{
5854 build_native_dynamic_lib, build_native_static_lib, build_native_static_lib_cxx,
5955 build_native_static_lib_optimized,
6056};
61pub use cargo::cargo;
62pub use clang::{clang, Clang};
63pub use htmldocck::htmldocck;
64pub 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};
69pub use python::python_command;
70pub use rustc::{bare_rustc, rustc, rustc_path, Rustc};
71pub 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
76pub use diff::{diff, Diff};
77
78/// Panic-on-fail [`std::env::var`] and [`std::env::var_os`] wrappers.
79pub use env::{env_var, env_var_os, set_current_dir};
80
81/// Convenience helpers for running binaries and other commands.
82pub use run::{cmd, run, run_fail, run_with_args};
83
84/// Helpers for checking target information.
85pub 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.
58pub use crate::external_deps::c_cxx_compiler::{
59 Cc, Gcc, cc, cxx, extra_c_flags, extra_cxx_flags, gcc,
8860};
89
90/// Helpers for building names of output artifacts that are potentially target-specific.
91pub use artifact_names::{
92 bin_name, dynamic_lib_extension, dynamic_lib_name, msvc_import_dynamic_lib_name, rust_lib_name,
93 static_lib_name,
61pub use crate::external_deps::cargo::cargo;
62pub use crate::external_deps::clang::{Clang, clang};
63pub use crate::external_deps::htmldocck::htmldocck;
64pub 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,
9468};
95
96/// Path-related helpers.
97pub use path_helpers::{
69pub use crate::external_deps::python::python_command;
70pub use crate::external_deps::rustc::{self, Rustc, bare_rustc, rustc, rustc_path};
71pub use crate::external_deps::rustdoc::{Rustdoc, bare_rustdoc, rustdoc};
72// Path-related helpers.
73pub use crate::path_helpers::{
9874 build_root, cwd, filename_contains, filename_not_in_denylist, has_extension, has_prefix,
9975 has_suffix, not_contains, path, shallow_find_directories, shallow_find_files, source_root,
10076};
101
102/// Helpers for scoped test execution where certain properties are attempted to be maintained.
103pub use scoped_run::{run_in_tmpdir, test_while_readonly};
104
105pub 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
110pub use string::{
77// Convenience helpers for running binaries and other commands.
78pub use crate::run::{cmd, run, run_fail, run_with_args};
79// Helpers for scoped test execution where certain properties are attempted to be maintained.
80pub use crate::scoped_run::{run_in_tmpdir, test_while_readonly};
81pub use crate::string::{
11182 count_regex_matches_in_files_with_extension, invalid_utf8_contains, invalid_utf8_not_contains,
11283};
84// Helpers for checking target information.
85pub 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 @@
11use regex::Regex;
22
3use crate::{Rustc, is_msvc};
3use crate::{Rustc, is_windows_msvc};
44
55/// Asserts that `rustc` uses LLD for linking when executed.
66pub fn assert_rustc_uses_lld(rustc: &mut Rustc) {
......@@ -22,7 +22,7 @@ pub fn assert_rustc_doesnt_use_lld(rustc: &mut Rustc) {
2222
2323fn get_stderr_with_linker_messages(rustc: &mut Rustc) -> String {
2424 // 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" };
2626
2727 let output = rustc.arg("-Wlinker-messages").link_arg(linker_version_flag).run();
2828 output.stderr_utf8()
src/tools/run-make-support/src/targets.rs+3-9
......@@ -16,10 +16,10 @@ pub fn is_windows() -> bool {
1616 target().contains("windows")
1717}
1818
19/// Check if target uses msvc.
19/// Check if target is windows-msvc.
2020#[must_use]
21pub fn is_msvc() -> bool {
22 target().contains("msvc")
21pub fn is_windows_msvc() -> bool {
22 target().ends_with("windows-msvc")
2323}
2424
2525/// Check if target is windows-gnu.
......@@ -28,12 +28,6 @@ pub fn is_windows_gnu() -> bool {
2828 target().ends_with("windows-gnu")
2929}
3030
31/// Check if target is windows-msvc.
32#[must_use]
33pub fn is_windows_msvc() -> bool {
34 target().ends_with("windows-msvc")
35}
36
3731/// Check if target is win7.
3832#[must_use]
3933pub fn is_win7() -> bool {
src/tools/rust-analyzer/crates/rust-analyzer/src/cli/scip.rs+1-1
......@@ -25,7 +25,7 @@ impl flags::Scip {
2525 eprintln!("Generating SCIP start...");
2626 let now = Instant::now();
2727
28 let no_progress = &|s| (eprintln!("rust-analyzer: Loading {s}"));
28 let no_progress = &|s| eprintln!("rust-analyzer: Loading {s}");
2929 let root =
3030 vfs::AbsPathBuf::assert_utf8(std::env::current_dir()?.join(&self.path)).normalize();
3131
src/tools/test-float-parse/src/lib.rs+1-1
......@@ -340,7 +340,7 @@ fn launch_tests(tests: &mut [TestInfo], cfg: &Config) -> Duration {
340340 for test in tests.iter_mut() {
341341 test.progress = Some(ui::Progress::new(test, &mut all_progress_bars));
342342 ui::set_panic_hook(&all_progress_bars);
343 ((test.launch)(test, cfg));
343 (test.launch)(test, cfg);
344344 }
345345
346346 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>(
8080 let needle = needle as u32;
8181
8282 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) {
8484 Ok(idx) => idx + 1,
8585 Err(idx) => idx,
8686 };
tests/run-make/archive-duplicate-names/rmake.rs+4-4
......@@ -6,7 +6,7 @@
66//@ ignore-cross-compile
77// Reason: the compiled binary is executed
88
9use run_make_support::{cc, is_msvc, llvm_ar, rfs, run, rustc};
9use run_make_support::{cc, is_windows_msvc, llvm_ar, rfs, run, rustc};
1010
1111fn main() {
1212 rfs::create_dir("a");
......@@ -15,7 +15,7 @@ fn main() {
1515 compile_obj_force_foo("b", "bar");
1616 let mut ar = llvm_ar();
1717 ar.obj_to_ar().arg("libfoo.a");
18 if is_msvc() {
18 if is_windows_msvc() {
1919 ar.arg("a/foo.obj").arg("b/foo.obj").run();
2020 } else {
2121 ar.arg("a/foo.o").arg("b/foo.o").run();
......@@ -27,9 +27,9 @@ fn main() {
2727
2828#[track_caller]
2929pub 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") };
3131 let src = format!("{lib_name}.c");
32 if is_msvc() {
32 if is_windows_msvc() {
3333 cc().arg("-c").out_exe(&obj_file).input(src).run();
3434 } else {
3535 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 @@
33
44//@ ignore-cross-compile
55
6use run_make_support::{cc, cwd, dynamic_lib_extension, is_msvc, rfs, run, run_fail, rustc};
6use run_make_support::{
7 cc, cwd, dynamic_lib_extension, is_windows_msvc, rfs, run, run_fail, rustc,
8};
79
810fn main() {
911 rustc().input("foo.rs").run();
1012
11 if is_msvc() {
13 if is_windows_msvc() {
1214 let lib = "foo.dll.lib";
1315
1416 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 @@
88//@ needs-unwind
99// Reason: this test exercises unwinding a panic
1010
11use run_make_support::{cc, is_msvc, llvm_ar, run, rustc, static_lib_name};
11use run_make_support::{cc, is_windows_msvc, llvm_ar, run, rustc, static_lib_name};
1212
1313fn main() {
1414 // Compile `add.c` into an object file.
15 if is_msvc() {
15 if is_windows_msvc() {
1616 cc().arg("-c").out_exe("add").input("add.c").run();
1717 } else {
1818 cc().arg("-v").arg("-c").out_exe("add.o").input("add.c").run();
......@@ -24,7 +24,7 @@ fn main() {
2424 rustc().emit("obj").input("panic.rs").run();
2525
2626 // Now, create an archive using these two objects.
27 if is_msvc() {
27 if is_windows_msvc() {
2828 llvm_ar().obj_to_ar().args(&[&static_lib_name("add"), "add.obj", "panic.o"]).run();
2929 } else {
3030 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 @@
99
1010use run_make_support::{
1111 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,
1313 shallow_find_files, target,
1414};
1515
......@@ -19,7 +19,7 @@ fn main() {
1919 let sysroot = rustc().print("sysroot").run().stdout_utf8();
2020 let sysroot = sysroot.trim();
2121 let target_sysroot = path(sysroot).join("lib/rustlib").join(target()).join("lib");
22 if is_msvc() {
22 if is_windows_msvc() {
2323 let mut libs = shallow_find_files(&target_sysroot, |path| {
2424 has_prefix(path, "libstd-") && has_suffix(path, ".dll.lib")
2525 });
tests/run-make/cdylib/rmake.rs+2-2
......@@ -10,13 +10,13 @@
1010
1111//@ ignore-cross-compile
1212
13use run_make_support::{cc, cwd, dynamic_lib_name, is_msvc, rfs, run, rustc};
13use run_make_support::{cc, cwd, dynamic_lib_name, is_windows_msvc, rfs, run, rustc};
1414
1515fn main() {
1616 rustc().input("bar.rs").run();
1717 rustc().input("foo.rs").run();
1818
19 if is_msvc() {
19 if is_windows_msvc() {
2020 cc().input("foo.c").arg("foo.dll.lib").out_exe("foo").run();
2121 } else {
2222 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 @@
55
66//@ only-windows-gnu
77
8use run_make_support::{cxx, is_msvc, llvm_ar, run, rustc, static_lib_name};
8use run_make_support::{cxx, llvm_ar, run, rustc, static_lib_name};
99
1010fn main() {
1111 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 @@
66// checks that linker arguments remain intact and in the order they were originally passed in.
77// See https://github.com/rust-lang/rust/pull/70665
88
9use run_make_support::{is_msvc, rustc};
9use run_make_support::{is_windows_msvc, rustc};
1010
1111fn main() {
12 let linker = if is_msvc() { "msvc" } else { "ld" };
12 let linker = if is_windows_msvc() { "msvc" } else { "ld" };
1313
1414 rustc()
1515 .input("empty.rs")
tests/run-make/link-dedup/rmake.rs+2-2
......@@ -9,7 +9,7 @@
99
1010use std::fmt::Write;
1111
12use run_make_support::{is_msvc, rustc, target};
12use run_make_support::{is_windows_msvc, rustc, target};
1313
1414fn main() {
1515 rustc().input("depa.rs").run();
......@@ -32,7 +32,7 @@ fn main() {
3232fn needle_from_libs(libs: &[&str]) -> String {
3333 let mut needle = String::new();
3434 for lib in libs {
35 if is_msvc() {
35 if is_windows_msvc() {
3636 needle.write_fmt(format_args!(r#""{lib}.lib" "#)).unwrap();
3737 } else if target().contains("wasm") {
3838 needle.write_fmt(format_args!(r#""-l" "{lib}" "#)).unwrap();
tests/run-make/native-link-modifier-bundle/rmake.rs+2-2
......@@ -20,7 +20,7 @@
2020// Reason: cross-compilation fails to export native symbols
2121
2222use 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,
2424 static_lib_name,
2525};
2626
......@@ -60,7 +60,7 @@ fn main() {
6060 .assert_stdout_contains_regex("U _*native_func");
6161
6262 // This part of the test does not function on Windows MSVC - no symbols are printed.
63 if !is_msvc() {
63 if !is_windows_msvc() {
6464 // Build a cdylib, `native-staticlib` will not appear on the linker line because it was
6565 // bundled previously. The cdylib will contain the `native_func` symbol in the end.
6666 rustc()
tests/run-make/native-link-modifier-whole-archive/rmake.rs+3-3
......@@ -10,11 +10,11 @@
1010// Reason: compiling C++ code does not work well when cross-compiling
1111// plus, the compiled binary is executed
1212
13use run_make_support::{cxx, is_msvc, llvm_ar, run, run_with_args, rustc, static_lib_name};
13use run_make_support::{cxx, is_windows_msvc, llvm_ar, run, run_with_args, rustc, static_lib_name};
1414
1515fn main() {
1616 let mut cxx = cxx();
17 if is_msvc() {
17 if is_windows_msvc() {
1818 cxx.arg("-EHs");
1919 }
2020 cxx.input("c_static_lib_with_constructor.cpp")
......@@ -24,7 +24,7 @@ fn main() {
2424
2525 let mut llvm_ar = llvm_ar();
2626 llvm_ar.obj_to_ar();
27 if is_msvc() {
27 if is_windows_msvc() {
2828 llvm_ar
2929 .output_input(
3030 static_lib_name("c_static_lib_with_constructor"),
tests/run-make/pointer-auth-link-with-c/rmake.rs+3-3
......@@ -9,7 +9,7 @@
99//@ ignore-cross-compile
1010// Reason: the compiled binary is executed
1111
12use run_make_support::{build_native_static_lib, cc, is_msvc, llvm_ar, run, rustc};
12use run_make_support::{build_native_static_lib, cc, is_windows_msvc, llvm_ar, run, rustc};
1313
1414fn main() {
1515 build_native_static_lib("test");
......@@ -21,7 +21,7 @@ fn main() {
2121 .input("test.c")
2222 .arg("-mbranch-protection=bti+pac-ret+leaf")
2323 .run();
24 let obj_file = if is_msvc() { "test.obj" } else { "test" };
24 let obj_file = if is_windows_msvc() { "test.obj" } else { "test" };
2525 llvm_ar().obj_to_ar().output_input("libtest.a", &obj_file).run();
2626 rustc().arg("-Zbranch-protection=bti,pac-ret,leaf").input("test.rs").run();
2727 run("test");
......@@ -33,7 +33,7 @@ fn main() {
3333 // .input("test.c")
3434 // .arg("-mbranch-protection=bti+pac-ret+pc+leaf")
3535 // .run();
36 // let obj_file = if is_msvc() { "test.obj" } else { "test" };
36 // let obj_file = if is_windows_msvc() { "test.obj" } else { "test" };
3737 // llvm_ar().obj_to_ar().output_input("libtest.a", &obj_file).run();
3838 // rustc().arg("-Zbranch-protection=bti,pac-ret,pc,leaf").input("test.rs").run();
3939 // run("test");
tests/run-make/print-native-static-libs/rmake.rs+3-3
......@@ -12,7 +12,7 @@
1212//@ ignore-cross-compile
1313//@ ignore-wasm
1414
15use run_make_support::{is_msvc, rustc};
15use run_make_support::{is_windows_msvc, rustc};
1616
1717fn main() {
1818 // build supporting crate
......@@ -41,9 +41,9 @@ fn main() {
4141 ($lib:literal in $args:ident) => {{
4242 let lib = format!(
4343 "{}{}{}",
44 if !is_msvc() { "-l" } else { "" },
44 if !is_windows_msvc() { "-l" } else { "" },
4545 $lib,
46 if !is_msvc() { "" } else { ".lib" },
46 if !is_windows_msvc() { "" } else { ".lib" },
4747 );
4848 let found = $args.contains(&&*lib);
4949 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 @@
99//@ only-x86
1010//@ only-windows
1111
12use run_make_support::{build_native_dynamic_lib, diff, is_msvc, run, run_with_args, rustc};
12use run_make_support::{
13 build_native_dynamic_lib, diff, is_windows_msvc, run, run_with_args, rustc,
14};
1315
1416fn main() {
1517 rustc()
......@@ -21,7 +23,7 @@ fn main() {
2123 build_native_dynamic_lib("extern");
2224 let out = run("driver").stdout_utf8();
2325 diff().expected_file("output.txt").actual_text("actual", out).normalize(r#"\r"#, "").run();
24 if is_msvc() {
26 if is_windows_msvc() {
2527 let out_msvc = run_with_args("driver", &["true"]).stdout_utf8();
2628 diff()
2729 .expected_file("output.msvc.txt")
tests/run-make/raw-dylib-import-name-type/rmake.rs+2-2
......@@ -11,14 +11,14 @@
1111//@ only-windows
1212// Reason: this test specifically exercises a 32bit Windows calling convention.
1313
14use run_make_support::{cc, diff, is_msvc, run, rustc};
14use run_make_support::{cc, diff, is_windows_msvc, run, rustc};
1515
1616// NOTE: build_native_dynamic lib is not used, as the special `def` files
1717// must be passed to the CC compiler.
1818
1919fn main() {
2020 rustc().crate_type("bin").input("driver.rs").run();
21 if is_msvc() {
21 if is_windows_msvc() {
2222 cc().arg("-c").out_exe("extern").input("extern.c").run();
2323 cc().input("extern.obj")
2424 .arg("extern.msvc.def")
tests/run-make/raw-dylib-inline-cross-dylib/rmake.rs+2-2
......@@ -7,7 +7,7 @@
77
88//@ only-windows
99
10use run_make_support::{cc, diff, is_msvc, llvm_objdump, run, rustc};
10use run_make_support::{cc, diff, is_windows_msvc, llvm_objdump, run, rustc};
1111
1212fn main() {
1313 rustc()
......@@ -31,7 +31,7 @@ fn main() {
3131 .assert_stdout_not_contains("inline_library_function")
3232 // Make sure we do find an import to the functions we expect to be imported.
3333 .assert_stdout_contains("library_function");
34 if is_msvc() {
34 if is_windows_msvc() {
3535 cc().arg("-c").out_exe("extern_1").input("extern_1.c").run();
3636 cc().arg("-c").out_exe("extern_2").input("extern_2.c").run();
3737 cc().input("extern_1.obj")
tests/run-make/raw-dylib-link-ordinal/rmake.rs+2-2
......@@ -11,7 +11,7 @@
1111
1212//@ only-windows
1313
14use run_make_support::{cc, diff, is_msvc, run, rustc};
14use run_make_support::{cc, diff, is_windows_msvc, run, rustc};
1515
1616// NOTE: build_native_dynamic lib is not used, as the special `def` files
1717// must be passed to the CC compiler.
......@@ -19,7 +19,7 @@ use run_make_support::{cc, diff, is_msvc, run, rustc};
1919fn main() {
2020 rustc().crate_type("lib").crate_name("raw_dylib_test").input("lib.rs").run();
2121 rustc().crate_type("bin").input("driver.rs").run();
22 if is_msvc() {
22 if is_windows_msvc() {
2323 cc().arg("-c").out_exe("exporter").input("exporter.c").run();
2424 cc().input("exporter.obj")
2525 .arg("exporter.def")
tests/run-make/raw-dylib-stdcall-ordinal/rmake.rs+2-2
......@@ -10,7 +10,7 @@
1010//@ only-windows
1111// Reason: this test specifically exercises a 32bit Windows calling convention.
1212
13use run_make_support::{cc, diff, is_msvc, run, rustc};
13use run_make_support::{cc, diff, is_windows_msvc, run, rustc};
1414
1515// NOTE: build_native_dynamic lib is not used, as the special `def` files
1616// must be passed to the CC compiler.
......@@ -18,7 +18,7 @@ use run_make_support::{cc, diff, is_msvc, run, rustc};
1818fn main() {
1919 rustc().crate_type("lib").crate_name("raw_dylib_test").input("lib.rs").run();
2020 rustc().crate_type("bin").input("driver.rs").run();
21 if is_msvc() {
21 if is_windows_msvc() {
2222 cc().arg("-c").out_exe("exporter").input("exporter.c").run();
2323 cc().input("exporter.obj")
2424 .arg("exporter-msvc.def")
tests/run-make/rlib-format-packed-bundled-libs/rmake.rs+3-3
......@@ -8,8 +8,8 @@
88// Reason: cross-compilation fails to export native symbols
99
1010use 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,
1313};
1414
1515fn main() {
......@@ -74,7 +74,7 @@ fn main() {
7474 .assert_stdout_contains_regex("native_dep_1.*native_dep_2.*native_dep_3");
7575
7676 // The binary "main" will not contain any symbols on MSVC.
77 if !is_msvc() {
77 if !is_windows_msvc() {
7878 llvm_nm().input(bin_name("main")).run().assert_stdout_contains_regex("T.*native_f1");
7979 llvm_nm().input(bin_name("main")).run().assert_stdout_contains_regex("T.*native_f2");
8080 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;
6161
6262use run_make_support::rustc::Rustc;
6363use 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,
6666};
6767
6868/// `-C debuginfo`. See <https://doc.rust-lang.org/rustc/codegen-options/index.html#debuginfo>.
......@@ -1296,7 +1296,7 @@ fn main() {
12961296 // identify which combination isn't exercised with a 6-layers nested for loop iterating through
12971297 // each of the cli flag enum variants.
12981298
1299 if is_msvc() {
1299 if is_windows_msvc() {
13001300 // FIXME: the windows-msvc test coverage is sparse at best.
13011301
13021302 windows_msvc_tests::split_debuginfo(SplitDebuginfo::Off, DebuginfoLevel::Unspecified);
tests/run-make/static-dylib-by-default/rmake.rs+3-3
......@@ -9,7 +9,7 @@
99// Reason: the compiled binary is executed
1010
1111use 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,
1313 shallow_find_files,
1414};
1515
......@@ -22,13 +22,13 @@ fn main() {
2222 // bar.dll.exp // export library for the dylib
2323 // msvc's underlying link.exe requires the import library for the dynamic library as input.
2424 // 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") };
2626 cc().input("main.c").out_exe("main").arg(library).args(extra_c_flags()).run();
2727 for rlib in shallow_find_files(cwd(), |path| has_extension(path, "rlib")) {
2828 rfs::remove_file(rlib);
2929 }
3030 rfs::remove_file(dynamic_lib_name("foo"));
31 if is_msvc() {
31 if is_windows_msvc() {
3232 rfs::remove_file("foo.dll.lib");
3333 }
3434 run("main");
tests/run-make/staticlib-dylib-linkage/rmake.rs+2-2
......@@ -9,7 +9,7 @@
99//@ ignore-wasm
1010// Reason: WASM does not support dynamic libraries
1111
12use run_make_support::{cc, is_msvc, regex, run, rustc, static_lib_name};
12use run_make_support::{cc, is_windows_msvc, regex, run, rustc, static_lib_name};
1313
1414fn main() {
1515 rustc().arg("-Cprefer-dynamic").input("bar.rs").run();
......@@ -27,7 +27,7 @@ fn main() {
2727 let (_, native_link_args) = libs.split_once("note: native-static-libs: ").unwrap();
2828 // divide the command-line arguments in a vec
2929 let mut native_link_args = native_link_args.split(' ').collect::<Vec<&str>>();
30 if is_msvc() {
30 if is_windows_msvc() {
3131 // For MSVC pass the arguments on to the linker.
3232 native_link_args.insert(0, "-link");
3333 }
tests/run-make/symbol-visibility/rmake.rs+3-3
......@@ -9,7 +9,7 @@
99// See https://github.com/rust-lang/rust/issues/37530
1010
1111use run_make_support::object::read::Object;
12use run_make_support::{bin_name, dynamic_lib_name, is_msvc, object, regex, rfs, rustc};
12use run_make_support::{bin_name, dynamic_lib_name, is_windows_msvc, object, regex, rfs, rustc};
1313
1414fn main() {
1515 let cdylib_name = dynamic_lib_name("a_cdylib");
......@@ -64,7 +64,7 @@ fn main() {
6464 );
6565
6666 // 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() {
6868 // Check that an executable does not export any dynamic symbols
6969 symbols_check(&exe_name, SymbolCheckType::StrSymbol("public_c_function_from_rlib"), false);
7070 symbols_check(
......@@ -130,7 +130,7 @@ fn main() {
130130 );
131131
132132 // 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() {
134134 // Check that an executable does not export any dynamic symbols
135135 symbols_check(&exe_name, SymbolCheckType::StrSymbol("public_c_function_from_rlib"), false);
136136 symbols_check(
tests/ui-fulldeps/auxiliary/obtain-borrowck-input.rs+4
......@@ -28,6 +28,10 @@ const fn foo() -> usize {
2828 1
2929}
3030
31fn with_nested_body(opt: Option<i32>) -> Option<i32> {
32 opt.map(|x| x + 1)
33}
34
3135fn main() {
3236 let bar: [Bar; foo()] = [Bar::new()];
3337 assert_eq!(bar[0].provided(), foo());
tests/ui-fulldeps/obtain-borrowck.rs+12-8
......@@ -9,16 +9,17 @@
99
1010//! This program implements a rustc driver that retrieves MIR bodies with
1111//! 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.
1414//! 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`
1717//! callback triggers borrow checking of all MIR bodies by retrieving
1818//! `optimized_mir` and pulls out the MIR bodies with the borrowck information
1919//! from the thread local storage.
2020
2121extern crate rustc_borrowck;
22extern crate rustc_data_structures;
2223extern crate rustc_driver;
2324extern crate rustc_hir;
2425extern crate rustc_interface;
......@@ -30,6 +31,7 @@ use std::collections::HashMap;
3031use std::thread_local;
3132
3233use rustc_borrowck::consumers::{self, BodyWithBorrowckFacts, ConsumerOptions};
34use rustc_data_structures::fx::FxHashMap;
3335use rustc_driver::Compilation;
3436use rustc_hir::def::DefKind;
3537use rustc_hir::def_id::LocalDefId;
......@@ -129,13 +131,15 @@ thread_local! {
129131
130132fn mir_borrowck<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> ProvidedValue<'tcx> {
131133 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);
133135 // 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) };
136138 MIR_BODIES.with(|state| {
137139 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 }
139143 });
140144 let mut providers = Providers::default();
141145 rustc_borrowck::provide(&mut providers);
tests/ui-fulldeps/obtain-borrowck.run.stdout+2
......@@ -3,6 +3,8 @@ Bodies retrieved for:
33::foo
44::main
55::main::{constant#0}
6::with_nested_body
7::with_nested_body::{closure#0}
68::{impl#0}::new
79::{impl#1}::provided
810::{impl#1}::required
tests/ui/async-await/issues/issue-54752-async-block.rs-1
......@@ -4,4 +4,3 @@
44//@ pp-exact
55
66fn 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 @@
1warning: unnecessary parentheses around assigned value
2 --> $DIR/issue-54752-async-block.rs:6:22
3 |
4LL | fn main() { let _a = (async { }); }
5 | ^ ^
6 |
7 = note: `#[warn(unused_parens)]` on by default
8help: remove these parentheses
9 |
10LL - fn main() { let _a = (async { }); }
11LL + fn main() { let _a = async { }; }
12 |
13
14warning: 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
6fn long_expr_that_does_not_require_braces_long_expr_that_does_not_require_braces_long_expr_that_does_not_require_braces()
7{}
8
9fn func(f: impl FnOnce()) {
10 f()
11}
12
13pub 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
6fn long_expr_that_does_not_require_braces_long_expr_that_does_not_require_braces_long_expr_that_does_not_require_braces()
7{}
8
9fn func(f: impl FnOnce()) {
10 f()
11}
12
13pub 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 @@
1error: unnecessary parentheses around closure body
2 --> $DIR/closure-body-issue-136741.rs:15:16
3 |
4LL | let _ = || (0 == 0);
5 | ^ ^
6 |
7note: the lint level is defined here
8 --> $DIR/closure-body-issue-136741.rs:3:9
9 |
10LL | #![deny(unused_parens)]
11 | ^^^^^^^^^^^^^
12help: remove these parentheses
13 |
14LL - let _ = || (0 == 0);
15LL + let _ = || 0 == 0;
16 |
17
18error: unnecessary parentheses around closure body
19 --> $DIR/closure-body-issue-136741.rs:16:28
20 |
21LL | let _ = (0..).find(|n| (n % 2 == 0));
22 | ^ ^
23 |
24help: remove these parentheses
25 |
26LL - let _ = (0..).find(|n| (n % 2 == 0));
27LL + let _ = (0..).find(|n| n % 2 == 0);
28 |
29
30error: unnecessary parentheses around closure body
31 --> $DIR/closure-body-issue-136741.rs:25:28
32 |
33LL | let _ = (0..).find(|n| (
34 | _____________________________^
35LL | | n % 2 == 0
36 | | ________^__________^
37 | ||________|
38 | |
39LL | | ));
40 | |_____^
41 |
42help: remove these parentheses
43 |
44LL - let _ = (0..).find(|n| (
45LL - n % 2 == 0
46LL + let _ = (0..).find(|n| n % 2 == 0);
47 |
48
49error: unnecessary parentheses around block return value
50 --> $DIR/closure-body-issue-136741.rs:31:9
51 |
52LL | (0 == 0)
53 | ^ ^
54 |
55help: remove these parentheses
56 |
57LL - (0 == 0)
58LL + 0 == 0
59 |
60
61error: aborting due to 4 previous errors
62
triagebot.toml+7
......@@ -535,6 +535,9 @@ trigger_files = [
535535[autolabel."S-waiting-on-review"]
536536new_pr = true
537537
538[autolabel."S-waiting-on-author"]
539new_draft = true
540
538541[autolabel."needs-triage"]
539542new_issue = true
540543exclude_labels = [
......@@ -1089,6 +1092,10 @@ cc = ["@jieyouxu"]
10891092message = "The list of allowed third-party dependencies may have been modified! You must ensure that any new dependencies have compatible licenses before merging."
10901093cc = ["@davidtwco", "@wesleywiser"]
10911094
1095[mentions."src/tools/tidy/src/ext_tool_checks.rs"]
1096message = "`tidy` extra checks were modified."
1097cc = ["@lolbinarycat"]
1098
10921099[mentions."src/bootstrap/src/core/config"]
10931100message = """
10941101This PR modifies `src/bootstrap/src/core/config`.