Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f8eb81b
Modify type names on MSVC to make tuples .natvis compatible.
MaulingMonkey Jun 25, 2020
24a728a
debuginfo: Define int/float types in terms of MSVC-recognized types.
MaulingMonkey Jun 25, 2020
980d8e1
Optimize is_ascii for &str and &[u8]
Jul 5, 2020
63e2e2e
Avoid `vec!` allocation in `is_ascii_slice_*` benches
Jul 5, 2020
e1d4db6
Add benchmark for slice is_ascii using align_to
Jul 5, 2020
13e380d
Benchmark the unaligned case for is_ascii, and add missing SAFETY
Jul 5, 2020
dc4a644
Add 'unrolled' is_ascii_align_to benchmark, and move is_ascii benchma…
Jul 5, 2020
a150dcc
Remove pointless `black_box` call, add a comment about the `unaligned…
Jul 6, 2020
59f979f
Fix cross-compilation of LLVM to aarch64 Windows targets
arlosi Jul 2, 2020
7fb421b
linker: illumos ld does not support --eh-frame-hdr
jclulow Jul 8, 2020
520fb92
Reword incorrect `self` token suggestion
estebank Jul 9, 2020
6864546
Add a help to use `in_band_lifetimes` in nightly
JohnTitor Jul 8, 2020
a9b6476
Tweak wording
JohnTitor Jul 9, 2020
1fb0ed0
Minor refactor for rustc_resolve diagnostics match
pickfire Jul 10, 2020
dd872be
Stabilize `transmute` in constants and statics but not const fn
oli-obk Aug 30, 2019
b929f72
Fix try_print_visible_def_path_recur for opt_def_id usage
da-x Jul 11, 2020
6bda2e8
update miri
RalfJung Jul 11, 2020
f5de23b
Add the test case mentioned in #74236
da-x Jul 11, 2020
90f1d72
Rollup merge of #72920 - oli-obk:const_transmute, r=RalfJung
Manishearth Jul 11, 2020
084ac77
Rollup merge of #73715 - MaulingMonkey:pr-natvis-tuples, r=Amanieu
Manishearth Jul 11, 2020
1979fa8
Rollup merge of #74066 - thomcc:optimize-is-ascii, r=nagisa
Manishearth Jul 11, 2020
9614238
Rollup merge of #74116 - arlosi:aarch64build, r=pietroalbini
Manishearth Jul 11, 2020
8f8ff15
Rollup merge of #74167 - jclulow:illumos-linker-eh-frame-hdr-fix, r=p…
Manishearth Jul 11, 2020
9f7b64e
Rollup merge of #74168 - JohnTitor:help-for-in-band-lifetimes, r=petr…
Manishearth Jul 11, 2020
e15fa45
Rollup merge of #74197 - estebank:self-sugg, r=petrochenkov
Manishearth Jul 11, 2020
6204a73
Rollup merge of #74213 - pickfire:patch-1, r=jonas-schievink
Manishearth Jul 11, 2020
aa04ffb
Rollup merge of #74240 - da-x:fix-74081, r=Manishearth
Manishearth Jul 11, 2020
95c5fb8
Rollup merge of #74241 - RalfJung:miri, r=RalfJung
Manishearth Jul 11, 2020
c8c4fd7
Correctly sort const_fn_transmute
Manishearth Jul 11, 2020
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
Add a help to use in_band_lifetimes in nightly
  • Loading branch information
JohnTitor committed Jul 9, 2020
commit 6864546049d8f41b0521ee7dc5dedac4850f6c88
11 changes: 11 additions & 0 deletions src/librustc_resolve/late/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1044,6 +1044,7 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
lifetime_ref
);
err.span_label(lifetime_ref.span, "undeclared lifetime");
let mut suggests_in_band = false;
for missing in &self.missing_named_lifetime_spots {
match missing {
MissingLifetimeSpot::Generics(generics) => {
Expand All @@ -1057,6 +1058,7 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
}) {
(param.span.shrink_to_lo(), format!("{}, ", lifetime_ref))
} else {
suggests_in_band = true;
(generics.span, format!("<{}>", lifetime_ref))
};
err.span_suggestion(
Expand Down Expand Up @@ -1084,6 +1086,15 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
}
}
}
if nightly_options::is_nightly_build()
&& !self.tcx.features().in_band_lifetimes
&& suggests_in_band
{
err.help(
"if you want to use in-band lifetime bindings, \
add `#![feature(in_band_lifetimes)]` to the crate attributes",
);
}
err.emit();
}

