Skip to content

Commit eded109

Browse files
committed
FRTs are not trivially Copy & Clone
1 parent 437303e commit eded109

File tree

5 files changed

+24
-2
lines changed

5 files changed

+24
-2
lines changed

compiler/rustc_middle/src/ty/sty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1945,7 +1945,7 @@ impl<'tcx> Ty<'tcx> {
19451945
ty::Coroutine(..) | ty::CoroutineWitness(..) => false,
19461946

19471947
// Might be, but not "trivial" so just giving the safe answer.
1948-
ty::Adt(..) | ty::Closure(..) | ty::CoroutineClosure(..) => false,
1948+
ty::Adt(..) | ty::Field(..) | ty::Closure(..) | ty::CoroutineClosure(..) => false,
19491949

19501950
ty::UnsafeBinder(_) => false,
19511951

compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ where
221221
| ty::Foreign(..)
222222
| ty::Ref(_, _, Mutability::Mut)
223223
| ty::Adt(_, _)
224+
| ty::Field(_, _)
224225
| ty::Alias(_, _)
225226
| ty::Param(_)
226227
| ty::Placeholder(..) => Err(NoSolution),

compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1206,7 +1206,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
12061206
}
12071207

12081208
// Fallback to whatever user-defined impls or param-env clauses exist in this case.
1209-
ty::Adt(..) | ty::Alias(..) | ty::Param(..) | ty::Placeholder(..) => {}
1209+
ty::Adt(..) | ty::Field(..) | ty::Alias(..) | ty::Param(..) | ty::Placeholder(..) => {}
12101210

12111211
ty::Infer(ty::TyVar(_)) => {
12121212
candidates.ambiguous = true;

compiler/rustc_trait_selection/src/traits/select/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2222,6 +2222,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
22222222
| ty::Slice(_)
22232223
| ty::Dynamic(..)
22242224
| ty::Adt(..)
2225+
| ty::Field(..)
22252226
| ty::Alias(..)
22262227
| ty::Param(..)
22272228
| ty::Placeholder(..)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#![allow(incomplete_features)]
2+
#![feature(field_projections)]
3+
4+
use std::field::field_of;
5+
6+
struct MyStruct(());
7+
8+
impl Clone for field_of!(MyStruct, 0) {
9+
fn clone(&self) -> Self {
10+
*self
11+
}
12+
}
13+
14+
impl Copy for field_of!(MyStruct, 0) {}
15+
16+
fn assert_copy<T: Copy>() {}
17+
18+
fn main() {
19+
assert_copy::<field_of!(MyStruct, 0)>();
20+
}

0 commit comments

Comments
 (0)