Skip to content

Commit ec16270

Browse files
authored
Rollup merge of #108744 - compiler-errors:non_lifetime_binders-bad-copy-clone, r=jackh726
Don't ICE when encountering bound var in builtin copy/clone bounds Fixes #108742
2 parents 03c1e4d + 32f1f01 commit ec16270

File tree

3 files changed

+39
-5
lines changed

3 files changed

+39
-5
lines changed

Diff for: compiler/rustc_trait_selection/src/traits/select/mod.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -2149,7 +2149,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
21492149
ty::Alias(..) | ty::Param(_) | ty::Placeholder(..) => None,
21502150
ty::Infer(ty::TyVar(_)) => Ambiguous,
21512151

2152-
// We can make this an ICE if/once we actually instantiate the trait obligation.
2152+
// We can make this an ICE if/once we actually instantiate the trait obligation eagerly.
21532153
ty::Bound(..) => None,
21542154

21552155
ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {
@@ -2257,7 +2257,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
22572257
}
22582258
}
22592259

2260-
ty::Adt(..) | ty::Alias(..) | ty::Param(..) => {
2260+
ty::Adt(..) | ty::Alias(..) | ty::Param(..) | ty::Placeholder(..) => {
22612261
// Fallback to whatever user-defined impls exist in this case.
22622262
None
22632263
}
@@ -2269,9 +2269,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
22692269
Ambiguous
22702270
}
22712271

2272-
ty::Placeholder(..)
2273-
| ty::Bound(..)
2274-
| ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {
2272+
// We can make this an ICE if/once we actually instantiate the trait obligation eagerly.
2273+
ty::Bound(..) => None,
2274+
2275+
ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {
22752276
bug!("asked to assemble builtin bounds of unexpected type: {:?}", self_ty);
22762277
}
22772278
}
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#![feature(non_lifetime_binders)]
2+
//~^ WARN the feature `non_lifetime_binders` is incomplete
3+
4+
fn foo() where for<T> T: Copy {}
5+
6+
fn main() {
7+
foo();
8+
//~^ ERROR the trait bound `T: Copy` is not satisfied
9+
}
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
2+
--> $DIR/bad-copy-cond.rs:1:12
3+
|
4+
LL | #![feature(non_lifetime_binders)]
5+
| ^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information
8+
= note: `#[warn(incomplete_features)]` on by default
9+
10+
error[E0277]: the trait bound `T: Copy` is not satisfied
11+
--> $DIR/bad-copy-cond.rs:7:5
12+
|
13+
LL | foo();
14+
| ^^^ the trait `Copy` is not implemented for `T`
15+
|
16+
note: required by a bound in `foo`
17+
--> $DIR/bad-copy-cond.rs:4:26
18+
|
19+
LL | fn foo() where for<T> T: Copy {}
20+
| ^^^^ required by this bound in `foo`
21+
22+
error: aborting due to previous error; 1 warning emitted
23+
24+
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)