Skip to content
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

Rollup of 6 pull requests #102867

Merged
merged 18 commits into from
Oct 10, 2022
Merged
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
Using multipart suggestion
  • Loading branch information
Stoozy committed Sep 27, 2022
commit 365457bd2590029e0cdba5b401273169c0fa6a79
31 changes: 19 additions & 12 deletions compiler/rustc_resolve/src/late/lifetimes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

use rustc_ast::walk_list;
use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
use rustc_errors::{struct_span_err};
use rustc_errors::struct_span_err;
use rustc_hir as hir;
use rustc_hir::def::{DefKind, Res};
use rustc_hir::def_id::LocalDefId;
Expand All @@ -24,7 +24,6 @@ use rustc_span::symbol::{sym, Ident};
use rustc_span::Span;
use std::fmt;


trait RegionExt {
fn early(hir_map: Map<'_>, param: &GenericParam<'_>) -> (LocalDefId, Region);

Expand Down Expand Up @@ -1320,21 +1319,29 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
&& !self.tcx.features().anonymous_lifetime_in_impl_trait
{

match self.tcx.hir().get_generics(lifetime_ref.hir_id.owner.to_def_id().as_local().unwrap()) {
match self.tcx.hir().get_generics(lifetime_ref.hir_id.owner.def_id) {
Some(generics) => {
for i in 0..generics.params.len() {

if !generics.span.contains(generics.params[i].span) {
struct_span_err!(
self.tcx.sess,

let mut diag = rustc_session::parse::feature_err(
&self.tcx.sess.parse_sess,
sym::anonymous_lifetime_in_impl_trait,
lifetime_ref.span,
E0106,
"missing lifetime specifier"
)
.span_label(lifetime_ref.span, "expected named lifetime parameter")
.span_help(generics.span, "consider introducing a named lifetime parameter")
.emit();
return;
"anonymous lifetimes in `impl Trait` are unstable",
);

diag.span_label(lifetime_ref.span, "expected named lifetime parameter");

diag.multipart_suggestion("consider introducing a named lifetime parameter",
vec![
(lifetime_ref.span, "&'a ".to_owned()),
(generics.span, "<'a>".to_owned())
], rustc_errors::Applicability::MaybeIncorrect);
diag.emit();

return;
}
}
},
Expand Down