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

Fix 'impossible case reached' ICE #3248

Merged
merged 1 commit into from Oct 2, 2018
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -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

ProTip! Use n and p to navigate between commits in a pull request.