Skip to content

Commit 561b5de

Browse files
committed
Auto merge of rust-lang#124646 - matthiaskrgr:rollup-crlsvg5, r=matthiaskrgr
Rollup of 10 pull requests Successful merges: - rust-lang#123480 (deref patterns: impl `DerefPure` for more std types) - rust-lang#124412 (io safety: update Unix explanation to use `Arc`) - rust-lang#124441 (String.truncate comment microfix (greater or equal)) - rust-lang#124594 (run-make-support: preserve tooks.mk behavior for EXTRACXXFLAGS) - rust-lang#124604 (library/std: Remove unused `gimli-symbolize` feature) - rust-lang#124607 (`rustc_expand` cleanups) - rust-lang#124609 (variable-precision float operations can differ depending on optimization levels) - rust-lang#124610 (Tweak `consts_may_unify`) - rust-lang#124626 (const_eval_select: add tracking issue) - rust-lang#124637 (AST pretty: Use `builtin_syntax` for type ascription) Failed merges: - rust-lang#124638 (Move some tests from `rustc_expand` to `rustc_parse`.) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 79734f1 + e6c82d9 commit 561b5de

File tree

26 files changed

+376
-323
lines changed

26 files changed

+376
-323
lines changed

Diff for: compiler/rustc_ast/src/ast.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -1390,7 +1390,7 @@ pub struct StructExpr {
13901390
// Adding a new variant? Please update `test_expr` in `tests/ui/macros/stringify.rs`.
13911391
#[derive(Clone, Encodable, Decodable, Debug)]
13921392
pub enum ExprKind {
1393-
/// An array (`[a, b, c, d]`)
1393+
/// An array (e.g, `[a, b, c, d]`).
13941394
Array(ThinVec<P<Expr>>),
13951395
/// Allow anonymous constants from an inline `const` block
13961396
ConstBlock(AnonConst),
@@ -1401,7 +1401,7 @@ pub enum ExprKind {
14011401
/// This also represents calling the constructor of
14021402
/// tuple-like ADTs such as tuple structs and enum variants.
14031403
Call(P<Expr>, ThinVec<P<Expr>>),
1404-
/// A method call (e.g. `x.foo::<Bar, Baz>(a, b, c)`).
1404+
/// A method call (e.g., `x.foo::<Bar, Baz>(a, b, c)`).
14051405
MethodCall(Box<MethodCall>),
14061406
/// A tuple (e.g., `(a, b, c, d)`).
14071407
Tup(ThinVec<P<Expr>>),
@@ -1413,7 +1413,10 @@ pub enum ExprKind {
14131413
Lit(token::Lit),
14141414
/// A cast (e.g., `foo as f64`).
14151415
Cast(P<Expr>, P<Ty>),
1416-
/// A type ascription (e.g., `42: usize`).
1416+
/// A type ascription (e.g., `builtin # type_ascribe(42, usize)`).
1417+
///
1418+
/// Usually not written directly in user code but
1419+
/// indirectly via the macro `type_ascribe!(...)`.
14171420
Type(P<Expr>, P<Ty>),
14181421
/// A `let pat = expr` expression that is only semantically allowed in the condition
14191422
/// of `if` / `while` expressions. (e.g., `if let 0 = x { .. }`).
@@ -1488,7 +1491,10 @@ pub enum ExprKind {
14881491
/// Output of the `asm!()` macro.
14891492
InlineAsm(P<InlineAsm>),
14901493

1491-
/// Output of the `offset_of!()` macro.
1494+
/// An `offset_of` expression (e.g., `builtin # offset_of(Struct, field)`).
1495+
///
1496+
/// Usually not written directly in user code but
1497+
/// indirectly via the macro `core::mem::offset_of!(...)`.
14921498
OffsetOf(P<Ty>, P<[Ident]>),
14931499

14941500
/// A macro invocation; pre-expansion.

Diff for: compiler/rustc_ast_pretty/src/pprust/state/expr.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,8 @@ impl<'a> State<'a> {
422422
self.print_type(ty);
423423
}
424424
ast::ExprKind::Type(expr, ty) => {
425-
self.word("type_ascribe!(");
425+
self.word("builtin # type_ascribe");
426+
self.popen();
426427
self.ibox(0);
427428
self.print_expr(expr, FixupContext::default());
428429

@@ -431,7 +432,7 @@ impl<'a> State<'a> {
431432
self.print_type(ty);
432433

433434
self.end();
434-
self.word(")");
435+
self.pclose();
435436
}
436437
ast::ExprKind::Let(pat, scrutinee, _, _) => {
437438
self.print_let(pat, scrutinee, fixup);
@@ -657,15 +658,15 @@ impl<'a> State<'a> {
657658
);
658659
}
659660
ast::ExprKind::InlineAsm(a) => {
660-
// FIXME: This should have its own syntax, distinct from a macro invocation.
661+
// FIXME: Print `builtin # asm` once macro `asm` uses `builtin_syntax`.
661662
self.word("asm!");
662663
self.print_inline_asm(a);
663664
}
664665
ast::ExprKind::FormatArgs(fmt) => {
665-
// FIXME: This should have its own syntax, distinct from a macro invocation.
666+
// FIXME: Print `builtin # format_args` once macro `format_args` uses `builtin_syntax`.
666667
self.word("format_args!");
667668
self.popen();
668-
self.rbox(0, Inconsistent);
669+
self.ibox(0);
669670
self.word(reconstruct_format_args_template_string(&fmt.template));
670671
for arg in fmt.arguments.all_args() {
671672
self.word_space(",");
@@ -677,7 +678,7 @@ impl<'a> State<'a> {
677678
ast::ExprKind::OffsetOf(container, fields) => {
678679
self.word("builtin # offset_of");
679680
self.popen();
680-
self.rbox(0, Inconsistent);
681+
self.ibox(0);
681682
self.print_type(container);
682683
self.word(",");
683684
self.space();
@@ -690,8 +691,8 @@ impl<'a> State<'a> {
690691
self.print_ident(field);
691692
}
692693
}
693-
self.pclose();
694694
self.end();
695+
self.pclose();
695696
}
696697
ast::ExprKind::MacCall(m) => self.print_mac(m),
697698
ast::ExprKind::Paren(e) => {

Diff for: compiler/rustc_ast_pretty/src/pprust/state/item.rs

+1
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ impl<'a> State<'a> {
238238
self.bclose(item.span, empty);
239239
}
240240
ast::ItemKind::GlobalAsm(asm) => {
241+
// FIXME: Print `builtin # global_asm` once macro `global_asm` uses `builtin_syntax`.
241242
self.head(visibility_qualified(&item.vis, "global_asm!"));
242243
self.print_inline_asm(asm);
243244
self.word(";");

Diff for: compiler/rustc_expand/src/base.rs

+23-35
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use rustc_session::config::CollapseMacroDebuginfo;
2121
use rustc_session::{parse::ParseSess, Limit, Session};
2222
use rustc_span::def_id::{CrateNum, DefId, LocalDefId};
2323
use rustc_span::edition::Edition;
24-
use rustc_span::hygiene::{AstPass, ExpnData, ExpnKind, LocalExpnId};
24+
use rustc_span::hygiene::{AstPass, ExpnData, ExpnKind, LocalExpnId, MacroKind};
2525
use rustc_span::source_map::SourceMap;
2626
use rustc_span::symbol::{kw, sym, Ident, Symbol};
2727
use rustc_span::{FileName, Span, DUMMY_SP};
@@ -32,8 +32,6 @@ use std::path::{Path, PathBuf};
3232
use std::rc::Rc;
3333
use thin_vec::ThinVec;
3434

35-
pub(crate) use rustc_span::hygiene::MacroKind;
36-
3735
// When adding new variants, make sure to
3836
// adjust the `visit_*` / `flat_map_*` calls in `InvocationCollector`
3937
// to use `assign_id!`
@@ -573,35 +571,6 @@ impl DummyResult {
573571
tokens: None,
574572
})
575573
}
576-
577-
/// A plain dummy pattern.
578-
pub fn raw_pat(sp: Span) -> ast::Pat {
579-
ast::Pat { id: ast::DUMMY_NODE_ID, kind: PatKind::Wild, span: sp, tokens: None }
580-
}
581-
582-
/// A plain dummy type.
583-
pub fn raw_ty(sp: Span) -> P<ast::Ty> {
584-
// FIXME(nnethercote): you might expect `ast::TyKind::Dummy` to be used here, but some
585-
// values produced here end up being lowered to HIR, which `ast::TyKind::Dummy` does not
586-
// support, so we use an empty tuple instead.
587-
P(ast::Ty {
588-
id: ast::DUMMY_NODE_ID,
589-
kind: ast::TyKind::Tup(ThinVec::new()),
590-
span: sp,
591-
tokens: None,
592-
})
593-
}
594-
595-
/// A plain dummy crate.
596-
pub fn raw_crate() -> ast::Crate {
597-
ast::Crate {
598-
attrs: Default::default(),
599-
items: Default::default(),
600-
spans: Default::default(),
601-
id: ast::DUMMY_NODE_ID,
602-
is_placeholder: Default::default(),
603-
}
604-
}
605574
}
606575

607576
impl MacResult for DummyResult {
@@ -610,7 +579,12 @@ impl MacResult for DummyResult {
610579
}
611580

612581
fn make_pat(self: Box<DummyResult>) -> Option<P<ast::Pat>> {
613-
Some(P(DummyResult::raw_pat(self.span)))
582+
Some(P(ast::Pat {
583+
id: ast::DUMMY_NODE_ID,
584+
kind: PatKind::Wild,
585+
span: self.span,
586+
tokens: None,
587+
}))
614588
}
615589

616590
fn make_items(self: Box<DummyResult>) -> Option<SmallVec<[P<ast::Item>; 1]>> {
@@ -638,7 +612,15 @@ impl MacResult for DummyResult {
638612
}
639613

640614
fn make_ty(self: Box<DummyResult>) -> Option<P<ast::Ty>> {
641-
Some(DummyResult::raw_ty(self.span))
615+
// FIXME(nnethercote): you might expect `ast::TyKind::Dummy` to be used here, but some
616+
// values produced here end up being lowered to HIR, which `ast::TyKind::Dummy` does not
617+
// support, so we use an empty tuple instead.
618+
Some(P(ast::Ty {
619+
id: ast::DUMMY_NODE_ID,
620+
kind: ast::TyKind::Tup(ThinVec::new()),
621+
span: self.span,
622+
tokens: None,
623+
}))
642624
}
643625

644626
fn make_arms(self: Box<DummyResult>) -> Option<SmallVec<[ast::Arm; 1]>> {
@@ -670,7 +652,13 @@ impl MacResult for DummyResult {
670652
}
671653

672654
fn make_crate(self: Box<DummyResult>) -> Option<ast::Crate> {
673-
Some(DummyResult::raw_crate())
655+
Some(ast::Crate {
656+
attrs: Default::default(),
657+
items: Default::default(),
658+
spans: Default::default(),
659+
id: ast::DUMMY_NODE_ID,
660+
is_placeholder: Default::default(),
661+
})
674662
}
675663
}
676664

Diff for: compiler/rustc_expand/src/build.rs

-27
Original file line numberDiff line numberDiff line change
@@ -175,20 +175,6 @@ impl<'a> ExtCtxt<'a> {
175175
ast::Stmt { id: ast::DUMMY_NODE_ID, span: expr.span, kind: ast::StmtKind::Expr(expr) }
176176
}
177177

178-
pub fn stmt_let_pat(&self, sp: Span, pat: P<ast::Pat>, ex: P<ast::Expr>) -> ast::Stmt {
179-
let local = P(ast::Local {
180-
pat,
181-
ty: None,
182-
id: ast::DUMMY_NODE_ID,
183-
kind: LocalKind::Init(ex),
184-
span: sp,
185-
colon_sp: None,
186-
attrs: AttrVec::new(),
187-
tokens: None,
188-
});
189-
self.stmt_local(local, sp)
190-
}
191-
192178
pub fn stmt_let(&self, sp: Span, mutbl: bool, ident: Ident, ex: P<ast::Expr>) -> ast::Stmt {
193179
self.stmt_let_ty(sp, mutbl, ident, None, ex)
194180
}
@@ -278,10 +264,6 @@ impl<'a> ExtCtxt<'a> {
278264
self.expr_ident(span, Ident::with_dummy_span(kw::SelfLower))
279265
}
280266

281-
pub fn expr_field(&self, span: Span, expr: P<Expr>, field: Ident) -> P<ast::Expr> {
282-
self.expr(span, ast::ExprKind::Field(expr, field))
283-
}
284-
285267
pub fn expr_macro_call(&self, span: Span, call: P<ast::MacCall>) -> P<ast::Expr> {
286268
self.expr(span, ast::ExprKind::MacCall(call))
287269
}
@@ -394,11 +376,6 @@ impl<'a> ExtCtxt<'a> {
394376
self.expr(span, ast::ExprKind::Lit(lit))
395377
}
396378

397-
pub fn expr_char(&self, span: Span, ch: char) -> P<ast::Expr> {
398-
let lit = token::Lit::new(token::Char, literal::escape_char_symbol(ch), None);
399-
self.expr(span, ast::ExprKind::Lit(lit))
400-
}
401-
402379
pub fn expr_byte_str(&self, span: Span, bytes: Vec<u8>) -> P<ast::Expr> {
403380
let lit = token::Lit::new(token::ByteStr, literal::escape_byte_str_symbol(&bytes), None);
404381
self.expr(span, ast::ExprKind::Lit(lit))
@@ -414,10 +391,6 @@ impl<'a> ExtCtxt<'a> {
414391
self.expr_addr_of(sp, self.expr_array(sp, exprs))
415392
}
416393

417-
pub fn expr_cast(&self, sp: Span, expr: P<ast::Expr>, ty: P<ast::Ty>) -> P<ast::Expr> {
418-
self.expr(sp, ast::ExprKind::Cast(expr, ty))
419-
}
420-
421394
pub fn expr_some(&self, sp: Span, expr: P<ast::Expr>) -> P<ast::Expr> {
422395
let some = self.std_path(&[sym::option, sym::Option, sym::Some]);
423396
self.expr_call_global(sp, some, thin_vec![expr])

Diff for: compiler/rustc_expand/src/config.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,11 @@ pub fn features(sess: &Session, krate_attrs: &[Attribute], crate_name: Symbol) -
9999
// If the declared feature is unstable, record it.
100100
if let Some(f) = UNSTABLE_FEATURES.iter().find(|f| name == f.feature.name) {
101101
(f.set_enabled)(&mut features);
102-
// When the ICE comes from core, alloc or std (approximation of the standard library), there's a chance
103-
// that the person hitting the ICE may be using -Zbuild-std or similar with an untested target.
104-
// The bug is probably in the standard library and not the compiler in that case, but that doesn't
105-
// really matter - we want a bug report.
102+
// When the ICE comes from core, alloc or std (approximation of the standard
103+
// library), there's a chance that the person hitting the ICE may be using
104+
// -Zbuild-std or similar with an untested target. The bug is probably in the
105+
// standard library and not the compiler in that case, but that doesn't really
106+
// matter - we want a bug report.
106107
if features.internal(name)
107108
&& ![sym::core, sym::alloc, sym::std].contains(&crate_name)
108109
{

0 commit comments

Comments
 (0)