Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 5c18bc6

Browse files
committedJan 4, 2023
Auto merge of rust-lang#106442 - matthiaskrgr:rollup-wivf7gh, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - rust-lang#106200 (Suggest `impl Fn*` and `impl Future` in `-> _` return suggestions) - rust-lang#106274 (Add JSON output to -Zdump-mono-stats) - rust-lang#106292 (Add codegen test for `Box::new(uninit)` of big arrays) - rust-lang#106327 (Add tidy check for dbg) - rust-lang#106361 (Note maximum integer literal for `IntLiteralTooLarge`) - rust-lang#106396 (Allow passing a specific date to `bump-stage0`) - rust-lang#106436 (Enable doctests for rustc_query_impl) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents ddad1e1 + 4e590b3 commit 5c18bc6

File tree

37 files changed

+473
-127
lines changed

37 files changed

+473
-127
lines changed
 

‎Cargo.lock

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4243,6 +4243,8 @@ dependencies = [
42434243
"rustc_session",
42444244
"rustc_span",
42454245
"rustc_target",
4246+
"serde",
4247+
"serde_json",
42464248
"smallvec",
42474249
"tracing",
42484250
]

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub enum LitError {
3434
InvalidIntSuffix,
3535
InvalidFloatSuffix,
3636
NonDecimalFloat(u32),
37-
IntTooLarge,
37+
IntTooLarge(u32),
3838
}
3939

4040
impl LitKind {
@@ -333,6 +333,6 @@ fn integer_lit(symbol: Symbol, suffix: Option<Symbol>) -> Result<LitKind, LitErr
333333
// but these kinds of errors are already reported by the lexer.
334334
let from_lexer =
335335
base < 10 && s.chars().any(|c| c.to_digit(10).map_or(false, |d| d >= base));
336-
if from_lexer { LitError::LexerError } else { LitError::IntTooLarge }
336+
if from_lexer { LitError::LexerError } else { LitError::IntTooLarge(base) }
337337
})
338338
}

‎compiler/rustc_error_messages/locales/en-US/session.ftl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ session_invalid_float_literal_suffix = invalid suffix `{$suffix}` for float lite
8585
.help = valid suffixes are `f32` and `f64`
8686
8787
session_int_literal_too_large = integer literal is too large
88+
.note = value exceeds limit of `{$limit}`
8889
8990
session_invalid_int_literal_width = invalid width `{$width}` for integer literal
9091
.help = valid widths are 8, 16, 32, 64 and 128

‎compiler/rustc_hir_analysis/src/collect.rs

Lines changed: 97 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,16 @@
1717
use crate::astconv::AstConv;
1818
use crate::check::intrinsic::intrinsic_operation_unsafety;
1919
use crate::errors;
20+
use hir::def::DefKind;
2021
use rustc_data_structures::captures::Captures;
2122
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
2223
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder, ErrorGuaranteed, StashKey};
2324
use rustc_hir as hir;
2425
use rustc_hir::def_id::{DefId, LocalDefId};
2526
use rustc_hir::intravisit::{self, Visitor};
2627
use rustc_hir::{GenericParamKind, Node};
27-
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
2828
use rustc_infer::infer::TyCtxtInferExt;
29+
use rustc_infer::traits::ObligationCause;
2930
use rustc_middle::hir::nested_filter;
3031
use rustc_middle::ty::query::Providers;
3132
use rustc_middle::ty::util::{Discr, IntTypeExt};
@@ -1195,12 +1196,11 @@ fn infer_return_ty_for_fn_sig<'tcx>(
11951196
ty::ReErased => tcx.lifetimes.re_static,
11961197
_ => r,
11971198
});
1198-
let fn_sig = ty::Binder::dummy(fn_sig);
11991199

12001200
let mut visitor = HirPlaceholderCollector::default();
12011201
visitor.visit_ty(ty);
12021202
let mut diag = bad_placeholder(tcx, visitor.0, "return type");
1203-
let ret_ty = fn_sig.skip_binder().output();
1203+
let ret_ty = fn_sig.output();
12041204
if ret_ty.is_suggestable(tcx, false) {
12051205
diag.span_suggestion(
12061206
ty.span,
@@ -1223,26 +1223,26 @@ fn infer_return_ty_for_fn_sig<'tcx>(
12231223
Applicability::MachineApplicable,
12241224
);
12251225
}
1226+
} else if let Some(sugg) = suggest_impl_trait(tcx, ret_ty, ty.span, hir_id, def_id) {
1227+
diag.span_suggestion(
1228+
ty.span,
1229+
"replace with an appropriate return type",
1230+
sugg,
1231+
Applicability::MachineApplicable,
1232+
);
12261233
} else if ret_ty.is_closure() {
1227-
// We're dealing with a closure, so we should suggest using `impl Fn` or trait bounds
1228-
// to prevent the user from getting a papercut while trying to use the unique closure
1229-
// syntax (e.g. `[closure@src/lib.rs:2:5: 2:9]`).
12301234
diag.help("consider using an `Fn`, `FnMut`, or `FnOnce` trait bound");
1235+
}
1236+
// Also note how `Fn` traits work just in case!
1237+
if ret_ty.is_closure() {
12311238
diag.note(
12321239
"for more information on `Fn` traits and closure types, see \
12331240
https://doc.rust-lang.org/book/ch13-01-closures.html",
12341241
);
1235-
} else if let Some(i_ty) = suggest_impl_iterator(tcx, ret_ty, ty.span, hir_id, def_id) {
1236-
diag.span_suggestion(
1237-
ty.span,
1238-
"replace with an appropriate return type",
1239-
format!("impl Iterator<Item = {}>", i_ty),
1240-
Applicability::MachineApplicable,
1241-
);
12421242
}
12431243
diag.emit();
12441244

1245-
fn_sig
1245+
ty::Binder::dummy(fn_sig)
12461246
}
12471247
None => <dyn AstConv<'_>>::ty_of_fn(
12481248
icx,
@@ -1256,47 +1256,94 @@ fn infer_return_ty_for_fn_sig<'tcx>(
12561256
}
12571257
}
12581258

