File tree 6 files changed +109
-2
lines changed
6 files changed +109
-2
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ pub mod intravisit;
26
26
pub mod lang_items;
27
27
pub mod pat_util;
28
28
mod stable_hash_impls;
29
- mod target;
29
+ pub mod target;
30
30
pub mod weak_lang_items;
31
31
32
32
#[ cfg( test) ]
Original file line number Diff line number Diff line change @@ -584,6 +584,10 @@ passes_pass_by_value =
584
584
`pass_by_value` attribute should be applied to a struct, enum or type alias
585
585
.label = is not a struct, enum or type alias
586
586
587
+ passes_pointee_on_non_generic_ty =
588
+ attribute should be applied to generic type parameters
589
+ .label = not a generic type parameter
590
+
587
591
passes_proc_macro_bad_sig = { $kind } has incorrect signature
588
592
589
593
passes_remove_fields =
Original file line number Diff line number Diff line change @@ -242,6 +242,9 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
242
242
[ sym:: coroutine, ..] => {
243
243
self . check_coroutine ( attr, target) ;
244
244
}
245
+ [ sym:: pointee, ..] => {
246
+ self . check_pointee ( attr, target) ;
247
+ }
245
248
[
246
249
// ok
247
250
sym:: allow
@@ -253,7 +256,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
253
256
// need to be fixed
254
257
| sym:: cfi_encoding // FIXME(cfi_encoding)
255
258
| sym:: may_dangle // FIXME(dropck_eyepatch)
256
- | sym:: pointee // FIXME(derive_smart_pointer)
257
259
| sym:: linkage // FIXME(linkage)
258
260
| sym:: no_sanitize // FIXME(no_sanitize)
259
261
| sym:: omit_gdb_pretty_printer_section // FIXME(omit_gdb_pretty_printer_section)
@@ -2343,6 +2345,15 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
2343
2345
}
2344
2346
}
2345
2347
}
2348
+
2349
+ fn check_pointee ( & self , attr : & Attribute , target : Target ) {
2350
+ match target {
2351
+ Target :: GenericParam ( hir:: target:: GenericParamKind :: Type ) => return ,
2352
+ _ => {
2353
+ self . dcx ( ) . emit_err ( errors:: PointeeOnNonGenericTy { attr_span : attr. span } ) ;
2354
+ }
2355
+ }
2356
+ }
2346
2357
}
2347
2358
2348
2359
impl < ' tcx > Visitor < ' tcx > for CheckAttrVisitor < ' tcx > {
Original file line number Diff line number Diff line change @@ -643,6 +643,13 @@ pub struct CoroutineOnNonClosure {
643
643
pub span : Span ,
644
644
}
645
645
646
+ #[ derive( Diagnostic ) ]
647
+ #[ diag( passes_pointee_on_non_generic_ty) ]
648
+ pub struct PointeeOnNonGenericTy {
649
+ #[ primary_span]
650
+ pub attr_span : Span ,
651
+ }
652
+
646
653
#[ derive( Diagnostic ) ]
647
654
#[ diag( passes_empty_confusables) ]
648
655
pub ( crate ) struct EmptyConfusables {
Original file line number Diff line number Diff line change
1
+ #![ feature( derive_smart_pointer) ]
2
+
3
+ #[ pointee]
4
+ //~^ ERROR: attribute should be applied to generic type parameters
5
+ struct AStruct <
6
+ #[ pointee]
7
+ //~^ ERROR: attribute should be applied to generic type parameters
8
+ ' lifetime ,
9
+ #[ pointee]
10
+ //~^ ERROR: attribute should be applied to generic type parameters
11
+ const CONST : usize
12
+ > {
13
+ #[ pointee]
14
+ //~^ ERROR: attribute should be applied to generic type parameters
15
+ val : & ' lifetime ( )
16
+ }
17
+
18
+ #[ pointee]
19
+ //~^ ERROR: attribute should be applied to generic type parameters
20
+ enum AnEnum {
21
+ #[ pointee]
22
+ //~^ ERROR: attribute should be applied to generic type parameters
23
+ AVariant
24
+ }
25
+
26
+ #[ pointee]
27
+ //~^ ERROR: attribute should be applied to generic type parameters
28
+ mod AModule { }
29
+
30
+ #[ pointee]
31
+ //~^ ERROR: attribute should be applied to generic type parameters
32
+ fn a_function (
33
+ ) { }
34
+
35
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ error: attribute should be applied to generic type parameters
2
+ --> $DIR/deriving-smart-pointer-pointee-in-strange-places.rs:3:1
3
+ |
4
+ LL | #[pointee]
5
+ | ^^^^^^^^^^
6
+
7
+ error: attribute should be applied to generic type parameters
8
+ --> $DIR/deriving-smart-pointer-pointee-in-strange-places.rs:6:5
9
+ |
10
+ LL | #[pointee]
11
+ | ^^^^^^^^^^
12
+
13
+ error: attribute should be applied to generic type parameters
14
+ --> $DIR/deriving-smart-pointer-pointee-in-strange-places.rs:9:5
15
+ |
16
+ LL | #[pointee]
17
+ | ^^^^^^^^^^
18
+
19
+ error: attribute should be applied to generic type parameters
20
+ --> $DIR/deriving-smart-pointer-pointee-in-strange-places.rs:13:5
21
+ |
22
+ LL | #[pointee]
23
+ | ^^^^^^^^^^
24
+
25
+ error: attribute should be applied to generic type parameters
26
+ --> $DIR/deriving-smart-pointer-pointee-in-strange-places.rs:18:1
27
+ |
28
+ LL | #[pointee]
29
+ | ^^^^^^^^^^
30
+
31
+ error: attribute should be applied to generic type parameters
32
+ --> $DIR/deriving-smart-pointer-pointee-in-strange-places.rs:21:5
33
+ |
34
+ LL | #[pointee]
35
+ | ^^^^^^^^^^
36
+
37
+ error: attribute should be applied to generic type parameters
38
+ --> $DIR/deriving-smart-pointer-pointee-in-strange-places.rs:26:1
39
+ |
40
+ LL | #[pointee]
41
+ | ^^^^^^^^^^
42
+
43
+ error: attribute should be applied to generic type parameters
44
+ --> $DIR/deriving-smart-pointer-pointee-in-strange-places.rs:30:1
45
+ |
46
+ LL | #[pointee]
47
+ | ^^^^^^^^^^
48
+
49
+ error: aborting due to 8 previous errors
50
+
You can’t perform that action at this time.
0 commit comments