]> git.lizzy.rs Git - rust.git/blob - src/test/compile-fail/feature-gate/issue-43106-gating-of-builtin-attrs.rs
feature error span on attr. for fn_must_use, SIMD/align, macro reƫxport
[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     struct S;
358
359     #[repr = "3900"] type T = S;
360     //~^ WARN unused attribute
361
362     #[repr = "3900"] impl S { }
363     //~^ WARN unused attribute
364 }
365
366 #[path = "3800"]
367 mod path {
368     mod inner { #![path="3800"] }
369
370     #[path = "3800"] fn f() { }
371     //~^ WARN unused attribute
372
373     #[path = "3800"]  struct S;
374     //~^ WARN unused attribute
375
376     #[path = "3800"] type T = S;
377     //~^ WARN unused attribute
378
379     #[path = "3800"] impl S { }
380     //~^ WARN unused attribute
381 }
382
383 #[abi = "3700"]
384 //~^ WARN unused attribute
385 mod abi {
386     mod inner { #![abi="3700"] }
387     //~^ WARN unused attribute
388
389     #[abi = "3700"] fn f() { }
390     //~^ WARN unused attribute
391
392     #[abi = "3700"] struct S;
393     //~^ WARN unused attribute
394
395     #[abi = "3700"] type T = S;
396     //~^ WARN unused attribute
397
398     #[abi = "3700"] impl S { }
399     //~^ WARN unused attribute
400 }
401
402 #[automatically_derived = "3600"]
403 //~^ WARN unused attribute
404 mod automatically_derived {
405     mod inner { #![automatically_derived="3600"] }
406     //~^ WARN unused attribute
407
408     #[automatically_derived = "3600"] fn f() { }
409     //~^ WARN unused attribute
410
411     #[automatically_derived = "3600"] struct S;
412     //~^ WARN unused attribute
413
414     #[automatically_derived = "3600"] type T = S;
415     //~^ WARN unused attribute
416
417     #[automatically_derived = "3600"] impl S { }
418     //~^ WARN unused attribute
419 }
420
421 #[no_mangle = "3500"]
422 mod no_mangle {
423     mod inner { #![no_mangle="3500"] }
424
425     #[no_mangle = "3500"] fn f() { }
426     //~^ WARN function f is marked #[no_mangle], but not exported
427
428     #[no_mangle = "3500"] struct S;
429
430     #[no_mangle = "3500"] type T = S;
431
432     #[no_mangle = "3500"] impl S { }
433 }
434
435 #[no_link = "3400"]
436 //~^ WARN unused attribute
437 mod no_link {
438     mod inner { #![no_link="3400"] }
439     //~^ WARN unused attribute
440
441     #[no_link = "3400"] fn f() { }
442     //~^ WARN unused attribute
443
444     #[no_link = "3400"] struct S;
445     //~^ WARN unused attribute
446
447     #[no_link = "3400"]type T = S;
448     //~^ WARN unused attribute
449
450     #[no_link = "3400"] impl S { }
451     //~^ WARN unused attribute
452 }
453
454 #[should_panic = "3200"]
455 //~^ WARN unused attribute
456 mod should_panic {
457     mod inner { #![should_panic="3200"] }
458     //~^ WARN unused attribute
459
460     #[should_panic = "3200"] fn f() { }
461     //~^ WARN unused attribute
462
463     #[should_panic = "3200"] struct S;
464     //~^ WARN unused attribute
465
466     #[should_panic = "3200"] type T = S;
467     //~^ WARN unused attribute
468
469     #[should_panic = "3200"] impl S { }
470     //~^ WARN unused attribute
471 }
472
473 #[ignore = "3100"]
474 //~^ WARN unused attribute
475 mod ignore {
476     mod inner { #![ignore="3100"] }
477     //~^ WARN unused attribute
478
479     #[ignore = "3100"] fn f() { }
480     //~^ WARN unused attribute
481
482     #[ignore = "3100"] struct S;
483     //~^ WARN unused attribute
484
485     #[ignore = "3100"] type T = S;
486     //~^ WARN unused attribute
487
488     #[ignore = "3100"] impl S { }
489     //~^ WARN unused attribute
490 }
491
492 #[no_implicit_prelude = "3000"]
493 //~^ WARN unused attribute
494 mod no_implicit_prelude {
495     mod inner { #![no_implicit_prelude="3000"] }
496     //~^ WARN unused attribute
497
498     #[no_implicit_prelude = "3000"] fn f() { }
499     //~^ WARN unused attribute
500
501     #[no_implicit_prelude = "3000"] struct S;
502     //~^ WARN unused attribute
503
504     #[no_implicit_prelude = "3000"] type T = S;
505     //~^ WARN unused attribute
506
507     #[no_implicit_prelude = "3000"] impl S { }
508     //~^ WARN unused attribute
509 }
510
511 #[reexport_test_harness_main = "2900"]
512 //~^ WARN unused attribute
513 mod reexport_test_harness_main {
514     mod inner { #![reexport_test_harness_main="2900"] }
515     //~^ WARN unused attribute
516
517     #[reexport_test_harness_main = "2900"] fn f() { }
518     //~^ WARN unused attribute
519
520     #[reexport_test_harness_main = "2900"] struct S;
521     //~^ WARN unused attribute
522
523     #[reexport_test_harness_main = "2900"] type T = S;
524     //~^ WARN unused attribute
525
526     #[reexport_test_harness_main = "2900"] impl S { }
527     //~^ WARN unused attribute
528 }
529
530 // Cannnot feed "2700" to `#[macro_escape]` without signaling an error.
531 #[macro_escape]
532 //~^ WARN macro_escape is a deprecated synonym for macro_use
533 mod macro_escape {
534     mod inner { #![macro_escape] }
535     //~^ WARN macro_escape is a deprecated synonym for macro_use
536
537     #[macro_escape] fn f() { }
538     //~^ WARN unused attribute
539
540     #[macro_escape] struct S;
541     //~^ WARN unused attribute
542
543     #[macro_escape] type T = S;
544     //~^ WARN unused attribute
545
546     #[macro_escape] impl S { }
547     //~^ WARN unused attribute
548 }
549
550 #[no_std = "2600"]
551 //~^ WARN unused attribute
552 //~| WARN crate-level attribute should be an inner attribute
553 mod no_std {
554     mod inner { #![no_std="2600"] }
555     //~^ WARN unused attribute
556     //~| WARN crate-level attribute should be in the root module
557
558     #[no_std = "2600"] fn f() { }
559     //~^ WARN unused attribute
560     //~| WARN crate-level attribute should be an inner attribute
561
562     #[no_std = "2600"] struct S;
563     //~^ WARN unused attribute
564     //~| WARN crate-level attribute should be an inner attribute
565
566     #[no_std = "2600"] type T = S;
567     //~^ WARN unused attribute
568     //~| WARN crate-level attribute should be an inner attribute
569
570     #[no_std = "2600"] impl S { }
571     //~^ WARN unused attribute
572     //~| WARN crate-level attribute should be an inner attribute
573 }
574
575 // At time of authorship, #[proc_macro_derive = "2500"] signals error
576 // when it occurs on a mod (apart from crate-level). Therefore it goes
577 // into its own file; see issue-43106-gating-of-proc_macro_derive.rs
578
579 #[doc = "2400"]
580 mod doc {
581     mod inner { #![doc="2400"] }
582
583     #[doc = "2400"] fn f() { }
584
585     #[doc = "2400"] struct S;
586
587     #[doc = "2400"] type T = S;
588
589     #[doc = "2400"] impl S { }
590 }
591
592 #[cold = "2300"]
593 mod cold {
594     mod inner { #![cold="2300"] }
595
596     #[cold = "2300"] fn f() { }
597
598     #[cold = "2300"] struct S;
599
600     #[cold = "2300"] type T = S;
601
602     #[cold = "2300"] impl S { }
603 }
604
605 #[export_name = "2200"]
606 mod export_name {
607     mod inner { #![export_name="2200"] }
608
609     #[export_name = "2200"] fn f() { }
610
611     #[export_name = "2200"] struct S;
612
613     #[export_name = "2200"] type T = S;
614
615     #[export_name = "2200"] impl S { }
616 }
617
618 // Note that this test ends with a `#[rustc_error] fn main()`, so it
619 // will never invoke the linker. These are here nonetheless to point
620 // out that we allow them at non-crate-level (though I do not know
621 // whether they have the same effect here as at crate-level).
622
623 #[link = "2000"]
624 mod link {
625     mod inner { #![link="2000"] }
626
627     #[link = "2000"] fn f() { }
628
629     #[link = "2000"] struct S;
630
631     #[link = "2000"] type T = S;
632
633     #[link = "2000"] impl S { }
634 }
635
636 #[link_name = "1900"]
637 mod link_name {
638     mod inner { #![link_name="1900"] }
639
640     #[link_name = "1900"] fn f() { }
641
642     #[link_name = "1900"] struct S;
643
644     #[link_name = "1900"] type T = S;
645
646     #[link_name = "1900"] impl S { }
647 }
648
649 #[link_section = "1800"]
650 mod link_section {
651     mod inner { #![link_section="1800"] }
652
653     #[link_section = "1800"] fn f() { }
654
655     #[link_section = "1800"] struct S;
656
657     #[link_section = "1800"] type T = S;
658
659     #[link_section = "1800"] impl S { }
660 }
661
662 struct StructForDeprecated;
663
664 #[deprecated = "1500"]
665 mod deprecated {
666     mod inner { #![deprecated="1500"] }
667
668     #[deprecated = "1500"] fn f() { }
669
670     #[deprecated = "1500"] struct S1;
671
672     #[deprecated = "1500"] type T = super::StructForDeprecated;
673
674     #[deprecated = "1500"] impl super::StructForDeprecated { }
675 }
676
677 #[must_use = "1400"]
678 mod must_use {
679     mod inner { #![must_use="1400"] }
680
681     #[must_use = "1400"] fn f() { }
682     //~^ WARN `#[must_use]` on functions is experimental
683
684     #[must_use = "1400"] struct S;
685
686     #[must_use = "1400"] type T = S;
687
688     #[must_use = "1400"] impl S { }
689 }
690
691 #[windows_subsystem = "1000"]
692 mod windows_subsystem {
693     mod inner { #![windows_subsystem="1000"] }
694
695     #[windows_subsystem = "1000"] fn f() { }
696
697     #[windows_subsystem = "1000"] struct S;
698
699     #[windows_subsystem = "1000"] type T = S;
700
701     #[windows_subsystem = "1000"] impl S { }
702 }
703
704 // BROKEN USES OF CRATE-LEVEL BUILT-IN ATTRIBUTES
705
706 #[crate_name = "0900"]
707 //~^ WARN unused attribute
708 //~| WARN crate-level attribute should be an inner attribute
709 mod crate_name {
710     mod inner { #![crate_name="0900"] }
711     //~^ WARN unused attribute
712     //~| WARN crate-level attribute should be in the root module
713
714     #[crate_name = "0900"] fn f() { }
715     //~^ WARN unused attribute
716     //~| WARN crate-level attribute should be an inner attribute
717
718     #[crate_name = "0900"] struct S;
719     //~^ WARN unused attribute
720     //~| WARN crate-level attribute should be an inner attribute
721
722     #[crate_name = "0900"] type T = S;
723     //~^ WARN unused attribute
724     //~| WARN crate-level attribute should be an inner attribute
725
726     #[crate_name = "0900"] impl S { }
727     //~^ WARN unused attribute
728     //~| WARN crate-level attribute should be an inner attribute
729 }
730
731 #[crate_type = "0800"]
732 //~^ WARN unused attribute
733 //~| WARN crate-level attribute should be an inner attribute
734 mod crate_type {
735     mod inner { #![crate_type="0800"] }
736     //~^ WARN unused attribute
737     //~| WARN crate-level attribute should be in the root module
738
739     #[crate_type = "0800"] fn f() { }
740     //~^ WARN unused attribute
741     //~| WARN crate-level attribute should be an inner attribute
742
743     #[crate_type = "0800"] struct S;
744     //~^ WARN unused attribute
745     //~| WARN crate-level attribute should be an inner attribute
746
747     #[crate_type = "0800"] type T = S;
748     //~^ WARN unused attribute
749     //~| WARN crate-level attribute should be an inner attribute
750
751     #[crate_type = "0800"] impl S { }
752     //~^ WARN unused attribute
753     //~| WARN crate-level attribute should be an inner attribute
754 }
755
756 #[feature(x0600)]
757 //~^ WARN unused attribute
758 //~| WARN crate-level attribute should be an inner attribute
759 mod feature {
760     mod inner { #![feature(x0600)] }
761     //~^ WARN unused attribute
762     //~| WARN crate-level attribute should be in the root module
763
764     #[feature(x0600)] fn f() { }
765     //~^ WARN unused attribute
766     //~| WARN crate-level attribute should be an inner attribute
767
768     #[feature(x0600)] struct S;
769     //~^ WARN unused attribute
770     //~| WARN crate-level attribute should be an inner attribute
771
772     #[feature(x0600)] type T = S;
773     //~^ WARN unused attribute
774     //~| WARN crate-level attribute should be an inner attribute
775
776     #[feature(x0600)] impl S { }
777     //~^ WARN unused attribute
778     //~| WARN crate-level attribute should be an inner attribute
779 }
780
781
782 #[no_main = "0400"]
783 //~^ WARN unused attribute
784 //~| WARN crate-level attribute should be an inner attribute
785 mod no_main_1 {
786     mod inner { #![no_main="0400"] }
787     //~^ WARN unused attribute
788     //~| WARN crate-level attribute should be in the root module
789
790     #[no_main = "0400"] fn f() { }
791     //~^ WARN unused attribute
792     //~| WARN crate-level attribute should be an inner attribute
793
794     #[no_main = "0400"] struct S;
795     //~^ WARN unused attribute
796     //~| WARN crate-level attribute should be an inner attribute
797
798     #[no_main = "0400"] type T = S;
799     //~^ WARN unused attribute
800     //~| WARN crate-level attribute should be an inner attribute
801
802     #[no_main = "0400"] impl S { }
803     //~^ WARN unused attribute
804     //~| WARN crate-level attribute should be an inner attribute
805 }
806
807 #[no_builtins = "0300"]
808 mod no_builtins {
809     mod inner { #![no_builtins="0200"] }
810
811     #[no_builtins = "0300"] fn f() { }
812
813     #[no_builtins = "0300"] struct S;
814
815     #[no_builtins = "0300"] type T = S;
816
817     #[no_builtins = "0300"] impl S { }
818 }
819
820 #[recursion_limit="0200"]
821 //~^ WARN unused attribute
822 //~| WARN crate-level attribute should be an inner attribute
823 mod recursion_limit {
824     mod inner { #![recursion_limit="0200"] }
825     //~^ WARN unused attribute
826     //~| WARN crate-level attribute should be in the root module
827
828     #[recursion_limit="0200"] fn f() { }
829     //~^ WARN unused attribute
830     //~| WARN crate-level attribute should be an inner attribute
831
832     #[recursion_limit="0200"] struct S;
833     //~^ WARN unused attribute
834     //~| WARN crate-level attribute should be an inner attribute
835
836     #[recursion_limit="0200"] type T = S;
837     //~^ WARN unused attribute
838     //~| WARN crate-level attribute should be an inner attribute
839
840     #[recursion_limit="0200"] impl S { }
841     //~^ WARN unused attribute
842     //~| WARN crate-level attribute should be an inner attribute
843 }
844
845 #[type_length_limit="0100"]
846 //~^ WARN unused attribute
847 //~| WARN crate-level attribute should be an inner attribute
848 mod type_length_limit {
849     mod inner { #![type_length_limit="0100"] }
850     //~^ WARN unused attribute
851     //~| WARN crate-level attribute should be in the root module
852
853     #[type_length_limit="0100"] fn f() { }
854     //~^ WARN unused attribute
855     //~| WARN crate-level attribute should be an inner attribute
856
857     #[type_length_limit="0100"] struct S;
858     //~^ WARN unused attribute
859     //~| WARN crate-level attribute should be an inner attribute
860
861     #[type_length_limit="0100"] type T = S;
862     //~^ WARN unused attribute
863     //~| WARN crate-level attribute should be an inner attribute
864
865     #[type_length_limit="0100"] impl S { }
866     //~^ WARN unused attribute
867     //~| WARN crate-level attribute should be an inner attribute
868 }
869
870 // Since we expect for the mix of attributes used here to compile
871 // successfully, and we are just testing for the expected warnings of
872 // various (mis)uses of attributes, we use the `rustc_error` attribute
873 // on the `fn main()`.
874
875 #[rustc_error]
876 fn main() { //~ ERROR compilation successful
877     println!("Hello World");
878 }