about summary refs log tree commit diff
path: root/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.rs
blob: c2653dd82a9f551834c084ed0e3201c6da1ea9b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
//~ NOTE not an `extern` block
// This test enumerates as many compiler-builtin ungated attributes as
// possible (that is, all the mutually compatible ones), and checks
// that we get "expected" (*) warnings for each in the various weird
// places that users might put them in the syntax.
//
// (*): The word "expected" is in quotes above because the cases where
// warnings are and are not emitted might not match a user's intuition
// nor the rustc developers' intent. I am really just trying to
// capture today's behavior in a test, not so that it become enshrined
// as the absolute behavior going forward, but rather so that we do
// not change the behavior in the future without even being *aware* of
// the change when it happens.
//
// At the time of authoring, the attributes here are listed in the
// order that they occur in `librustc_feature`.
//
// Any builtin attributes that:
//
//  - are not stable, or
//
//  - could not be included here covering the same cases as the other
//    attributes without raising an *error* from rustc (note though
//    that warnings are of course expected)
//
// have their own test case referenced by filename in an inline
// comment.
//
// The test feeds numeric inputs to each attribute that accepts them
// without error. We do this for two reasons: (1.) to exercise how
// inputs are handled by each, and (2.) to ease searching for related
// occurrences in the source text.

//@ check-pass

#![feature(test)]
#![warn(unused_attributes, unknown_lints)]
//~^ NOTE the lint level is defined here
//~| NOTE the lint level is defined here

// UNGATED WHITE-LISTED BUILT-IN ATTRIBUTES

#![warn(x5400)] //~ WARN unknown lint: `x5400`
#![allow(x5300)] //~ WARN unknown lint: `x5300`
#![forbid(x5200)] //~ WARN unknown lint: `x5200`
#![deny(x5100)] //~ WARN unknown lint: `x5100`
#![macro_use] // (allowed if no argument; see issue-43160-gating-of-macro_use.rs)
// skipping testing of cfg
// skipping testing of cfg_attr
#![should_panic] //~ WARN attribute cannot be used on
//~| WARN previously accepted
//~| HELP can only be applied to
//~| HELP remove the attribute
#![ignore] //~ WARN attribute cannot be used on
//~| WARN previously accepted
//~| HELP can only be applied to
//~| HELP remove the attribute
#![no_implicit_prelude]
#![reexport_test_harness_main = "2900"]
// see gated-link-args.rs
// see issue-43106-gating-of-macro_escape.rs for crate-level; but non crate-level is below at "2700"
// (cannot easily test gating of crate-level #[no_std]; but non crate-level is below at "2600")
#![proc_macro_derive(Test)] //~ WARN attribute cannot be used on
//~| WARN previously accepted
//~| HELP can only be applied to
//~| HELP remove the attribute
#![doc = "2400"]
#![cold] //~ WARN attribute cannot be used on
//~| WARN previously accepted
//~| HELP can only be applied to
//~| HELP remove the attribute
#![link(name = "x")] //~ WARN attribute should be applied to an `extern` block
//~^ WARN this was previously accepted
#![link_name = "1900"]
//~^ WARN attribute cannot be used on
//~| WARN previously accepted
//~| HELP can be applied to
//~| HELP remove the attribute
#![link_section = "1800"]
//~^ WARN attribute cannot be used on
//~| WARN previously accepted
//~| HELP can be applied to
//~| HELP remove the attribute
#![must_use]
//~^ WARN attribute cannot be used on
//~| WARN previously accepted
//~| HELP can be applied to
//~| HELP remove the attribute
// see issue-43106-gating-of-stable.rs
// see issue-43106-gating-of-unstable.rs
// see issue-43106-gating-of-deprecated.rs
#![windows_subsystem = "windows"]

// UNGATED CRATE-LEVEL BUILT-IN ATTRIBUTES

#![crate_name = "0900"]
#![crate_type = "bin"] // cannot pass "0800" here

