Skip to content

Commit 41dca5b

Browse files
committed
Auto merge of #152185 - JonathanBrouwer:rollup-JuaHm6e, r=JonathanBrouwer
Rollup of 11 pull requests Successful merges: - #152174 (stdarch subtree update) - #151278 (Provide more context on trait bounds being unmet due to imperfect derive) - #151955 (escape symbol names in global asm) - #149329 (Mark match arms in try and for as being from desugarings.) - #151474 (Minor structural improvements) - #151744 (fix refining_impl_trait suggestion with return_type_notation) - #152107 (Convert to inline diagnostics in `rustc_borrowck`) - #152117 (Convert to inline diagnostics in `rustc_trait_selection`) - #152136 (Consolidate type const checks on `tcx.is_type_const`) - #152170 (Port `rustc_effective_visibility` to the new attribute parser) - #152184 (Port rustc_abi to the attribute parser)
2 parents f889772 + bd85423 commit 41dca5b

File tree

156 files changed

+3328
-3616
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

156 files changed

+3328
-3616
lines changed

Cargo.lock

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3571,7 +3571,6 @@ dependencies = [
35713571
"rustc_abi",
35723572
"rustc_data_structures",
35733573
"rustc_errors",
3574-
"rustc_fluent_macro",
35753574
"rustc_graphviz",
35763575
"rustc_hir",
35773576
"rustc_index",
@@ -3771,7 +3770,6 @@ dependencies = [
37713770
"rustc_abi",
37723771
"rustc_ast",
37733772
"rustc_ast_pretty",
3774-
"rustc_borrowck",
37753773
"rustc_codegen_ssa",
37763774
"rustc_const_eval",
37773775
"rustc_data_structures",
@@ -3797,7 +3795,6 @@ dependencies = [
37973795
"rustc_session",
37983796
"rustc_span",
37993797
"rustc_target",
3800-
"rustc_trait_selection",
38013798
"serde_json",
38023799
"shlex",
38033800
"tracing",
@@ -4724,7 +4721,6 @@ dependencies = [
47244721
"rustc_ast",
47254722
"rustc_data_structures",
47264723
"rustc_errors",
4727-
"rustc_fluent_macro",
47284724
"rustc_hir",
47294725
"rustc_infer",
47304726
"rustc_macros",

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -966,14 +966,14 @@ impl<'hir> LoweringContext<'_, 'hir> {
966966
hir::ExprKind::Break(this.lower_loop_destination(None), Some(x_expr));
967967
this.arena.alloc(this.expr(gen_future_span, expr_break))
968968
});
969-
self.arm(ready_pat, break_x)
969+
self.arm(ready_pat, break_x, span)
970970
};
971971

972972
// `::std::task::Poll::Pending => {}`
973973
let pending_arm = {
974974
let pending_pat = self.pat_lang_item_variant(span, hir::LangItem::PollPending, &[]);
975975
let empty_block = self.expr_block_empty(span);
976-
self.arm(pending_pat, empty_block)
976+
self.arm(pending_pat, empty_block, span)
977977
};
978978

979979
let inner_match_stmt = {
@@ -1027,7 +1027,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
10271027
});
10281028

10291029
// mut __awaitee => loop { ... }
1030-
let awaitee_arm = self.arm(awaitee_pat, loop_expr);
1030+
let awaitee_arm = self.arm(awaitee_pat, loop_expr, span);
10311031

10321032
// `match ::std::future::IntoFuture::into_future(<expr>) { ... }`
10331033
let into_future_expr = match await_kind {
@@ -1817,7 +1817,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
18171817
let break_expr =
18181818
self.with_loop_scope(loop_hir_id, |this| this.expr_break_alloc(for_span));
18191819
let pat = self.pat_none(for_span);
1820-
self.arm(pat, break_expr)
1820+
self.arm(pat, break_expr, for_span)
18211821
};
18221822

18231823
// Some(<pat>) => <body>,
@@ -1826,7 +1826,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
18261826
let body_block =
18271827
self.with_loop_scope(loop_hir_id, |this| this.lower_block(body, false));
18281828
let body_expr = self.arena.alloc(self.expr_block(body_block));
1829-
self.arm(some_pat, body_expr)
1829+
self.arm(some_pat, body_expr, for_span)
18301830
};
18311831

