mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 21:23:56 +00:00
Fix 'impossible case reached' ICE
This commit is contained in:
parent
5f9af5f69c
commit
eb5f146f14
3 changed files with 27 additions and 6 deletions
|
@ -174,15 +174,14 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue {
|
|||
(
|
||||
preds.iter().any(|t| t.def_id() == borrow_trait),
|
||||
!preds.is_empty() && preds.iter().all(|t| {
|
||||
let ty_params = &t.skip_binder().trait_ref.substs.iter().skip(1)
|
||||
.cloned()
|
||||
.collect::<Vec<_>>();
|
||||
implements_trait(
|
||||
cx,
|
||||
cx.tcx.mk_imm_ref(&RegionKind::ReErased, ty),
|
||||
t.def_id(),
|
||||
&t.skip_binder()
|
||||
.input_types()
|
||||
.skip(1)
|
||||
.map(|ty| ty.into())
|
||||
.collect::<Vec<_>>(),
|
||||
ty_params
|
||||
)
|
||||
}),
|
||||
)
|
||||
|
|
|
@ -134,4 +134,14 @@ fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: CopyWrapper) {
|
|||
println!("{}", t);
|
||||
}
|
||||
|
||||
// The following 3 lines should not cause an ICE. See #2831
|
||||
trait Bar<'a, A> {}
|
||||
impl<'b, T> Bar<'b, T> for T {}
|
||||
fn some_fun<'b, S: Bar<'b, ()>>(_item: S) {}
|
||||
|
||||
// Also this should not cause an ICE. See #2831
|
||||
trait Club<'a, A> {}
|
||||
impl<T> Club<'static, T> for T {}
|
||||
fn more_fun(_item: impl Club<'static, i32>) {}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -184,5 +184,17 @@ help: consider taking a reference instead
|
|||
129 | let CopyWrapper(s) = *z; // moved
|
||||
|
|
||||
|
||||
error: aborting due to 20 previous errors
|
||||
error: this argument is passed by value, but not consumed in the function body
|
||||
--> $DIR/needless_pass_by_value.rs:140:40
|
||||
|
|
||||
140 | fn some_fun<'b, S: Bar<'b, ()>>(_item: S) {}
|
||||
| ^ help: consider taking a reference instead: `&S`
|
||||
|
||||
error: this argument is passed by value, but not consumed in the function body
|
||||
--> $DIR/needless_pass_by_value.rs:145:20
|
||||
|
|
||||
145 | fn more_fun(_item: impl Club<'static, i32>) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ help: consider taking a reference instead: `&impl Club<'static, i32>`
|
||||
|
||||
error: aborting due to 22 previous errors
|
||||
|
||||
|
|
Loading…
Reference in a new issue