// FIXME(#44232) we should warn that this isn't used.
#![feature(rust1)]
//~^ WARN no longer requires an attribute to enable
//~| NOTE `#[warn(stable_features)]` on by default

// (cannot easily gating state of crate-level #[no_main]; but non crate-level is below at "0400")
#![no_builtins]
#![recursion_limit = "0200"]
#![type_length_limit = "0100"]

// USES OF BUILT-IN ATTRIBUTES IN OTHER ("UNUSUAL") PLACES

#[warn(x5400)]
//~^ WARN unknown lint: `x5400`
mod warn {
    mod inner { #![warn(x5400)] }
    //~^ WARN unknown lint: `x5400`

    #[warn(x5400)] fn f() { }
    //~^ WARN unknown lint: `x5400`

    #[warn(x5400)] struct S;
    //~^ WARN unknown lint: `x5400`

    #[warn(x5400)] type T = S;
    //~^ WARN unknown lint: `x5400`

    #[warn(x5400)] impl S { }
    //~^ WARN unknown lint: `x5400`
}

#[allow(x5300)]
//~^ WARN unknown lint: `x5300`
mod allow {
    mod inner { #![allow(x5300)] }
    //~^ WARN unknown lint: `x5300`

    #[allow(x5300)] fn f() { }
    //~^ WARN unknown lint: `x5300`

    #[allow(x5300)] struct S;
    //~^ WARN unknown lint: `x5300`

    #[allow(x5300)] type T = S;
    //~^ WARN unknown lint: `x5300`

    #[allow(x5300)] impl S { }
    //~^ WARN unknown lint: `x5300`
}

#[forbid(x5200)]
//~^ WARN unknown lint: `x5200`
mod forbid {
    mod inner { #![forbid(x5200)] }
    //~^ WARN unknown lint: `x5200`

    #[forbid(x5200)] fn f() { }
    //~^ WARN unknown lint: `x5200`

    #[forbid(x5200)] struct S;
    //~^ WARN unknown lint: `x5200`

    #[forbid(x5200)] type T = S;
    //~^ WARN unknown lint: `x5200`

    #[forbid(x5200)] impl S { }
    //~^ WARN unknown lint: `x5200`
}

#[deny(x5100)]
//~^ WARN unknown lint: `x5100`
mod deny {
    mod inner { #![deny(x5100)] }
    //~^ WARN unknown lint: `x5100`

    #[deny(x5100)] fn f() { }
    //~^ WARN unknown lint: `x5100`

    #[deny(x5100)] struct S;
    //~^ WARN unknown lint: `x5100`

    #[deny(x5100)] type T = S;
    //~^ WARN unknown lint: `x5100`

    #[deny(x5100)] impl S { }
    //~^ WARN unknown lint: `x5100`
}

#[macro_use]
mod macro_use {
    mod inner { #![macro_use] }

    #[macro_use] fn f() { }
    //~^ WARN attribute cannot be used on
//~| WARN previously accepted
    //~| HELP can be applied to
    //~| HELP remove the attribute

    #[macro_use] struct S;
    //~^ WARN attribute cannot be used on
//~| WARN previously accepted
    //~| HELP can be applied to
    //~| HELP remove the attribute

    #[macro_use] type T = S;
    //~^ WARN attribute cannot be used on
//~| WARN previously accepted
    //~| HELP can be applied to
    //~| HELP remove the attribute

    #[macro_use] impl S { }
    //~^ WARN attribute cannot be used on
//~| WARN previously accepted
    //~| HELP can be applied to
    //~| HELP remove the attribute
}

#[macro_export]
//~^ WARN `#[macro_export]` only has an effect on macro definitions
mod macro_export {
    mod inner { #![macro_export] }
    //~^ WARN `#[macro_export]` only has an effect on macro definitions

    #[macro_export] fn f() { }
    //~^ WARN `#[macro_export]` only has an effect on macro definitions