18321832
// `mut iter`
@@ -1885,7 +1885,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
18851885
let loop_expr = self.arena.alloc(hir::Expr { hir_id: loop_hir_id, kind, span: for_span });
18861886

18871887
// `mut iter => { ... }`
1888-
let iter_arm = self.arm(iter_pat, loop_expr);
1888+
let iter_arm = self.arm(iter_pat, loop_expr, for_span);
18891889

18901890
let match_expr = match loop_kind {
18911891
ForLoopKind::For => {
@@ -1930,7 +1930,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
19301930
hir::LangItem::IntoAsyncIterIntoIter,
19311931
arena_vec![self; head],
19321932
);
1933-
let iter_arm = self.arm(async_iter_pat, inner_match_expr);
1933+
let iter_arm = self.arm(async_iter_pat, inner_match_expr, for_span);
19341934
self.arena.alloc(self.expr_match(
19351935
for_span,
19361936
iter,
@@ -1997,7 +1997,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
19971997
let val_expr = self.expr_ident(span, val_ident, val_pat_nid);
19981998
self.lower_attrs(val_expr.hir_id, &attrs, span, Target::Expression);
19991999
let continue_pat = self.pat_cf_continue(unstable_span, val_pat);
2000-
self.arm(continue_pat, val_expr)
2000+
self.arm(continue_pat, val_expr, try_span)
20012001
};
20022002

20032003
// `ControlFlow::Break(residual) =>
@@ -2040,7 +2040,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
20402040
self.lower_attrs(ret_expr.hir_id, &attrs, span, Target::Expression);
20412041

20422042
let break_pat = self.pat_cf_break(try_span, residual_local);
2043-
self.arm(break_pat, ret_expr)
2043+
self.arm(break_pat, ret_expr, try_span)
20442044
};
20452045

20462046
hir::ExprKind::Match(
@@ -2368,12 +2368,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
23682368
&mut self,
23692369
pat: &'hir hir::Pat<'hir>,
23702370
expr: &'hir hir::Expr<'hir>,
2371+
span: Span,
23712372
) -> hir::Arm<'hir> {
23722373
hir::Arm {
23732374
hir_id: self.next_id(),
23742375
pat,
23752376
guard: None,
2376-
span: self.lower_span(expr.span),
2377+
span: self.lower_span(span),
23772378
body: expr,
23782379
}
23792380
}

compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,3 +721,42 @@ impl<S: Stage> CombineAttributeParser<S> for RustcThenThisWouldNeedParser {
721721
Some(ident)
722722
}
723723
}
724+
725+
pub(crate) struct RustcEffectiveVisibilityParser;
726+
727+
impl<S: Stage> NoArgsAttributeParser<S> for RustcEffectiveVisibilityParser {
728+
const PATH: &'static [Symbol] = &[sym::rustc_effective_visibility];
729+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
730+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
731+
Allow(Target::Use),
732+
Allow(Target::Static),
733+
Allow(Target::Const),
734+
Allow(Target::Fn),
735+
Allow(Target::Closure),
736+
Allow(Target::Mod),
737+
Allow(Target::ForeignMod),
738+
Allow(Target::TyAlias),
739+
Allow(Target::Enum),
740+
Allow(Target::Variant),
741+
Allow(Target::Struct),
742+
Allow(Target::Field),
743+
Allow(Target::Union),
744+
Allow(Target::Trait),
745+
Allow(Target::TraitAlias),
746+
Allow(Target::Impl { of_trait: false }),
747+
Allow(Target::Impl { of_trait: true }),
748+
Allow(Target::AssocConst),
749+
Allow(Target::Method(MethodKind::Inherent)),
750+
Allow(Target::Method(MethodKind::Trait { body: false })),
751+
Allow(Target::Method(MethodKind::Trait { body: true })),
752+
Allow(Target::Method(MethodKind::TraitImpl)),
753+
Allow(Target::AssocTy),
754+
Allow(Target::ForeignFn),
755+
Allow(Target::ForeignStatic),
756+
Allow(Target::ForeignTy),
757+
Allow(Target::MacroDef),
758+
Allow(Target::PatField),
759+
Allow(Target::Crate),
760+
]);
761+
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcEffectiveVisibility;
762+
}

