Skip to content

Commit 0d63418

Browse files
committedAug 29, 2024·
Auto merge of rust-lang#129750 - GuillaumeGomez:rollup-gphsb7y, r=GuillaumeGomez
Rollup of 7 pull requests Successful merges: - rust-lang#123940 (debug-fmt-detail option) - rust-lang#128166 (Improved `checked_isqrt` and `isqrt` methods) - rust-lang#128970 (Add `-Zlint-llvm-ir`) - rust-lang#129316 (riscv64imac: allow shadow call stack sanitizer) - rust-lang#129690 (Add `needs-unwind` compiletest directive to `libtest-thread-limit` and replace some `Path` with `path` in `run-make`) - rust-lang#129732 (Add `unreachable_pub`, round 3) - rust-lang#129743 (Fix rustdoc clippy lints) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 784d444 + 9c7ae1d commit 0d63418

File tree

141 files changed

+1587
-644
lines changed

Some content is hidden

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

141 files changed

+1587
-644
lines changed
 

‎compiler/rustc_ast_lowering/src/format.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ use std::borrow::Cow;
44
use rustc_ast::visit::Visitor;
55
use rustc_ast::*;
66
use rustc_data_structures::fx::FxIndexMap;
7+
use rustc_hir as hir;
8+
use rustc_session::config::FmtDebug;
79
use rustc_span::symbol::{kw, Ident};
810
use rustc_span::{sym, Span, Symbol};
9-
use {rustc_ast as ast, rustc_hir as hir};
1011

1112
use super::LoweringContext;
1213

@@ -243,7 +244,10 @@ fn make_argument<'hir>(
243244
hir::LangItem::FormatArgument,
244245
match ty {
245246
Format(Display) => sym::new_display,
246-
Format(Debug) => sym::new_debug,
247+
Format(Debug) => match ctx.tcx.sess.opts.unstable_opts.fmt_debug {
248+
FmtDebug::Full | FmtDebug::Shallow => sym::new_debug,
249+
FmtDebug::None => sym::new_debug_noop,
250+
},
247251
Format(LowerExp) => sym::new_lower_exp,
248252
Format(UpperExp) => sym::new_upper_exp,
249253
Format(Octal) => sym::new_octal,

‎compiler/rustc_builtin_macros/src/deriving/debug.rs

+13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use rustc_ast::{self as ast, EnumDef, MetaItem};
22
use rustc_expand::base::{Annotatable, ExtCtxt};
3+
use rustc_session::config::FmtDebug;
34
use rustc_span::symbol::{sym, Ident, Symbol};
45
use rustc_span::Span;
56
use thin_vec::{thin_vec, ThinVec};
@@ -49,6 +50,11 @@ fn show_substructure(cx: &ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) ->
4950
// We want to make sure we have the ctxt set so that we can use unstable methods
5051
let span = cx.with_def_site_ctxt(span);
5152

53+
let fmt_detail = cx.sess.opts.unstable_opts.fmt_debug;
54+
if fmt_detail == FmtDebug::None {
55+
return BlockOrExpr::new_expr(cx.expr_ok(span, cx.expr_tuple(span, ThinVec::new())));
56+
}
57+
5258
let (ident, vdata, fields) = match substr.fields {
5359
Struct(vdata, fields) => (substr.type_ident, *vdata, fields),
5460
EnumMatching(_, v, fields) => (v.ident, &v.data, fields),
@@ -61,6 +67,13 @@ fn show_substructure(cx: &ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) ->
6167
let name = cx.expr_str(span, ident.name);
6268
let fmt = substr.nonselflike_args[0].clone();
6369

70+
// Fieldless enums have been special-cased earlier
71+
if fmt_detail == FmtDebug::Shallow {
72+
let fn_path_write_str = cx.std_path(&[sym::fmt, sym::Formatter, sym::write_str]);
73+
let expr = cx.expr_call_global(span, fn_path_write_str, thin_vec![fmt, name]);
74+
return BlockOrExpr::new_expr(expr);
75+
}
76+
6477
// Struct and tuples are similar enough that we use the same code for both,
6578
// with some extra pieces for structs due to the field names.
6679
let (is_struct, args_per_field) = match vdata {

0 commit comments

Comments
 (0)
Please sign in to comment.