    #[macro_export] struct S;
    //~^ WARN `#[macro_export]` only has an effect on macro definitions

    #[macro_export] type T = S;
    //~^ WARN `#[macro_export]` only has an effect on macro definitions

    #[macro_export] impl S { }
    //~^ WARN `#[macro_export]` only has an effect on macro definitions
}

// At time of unit test authorship, if compiling without `--test` then
// non-crate-level #[test] attributes seem to be ignored.

#[test]
mod test { mod inner { #![test] }

    fn f() { }

    struct S;

    type T = S;

    impl S { }
}

// At time of unit test authorship, if compiling without `--test` then
// non-crate-level #[bench] attributes seem to be ignored.

#[bench]
mod bench {
    mod inner { #![bench] }

    #[bench]
    struct S;

    #[bench]
    type T = S;

    #[bench]
    impl S { }
}

#[path = "3800"]
mod path {
    mod inner { #![path="3800"] }

    #[path = "3800"] fn f() { }
    //~^ WARN attribute cannot be used on
//~| WARN previously accepted
    //~| HELP can only be applied to
    //~| HELP remove the attribute

    #[path = "3800"]  struct S;
    //~^ WARN attribute cannot be used on
//~| WARN previously accepted
    //~| HELP can only be applied to
    //~| HELP remove the attribute

    #[path = "3800"] type T = S;
    //~^ WARN attribute cannot be used on
//~| WARN previously accepted
    //~| HELP can only be applied to
    //~| HELP remove the attribute

    #[path = "3800"] impl S { }
    //~^ WARN attribute cannot be used on
//~| WARN previously accepted
    //~| HELP can only be applied to
    //~| HELP remove the attribute
}

#[automatically_derived]
//~^ WARN attribute cannot be used on
//~| WARN previously accepted
//~| HELP can only be applied to
//~| HELP remove the attribute
mod automatically_derived {
    mod inner { #![automatically_derived] }
    //~^ WARN attribute cannot be used on
//~| WARN previously accepted
    //~| HELP can only be applied to
    //~| HELP remove the attribute

    #[automatically_derived] fn f() { }
    //~^ WARN attribute cannot be used on
//~| WARN previously accepted
    //~| HELP can only be applied to
    //~| HELP remove the attribute

    #[automatically_derived] struct S;
    //~^ WARN attribute cannot be used on
//~| WARN previously accepted
    //~| HELP can only be applied to
    //~| HELP remove the attribute

    #[automatically_derived] type T = S;
    //~^ WARN attribute cannot be used on
//~| WARN previously accepted
    //~| HELP can only be applied to
    //~| HELP remove the attribute

    #[automatically_derived] trait W { }
    //~^ WARN attribute cannot be used on
//~| WARN previously accepted
    //~| HELP can only be applied to
    //~| HELP remove the attribute

    #[automatically_derived] impl S { }
    //~^ WARN attribute cannot be used on
//~| WARN previously accepted
    //~| HELP can only be applied to
    //~| HELP remove the attribute

    #[automatically_derived] impl W for S { }
}

#[no_mangle]
//~^ WARN attribute cannot be used on
//~| WARN previously accepted
//~| HELP can be applied to
//~| HELP remove the attribute
mod no_mangle {
    mod inner { #![no_mangle] }
    //~^ WARN attribute cannot be used on
//~| WARN previously accepted
    //~| HELP can be applied to
    //~| HELP remove the attribute

    #[no_mangle] fn f() { }

    #[no_mangle] struct S;
    //~^ WARN attribute cannot be used on
//~| WARN previously accepted
    //~| HELP can be applied to
    //~| HELP remove the attribute

    #[no_mangle] type T = S;
    //~^ WARN attribute cannot be used on
//~| WARN previously accepted
    //~| HELP can be applied to
    //~| HELP remove the attribute

