Skip to content

Commit 736a1a8

Browse files
authored
Merge pull request #2786 from phansch/fix_param_env_compile_fail
Fix chrono compile-fail due to empty param_env
2 parents 0a368b4 + 74be563 commit 736a1a8

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

clippy_lints/src/needless_pass_by_value.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue {
200200
let sugg = |db: &mut DiagnosticBuilder| {
201201
if let ty::TypeVariants::TyAdt(def, ..) = ty.sty {
202202
if let Some(span) = cx.tcx.hir.span_if_local(def.did) {
203-
let param_env = ty::ParamEnv::empty();
204-
if param_env.can_type_implement_copy(cx.tcx, ty).is_ok() {
203+
if cx.param_env.can_type_implement_copy(cx.tcx, ty).is_ok() {
205204
db.span_help(span, "consider marking this type as Copy");
206205
}
207206
}

tests/run-pass/ice-2760.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#![allow(unused_variables, blacklisted_name, needless_pass_by_value, dead_code)]
2+
3+
// This should not compile-fail with:
4+
//
5+
// error[E0277]: the trait bound `T: Foo` is not satisfied
6+
//
7+
// See https://github.com/rust-lang-nursery/rust-clippy/issues/2760
8+
9+
trait Foo {
10+
type Bar;
11+
}
12+
13+
struct Baz<T: Foo> {
14+
bar: T::Bar,
15+
}
16+
17+
fn take<T: Foo>(baz: Baz<T>) {}
18+
19+
fn main() {}

0 commit comments

Comments
 (0)