File tree Expand file tree Collapse file tree 6 files changed +109
-2
lines changed Expand file tree Collapse file tree 6 files changed +109
-2
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ pub mod intravisit;
2626pub mod lang_items;
2727pub mod pat_util;
2828mod stable_hash_impls;
29- mod target;
29+ pub mod target;
3030pub mod weak_lang_items;
3131
3232#[ cfg( test) ]
Original file line number Diff line number Diff line change @@ -584,6 +584,10 @@ passes_pass_by_value =
584584 `pass_by_value` attribute should be applied to a struct, enum or type alias
585585 .label = is not a struct, enum or type alias
586586
587+ passes_pointee_on_non_generic_ty =
588+ attribute should be applied to generic type parameters
589+ .label = not a generic type parameter
590+
587591passes_proc_macro_bad_sig = { $kind } has incorrect signature
588592
589593passes_remove_fields =
Original file line number Diff line number Diff line change @@ -242,6 +242,9 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
242242 [ sym:: coroutine, ..] => {
243243 self . check_coroutine ( attr, target) ;
244244 }
245+ [ sym:: pointee, ..] => {
246+ self . check_pointee ( attr, target) ;
247+ }
245248 [
246249 // ok
247250 sym:: allow
@@ -253,7 +256,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
253256 // need to be fixed
254257 | sym:: cfi_encoding // FIXME(cfi_encoding)
255258 | sym:: may_dangle // FIXME(dropck_eyepatch)
256- | sym:: pointee // FIXME(derive_smart_pointer)
257259 | sym:: linkage // FIXME(linkage)
258260 | sym:: no_sanitize // FIXME(no_sanitize)
259261 | sym:: omit_gdb_pretty_printer_section // FIXME(omit_gdb_pretty_printer_section)
@@ -2343,6 +2345,15 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
23432345 }
23442346 }
23452347 }
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+ }
23462357}
23472358
23482359impl < ' tcx > Visitor < ' tcx > for CheckAttrVisitor < ' tcx > {
Original file line number Diff line number Diff line change @@ -643,6 +643,13 @@ pub struct CoroutineOnNonClosure {
643643 pub span : Span ,
644644}
645645
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+
646653#[ derive( Diagnostic ) ]
647654#[ diag( passes_empty_confusables) ]
648655pub ( 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