    #[no_mangle] impl S { }
    //~^ WARN attribute cannot be used on
//~| WARN previously accepted
    //~| HELP can be applied to
    //~| HELP remove the attribute

    trait Tr {
        #[no_mangle] fn foo();
        //~^ WARN attribute cannot be used on
//~| WARN previously accepted
        //~| HELP can be applied to
        //~| HELP remove the attribute

        #[no_mangle] fn bar() {}
        //~^ WARN attribute cannot be used on
//~| WARN previously accepted
        //~| HELP can be applied to
        //~| HELP remove the attribute
    }
}

#[should_panic]
//~^ WARN attribute cannot be used on
//~| WARN previously accepted
//~| HELP can only be applied to
//~| HELP remove the attribute
mod should_panic {
    mod inner { #![should_panic] }
    //~^ WARN attribute cannot be used on
    //~| WARN previously accepted
    //~| HELP can only be applied to
    //~| HELP remove the attribute

    #[should_panic] fn f() { }

    #[should_panic] struct S;
    //~^ WARN attribute cannot be used on
    //~| WARN previously accepted
    //~| HELP can only be applied to
    //~| HELP remove the attribute

    #[should_panic] type T = S;
    //~^ WARN attribute cannot be used on
    //~| WARN previously accepted
    //~| HELP can only be applied to
    //~| HELP remove the attribute

    #[should_panic] impl S { }
    //~^ WARN attribute cannot be used on
    //~| WARN previously accepted
    //~| HELP can only be applied to
    //~| HELP remove the attribute
}

#[ignore]
//~^ WARN attribute cannot be used on
//~| WARN previously accepted
//~| HELP can only be applied to
//~| HELP remove the attribute
mod ignore {
    mod inner { #![ignore] }
    //~^ WARN attribute cannot be used on
//~| WARN previously accepted
    //~| HELP can only be applied to
    //~| HELP remove the attribute

    #[ignore] fn f() { }

    #[ignore] struct S;
    //~^ WARN attribute cannot be used on
//~| WARN previously accepted
    //~| HELP can only be applied to
    //~| HELP remove the attribute

    #[ignore] type T = S;
    //~^ WARN attribute cannot be used on
//~| WARN previously accepted
    //~| HELP can only be applied to
    //~| HELP remove the attribute

    #[ignore] impl S { }
    //~^ WARN attribute cannot be used on
//~| WARN previously accepted
    //~| HELP can only be applied to
    //~| HELP remove the attribute
}

#[no_implicit_prelude]
mod no_implicit_prelude {
    mod inner { #![no_implicit_prelude] }

    #[no_implicit_prelude] fn f() { }
    //~^ WARN attribute cannot be used on
//~| WARN previously accepted
    //~| HELP can be applied to
    //~| HELP remove the attribute

    #[no_implicit_prelude] struct S;
    //~^ WARN attribute cannot be used on
//~| WARN previously accepted
    //~| HELP can be applied to
    //~| HELP remove the attribute

    #[no_implicit_prelude] type T = S;
    //~^ WARN attribute cannot be used on
//~| WARN previously accepted
    //~| HELP can be applied to
    //~| HELP remove the attribute

    #[no_implicit_prelude] impl S { }
    //~^ WARN attribute cannot be used on
//~| WARN previously accepted
    //~| HELP can be applied to
    //~| HELP remove the attribute
}

#[reexport_test_harness_main = "2900"]
//~^ WARN crate-level attribute should be
//~| HELP add a `!`
mod reexport_test_harness_main {
    mod inner { #![reexport_test_harness_main="2900"] }
    //~^ WARN crate-level attribute should be

    #[reexport_test_harness_main = "2900"] fn f() { }
    //~^ WARN crate-level attribute should be
    //~| HELP add a `!`

    #[reexport_test_harness_main = "2900"] struct S;
    //~^ WARN crate-level attribute should be
    //~| HELP add a `!`

