Skip to content

Rollup of 8 pull requests #140475

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 31 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
14491b0
Use START_BLOCK in codegen_naked_asm
bjorn3 Dec 12, 2024
03f4e88
Handle protected visibility in codegen_naked_asm
bjorn3 Dec 12, 2024
ffdc292
Don't begin defining a function when codegening a naked function
bjorn3 Dec 12, 2024
1988de5
Only require a CodegenCx for codegen_naked_asm
bjorn3 Dec 12, 2024
764d3a5
Make codegen_naked_asm retrieve the MIR Body itself
bjorn3 Dec 12, 2024
a73eba9
Move codegen_naked_asm call up into MonoItem::define
bjorn3 Dec 12, 2024
e2e96fa
Pass MonoItemData to MonoItem::define
bjorn3 Dec 12, 2024
94e95f3
Make codegen_naked_asm public
bjorn3 Dec 12, 2024
421f22e
Pass &mut self to codegen_global_asm
bjorn3 Dec 12, 2024
f5c93fa
Use cg_ssa's version of codegen_naked_asm in cg_clif
bjorn3 Dec 12, 2024
3066da8
Share part of the global_asm!() implementation between cg_ssa and cg_…
bjorn3 Dec 13, 2024
5b1e495
Add a few extra tests to `tests/ui/macros/stringify.rs`.
nnethercote Apr 23, 2025
99f6b63
Improve pretty-printing of braces.
nnethercote May 17, 2024
cf12e29
enable msa feature for mips in codegen tests
koalatux Apr 29, 2025
4fe94ba
add `rust.debug-assertions-tools` option
pietroalbini Apr 29, 2025
2393e44
miri: algebraic intrinsics: bring back float non-determinism
RalfJung Apr 29, 2025
478b378
Move `on impl position` test to proper directory
mejrs Apr 29, 2025
fc2cd77
Fix comment describing what the test does
mejrs Apr 29, 2025
923ca85
Add test
oli-obk Apr 29, 2025
a1c7059
Treat `ManuallyDrop` as `~const Destruct`
oli-obk Apr 29, 2025
a4ce307
Coalesce duplicate missing clone tests
mejrs Apr 29, 2025
64bcf3b
Rename `rustc_query_append!` to `rustc_with_all_queries!`
Zalathar Apr 29, 2025
ed2f4b6
Reformat parameters to macros used by with-all-queries
Zalathar Apr 29, 2025
40ebd1b
Rollup merge of #134232 - bjorn3:naked_asm_improvements, r=wesleywiser
tgross35 Apr 29, 2025
3e26eb9
Rollup merge of #140312 - nnethercote:DelimArgs-spacing, r=petrochenkov
tgross35 Apr 29, 2025
f241cb1
Rollup merge of #140437 - husqvarnagroup:af/codegen-test-mips-msa, r=…
tgross35 Apr 29, 2025
3ef052f
Rollup merge of #140438 - ferrocene:pa-debug-assertions-tools, r=Kobzol
tgross35 Apr 29, 2025
8719830
Rollup merge of #140439 - RalfJung:miri-algebraic-float-nondet, r=oli…
tgross35 Apr 29, 2025
59613f5
Rollup merge of #140445 - oli-obk:const-manually-drop, r=fee1-dead
tgross35 Apr 29, 2025
ef36ca5
Rollup merge of #140446 - mejrs:test1, r=jieyouxu
tgross35 Apr 29, 2025
9529cc4
Rollup merge of #140448 - Zalathar:query-append, r=compiler-errors
tgross35 Apr 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Improve pretty-printing of braces.
Most notably, the `FIXME` for suboptimal printing of `use` groups in
`tests/ui/macros/stringify.rs` is fixed. And all other test output
changes result in pretty printed output being closer to the original
formatting in the source code.
  • Loading branch information
nnethercote committed Apr 29, 2025
commit 99f6b6328e7b418abe2e3bcf49b4504c2866671e
33 changes: 24 additions & 9 deletions compiler/rustc_ast_pretty/src/pprust/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
false,
None,
*delim,
None,
tokens,
true,
span,
Expand Down Expand Up @@ -679,6 +680,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
false,
None,
*delim,
Some(spacing.open),
tts,
convert_dollar_crate,
dspan.entire(),
Expand Down Expand Up @@ -735,6 +737,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
has_bang: bool,
ident: Option<Ident>,
delim: Delimiter,
open_spacing: Option<Spacing>,
tts: &TokenStream,
convert_dollar_crate: bool,
span: Span,
Expand All @@ -758,16 +761,26 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
self.nbsp();
}
self.word("{");
if !tts.is_empty() {

// Respect `Alone`, if provided, and print a space. Unless the list is empty.
let open_space = (open_spacing == None || open_spacing == Some(Spacing::Alone))
&& !tts.is_empty();
if open_space {
self.space();
}
let ib = self.ibox(0);
self.print_tts(tts, convert_dollar_crate);
self.end(ib);
let empty = tts.is_empty();
self.bclose(span, empty, cb.unwrap());

// Use `open_space` for the spacing *before* the closing delim.
// Because spacing on delimiters is lost when going through
// proc macros, and otherwise we can end up with ugly cases
// like `{ x}`. Symmetry is better.
self.bclose(span, !open_space, cb.unwrap());
}
delim => {
// `open_spacing` is ignored. We never print spaces after
// non-brace opening delims or before non-brace closing delims.
let token_str = self.token_kind_to_string(&delim.as_open_token_kind());
self.word(token_str);
let ib = self.ibox(0);
Expand Down Expand Up @@ -797,6 +810,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
has_bang,
Some(*ident),
macro_def.body.delim,
None,
&macro_def.body.tokens,
true,
sp,
Expand Down Expand Up @@ -844,9 +858,9 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
self.end(ib);
}

