Skip to content

Rollup of 12 pull requests #52988

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 37 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
ef6fddd
cleanup: Remove `Def::GlobalAsm`
petrochenkov Jul 30, 2018
e9509d7
Disable debug sections when optimization flags is set for LLD.
yurydelendik Jul 31, 2018
77aa031
Calculate capacity when collecting into Option and Result
ljedrz Jul 31, 2018
5e70e5e
Move validate_crate_name to rustc_metadata
Mark-Simulacrum Jul 31, 2018
8752e61
Delete dummy crate store
Mark-Simulacrum Jul 31, 2018
5ce5f31
check_const: use the same ParamEnv as codegen for statics
RalfJung Jul 31, 2018
d148b41
Visibility is now a query
Mark-Simulacrum Jul 31, 2018
222dd17
add comment
RalfJung Aug 1, 2018
0da7da8
Align 6-week cycle check with beta promotion instead of stable release.
kennytm Aug 1, 2018
424f6bd
Store concrete crate stores where possible
Mark-Simulacrum Jul 31, 2018
dd753cd
Move unused trait functions to inherent functions
Mark-Simulacrum Jul 31, 2018
c3618c8
Special-case `Box` in `rustc_mir::borrow_check`.
pnkfelix Jul 26, 2018
1863cb7
Errors are more specific in cases where borrows are used in future it…
davidtwco Aug 1, 2018
88284ba
minor fallout from the change.
pnkfelix Jul 27, 2018
08b3a8e
Regression tests.
pnkfelix Jul 27, 2018
469d6a8
Test for (previously uncaught) infinite loop identified by matthewjas…
pnkfelix Jul 30, 2018
a1b8a93
Expand long-live-borrows-in-boxes test to include simplier illustrati…
pnkfelix Jul 30, 2018
c02c00b
Fix bug in test pointed out during review.
pnkfelix Jul 30, 2018
01cf9bf
Update LLVM submodule
cramertj Aug 1, 2018
66a4718
rustbuild: fix local_rebuild
Keruspe Aug 2, 2018
2488cb6
Explicitly label any named lifetimes mentioned in error messages.
davidtwco Aug 2, 2018
bb88c98
Add lldb to the build
tromey Jul 3, 2018
4aa21d1
Ignore clang and lldb in tidy
tromey Jul 26, 2018
7707578
Do not try to distribute lldb if it was not built
tromey Jul 27, 2018
1d43f25
Handle the dry_run case in the lldb dist step
tromey Jul 27, 2018
5c54bd9
Rollup merge of #52716 - tromey:rustup-lldb, r=Mark-Simulacrum
cramertj Aug 2, 2018
45abb02
Rollup merge of #52782 - pnkfelix:issue-45696-dangly-paths-for-box, r…
cramertj Aug 2, 2018
a94309c
Rollup merge of #52886 - petrochenkov:noga, r=alexcrichton
cramertj Aug 2, 2018
9a7af03
Rollup merge of #52887 - yurydelendik:disable-lld-symbols, r=alexcric…
cramertj Aug 2, 2018
5375ce4
Rollup merge of #52910 - ljedrz:fix_48994, r=sfackler
cramertj Aug 2, 2018
78560fa
Rollup merge of #52925 - RalfJung:sanity_check, r=oli-obk
cramertj Aug 2, 2018
83b3288
Rollup merge of #52927 - Mark-Simulacrum:cratestore-cleanup, r=varkor
cramertj Aug 2, 2018
3d60b78
Rollup merge of #52940 - kennytm:move-checktool-protection-week, r=al…
cramertj Aug 2, 2018
869731b
Rollup merge of #52948 - davidtwco:issue-52633-later-loop-iteration, …
cramertj Aug 2, 2018
4889e0f
Rollup merge of #52952 - cramertj:llvm-update, r=alexcrichton
cramertj Aug 2, 2018
9979b16
Rollup merge of #52969 - Keruspe:local_rebuild, r=alexcrichton
cramertj Aug 2, 2018
ad7b17a
Rollup merge of #52973 - davidtwco:issue-52663-lifetimes-not-included…
cramertj Aug 2, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Explicitly label any named lifetimes mentioned in error messages.
  • Loading branch information