    #[reexport_test_harness_main = "2900"] type T = S;
    //~^ WARN crate-level attribute should be
    //~| HELP add a `!`

    #[reexport_test_harness_main = "2900"] impl S { }
    //~^ WARN crate-level attribute should be
    //~| HELP add a `!`
}

// Cannot feed "2700" to `#[macro_escape]` without signaling an error.
#[macro_escape]
//~^ WARN `#[macro_escape]` is a deprecated synonym for `#[macro_use]`
mod macro_escape {
    mod inner { #![macro_escape] }
    //~^ WARN `#[macro_escape]` is a deprecated synonym for `#[macro_use]`
    //~| HELP try an outer attribute: `#[macro_use]`

    #[macro_escape] fn f() { }
    //~^ WARN attribute cannot be used on
//~| WARN previously accepted
    //~| HELP can be applied to
    //~| HELP remove the attribute

    #[macro_escape] struct S;
    //~^ WARN attribute cannot be used on
//~| WARN previously accepted
    //~| HELP can be applied to
    //~| HELP remove the attribute

    #[macro_escape] type T = S;
    //~^ WARN attribute cannot be used on
//~| WARN previously accepted
    //~| HELP can be applied to
    //~| HELP remove the attribute

    #[macro_escape] impl S { }
    //~^ WARN attribute cannot be used on
//~| WARN previously accepted
    //~| HELP can be applied to
    //~| HELP remove the attribute
}

#[no_std]
//~^ WARN crate-level attribute should be an inner attribute
//~| HELP add a `!`
mod no_std {
    mod inner { #![no_std] }
//~^ WARN crate-level attribute should be in the root module

    #[no_std] fn f() { }
    //~^ WARN crate-level attribute should be an inner attribute
    //~| HELP add a `!`

    #[no_std] struct S;
    //~^ WARN crate-level attribute should be an inner attribute
    //~| HELP add a `!`

    #[no_std] type T = S;
    //~^ WARN crate-level attribute should be an inner attribute
    //~| HELP add a `!`

    #[no_std] impl S { }
    //~^ WARN crate-level attribute should be an inner attribute
    //~| HELP add a `!`
}

// At time of authorship, #[proc_macro_derive = "2500"] signals error
// when it occurs on a mod (apart from crate-level). Therefore it goes
// into its own file; see issue-43106-gating-of-proc_macro_derive.rs

#[doc = "2400"]
mod doc {
    mod inner { #![doc="2400"] }

    #[doc = "2400"] fn f() { }

    #[doc = "2400"] struct S;

    #[doc = "2400"] type T = S;

    #[doc = "2400"] impl S { }
}

#[cold]
//~^ WARN attribute cannot be used on
//~| WARN previously accepted
//~| HELP can only be applied to
//~| HELP remove the attribute
mod cold {

    mod inner { #![cold] }
    //~^ WARN attribute cannot be used on
    //~| WARN previously accepted
    //~| HELP can only be applied to
    //~| HELP remove the attribute

    #[cold] fn f() { }

    #[cold] struct S;
    //~^ WARN attribute cannot be used on
    //~| WARN previously accepted
    //~| HELP can only be applied to
    //~| HELP remove the attribute

    #[cold] type T = S;
    //~^ WARN attribute cannot be used on
    //~| WARN previously accepted
    //~| HELP can only be applied to
    //~| HELP remove the attribute

    #[cold] impl S { }
    //~^ WARN attribute cannot be used on
    //~| WARN previously accepted
    //~| HELP can only be applied to
    //~| HELP remove the attribute
}

#[link_name = "1900"]
//~^ WARN attribute cannot be used on
//~| WARN previously accepted
//~| HELP can be applied to
//~| HELP remove the attribute
mod link_name {
    #[link_name = "1900"]
    //~^ WARN attribute cannot be used on
    //~| WARN previously accepted
    //~| HELP can be applied to
    //~| HELP remove the attribute
    extern "C" { }

