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

+1-2
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

+17-8
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

+2
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

+3
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

+14-15
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

+2-2
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

+2-2
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

+10
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

+3-2
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
)

src/librustc_mir/interpret/snapshot.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ impl<'a, 'mir, 'tcx> Eq for EvalSnapshot<'a, 'mir, 'tcx>
431431
impl<'a, 'mir, 'tcx> PartialEq for EvalSnapshot<'a, 'mir, 'tcx>
432432
{
433433
fn eq(&self, other: &Self) -> bool {
434-
// FIXME: This looks to be a *ridicolously expensive* comparison operation.
434+
// FIXME: This looks to be a *ridiculously expensive* comparison operation.
435435
// Doesn't this make tons of copies? Either `snapshot` is very badly named,
436436
// or it does!
437437
self.snapshot() == other.snapshot()

src/libsyntax/parse/parser.rs

+16
Original file line numberDiff line numberDiff line change
@@ -6722,6 +6722,22 @@ impl<'a> Parser<'a> {
67226722
self.expect(&token::OpenDelim(token::Brace))?;
67236723
let mut trait_items = vec![];
67246724
while !self.eat(&token::CloseDelim(token::Brace)) {
6725+
if let token::DocComment(_) = self.token {
6726+
if self.look_ahead(1,
6727+
|tok| tok == &token::Token::CloseDelim(token::Brace)) {
6728+
let mut err = self.diagnostic().struct_span_err_with_code(
6729+
self.span,
6730+
"found a documentation comment that doesn't document anything",
6731+
DiagnosticId::Error("E0584".into()),
6732+
);
6733+
err.help("doc comments must come before what they document, maybe a \
6734+
comment was intended with `//`?",
6735+
);
6736+
err.emit();
6737+
self.bump();
6738+
continue;
6739+
}
6740+
}
67256741
let mut at_end = false;
67266742
match self.parse_trait_item(&mut at_end) {
67276743
Ok(item) => trait_items.push(item),

src/test/ui/impl-trait/must_outlive_least_region_or_bound.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::fmt::Debug;
22

33
fn elided(x: &i32) -> impl Copy { x }
4-
//~^ ERROR explicit lifetime required in the type of `x` [E0621]
4+
//~^ ERROR cannot infer an appropriate lifetime
55

66
fn explicit<'a>(x: &'a i32) -> impl Copy { x }
77
//~^ ERROR cannot infer an appropriate lifetime

src/test/ui/impl-trait/must_outlive_least_region_or_bound.stderr

+16-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
1-
error[E0621]: explicit lifetime required in the type of `x`
2-
--> $DIR/must_outlive_least_region_or_bound.rs:3:23
1+
error: cannot infer an appropriate lifetime
2+
--> $DIR/must_outlive_least_region_or_bound.rs:3:35
33
|
44
LL | fn elided(x: &i32) -> impl Copy { x }
5-
| ---- ^^^^^^^^^ lifetime `'static` required
6-
| |
7-
| help: add explicit lifetime `'static` to the type of `x`: `&'static i32`
5+
| --------- ^ ...but this borrow...
6+
| |
7+
| this return type evaluates to the `'static` lifetime...
8+
|
9+
note: ...can't outlive the anonymous lifetime #1 defined on the function body at 3:1
10+
--> $DIR/must_outlive_least_region_or_bound.rs:3:1
11+
|
12+
LL | fn elided(x: &i32) -> impl Copy { x }
13+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
14+
help: you can add a constraint to the return type to make it last less than `'static` and match the anonymous lifetime #1 defined on the function body at 3:1
15+
|
16+
LL | fn elided(x: &i32) -> impl Copy + '_ { x }
17+
| ^^^^^^^^^^^^^^
818

919
error: cannot infer an appropriate lifetime
1020
--> $DIR/must_outlive_least_region_or_bound.rs:6:44
@@ -67,5 +77,5 @@ LL | fn ty_param_wont_outlive_static<T:Debug>(x: T) -> impl Debug + 'static {
6777

6878
error: aborting due to 5 previous errors
6979

70-
Some errors occurred: E0310, E0621, E0623.
80+
Some errors occurred: E0310, E0623.
7181
For more information about an error, try `rustc --explain E0310`.

src/test/ui/nll/ty-outlives/impl-trait-captures.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ trait Foo<'a> {
88
impl<'a, T> Foo<'a> for T { }
99

1010
fn foo<'a, T>(x: &T) -> impl Foo<'a> {
11+
//~^ ERROR explicit lifetime required in the type of `x` [E0621]
1112
x
12-
//~^ ERROR explicit lifetime required in the type of `x` [E0621]
1313
}
1414

1515
fn main() {}

src/test/ui/nll/ty-outlives/impl-trait-captures.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error[E0621]: explicit lifetime required in the type of `x`
2-
--> $DIR/impl-trait-captures.rs:11:5
2+
--> $DIR/impl-trait-captures.rs:10:25
33
|
4-
LL | x
5-
| ^ lifetime `ReEarlyBound(0, 'a)` required
4+
LL | fn foo<'a, T>(x: &T) -> impl Foo<'a> {
5+
| ^^^^^^^^^^^^ lifetime `ReEarlyBound(0, 'a)` required
66
help: add explicit lifetime `ReEarlyBound(0, 'a)` to the type of `x`
77
|
88
LL | fn foo<'a, T>(x: &ReEarlyBound(0, 'a) T) -> impl Foo<'a> {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
trait User{
2+
fn test();
3+
/// empty doc
4+
//~^ ERROR found a documentation comment that doesn't document anything
5+
}
6+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0584]: found a documentation comment that doesn't document anything
2+
--> $DIR/doc-inside-trait-item.rs:3:5
3+
|
4+
LL | /// empty doc
5+
| ^^^^^^^^^^^^^
6+
|
7+
= help: doc comments must come before what they document, maybe a comment was intended with `//`?
8+
9+
error: aborting due to previous error
10+
11+
For more information about this error, try `rustc --explain E0584`.

src/tools/cargotest/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const TEST_REPOS: &'static [Test] = &[
3030
},
3131
Test {
3232
name: "tokei",
33-
repo: "https://github.com/Aaronepower/tokei",
33+
repo: "https://github.com/XAMPPRocky/tokei",
3434
sha: "5e11c4852fe4aa086b0e4fe5885822fbe57ba928",
3535
lock: None,
3636
packages: &[],

0 commit comments

Comments
 (0)