Skip to content

Commit 0ca3565

Browse files
committed
Auto merge of #102741 - matthiaskrgr:rollup-63no5tz, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - #98496 (make `compare_const_impl` a query and use it in `instance.rs`) - #102680 (Fix overconstrained Send impls in btree internals) - #102718 (Fix `opaque_hidden_inferred_bound` lint ICE) - #102725 (Remove `-Ztime`) - #102736 (Migrate search input color to CSS variable) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 2d46584 + 48964bd commit 0ca3565

File tree

35 files changed

+500
-169
lines changed

35 files changed

+500
-169
lines changed

compiler/rustc_codegen_llvm/src/back/lto.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ pub(crate) fn run_pass_manager(
573573
module: &mut ModuleCodegen<ModuleLlvm>,
574574
thin: bool,
575575
) -> Result<(), FatalError> {
576-
let _timer = cgcx.prof.extra_verbose_generic_activity("LLVM_lto_optimize", &*module.name);
576+
let _timer = cgcx.prof.verbose_generic_activity_with_arg("LLVM_lto_optimize", &*module.name);
577577
let config = cgcx.config(module.kind);
578578

579579
// Now we have one massive module inside of llmod. Time to run the

compiler/rustc_codegen_ssa/src/back/write.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1637,7 +1637,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
16371637
llvm_start_time: &mut Option<VerboseTimingGuard<'a>>,
16381638
) {
16391639
if config.time_module && llvm_start_time.is_none() {
1640-
*llvm_start_time = Some(prof.extra_verbose_generic_activity("LLVM_passes", "crate"));
1640+
*llvm_start_time = Some(prof.verbose_generic_activity("LLVM_passes"));
16411641
}
16421642
}
16431643
}

compiler/rustc_data_structures/src/profiling.rs

+27-37
Original file line numberDiff line numberDiff line change
@@ -158,30 +158,21 @@ pub struct SelfProfilerRef {
158158
// actually enabled.
159159
event_filter_mask: EventFilter,
160160

161-
// Print verbose generic activities to stdout
161+
// Print verbose generic activities to stderr?
162162
print_verbose_generic_activities: bool,
163-
164-
// Print extra verbose generic activities to stdout
165-
print_extra_verbose_generic_activities: bool,
166163
}
167164