fn bclose_maybe_open(&mut self, span: rustc_span::Span, empty: bool, cb: Option<BoxMarker>) {
fn bclose_maybe_open(&mut self, span: rustc_span::Span, no_space: bool, cb: Option<BoxMarker>) {
let has_comment = self.maybe_print_comment(span.hi());
if !empty || has_comment {
if !no_space || has_comment {
self.break_offset_if_not_bol(1, -INDENT_UNIT);
}
self.word("}");
Expand All @@ -855,9 +869,9 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
}
}

fn bclose(&mut self, span: rustc_span::Span, empty: bool, cb: BoxMarker) {
fn bclose(&mut self, span: rustc_span::Span, no_space: bool, cb: BoxMarker) {
let cb = Some(cb);
self.bclose_maybe_open(span, empty, cb)
self.bclose_maybe_open(span, no_space, cb)
}

fn break_offset_if_not_bol(&mut self, n: usize, off: isize) {
Expand Down Expand Up @@ -1423,8 +1437,8 @@ impl<'a> State<'a> {
}
}

let empty = !has_attrs && blk.stmts.is_empty();
self.bclose_maybe_open(blk.span, empty, cb);
let no_space = !has_attrs && blk.stmts.is_empty();
self.bclose_maybe_open(blk.span, no_space, cb);
self.ann.post(self, AnnNode::Block(blk))
}

Expand Down Expand Up @@ -1471,6 +1485,7 @@ impl<'a> State<'a> {
true,
None,
m.args.delim,
None,
&m.args.tokens,
true,
m.span(),
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_builtin_macros/src/autodiff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,9 @@ mod llvm_enzyme {
Spacing::Joint,
)];
let never_arg = ast::DelimArgs {
dspan: ast::tokenstream::DelimSpan::from_single(span),
dspan: DelimSpan::from_single(span),
delim: ast::token::Delimiter::Parenthesis,
tokens: ast::tokenstream::TokenStream::from_iter(ts2),
tokens: TokenStream::from_iter(ts2),
};
let inline_item = ast::AttrItem {
unsafety: ast::Safety::Default,
Expand Down
14 changes: 8 additions & 6 deletions compiler/rustc_expand/src/build.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use rustc_ast::ptr::P;
use rustc_ast::token::Delimiter;
use rustc_ast::tokenstream::TokenStream;
use rustc_ast::util::literal;
use rustc_ast::{
self as ast, AnonConst, AttrVec, BlockCheckMode, Expr, LocalKind, MatchKind, PatKind, UnOp,
attr, token,
attr, token, tokenstream,
};
use rustc_span::source_map::Spanned;
use rustc_span::{DUMMY_SP, Ident, Span, Symbol, kw, sym};
Expand Down Expand Up @@ -55,13 +57,13 @@ impl<'a> ExtCtxt<'a> {
&self,
span: Span,
path: ast::Path,
delim: ast::token::Delimiter,
tokens: ast::tokenstream::TokenStream,
delim: Delimiter,
tokens: TokenStream,
) -> P<ast::MacCall> {
P(ast::MacCall {
path,
args: P(ast::DelimArgs {
dspan: ast::tokenstream::DelimSpan { open: span, close: span },
dspan: tokenstream::DelimSpan { open: span, close: span },
delim,
tokens,
}),
Expand Down Expand Up @@ -480,8 +482,8 @@ impl<'a> ExtCtxt<'a> {
span,
[sym::std, sym::unreachable].map(|s| Ident::new(s, span)).to_vec(),
),
ast::token::Delimiter::Parenthesis,
ast::tokenstream::TokenStream::default(),
Delimiter::Parenthesis,
TokenStream::default(),
),
)
}
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_hir_pretty/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ impl<'a> State<'a> {
false,
None,
*delim,
None,
&tokens,
true,
span,
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/macros/stringify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ fn test_item() {
c1!(item, [ pub extern crate self as std; ], "pub extern crate self as std;");

// ItemKind::Use
c1!(item, [ pub use crate::{a, b::c}; ], "pub use crate::{ a, b::c };"); // FIXME
c1!(item, [ pub use crate::{a, b::c}; ], "pub use crate::{a, b::c};");
c1!(item, [ pub use crate::{ e, ff }; ], "pub use crate::{ e, ff };");
c1!(item, [ pub use A::*; ], "pub use A::*;");

Expand Down Expand Up @@ -491,7 +491,7 @@ fn test_item() {
c1!(item, [ mac! {} ], "mac! {}");
c1!(item, [ mac!(...); ], "mac!(...);");
c1!(item, [ mac![...]; ], "mac![...];");
c1!(item, [ mac! {...} ], "mac! { ... }");
c1!(item, [ mac! {...} ], "mac! {...}");

// ItemKind::MacroDef
c1!(item,
Expand Down
6 changes: 3 additions & 3 deletions tests/ui/macros/trace_faulty_macros.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ LL | let a = pat_macro!();
| ^^^^^^^^^^^^
|
= note: expanding `pat_macro! { }`
= note: to `pat_macro! (A { a : a, b : 0, c : _, .. });`
= note: expanding `pat_macro! { A { a : a, b : 0, c : _, .. } }`
= note: to `A { a : a, b : 0, c : _, .. }`
= note: to `pat_macro! (A {a : a, b : 0, c : _, ..});`
= note: expanding `pat_macro! { A {a : a, b : 0, c : _, ..} }`
= note: to `A {a : a, b : 0, c : _, ..}`

note: trace_macro
--> $DIR/trace_faulty_macros.rs:53:5
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/proc-macro/attr-complex-fn.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [
span: $DIR/attr-complex-fn.rs:19:42: 19:44 (#0),
},
]
PRINT-ATTR INPUT (DISPLAY): impl<T> MyTrait<T> for MyStruct<{ true }> { #![rustc_dummy] }
PRINT-ATTR INPUT (DISPLAY): impl<T> MyTrait<T> for MyStruct<{true}> { #![rustc_dummy] }
PRINT-ATTR RE-COLLECTED (DISPLAY): impl < T > MyTrait < T > for MyStruct < { true } > { #![rustc_dummy] }
PRINT-ATTR DEEP-RE-COLLECTED (DISPLAY): impl < T > MyTrait < T > for MyStruct < { true } > { #! [rustc_dummy] }
PRINT-ATTR INPUT (DEBUG): TokenStream [
Expand Down
9 changes: 4 additions & 5 deletions tests/ui/proc-macro/weird-braces.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ PRINT-ATTR_ARGS INPUT (DEBUG): TokenStream [
span: $DIR/weird-braces.rs:16:25: 16:36 (#0),
},
]
PRINT-ATTR INPUT (DISPLAY): #[print_target_and_args(second_outer)] impl Bar<{ 1 > 0 }> for Foo<{ true }>
PRINT-ATTR INPUT (DISPLAY): #[print_target_and_args(second_outer)] impl Bar<{1 > 0}> for Foo<{true}>
{
#![print_target_and_args(first_inner)]
#![print_target_and_args(second_inner)]
Expand Down Expand Up @@ -191,7 +191,7 @@ PRINT-ATTR_ARGS INPUT (DEBUG): TokenStream [
span: $DIR/weird-braces.rs:17:25: 17:37 (#0),
},
]
PRINT-ATTR INPUT (DISPLAY): impl Bar<{ 1 > 0 }> for Foo<{ true }>
PRINT-ATTR INPUT (DISPLAY): impl Bar<{1 > 0}> for Foo<{true}>
{
#![print_target_and_args(first_inner)]
#![print_target_and_args(second_inner)]
Expand Down Expand Up @@ -350,8 +350,7 @@ PRINT-ATTR_ARGS INPUT (DEBUG): TokenStream [
span: $DIR/weird-braces.rs:19:30: 19:41 (#0),
},
]
PRINT-ATTR INPUT (DISPLAY): impl Bar<{ 1 > 0 }> for Foo<{ true }>
{ #![print_target_and_args(second_inner)] }
PRINT-ATTR INPUT (DISPLAY): impl Bar<{1 > 0}> for Foo<{true}> { #![print_target_and_args(second_inner)] }
PRINT-ATTR RE-COLLECTED (DISPLAY): impl Bar < { 1 > 0 } > for Foo < { true } >
{ #![print_target_and_args(second_inner)] }
PRINT-ATTR DEEP-RE-COLLECTED (DISPLAY): impl Bar < { 1 > 0 } > for Foo < { true } >
Expand Down Expand Up @@ -470,7 +469,7 @@ PRINT-ATTR_ARGS INPUT (DEBUG): TokenStream [
span: $DIR/weird-braces.rs:20:30: 20:42 (#0),
},
]
PRINT-ATTR INPUT (DISPLAY): impl Bar<{ 1 > 0 }> for Foo<{ true }> {}
PRINT-ATTR INPUT (DISPLAY): impl Bar<{1 > 0}> for Foo<{true}> {}
PRINT-ATTR RE-COLLECTED (DISPLAY): impl Bar < { 1 > 0 } > for Foo < { true } > {}
PRINT-ATTR INPUT (DEBUG): TokenStream [
Ident {
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/unpretty/expanded-exhaustive.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ mod items {
mod item_mac_call { }
/// ItemKind::MacroDef
mod item_macro_def {
macro_rules! mac { () => { ... }; }
macro_rules! mac { () => {...}; }
pub macro stringify { () => {} }
}
/// ItemKind::Delegation
Expand Down
Loading