mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-22 04:27:33 +00:00
Rollup merge of #141781 - matthewjasper:unused-unsafe-lifetimes, r=compiler-errors
Fix spans for unsafe binders closes rust-lang/rust#141758 r? ``@compiler-errors``
This commit is contained in:
commit
955ebfc7d3
@ -934,8 +934,7 @@ impl<'ra: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'_, 'ast, 'r
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
TyKind::UnsafeBinder(unsafe_binder) => {
|
TyKind::UnsafeBinder(unsafe_binder) => {
|
||||||
// FIXME(unsafe_binder): Better span
|
let span = ty.span.shrink_to_lo().to(unsafe_binder.inner_ty.span.shrink_to_lo());
|
||||||
let span = ty.span;
|
|
||||||
self.with_generic_param_rib(
|
self.with_generic_param_rib(
|
||||||
&unsafe_binder.generic_params,
|
&unsafe_binder.generic_params,
|
||||||
RibKind::Normal,
|
RibKind::Normal,
|
||||||
|
20
tests/ui/unsafe-binders/unused-lifetimes-2.fixed
Normal file
20
tests/ui/unsafe-binders/unused-lifetimes-2.fixed
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
// regression test for #141758
|
||||||
|
//@ run-rustfix
|
||||||
|
//@ check-pass
|
||||||
|
|
||||||
|
#![warn(unused_lifetimes)]
|
||||||
|
#![allow(incomplete_features, unused_imports, dead_code)]
|
||||||
|
#![feature(unsafe_binders)]
|
||||||
|
|
||||||
|
use std::unsafe_binder::unwrap_binder;
|
||||||
|
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
|
pub struct S([usize; 8]);
|
||||||
|
|
||||||
|
// Regression test for <https://github.com/rust-lang/rust/issues/141418>.
|
||||||
|
pub fn by_value(_x: unsafe<'a> &'a S) -> usize {
|
||||||
|
//~^ WARN lifetime parameter `'b` never used
|
||||||
|
0
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
20
tests/ui/unsafe-binders/unused-lifetimes-2.rs
Normal file
20
tests/ui/unsafe-binders/unused-lifetimes-2.rs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
// regression test for #141758
|
||||||
|
//@ run-rustfix
|
||||||
|
//@ check-pass
|
||||||
|
|
||||||
|
#![warn(unused_lifetimes)]
|
||||||
|
#![allow(incomplete_features, unused_imports, dead_code)]
|
||||||
|
#![feature(unsafe_binders)]
|
||||||
|
|
||||||
|
use std::unsafe_binder::unwrap_binder;
|
||||||
|
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
|
pub struct S([usize; 8]);
|
||||||
|
|
||||||
|
// Regression test for <https://github.com/rust-lang/rust/issues/141418>.
|
||||||
|
pub fn by_value(_x: unsafe<'a, 'b> &'a S) -> usize {
|
||||||
|
//~^ WARN lifetime parameter `'b` never used
|
||||||
|
0
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
16
tests/ui/unsafe-binders/unused-lifetimes-2.stderr
Normal file
16
tests/ui/unsafe-binders/unused-lifetimes-2.stderr
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
warning: lifetime parameter `'b` never used
|
||||||
|
--> $DIR/unused-lifetimes-2.rs:15:32
|
||||||
|
|
|
||||||
|
LL | pub fn by_value(_x: unsafe<'a, 'b> &'a S) -> usize {
|
||||||
|
| --^^
|
||||||
|
| |
|
||||||
|
| help: elide the unused lifetime
|
||||||
|
|
|
||||||
|
note: the lint level is defined here
|
||||||
|
--> $DIR/unused-lifetimes-2.rs:5:9
|
||||||
|
|
|
||||||
|
LL | #![warn(unused_lifetimes)]
|
||||||
|
| ^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
warning: 1 warning emitted
|
||||||
|
|
20
tests/ui/unsafe-binders/unused-lifetimes.fixed
Normal file
20
tests/ui/unsafe-binders/unused-lifetimes.fixed
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
// regression test for #141758
|
||||||
|
//@ run-rustfix
|
||||||
|
//@ check-pass
|
||||||
|
|
||||||
|
#![warn(unused_lifetimes)]
|
||||||
|
#![allow(incomplete_features, unused_imports, dead_code)]
|
||||||
|
#![feature(unsafe_binders)]
|
||||||
|
|
||||||
|
use std::unsafe_binder::unwrap_binder;
|
||||||
|
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
|
pub struct S([usize; 8]);
|
||||||
|
|
||||||
|
// Regression test for <https://github.com/rust-lang/rust/issues/141418>.
|
||||||
|
pub fn by_value(_x: S) -> usize {
|
||||||
|
//~^ WARN lifetime parameter `'a` never used
|
||||||
|
0
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
20
tests/ui/unsafe-binders/unused-lifetimes.rs
Normal file
20
tests/ui/unsafe-binders/unused-lifetimes.rs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
// regression test for #141758
|
||||||
|
//@ run-rustfix
|
||||||
|
//@ check-pass
|
||||||
|
|
||||||
|
#![warn(unused_lifetimes)]
|
||||||
|
#![allow(incomplete_features, unused_imports, dead_code)]
|
||||||
|
#![feature(unsafe_binders)]
|
||||||
|
|
||||||
|
use std::unsafe_binder::unwrap_binder;
|
||||||
|
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
|
pub struct S([usize; 8]);
|
||||||
|
|
||||||
|
// Regression test for <https://github.com/rust-lang/rust/issues/141418>.
|
||||||
|
pub fn by_value(_x: unsafe<'a> S) -> usize {
|
||||||
|
//~^ WARN lifetime parameter `'a` never used
|
||||||
|
0
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
14
tests/ui/unsafe-binders/unused-lifetimes.stderr
Normal file
14
tests/ui/unsafe-binders/unused-lifetimes.stderr
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
warning: lifetime parameter `'a` never used
|
||||||
|
--> $DIR/unused-lifetimes.rs:15:28
|
||||||
|
|
|
||||||
|
LL | pub fn by_value(_x: unsafe<'a> S) -> usize {
|
||||||
|
| -------^^-- help: elide the unused lifetime
|
||||||
|
|
|
||||||
|
note: the lint level is defined here
|
||||||
|
--> $DIR/unused-lifetimes.rs:5:9
|
||||||
|
|
|
||||||
|
LL | #![warn(unused_lifetimes)]
|
||||||
|
| ^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
warning: 1 warning emitted
|
||||||
|
|
Loading…
Reference in New Issue
Block a user