    mod inner { #![link_name="1900"] }
    //~^ WARN attribute cannot be used on
    //~| WARN previously accepted
    //~| HELP can be applied to
    //~| HELP remove the attribute

    #[link_name = "1900"] fn f() { }
    //~^ WARN attribute cannot be used on
    //~| WARN previously accepted
    //~| HELP can be applied to
    //~| HELP remove the attribute

    #[link_name = "1900"] struct S;
    //~^ WARN attribute cannot be used on
    //~| WARN previously accepted
    //~| HELP can be applied to
    //~| HELP remove the attribute

    #[link_name = "1900"] type T = S;
    //~^ WARN attribute cannot be used on
    //~| WARN previously accepted
    //~| HELP can be applied to
    //~| HELP remove the attribute

    #[link_name = "1900"] impl S { }
    //~^ WARN attribute cannot be used on
    //~| WARN previously accepted
    //~| HELP can be applied to
    //~| HELP remove the attribute
}

#[link_section = "1800"]
//~^ WARN attribute cannot be used on
//~| WARN previously accepted
//~| HELP can be applied to
//~| HELP remove the attribute
mod link_section {
    mod inner { #![link_section="1800"] }
    //~^ WARN attribute cannot be used on
    //~| WARN previously accepted
    //~| HELP can be applied to
    //~| HELP remove the attribute

    #[link_section = "1800"] fn f() { }

    #[link_section = "1800"] struct S;
    //~^ WARN attribute cannot be used on
    //~| WARN previously accepted
    //~| HELP can be applied to
    //~| HELP remove the attribute

    #[link_section = "1800"] type T = S;
    //~^ WARN attribute cannot be used on
    //~| WARN previously accepted
    //~| HELP can be applied to
    //~| HELP remove the attribute

    #[link_section = "1800"] impl S { }
    //~^ WARN attribute cannot be used on
    //~| WARN previously accepted
    //~| HELP can be applied to
    //~| HELP remove the attribute
}


// Note that this is a `check-pass` test, so it will never invoke the linker.

#[link(name = "x")]
//~^ WARN attribute should be applied to an `extern` block
//~| WARN this was previously accepted
mod link {
    //~^ NOTE not an `extern` block

    mod inner { #![link(name = "x")] }
    //~^ WARN attribute should be applied to an `extern` block
    //~| WARN this was previously accepted
    //~| NOTE not an `extern` block

    #[link(name = "x")] fn f() { }
    //~^ WARN attribute should be applied to an `extern` block
    //~| WARN this was previously accepted
    //~| NOTE not an `extern` block

    #[link(name = "x")] struct S;
    //~^ WARN attribute should be applied to an `extern` block
    //~| WARN this was previously accepted
    //~| NOTE not an `extern` block

    #[link(name = "x")] type T = S;
    //~^ WARN attribute should be applied to an `extern` block
    //~| WARN this was previously accepted
    //~| NOTE not an `extern` block

    #[link(name = "x")] impl S { }
    //~^ WARN attribute should be applied to an `extern` block
    //~| WARN this was previously accepted
    //~| NOTE not an `extern` block

    #[link(name = "x")] extern "Rust" {}
    //~^ WARN attribute should be applied to an `extern` block
    //~| WARN this was previously accepted
}

struct StructForDeprecated;

#[deprecated]
mod deprecated {
    mod inner { #![deprecated] }

    #[deprecated] fn f() { }

    #[deprecated] struct S1;

    #[deprecated] type T = super::StructForDeprecated;

    #[deprecated] impl super::StructForDeprecated { }
}

#[must_use] //~ WARN attribute cannot be used on
//~| WARN previously accepted
//~| HELP can be applied to
//~| HELP remove the attribute
mod must_use {
    mod inner { #![must_use] } //~ WARN attribute cannot be used on
    //~| WARN previously accepted
    //~| HELP can be applied to
    //~| HELP remove the attribute