168165
impl SelfProfilerRef {
169166
pub fn new(
170167
profiler: Option<Arc<SelfProfiler>>,
171168
print_verbose_generic_activities: bool,
172-
print_extra_verbose_generic_activities: bool,
173169
) -> SelfProfilerRef {
174170
// If there is no SelfProfiler then the filter mask is set to NONE,
175171
// ensuring that nothing ever tries to actually access it.
176172
let event_filter_mask =
177173
profiler.as_ref().map_or(EventFilter::empty(), |p| p.event_filter_mask);
178174

179-
SelfProfilerRef {
180-
profiler,
181-
event_filter_mask,
182-
print_verbose_generic_activities,
183-
print_extra_verbose_generic_activities,
184-
}
175+
SelfProfilerRef { profiler, event_filter_mask, print_verbose_generic_activities }
185176
}
186177

187178
/// This shim makes sure that calls only get executed if the filter mask
@@ -214,7 +205,7 @@ impl SelfProfilerRef {
214205
/// Start profiling a verbose generic activity. Profiling continues until the
215206
/// VerboseTimingGuard returned from this call is dropped. In addition to recording
216207
/// a measureme event, "verbose" generic activities also print a timing entry to
217-
/// stdout if the compiler is invoked with -Ztime or -Ztime-passes.
208+
/// stderr if the compiler is invoked with -Ztime-passes.
218209
pub fn verbose_generic_activity<'a>(
219210
&'a self,
220211
event_label: &'static str,
@@ -225,19 +216,16 @@ impl SelfProfilerRef {
225216
VerboseTimingGuard::start(message, self.generic_activity(event_label))
226217
}
227218

228-
/// Start profiling an extra verbose generic activity. Profiling continues until the
229-
/// VerboseTimingGuard returned from this call is dropped. In addition to recording
230-
/// a measureme event, "extra verbose" generic activities also print a timing entry to
231-
/// stdout if the compiler is invoked with -Ztime-passes.
232-
pub fn extra_verbose_generic_activity<'a, A>(
219+
/// Like `verbose_generic_activity`, but with an extra arg.
220+
pub fn verbose_generic_activity_with_arg<'a, A>(
233221
&'a self,
234222
event_label: &'static str,
235223
event_arg: A,
236224
) -> VerboseTimingGuard<'a>
237225
where
238226
A: Borrow<str> + Into<String>,
239227
{
240-
let message = if self.print_extra_verbose_generic_activities {
228+
let message = if self.print_verbose_generic_activities {
241229
Some(format!("{}({})", event_label, event_arg.borrow()))
242230
} else {
243231
None
@@ -745,27 +733,9 @@ impl Drop for VerboseTimingGuard<'_> {
745733
if let Some((start_time, start_rss, ref message)) = self.start_and_message {
746734
let end_rss = get_resident_set_size();
747735
let dur = start_time.elapsed();
748-
749-
if should_print_passes(dur, start_rss, end_rss) {
750-
print_time_passes_entry(&message, dur, start_rss, end_rss);
751-
}
752-
}
753-
}
754-
}
755-
756-
fn should_print_passes(dur: Duration, start_rss: Option<usize>, end_rss: Option<usize>) -> bool {
757-
if dur.as_millis() > 5 {
758-
return true;
759-
}
760-
761-
if let (Some(start_rss), Some(end_rss)) = (start_rss, end_rss) {
762-
let change_rss = end_rss.abs_diff(start_rss);
763-
if change_rss > 0 {
764-
return true;
736+
print_time_passes_entry(&message, dur, start_rss, end_rss);
765737
}
766738
}
767-
768-
false
769739
}
770740

771741
pub fn print_time_passes_entry(
@@ -774,6 +744,26 @@ pub fn print_time_passes_entry(
774744
start_rss: Option<usize>,
775745
end_rss: Option<usize>,
776746
) {
747+
// Print the pass if its duration is greater than 5 ms, or it changed the
748+
// measured RSS.
749+
let is_notable = || {
750+
if dur.as_millis() > 5 {
751+
return true;
752+
}
753+
754+
if let (Some(start_rss), Some(end_rss)) = (start_rss, end_rss) {
755+
let change_rss = end_rss.abs_diff(start_rss);
756+
if change_rss > 0 {
757+
return true;
758+
}
759+
}
760+
761+
false
762+
};
763+
if !is_notable() {
764+
return;
765+
}
766+
777767
let rss_to_mb = |rss| (rss as f64 / 1_000_000.0).round() as usize;
778768
let rss_change_to_mb = |rss| (rss as f64 / 1_000_000.0).round() as i128;
779769

compiler/rustc_driver/src/lib.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,13 @@ pub struct TimePassesCallbacks {
127127
}
128128

129129
impl Callbacks for TimePassesCallbacks {
130+
// JUSTIFICATION: the session doesn't exist at this point.
131+
#[allow(rustc::bad_opt_access)]
130132
fn config(&mut self, config: &mut interface::Config) {
131-
// If a --prints=... option has been given, we don't print the "total"
132-
// time because it will mess up the --prints output. See #64339.
133-
self.time_passes = config.opts.prints.is_empty() && config.opts.time_passes();
133+
// If a --print=... option has been given, we don't print the "total"
134+
// time because it will mess up the --print output. See #64339.
135+
//
136+
self.time_passes = config.opts.prints.is_empty() && config.opts.unstable_opts.time_passes;
134137
config.opts.trimmed_def_paths = TrimmedDefPaths::GoodPath;
135138
}
136139
}

compiler/rustc_error_messages/locales/en-US/lint.ftl

+2-1
Original file line numberDiff line numberDiff line change
@@ -436,4 +436,5 @@ lint_check_name_deprecated = lint name `{$lint_name}` is deprecated and does not
436436
437437
lint_opaque_hidden_inferred_bound = opaque type `{$ty}` does not satisfy its associated type bounds
438438
.specifically = this associated type bound is unsatisfied for `{$proj_ty}`
439-
.suggestion = add this bound
439+
440+
lint_opaque_hidden_inferred_bound_sugg = add this bound

compiler/rustc_hir_analysis/src/check/check.rs

+5-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::check::intrinsicck::InlineAsmCtxt;
22

33
use super::coercion::CoerceMany;
44
use super::compare_method::check_type_bounds;
5-
use super::compare_method::{compare_const_impl, compare_impl_method, compare_ty_impl};
5+
use super::compare_method::{compare_impl_method, compare_ty_impl};
66
use super::*;
77
use rustc_attr as attr;
88
use rustc_errors::{Applicability, ErrorGuaranteed, MultiSpan};
@@ -1048,14 +1048,10 @@ fn check_impl_items_against_trait<'tcx>(
10481048
let impl_item_full = tcx.hir().impl_item(impl_item.id);
10491049
match impl_item_full.kind {
10501050
hir::ImplItemKind::Const(..) => {
1051-
// Find associated const definition.
1052-
compare_const_impl(
1053-
tcx,
1054-
&ty_impl_item,
1055-
impl_item.span,
1056-
&ty_trait_item,
1057-
impl_trait_ref,
1058-
);
1051+
let _ = tcx.compare_assoc_const_impl_item_with_trait_item((
1052+
impl_item.id.def_id.def_id,
1053+
ty_impl_item.trait_item_def_id.unwrap(),
1054+
));
10591055
}
10601056
hir::ImplItemKind::Fn(..) => {
10611057
let opt_trait_span = tcx.hir().span_if_local(ty_trait_item.def_id);

compiler/rustc_hir_analysis/src/check/compare_method.rs

+30-28
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::potentially_plural_count;
22
use crate::errors::LifetimesOrBoundsMismatchOnTrait;
3-
use hir::def_id::DefId;
3+
use hir::def_id::{DefId, LocalDefId};
44
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
55
use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticId, ErrorGuaranteed};
66
use rustc_hir as hir;
@@ -1300,17 +1300,20 @@ fn compare_generic_param_kinds<'tcx>(
13001300
Ok(())
13011301
}
13021302

1303-
pub(crate) fn compare_const_impl<'tcx>(
1303+
/// Use `tcx.compare_assoc_const_impl_item_with_trait_item` instead
1304+
pub(crate) fn raw_compare_const_impl<'tcx>(
13041305
tcx: TyCtxt<'tcx>,
1305-
impl_c: &ty::AssocItem,
1306-
impl_c_span: Span,
1307-
trait_c: &ty::AssocItem,
1308-
impl_trait_ref: ty::TraitRef<'tcx>,
1309-
) {
1306+
(impl_const_item_def, trait_const_item_def): (LocalDefId, DefId),
1307+
) -> Result<(), ErrorGuaranteed> {
1308+
let impl_const_item = tcx.associated_item(impl_const_item_def);
1309+
let trait_const_item = tcx.associated_item(trait_const_item_def);
1310+
let impl_trait_ref = tcx.impl_trait_ref(impl_const_item.container_id(tcx)).unwrap();
13101311
debug!("compare_const_impl(impl_trait_ref={:?})", impl_trait_ref);
13111312

1313+
let impl_c_span = tcx.def_span(impl_const_item_def.to_def_id());
1314+
13121315
tcx.infer_ctxt().enter(|infcx| {
1313-
let param_env = tcx.param_env(impl_c.def_id);
1316+
let param_env = tcx.param_env(impl_const_item_def.to_def_id());
13141317
let ocx = ObligationCtxt::new(&infcx);
13151318

13161319
// The below is for the most part highly similar to the procedure
@@ -1322,18 +1325,18 @@ pub(crate) fn compare_const_impl<'tcx>(
13221325

13231326
// Create a parameter environment that represents the implementation's
13241327
// method.
1325-
let impl_c_hir_id = tcx.hir().local_def_id_to_hir_id(impl_c.def_id.expect_local());
1328+
let impl_c_hir_id = tcx.hir().local_def_id_to_hir_id(impl_const_item_def);
13261329

13271330
// Compute placeholder form of impl and trait const tys.
1328-
let impl_ty = tcx.type_of(impl_c.def_id);
1329-
let trait_ty = tcx.bound_type_of(trait_c.def_id).subst(tcx, trait_to_impl_substs);
1331+
let impl_ty = tcx.type_of(impl_const_item_def.to_def_id());
1332+
let trait_ty = tcx.bound_type_of(trait_const_item_def).subst(tcx, trait_to_impl_substs);
13301333
let mut cause = ObligationCause::new(
13311334
impl_c_span,
13321335
impl_c_hir_id,
13331336
ObligationCauseCode::CompareImplItemObligation {
1334-
impl_item_def_id: impl_c.def_id.expect_local(),
1335-
trait_item_def_id: trait_c.def_id,
1336-
kind: impl_c.kind,
1337+
impl_item_def_id: impl_const_item_def,
1338+
trait_item_def_id: trait_const_item_def,
1339+
kind: impl_const_item.kind,
13371340
},
13381341
);
13391342

@@ -1358,24 +1361,24 @@ pub(crate) fn compare_const_impl<'tcx>(
13581361
);
13591362

13601363
// Locate the Span containing just the type of the offending impl
1361-
match tcx.hir().expect_impl_item(impl_c.def_id.expect_local()).kind {
1364+
match tcx.hir().expect_impl_item(impl_const_item_def).kind {
13621365
ImplItemKind::Const(ref ty, _) => cause.span = ty.span,
1363-
_ => bug!("{:?} is not a impl const", impl_c),
1366+
_ => bug!("{:?} is not a impl const", impl_const_item),
13641367
}
13651368

13661369
let mut diag = struct_span_err!(
13671370
tcx.sess,
13681371
cause.span,
13691372
E0326,
13701373
"implemented const `{}` has an incompatible type for trait",
1371-
trait_c.name
1374+
trait_const_item.name
13721375
);
13731376

1374-
let trait_c_span = trait_c.def_id.as_local().map(|trait_c_def_id| {
1377+
let trait_c_span = trait_const_item_def.as_local().map(|trait_c_def_id| {
13751378
// Add a label to the Span containing just the type of the const
13761379
match tcx.hir().expect_trait_item(trait_c_def_id).kind {
13771380
TraitItemKind::Const(ref ty, _) => ty.span,
1378-
_ => bug!("{:?} is not a trait const", trait_c),
1381+
_ => bug!("{:?} is not a trait const", trait_const_item),
13791382
}
13801383
});
13811384

@@ -1391,23 +1394,22 @@ pub(crate) fn compare_const_impl<'tcx>(
13911394
false,
13921395
false,
13931396
);
1394-
diag.emit();
1395-
}
1397+
return Err(diag.emit());
1398+
};
13961399

13971400
// Check that all obligations are satisfied by the implementation's
13981401
// version.
13991402
let errors = ocx.select_all_or_error();
14001403
if !errors.is_empty() {
1401-
infcx.report_fulfillment_errors(&errors, None, false);
1402-
return;
1404+
return Err(infcx.report_fulfillment_errors(&errors, None, false));
14031405
}
14041406

1407+
// FIXME return `ErrorReported` if region obligations error?
14051408
let outlives_environment = OutlivesEnvironment::new(param_env);
1406-
infcx.check_region_obligations_and_report_errors(
1407-
impl_c.def_id.expect_local(),
1408-
&outlives_environment,
1409-
);
1410-
});
1409+
infcx
1410+
.check_region_obligations_and_report_errors(impl_const_item_def, &outlives_environment);
1411+
Ok(())
1412+
})
14111413
}
14121414

