Skip to content

Commit f694222

Browse files
committed
Auto merge of #59606 - Centril:rollup, r=Centril
Rollup of 7 pull requests Successful merges: - #58507 (Add a -Z time option which prints only passes which runs once) - #58919 (Suggest using anonymous lifetime in `impl Trait` return) - #59041 (fixes #56766) - #59586 (Fixed URL in cargotest::TEST_REPOS) - #59595 (Update rustc-guide submodule) - #59601 (Fix small typo) - #59603 (stabilize ptr::hash) Failed merges: r? @ghost
2 parents 9ebf478 + e9b9f33 commit f694222

File tree

19 files changed

+111
-45
lines changed

19 files changed

+111
-45
lines changed

src/doc/rustc-guide

src/libcore/ptr.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2561,7 +2561,6 @@ pub fn eq<T: ?Sized>(a: *const T, b: *const T) -> bool {
25612561
/// # Examples
25622562
///
25632563
/// ```
2564-
/// #![feature(ptr_hash)]
25652564
/// use std::collections::hash_map::DefaultHasher;
25662565
/// use std::hash::{Hash, Hasher};
25672566
/// use std::ptr;
@@ -2579,7 +2578,7 @@ pub fn eq<T: ?Sized>(a: *const T, b: *const T) -> bool {
25792578
///
25802579
/// assert_eq!(actual, expected);
25812580
/// ```
2582-
#[unstable(feature = "ptr_hash", reason = "newly added", issue = "56286")]
2581+
#[stable(feature = "ptr_hash", since = "1.35.0")]
25832582
pub fn hash<T: ?Sized, S: hash::Hasher>(hashee: *const T, into: &mut S) {
25842583
use hash::Hash;
25852584
hashee.hash(into);

src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! Error Reporting for Anonymous Region Lifetime Errors
22
//! where one region is named and the other is anonymous.
33
use crate::infer::error_reporting::nice_region_error::NiceRegionError;
4+
use crate::hir::{FunctionRetTy, TyKind};
45
use crate::ty;
56
use errors::{Applicability, DiagnosticBuilder};
67

@@ -11,9 +12,10 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> {
1112
let (span, sub, sup) = self.get_regions();
1213

1314
debug!(
14-
"try_report_named_anon_conflict(sub={:?}, sup={:?})",
15+
"try_report_named_anon_conflict(sub={:?}, sup={:?}, error={:?})",
1516
sub,
16-
sup
17+
sup,
18+
self.error,
1719
);
1820

1921
// Determine whether the sub and sup consist of one named region ('a)
@@ -84,6 +86,13 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> {
8486
{
8587
return None;
8688
}
89+
if let FunctionRetTy::Return(ty) = &fndecl.output {
90+
if let (TyKind::Def(_, _), ty::ReStatic) = (&ty.node, sub) {
91+
// This is an impl Trait return that evaluates de need of 'static.
92+
// We handle this case better in `static_impl_trait`.
93+
return None;
94+
}
95+
}
8796
}
8897

8998
let (error_var, span_label_var) = if let Some(simple_ident) = arg.pat.simple_ident() {
@@ -103,13 +112,13 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> {
103112
error_var
104113
);
105114

115+
diag.span_label(span, format!("lifetime `{}` required", named));
106116
diag.span_suggestion(
107-
new_ty_span,
108-
&format!("add explicit lifetime `{}` to {}", named, span_label_var),
109-
new_ty.to_string(),
110-
Applicability::Unspecified,
111-
)
112-
.span_label(span, format!("lifetime `{}` required", named));
117+
new_ty_span,
118+
&format!("add explicit lifetime `{}` to {}", named, span_label_var),
119+
new_ty.to_string(),
120+
Applicability::Unspecified,
121+
);
113122

114123
Some(diag)
115124
}

src/librustc/session/config.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,6 +1200,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
12001200
"when using two-phase-borrows, allow two phases even for non-autoref `&mut` borrows"),
12011201
time_passes: bool = (false, parse_bool, [UNTRACKED],
12021202
"measure time of each rustc pass"),
1203+
time: bool = (false, parse_bool, [UNTRACKED],
1204+
"measure time of rustc processes"),
12031205
count_llvm_insns: bool = (false, parse_bool,
12041206
[UNTRACKED_WITH_WARNING(true,
12051207
"The output generated by `-Z count_llvm_insns` might not be reliable \

src/librustc/session/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,9 @@ impl Session {
504504
self.opts.debugging_opts.verbose
505505
}
506506
pub fn time_passes(&self) -> bool {
507+
self.opts.debugging_opts.time_passes || self.opts.debugging_opts.time
508+
}
509+
pub fn time_extended(&self) -> bool {
507510
self.opts.debugging_opts.time_passes
508511
}
509512
pub fn profile_queries(&self) -> bool {

src/librustc/ty/query/on_disk_cache.rs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::session::{CrateDisambiguator, Session};
1212
use crate::ty;
1313
use crate::ty::codec::{self as ty_codec, TyDecoder, TyEncoder};
1414
use crate::ty::context::TyCtxt;
15-
use crate::util::common::time;
15+
use crate::util::common::{time, time_ext};
1616

1717
use errors::Diagnostic;
1818
use rustc_data_structures::fx::FxHashMap;
@@ -1080,23 +1080,22 @@ fn encode_query_results<'enc, 'a, 'tcx, Q, E>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
10801080
let desc = &format!("encode_query_results for {}",
10811081
unsafe { ::std::intrinsics::type_name::<Q>() });
10821082

1083-
time(tcx.sess, desc, || {
1083+
time_ext(tcx.sess.time_extended(), Some(tcx.sess), desc, || {
1084+
let map = Q::query_cache(tcx).borrow();
1085+
assert!(map.active.is_empty());
1086+
for (key, entry) in map.results.iter() {
1087+
if Q::cache_on_disk(tcx, key.clone()) {
1088+
let dep_node = SerializedDepNodeIndex::new(entry.index.index());
10841089

1085-
let map = Q::query_cache(tcx).borrow();
1086-
assert!(map.active.is_empty());
1087-
for (key, entry) in map.results.iter() {
1088-
if Q::cache_on_disk(tcx, key.clone()) {
1089-
let dep_node = SerializedDepNodeIndex::new(entry.index.index());
1090+
// Record position of the cache entry
1091+
query_result_index.push((dep_node, AbsoluteBytePos::new(encoder.position())));
10901092

1091-
// Record position of the cache entry
1092-
query_result_index.push((dep_node, AbsoluteBytePos::new(encoder.position())));
1093-
1094-
// Encode the type check tables with the SerializedDepNodeIndex
1095-
// as tag.
1096-
encoder.encode_tagged(dep_node, &entry.value)?;
1093+
// Encode the type check tables with the SerializedDepNodeIndex
1094+
// as tag.
1095+
encoder.encode_tagged(dep_node, &entry.value)?;
1096+
}
10971097
}
1098-
}
10991098

1100-
Ok(())
1099+
Ok(())
11011100
})
11021101
}

src/librustc_codegen_llvm/back/link.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use rustc::session::Session;
1818
use rustc::middle::cstore::{NativeLibrary, NativeLibraryKind};
1919
use rustc::middle::dependency_format::Linkage;
2020
use rustc_codegen_ssa::CodegenResults;
21-
use rustc::util::common::time;
21+
use rustc::util::common::{time, time_ext};
2222
use rustc_fs_util::fix_windows_verbatim_for_gcc;
2323
use rustc::hir::def_id::CrateNum;
2424
use tempfile::{Builder as TempFileBuilder, TempDir};
@@ -1319,7 +1319,7 @@ fn add_upstream_rust_crates(cmd: &mut dyn Linker,
13191319
let name = cratepath.file_name().unwrap().to_str().unwrap();
13201320
let name = &name[3..name.len() - 5]; // chop off lib/.rlib
13211321

1322-
time(sess, &format!("altering {}.rlib", name), || {
1322+
time_ext(sess.time_extended(), Some(sess), &format!("altering {}.rlib", name), || {
13231323
let cfg = archive_config(sess, &dst, Some(cratepath));
13241324
let mut archive = ArchiveBuilder::new(cfg);
13251325
archive.update_symbols();

src/librustc_codegen_ssa/back/write.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ impl ModuleConfig {
125125
self.verify_llvm_ir = sess.verify_llvm_ir();
126126
self.no_prepopulate_passes = sess.opts.cg.no_prepopulate_passes;
127127
self.no_builtins = no_builtins || sess.target.target.options.no_builtins;
128-
self.time_passes = sess.time_passes();
128+
self.time_passes = sess.time_extended();
129129
self.inline_threshold = sess.opts.cg.inline_threshold;
130130
self.obj_is_bitcode = sess.target.target.options.obj_is_bitcode ||
131131
sess.opts.cg.linker_plugin_lto.enabled();
@@ -1091,7 +1091,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
10911091
fewer_names: sess.fewer_names(),
10921092
save_temps: sess.opts.cg.save_temps,
10931093
opts: Arc::new(sess.opts.clone()),
1094-
time_passes: sess.time_passes(),
1094+
time_passes: sess.time_extended(),
10951095
profiler: sess.self_profiling.clone(),
10961096
exported_symbols,
10971097
plugin_passes: sess.plugin_llvm_passes.borrow().clone(),

src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,15 @@ impl<'tcx> RegionInferenceContext<'tcx> {
132132
}
133133
});
134134
if let Some(i) = best_choice {
135+
if let Some(next) = categorized_path.get(i + 1) {
136+
if categorized_path[i].0 == ConstraintCategory::Return
137+
&& next.0 == ConstraintCategory::OpaqueType
138+
{
139+
// The return expression is being influenced by the return type being
140+
// impl Trait, point at the return type and not the return expr.
141+
return *next;
142+
}
143+
}
135144
return categorized_path[i];
136145
}
137146

@@ -240,6 +249,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
240249
self.provides_universal_region(r, fr, outlived_fr)
241250
});
242251

252+
debug!("report_error: category={:?} {:?}", category, span);
243253
// Check if we can use one of the "nice region errors".
244254
if let (Some(f), Some(o)) = (self.to_error_region(fr), self.to_error_region(outlived_fr)) {
245255
let tables = infcx.tcx.typeck_tables_of(mir_def_id);

src/librustc_mir/borrow_check/nll/region_infer/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,9 @@ impl<'tcx> RegionInferenceContext<'tcx> {
403403
mir_def_id: DefId,
404404
errors_buffer: &mut Vec<Diagnostic>,
405405
) -> Option<ClosureRegionRequirements<'gcx>> {
406-
common::time(
407-
infcx.tcx.sess,
406+
common::time_ext(
407+
infcx.tcx.sess.time_extended(),
408+
Some(infcx.tcx.sess),
408409
&format!("solve_nll_region_constraints({:?})", mir_def_id),
409410
|| self.solve_inner(infcx, mir, mir_def_id, errors_buffer),
410411
)

0 commit comments

Comments
 (0)