    #[must_use] fn f() { }

    #[must_use] struct S;

    #[must_use] type T = S; //~ WARN attribute cannot be used on
    //~| WARN previously accepted
    //~| HELP can be applied to
    //~| HELP remove the attribute

    #[must_use] impl S { } //~ WARN attribute cannot be used on
    //~| WARN previously accepted
    //~| HELP can be applied to
    //~| HELP remove the attribute
}

#[windows_subsystem = "windows"]
//~^ WARN crate-level attribute should be an inner attribute
//~| HELP add a `!`
mod windows_subsystem {
    mod inner { #![windows_subsystem="windows"] }
    //~^ WARN crate-level attribute should be in the root module

    #[windows_subsystem = "windows"] fn f() { }
    //~^ WARN crate-level attribute should be an inner attribute
    //~| HELP add a `!`

    #[windows_subsystem = "windows"] struct S;
    //~^ WARN crate-level attribute should be an inner attribute
    //~| HELP add a `!`

    #[windows_subsystem = "windows"] type T = S;
    //~^ WARN crate-level attribute should be an inner attribute
    //~| HELP add a `!`

    #[windows_subsystem = "windows"] impl S { }
    //~^ WARN crate-level attribute should be an inner attribute
    //~| HELP add a `!`
}

// BROKEN USES OF CRATE-LEVEL BUILT-IN ATTRIBUTES

#[crate_name = "0900"]
//~^ WARN crate-level attribute should be an inner attribute
mod crate_name {
//~^ NOTE This attribute does not have an `!`, which means it is applied to this module
    mod inner { #![crate_name="0900"] }
//~^ WARN the `#![crate_name]` attribute can only be used at the crate root

    #[crate_name = "0900"] fn f() { }
    //~^ WARN crate-level attribute should be an inner attribute
    //~| NOTE This attribute does not have an `!`, which means it is applied to this function

    #[crate_name = "0900"] struct S;
    //~^ WARN crate-level attribute should be an inner attribute
    //~| NOTE This attribute does not have an `!`, which means it is applied to this struct

    #[crate_name = "0900"] type T = S;
    //~^ WARN crate-level attribute should be an inner attribute
    //~| NOTE This attribute does not have an `!`, which means it is applied to this type alias

    #[crate_name = "0900"] impl S { }
    //~^ WARN crate-level attribute should be an inner attribute
    //~| NOTE This attribute does not have an `!`, which means it is applied to this implementation block
}

#[crate_type = "0800"]
//~^ WARN crate-level attribute should be an inner attribute
//~| HELP add a `!`
mod crate_type {
    mod inner { #![crate_type="0800"] }
//~^ WARN crate-level attribute should be in the root module

    #[crate_type = "0800"] fn f() { }
    //~^ WARN crate-level attribute should be an inner attribute
    //~| HELP add a `!`

    #[crate_type = "0800"] struct S;
    //~^ WARN crate-level attribute should be an inner attribute
    //~| HELP add a `!`

    #[crate_type = "0800"] type T = S;
    //~^ WARN crate-level attribute should be an inner attribute
    //~| HELP add a `!`

    #[crate_type = "0800"] impl S { }
    //~^ WARN crate-level attribute should be an inner attribute
    //~| HELP add a `!`
}

#[feature(x0600)]
//~^ WARN crate-level attribute should be an inner attribute
//~| HELP add a `!`
mod feature {
    mod inner { #![feature(x0600)] }
//~^ WARN crate-level attribute should be in the root module

    #[feature(x0600)] fn f() { }
    //~^ WARN crate-level attribute should be an inner attribute
    //~| HELP add a `!`

    #[feature(x0600)] struct S;
    //~^ WARN crate-level attribute should be an inner attribute
    //~| HELP add a `!`

    #[feature(x0600)] type T = S;
    //~^ WARN crate-level attribute should be an inner attribute
    //~| HELP add a `!`

