File tree Expand file tree Collapse file tree 4 files changed +65
-1
lines changed
compiler/rustc_hir_analysis/src/check
tests/ui/field_projections Expand file tree Collapse file tree 4 files changed +65
-1
lines changed Original file line number Diff line number Diff line change @@ -259,6 +259,17 @@ pub(super) fn check_item<'tcx>(
259
259
. with_span_label ( sp, "auto trait" )
260
260
. emit ( ) ) ;
261
261
}
262
+ if is_auto && let rustc_hir:: TyKind :: FieldOf ( ..) = impl_. self_ty . kind {
263
+ res = res. and ( Err ( tcx
264
+ . dcx ( )
265
+ . struct_span_err (
266
+ item. span ,
267
+ "impls of auto traits for field representing types not supported" ,
268
+ )
269
+ . with_span_label ( impl_. self_ty . span , "field representing type" )
270
+ . with_span_label ( of_trait. trait_ref . path . span , "auto trait" )
271
+ . emit ( ) ) ) ;
272
+ }
262
273
match header. polarity {
263
274
ty:: ImplPolarity :: Positive => {
264
275
res = res. and ( check_impl ( tcx, item, impl_) ) ;
Original file line number Diff line number Diff line change
1
+ error: impls of auto traits for field representing types not supported
2
+ --> $DIR/send.rs:13:1
3
+ |
4
+ LL | unsafe impl Send for field_of!(Bar, bar_field) {}
5
+ | ^^^^^^^^^^^^----^^^^^-------------------------^^^
6
+ | | |
7
+ | | field representing type
8
+ | auto trait
9
+
10
+ error[E0277]: `field_of!(Foo, field)` cannot be sent between threads safely
11
+ --> $DIR/send.rs:20:15
12
+ |
13
+ LL | is_send::<field_of!(Foo, field)>();
14
+ | ^^^^^^^^^^^^^^^^^^^^^ `field_of!(Foo, field)` cannot be sent between threads safely
15
+ |
16
+ = help: the trait `Send` is not implemented for `field_of!(Foo, field)`
17
+ = help: the trait `Send` is implemented for `field_of!(Bar, bar_field)`
18
+ note: required by a bound in `is_send`
19
+ --> $DIR/send.rs:16:15
20
+ |
21
+ LL | fn is_send<T: Send>() {}
22
+ | ^^^^ required by this bound in `is_send`
23
+
24
+ error: aborting due to 2 previous errors
25
+
26
+ For more information about this error, try `rustc --explain E0277`.
Original file line number Diff line number Diff line change
1
+ error: impls of auto traits for field representing types not supported
2
+ --> $DIR/send.rs:13:1
3
+ |
4
+ LL | unsafe impl Send for field_of!(Bar, bar_field) {}
5
+ | ^^^^^^^^^^^^----^^^^^-------------------------^^^
6
+ | | |
7
+ | | field representing type
8
+ | auto trait
9
+
10
+ error[E0277]: `field_of!(Foo, field)` cannot be sent between threads safely
11
+ --> $DIR/send.rs:20:15
12
+ |
13
+ LL | is_send::<field_of!(Foo, field)>();
14
+ | ^^^^^^^^^^^^^^^^^^^^^ `field_of!(Foo, field)` cannot be sent between threads safely
15
+ |
16
+ = help: the trait `Send` is not implemented for `field_of!(Foo, field)`
17
+ = help: the trait `Send` is implemented for `field_of!(Bar, bar_field)`
18
+ note: required by a bound in `is_send`
19
+ --> $DIR/send.rs:16:15
20
+ |
21
+ LL | fn is_send<T: Send>() {}
22
+ | ^^^^ required by this bound in `is_send`
23
+
24
+ error: aborting due to 2 previous errors
25
+
26
+ For more information about this error, try `rustc --explain E0277`.
Original file line number Diff line number Diff line change 1
1
//@ revisions: old next
2
2
//@ [next] compile-flags: -Znext-solver
3
- //@ run-pass
4
3
#![ feature( field_projections) ]
5
4
#![ allow( incomplete_features) ]
6
5
use std:: field:: field_of;
@@ -12,10 +11,12 @@ struct Bar {
12
11
bar_field : u32 ,
13
12
}
14
13
unsafe impl Send for field_of ! ( Bar , bar_field) { }
14
+ //~^ ERROR: impls of auto traits for field representing types not supported
15
15
16
16
fn is_send < T : Send > ( ) { }
17
17
18
18
fn main ( ) {
19
19
is_send :: < field_of ! ( Bar , bar_field) > ( ) ;
20
20
is_send :: < field_of ! ( Foo , field) > ( ) ;
21
+ //~^ ERROR: `field_of!(Foo, field)` cannot be sent between threads safely [E0277]
21
22
}
You can’t perform that action at this time.
0 commit comments