]> git.lizzy.rs Git - rust.git/blob - src/test/compile-fail/feature-gate/issue-43106-gating-of-builtin-attrs.rs
204190d64acc1f61a33a02b7e02a510c52ce464d
[rust.git] / src / test / compile-fail / feature-gate / issue-43106-gating-of-builtin-attrs.rs
1 // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // This test enumerates as many compiler-builtin ungated attributes as
12 // possible (that is, all the mutually compatible ones), and checks
13 // that we get "expected" (*) warnings for each in the various weird
14 // places that users might put them in the syntax.
15 //
16 // (*): The word "expected" is in quotes above because the cases where
17 // warnings are and are not emitted might not match a user's intuition
18 // nor the rustc developers' intent. I am really just trying to
19 // capture today's behavior in a test, not so that it become enshrined
20 // as the absolute behavior going forward, but rather so that we do
21 // not change the behavior in the future without even being *aware* of
22 // the change when it happens.
23 //
24 // At the time of authoring, the attributes here are listed in the
25 // order that they occur in libsyntax/feature_gate.rs.
26 //
27 // Any builtin attributes that:
28 //
29 //  - are not stable, or
30 //
31 //  - could not be included here covering the same cases as the other
32 //    attributes without raising an *error* from rustc (note though
33 //    that warnings are of course expected)
34 //
35 // have their own test case referenced by filename in an inline
36 // comment.
37 //
38 // The test feeds numeric inputs to each attribute that accepts them
39 // without error. We do this for two reasons: (1.) to exercise how
40 // inputs are handled by each, and (2.) to ease searching for related
41 // occurrences in the source text.
42
43 #![feature(rustc_attrs)] // For `rustc_error`; see note below.
44 #![warn(unused_attributes, unknown_lints)]
45 #![allow(dead_code)]
46
47 // UNGATED WHITE-LISTED BUILT-IN ATTRIBUTES
48
49 #![warn                        (x5400)] //~ WARN unknown lint: `x5400`
50 #![allow                       (x5300)] //~ WARN unknown lint: `x5300`
51 #![forbid                      (x5200)] //~ WARN unknown lint: `x5200`
52 #![deny                        (x5100)] //~ WARN unknown lint: `x5100`
53 #![macro_reexport             = "5000"] //~ WARN unused attribute
54 #![macro_use] // (allowed if no argument; see issue-43160-gating-of-macro_use.rs)
55 #![macro_export               = "4800"] //~ WARN unused attribute
56 #![plugin_registrar           = "4700"] //~ WARN unused attribute
57 // skipping testing of cfg
58 // skipping testing of cfg_attr
59 #![main                      = "x4400"] //~ WARN unused attribute
60 #![start                     = "x4300"] //~ WARN unused attribute
61 // see issue-43106-gating-of-test.rs for crate-level; but non crate-level is below at "4200"
62 // see issue-43106-gating-of-bench.rs for crate-level; but non crate-level is below at "4100"
63 #![simd                       = "4000"] //~ WARN unused attribute
64 #![repr                       = "3900"] //~ WARN unused attribute
65 #![path                       = "3800"] //~ WARN unused attribute
66 #![abi                        = "3700"] //~ WARN unused attribute
67 #![automatically_derived      = "3600"] //~ WARN unused attribute
68 #![no_mangle                  = "3500"]
69 #![no_link                    = "3400"] //~ WARN unused attribute
70 // see issue-43106-gating-of-derive.rs
71 #![should_panic               = "3200"] //~ WARN unused attribute
72 #![ignore                     = "3100"] //~ WARN unused attribute
73 #![no_implicit_prelude        = "3000"]
74 #![reexport_test_harness_main = "2900"]
75 // see gated-link-args.rs
76 // see issue-43106-gating-of-macro_escape.rs for crate-level; but non crate-level is below at "2700"
77 // (cannot easily test gating of crate-level #[no_std]; but non crate-level is below at "2600")
78 #![proc_macro_derive          = "2500"] //~ WARN unused attribute
79 #![doc                        = "2400"]
80 #![cold                       = "2300"]
81 #![export_name                = "2200"]
82 // see issue-43106-gating-of-inline.rs
83 #![link                       = "2000"]
84 #![link_name                  = "1900"]
85 #![link_section               = "1800"]
86 #![no_builtins                = "1700"] // Yikes, dupe'd on BUILTIN_ATTRIBUTES list (see "0300")
87 #![no_mangle                  = "1600"] // Yikes, dupe'd on BUILTIN_ATTRIBUTES list (see "3500")
88 // see issue-43106-gating-of-rustc_deprecated.rs
89 #![must_use                   = "1400"]
90 // see issue-43106-gating-of-stable.rs
91 // see issue-43106-gating-of-unstable.rs
92 // see issue-43106-gating-of-deprecated.rs
93 #![windows_subsystem          = "1000"]
94
95 // UNGATED CRATE-LEVEL BUILT-IN ATTRIBUTES
96
97 #![crate_name                 = "0900"]
98 #![crate_type                 = "bin"] // cannot pass "0800" here
99
100 // For #![crate_id], see issue #43142. (I cannot bear to enshrine current behavior in a test)
101
102 #![feature                    ( x0600)] //~ WARN unused or unknown feature
103
104 // For #![no_start], see issue #43144. (I cannot bear to enshrine current behavior in a test)
105
106 // (cannot easily gating state of crate-level #[no_main]; but non crate-level is below at "0400")
107 #![no_builtins                = "0300"]
108 #![recursion_limit            = "0200"]
109 #![type_length_limit          = "0100"]
110
111 // USES OF BUILT-IN ATTRIBUTES IN OTHER ("UNUSUAL") PLACES
112
113 #[warn(x5400)]
114 //~^ WARN unknown lint: `x5400`
115 mod warn {
116     mod inner { #![warn(x5400)] }
117     //~^ WARN unknown lint: `x5400`
118
119     #[warn(x5400)] fn f() { }
120     //~^ WARN unknown lint: `x5400`
121
122     #[warn(x5400)] struct S;
123     //~^ WARN unknown lint: `x5400`
124
125     #[warn(x5400)] type T = S;
126     //~^ WARN unknown lint: `x5400`
127
128     #[warn(x5400)] impl S { }
129     //~^ WARN unknown lint: `x5400`
130 }
131
132 #[allow(x5300)]
133 //~^ WARN unknown lint: `x5300`
134 mod allow {
135     mod inner { #![allow(x5300)] }
136     //~^ WARN unknown lint: `x5300`
137
138     #[allow(x5300)] fn f() { }
139     //~^ WARN unknown lint: `x5300`
140
141     #[allow(x5300)] struct S;
142     //~^ WARN unknown lint: `x5300`
143
144     #[allow(x5300)] type T = S;
145     //~^ WARN unknown lint: `x5300`
146
147     #[allow(x5300)] impl S { }
148     //~^ WARN unknown lint: `x5300`
149 }
150
151 #[forbid(x5200)]
152 //~^ WARN unknown lint: `x5200`
153 mod forbid {
154     mod inner { #![forbid(x5200)] }
155     //~^ WARN unknown lint: `x5200`
156
157     #[forbid(x5200)] fn f() { }
158     //~^ WARN unknown lint: `x5200`
159
160     #[forbid(x5200)] struct S;
161     //~^ WARN unknown lint: `x5200`
162
163     #[forbid(x5200)] type T = S;
164     //~^ WARN unknown lint: `x5200`
165
166     #[forbid(x5200)] impl S { }
167     //~^ WARN unknown lint: `x5200`
168 }
169
170 #[deny(x5100)]
171 //~^ WARN unknown lint: `x5100`
172 mod deny {
173     mod inner { #![deny(x5100)] }
174     //~^ WARN unknown lint: `x5100`
175
176     #[deny(x5100)] fn f() { }
177     //~^ WARN unknown lint: `x5100`
178
179     #[deny(x5100)] struct S;
180     //~^ WARN unknown lint: `x5100`
181
182     #[deny(x5100)] type T = S;
183     //~^ WARN unknown lint: `x5100`
184
185     #[deny(x5100)] impl S { }
186     //~^ WARN unknown lint: `x5100`
187 }
188
189 #[macro_reexport = "5000"]
190 //~^ WARN unused attribute
191 mod macro_reexport {
192     mod inner { #![macro_reexport="5000"] }
193     //~^ WARN unused attribute
194
195     #[macro_reexport = "5000"] fn f() { }
196     //~^ WARN unused attribute
197
198     #[macro_reexport = "5000"] struct S;
199     //~^ WARN unused attribute
200
201     #[macro_reexport = "5000"] type T = S;
202     //~^ WARN unused attribute
203
204     #[macro_reexport = "5000"] impl S { }
205     //~^ WARN unused attribute
206 }
207
208 #[macro_use]
209 mod macro_use {
210     mod inner { #![macro_use] }
211
212     #[macro_use] fn f() { }
213     //~^ WARN unused attribute
214
215     #[macro_use] struct S;
216     //~^ WARN unused attribute
217
218     #[macro_use] type T = S;
219     //~^ WARN unused attribute
220
221     #[macro_use] impl S { }
222     //~^ WARN unused attribute
223 }
224
225 #[macro_export = "4800"]
226 //~^ WARN unused attribute
227 mod macro_export {
228     mod inner { #![macro_export="4800"] }
229     //~^ WARN unused attribute
230
231     #[macro_export = "4800"] fn f() { }
232     //~^ WARN unused attribute
233
234     #[macro_export = "4800"] struct S;
235     //~^ WARN unused attribute
236
237     #[macro_export = "4800"] type T = S;
238     //~^ WARN unused attribute
239
240     #[macro_export = "4800"] impl S { }
241     //~^ WARN unused attribute
242 }
243
244 #[plugin_registrar = "4700"]
245 //~^ WARN unused attribute
246 mod plugin_registrar {
247     mod inner { #![plugin_registrar="4700"] }
248     //~^ WARN unused attribute
249
250     // for `fn f()` case, see gated-plugin_registrar.rs
251
252     #[plugin_registrar = "4700"] struct S;
253     //~^ WARN unused attribute
254
255     #[plugin_registrar = "4700"] type T = S;
256     //~^ WARN unused attribute
257
258     #[plugin_registrar = "4700"] impl S { }
259     //~^ WARN unused attribute
260 }
261
262 #[main = "4400"]
263 //~^ WARN unused attribute
264 mod main {
265     mod inner { #![main="4300"] }
266     //~^ WARN unused attribute
267
268     // for `fn f()` case, see feature-gate-main.rs
269
270     #[main = "4400"] struct S;
271     //~^ WARN unused attribute
272
273     #[main = "4400"] type T = S;
274     //~^ WARN unused attribute
275
276     #[main = "4400"] impl S { }
277     //~^ WARN unused attribute
278 }
279
280 #[start = "4300"]
281 //~^ WARN unused attribute
282 mod start {
283     mod inner { #![start="4300"] }
284     //~^ WARN unused attribute
285
286     // for `fn f()` case, see feature-gate-start.rs
287
288     #[start = "4300"] struct S;
289     //~^ WARN unused attribute
290
291     #[start = "4300"] type T = S;
292     //~^ WARN unused attribute
293
294     #[start = "4300"] impl S { }
295     //~^ WARN unused attribute
296 }
297
298 // At time of unit test authorship, if compiling without `--test` then
299 // non-crate-level #[test] attributes seem to be ignored.
300
301 #[test = "4200"]
302 mod test { mod inner { #![test="4200"] }
303
304     fn f() { }
305
306     struct S;
307
308     type T = S;
309
310     impl S { }
311 }
312
313 // At time of unit test authorship, if compiling without `--test` then
314 // non-crate-level #[bench] attributes seem to be ignored.
315
316 #[bench = "4100"]
317 mod bench {
318     mod inner { #![bench="4100"] }
319
320     #[bench = "4100"]
321     struct S;
322
323     #[bench = "4100"]
324     type T = S;
325
326     #[bench = "4100"]
327     impl S { }
328 }
329
330 #[simd = "4000"]
331 //~^ WARN unused attribute
332 mod simd {
333     mod inner { #![simd="4000"] }
334     //~^ WARN unused attribute
335
336     #[simd = "4000"] fn f() { }
337     //~^ WARN unused attribute
338
339     struct S; // for `struct S` case, see feature-gate-repr-simd.rs
340
341     #[simd = "4000"] type T = S;
342     //~^ WARN unused attribute
343
344     #[simd = "4000"] impl S { }
345     //~^ WARN unused attribute
346 }
347
348 #[repr = "3900"]
349 //~^ WARN unused attribute
350 mod repr {
351     mod inner { #![repr="3900"] }
352     //~^ WARN unused attribute
353
354     #[repr = "3900"] fn f() { }
355     //~^ WARN unused attribute
356
357     #[repr = "3900"] struct S;
358     //~^ WARN unused attribute
359
360     #[repr = "3900"] type T = S;
361     //~^ WARN unused attribute
362
363     #[repr = "3900"] impl S { }
364     //~^ WARN unused attribute
365 }
366
367 #[path = "3800"]
368 mod path {
369     mod inner { #![path="3800"] }
370
371     #[path = "3800"] fn f() { }
372     //~^ WARN unused attribute
373
374     #[path = "3800"]  struct S;
375     //~^ WARN unused attribute
376
377     #[path = "3800"] type T = S;
378     //~^ WARN unused attribute
379
380     #[path = "3800"] impl S { }
381     //~^ WARN unused attribute
382 }
383
384 #[abi = "3700"]
385 //~^ WARN unused attribute
386 mod abi {
387     mod inner { #![abi="3700"] }
388     //~^ WARN unused attribute
389
390     #[abi = "3700"] fn f() { }
391     //~^ WARN unused attribute
392
393     #[abi = "3700"] struct S;
394     //~^ WARN unused attribute
395
396     #[abi = "3700"] type T = S;
397     //~^ WARN unused attribute
398
399     #[abi = "3700"] impl S { }
400     //~^ WARN unused attribute
401 }
402
403 #[automatically_derived = "3600"]
404 //~^ WARN unused attribute
405 mod automatically_derived {
406     mod inner { #![automatically_derived="3600"] }
407     //~^ WARN unused attribute
408
409     #[automatically_derived = "3600"] fn f() { }
410     //~^ WARN unused attribute
411
412     #[automatically_derived = "3600"] struct S;
413     //~^ WARN unused attribute
414
415     #[automatically_derived = "3600"] type T = S;
416     //~^ WARN unused attribute
417
418     #[automatically_derived = "3600"] impl S { }
419     //~^ WARN unused attribute
420 }
421
422 #[no_mangle = "3500"]
423 mod no_mangle {
424     mod inner { #![no_mangle="3500"] }
425
426     #[no_mangle = "3500"] fn f() { }
427     //~^ WARN function f is marked #[no_mangle], but not exported
428
429     #[no_mangle = "3500"] struct S;
430
431     #[no_mangle = "3500"] type T = S;
432
433     #[no_mangle = "3500"] impl S { }
434 }
435
436 #[no_link = "3400"]
437 //~^ WARN unused attribute
438 mod no_link {
439     mod inner { #![no_link="3400"] }
440     //~^ WARN unused attribute
441
442     #[no_link = "3400"] fn f() { }
443     //~^ WARN unused attribute
444
445     #[no_link = "3400"] struct S;
446     //~^ WARN unused attribute
447
448     #[no_link = "3400"]type T = S;
449     //~^ WARN unused attribute
450
451     #[no_link = "3400"] impl S { }
452     //~^ WARN unused attribute
453 }
454
455 #[should_panic = "3200"]
456 //~^ WARN unused attribute
457 mod should_panic {
458     mod inner { #![should_panic="3200"] }
459     //~^ WARN unused attribute
460
461     #[should_panic = "3200"] fn f() { }
462     //~^ WARN unused attribute
463
464     #[should_panic = "3200"] struct S;
465     //~^ WARN unused attribute
466
467     #[should_panic = "3200"] type T = S;
468     //~^ WARN unused attribute
469
470     #[should_panic = "3200"] impl S { }
471     //~^ WARN unused attribute
472 }
473
474 #[ignore = "3100"]
475 //~^ WARN unused attribute
476 mod ignore {
477     mod inner { #![ignore="3100"] }
478     //~^ WARN unused attribute
479
480     #[ignore = "3100"] fn f() { }
481     //~^ WARN unused attribute
482
483     #[ignore = "3100"] struct S;
484     //~^ WARN unused attribute
485
486     #[ignore = "3100"] type T = S;
487     //~^ WARN unused attribute
488
489     #[ignore = "3100"] impl S { }
490     //~^ WARN unused attribute
491 }
492
493 #[no_implicit_prelude = "3000"]
494 //~^ WARN unused attribute
495 mod no_implicit_prelude {
496     mod inner { #![no_implicit_prelude="3000"] }
497     //~^ WARN unused attribute
498
499     #[no_implicit_prelude = "3000"] fn f() { }
500     //~^ WARN unused attribute
501
502     #[no_implicit_prelude = "3000"] struct S;
503     //~^ WARN unused attribute
504
505     #[no_implicit_prelude = "3000"] type T = S;
506     //~^ WARN unused attribute
507
508     #[no_implicit_prelude = "3000"] impl S { }
509     //~^ WARN unused attribute
510 }
511
512 #[reexport_test_harness_main = "2900"]
513 //~^ WARN unused attribute
514 mod reexport_test_harness_main {
515     mod inner { #![reexport_test_harness_main="2900"] }
516     //~^ WARN unused attribute
517
518     #[reexport_test_harness_main = "2900"] fn f() { }
519     //~^ WARN unused attribute
520
521     #[reexport_test_harness_main = "2900"] struct S;
522     //~^ WARN unused attribute
523
524     #[reexport_test_harness_main = "2900"] type T = S;
525     //~^ WARN unused attribute
526
527     #[reexport_test_harness_main = "2900"] impl S { }
528     //~^ WARN unused attribute
529 }
530
531 // Cannnot feed "2700" to `#[macro_escape]` without signaling an error.
532 #[macro_escape]
533 //~^ WARN macro_escape is a deprecated synonym for macro_use
534 mod macro_escape {
535     mod inner { #![macro_escape] }
536     //~^ WARN macro_escape is a deprecated synonym for macro_use
537
538     #[macro_escape] fn f() { }
539     //~^ WARN unused attribute
540
541     #[macro_escape] struct S;
542     //~^ WARN unused attribute
543
544     #[macro_escape] type T = S;
545     //~^ WARN unused attribute
546
547     #[macro_escape] impl S { }
548     //~^ WARN unused attribute
549 }
550
551 #[no_std = "2600"]
552 //~^ WARN unused attribute
553 //~| WARN crate-level attribute should be an inner attribute
554 mod no_std {
555     mod inner { #![no_std="2600"] }
556     //~^ WARN unused attribute
557     //~| WARN crate-level attribute should be in the root module
558
559     #[no_std = "2600"] fn f() { }
560     //~^ WARN unused attribute
561     //~| WARN crate-level attribute should be an inner attribute
562
563     #[no_std = "2600"] struct S;
564     //~^ WARN unused attribute
565     //~| WARN crate-level attribute should be an inner attribute
566
567     #[no_std = "2600"] type T = S;
568     //~^ WARN unused attribute
569     //~| WARN crate-level attribute should be an inner attribute
570
571     #[no_std = "2600"] impl S { }
572     //~^ WARN unused attribute
573     //~| WARN crate-level attribute should be an inner attribute
574 }
575
576 // At time of authorship, #[proc_macro_derive = "2500"] signals error
577 // when it occurs on a mod (apart from crate-level). Therefore it goes
578 // into its own file; see issue-43106-gating-of-proc_macro_derive.rs
579
580 #[doc = "2400"]
581 mod doc {
582     mod inner { #![doc="2400"] }
583
584     #[doc = "2400"] fn f() { }
585
586     #[doc = "2400"] struct S;
587
588     #[doc = "2400"] type T = S;
589
590     #[doc = "2400"] impl S { }
591 }
592
593 #[cold = "2300"]
594 mod cold {
595     mod inner { #![cold="2300"] }
596
597     #[cold = "2300"] fn f() { }
598
599     #[cold = "2300"] struct S;
600
601     #[cold = "2300"] type T = S;
602
603     #[cold = "2300"] impl S { }
604 }
605
606 #[export_name = "2200"]
607 mod export_name {
608     mod inner { #![export_name="2200"] }
609
610     #[export_name = "2200"] fn f() { }
611
612     #[export_name = "2200"] struct S;
613
614     #[export_name = "2200"] type T = S;
615
616     #[export_name = "2200"] impl S { }
617 }
618
619 // Note that this test ends with a `#[rustc_error] fn main()`, so it
620 // will never invoke the linker. These are here nonetheless to point
621 // out that we allow them at non-crate-level (though I do not know
622 // whether they have the same effect here as at crate-level).
623
624 #[link = "2000"]
625 mod link {
626     mod inner { #![link="2000"] }
627
628     #[link = "2000"] fn f() { }
629
630     #[link = "2000"] struct S;
631
632     #[link = "2000"] type T = S;
633
634     #[link = "2000"] impl S { }
635 }
636
637 #[link_name = "1900"]
638 mod link_name {
639     mod inner { #![link_name="1900"] }
640
641     #[link_name = "1900"] fn f() { }
642
643     #[link_name = "1900"] struct S;
644
645     #[link_name = "1900"] type T = S;
646
647     #[link_name = "1900"] impl S { }
648 }
649
650 #[link_section = "1800"]
651 mod link_section {
652     mod inner { #![link_section="1800"] }
653
654     #[link_section = "1800"] fn f() { }
655
656     #[link_section = "1800"] struct S;
657
658     #[link_section = "1800"] type T = S;
659
660     #[link_section = "1800"] impl S { }
661 }
662
663 struct StructForDeprecated;
664
665 #[deprecated = "1500"]
666 mod deprecated {
667     mod inner { #![deprecated="1500"] }
668
669     #[deprecated = "1500"] fn f() { }
670
671     #[deprecated = "1500"] struct S1;
672
673     #[deprecated = "1500"] type T = super::StructForDeprecated;
674
675     #[deprecated = "1500"] impl super::StructForDeprecated { }
676 }
677
678 #[must_use = "1400"]
679 mod must_use {
680     mod inner { #![must_use="1400"] }
681
682     #[must_use = "1400"] fn f() { }
683     //~^ WARN `#[must_use]` on functions is experimental
684
685     #[must_use = "1400"] struct S;
686
687     #[must_use = "1400"] type T = S;
688
689     #[must_use = "1400"] impl S { }
690 }
691
692 #[windows_subsystem = "1000"]
693 mod windows_subsystem {
694     mod inner { #![windows_subsystem="1000"] }
695
696     #[windows_subsystem = "1000"] fn f() { }
697
698     #[windows_subsystem = "1000"] struct S;
699
700     #[windows_subsystem = "1000"] type T = S;
701
702     #[windows_subsystem = "1000"] impl S { }
703 }
704
705 // BROKEN USES OF CRATE-LEVEL BUILT-IN ATTRIBUTES
706
707 #[crate_name = "0900"]
708 //~^ WARN unused attribute
709 //~| WARN crate-level attribute should be an inner attribute
710 mod crate_name {
711     mod inner { #![crate_name="0900"] }
712     //~^ WARN unused attribute
713     //~| WARN crate-level attribute should be in the root module
714
715     #[crate_name = "0900"] fn f() { }
716     //~^ WARN unused attribute
717     //~| WARN crate-level attribute should be an inner attribute
718
719     #[crate_name = "0900"] struct S;
720     //~^ WARN unused attribute
721     //~| WARN crate-level attribute should be an inner attribute
722
723     #[crate_name = "0900"] type T = S;
724     //~^ WARN unused attribute
725     //~| WARN crate-level attribute should be an inner attribute
726
727     #[crate_name = "0900"] impl S { }
728     //~^ WARN unused attribute
729     //~| WARN crate-level attribute should be an inner attribute
730 }
731
732 #[crate_type = "0800"]
733 //~^ WARN unused attribute
734 //~| WARN crate-level attribute should be an inner attribute
735 mod crate_type {
736     mod inner { #![crate_type="0800"] }
737     //~^ WARN unused attribute
738     //~| WARN crate-level attribute should be in the root module
739
740     #[crate_type = "0800"] fn f() { }
741     //~^ WARN unused attribute
742     //~| WARN crate-level attribute should be an inner attribute
743
744     #[crate_type = "0800"] struct S;
745     //~^ WARN unused attribute
746     //~| WARN crate-level attribute should be an inner attribute
747
748     #[crate_type = "0800"] type T = S;
749     //~^ WARN unused attribute
750     //~| WARN crate-level attribute should be an inner attribute
751
752     #[crate_type = "0800"] impl S { }
753     //~^ WARN unused attribute
754     //~| WARN crate-level attribute should be an inner attribute
755 }
756
757 #[feature(x0600)]
758 //~^ WARN unused attribute
759 //~| WARN crate-level attribute should be an inner attribute
760 mod feature {
761     mod inner { #![feature(x0600)] }
762     //~^ WARN unused attribute
763     //~| WARN crate-level attribute should be in the root module
764
765     #[feature(x0600)] fn f() { }
766     //~^ WARN unused attribute
767     //~| WARN crate-level attribute should be an inner attribute
768
769     #[feature(x0600)] struct S;
770     //~^ WARN unused attribute
771     //~| WARN crate-level attribute should be an inner attribute
772
773     #[feature(x0600)] type T = S;
774     //~^ WARN unused attribute
775     //~| WARN crate-level attribute should be an inner attribute
776
777     #[feature(x0600)] impl S { }
778     //~^ WARN unused attribute
779     //~| WARN crate-level attribute should be an inner attribute
780 }
781
782
783 #[no_main = "0400"]
784 //~^ WARN unused attribute
785 //~| WARN crate-level attribute should be an inner attribute
786 mod no_main_1 {
787     mod inner { #![no_main="0400"] }
788     //~^ WARN unused attribute
789     //~| WARN crate-level attribute should be in the root module
790
791     #[no_main = "0400"] fn f() { }
792     //~^ WARN unused attribute
793     //~| WARN crate-level attribute should be an inner attribute
794
795     #[no_main = "0400"] struct S;
796     //~^ WARN unused attribute
797     //~| WARN crate-level attribute should be an inner attribute
798
799     #[no_main = "0400"] type T = S;
800     //~^ WARN unused attribute
801     //~| WARN crate-level attribute should be an inner attribute
802
803     #[no_main = "0400"] impl S { }
804     //~^ WARN unused attribute
805     //~| WARN crate-level attribute should be an inner attribute
806 }
807
808 #[no_builtins = "0300"]
809 mod no_builtins {
810     mod inner { #![no_builtins="0200"] }
811
812     #[no_builtins = "0300"] fn f() { }
813
814     #[no_builtins = "0300"] struct S;
815
816     #[no_builtins = "0300"] type T = S;
817
818     #[no_builtins = "0300"] impl S { }
819 }
820
821 #[recursion_limit="0200"]
822 //~^ WARN unused attribute
823 //~| WARN crate-level attribute should be an inner attribute
824 mod recursion_limit {
825     mod inner { #![recursion_limit="0200"] }
826     //~^ WARN unused attribute
827     //~| WARN crate-level attribute should be in the root module
828
829     #[recursion_limit="0200"] fn f() { }
830     //~^ WARN unused attribute
831     //~| WARN crate-level attribute should be an inner attribute
832
833     #[recursion_limit="0200"] struct S;
834     //~^ WARN unused attribute
835     //~| WARN crate-level attribute should be an inner attribute
836
837     #[recursion_limit="0200"] type T = S;
838     //~^ WARN unused attribute
839     //~| WARN crate-level attribute should be an inner attribute
840
841     #[recursion_limit="0200"] impl S { }
842     //~^ WARN unused attribute
843     //~| WARN crate-level attribute should be an inner attribute
844 }
845
846 #[type_length_limit="0100"]
847 //~^ WARN unused attribute
848 //~| WARN crate-level attribute should be an inner attribute
849 mod type_length_limit {
850     mod inner { #![type_length_limit="0100"] }
851     //~^ WARN unused attribute
852     //~| WARN crate-level attribute should be in the root module
853
854     #[type_length_limit="0100"] fn f() { }
855     //~^ WARN unused attribute
856     //~| WARN crate-level attribute should be an inner attribute
857
858     #[type_length_limit="0100"] struct S;
859     //~^ WARN unused attribute
860     //~| WARN crate-level attribute should be an inner attribute
861
862     #[type_length_limit="0100"] type T = S;
863     //~^ WARN unused attribute
864     //~| WARN crate-level attribute should be an inner attribute
865
866     #[type_length_limit="0100"] impl S { }
867     //~^ WARN unused attribute
868     //~| WARN crate-level attribute should be an inner attribute
869 }
870
871 // Since we expect for the mix of attributes used here to compile
872 // successfully, and we are just testing for the expected warnings of
873 // various (mis)uses of attributes, we use the `rustc_error` attribute
874 // on the `fn main()`.
875
876 #[rustc_error]
877 fn main() { //~ ERROR compilation successful
878     println!("Hello World");
879 }