Skip to content

Commit 4dcd02e

Browse files
khyperiaBoxyUwU
andcommitted
rename direct_const_arg! to gca!
Co-authored-by: Boxy <[email protected]>
1 parent 1a82b5d commit 4dcd02e

274 files changed

Lines changed: 1325 additions & 1042 deletions

File tree

Some content is hidden

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

‎compiler/rustc_ast/src/ast.rs‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1623,7 +1623,7 @@ impl Expr {
16231623
| ExprKind::UnsafeBinderCast(..)
16241624
| ExprKind::While(..)
16251625
| ExprKind::Yield(YieldKind::Postfix(..))
1626-
| ExprKind::DirectConstArg(..)
1626+
| ExprKind::GcaMacro(..)
16271627
| ExprKind::Err(_)
16281628
| ExprKind::Dummy => prefix_attrs_precedence(&self.attrs),
16291629
}
@@ -1920,8 +1920,8 @@ pub enum ExprKind {
19201920

19211921
UnsafeBinderCast(UnsafeBinderCastKind, Box<Expr>, Option<Box<Ty>>),
19221922

1923-
/// An mGCA `direct_const_arg!()` expression.
1924-
DirectConstArg(Box<Expr>),
1923+
/// An mGCA `gca!()` expression.
1924+
GcaMacro(Box<Expr>),
19251925

19261926
/// Placeholder for an expression that wasn't syntactically well formed in some way.
19271927
Err(ErrorGuaranteed),
@@ -2579,8 +2579,8 @@ pub enum TyKind {
25792579
FieldOf(Box<Ty>, Option<Ident>, Ident),
25802580
/// A view of a type. `T.{ field_1, field_2 }`.
25812581
View(Box<Ty>, #[visitable(ignore)] ThinVec<Ident>),
2582-
/// An mGCA `direct_const_arg!()` expression.
2583-
DirectConstArg(Box<Expr>),
2582+
/// An mGCA `gca!()` expression.
2583+
GcaMacro(Box<Expr>),
25842584
/// Sometimes we need a dummy value when no error has occurred.
25852585
Dummy,
25862586
/// Placeholder for a kind that has failed to be defined.

‎compiler/rustc_ast/src/util/classify.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ pub fn leading_labeled_expr(mut expr: &ast::Expr) -> bool {
158158
| Yeet(..)
159159
| Yield(..)
160160
| UnsafeBinderCast(..)
161-
| DirectConstArg(..)
161+
| GcaMacro(..)
162162
| Err(..)
163163
| Dummy => return false,
164164
}
@@ -244,7 +244,7 @@ pub fn expr_trailing_brace(mut expr: &ast::Expr) -> Option<TrailingBrace<'_>> {
244244
| Try(_)
245245
| Yeet(None)
246246
| UnsafeBinderCast(..)
247-
| DirectConstArg(..)
247+
| GcaMacro(..)
248248
| Err(_)
249249
| Dummy => {
250250
break None;
@@ -307,7 +307,7 @@ fn type_trailing_braced_mac_call(mut ty: &ast::Ty) -> Option<&ast::MacCall> {
307307
| ast::TyKind::Pat(..)
308308
| ast::TyKind::FieldOf(..)
309309
| ast::TyKind::View(..)
310-
| ast::TyKind::DirectConstArg(..)
310+
| ast::TyKind::GcaMacro(..)
311311
| ast::TyKind::Dummy
312312
| ast::TyKind::Err(..) => break None,
313313
}

‎compiler/rustc_ast/src/visit.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1112,7 +1112,7 @@ macro_rules! common_visitor_and_walkers {
11121112
visit_visitable!(vis, bytes),
11131113
ExprKind::UnsafeBinderCast(kind, expr, ty) =>
11141114
visit_visitable!(vis, kind, expr, ty),
1115-
ExprKind::DirectConstArg(expr) =>
1115+
ExprKind::GcaMacro(expr) =>
11161116
visit_visitable!(vis, expr),
11171117
ExprKind::Err(_guar) => {}
11181118
ExprKind::Dummy => {}

‎compiler/rustc_ast_lowering/src/expr.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,8 +544,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
544544

545545
ExprKind::MacCall(_) => panic!("{:?} shouldn't exist here", e.span),
546546

547-
ExprKind::DirectConstArg(expr) => {
548-
let e = self.emit_bad_direct_const_arg(e.span, expr, "expression");
547+
ExprKind::GcaMacro(expr) => {
548+
let e = self.emit_bad_gca_macro(e.span, expr, "expression");
549549
hir::ExprKind::Err(e)
550550
}
551551
};

‎compiler/rustc_ast_lowering/src/lib.rs‎

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1489,9 +1489,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
14891489
let ct = self.arena.alloc(ct);
14901490
return GenericArg::Const(ct.try_as_ambig_ct().unwrap());
14911491
}
1492-
TyKind::DirectConstArg(expr)
1493-
if self.tcx.features().min_generic_const_args() =>
1494-
{
1492+
TyKind::GcaMacro(expr) if self.tcx.features().min_generic_const_args() => {
14951493
let ct = match self.can_lower_expr_to_const_arg_direct(
14961494
expr,
14971495
DirectConstArgContext::MacrolessMinGenericConstArgs,
@@ -1797,8 +1795,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
17971795
let fields = self.arena.alloc_slice(fields);
17981796
hir::TyKind::View(ty, fields)
17991797
}
1800-
TyKind::DirectConstArg(expr) => {
1801-
let e = self.emit_bad_direct_const_arg(t.span, expr, "type");
1798+
TyKind::GcaMacro(expr) => {
1799+
let e = self.emit_bad_gca_macro(t.span, expr, "type");
18021800
hir::TyKind::Err(e)
18031801
}
18041802
TyKind::Dummy => panic!("`TyKind::Dummy` should never be lowered"),
@@ -1807,16 +1805,16 @@ impl<'hir> LoweringContext<'_, 'hir> {
18071805
hir::Ty { kind, span: self.lower_span(t.span), hir_id: self.lower_node_id(t.id) }
18081806
}
18091807

1810-
pub(crate) fn emit_bad_direct_const_arg(
1808+
pub(crate) fn emit_bad_gca_macro(
18111809
&mut self,
18121810
span: Span,
18131811
expr: &Expr,
18141812
expected: &'static str,
18151813
) -> ErrorGuaranteed {
1816-
let msg = format!("expected {expected}, found `direct_const_arg!()` constant");
1814+
let msg = format!("expected {expected}, found `gca!()` constant");
18171815
if expr::WillCreateDefIdsVisitor.visit_expr(expr).is_break() {
18181816
// FIXME(mgca): make this non-fatal once we have a better way to handle
1819-
// nested items in invalid `direct_const_arg!()` arguments.
1817+
// nested items in invalid `gca!()` arguments.
18201818
self.dcx().span_fatal(span, msg)
18211819
} else {
18221820
self.dcx().span_err(span, msg)
@@ -2711,9 +2709,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
27112709
.is_ok()
27122710
} else {
27132711
// do not check can_lower_expr_to_const_arg_direct, but rather just
2714-
// ExprKind::DirectConstArg, because we don't want e.g.
2712+
// ExprKind::GcaMacro, because we don't want e.g.
27152713
// `impl<const N: u8> { const C: u8 = N; }` to be a direct-rhs const
2716-
matches!(body, Expr { kind: ExprKind::DirectConstArg(_), .. })
2714+
matches!(body, Expr { kind: ExprKind::GcaMacro(_), .. })
27172715
}
27182716
};
27192717
if self.tcx.features().min_generic_const_args()
@@ -2816,7 +2814,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
28162814
Ok(())
28172815
}
28182816
(ExprKind::ConstBlock(_), MacrolessMinGenericConstArgs) => Ok(()),
2819-
(ExprKind::DirectConstArg(_), MacrolessMinGenericConstArgs | MinGenericConstArgs) => {
2817+
(ExprKind::GcaMacro(_), MacrolessMinGenericConstArgs | MinGenericConstArgs) => {
28202818
// Always report this as able to be represented directly. If it turns out not to be,
28212819
// `lower_expr_to_const_arg_direct` will report an error.
28222820
Ok(())
@@ -2998,11 +2996,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
29982996
span,
29992997
}
30002998
}
3001-
ExprKind::DirectConstArg(expr) => {
2999+
ExprKind::GcaMacro(expr) => {
30023000
// `can_lower_expr_to_const_arg_direct` always returns success upon encountering a
3003-
// ExprKind::DirectConstArg, which effectively forces the expression to be lowered
3004-
// as a direct arg. If it actually turns out to not be possible, emit an error
3005-
// instead.
3001+
// ExprKind::GcaMacro, which effectively forces the expression to be lowered as a
3002+
// direct arg. If it actually turns out to not be possible, emit an error instead.
30063003
// Always use MacrolessMinGenericConstArgs, even if we're under regular GCA, because
30073004
// that's what the macro means: to enter a context that is like macroless GCA.
30083005
match self.can_lower_expr_to_const_arg_direct(
@@ -3354,12 +3351,12 @@ enum DirectConstArgContext {
33543351
/// The only allowed direct const arg representation is simple paths that nameres to generic
33553352
/// const parameters.
33563353
Stable,
3357-
/// The allowed representations are what is allowed on stable, plus the `direct_const_arg!` macro.
3354+
/// The allowed representations are what is allowed on stable, plus the `gca!` macro.
33583355
MinGenericConstArgs,
33593356
/// Expressions attempt to be lowered directly, and if that fails, the expression falls back to
33603357
/// being represented as an anon const.
33613358
///
3362-
/// This context is also used under MinGenericConstArgs inside a `direct_const_arg!` macro, for
3359+
/// This context is also used under MinGenericConstArgs inside a `gca!` macro, for
33633360
/// simplicity, as they allow the same code.
33643361
MacrolessMinGenericConstArgs,
33653362
}

‎compiler/rustc_ast_pretty/src/pprust/state.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,8 +1460,8 @@ impl<'a> State<'a> {
14601460
self.print_type(ty);
14611461
self.print_view(fields);
14621462
}
1463-
ast::TyKind::DirectConstArg(expr) => {
1464-
self.word_nbsp("core::direct_const_arg!");
1463+
ast::TyKind::GcaMacro(expr) => {
1464+
self.word_nbsp("core::gca!");
14651465
self.popen();
14661466
self.print_expr(expr, FixupContext::default());
14671467
self.pclose();

‎compiler/rustc_ast_pretty/src/pprust/state/expr.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -883,8 +883,8 @@ impl<'a> State<'a> {
883883
self.word("/*DUMMY*/");
884884
self.pclose();
885885
}
886-
ast::ExprKind::DirectConstArg(expr) => {
887-
self.word_nbsp("core::direct_const_arg!");
886+
ast::ExprKind::GcaMacro(expr) => {
887+
self.word_nbsp("core::gca!");
888888
self.popen();
889889
self.print_expr(expr, FixupContext::default());
890890
self.pclose()

‎compiler/rustc_builtin_macros/src/assert/context.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ impl<'cx, 'a> Context<'cx, 'a> {
321321
| ExprKind::Yeet(_)
322322
| ExprKind::Become(_)
323323
| ExprKind::Yield(_)
324-
| ExprKind::DirectConstArg(_)
324+
| ExprKind::GcaMacro(_)
325325
| ExprKind::UnsafeBinderCast(..) => {}
326326
}
327327
}

compiler/rustc_builtin_macros/src/direct_const_arg.rs renamed to compiler/rustc_builtin_macros/src/gca.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ pub(crate) fn expand<'cx>(
1010
span: Span,
1111
tts: TokenStream,
1212
) -> MacroExpanderResult<'cx> {
13-
let ExpandResult::Ready(expr) = get_single_expr_from_tts(cx, span, tts, "direct_const_arg!")
14-
else {
13+
let ExpandResult::Ready(expr) = get_single_expr_from_tts(cx, span, tts, "gca!") else {
1514
return ExpandResult::Retry(());
1615
};
1716
let expr = match expr {
@@ -23,12 +22,12 @@ pub(crate) fn expand<'cx>(
2322
ExpandResult::Ready(Box::new(base::MacEager {
2423
expr: Some(Box::new(ast::Expr {
2524
id,
26-
kind: ast::ExprKind::DirectConstArg(expr.clone()),
25+
kind: ast::ExprKind::GcaMacro(expr.clone()),
2726
span,
2827
attrs: Default::default(),
2928
tokens: None,
3029
})),
31-
ty: Some(Box::new(ast::Ty { id, kind: ast::TyKind::DirectConstArg(expr), span })),
30+
ty: Some(Box::new(ast::Ty { id, kind: ast::TyKind::GcaMacro(expr), span })),
3231
..Default::default()
3332
}))
3433
}

‎compiler/rustc_builtin_macros/src/lib.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ mod define_opaque;
3434
mod derive;
3535
mod deriving;
3636
mod diagnostics;
37-
mod direct_const_arg;
3837
mod edition_panic;
3938
mod eii;
4039
mod env;
4140
mod format;
4241
mod format_foreign;
42+
mod gca;
4343
mod global_allocator;
4444
mod iter;
4545
mod log_syntax;
@@ -83,11 +83,11 @@ pub fn register_builtin_macros(resolver: &mut dyn ResolverExpand) {
8383
concat_bytes: concat_bytes::expand_concat_bytes,
8484
const_format_args: format::expand_format_args,
8585
core_panic: edition_panic::expand_panic,
86-
direct_const_arg: direct_const_arg::expand,
8786
env: env::expand_env,
8887
file: source_util::expand_file,
8988
format_args: format::expand_format_args,
9089
format_args_nl: format::expand_format_args_nl,
90+
gca: gca::expand,
9191
global_asm: asm::expand_global_asm,
9292
include: source_util::expand_include,
9393
include_bytes: source_util::expand_include_bytes,

0 commit comments

Comments
 (0)