14131415
pub(crate) fn compare_ty_impl<'tcx>(

compiler/rustc_hir_analysis/src/check/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ pub fn provide(providers: &mut Providers) {
251251
check_mod_item_types,
252252
region_scope_tree,
253253
collect_trait_impl_trait_tys,
254+
compare_assoc_const_impl_item_with_trait_item: compare_method::raw_compare_const_impl,
254255
..*providers
255256
};
256257
}

compiler/rustc_interface/src/tests.rs

-1
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,6 @@ fn test_unstable_options_tracking_hash() {
692692
untracked!(span_free_formats, true);
693693
untracked!(temps_dir, Some(String::from("abc")));
694694
untracked!(threads, 99);
695-
untracked!(time, true);
696695
untracked!(time_llvm_passes, true);
697696
untracked!(time_passes, true);
698697
untracked!(trace_macros, true);

compiler/rustc_lint/src/early.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ pub fn check_ast_node<'a>(
409409
if sess.opts.unstable_opts.no_interleave_lints {
410410
for (i, pass) in passes.iter_mut().enumerate() {
411411
buffered =
412-
sess.prof.extra_verbose_generic_activity("run_lint", pass.name()).run(|| {
412+
sess.prof.verbose_generic_activity_with_arg("run_lint", pass.name()).run(|| {
413413
early_lint_node(
414414
sess,
415415
!pre_expansion && i == 0,

compiler/rustc_lint/src/late.rs

+10-7
Original file line numberDiff line numberDiff line change
@@ -425,20 +425,23 @@ fn late_lint_crate<'tcx, T: LateLintPass<'tcx>>(tcx: TyCtxt<'tcx>, builtin_lints
425425
late_lint_pass_crate(tcx, builtin_lints);
426426
} else {
427427
for pass in &mut passes {
428-
tcx.sess.prof.extra_verbose_generic_activity("run_late_lint", pass.name()).run(|| {
429-
late_lint_pass_crate(tcx, LateLintPassObjects { lints: slice::from_mut(pass) });
430-
});
428+
tcx.sess.prof.verbose_generic_activity_with_arg("run_late_lint", pass.name()).run(
429+
|| {
430+
late_lint_pass_crate(tcx, LateLintPassObjects { lints: slice::from_mut(pass) });
431+
},
432+
);
431433
}
432434

433435
let mut passes: Vec<_> =
434436
unerased_lint_store(tcx).late_module_passes.iter().map(|pass| (pass)(tcx)).collect();
435437

436438
for pass in &mut passes {
437-
tcx.sess.prof.extra_verbose_generic_activity("run_late_module_lint", pass.name()).run(
438-
|| {
439+
tcx.sess
440+
.prof
441+
.verbose_generic_activity_with_arg("run_late_module_lint", pass.name())
442+
.run(|| {
439443
late_lint_pass_crate(tcx, LateLintPassObjects { lints: slice::from_mut(pass) });
440-
},
441-
);
444+
});
442445
}
443446
}
444447
}

0 commit comments

Comments
 (0)