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 0ca3565

Browse files
committedOct 6, 2022
Auto merge of rust-lang#102741 - matthiaskrgr:rollup-63no5tz, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - rust-lang#98496 (make `compare_const_impl` a query and use it in `instance.rs`) - rust-lang#102680 (Fix overconstrained Send impls in btree internals) - rust-lang#102718 (Fix `opaque_hidden_inferred_bound` lint ICE) - rust-lang#102725 (Remove `-Ztime`) - rust-lang#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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 27 additions & 37 deletions
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

Lines changed: 6 additions & 3 deletions
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 5 additions & 9 deletions
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

Lines changed: 30 additions & 28 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 10 additions & 7 deletions
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
}

‎compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
use rustc_hir as hir;
22
use rustc_infer::infer::TyCtxtInferExt;
3-
use rustc_macros::LintDiagnostic;
4-
use rustc_middle::ty::{self, fold::BottomUpFolder, Ty, TypeFoldable};
3+
use rustc_macros::{LintDiagnostic, Subdiagnostic};
4+
use rustc_middle::ty::{
5+
self, fold::BottomUpFolder, print::TraitPredPrintModifiersAndPath, Ty, TypeFoldable,
6+
};
57
use rustc_span::Span;
68
use rustc_trait_selection::traits;
79
use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt;
@@ -117,13 +119,13 @@ impl<'tcx> LateLintPass<'tcx> for OpaqueHiddenInferredBound {
117119
)) {
118120
// If it's a trait bound and an opaque that doesn't satisfy it,
119121
// then we can emit a suggestion to add the bound.
120-
let (suggestion, suggest_span) =
122+
let add_bound =
121123
match (proj_term.kind(), assoc_pred.kind().skip_binder()) {
122-
(ty::Opaque(def_id, _), ty::PredicateKind::Trait(trait_pred)) => (
123-
format!(" + {}", trait_pred.print_modifiers_and_trait_path()),
124-
Some(cx.tcx.def_span(def_id).shrink_to_hi()),
125-
),
126-
_ => (String::new(), None),
124+
(ty::Opaque(def_id, _), ty::PredicateKind::Trait(trait_pred)) => Some(AddBound {
125+
suggest_span: cx.tcx.def_span(*def_id).shrink_to_hi(),
126+
trait_ref: trait_pred.print_modifiers_and_trait_path(),
127+
}),
128+
_ => None,
127129
};
128130
cx.emit_spanned_lint(
129131
OPAQUE_HIDDEN_INFERRED_BOUND,
@@ -132,8 +134,7 @@ impl<'tcx> LateLintPass<'tcx> for OpaqueHiddenInferredBound {
132134
ty: cx.tcx.mk_opaque(def_id, ty::InternalSubsts::identity_for_item(cx.tcx, def_id)),
133135
proj_ty: proj_term,
134136
assoc_pred_span,
135-
suggestion,
136-
suggest_span,
137+
add_bound,
137138
},
138139
);
139140
}
@@ -150,7 +151,19 @@ struct OpaqueHiddenInferredBoundLint<'tcx> {
150151
proj_ty: Ty<'tcx>,
151152
#[label(lint::specifically)]
152153
assoc_pred_span: Span,
153-
#[suggestion_verbose(applicability = "machine-applicable", code = "{suggestion}")]
154-
suggest_span: Option<Span>,
155-
suggestion: String,
154+
#[subdiagnostic]
155+
add_bound: Option<AddBound<'tcx>>,
156+
}
157+
158+
#[derive(Subdiagnostic)]
159+
#[suggestion_verbose(
160+
lint::opaque_hidden_inferred_bound_sugg,
161+
applicability = "machine-applicable",
162+
code = " + {trait_ref}"
163+
)]
164+
struct AddBound<'tcx> {
165+
#[primary_span]
166+
suggest_span: Span,
167+
#[skip_arg]
168+
trait_ref: TraitPredPrintModifiersAndPath<'tcx>,
156169
}

‎compiler/rustc_middle/src/query/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2105,4 +2105,10 @@ rustc_queries! {
21052105
query permits_zero_init(key: TyAndLayout<'tcx>) -> bool {
21062106
desc { "checking to see if {:?} permits being left zeroed", key.ty }
21072107
}
2108+
2109+
query compare_assoc_const_impl_item_with_trait_item(
2110+
key: (LocalDefId, DefId)
2111+
) -> Result<(), ErrorGuaranteed> {
2112+
desc { |tcx| "checking assoc const `{}` has the same type as trait item", tcx.def_path_str(key.0.to_def_id()) }
2113+
}
21082114
}

