Skip to content

Commit

Permalink
Auto merge of #59606 - Centril:rollup, r=Centril
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Apr 1, 2019
2 parents 9ebf478 + e9b9f33 commit f694222
Show file tree
Hide file tree
Showing 19 changed files with 111 additions and 45 deletions.
2 changes: 1 addition & 1 deletion src/doc/rustc-guide
3 changes: 1 addition & 2 deletions src/libcore/ptr.rs
Expand Up @@ -2561,7 +2561,6 @@ pub fn eq<T: ?Sized>(a: *const T, b: *const T) -> bool {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(ptr_hash)]
/// use std::collections::hash_map::DefaultHasher; /// use std::collections::hash_map::DefaultHasher;
/// use std::hash::{Hash, Hasher}; /// use std::hash::{Hash, Hasher};
/// use std::ptr; /// use std::ptr;
Expand All @@ -2579,7 +2578,7 @@ pub fn eq<T: ?Sized>(a: *const T, b: *const T) -> bool {
/// ///
/// assert_eq!(actual, expected); /// assert_eq!(actual, expected);
/// ``` /// ```
#[unstable(feature = "ptr_hash", reason = "newly added", issue = "56286")] #[stable(feature = "ptr_hash", since = "1.35.0")]
pub fn hash<T: ?Sized, S: hash::Hasher>(hashee: *const T, into: &mut S) { pub fn hash<T: ?Sized, S: hash::Hasher>(hashee: *const T, into: &mut S) {
use hash::Hash; use hash::Hash;
hashee.hash(into); hashee.hash(into);
Expand Down
@@ -1,6 +1,7 @@
//! Error Reporting for Anonymous Region Lifetime Errors //! Error Reporting for Anonymous Region Lifetime Errors
//! where one region is named and the other is anonymous. //! where one region is named and the other is anonymous.
use crate::infer::error_reporting::nice_region_error::NiceRegionError; use crate::infer::error_reporting::nice_region_error::NiceRegionError;
use crate::hir::{FunctionRetTy, TyKind};
use crate::ty; use crate::ty;
use errors::{Applicability, DiagnosticBuilder}; use errors::{Applicability, DiagnosticBuilder};


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


debug!( debug!(
"try_report_named_anon_conflict(sub={:?}, sup={:?})", "try_report_named_anon_conflict(sub={:?}, sup={:?}, error={:?})",
sub, sub,
sup sup,
self.error,
); );


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


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


diag.span_label(span, format!("lifetime `{}` required", named));
diag.span_suggestion( diag.span_suggestion(
new_ty_span, new_ty_span,
&format!("add explicit lifetime `{}` to {}", named, span_label_var), &format!("add explicit lifetime `{}` to {}", named, span_label_var),
new_ty.to_string(), new_ty.to_string(),
Applicability::Unspecified, Applicability::Unspecified,
) );
.span_label(span, format!("lifetime `{}` required", named));


Some(diag) Some(diag)
} }
Expand Down
2 changes: 2 additions & 0 deletions src/librustc/session/config.rs
Expand Up @@ -1200,6 +1200,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
"when using two-phase-borrows, allow two phases even for non-autoref `&mut` borrows"), "when using two-phase-borrows, allow two phases even for non-autoref `&mut` borrows"),
time_passes: bool = (false, parse_bool, [UNTRACKED], time_passes: bool = (false, parse_bool, [UNTRACKED],
"measure time of each rustc pass"), "measure time of each rustc pass"),
time: bool = (false, parse_bool, [UNTRACKED],
"measure time of rustc processes"),
count_llvm_insns: bool = (false, parse_bool, count_llvm_insns: bool = (false, parse_bool,
[UNTRACKED_WITH_WARNING(true, [UNTRACKED_WITH_WARNING(true,
"The output generated by `-Z count_llvm_insns` might not be reliable \ "The output generated by `-Z count_llvm_insns` might not be reliable \
Expand Down
3 changes: 3 additions & 0 deletions src/librustc/session/mod.rs
Expand Up @@ -504,6 +504,9 @@ impl Session {
self.opts.debugging_opts.verbose self.opts.debugging_opts.verbose
} }
pub fn time_passes(&self) -> bool { pub fn time_passes(&self) -> bool {
self.opts.debugging_opts.time_passes || self.opts.debugging_opts.time
}
pub fn time_extended(&self) -> bool {
self.opts.debugging_opts.time_passes self.opts.debugging_opts.time_passes
} }
pub fn profile_queries(&self) -> bool { pub fn profile_queries(&self) -> bool {
Expand Down
29 changes: 14 additions & 15 deletions src/librustc/ty/query/on_disk_cache.rs
Expand Up @@ -12,7 +12,7 @@ use crate::session::{CrateDisambiguator, Session};
use crate::ty; use crate::ty;
use crate::ty::codec::{self as ty_codec, TyDecoder, TyEncoder}; use crate::ty::codec::{self as ty_codec, TyDecoder, TyEncoder};
use crate::ty::context::TyCtxt; use crate::ty::context::TyCtxt;
use crate::util::common::time; use crate::util::common::{time, time_ext};


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


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


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


// Record position of the cache entry // Encode the type check tables with the SerializedDepNodeIndex
query_result_index.push((dep_node, AbsoluteBytePos::new(encoder.position()))); // as tag.

encoder.encode_tagged(dep_node, &entry.value)?;
// Encode the type check tables with the SerializedDepNodeIndex }
// as tag.
encoder.encode_tagged(dep_node, &entry.value)?;
} }
}


Ok(()) Ok(())
}) })
} }
4 changes: 2 additions & 2 deletions src/librustc_codegen_llvm/back/link.rs
Expand Up @@ -18,7 +18,7 @@ use rustc::session::Session;
use rustc::middle::cstore::{NativeLibrary, NativeLibraryKind}; use rustc::middle::cstore::{NativeLibrary, NativeLibraryKind};
use rustc::middle::dependency_format::Linkage; use rustc::middle::dependency_format::Linkage;
use rustc_codegen_ssa::CodegenResults; use rustc_codegen_ssa::CodegenResults;
use rustc::util::common::time; use rustc::util::common::{time, time_ext};
use rustc_fs_util::fix_windows_verbatim_for_gcc; use rustc_fs_util::fix_windows_verbatim_for_gcc;
use rustc::hir::def_id::CrateNum; use rustc::hir::def_id::CrateNum;
use tempfile::{Builder as TempFileBuilder, TempDir}; use tempfile::{Builder as TempFileBuilder, TempDir};
Expand Down Expand Up @@ -1319,7 +1319,7 @@ fn add_upstream_rust_crates(cmd: &mut dyn Linker,
let name = cratepath.file_name().unwrap().to_str().unwrap(); let name = cratepath.file_name().unwrap().to_str().unwrap();
let name = &name[3..name.len() - 5]; // chop off lib/.rlib let name = &name[3..name.len() - 5]; // chop off lib/.rlib


time(sess, &format!("altering {}.rlib", name), || { time_ext(sess.time_extended(), Some(sess), &format!("altering {}.rlib", name), || {
let cfg = archive_config(sess, &dst, Some(cratepath)); let cfg = archive_config(sess, &dst, Some(cratepath));
let mut archive = ArchiveBuilder::new(cfg); let mut archive = ArchiveBuilder::new(cfg);
archive.update_symbols(); archive.update_symbols();
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_codegen_ssa/back/write.rs
Expand Up @@ -125,7 +125,7 @@ impl ModuleConfig {
self.verify_llvm_ir = sess.verify_llvm_ir(); self.verify_llvm_ir = sess.verify_llvm_ir();
self.no_prepopulate_passes = sess.opts.cg.no_prepopulate_passes; self.no_prepopulate_passes = sess.opts.cg.no_prepopulate_passes;
self.no_builtins = no_builtins || sess.target.target.options.no_builtins; self.no_builtins = no_builtins || sess.target.target.options.no_builtins;
self.time_passes = sess.time_passes(); self.time_passes = sess.time_extended();
self.inline_threshold = sess.opts.cg.inline_threshold; self.inline_threshold = sess.opts.cg.inline_threshold;
self.obj_is_bitcode = sess.target.target.options.obj_is_bitcode || self.obj_is_bitcode = sess.target.target.options.obj_is_bitcode ||
sess.opts.cg.linker_plugin_lto.enabled(); sess.opts.cg.linker_plugin_lto.enabled();
Expand Down Expand Up @@ -1091,7 +1091,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
fewer_names: sess.fewer_names(), fewer_names: sess.fewer_names(),
save_temps: sess.opts.cg.save_temps, save_temps: sess.opts.cg.save_temps,
opts: Arc::new(sess.opts.clone()), opts: Arc::new(sess.opts.clone()),
time_passes: sess.time_passes(), time_passes: sess.time_extended(),
profiler: sess.self_profiling.clone(), profiler: sess.self_profiling.clone(),
exported_symbols, exported_symbols,
plugin_passes: sess.plugin_llvm_passes.borrow().clone(), plugin_passes: sess.plugin_llvm_passes.borrow().clone(),
Expand Down
Expand Up @@ -132,6 +132,15 @@ impl<'tcx> RegionInferenceContext<'tcx> {
} }
}); });
if let Some(i) = best_choice { if let Some(i) = best_choice {
if let Some(next) = categorized_path.get(i + 1) {
if categorized_path[i].0 == ConstraintCategory::Return
&& next.0 == ConstraintCategory::OpaqueType
{
// The return expression is being influenced by the return type being
// impl Trait, point at the return type and not the return expr.
return *next;
}
}
return categorized_path[i]; return categorized_path[i];
} }


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


debug!("report_error: category={:?} {:?}", category, span);
// Check if we can use one of the "nice region errors". // Check if we can use one of the "nice region errors".
if let (Some(f), Some(o)) = (self.to_error_region(fr), self.to_error_region(outlived_fr)) { if let (Some(f), Some(o)) = (self.to_error_region(fr), self.to_error_region(outlived_fr)) {
let tables = infcx.tcx.typeck_tables_of(mir_def_id); let tables = infcx.tcx.typeck_tables_of(mir_def_id);
Expand Down
5 changes: 3 additions & 2 deletions src/librustc_mir/borrow_check/nll/region_infer/mod.rs
Expand Up @@ -403,8 +403,9 @@ impl<'tcx> RegionInferenceContext<'tcx> {
mir_def_id: DefId, mir_def_id: DefId,
errors_buffer: &mut Vec<Diagnostic>, errors_buffer: &mut Vec<Diagnostic>,
) -> Option<ClosureRegionRequirements<'gcx>> { ) -> Option<ClosureRegionRequirements<'gcx>> {
common::time( common::time_ext(
infcx.tcx.sess, infcx.tcx.sess.time_extended(),
Some(infcx.tcx.sess),
&format!("solve_nll_region_constraints({:?})", mir_def_id), &format!("solve_nll_region_constraints({:?})", mir_def_id),
|| self.solve_inner(infcx, mir, mir_def_id, errors_buffer), || self.solve_inner(infcx, mir, mir_def_id, errors_buffer),
) )
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/interpret/snapshot.rs
Expand Up @@ -431,7 +431,7 @@ impl<'a, 'mir, 'tcx> Eq for EvalSnapshot<'a, 'mir, 'tcx>
impl<'a, 'mir, 'tcx> PartialEq for EvalSnapshot<'a, 'mir, 'tcx> impl<'a, 'mir, 'tcx> PartialEq for EvalSnapshot<'a, 'mir, 'tcx>
{ {
fn eq(&self, other: &Self) -> bool { fn eq(&self, other: &Self) -> bool {
// FIXME: This looks to be a *ridicolously expensive* comparison operation. // FIXME: This looks to be a *ridiculously expensive* comparison operation.
// Doesn't this make tons of copies? Either `snapshot` is very badly named, // Doesn't this make tons of copies? Either `snapshot` is very badly named,
// or it does! // or it does!
self.snapshot() == other.snapshot() self.snapshot() == other.snapshot()
Expand Down
16 changes: 16 additions & 0 deletions src/libsyntax/parse/parser.rs
Expand Up @@ -6722,6 +6722,22 @@ impl<'a> Parser<'a> {
self.expect(&token::OpenDelim(token::Brace))?; self.expect(&token::OpenDelim(token::Brace))?;
let mut trait_items = vec![]; let mut trait_items = vec![];
while !self.eat(&token::CloseDelim(token::Brace)) { while !self.eat(&token::CloseDelim(token::Brace)) {
if let token::DocComment(_) = self.token {
if self.look_ahead(1,
|tok| tok == &token::Token::CloseDelim(token::Brace)) {
let mut err = self.diagnostic().struct_span_err_with_code(
self.span,
"found a documentation comment that doesn't document anything",
DiagnosticId::Error("E0584".into()),
);
err.help("doc comments must come before what they document, maybe a \
comment was intended with `//`?",
);
err.emit();
self.bump();
continue;
}
}
let mut at_end = false; let mut at_end = false;
match self.parse_trait_item(&mut at_end) { match self.parse_trait_item(&mut at_end) {
Ok(item) => trait_items.push(item), Ok(item) => trait_items.push(item),
Expand Down
@@ -1,7 +1,7 @@
use std::fmt::Debug; use std::fmt::Debug;


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


fn explicit<'a>(x: &'a i32) -> impl Copy { x } fn explicit<'a>(x: &'a i32) -> impl Copy { x }
//~^ ERROR cannot infer an appropriate lifetime //~^ ERROR cannot infer an appropriate lifetime
Expand Down
22 changes: 16 additions & 6 deletions src/test/ui/impl-trait/must_outlive_least_region_or_bound.stderr
@@ -1,10 +1,20 @@
error[E0621]: explicit lifetime required in the type of `x` error: cannot infer an appropriate lifetime
--> $DIR/must_outlive_least_region_or_bound.rs:3:23 --> $DIR/must_outlive_least_region_or_bound.rs:3:35
| |
LL | fn elided(x: &i32) -> impl Copy { x } LL | fn elided(x: &i32) -> impl Copy { x }
| ---- ^^^^^^^^^ lifetime `'static` required | --------- ^ ...but this borrow...
| | | |
| help: add explicit lifetime `'static` to the type of `x`: `&'static i32` | this return type evaluates to the `'static` lifetime...
|
note: ...can't outlive the anonymous lifetime #1 defined on the function body at 3:1
--> $DIR/must_outlive_least_region_or_bound.rs:3:1
|
LL | fn elided(x: &i32) -> impl Copy { x }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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
|
LL | fn elided(x: &i32) -> impl Copy + '_ { x }
| ^^^^^^^^^^^^^^


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


error: aborting due to 5 previous errors error: aborting due to 5 previous errors


Some errors occurred: E0310, E0621, E0623. Some errors occurred: E0310, E0623.
For more information about an error, try `rustc --explain E0310`. For more information about an error, try `rustc --explain E0310`.
2 changes: 1 addition & 1 deletion src/test/ui/nll/ty-outlives/impl-trait-captures.rs
Expand Up @@ -8,8 +8,8 @@ trait Foo<'a> {
impl<'a, T> Foo<'a> for T { } impl<'a, T> Foo<'a> for T { }


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


fn main() {} fn main() {}
6 changes: 3 additions & 3 deletions src/test/ui/nll/ty-outlives/impl-trait-captures.stderr
@@ -1,8 +1,8 @@
error[E0621]: explicit lifetime required in the type of `x` error[E0621]: explicit lifetime required in the type of `x`
--> $DIR/impl-trait-captures.rs:11:5 --> $DIR/impl-trait-captures.rs:10:25
| |
LL | x LL | fn foo<'a, T>(x: &T) -> impl Foo<'a> {
| ^ lifetime `ReEarlyBound(0, 'a)` required | ^^^^^^^^^^^^ lifetime `ReEarlyBound(0, 'a)` required
help: add explicit lifetime `ReEarlyBound(0, 'a)` to the type of `x` help: add explicit lifetime `ReEarlyBound(0, 'a)` to the type of `x`
| |
LL | fn foo<'a, T>(x: &ReEarlyBound(0, 'a) T) -> impl Foo<'a> { LL | fn foo<'a, T>(x: &ReEarlyBound(0, 'a) T) -> impl Foo<'a> {
Expand Down
6 changes: 6 additions & 0 deletions src/test/ui/parser/doc-inside-trait-item.rs
@@ -0,0 +1,6 @@
trait User{
fn test();
/// empty doc
//~^ ERROR found a documentation comment that doesn't document anything
}
fn main() {}
11 changes: 11 additions & 0 deletions src/test/ui/parser/doc-inside-trait-item.stderr
@@ -0,0 +1,11 @@
error[E0584]: found a documentation comment that doesn't document anything
--> $DIR/doc-inside-trait-item.rs:3:5
|
LL | /// empty doc
| ^^^^^^^^^^^^^
|
= help: doc comments must come before what they document, maybe a comment was intended with `//`?

error: aborting due to previous error

For more information about this error, try `rustc --explain E0584`.
2 changes: 1 addition & 1 deletion src/tools/cargotest/main.rs
Expand Up @@ -30,7 +30,7 @@ const TEST_REPOS: &'static [Test] = &[
}, },
Test { Test {
name: "tokei", name: "tokei",
repo: "https://github.com/Aaronepower/tokei", repo: "https://github.com/XAMPPRocky/tokei",
sha: "5e11c4852fe4aa086b0e4fe5885822fbe57ba928", sha: "5e11c4852fe4aa086b0e4fe5885822fbe57ba928",
lock: None, lock: None,
packages: &[], packages: &[],
Expand Down

0 comments on commit f694222

Please sign in to comment.