Expand Down
4 changes: 4 additions & 0 deletions src/test/ui/error-codes/E0261.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ LL | fn foo(x: &'a str) { }
| - ^^ undeclared lifetime
| |
| help: consider introducing lifetime `'a` here: `<'a>`
|
= help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes

error[E0261]: use of undeclared lifetime name `'a`
--> $DIR/E0261.rs:5:9
Expand All @@ -13,6 +15,8 @@ LL | struct Foo {
| - help: consider introducing lifetime `'a` here: `<'a>`
LL | x: &'a str,
| ^^ undeclared lifetime
|
= help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes

error: aborting due to 2 previous errors

Expand Down
22 changes: 22 additions & 0 deletions src/test/ui/feature-gates/feature-gate-in_band_lifetimes.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ LL | fn foo(x: &'x u8) -> &'x u8 { x }
| - ^^ undeclared lifetime
| |
| help: consider introducing lifetime `'x` here: `<'x>`
|
= help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes

error[E0261]: use of undeclared lifetime name `'x`
--> $DIR/feature-gate-in_band_lifetimes.rs:3:23
Expand All @@ -13,6 +15,8 @@ LL | fn foo(x: &'x u8) -> &'x u8 { x }
| - ^^ undeclared lifetime
| |
| help: consider introducing lifetime `'x` here: `<'x>`
|
= help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes

error[E0261]: use of undeclared lifetime name `'b`
--> $DIR/feature-gate-in_band_lifetimes.rs:15:12
Expand All @@ -28,6 +32,7 @@ error[E0261]: use of undeclared lifetime name `'b`
LL | fn inner_2(&self) -> &'b u8 {
| ^^ undeclared lifetime
|
= help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
help: consider introducing lifetime `'b` here
|
LL | impl<'b, 'a> X<'b> {
Expand All @@ -44,13 +49,16 @@ LL | impl X<'b> {
| - ^^ undeclared lifetime
| |
| help: consider introducing lifetime `'b` here: `<'b>`
|
= help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes

error[E0261]: use of undeclared lifetime name `'b`
--> $DIR/feature-gate-in_band_lifetimes.rs:25:27
|
LL | fn inner_3(&self) -> &'b u8 {
| ^^ undeclared lifetime
|
= help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
help: consider introducing lifetime `'b` here
|
LL | impl<'b> X<'b> {
Expand All @@ -67,13 +75,16 @@ LL | impl Y<&'a u8> {
| - ^^ undeclared lifetime
| |
| help: consider introducing lifetime `'a` here: `<'a>`
|
= help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes

error[E0261]: use of undeclared lifetime name `'a`
--> $DIR/feature-gate-in_band_lifetimes.rs:35:25
|
LL | fn inner(&self) -> &'a u8 {
| ^^ undeclared lifetime
|
= help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
help: consider introducing lifetime `'a` here
|
LL | impl<'a> Y<&'a u8> {
Expand All @@ -89,6 +100,7 @@ error[E0261]: use of undeclared lifetime name `'b`
LL | fn any_lifetime() -> &'b u8;
| ^^ undeclared lifetime
|
= help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
help: consider introducing lifetime `'b` here
|
LL | trait MyTrait<'b, 'a> {
Expand All @@ -104,6 +116,7 @@ error[E0261]: use of undeclared lifetime name `'b`
LL | fn borrowed_lifetime(&'b self) -> &'b u8;
| ^^ undeclared lifetime
|
= help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
help: consider introducing lifetime `'b` here
|
LL | trait MyTrait<'b, 'a> {
Expand All @@ -119,6 +132,7 @@ error[E0261]: use of undeclared lifetime name `'b`
LL | fn borrowed_lifetime(&'b self) -> &'b u8;
| ^^ undeclared lifetime
|
= help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
help: consider introducing lifetime `'b` here
|
LL | trait MyTrait<'b, 'a> {
Expand All @@ -135,6 +149,8 @@ LL | impl MyTrait<'a> for Y<&'a u8> {
| - ^^ undeclared lifetime
| |
| help: consider introducing lifetime `'a` here: `<'a>`
|
= help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes

error[E0261]: use of undeclared lifetime name `'a`
--> $DIR/feature-gate-in_band_lifetimes.rs:50:25
Expand All @@ -143,13 +159,16 @@ LL | impl MyTrait<'a> for Y<&'a u8> {
| - ^^ undeclared lifetime
| |
| help: consider introducing lifetime `'a` here: `<'a>`
|
= help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes

error[E0261]: use of undeclared lifetime name `'a`
--> $DIR/feature-gate-in_band_lifetimes.rs:53:31
|
LL | fn my_lifetime(&self) -> &'a u8 { self.0 }
| ^^ undeclared lifetime
|
= help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
help: consider introducing lifetime `'a` here
|
LL | impl<'a> MyTrait<'a> for Y<&'a u8> {
Expand All @@ -165,6 +184,7 @@ error[E0261]: use of undeclared lifetime name `'b`
LL | fn any_lifetime() -> &'b u8 { &0 }
| ^^ undeclared lifetime
|
= help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
help: consider introducing lifetime `'b` here
|
LL | impl<'b> MyTrait<'a> for Y<&'a u8> {
Expand All @@ -180,6 +200,7 @@ error[E0261]: use of undeclared lifetime name `'b`
LL | fn borrowed_lifetime(&'b self) -> &'b u8 { &*self.0 }
| ^^ undeclared lifetime
|
= help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
help: consider introducing lifetime `'b` here
|
LL | impl<'b> MyTrait<'a> for Y<&'a u8> {
Expand All @@ -195,6 +216,7 @@ error[E0261]: use of undeclared lifetime name `'b`
LL | fn borrowed_lifetime(&'b self) -> &'b u8 { &*self.0 }
| ^^ undeclared lifetime
|
= help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
help: consider introducing lifetime `'b` here
|
LL | impl<'b> MyTrait<'a> for Y<&'a u8> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ error[E0261]: use of undeclared lifetime name `'b`
LL | + Deref<Target = Self::Item<'b>>;
| ^^ undeclared lifetime
|
= help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
help: consider introducing lifetime `'b` here
|
LL | trait Iterable<'b> {
Expand All @@ -19,6 +20,7 @@ error[E0261]: use of undeclared lifetime name `'undeclared`
LL | fn iter<'a>(&'a self) -> Self::Iter<'undeclared>;
| ^^^^^^^^^^^ undeclared lifetime
|
= help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
help: consider introducing lifetime `'undeclared` here
|
LL | trait Iterable<'undeclared> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ LL | fn main() {
| - help: consider introducing lifetime `'a` here: `<'a>`
LL | 0.clone::<'a>();
| ^^ undeclared lifetime
|
= help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes

error: aborting due to previous error

Expand Down
4 changes: 4 additions & 0 deletions src/test/ui/regions/regions-in-enums.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ LL | enum No0 {
| - help: consider introducing lifetime `'foo` here: `<'foo>`
LL | X5(&'foo usize)
| ^^^^ undeclared lifetime
|
= help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes

error[E0261]: use of undeclared lifetime name `'a`
--> $DIR/regions-in-enums.rs:17:9
Expand All @@ -13,6 +15,8 @@ LL | enum No1 {
| - help: consider introducing lifetime `'a` here: `<'a>`
LL | X6(&'a usize)
| ^^ undeclared lifetime
|
= help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes

error: aborting due to 2 previous errors

Expand Down
4 changes: 4 additions & 0 deletions src/test/ui/regions/regions-in-structs.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ LL | struct StructDecl {
| - help: consider introducing lifetime `'a` here: `<'a>`
LL | a: &'a isize,
| ^^ undeclared lifetime
|
= help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes

error[E0261]: use of undeclared lifetime name `'a`
--> $DIR/regions-in-structs.rs:11:9
Expand All @@ -14,6 +16,8 @@ LL | struct StructDecl {
LL | a: &'a isize,
LL | b: &'a isize,
| ^^ undeclared lifetime
|
= help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes

error: aborting due to 2 previous errors

Expand Down
17 changes: 17 additions & 0 deletions src/test/ui/regions/regions-name-undeclared.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ error[E0261]: use of undeclared lifetime name `'b`
LL | fn m4(&self, arg: &'b isize) { }
| ^^ undeclared lifetime
|
= help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
help: consider introducing lifetime `'b` here
|
LL | impl<'b, 'a> Foo<'a> {
Expand All @@ -19,6 +20,7 @@ error[E0261]: use of undeclared lifetime name `'b`
LL | fn m5(&'b self) { }
| ^^ undeclared lifetime
|
= help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
help: consider introducing lifetime `'b` here
|
LL | impl<'b, 'a> Foo<'a> {
Expand All @@ -34,6 +36,7 @@ error[E0261]: use of undeclared lifetime name `'b`
LL | fn m6(&self, arg: Foo<'b>) { }
| ^^ undeclared lifetime
|
= help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
help: consider introducing lifetime `'b` here
|
LL | impl<'b, 'a> Foo<'a> {
Expand All @@ -50,6 +53,8 @@ LL | type X = Option<&'a isize>;
| - ^^ undeclared lifetime
| |
| help: consider introducing lifetime `'a` here: `<'a>`
|
= help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes

error[E0261]: use of undeclared lifetime name `'a`
--> $DIR/regions-name-undeclared.rs:27:13
Expand All @@ -58,6 +63,8 @@ LL | enum E {
| - help: consider introducing lifetime `'a` here: `<'a>`
LL | E1(&'a isize)
| ^^ undeclared lifetime
|
= help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes

error[E0261]: use of undeclared lifetime name `'a`
--> $DIR/regions-name-undeclared.rs:30:13
Expand All @@ -66,6 +73,8 @@ LL | struct S {
| - help: consider introducing lifetime `'a` here: `<'a>`
LL | f: &'a isize
| ^^ undeclared lifetime
|
= help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes

error[E0261]: use of undeclared lifetime name `'a`
--> $DIR/regions-name-undeclared.rs:32:14
Expand All @@ -74,6 +83,8 @@ LL | fn f(a: &'a isize) { }
| - ^^ undeclared lifetime
| |
| help: consider introducing lifetime `'a` here: `<'a>`
|
= help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes

error[E0261]: use of undeclared lifetime name `'a`
--> $DIR/regions-name-undeclared.rs:40:17
Expand All @@ -82,6 +93,8 @@ LL | fn fn_types(a: &'a isize,
| - ^^ undeclared lifetime
| |
| help: consider introducing lifetime `'a` here: `<'a>`
|
= help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes

error[E0261]: use of undeclared lifetime name `'b`
--> $DIR/regions-name-undeclared.rs:42:36
Expand All @@ -90,6 +103,7 @@ LL | ... &'b isize,
| ^^ undeclared lifetime
|
= note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html
= help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
help: consider introducing lifetime `'b` here
|
LL | fn fn_types<'b>(a: &'a isize,
Expand All @@ -106,6 +120,7 @@ LL | ... &'b isize)>,
| ^^ undeclared lifetime
|
= note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html
= help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
help: consider introducing lifetime `'b` here
|
LL | fn fn_types<'b>(a: &'a isize,
Expand All @@ -123,6 +138,8 @@ LL | fn fn_types(a: &'a isize,
...
LL | c: &'a isize)
| ^^ undeclared lifetime
|
= help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes

error: aborting due to 11 previous errors

Expand Down
8 changes: 8 additions & 0 deletions src/test/ui/regions/regions-undeclared.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ LL | enum EnumDecl {
| - help: consider introducing lifetime `'a` here: `<'a>`
LL | Foo(&'a isize),
| ^^ undeclared lifetime
|
= help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes

error[E0261]: use of undeclared lifetime name `'a`
--> $DIR/regions-undeclared.rs:5:10
Expand All @@ -20,6 +22,8 @@ LL | enum EnumDecl {
LL | Foo(&'a isize),
LL | Bar(&'a isize),
| ^^ undeclared lifetime
|
= help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes

error[E0261]: use of undeclared lifetime name `'a`
--> $DIR/regions-undeclared.rs:8:15
Expand All @@ -28,6 +32,8 @@ LL | fn fnDecl(x: &'a isize,
| - ^^ undeclared lifetime
| |
| help: consider introducing lifetime `'a` here: `<'a>`
|
= help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes

error[E0261]: use of undeclared lifetime name `'a`
--> $DIR/regions-undeclared.rs:9:15
Expand All @@ -36,6 +42,8 @@ LL | fn fnDecl(x: &'a isize,
| - help: consider introducing lifetime `'a` here: `<'a>`
LL | y: &'a isize)
| ^^ undeclared lifetime
|
= help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes

error: aborting due to 5 previous errors

Expand Down
4 changes: 4 additions & 0 deletions src/test/ui/where-clauses/where-lifetime-resolution.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ LL | fn f() where
LL | for<'a> dyn Trait1<'a>: Trait1<'a>, // OK
LL | (dyn for<'a> Trait1<'a>): Trait1<'a>,
| ^^ undeclared lifetime
|
= help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes

error[E0261]: use of undeclared lifetime name `'b`
--> $DIR/where-lifetime-resolution.rs:8:52
Expand All @@ -15,6 +17,8 @@ LL | fn f() where
...
LL | for<'a> dyn for<'b> Trait2<'a, 'b>: Trait2<'a, 'b>,
| ^^ undeclared lifetime
|
= help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes

error: aborting due to 2 previous errors

Expand Down