1259-
fn suggest_impl_iterator<'tcx>(
1259+
fn suggest_impl_trait<'tcx>(
12601260
tcx: TyCtxt<'tcx>,
12611261
ret_ty: Ty<'tcx>,
12621262
span: Span,
12631263
hir_id: hir::HirId,
12641264
def_id: LocalDefId,
1265-
) -> Option<Ty<'tcx>> {
1266-
let Some(iter_trait) = tcx.get_diagnostic_item(sym::Iterator) else { return None; };
1267-
let Some(iterator_item) = tcx.get_diagnostic_item(sym::IteratorItem) else { return None; };
1268-
if !tcx
1269-
.infer_ctxt()
1270-
.build()
1271-
.type_implements_trait(iter_trait, [ret_ty], tcx.param_env(def_id))
1272-
.must_apply_modulo_regions()
1273-
{
1274-
return None;
1275-
}
1276-
let infcx = tcx.infer_ctxt().build();
1277-
let ocx = ObligationCtxt::new_in_snapshot(&infcx);
1278-
// Find the type of `Iterator::Item`.
1279-
let origin = TypeVariableOrigin { kind: TypeVariableOriginKind::TypeInference, span };
1280-
let ty_var = infcx.next_ty_var(origin);
1281-
let projection = ty::Binder::dummy(ty::PredicateKind::Clause(ty::Clause::Projection(
1282-
ty::ProjectionPredicate {
1283-
projection_ty: tcx.mk_alias_ty(iterator_item, tcx.mk_substs([ret_ty.into()].iter())),
1284-
term: ty_var.into(),
1285-
},
1286-
)));
1287-
// Add `<ret_ty as Iterator>::Item = _` obligation.
1288-
ocx.register_obligation(crate::traits::Obligation::misc(
1289-
tcx,
1290-
span,
1291-
hir_id,
1292-
tcx.param_env(def_id),
1293-
projection,
1294-
));
1295-
if ocx.select_where_possible().is_empty()
1296-
&& let item_ty = infcx.resolve_vars_if_possible(ty_var)
1297-
&& item_ty.is_suggestable(tcx, false)
1298-
{
1299-
return Some(item_ty);
1265+
) -> Option<String> {
1266+
let format_as_assoc: fn(_, _, _, _, _) -> _ =
1267+
|tcx: TyCtxt<'tcx>,
1268+
_: ty::SubstsRef<'tcx>,
1269+
trait_def_id: DefId,
1270+
assoc_item_def_id: DefId,
1271+
item_ty: Ty<'tcx>| {
1272+
let trait_name = tcx.item_name(trait_def_id);
1273+
let assoc_name = tcx.item_name(assoc_item_def_id);
1274+
Some(format!("impl {trait_name}<{assoc_name} = {item_ty}>"))
1275+
};
1276+
let format_as_parenthesized: fn(_, _, _, _, _) -> _ =
1277+
|tcx: TyCtxt<'tcx>,
1278+
substs: ty::SubstsRef<'tcx>,
1279+
trait_def_id: DefId,
1280+
_: DefId,
1281+
item_ty: Ty<'tcx>| {
1282+
let trait_name = tcx.item_name(trait_def_id);
1283+
let args_tuple = substs.type_at(1);
1284+
let ty::Tuple(types) = *args_tuple.kind() else { return None; };
1285+
if !types.is_suggestable(tcx, false) {
1286+
return None;
1287+
}
1288+
let maybe_ret =
1289+
if item_ty.is_unit() { String::new() } else { format!(" -> {item_ty}") };
1290+
Some(format!(
1291+
"impl {trait_name}({}){maybe_ret}",
1292+
types.iter().map(|ty| ty.to_string()).collect::<Vec<_>>().join(", ")
1293+
))
1294+
};
1295+
1296+
for (trait_def_id, assoc_item_def_id, formatter) in [
1297+
(
1298+
tcx.get_diagnostic_item(sym::Iterator),
1299+
tcx.get_diagnostic_item(sym::IteratorItem),
1300+
format_as_assoc,
1301+
),
1302+
(
1303+
tcx.lang_items().future_trait(),
1304+
tcx.get_diagnostic_item(sym::FutureOutput),
1305+
format_as_assoc,
1306+
),
1307+
(tcx.lang_items().fn_trait(), tcx.lang_items().fn_once_output(), format_as_parenthesized),
1308+
(
1309+
tcx.lang_items().fn_mut_trait(),
1310+
tcx.lang_items().fn_once_output(),
1311+
format_as_parenthesized,
1312+
),
1313+
(
1314+
tcx.lang_items().fn_once_trait(),
1315+
tcx.lang_items().fn_once_output(),
1316+
format_as_parenthesized,
1317+
),
1318+
] {
1319+
let Some(trait_def_id) = trait_def_id else { continue; };
1320+
let Some(assoc_item_def_id) = assoc_item_def_id else { continue; };
1321+
if tcx.def_kind(assoc_item_def_id) != DefKind::AssocTy {
1322+
continue;
1323+
}
1324+
let param_env = tcx.param_env(def_id);
1325+
let infcx = tcx.infer_ctxt().build();
1326+
let substs = ty::InternalSubsts::for_item(tcx, trait_def_id, |param, _| {
1327+
if param.index == 0 { ret_ty.into() } else { infcx.var_for_def(span, param) }
1328+
});
1329+
if !infcx.type_implements_trait(trait_def_id, substs, param_env).must_apply_modulo_regions()
1330+
{
1331+
continue;
1332+
}
1333+
let ocx = ObligationCtxt::new_in_snapshot(&infcx);
1334+
let item_ty = ocx.normalize(
1335+
&ObligationCause::misc(span, hir_id),
1336+
param_env,
1337+
tcx.mk_projection(assoc_item_def_id, substs),
1338+
);
1339+
// FIXME(compiler-errors): We may benefit from resolving regions here.
1340+
if ocx.select_where_possible().is_empty()
1341+
&& let item_ty = infcx.resolve_vars_if_possible(item_ty)
1342+
&& item_ty.is_suggestable(tcx, false)
1343+
&& let Some(sugg) = formatter(tcx, infcx.resolve_vars_if_possible(substs), trait_def_id, assoc_item_def_id, item_ty)
1344+
{
1345+
return Some(sugg);
1346+
}
13001347
}
13011348
None
13021349
}

‎compiler/rustc_interface/src/tests.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,16 @@ use crate::interface::parse_cfgspecs;
33