compiler/rustc_attr_parsing/src/attributes/test_attrs.rs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use rustc_hir::attrs::RustcAbiAttrKind;
12
use rustc_session::lint::builtin::ILL_FORMED_ATTRIBUTE_INPUT;
23

34
use super::prelude::*;
@@ -140,3 +141,52 @@ impl<S: Stage> SingleAttributeParser<S> for ReexportTestHarnessMainParser {
140141
Some(AttributeKind::ReexportTestHarnessMain(name))
141142
}
142143
}
144+
145+
pub(crate) struct RustcAbiParser;
146+
147+
impl<S: Stage> SingleAttributeParser<S> for RustcAbiParser {
148+
const PATH: &[Symbol] = &[sym::rustc_abi];
149+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
150+
const TEMPLATE: AttributeTemplate = template!(OneOf: &[sym::debug, sym::assert_eq]);
151+
const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepOutermost;
152+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
153+
Allow(Target::TyAlias),
154+
Allow(Target::Fn),
155+
Allow(Target::ForeignFn),
156+
Allow(Target::Method(MethodKind::Inherent)),
157+
Allow(Target::Method(MethodKind::Trait { body: true })),
158+
Allow(Target::Method(MethodKind::Trait { body: false })),
159+
Allow(Target::Method(MethodKind::TraitImpl)),
160+
]);
161+
162+
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option<AttributeKind> {
163+
let Some(args) = args.list() else {
164+
cx.expected_specific_argument_and_list(cx.attr_span, &[sym::assert_eq, sym::debug]);
165+
return None;
166+
};
167+
168+
let Some(arg) = args.single() else {
169+
cx.expected_single_argument(cx.attr_span);
170+
return None;
171+
};
172+
173+
let fail_incorrect_argument =
174+
|span| cx.expected_specific_argument(span, &[sym::assert_eq, sym::debug]);
175+
176+
let Some(arg) = arg.meta_item() else {
177+
fail_incorrect_argument(args.span);
178+
return None;
179+
};
180+
181+
let kind: RustcAbiAttrKind = match arg.path().word_sym() {
182+
Some(sym::assert_eq) => RustcAbiAttrKind::AssertEq,
183+
Some(sym::debug) => RustcAbiAttrKind::Debug,
184+
None | Some(_) => {
185+
fail_incorrect_argument(arg.span());
186+
return None;
187+
}
188+
};
189+
190+
Some(AttributeKind::RustcAbi { attr_span: cx.attr_span, kind })
191+
}
192+
}

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ attribute_parsers!(
191191
Single<ProcMacroDeriveParser>,
192192
Single<RecursionLimitParser>,
193193
Single<ReexportTestHarnessMainParser>,
194+
Single<RustcAbiParser>,
194195
Single<RustcAllocatorZeroedVariantParser>,
195196
Single<RustcBuiltinMacroParser>,
196197
Single<RustcForceInlineParser>,
@@ -258,6 +259,7 @@ attribute_parsers!(
258259
Single<WithoutArgs<RustcDumpPredicatesParser>>,
259260
Single<WithoutArgs<RustcDumpUserArgsParser>>,
260261
Single<WithoutArgs<RustcDumpVtableParser>>,
262+
Single<WithoutArgs<RustcEffectiveVisibilityParser>>,
261263
Single<WithoutArgs<RustcHasIncoherentInherentImplsParser>>,
262264
Single<WithoutArgs<RustcHiddenTypeOfOpaquesParser>>,
263265
Single<WithoutArgs<RustcLintOptTyParser>>,

compiler/rustc_borrowck/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ polonius-engine = "0.13.0"
1111
rustc_abi = { path = "../rustc_abi" }
1212
rustc_data_structures = { path = "../rustc_data_structures" }
1313
rustc_errors = { path = "../rustc_errors" }
14-
rustc_fluent_macro = { path = "../rustc_fluent_macro" }
1514
rustc_graphviz = { path = "../rustc_graphviz" }
1615
rustc_hir = { path = "../rustc_hir" }
1716
rustc_index = { path = "../rustc_index" }

0 commit comments

Comments
 (0)