    #[feature(x0600)] impl S { }
    //~^ WARN crate-level attribute should be an inner attribute
    //~| HELP add a `!`
}


#[no_main]
//~^ WARN crate-level attribute should be an inner attribute
//~| HELP add a `!`
mod no_main_1 {
    mod inner { #![no_main] }
//~^ WARN crate-level attribute should be in the root module

    #[no_main] fn f() { }
    //~^ WARN crate-level attribute should be an inner attribute
    //~| HELP add a `!`

    #[no_main] struct S;
    //~^ WARN crate-level attribute should be an inner attribute
    //~| HELP add a `!`

    #[no_main] type T = S;
    //~^ WARN crate-level attribute should be an inner attribute
    //~| HELP add a `!`

    #[no_main] impl S { }
    //~^ WARN crate-level attribute should be an inner attribute
    //~| HELP add a `!`
}

#[no_builtins]
//~^ WARN crate-level attribute should be an inner attribute
//~| HELP add a `!`
mod no_builtins {
    mod inner { #![no_builtins] }
    //~^ WARN crate-level attribute should be in the root module

    #[no_builtins] fn f() { }
    //~^ WARN crate-level attribute should be an inner attribute
    //~| HELP add a `!`

    #[no_builtins] struct S;
    //~^ WARN crate-level attribute should be an inner attribute
    //~| HELP add a `!`

    #[no_builtins] type T = S;
    //~^ WARN crate-level attribute should be an inner attribute
    //~| HELP add a `!`

    #[no_builtins] impl S { }
    //~^ WARN crate-level attribute should be an inner attribute
    //~| HELP add a `!`
}

#[recursion_limit="0200"]
//~^ WARN crate-level attribute should be an inner attribute
mod recursion_limit {
    //~^ NOTE This attribute does not have an `!`, which means it is applied to this module
    mod inner { #![recursion_limit="0200"] }
//~^ WARN the `#![recursion_limit]` attribute can only be used at the crate root

    #[recursion_limit="0200"] fn f() { }
    //~^ WARN crate-level attribute should be an inner attribute
    //~| NOTE This attribute does not have an `!`, which means it is applied to this function

    #[recursion_limit="0200"] struct S;
    //~^ WARN crate-level attribute should be an inner attribute
    //~| NOTE This attribute does not have an `!`, which means it is applied to this struct

    #[recursion_limit="0200"] type T = S;
    //~^ WARN crate-level attribute should be an inner attribute
    //~| NOTE This attribute does not have an `!`, which means it is applied to this type alias

    #[recursion_limit="0200"] impl S { }
    //~^ WARN crate-level attribute should be an inner attribute
    //~| NOTE This attribute does not have an `!`, which means it is applied to this implementation block
}

#[type_length_limit="0100"]
//~^ WARN crate-level attribute should be an inner attribute
mod type_length_limit {
    //~^ NOTE This attribute does not have an `!`, which means it is applied to this module
    mod inner { #![type_length_limit="0100"] }
//~^ WARN the `#![type_length_limit]` attribute can only be used at the crate root

    #[type_length_limit="0100"] fn f() { }
    //~^ WARN crate-level attribute should be an inner attribute
    //~| NOTE This attribute does not have an `!`, which means it is applied to this function

    #[type_length_limit="0100"] struct S;
    //~^ WARN crate-level attribute should be an inner attribute
    //~| NOTE This attribute does not have an `!`, which means it is applied to this struct

    #[type_length_limit="0100"] type T = S;
    //~^ WARN crate-level attribute should be an inner attribute
    //~| NOTE This attribute does not have an `!`, which means it is applied to this type alias

    #[type_length_limit="0100"] impl S { }
    //~^ WARN crate-level attribute should be an inner attribute
    //~| NOTE This attribute does not have an `!`, which means it is applied to this implementation block
}

fn main() {}