davidtwco committed Aug 2, 2018
commit 2488cb6b1027bf88e33dfdc7ce89472f5dc54714
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ use rustc::hir::def_id::DefId;
use rustc::infer::InferCtxt;
use rustc::mir::Mir;
use rustc::ty::subst::{Substs, UnpackedKind};
use rustc::ty::{self, RegionVid, Ty, TyCtxt};
use rustc::ty::{self, RegionKind, RegionVid, Ty, TyCtxt};
use rustc::util::ppaux::with_highlight_region;
use rustc_errors::DiagnosticBuilder;
use syntax::ast::Name;
use syntax::ast::{Name, DUMMY_NODE_ID};
use syntax::symbol::keywords;
use syntax_pos::symbol::InternedString;

Expand Down Expand Up @@ -90,14 +90,21 @@ impl<'tcx> RegionInferenceContext<'tcx> {
diag: &mut DiagnosticBuilder<'_>,
) -> Option<InternedString> {
let error_region = self.to_error_region(fr)?;

debug!("give_region_a_name: error_region = {:?}", error_region);
match error_region {
ty::ReEarlyBound(ebr) => Some(ebr.name),
ty::ReEarlyBound(ebr) => {
self.highlight_named_span(tcx, error_region, &ebr.name, diag);
Some(ebr.name)
},

ty::ReStatic => Some(keywords::StaticLifetime.name().as_interned_str()),

ty::ReFree(free_region) => match free_region.bound_region {
ty::BoundRegion::BrNamed(_, name) => Some(name),
ty::BoundRegion::BrNamed(_, name) => {
self.highlight_named_span(tcx, error_region, &name, diag);
Some(name)
},

ty::BoundRegion::BrEnv => {
let closure_span = tcx.hir.span_if_local(mir_def_id).unwrap();
Expand All @@ -123,6 +130,45 @@ impl<'tcx> RegionInferenceContext<'tcx> {
}
}

/// Highlight a named span to provide context for error messages that
/// mention that span, for example:
///
/// ```
/// |
/// | fn two_regions<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
/// | -- -- lifetime `'b` defined here
/// | |
/// | lifetime `'a` defined here
/// |
/// | with_signature(cell, t, |cell, t| require(cell, t));
/// | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'b` must
/// | outlive `'a`
/// ```
fn highlight_named_span(
&self,
tcx: TyCtxt<'_, '_, 'tcx>,
error_region: &RegionKind,
name: &InternedString,
diag: &mut DiagnosticBuilder<'_>,
) {
let cm = tcx.sess.codemap();

let scope = error_region.free_region_binding_scope(tcx);
let node = tcx.hir.as_local_node_id(scope).unwrap_or(DUMMY_NODE_ID);

let mut sp = cm.def_span(tcx.hir.span(node));
if let Some(param) = tcx.hir.get_generics(scope).and_then(|generics| {
generics.get_named(name)
}) {
sp = param.span;
}

diag.span_label(
sp,
format!("lifetime `{}` defined here", name),
);
}

/// Find an argument that contains `fr` and label it with a fully
/// elaborated type, returning something like `'1`. Result looks
/// like:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ LL | self.x.iter().map(|a| a.0)
error: unsatisfied lifetime constraints
--> $DIR/static-return-lifetime-infered.rs:21:9
|
LL | fn iter_values<'a>(&'a self) -> impl Iterator<Item=u32> {
| -- lifetime `'a` defined here
LL | self.x.iter().map(|a| a.0)
| ^^^^^^^^^^^^^ requires that `'a` must outlive `'static`

Expand Down
2 changes: 2 additions & 0 deletions src/test/ui/issue-10291.nll.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ LL | x //~ ERROR E0312
error: unsatisfied lifetime constraints
--> $DIR/issue-10291.rs:12:5
|
LL | fn test<'x>(x: &'x isize) {
| -- lifetime `'x` defined here
LL | drop::<Box<for<'z> FnMut(&'z isize) -> &'z isize>>(Box::new(|z| {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'x` must outlive `'static`

Expand Down
5 changes: 5 additions & 0 deletions src/test/ui/issue-52213.nll.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ LL | match (&t,) { //~ ERROR cannot infer an appropriate lifetime
error: unsatisfied lifetime constraints
--> $DIR/issue-52213.rs:13:11
|
LL | fn transmute_lifetime<'a, 'b, T>(t: &'a (T,)) -> &'b T {
| -- -- lifetime `'b` defined here
| |
| lifetime `'a` defined here
LL | match (&t,) { //~ ERROR cannot infer an appropriate lifetime
LL | ((u,),) => u,
| ^ requires that `'a` must outlive `'b`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ LL | &*x
error: unsatisfied lifetime constraints
--> $DIR/region-lbr-named-does-not-outlive-static.rs:19:5
|
LL | fn foo<'a>(x: &'a u32) -> &'static u32 {
| -- lifetime `'a` defined here
LL | &*x
| ^^^ requires that `'a` must outlive `'static`

Expand Down
4 changes: 4 additions & 0 deletions src/test/ui/nll/mir_check_cast_closure.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ LL | g
error: unsatisfied lifetime constraints
--> $DIR/mir_check_cast_closure.rs:16:28
|
LL | fn bar<'a, 'b>() -> fn(&'a u32, &'b u32) -> &'a u32 {
| -- -- lifetime `'b` defined here
| |
| lifetime `'a` defined here
LL | let g: fn(_, _) -> _ = |_x, y| y;
| ^^^^^^^^^ cast requires that `'b` must outlive `'a`

Expand Down
4 changes: 3 additions & 1 deletion src/test/ui/nll/mir_check_cast_unsize.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ error: unsatisfied lifetime constraints
--> $DIR/mir_check_cast_unsize.rs:17:46
|
LL | fn bar<'a>(x: &'a u32) -> &'static dyn Debug {
| ______________________________________________^
| ________--____________________________________^
| | |
| | lifetime `'a` defined here
LL | | //~^ ERROR unsatisfied lifetime constraints
LL | | x
LL | | //~^ WARNING not reporting region error due to nll
Expand Down
15 changes: 15 additions & 0 deletions src/test/ui/nll/ty-outlives/projection-one-region-closure.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ LL | | }
error: unsatisfied lifetime constraints
--> $DIR/projection-one-region-closure.rs:55:5
|
LL | fn no_relationships_late<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
| -- -- lifetime `'b` defined here
| |
| lifetime `'a` defined here
...
LL | with_signature(cell, t, |cell, t| require(cell, t));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'b` must outlive `'a`

Expand Down Expand Up @@ -101,6 +106,11 @@ LL | | }
error: unsatisfied lifetime constraints
--> $DIR/projection-one-region-closure.rs:67:5
|
LL | fn no_relationships_early<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
| -- -- lifetime `'b` defined here
| |
| lifetime `'a` defined here
...
LL | with_signature(cell, t, |cell, t| require(cell, t));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'b` must outlive `'a`

Expand Down Expand Up @@ -150,6 +160,11 @@ LL | | }
error: unsatisfied lifetime constraints
--> $DIR/projection-one-region-closure.rs:89:5
|
LL | fn projection_outlives<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
| -- -- lifetime `'b` defined here
| |
| lifetime `'a` defined here
...
LL | with_signature(cell, t, |cell, t| require(cell, t));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'b` must outlive `'a`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ LL | | }
error: unsatisfied lifetime constraints
--> $DIR/projection-one-region-trait-bound-closure.rs:47:5
|
LL | fn no_relationships_late<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
| -- -- lifetime `'b` defined here
| |
| lifetime `'a` defined here
...
LL | with_signature(cell, t, |cell, t| require(cell, t));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'b` must outlive `'a`

Expand Down Expand Up @@ -91,6 +96,11 @@ LL | | }
error: unsatisfied lifetime constraints
--> $DIR/projection-one-region-trait-bound-closure.rs:58:5
|
LL | fn no_relationships_early<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
| -- -- lifetime `'b` defined here
| |
| lifetime `'a` defined here
...
LL | with_signature(cell, t, |cell, t| require(cell, t));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'b` must outlive `'a`

Expand Down Expand Up @@ -131,6 +141,11 @@ LL | | }
error: unsatisfied lifetime constraints
--> $DIR/projection-one-region-trait-bound-closure.rs:79:5
|
LL | fn projection_outlives<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
| -- -- lifetime `'b` defined here
| |
| lifetime `'a` defined here
...
LL | with_signature(cell, t, |cell, t| require(cell, t));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'b` must outlive `'a`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,11 @@ LL | | }
error: unsatisfied lifetime constraints
--> $DIR/projection-two-region-trait-bound-closure.rs:108:5
|
LL | fn two_regions<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
| -- -- lifetime `'b` defined here
| |
| lifetime `'a` defined here
...
LL | with_signature(cell, t, |cell, t| require(cell, t));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'b` must outlive `'a`

Expand Down