‎compiler/rustc_query_impl/src/on_disk_cache.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1067,7 +1067,7 @@ pub fn encode_query_results<'a, 'tcx, CTX, Q>(
10671067
let _timer = tcx
10681068
.dep_context()
10691069
.profiler()
1070-
.extra_verbose_generic_activity("encode_query_results_for", std::any::type_name::<Q>());
1070+
.verbose_generic_activity_with_arg("encode_query_results_for", std::any::type_name::<Q>());
10711071

10721072
assert!(Q::query_state(tcx).all_inactive());
10731073
let cache = Q::query_cache(tcx);

‎compiler/rustc_session/src/options.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -280,14 +280,6 @@ macro_rules! options {
280280

281281
) }
282282

283-
impl Options {
284-
// JUSTIFICATION: defn of the suggested wrapper fn
285-
#[allow(rustc::bad_opt_access)]
286-
pub fn time_passes(&self) -> bool {
287-
self.unstable_opts.time_passes || self.unstable_opts.time
288-
}
289-
}
290-
291283
impl CodegenOptions {
292284
// JUSTIFICATION: defn of the suggested wrapper fn
293285
#[allow(rustc::bad_opt_access)]
@@ -1596,9 +1588,6 @@ options! {
15961588
#[rustc_lint_opt_deny_field_access("use `Session::threads` instead of this field")]
15971589
threads: usize = (1, parse_threads, [UNTRACKED],
15981590
"use a thread pool with N threads"),
1599-
#[rustc_lint_opt_deny_field_access("use `Session::time_passes` instead of this field")]
1600-
time: bool = (false, parse_bool, [UNTRACKED],
1601-
"measure time of rustc processes (default: no)"),
16021591
#[rustc_lint_opt_deny_field_access("use `Session::time_llvm_passes` instead of this field")]
16031592
time_llvm_passes: bool = (false, parse_bool, [UNTRACKED],
16041593
"measure time of each LLVM pass (default: no)"),

‎compiler/rustc_session/src/session.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -606,10 +606,6 @@ impl Session {
606606
self.parse_sess.source_map()
607607
}
608608

609-
pub fn time_passes(&self) -> bool {
610-
self.opts.time_passes()
611-
}
612-
613609
/// Returns `true` if internal lints should be added to the lint store - i.e. if
614610
/// `-Zunstable-options` is provided and this isn't rustdoc (internal lints can trigger errors
615611
/// to be emitted under rustdoc).
@@ -927,6 +923,10 @@ impl Session {
927923
self.opts.unstable_opts.instrument_mcount
928924
}
929925

926+
pub fn time_passes(&self) -> bool {
927+
self.opts.unstable_opts.time_passes
928+
}
929+
930930
pub fn time_llvm_passes(&self) -> bool {
931931
self.opts.unstable_opts.time_llvm_passes
932932
}
@@ -1403,8 +1403,7 @@ pub fn build_session(
14031403
CguReuseTracker::new_disabled()
14041404
};
14051405

1406-
let prof =
1407-
SelfProfilerRef::new(self_profiler, sopts.time_passes(), sopts.unstable_opts.time_passes);
1406+
let prof = SelfProfilerRef::new(self_profiler, sopts.unstable_opts.time_passes);
14081407

14091408
let ctfe_backtrace = Lock::new(match env::var("RUSTC_CTFE_BACKTRACE") {
14101409
Ok(ref val) if val == "immediate" => CtfeBacktrace::Immediate,

‎compiler/rustc_ty_utils/src/instance.rs

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -186,40 +186,14 @@ fn resolve_associated_item<'tcx>(
186186
// a `trait` to an associated `const` definition in an `impl`, where
187187
// the definition in the `impl` has the wrong type (for which an
188188
// error has already been/will be emitted elsewhere).
189-
//
190-
// NB: this may be expensive, we try to skip it in all the cases where
191-
// we know the error would've been caught (e.g. in an upstream crate).
192-
//
193-
// A better approach might be to just introduce a query (returning
194-
// `Result<(), ErrorGuaranteed>`) for the check that `rustc_hir_analysis`
195-
// performs (i.e. that the definition's type in the `impl` matches
196-
// the declaration in the `trait`), so that we can cheaply check
197-
// here if it failed, instead of approximating it.
198189
if leaf_def.item.kind == ty::AssocKind::Const
199190
&& trait_item_id != leaf_def.item.def_id
200-
&& leaf_def.item.def_id.is_local()
191+
&& let Some(leaf_def_item) = leaf_def.item.def_id.as_local()
201192
{
202-
let normalized_type_of = |def_id, substs| {
203-
tcx.subst_and_normalize_erasing_regions(substs, param_env, tcx.type_of(def_id))
204-
};
205-
206-
let original_ty = normalized_type_of(trait_item_id, rcvr_substs);
207-
let resolved_ty = normalized_type_of(leaf_def.item.def_id, substs);
208-
209-
if original_ty != resolved_ty {
210-
let msg = format!(
211-
"Instance::resolve: inconsistent associated `const` type: \
212-
was `{}: {}` but resolved to `{}: {}`",
213-
tcx.def_path_str_with_substs(trait_item_id, rcvr_substs),
214-
original_ty,
215-
tcx.def_path_str_with_substs(leaf_def.item.def_id, substs),
216-
resolved_ty,
217-
);
218-
let span = tcx.def_span(leaf_def.item.def_id);
219-
let reported = tcx.sess.delay_span_bug(span, &msg);
220-
221-
return Err(reported);
222-
}
193+
tcx.compare_assoc_const_impl_item_with_trait_item((
194+
leaf_def_item,
195+
trait_item_id,
196+
))?;
223197
}
224198

225199
Some(ty::Instance::new(leaf_def.item.def_id, substs))

‎compiler/rustc_ty_utils/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
//! This API is completely unstable and subject to change.
66
77
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
8+
#![feature(let_chains)]
89
#![feature(control_flow_enum)]
910
#![feature(never_type)]
1011
#![feature(box_patterns)]

‎library/alloc/src/collections/btree/node.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,9 @@ impl<'a, K: 'a, V: 'a, Type> Clone for NodeRef<marker::Immut<'a>, K, V, Type> {
206206

207207
unsafe impl<BorrowType, K: Sync, V: Sync, Type> Sync for NodeRef<BorrowType, K, V, Type> {}
208208

209-
unsafe impl<'a, K: Sync + 'a, V: Sync + 'a, Type> Send for NodeRef<marker::Immut<'a>, K, V, Type> {}
210-
unsafe impl<'a, K: Send + 'a, V: Send + 'a, Type> Send for NodeRef<marker::Mut<'a>, K, V, Type> {}
211-
unsafe impl<'a, K: Send + 'a, V: Send + 'a, Type> Send for NodeRef<marker::ValMut<'a>, K, V, Type> {}
209+
unsafe impl<K: Sync, V: Sync, Type> Send for NodeRef<marker::Immut<'_>, K, V, Type> {}
210+
unsafe impl<K: Send, V: Send, Type> Send for NodeRef<marker::Mut<'_>, K, V, Type> {}
211+
unsafe impl<K: Send, V: Send, Type> Send for NodeRef<marker::ValMut<'_>, K, V, Type> {}
212212
unsafe impl<K: Send, V: Send, Type> Send for NodeRef<marker::Owned, K, V, Type> {}
213213
unsafe impl<K: Send, V: Send, Type> Send for NodeRef<marker::Dying, K, V, Type> {}
214214

‎library/alloc/tests/autotraits.rs

Lines changed: 293 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,293 @@
1+
fn require_sync<T: Sync>(_: T) {}
2+
fn require_send_sync<T: Send + Sync>(_: T) {}
3+
4+
struct NotSend(*const ());
5+
unsafe impl Sync for NotSend {}
6+
7+
#[test]
8+
fn test_btree_map() {
9+
// Tests of this form are prone to https://github.com/rust-lang/rust/issues/64552.
10+
//
11+
// In theory the async block's future would be Send if the value we hold
12+
// across the await point is Send, and Sync if the value we hold across the
13+
// await point is Sync.
14+
//
15+
// We test autotraits in this convoluted way, instead of a straightforward
16+
// `require_send_sync::<TypeIWantToTest>()`, because the interaction with
17+
// generators exposes some current limitations in rustc's ability to prove a
18+
// lifetime bound on the erased generator witness types. See the above link.
19+
//
20+
// A typical way this would surface in real code is:
21+
//
22+
// fn spawn<T: Future + Send>(_: T) {}
23+
//
24+
// async fn f() {
25+
// let map = BTreeMap::<u32, Box<dyn Send + Sync>>::new();
26+
// for _ in &map {
27+
// async {}.await;
28+
// }
29+
// }
30+
//
31+
// fn main() {
32+
// spawn(f());
33+
// }
34+
//
35+
// where with some unintentionally overconstrained Send impls in liballoc's
36+
// internals, the future might incorrectly not be Send even though every
37+
// single type involved in the program is Send and Sync.
38+
require_send_sync(async {
39+
let _v = None::<alloc::collections::btree_map::Iter<'_, &u32, &u32>>;
40+
async {}.await;
41+
});
42+
43+
// Testing like this would not catch all issues that the above form catches.
44+
require_send_sync(None::<alloc::collections::btree_map::Iter<'_, &u32, &u32>>);
45+
46+
require_sync(async {
47+
let _v = None::<alloc::collections::btree_map::Iter<'_, u32, NotSend>>;
48+
async {}.await;
49+
});
50+
51+
require_send_sync(async {
52+
let _v = None::<alloc::collections::btree_map::BTreeMap<&u32, &u32>>;
53+
async {}.await;
54+
});
55+
56+
require_send_sync(async {
57+
let _v = None::<
58+
alloc::collections::btree_map::DrainFilter<
59+
'_,
60+
&u32,
61+
&u32,
62+
fn(&&u32, &mut &u32) -> bool,
63+
>,
64+
>;
65+
async {}.await;
66+
});
67+
68+
require_send_sync(async {
69+
let _v = None::<alloc::collections::btree_map::Entry<'_, &u32, &u32>>;
70+
async {}.await;
71+
});
72+
73+
require_send_sync(async {
74+
let _v = None::<alloc::collections::btree_map::IntoIter<&u32, &u32>>;
75+
async {}.await;
76+
});
77+
78+
require_send_sync(async {
79+
let _v = None::<alloc::collections::btree_map::IntoKeys<&u32, &u32>>;
80+
async {}.await;
81+
});
82+
83+
require_send_sync(async {
84+
let _v = None::<alloc::collections::btree_map::IntoValues<&u32, &u32>>;
85+
async {}.await;
86+
});
87+
88+
require_send_sync(async {
89+
let _v = None::<alloc::collections::btree_map::Iter<'_, &u32, &u32>>;
90+
async {}.await;
91+
});
92+
93+
require_send_sync(async {
94+
let _v = None::<alloc::collections::btree_map::IterMut<'_, &u32, &u32>>;
95+
async {}.await;
96+
});
97+
98+
require_send_sync(async {
99+
let _v = None::<alloc::collections::btree_map::Keys<'_, &u32, &u32>>;
100+
async {}.await;
101+
});
102+
103+
require_send_sync(async {
104+
let _v = None::<alloc::collections::btree_map::OccupiedEntry<'_, &u32, &u32>>;
105+
async {}.await;
106+
});
107+
108+
require_send_sync(async {
109+
let _v = None::<alloc::collections::btree_map::OccupiedError<'_, &u32, &u32>>;
110+
async {}.await;
111+
});
112+
113+
require_send_sync(async {
114+
let _v = None::<alloc::collections::btree_map::Range<'_, &u32, &u32>>;
115+
async {}.await;
116+
});
117+
118+
require_send_sync(async {
119+
let _v = None::<alloc::collections::btree_map::RangeMut<'_, &u32, &u32>>;
120+
async {}.await;
121+
});
122+
123+
require_send_sync(async {
124+
let _v = None::<alloc::collections::btree_map::VacantEntry<'_, &u32, &u32>>;
125+
async {}.await;
126+
});
127+
128+
require_send_sync(async {
129+
let _v = None::<alloc::collections::btree_map::Values<'_, &u32, &u32>>;
130+
async {}.await;
131+
});
132+
133+
require_send_sync(async {
134+
let _v = None::<alloc::collections::btree_map::ValuesMut<'_, &u32, &u32>>;
135+
async {}.await;
136+
});
137+
}
138+
139+
#[test]
140+
fn test_btree_set() {
141+
require_send_sync(async {
142+
let _v = None::<alloc::collections::btree_set::BTreeSet<&u32>>;
143+
async {}.await;
144+
});
145+
146+
require_send_sync(async {
147+
let _v = None::<alloc::collections::btree_set::Difference<'_, &u32>>;
148+
async {}.await;
149+
});
150+
151+
require_send_sync(async {
152+
let _v = None::<alloc::collections::btree_set::DrainFilter<'_, &u32, fn(&&u32) -> bool>>;
153+
async {}.await;
154+
});
155+
156+
require_send_sync(async {
157+
let _v = None::<alloc::collections::btree_set::Intersection<'_, &u32>>;
158+
async {}.await;
159+
});
160+
161+
require_send_sync(async {
162+
let _v = None::<alloc::collections::btree_set::IntoIter<&u32>>;
163+
async {}.await;
164+
});
165+
166+
require_send_sync(async {
167+
let _v = None::<alloc::collections::btree_set::Iter<'_, &u32>>;
168+
async {}.await;
169+
});
170+
171+
require_send_sync(async {
172+
let _v = None::<alloc::collections::btree_set::Range<'_, &u32>>;
173+
async {}.await;
174+
});
175+
176+
require_send_sync(async {
177+
let _v = None::<alloc::collections::btree_set::SymmetricDifference<'_, &u32>>;
178+
async {}.await;
179+
});
180+
181+
require_send_sync(async {
182+
let _v = None::<alloc::collections::btree_set::Union<'_, &u32>>;
183+
async {}.await;
184+
});
185+
}
186+
187+
#[test]
188+
fn test_binary_heap() {
189+
require_send_sync(async {
190+
let _v = None::<alloc::collections::binary_heap::BinaryHeap<&u32>>;
191+
async {}.await;
192+
});
193+
194+
require_send_sync(async {
195+
let _v = None::<alloc::collections::binary_heap::Drain<'_, &u32>>;
196+
async {}.await;
197+
});
198+
199+
require_send_sync(async {
200+
let _v = None::<alloc::collections::binary_heap::DrainSorted<'_, &u32>>;
201+
async {}.await;
202+
});
203+
204+
require_send_sync(async {
205+
let _v = None::<alloc::collections::binary_heap::IntoIter<&u32>>;
206+
async {}.await;
207+
});
208+
209+
require_send_sync(async {
210+
let _v = None::<alloc::collections::binary_heap::IntoIterSorted<&u32>>;
211+
async {}.await;
212+
});
213+
214+
require_send_sync(async {
215+
let _v = None::<alloc::collections::binary_heap::Iter<'_, &u32>>;
216+
async {}.await;
217+
});
218+
219+
require_send_sync(async {
220+
let _v = None::<alloc::collections::binary_heap::PeekMut<'_, &u32>>;
221+
async {}.await;
222+
});
223+
}
224+
225+
#[test]
226+
fn test_linked_list() {
227+
require_send_sync(async {
228+
let _v = None::<alloc::collections::linked_list::Cursor<'_, &u32>>;
229+
async {}.await;
230+
});
231+
232+
require_send_sync(async {
233+
let _v = None::<alloc::collections::linked_list::CursorMut<'_, &u32>>;
234+
async {}.await;
235+
});
236+
237+
// FIXME
238+
/*
239+
require_send_sync(async {
240+
let _v =
241+
None::<alloc::collections::linked_list::DrainFilter<'_, &u32, fn(&mut &u32) -> bool>>;
242+
async {}.await;
243+
});
244+
*/
245+
246+
require_send_sync(async {
247+
let _v = None::<alloc::collections::linked_list::IntoIter<&u32>>;
248+
async {}.await;
249+
});
250+
251+
require_send_sync(async {
252+
let _v = None::<alloc::collections::linked_list::Iter<'_, &u32>>;
253+
async {}.await;
254+
});
255+
256+
require_send_sync(async {
257+
let _v = None::<alloc::collections::linked_list::IterMut<'_, &u32>>;
258+
async {}.await;
259+
});
260+
261+
require_send_sync(async {
262+
let _v = None::<alloc::collections::linked_list::LinkedList<&u32>>;
263+
async {}.await;
264+
});
265+
}
266+
267+
#[test]
268+
fn test_vec_deque() {
269+
require_send_sync(async {
270+
let _v = None::<alloc::collections::vec_deque::Drain<'_, &u32>>;
271+
async {}.await;
272+
});
273+
274+
require_send_sync(async {
275+
let _v = None::<alloc::collections::vec_deque::IntoIter<&u32>>;
276+
async {}.await;
277+
});
278+
279+
require_send_sync(async {
280+
let _v = None::<alloc::collections::vec_deque::Iter<'_, &u32>>;
281+
async {}.await;
282+
});
283+
284+
require_send_sync(async {
285+
let _v = None::<alloc::collections::vec_deque::IterMut<'_, &u32>>;
286+
async {}.await;
287+
});
288+
289+
require_send_sync(async {
290+
let _v = None::<alloc::collections::vec_deque::VecDeque<&u32>>;
291+
async {}.await;
292+
});
293+
}

‎library/alloc/tests/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#![feature(alloc_layout_extra)]
33
#![feature(assert_matches)]
44
#![feature(box_syntax)]
5+
#![feature(btree_drain_filter)]
56
#![feature(cow_is_borrowed)]
67
#![feature(const_box)]
78
#![feature(const_convert)]
@@ -14,6 +15,8 @@
1415
#![feature(core_intrinsics)]
1516
#![feature(drain_filter)]
1617
#![feature(exact_size_is_empty)]
18+
#![feature(linked_list_cursors)]
19+
#![feature(map_try_insert)]
1720
#![feature(new_uninit)]
1821
#![feature(pattern)]
1922
#![feature(trusted_len)]
@@ -49,6 +52,7 @@ use std::collections::hash_map::DefaultHasher;
4952
use std::hash::{Hash, Hasher};
5053

5154
mod arc;
55+
mod autotraits;
5256
mod borrow;
5357
mod boxed;
5458
mod btree_set_hash;

‎src/bootstrap/bin/rustc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ fn main() {
6767
if target == "all"
6868
|| target.into_string().unwrap().split(',').any(|c| c.trim() == crate_name)
6969
{
70-
cmd.arg("-Ztime");
70+
cmd.arg("-Ztime-passes");
7171
}
7272
}
7373
}

‎src/doc/rustc/src/command-line-arguments.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ _Note:_ The order of these lint level arguments is taken into account, see [lint
300300
## `-Z`: set unstable options
301301

302302
This flag will allow you to set unstable options of rustc. In order to set multiple options,
303-
the -Z flag can be used multiple times. For example: `rustc -Z verbose -Z time`.
303+
the -Z flag can be used multiple times. For example: `rustc -Z verbose -Z time-passes`.
304304
Specifying options with -Z is only available on nightly. To view all available options
305305
run: `rustc -Z help`.
306306

‎src/librustdoc/formats/renderer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ pub(crate) fn run_format<'tcx, T: FormatRenderer<'tcx>>(
5858

5959
let emit_crate = options.should_emit_crate();
6060
let (mut format_renderer, krate) = prof
61-
.extra_verbose_generic_activity("create_renderer", T::descr())
61+
.verbose_generic_activity_with_arg("create_renderer", T::descr())
6262
.run(|| T::init(krate, options, cache, tcx))?;
6363

6464
if !emit_crate {
@@ -92,6 +92,6 @@ pub(crate) fn run_format<'tcx, T: FormatRenderer<'tcx>>(
9292
.run(|| cx.item(item))?;
9393
}
9494
}
95-
prof.extra_verbose_generic_activity("renderer_after_krate", T::descr())
95+
prof.verbose_generic_activity_with_arg("renderer_after_krate", T::descr())
9696
.run(|| format_renderer.after_krate())
9797
}

‎src/librustdoc/html/static/css/rustdoc.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -914,6 +914,7 @@ so that we can apply CSS-filters to change the arrow color in themes */
914914
font-size: 1rem;
915915
width: 100%;
916916
background-color: var(--button-background-color);
917+
color: var(--search-color);
917918
}
918919
.search-input:focus {
919920
border-color: var(--search-input-focused-border-color);

‎src/librustdoc/html/static/css/themes/ayu.css

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Original by Dempfi (https://github.com/dempfi/ayu)
4040
--search-result-link-focus-background-color: #3c3c3c;
4141
--stab-background-color: #314559;
4242
--stab-code-color: #e6e1cf;
43+
--search-color: #fff;
4344
}
4445

4546
.slider {
@@ -149,10 +150,6 @@ details.rustdoc-toggle > summary::before {
149150
filter: invert(98%) sepia(12%) saturate(81%) hue-rotate(343deg) brightness(113%) contrast(76%);
150151
}
151152

152-
.search-input {
153-
color: #fff;
154-
}
155-
156153
.module-item .stab,
157154
.import-item .stab {
158155
color: #000;

‎src/librustdoc/html/static/css/themes/dark.css

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
--search-result-link-focus-background-color: #616161;
3636
--stab-background-color: #314559;
3737
--stab-code-color: #e6e1cf;
38+
--search-color: #111;
3839
}
3940

4041
.slider {
@@ -72,10 +73,6 @@ details.rustdoc-toggle > summary::before {
7273
filter: invert(100%);
7374
}
7475

75-
.search-input {
76-
color: #111;
77-
}
78-
7976
#crate-search-div::after {
8077
/* match border-color; uses https://codepen.io/sosuke/pen/Pjoqqp */
8178
filter: invert(94%) sepia(0%) saturate(721%) hue-rotate(255deg) brightness(90%) contrast(90%);

‎src/librustdoc/html/static/css/themes/light.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
--search-result-link-focus-background-color: #ccc;
3636
--stab-background-color: #fff5d6;
3737
--stab-code-color: #000;
38+
--search-color: #000;
3839
}
3940

4041
.slider {

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@
170170
-Z thinlto=val -- enable ThinLTO when possible
171171
-Z thir-unsafeck=val -- use the THIR unsafety checker (default: no)
172172
-Z threads=val -- use a thread pool with N threads
173-
-Z time=val -- measure time of rustc processes (default: no)
174173
-Z time-llvm-passes=val -- measure time of each LLVM pass (default: no)
175174
-Z time-passes=val -- measure time of each rustc pass (default: no)
176175
-Z tls-model=val -- choose the TLS model to use (`rustc --print tls-models` for details)

‎src/test/ui/associated-consts/associated-const-impl-wrong-lifetime.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0308]: const not compatible with trait
22
--> $DIR/associated-const-impl-wrong-lifetime.rs:7:5
33
|
44
LL | const NAME: &'a str = "unit";
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch
5+
| ^^^^^^^^^^^^^^^^^^^ lifetime mismatch
66
|
77
= note: expected reference `&'static str`
88
found reference `&'a str`
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// run-pass
2+
#![feature(generic_const_exprs)]
3+
#![allow(incomplete_features)]
4+
5+
trait MyTrait {
6+
type ArrayType;
7+
const SIZE: usize;
8+
const ARRAY: Self::ArrayType;
9+
}
10+
impl MyTrait for () {
11+
type ArrayType = [u8; Self::SIZE];
12+
const SIZE: usize = 4;
13+
const ARRAY: [u8; Self::SIZE] = [1, 2, 3, 4];
14+
}
15+
16+
fn main() {
17+
let _ = <() as MyTrait>::ARRAY;
18+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// run-pass
2+
trait Trait {
3+
const ASSOC: fn(&'static u32);
4+
}
5+
impl Trait for () {
6+
const ASSOC: for<'a> fn(&'a u32) = |_| ();
7+
}
8+
9+
fn main() {
10+
let _ = <() as Trait>::ASSOC;
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// run-pass
2+
trait Trait {
3+
const ASSOC: for<'a, 'b> fn(&'a u32, &'b u32);
4+
}
5+
impl Trait for () {
6+
const ASSOC: for<'a> fn(&'a u32, &'a u32) = |_, _| ();
7+
}
8+
9+
fn main() {
10+
let _ = <() as Trait>::ASSOC;
11+
}

‎src/test/ui/lint/issue-102705.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// check-pass
2+
3+
#![allow(opaque_hidden_inferred_bound)]
4+
#![allow(dead_code)]
5+
6+
trait Duh {}
7+
8+
impl Duh for i32 {}
9+
10+
trait Trait {
11+
type Assoc: Duh;
12+
}
13+
14+
impl<R: Duh, F: FnMut() -> R> Trait for F {
15+
type Assoc = R;
16+
}
17+
18+
fn foo() -> impl Trait<Assoc = impl Send> {
19+
|| 42
20+
}
21+
22+
fn main() {}

‎src/test/ui/nll/trait-associated-constant.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0308]: const not compatible with trait
22
--> $DIR/trait-associated-constant.rs:21:5
33
|
44
LL | const AC: Option<&'c str> = None;
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch
66
|
77
= note: expected enum `Option<&'b str>`
88
found enum `Option<&'c str>`

0 commit comments

Comments
 (0)
This repository has been archived.