diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2020-07-11 08:53:21 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-11 08:53:21 -0700 |
| commit | 9f7b64eecba095c1efb0f6c5aab8f2ad93fc0df5 (patch) | |
| tree | d3496e903d6de7a42b5bbb3971bd8e5ed79e05ad /src/librustc_resolve | |
| parent | 8f8ff1505f762dd29d51a21494b92084a3bad838 (diff) | |
| parent | a9b64766a47ce7a0ad6768b7a74bae7fa991576e (diff) | |
| download | rust-9f7b64eecba095c1efb0f6c5aab8f2ad93fc0df5.tar.gz rust-9f7b64eecba095c1efb0f6c5aab8f2ad93fc0df5.zip | |
Rollup merge of #74168 - JohnTitor:help-for-in-band-lifetimes, r=petrochenkov
Add a help to use `in_band_lifetimes` in nightly Fixes #73775
Diffstat (limited to 'src/librustc_resolve')
| -rw-r--r-- | src/librustc_resolve/late/diagnostics.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/librustc_resolve/late/diagnostics.rs b/src/librustc_resolve/late/diagnostics.rs index e469ca80c59..3537fb388d0 100644 --- a/src/librustc_resolve/late/diagnostics.rs +++ b/src/librustc_resolve/late/diagnostics.rs @@ -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) => { @@ -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( @@ -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 experiment with in-band lifetime bindings, \ + add `#![feature(in_band_lifetimes)]` to the crate attributes", + ); + } err.emit(); } |
