about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-05-20 15:40:33 +0000
committerbors <bors@rust-lang.org>2022-05-20 15:40:33 +0000
commitb5caa5a8421f84cb7664f999b7635801bcf3f96a (patch)
tree641380c4a3f31c8369c7d07644d6f2f28b260851 /compiler/rustc_parse/src/parser
parent22ee39504a702f75485582d02060495a01254de1 (diff)
parent563916d698380f3773da38b1ebff00ef2842e781 (diff)
downloadrust-b5caa5a8421f84cb7664f999b7635801bcf3f96a.tar.gz
rust-b5caa5a8421f84cb7664f999b7635801bcf3f96a.zip
Auto merge of #96833 - cjgillot:ast-lifetimes-single, r=petrochenkov
Lint single-use lifetimes during AST resolution

This PR rewrites `single_use_lifetime` and `unused_lifetime` lints to be based on the AST.
We have more information at our disposal, so we can reduce the amount of false positives.

Remaining false positive: single-use lifetimes in argument-position impl-trait.
I'm waiting for https://github.com/rust-lang/rust/issues/96529 to be fixed to have a clean and proper solution here.

Closes https://github.com/rust-lang/rust/issues/54079
Closes https://github.com/rust-lang/rust/issues/55057
Closes https://github.com/rust-lang/rust/issues/55058
Closes https://github.com/rust-lang/rust/issues/60554
Closes https://github.com/rust-lang/rust/issues/69952

r? `@petrochenkov`
Diffstat (limited to 'compiler/rustc_parse/src/parser')
-rw-r--r--compiler/rustc_parse/src/parser/ty.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/compiler/rustc_parse/src/parser/ty.rs b/compiler/rustc_parse/src/parser/ty.rs
index b0439a5987a..fb3f5eb3f9f 100644
--- a/compiler/rustc_parse/src/parser/ty.rs
+++ b/compiler/rustc_parse/src/parser/ty.rs
@@ -518,6 +518,7 @@ impl<'a> Parser<'a> {
             kind: rustc_ast::VisibilityKind::Inherited,
             tokens: None,
         };
+        let span_start = self.token.span;
         let ast::FnHeader { ext, unsafety, constness, asyncness } =
             self.parse_fn_front_matter(&inherited_vis)?;
         let decl = self.parse_fn_decl(|_| false, AllowPlus::No, recover_return_sign)?;
@@ -531,7 +532,8 @@ impl<'a> Parser<'a> {
         if let ast::Async::Yes { span, .. } = asyncness {
             self.error_fn_ptr_bad_qualifier(whole_span, span, "async");
         }
-        Ok(TyKind::BareFn(P(BareFnTy { ext, unsafety, generic_params: params, decl })))
+        let decl_span = span_start.to(self.token.span);
+        Ok(TyKind::BareFn(P(BareFnTy { ext, unsafety, generic_params: params, decl, decl_span })))
     }
 
     /// Emit an error for the given bad function pointer qualifier.