Skip to content

Commit fac7753

Browse files
committed
Auto merge of #128853 - matthiaskrgr:rollup-pr222x1, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #128640 (rwlock: disable 'frob' test in Miri on macOS) - #128791 (Don't implement `AsyncFn` for `FnDef`/`FnPtr` that wouldnt implement `Fn`) - #128806 (Split `ColorConfig` off of `HumanReadableErrorType`) - #128818 (std float tests: special-case Miri in feature detection) - #128834 (rustdoc: strip unreachable modules) - #128836 (rustdoc-json: add a test for impls on private & hidden types) - #128837 (Clippy subtree update) - #128851 (Add comment that bors did not see pushed before it merged) r? `@ghost` `@rustbot` modify labels: rollup
2 parents c7b0d4e + 9243aee commit fac7753

File tree

320 files changed

+5830
-4097
lines changed

Some content is hidden

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

320 files changed

+5830
-4097
lines changed

Cargo.lock

+6-5
Original file line numberDiff line numberDiff line change
@@ -564,14 +564,15 @@ dependencies = [
564564
"termize",
565565
"tokio",
566566
"toml 0.7.8",
567-
"ui_test 0.24.0",
567+
"ui_test 0.25.0",
568568
"walkdir",
569569
]
570570

571571
[[package]]
572572
name = "clippy_config"
573573
version = "0.1.82"
574574
dependencies = [
575+
"itertools",
575576
"rustc-semver",
576577
"serde",
577578
"toml 0.7.8",
@@ -4936,9 +4937,9 @@ dependencies = [
49364937

49374938
[[package]]
49384939
name = "spanned"
4939-
version = "0.2.1"
4940+
version = "0.3.0"
49404941
source = "registry+https://github.com/rust-lang/crates.io-index"
4941-
checksum = "ed14ba8b4b82241bd5daba2c49185d4a0581a0058355fe96537338f002b8605d"
4942+
checksum = "86af297923fbcfd107c20a189a6e9c872160df71a7190ae4a7a6c5dce4b2feb6"
49424943
dependencies = [
49434944
"bstr",
49444945
"color-eyre",
@@ -5562,9 +5563,9 @@ dependencies = [
55625563

55635564
[[package]]
55645565
name = "ui_test"
5565-
version = "0.24.0"
5566+
version = "0.25.0"
55665567
source = "registry+https://github.com/rust-lang/crates.io-index"
5567-
checksum = "bc1c6c78d55482388711c8d417b8e547263046a607512278fed274c54633bbe4"
5568+
checksum = "f7e4f339f62edc873975c47115f9e71c5454ddaa37c1142b42fc0b2672c8dacb"
55685569
dependencies = [
55695570
"annotate-snippets 0.11.4",
55705571
"anyhow",

compiler/rustc_errors/src/emitter.rs

+5-10
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,14 @@ const DEFAULT_COLUMN_WIDTH: usize = 140;
4343
/// Describes the way the content of the `rendered` field of the json output is generated
4444
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
4545
pub enum HumanReadableErrorType {
46-
Default(ColorConfig),
47-
AnnotateSnippet(ColorConfig),
48-
Short(ColorConfig),
46+
Default,
47+
AnnotateSnippet,
48+
Short,
4949
}
5050

5151
impl HumanReadableErrorType {
52-
/// Returns a (`short`, `color`) tuple
53-
pub fn unzip(self) -> (bool, ColorConfig) {
54-
match self {
55-
HumanReadableErrorType::Default(cc) => (false, cc),
56-
HumanReadableErrorType::Short(cc) => (true, cc),
57-
HumanReadableErrorType::AnnotateSnippet(cc) => (false, cc),
58-
}
52+
pub fn short(&self) -> bool {
53+
*self == HumanReadableErrorType::Short
5954
}
6055
}
6156

compiler/rustc_errors/src/json.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ pub struct JsonEmitter {
5555
ignored_directories_in_source_blocks: Vec<String>,
5656
#[setters(skip)]
5757
json_rendered: HumanReadableErrorType,
58+
color_config: ColorConfig,
5859
diagnostic_width: Option<usize>,
5960
macro_backtrace: bool,
6061
track_diagnostics: bool,
@@ -68,6 +69,7 @@ impl JsonEmitter {
6869
fallback_bundle: LazyFallbackBundle,
6970
pretty: bool,
7071
json_rendered: HumanReadableErrorType,
72+
color_config: ColorConfig,
7173
) -> JsonEmitter {
7274
JsonEmitter {
7375
dst: IntoDynSyncSend(dst),
@@ -79,6 +81,7 @@ impl JsonEmitter {
7981
ui_testing: false,
8082
ignored_directories_in_source_blocks: Vec::new(),
8183
json_rendered,
84+
color_config,
8285
diagnostic_width: None,
8386
macro_backtrace: false,
8487
track_diagnostics: false,
@@ -173,7 +176,7 @@ impl Emitter for JsonEmitter {
173176
}
174177

175178
fn should_show_explain(&self) -> bool {
176-
!matches!(self.json_rendered, HumanReadableErrorType::Short(_))
179+
!self.json_rendered.short()
177180
}
178181
}
179182

@@ -353,8 +356,8 @@ impl Diagnostic {
353356

354357
let buf = BufWriter::default();
355358
let mut dst: Destination = Box::new(buf.clone());
356-
let (short, color_config) = je.json_rendered.unzip();
357-
match color_config {
359+
let short = je.json_rendered.short();
360+
match je.color_config {
358361
ColorConfig::Always | ColorConfig::Auto => dst = Box::new(termcolor::Ansi::new(dst)),
359362
ColorConfig::Never => {}
360363
}

compiler/rustc_errors/src/json/tests.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ fn test_positions(code: &str, span: (u32, u32), expected_output: SpanTestData) {
5050
sm,
5151
fallback_bundle,
5252
true, // pretty
53-
HumanReadableErrorType::Short(ColorConfig::Never),
53+
HumanReadableErrorType::Short,
54+
ColorConfig::Never,
5455
);
5556

5657
let span = Span::with_root_ctxt(BytePos(span.0), BytePos(span.1));

compiler/rustc_interface/src/passes.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -818,8 +818,14 @@ fn run_required_analyses(tcx: TyCtxt<'_>) {
818818
});
819819
sess.time("layout_testing", || layout_test::test_layout(tcx));
820820
sess.time("abi_testing", || abi_test::test_abi(tcx));
821+
822+
// If `-Zvalidate-mir` is set, we also want to compute the final MIR for each item
823+
// (either its `mir_for_ctfe` or `optimized_mir`) since that helps uncover any bugs
824+
// in MIR optimizations that may only be reachable through codegen, or other codepaths
825+
// that requires the optimized/ctfe MIR, such as polymorphization, coroutine bodies,
826+
// or evaluating consts.
821827
if tcx.sess.opts.unstable_opts.validate_mir {
822-
sess.time("ensuring_optimized_MIR_is_computable", || {
828+
sess.time("ensuring_final_MIR_is_computable", || {
823829
tcx.hir().par_body_owners(|def_id| {
824830
tcx.instance_mir(ty::InstanceKind::Item(def_id.into()));
825831
});

compiler/rustc_interface/src/tests.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,8 @@ fn test_search_paths_tracking_hash_different_order() {
315315
let early_dcx = EarlyDiagCtxt::new(JSON);
316316
const JSON: ErrorOutputType = ErrorOutputType::Json {
317317
pretty: false,
318-
json_rendered: HumanReadableErrorType::Default(ColorConfig::Never),
318+
json_rendered: HumanReadableErrorType::Default,
319+
color_config: ColorConfig::Never,
319320
};
320321

321322
let push = |opts: &mut Options, search_path| {

compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs

+39-21
Original file line numberDiff line numberDiff line change
@@ -458,28 +458,23 @@ pub(in crate::solve) fn extract_tupled_inputs_and_output_from_async_callable<I:
458458
))
459459
}
460460

461-
ty::FnDef(..) | ty::FnPtr(..) => {
462-
let bound_sig = self_ty.fn_sig(cx);
463-
let sig = bound_sig.skip_binder();
464-
let future_trait_def_id = cx.require_lang_item(TraitSolverLangItem::Future);
465-
// `FnDef` and `FnPtr` only implement `AsyncFn*` when their
466-
// return type implements `Future`.
467-
let nested = vec![
468-
bound_sig
469-
.rebind(ty::TraitRef::new(cx, future_trait_def_id, [sig.output()]))
470-
.upcast(cx),
471-
];
472-
let future_output_def_id = cx.require_lang_item(TraitSolverLangItem::FutureOutput);
473-
let future_output_ty = Ty::new_projection(cx, future_output_def_id, [sig.output()]);
474-
Ok((
475-
bound_sig.rebind(AsyncCallableRelevantTypes {
476-
tupled_inputs_ty: Ty::new_tup(cx, sig.inputs().as_slice()),
477-
output_coroutine_ty: sig.output(),
478-
coroutine_return_ty: future_output_ty,
479-
}),
480-
nested,
481-
))
461+
ty::FnDef(def_id, _) => {
462+
let sig = self_ty.fn_sig(cx);
463+
if sig.skip_binder().is_fn_trait_compatible() && !cx.has_target_features(def_id) {
464+
fn_item_to_async_callable(cx, sig)
465+
} else {
466+
Err(NoSolution)
467+
}
468+
}
469+
ty::FnPtr(..) => {
470+
let sig = self_ty.fn_sig(cx);
471+
if sig.skip_binder().is_fn_trait_compatible() {
472+
fn_item_to_async_callable(cx, sig)
473+
} else {
474+
Err(NoSolution)
475+
}
482476
}
477+
483478
ty::Closure(_, args) => {
484479
let args = args.as_closure();
485480
let bound_sig = args.sig();
@@ -563,6 +558,29 @@ pub(in crate::solve) fn extract_tupled_inputs_and_output_from_async_callable<I:
563558
}
564559
}
565560

561+
fn fn_item_to_async_callable<I: Interner>(
562+
cx: I,
563+
bound_sig: ty::Binder<I, ty::FnSig<I>>,
564+
) -> Result<(ty::Binder<I, AsyncCallableRelevantTypes<I>>, Vec<I::Predicate>), NoSolution> {
565+
let sig = bound_sig.skip_binder();
566+
let future_trait_def_id = cx.require_lang_item(TraitSolverLangItem::Future);
567+
// `FnDef` and `FnPtr` only implement `AsyncFn*` when their
568+
// return type implements `Future`.
569+
let nested = vec![
570+
bound_sig.rebind(ty::TraitRef::new(cx, future_trait_def_id, [sig.output()])).upcast(cx),
571+
];
572+
let future_output_def_id = cx.require_lang_item(TraitSolverLangItem::FutureOutput);
573+
let future_output_ty = Ty::new_projection(cx, future_output_def_id, [sig.output()]);
574+
Ok((
575+
bound_sig.rebind(AsyncCallableRelevantTypes {
576+
tupled_inputs_ty: Ty::new_tup(cx, sig.inputs().as_slice()),
577+
output_coroutine_ty: sig.output(),
578+
coroutine_return_ty: future_output_ty,
579+
}),
580+
nested,
581+
))
582+
}
583+
566584
/// Given a coroutine-closure, project to its returned coroutine when we are *certain*
567585
/// that the closure's kind is compatible with the goal.
568586
fn coroutine_closure_to_certain_coroutine<I: Interner>(

compiler/rustc_session/src/config.rs

+23-15
Original file line numberDiff line numberDiff line change
@@ -602,20 +602,21 @@ impl OutputType {
602602
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
603603
pub enum ErrorOutputType {
604604
/// Output meant for the consumption of humans.
605-
HumanReadable(HumanReadableErrorType),
605+
HumanReadable(HumanReadableErrorType, ColorConfig),
606606
/// Output that's consumed by other tools such as `rustfix` or the `RLS`.
607607
Json {
608608
/// Render the JSON in a human readable way (with indents and newlines).
609609
pretty: bool,
610610
/// The JSON output includes a `rendered` field that includes the rendered
611611
/// human output.
612612
json_rendered: HumanReadableErrorType,
613+
color_config: ColorConfig,
613614
},
614615
}
615616

616617
impl Default for ErrorOutputType {
617618
fn default() -> Self {
618-
Self::HumanReadable(HumanReadableErrorType::Default(ColorConfig::Auto))
619+
Self::HumanReadable(HumanReadableErrorType::Default, ColorConfig::Auto)
619620
}
620621
}
621622

@@ -1631,6 +1632,7 @@ pub fn parse_color(early_dcx: &EarlyDiagCtxt, matches: &getopts::Matches) -> Col
16311632
/// Possible json config files
16321633
pub struct JsonConfig {
16331634
pub json_rendered: HumanReadableErrorType,
1635+
pub json_color: ColorConfig,
16341636
json_artifact_notifications: bool,
16351637
pub json_unused_externs: JsonUnusedExterns,
16361638
json_future_incompat: bool,
@@ -1668,8 +1670,7 @@ impl JsonUnusedExterns {
16681670
/// The first value returned is how to render JSON diagnostics, and the second
16691671
/// is whether or not artifact notifications are enabled.
16701672
pub fn parse_json(early_dcx: &EarlyDiagCtxt, matches: &getopts::Matches) -> JsonConfig {
1671-
let mut json_rendered: fn(ColorConfig) -> HumanReadableErrorType =
1672-
HumanReadableErrorType::Default;
1673+
let mut json_rendered = HumanReadableErrorType::Default;
16731674
let mut json_color = ColorConfig::Never;
16741675
let mut json_artifact_notifications = false;
16751676
let mut json_unused_externs = JsonUnusedExterns::No;
@@ -1696,7 +1697,8 @@ pub fn parse_json(early_dcx: &EarlyDiagCtxt, matches: &getopts::Matches) -> Json
16961697
}
16971698

16981699
JsonConfig {
1699-
json_rendered: json_rendered(json_color),
1700+
json_rendered,
1701+
json_color,
17001702
json_artifact_notifications,
17011703
json_unused_externs,
17021704
json_future_incompat,
@@ -1708,6 +1710,7 @@ pub fn parse_error_format(
17081710
early_dcx: &mut EarlyDiagCtxt,
17091711
matches: &getopts::Matches,
17101712
color: ColorConfig,
1713+
json_color: ColorConfig,
17111714
json_rendered: HumanReadableErrorType,
17121715
) -> ErrorOutputType {
17131716
// We need the `opts_present` check because the driver will send us Matches
@@ -1717,18 +1720,22 @@ pub fn parse_error_format(
17171720
let error_format = if matches.opts_present(&["error-format".to_owned()]) {
17181721
match matches.opt_str("error-format").as_deref() {
17191722
None | Some("human") => {
1720-
ErrorOutputType::HumanReadable(HumanReadableErrorType::Default(color))
1723+
ErrorOutputType::HumanReadable(HumanReadableErrorType::Default, color)
17211724
}
17221725
Some("human-annotate-rs") => {
1723-
ErrorOutputType::HumanReadable(HumanReadableErrorType::AnnotateSnippet(color))
1726+
ErrorOutputType::HumanReadable(HumanReadableErrorType::AnnotateSnippet, color)
17241727
}
1725-
Some("json") => ErrorOutputType::Json { pretty: false, json_rendered },
1726-
Some("pretty-json") => ErrorOutputType::Json { pretty: true, json_rendered },
1727-
Some("short") => ErrorOutputType::HumanReadable(HumanReadableErrorType::Short(color)),
1728-
1728+
Some("json") => {
1729+
ErrorOutputType::Json { pretty: false, json_rendered, color_config: json_color }
1730+
}
1731+
Some("pretty-json") => {
1732+
ErrorOutputType::Json { pretty: true, json_rendered, color_config: json_color }
1733+
}
1734+
Some("short") => ErrorOutputType::HumanReadable(HumanReadableErrorType::Short, color),
17291735
Some(arg) => {
17301736
early_dcx.abort_if_error_and_set_error_format(ErrorOutputType::HumanReadable(
1731-
HumanReadableErrorType::Default(color),
1737+
HumanReadableErrorType::Default,
1738+
color,
17321739
));
17331740
early_dcx.early_fatal(format!(
17341741
"argument for `--error-format` must be `human`, `json` or \
@@ -1737,7 +1744,7 @@ pub fn parse_error_format(
17371744
}
17381745
}
17391746
} else {
1740-
ErrorOutputType::HumanReadable(HumanReadableErrorType::Default(color))
1747+
ErrorOutputType::HumanReadable(HumanReadableErrorType::Default, color)
17411748
};
17421749

17431750
match error_format {
@@ -1791,7 +1798,7 @@ fn check_error_format_stability(
17911798
if let ErrorOutputType::Json { pretty: true, .. } = error_format {
17921799
early_dcx.early_fatal("`--error-format=pretty-json` is unstable");
17931800
}
1794-
if let ErrorOutputType::HumanReadable(HumanReadableErrorType::AnnotateSnippet(_)) =
1801+
if let ErrorOutputType::HumanReadable(HumanReadableErrorType::AnnotateSnippet, _) =
17951802
error_format
17961803
{
17971804
early_dcx.early_fatal("`--error-format=human-annotate-rs` is unstable");
@@ -2392,12 +2399,13 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M
23922399

23932400
let JsonConfig {
23942401
json_rendered,
2402+
json_color,
23952403
json_artifact_notifications,
23962404
json_unused_externs,
23972405
json_future_incompat,
23982406
} = parse_json(early_dcx, matches);
23992407

2400-
let error_format = parse_error_format(early_dcx, matches, color, json_rendered);
2408+
let error_format = parse_error_format(early_dcx, matches, color, json_color, json_rendered);
24012409

24022410
early_dcx.abort_if_error_and_set_error_format(error_format);
24032411

0 commit comments

Comments
 (0)