44
use rustc_data_structures::fx::FxHashSet;
55
use rustc_errors::{emitter::HumanReadableErrorType, registry, ColorConfig};
6-
use rustc_session::config::InstrumentCoverage;
7-
use rustc_session::config::Strip;
6+
use rustc_session::config::rustc_optgroups;
87
use rustc_session::config::{build_configuration, build_session_options, to_crate_config};
9-
use rustc_session::config::{
10-
rustc_optgroups, ErrorOutputType, ExternLocation, LocationDetail, Options, Passes,
11-
};
128
use rustc_session::config::{
139
BranchProtection, Externs, OomStrategy, OutputType, OutputTypes, PAuthKey, PacRet,
1410
ProcMacroExecutionStrategy, SymbolManglingVersion, WasiExecModel,
1511
};
1612
use rustc_session::config::{CFGuard, ExternEntry, LinkerPluginLto, LtoCli, SwitchWithOptPath};
13+
use rustc_session::config::{DumpMonoStatsFormat, MirSpanview};
14+
use rustc_session::config::{ErrorOutputType, ExternLocation, LocationDetail, Options, Strip};
15+
use rustc_session::config::{InstrumentCoverage, Passes};
1716
use rustc_session::lint::Level;
1817
use rustc_session::search_paths::SearchPath;
1918
use rustc_session::utils::{CanonicalizedPath, NativeLib, NativeLibKind};
@@ -647,6 +646,9 @@ fn test_unstable_options_tracking_hash() {
647646
untracked!(dump_mir_dir, String::from("abc"));
648647
untracked!(dump_mir_exclude_pass_number, true);
649648
untracked!(dump_mir_graphviz, true);
649+
untracked!(dump_mir_spanview, Some(MirSpanview::Statement));
650+
untracked!(dump_mono_stats, SwitchWithOptPath::Enabled(Some("mono-items-dir/".into())));
651+
untracked!(dump_mono_stats_format, DumpMonoStatsFormat::Json);
650652
untracked!(dylib_lto, true);
651653
untracked!(emit_stack_sizes, true);
652654
untracked!(future_incompat_test, true);

‎compiler/rustc_monomorphize/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ edition = "2021"
66
[lib]
77

88
[dependencies]
9+
serde = "1"
10+
serde_json = "1"
911
smallvec = { version = "1.8.1", features = [ "union", "may_dangle" ] }
1012
tracing = "0.1"
1113
rustc_data_structures = { path = "../rustc_data_structures" }

‎compiler/rustc_monomorphize/src/partitioning/mod.rs

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,14 @@ use std::path::{Path, PathBuf};
102102

103103
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
104104
use rustc_data_structures::sync;
105-
use rustc_hir::def_id::DefIdSet;
105+
use rustc_hir::def_id::{DefIdSet, LOCAL_CRATE};
106106
use rustc_middle::mir;
107107
use rustc_middle::mir::mono::MonoItem;
108108
use rustc_middle::mir::mono::{CodegenUnit, Linkage};
109109
use rustc_middle::ty::print::with_no_trimmed_paths;
110110
use rustc_middle::ty::query::Providers;
111111
use rustc_middle::ty::TyCtxt;
112-
use rustc_session::config::SwitchWithOptPath;
112+
use rustc_session::config::{DumpMonoStatsFormat, SwitchWithOptPath};
113113
use rustc_span::symbol::Symbol;
114114

115115
use crate::collector::InliningMap;
@@ -417,7 +417,7 @@ fn collect_and_partition_mono_items(tcx: TyCtxt<'_>, (): ()) -> (&DefIdSet, &[Co
417417
// Output monomorphization stats per def_id
418418
if let SwitchWithOptPath::Enabled(ref path) = tcx.sess.opts.unstable_opts.dump_mono_stats {
419419
if let Err(err) =
420-
dump_mono_items_stats(tcx, &codegen_units, path, tcx.sess.opts.crate_name.as_deref())
420+
dump_mono_items_stats(tcx, &codegen_units, path, tcx.crate_name(LOCAL_CRATE))
421421
{
422422
tcx.sess.emit_fatal(CouldntDumpMonoStats { error: err.to_string() });
423423
}
@@ -483,7 +483,7 @@ fn dump_mono_items_stats<'tcx>(
483483
tcx: TyCtxt<'tcx>,
484484
codegen_units: &[CodegenUnit<'tcx>],
485485
output_directory: &Option<PathBuf>,
486-
crate_name: Option<&str>,
486+
crate_name: Symbol,
487487
) -> Result<(), Box<dyn std::error::Error>> {
488488
let output_directory = if let Some(ref directory) = output_directory {
489489
fs::create_dir_all(directory)?;
@@ -492,9 +492,11 @@ fn dump_mono_items_stats<'tcx>(
492492
Path::new(".")
493493
};
494494

495-
let filename = format!("{}.mono_items.md", crate_name.unwrap_or("unknown-crate"));
495+
let format = tcx.sess.opts.unstable_opts.dump_mono_stats_format;
496+
let ext = format.extension();
497+
let filename = format!("{crate_name}.mono_items.{ext}");
496498
let output_path = output_directory.join(&filename);
497-
let file = File::create(output_path)?;
499+
let file = File::create(&output_path)?;
498500
let mut file = BufWriter::new(file);
499501

500502
// Gather instantiated mono items grouped by def_id
@@ -508,30 +510,44 @@ fn dump_mono_items_stats<'tcx>(
508510
}
509511
}
510512

513+
#[derive(serde::Serialize)]
514+
struct MonoItem {
515+
name: String,
516+
instantiation_count: usize,
517+
size_estimate: usize,
518+
total_estimate: usize,
519+
}
520+
511521
// Output stats sorted by total instantiated size, from heaviest to lightest
512522
let mut stats: Vec<_> = items_per_def_id
513523
.into_iter()
514524
.map(|(def_id, items)| {
525+
let name = with_no_trimmed_paths!(tcx.def_path_str(def_id));
515526
let instantiation_count = items.len();
516527
let size_estimate = items[0].size_estimate(tcx);
517528
let total_estimate = instantiation_count * size_estimate;
518-
(def_id, instantiation_count, size_estimate, total_estimate)
529+
MonoItem { name, instantiation_count, size_estimate, total_estimate }
519530
})
520531
.collect();
521-
stats.sort_unstable_by_key(|(_, _, _, total_estimate)| cmp::Reverse(*total_estimate));
532+
stats.sort_unstable_by_key(|item| cmp::Reverse(item.total_estimate));
522533

523534
if !stats.is_empty() {
524-
writeln!(
525-
file,
526-
"| Item | Instantiation count | Estimated Cost Per Instantiation | Total Estimated Cost |"
527-
)?;
528-
writeln!(file, "| --- | ---: | ---: | ---: |")?;
529-
for (def_id, instantiation_count, size_estimate, total_estimate) in stats {
530-
let item = with_no_trimmed_paths!(tcx.def_path_str(def_id));
531-
writeln!(
532-
file,
533-
"| {item} | {instantiation_count} | {size_estimate} | {total_estimate} |"
534-
)?;
535+
match format {
536+
DumpMonoStatsFormat::Json => serde_json::to_writer(file, &stats)?,
537+
DumpMonoStatsFormat::Markdown => {
538+
writeln!(
539+
file,
540+
"| Item | Instantiation count | Estimated Cost Per Instantiation | Total Estimated Cost |"
541+
)?;
542+
writeln!(file, "| --- | ---: | ---: | ---: |")?;
543+
544+
for MonoItem { name, instantiation_count, size_estimate, total_estimate } in stats {
545+
writeln!(
546+
file,
547+
"| `{name}` | {instantiation_count} | {size_estimate} | {total_estimate} |"
548+
)?;
549+
}
550+
}
535551
}
536552
}
537553

‎compiler/rustc_query_impl/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = "0.0.0"
44
edition = "2021"
55

66
[lib]
7-
doctest = false
7+
88

99
[dependencies]
1010
measureme = "10.0.0"

‎compiler/rustc_session/src/config.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2981,3 +2981,21 @@ pub enum ProcMacroExecutionStrategy {
29812981
/// Run the proc-macro code on a different thread.
29822982
CrossThread,
29832983
}
2984+
2985+
/// Which format to use for `-Z dump-mono-stats`
2986+
#[derive(Clone, Copy, PartialEq, Hash, Debug)]
2987+
pub enum DumpMonoStatsFormat {
2988+
/// Pretty-print a markdown table
2989+
Markdown,
2990+
/// Emit structured JSON
2991+
Json,
2992+
}
2993+
2994+
impl DumpMonoStatsFormat {
2995+
pub fn extension(self) -> &'static str {
2996+
match self {
2997+
Self::Markdown => "md",
2998+
Self::Json => "json",
2999+
}
3000+
}
3001+
}

‎compiler/rustc_session/src/errors.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,11 @@ pub(crate) struct InvalidFloatLiteralSuffix {
260260

261261
#[derive(Diagnostic)]
262262
#[diag(session_int_literal_too_large)]
263+
#[note]
263264
pub(crate) struct IntLiteralTooLarge {
264265
#[primary_span]
265266
pub span: Span,
267+
pub limit: String,
266268
}
267269

268270
#[derive(Diagnostic)]
@@ -361,8 +363,15 @@ pub fn report_lit_error(sess: &ParseSess, err: LitError, lit: token::Lit, span:
361363
_ => unreachable!(),
362364
};
363365
}
364-
LitError::IntTooLarge => {
365-
sess.emit_err(IntLiteralTooLarge { span });
366+
LitError::IntTooLarge(base) => {
367+
let max = u128::MAX;
368+
let limit = match base {
369+
2 => format!("{max:#b}"),
370+
8 => format!("{max:#o}"),
371+
16 => format!("{max:#x}"),
372+
_ => format!("{max}"),
373+
};
374+
sess.emit_err(IntLiteralTooLarge { span, limit });
366375
}
367376
}
368377
}

‎compiler/rustc_session/src/options.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@ mod desc {
377377
pub const parse_linker_flavor: &str = ::rustc_target::spec::LinkerFlavorCli::one_of();
378378
pub const parse_optimization_fuel: &str = "crate=integer";
379379
pub const parse_mir_spanview: &str = "`statement` (default), `terminator`, or `block`";
380+
pub const parse_dump_mono_stats: &str = "`markdown` (default) or `json`";
380381
pub const parse_instrument_coverage: &str =
381382
"`all` (default), `except-unused-generics`, `except-unused-functions`, or `off`";
382383
pub const parse_unpretty: &str = "`string` or `string=string`";
@@ -820,6 +821,21 @@ mod parse {
820821
true
821822
}
822823

824+
pub(crate) fn parse_dump_mono_stats(slot: &mut DumpMonoStatsFormat, v: Option<&str>) -> bool {
825+
match v {
826+
None => true,
827+
Some("json") => {
828+
*slot = DumpMonoStatsFormat::Json;
829+
true
830+
}
831+
Some("markdown") => {
832+
*slot = DumpMonoStatsFormat::Markdown;
833+
true
834+
}
835+
Some(_) => false,
836+
}
837+
}
838+
823839
pub(crate) fn parse_instrument_coverage(
824840
slot: &mut Option<InstrumentCoverage>,
825841
v: Option<&str>,
@@ -1295,7 +1311,9 @@ options! {
12951311
an additional `.html` file showing the computed coverage spans."),
12961312
dump_mono_stats: SwitchWithOptPath = (SwitchWithOptPath::Disabled,
12971313
parse_switch_with_opt_path, [UNTRACKED],
1298-
"output statistics about monomorphization collection (format: markdown)"),
1314+
"output statistics about monomorphization collection"),
1315+
dump_mono_stats_format: DumpMonoStatsFormat = (DumpMonoStatsFormat::Markdown, parse_dump_mono_stats, [UNTRACKED],
1316+
"the format to use for -Z dump-mono-stats (`markdown` (default) or `json`)"),
12991317
dwarf_version: Option<u32> = (None, parse_opt_number, [TRACKED],
13001318
"version of DWARF debug information to emit (default: 2 or 4, depending on platform)"),
13011319
dylib_lto: bool = (false, parse_bool, [UNTRACKED],

‎compiler/rustc_span/src/symbol.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ symbols! {
193193
FromIterator,
194194
FromResidual,
195195
Future,
196+
FutureOutput,
196197
FxHashMap,
197198
FxHashSet,
198199
GlobalAlloc,

‎library/core/src/future/future.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ use crate::task::{Context, Poll};
3737
pub trait Future {
3838
/// The type of value produced on completion.
3939
#[stable(feature = "futures_api", since = "1.36.0")]
40+
#[rustc_diagnostic_item = "FutureOutput"]
4041
type Output;
4142

4243
/// Attempt to resolve the future to a final value, registering

‎library/std/src/macros.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
//! This module contains a set of macros which are exported from the standard
44
//! library. Each macro is available for use when linking against the standard
55
//! library.
6+
// ignore-tidy-dbg
67

78
#[doc = include_str!("../../core/src/macros/panic.md")]
89
#[macro_export]

‎src/bootstrap/run.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ impl Step for BumpStage0 {
105105

106106
fn run(self, builder: &Builder<'_>) -> Self::Output {
107107
let mut cmd = builder.tool_cmd(Tool::BumpStage0);
108+
cmd.args(builder.config.cmd.args());
108109
builder.run(&mut cmd);
109110
}
110111
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# `dump-mono-stats-format`
2+
3+
--------------------
4+
5+
The `-Z dump-mono-stats-format` compiler flag controls what file format to use for `-Z dump-mono-stats`.
6+
The default is markdown; currently JSON is also supported. JSON can be useful for programatically manipulating the results (e.g. to find the item that took the longest to compile).
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# `dump-mono-stats`
2+
3+
--------------------
4+
5+
The `-Z dump-mono-stats` compiler flag generates a file with a list of the monomorphized items in the current crate.
6+
It is useful for investigating compile times.
7+
8+
It accepts an optional directory where the file will be located. If no directory is specified, the file will be placed in the current directory.
9+
10+
See also `-Z dump-mono-stats-format` and `-Z print-mono-items`. Unlike `print-mono-items`,
11+
`dump-mono-stats` aggregates monomorphized items by definition and includes a size estimate of how
12+
large the item is when codegened.
13+
14+
See <https://rustc-dev-guide.rust-lang.org/backend/monomorph.html> for an overview of monomorphized items.

‎src/test/codegen/box-maybe-uninit-llvm14.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// Once we're done with llvm 14 and earlier, this test can be deleted.
44

5-
#![crate_type="lib"]
5+
#![crate_type = "lib"]
66

77
use std::mem::MaybeUninit;
88

@@ -17,8 +17,16 @@ pub fn box_uninitialized() -> Box<MaybeUninit<usize>> {
1717
Box::new(MaybeUninit::uninit())
1818
}
1919

20-
// FIXME: add a test for a bigger box. Currently broken, see
21-
// https://github.com/rust-lang/rust/issues/58201.
20+
// https://github.com/rust-lang/rust/issues/58201
21+
#[no_mangle]
22+
pub fn box_uninitialized2() -> Box<MaybeUninit<[usize; 1024 * 1024]>> {
23+
// CHECK-LABEL: @box_uninitialized2
24+
// CHECK-NOT: store
25+
// CHECK-NOT: alloca
26+
// CHECK-NOT: memcpy
27+
// CHECK-NOT: memset
28+
Box::new(MaybeUninit::uninit())
29+
}
2230

2331
// Hide the LLVM 15+ `allocalign` attribute in the declaration of __rust_alloc
2432
// from the CHECK-NOT above. We don't check the attributes here because we can't rely

‎src/test/codegen/box-maybe-uninit.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// compile-flags: -O
22
// min-llvm-version: 15.0
3-
#![crate_type="lib"]
3+
#![crate_type = "lib"]
44

55
use std::mem::MaybeUninit;
66

@@ -15,8 +15,16 @@ pub fn box_uninitialized() -> Box<MaybeUninit<usize>> {
1515
Box::new(MaybeUninit::uninit())
1616
}
1717

18-
// FIXME: add a test for a bigger box. Currently broken, see
19-
// https://github.com/rust-lang/rust/issues/58201.
18+
// https://github.com/rust-lang/rust/issues/58201
19+
#[no_mangle]
20+
pub fn box_uninitialized2() -> Box<MaybeUninit<[usize; 1024 * 1024]>> {
21+
// CHECK-LABEL: @box_uninitialized2
22+
// CHECK-NOT: store
23+
// CHECK-NOT: alloca
24+
// CHECK-NOT: memcpy
25+
// CHECK-NOT: memset
26+
Box::new(MaybeUninit::uninit())
27+
}
2028

2129
// Hide the `allocalign` attribute in the declaration of __rust_alloc
2230
// from the CHECK-NOT above, and also verify the attributes got set reasonably.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
include ../../run-make-fulldeps/tools.mk
2+
3+
all:
4+
$(RUSTC) --crate-type lib foo.rs -Z dump-mono-stats=$(TMPDIR) -Zdump-mono-stats-format=json
5+
cat $(TMPDIR)/foo.mono_items.json | $(CGREP) '"name":"bar"'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub fn bar() {}

‎src/test/rustdoc-ui/z-help.stdout

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
-Z dump-mir-exclude-pass-number=val -- exclude the pass number when dumping MIR (used in tests) (default: no)
3636
-Z dump-mir-graphviz=val -- in addition to `.mir` files, create graphviz `.dot` files (and with `-Z instrument-coverage`, also create a `.dot` file for the MIR-derived coverage graph) (default: no)
3737
-Z dump-mir-spanview=val -- in addition to `.mir` files, create `.html` files to view spans for all `statement`s (including terminators), only `terminator` spans, or computed `block` spans (one span encompassing a block's terminator and all statements). If `-Z instrument-coverage` is also enabled, create an additional `.html` file showing the computed coverage spans.
38-
-Z dump-mono-stats=val -- output statistics about monomorphization collection (format: markdown)
38+
-Z dump-mono-stats=val -- output statistics about monomorphization collection
39+
-Z dump-mono-stats-format=val -- the format to use for -Z dump-mono-stats (`markdown` (default) or `json`)
3940
-Z dwarf-version=val -- version of DWARF debug information to emit (default: 2 or 4, depending on platform)
4041
-Z dylib-lto=val -- enables LTO for dylib crate type
4142
-Z emit-stack-sizes=val -- emit a section containing stack size metadata (default: no)

‎src/test/ui/fn/issue-80179.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ fn returns_fn_ptr() -> _ {
1818
fn returns_closure() -> _ {
1919
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types [E0121]
2020
//~| NOTE not allowed in type signatures
21-
//~| HELP consider using an `Fn`, `FnMut`, or `FnOnce` trait bound
22-
//~| NOTE for more information on `Fn` traits and closure types, see
23-
// https://doc.rust-lang.org/book/ch13-01-closures.html
21+
//~| HELP replace with an appropriate return type
22+
//~| SUGGESTION impl Fn() -> i32
23+
//~| NOTE for more information on `Fn` traits and closure types
2424
|| 0
2525
}
2626

‎src/test/ui/fn/issue-80179.stderr

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures
1111
--> $DIR/issue-80179.rs:18:25
1212
|
1313
LL | fn returns_closure() -> _ {
14-
| ^ not allowed in type signatures
14+
| ^
15+
| |
16+
| not allowed in type signatures
17+
| help: replace with an appropriate return type: `impl Fn() -> i32`
1518
|
16-
= help: consider using an `Fn`, `FnMut`, or `FnOnce` trait bound
1719
= note: for more information on `Fn` traits and closure types, see https://doc.rust-lang.org/book/ch13-01-closures.html
1820

1921
error: aborting due to 2 previous errors
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
fn fn_once() -> _ {
2+
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types [E0121]
3+
//~| NOTE not allowed in type signatures
4+
//~| HELP replace with an appropriate return type
5+
//~| SUGGESTION impl FnOnce()
6+
//~| NOTE for more information on `Fn` traits and closure types
7+
let x = String::new();
8+
|| {
9+
drop(x);
10+
}
11+
}
12+
13+
fn fn_mut() -> _ {
14+
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types [E0121]
15+
//~| NOTE not allowed in type signatures
16+
//~| HELP replace with an appropriate return type
17+
//~| SUGGESTION impl FnMut(char)
18+
//~| NOTE for more information on `Fn` traits and closure types
19+
let x = String::new();
20+
|c| {
21+
x.push(c);
22+
}
23+
}
24+
25+
fn fun() -> _ {
26+
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types [E0121]
27+
//~| NOTE not allowed in type signatures
28+
//~| HELP replace with an appropriate return type
29+
//~| SUGGESTION impl Fn() -> i32
30+
//~| NOTE for more information on `Fn` traits and closure types
31+
|| 1i32
32+
}
33+
34+
fn main() {}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types
2+
--> $DIR/suggest-return-closure.rs:1:17
3+
|
4+
LL | fn fn_once() -> _ {
5+
| ^
6+
| |
7+
| not allowed in type signatures
8+
| help: replace with an appropriate return type: `impl FnOnce()`
9+
|
10+
= note: for more information on `Fn` traits and closure types, see https://doc.rust-lang.org/book/ch13-01-closures.html
11+
12+
error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types
13+
--> $DIR/suggest-return-closure.rs:13:16
14+
|
15+
LL | fn fn_mut() -> _ {
16+
| ^
17+
| |
18+
| not allowed in type signatures
19+
| help: replace with an appropriate return type: `impl FnMut(char)`
20+
|
21+
= note: for more information on `Fn` traits and closure types, see https://doc.rust-lang.org/book/ch13-01-closures.html
22+
23+
error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types
24+
--> $DIR/suggest-return-closure.rs:25:13
25+
|
26+
LL | fn fun() -> _ {
27+
| ^
28+
| |
29+
| not allowed in type signatures
30+
| help: replace with an appropriate return type: `impl Fn() -> i32`
31+
|
32+
= note: for more information on `Fn` traits and closure types, see https://doc.rust-lang.org/book/ch13-01-closures.html
33+
34+
error: aborting due to 3 previous errors
35+
36+
For more information about this error, try `rustc --explain E0121`.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// edition: 2021
2+
3+
async fn a() -> i32 {
4+
0
5+
}
6+
7+
fn foo() -> _ {
8+
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types [E0121]
9+
//~| NOTE not allowed in type signatures
10+
//~| HELP replace with an appropriate return type
11+
//~| SUGGESTION impl Future<Output = i32>
12+
a()
13+
}
14+
15+
fn bar() -> _ {
16+
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types [E0121]
17+
//~| NOTE not allowed in type signatures
18+
//~| HELP replace with an appropriate return type
19+
//~| SUGGESTION impl Future<Output = i32>
20+
async { a().await }
21+
}
22+
23+
fn main() {}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types
2+
--> $DIR/suggest-return-future.rs:7:13
3+
|
4+
LL | fn foo() -> _ {
5+
| ^
6+
| |
7+
| not allowed in type signatures
8+
| help: replace with an appropriate return type: `impl Future<Output = i32>`
9+
10+
error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types
11+
--> $DIR/suggest-return-future.rs:15:13
12+
|
13+
LL | fn bar() -> _ {
14+
| ^
15+
| |
16+
| not allowed in type signatures
17+
| help: replace with an appropriate return type: `impl Future<Output = i32>`
18+
19+
error: aborting due to 2 previous errors
20+
21+
For more information about this error, try `rustc --explain E0121`.

‎src/test/ui/lexer/error-stage.stderr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ error: integer literal is too large
4949
|
5050
LL | 999340282366920938463463374607431768211455999;
5151
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
52+
|
53+
= note: value exceeds limit of `340282366920938463463374607431768211455`
5254

5355
error: aborting due to 8 previous errors
5456

‎src/test/ui/lexer/lex-bad-numeric-literals.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// ignore-tidy-linelength
2+
13
fn main() {
24
0o1.0; //~ ERROR: octal float literal is not supported
35
0o2f32; //~ ERROR: octal float literal is not supported
@@ -15,6 +17,12 @@ fn main() {
1517
//~^ ERROR: integer literal is too large
1618
9900000000000000000000000000999999999999999999999999999999;
1719
//~^ ERROR: integer literal is too large
20+
0b111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110;
21+
//~^ ERROR: integer literal is too large
22+
0o37777777777777777777777777777777777777777770;
23+
//~^ ERROR: integer literal is too large
24+
0xffffffffffffffffffffffffffffffff0;
25+
//~^ ERROR: integer literal is too large
1826
0x; //~ ERROR: no valid digits
1927
0xu32; //~ ERROR: no valid digits
2028
0ou32; //~ ERROR: no valid digits
Lines changed: 52 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,141 +1,169 @@
11
error: octal float literal is not supported
2-
--> $DIR/lex-bad-numeric-literals.rs:2:5
2+
--> $DIR/lex-bad-numeric-literals.rs:4:5
33
|
44
LL | 0o1.0;
55
| ^^^^^
66

77
error: octal float literal is not supported
8-
--> $DIR/lex-bad-numeric-literals.rs:4:5
8+
--> $DIR/lex-bad-numeric-literals.rs:6:5
99
|
1010
LL | 0o3.0f32;
1111
| ^^^^^
1212

1313
error: octal float literal is not supported
14-
--> $DIR/lex-bad-numeric-literals.rs:5:5
14+
--> $DIR/lex-bad-numeric-literals.rs:7:5
1515
|
1616
LL | 0o4e4;
1717
| ^^^^^
1818

1919
error: octal float literal is not supported
20-
--> $DIR/lex-bad-numeric-literals.rs:6:5
20+
--> $DIR/lex-bad-numeric-literals.rs:8:5
2121
|
2222
LL | 0o5.0e5;
2323
| ^^^^^^^
2424

2525
error: octal float literal is not supported
26-
--> $DIR/lex-bad-numeric-literals.rs:7:5
26+
--> $DIR/lex-bad-numeric-literals.rs:9:5
2727
|
2828
LL | 0o6e6f32;
2929
| ^^^^^
3030

3131
error: octal float literal is not supported
32-
--> $DIR/lex-bad-numeric-literals.rs:8:5
32+
--> $DIR/lex-bad-numeric-literals.rs:10:5
3333
|
3434
LL | 0o7.0e7f64;
3535
| ^^^^^^^
3636

3737
error: hexadecimal float literal is not supported
38-
--> $DIR/lex-bad-numeric-literals.rs:9:5
38+
--> $DIR/lex-bad-numeric-literals.rs:11:5
3939
|
4040
LL | 0x8.0e+9;
4141
| ^^^^^^^^
4242

4343
error: hexadecimal float literal is not supported
44-
--> $DIR/lex-bad-numeric-literals.rs:10:5
44+
--> $DIR/lex-bad-numeric-literals.rs:12:5
4545
|
4646
LL | 0x9.0e-9;
4747
| ^^^^^^^^
4848

4949
error[E0768]: no valid digits found for number
50-
--> $DIR/lex-bad-numeric-literals.rs:11:5
50+
--> $DIR/lex-bad-numeric-literals.rs:13:5
5151
|
5252
LL | 0o;
5353
| ^^
5454

5555
error: expected at least one digit in exponent
56-
--> $DIR/lex-bad-numeric-literals.rs:12:5
56+
--> $DIR/lex-bad-numeric-literals.rs:14:5
5757
|
5858
LL | 1e+;
5959
| ^^^
6060

6161
error: hexadecimal float literal is not supported
62-
--> $DIR/lex-bad-numeric-literals.rs:13:5
62+
--> $DIR/lex-bad-numeric-literals.rs:15:5
6363
|
6464
LL | 0x539.0;
6565
| ^^^^^^^
6666

6767
error[E0768]: no valid digits found for number
68-
--> $DIR/lex-bad-numeric-literals.rs:18:5
68+
--> $DIR/lex-bad-numeric-literals.rs:26:5
6969
|
7070
LL | 0x;
7171
| ^^
7272

7373
error[E0768]: no valid digits found for number
74-
--> $DIR/lex-bad-numeric-literals.rs:19:5
74+
--> $DIR/lex-bad-numeric-literals.rs:27:5
7575
|
7676
LL | 0xu32;
7777
| ^^
7878

7979
error[E0768]: no valid digits found for number
80-
--> $DIR/lex-bad-numeric-literals.rs:20:5
80+
--> $DIR/lex-bad-numeric-literals.rs:28:5
8181
|
8282
LL | 0ou32;
8383
| ^^
8484

8585
error[E0768]: no valid digits found for number
86-
--> $DIR/lex-bad-numeric-literals.rs:21:5
86+
--> $DIR/lex-bad-numeric-literals.rs:29:5
8787
|
8888
LL | 0bu32;
8989
| ^^
9090

9191
error[E0768]: no valid digits found for number
92-
--> $DIR/lex-bad-numeric-literals.rs:22:5
92+
--> $DIR/lex-bad-numeric-literals.rs:30:5
9393
|
9494
LL | 0b;
9595
| ^^
9696

9797
error: octal float literal is not supported
98-
--> $DIR/lex-bad-numeric-literals.rs:24:5
98+
--> $DIR/lex-bad-numeric-literals.rs:32:5
9999
|
100100
LL | 0o123.456;
101101
| ^^^^^^^^^
102102

103103
error: binary float literal is not supported
104-
--> $DIR/lex-bad-numeric-literals.rs:26:5
104+
--> $DIR/lex-bad-numeric-literals.rs:34:5
105105
|
106106
LL | 0b111.101;
107107
| ^^^^^^^^^
108108

109109
error: octal float literal is not supported
110-
--> $DIR/lex-bad-numeric-literals.rs:3:5
110+
--> $DIR/lex-bad-numeric-literals.rs:5:5
111111
|
112112
LL | 0o2f32;
113113
| ^^^^^^ not supported
114114

115115
error: integer literal is too large
116-
--> $DIR/lex-bad-numeric-literals.rs:14:5
116+
--> $DIR/lex-bad-numeric-literals.rs:16:5
117117
|
118118
LL | 9900000000000000000000000000999999999999999999999999999999;
119119
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
120+
|
121+
= note: value exceeds limit of `340282366920938463463374607431768211455`
120122

121123
error: integer literal is too large
122-
--> $DIR/lex-bad-numeric-literals.rs:16:5
124+
--> $DIR/lex-bad-numeric-literals.rs:18:5
123125
|
124126
LL | 9900000000000000000000000000999999999999999999999999999999;
125127
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
128+
|
129+
= note: value exceeds limit of `340282366920938463463374607431768211455`
130+
131+
error: integer literal is too large
132+
--> $DIR/lex-bad-numeric-literals.rs:20:5
133+
|
134+
LL | 0b111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110;
135+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
136+
|
137+
= note: value exceeds limit of `0b11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111`
138+
139+
error: integer literal is too large
140+
--> $DIR/lex-bad-numeric-literals.rs:22:5
141+
|
142+
LL | 0o37777777777777777777777777777777777777777770;
143+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
144+
|
145+
= note: value exceeds limit of `0o3777777777777777777777777777777777777777777`
146+
147+
error: integer literal is too large
148+
--> $DIR/lex-bad-numeric-literals.rs:24:5
149+
|
150+
LL | 0xffffffffffffffffffffffffffffffff0;
151+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
152+
|
153+
= note: value exceeds limit of `0xffffffffffffffffffffffffffffffff`
126154

127155
error: octal float literal is not supported
128-
--> $DIR/lex-bad-numeric-literals.rs:23:5
156+
--> $DIR/lex-bad-numeric-literals.rs:31:5
129157
|
130158
LL | 0o123f64;
131159
| ^^^^^^^^ not supported
132160

133161
error: binary float literal is not supported
134-
--> $DIR/lex-bad-numeric-literals.rs:25:5
162+
--> $DIR/lex-bad-numeric-literals.rs:33:5
135163
|
136164
LL | 0b101f64;
137165
| ^^^^^^^^ not supported
138166

139-
error: aborting due to 23 previous errors
167+
error: aborting due to 26 previous errors
140168

141169
For more information about this error, try `rustc --explain E0768`.

‎src/test/ui/macros/issue-104769-concat_bytes-invalid-literal.stderr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ error: integer literal is too large
1111
|
1212
LL | concat_bytes!(888888888888888888888888888888888888888);
1313
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
14+
|
15+
= note: value exceeds limit of `340282366920938463463374607431768211455`
1416

1517
error: aborting due to 2 previous errors
1618

‎src/test/ui/parser/int-literal-too-large-span.stderr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ error: integer literal is too large
33
|
44
LL | 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: value exceeds limit of `340282366920938463463374607431768211455`
68

79
error: aborting due to previous error
810

‎src/test/ui/parser/issues/issue-5544-a.stderr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ error: integer literal is too large
33
|
44
LL | let __isize = 340282366920938463463374607431768211456; // 2^128
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: value exceeds limit of `340282366920938463463374607431768211455`
68

79
error: aborting due to previous error
810

‎src/test/ui/parser/issues/issue-5544-b.stderr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ error: integer literal is too large
33
|
44
LL | let __isize = 0xffff_ffff_ffff_ffff_ffff_ffff_ffff_ffff_ff;
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: value exceeds limit of `0xffffffffffffffffffffffffffffffff`
68

79
error: aborting due to previous error
810

‎src/tools/bump-stage0/src/main.rs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use anyhow::Error;
1+
use anyhow::{Context, Error};
22
use curl::easy::Easy;
33
use indexmap::IndexMap;
44
use std::collections::HashMap;
@@ -13,12 +13,13 @@ struct Tool {
1313
comments: Vec<String>,
1414

1515
channel: Channel,
16+
date: Option<String>,
1617
version: [u16; 3],
1718
checksums: IndexMap<String, String>,
1819
}
1920

2021
impl Tool {
21-
fn new() -> Result<Self, Error> {
22+
fn new(date: Option<String>) -> Result<Self, Error> {
2223
let channel = match std::fs::read_to_string("src/ci/channel")?.trim() {
2324
"stable" => Channel::Stable,
2425
"beta" => Channel::Beta,
@@ -40,6 +41,7 @@ impl Tool {
4041
Ok(Self {
4142
channel,
4243
version,
44+
date,
4345
config: existing.config,
4446
comments: existing.comments,
4547
checksums: IndexMap::new(),
@@ -84,7 +86,7 @@ impl Tool {
8486
Channel::Nightly => "beta".to_string(),
8587
};
8688

87-
let manifest = fetch_manifest(&self.config, &channel)?;
89+
let manifest = fetch_manifest(&self.config, &channel, self.date.as_deref())?;
8890
self.collect_checksums(&manifest, COMPILER_COMPONENTS)?;
8991
Ok(Stage0Toolchain {
9092
date: manifest.date,
@@ -110,7 +112,7 @@ impl Tool {
110112
return Ok(None);
111113
}
112114

113-
let manifest = fetch_manifest(&self.config, "nightly")?;
115+
let manifest = fetch_manifest(&self.config, "nightly", self.date.as_deref())?;
114116
self.collect_checksums(&manifest, RUSTFMT_COMPONENTS)?;
115117
Ok(Some(Stage0Toolchain { date: manifest.date, version: "nightly".into() }))
116118
}
@@ -141,16 +143,19 @@ impl Tool {
141143
}
142144

143145
fn main() -> Result<(), Error> {
144-
let tool = Tool::new()?;
146+
let tool = Tool::new(std::env::args().nth(1))?;
145147
tool.update_json()?;
146148
Ok(())
147149
}
148150

149-
fn fetch_manifest(config: &Config, channel: &str) -> Result<Manifest, Error> {
150-
Ok(toml::from_slice(&http_get(&format!(
151-
"{}/dist/channel-rust-{}.toml",
152-
config.dist_server, channel
153-
))?)?)
151+
fn fetch_manifest(config: &Config, channel: &str, date: Option<&str>) -> Result<Manifest, Error> {
152+
let url = if let Some(date) = date {
153+
format!("{}/dist/{}/channel-rust-{}.toml", config.dist_server, date, channel)
154+
} else {
155+
format!("{}/dist/channel-rust-{}.toml", config.dist_server, channel)
156+
};
157+
158+
Ok(toml::from_slice(&http_get(&url)?)?)
154159
}
155160

156161
fn http_get(url: &str) -> Result<Vec<u8>, Error> {
@@ -164,7 +169,7 @@ fn http_get(url: &str) -> Result<Vec<u8>, Error> {
164169
data.extend_from_slice(new_data);
165170
Ok(new_data.len())
166171
})?;
167-
transfer.perform()?;
172+
transfer.perform().context(format!("failed to fetch {url}"))?;
168173
}
169174
Ok(data)
170175
}

‎src/tools/tidy/src/style.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
//!
1616
//! A number of these checks can be opted-out of with various directives of the form:
1717
//! `// ignore-tidy-CHECK-NAME`.
18+
// ignore-tidy-dbg
1819

1920
use crate::walk::{filter_dirs, walk};
2021
use regex::{Regex, RegexSet};
@@ -278,6 +279,7 @@ pub fn check(path: &Path, bad: &mut bool) {
278279
let mut skip_leading_newlines =
279280
contains_ignore_directive(can_contain, &contents, "leading-newlines");
280281
let mut skip_copyright = contains_ignore_directive(can_contain, &contents, "copyright");
282+
let mut skip_dbg = contains_ignore_directive(can_contain, &contents, "dbg");
281283
let mut leading_new_lines = false;
282284
let mut trailing_new_lines = 0;
283285
let mut lines = 0;
@@ -306,6 +308,21 @@ pub fn check(path: &Path, bad: &mut bool) {
306308
let mut err = |msg: &str| {
307309
tidy_error!(bad, "{}:{}: {}", file.display(), i + 1, msg);
308310
};
311+
312+
if trimmed.contains("dbg!")
313+
&& !trimmed.starts_with("//")
314+
&& !file
315+
.ancestors()
316+
.any(|a| a.ends_with("src/test") || a.ends_with("library/alloc/tests"))
317+
&& filename != "tests.rs"
318+
{
319+
suppressible_tidy_err!(
320+
err,
321+
skip_dbg,
322+
"`dbg!` macro is intended as a debugging tool. It should not be in version control."
323+
)
324+
}
325+
309326
if !under_rustfmt
310327
&& line.chars().count() > max_columns
311328
&& !long_line_is_ok(&extension, is_error_code, max_columns, line)

0 commit comments

Comments
 (0)
This repository has been archived.