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