]> git.proxmox.com Git - rustc.git/blob - src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.rs
New upstream version 1.28.0~beta.14+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
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_use] // (allowed if no argument; see issue-43160-gating-of-macro_use.rs)
54 #![macro_export = "4800"] //~ WARN unused attribute
55 #![plugin_registrar = "4700"] //~ WARN unused attribute
56 // skipping testing of cfg
57 // skipping testing of cfg_attr
58 #![main = "x4400"] //~ WARN unused attribute
59 #![start = "x4300"] //~ WARN unused attribute
60 // see issue-43106-gating-of-test.rs for crate-level; but non crate-level is below at "4200"
61 // see issue-43106-gating-of-bench.rs for crate-level; but non crate-level is below at "4100"
62 #![repr = "3900"]
63 //~^ WARN unused attribute
64 //~| WARN `repr` attribute isn't configurable with a literal
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 // FIXME(#44232) we should warn that this isn't used.
103 #![feature ( x0600)]
104
105 // For #![no_start], see issue #43144. (I cannot bear to enshrine current behavior in a test)
106
107 // (cannot easily gating state of crate-level #[no_main]; but non crate-level is below at "0400")
108 #![no_builtins = "0300"]
109 #![recursion_limit = "0200"]
110 #![type_length_limit = "0100"]
111
112 // USES OF BUILT-IN ATTRIBUTES IN OTHER ("UNUSUAL") PLACES
113
114 #[warn(x5400)]
115 //~^ WARN unknown lint: `x5400`
116 mod warn {
117 mod inner { #![warn(x5400)] }
118 //~^ WARN unknown lint: `x5400`
119
120 #[warn(x5400)] fn f() { }
121 //~^ WARN unknown lint: `x5400`
122
123 #[warn(x5400)] struct S;
124 //~^ WARN unknown lint: `x5400`
125
126 #[warn(x5400)] type T = S;
127 //~^ WARN unknown lint: `x5400`
128
129 #[warn(x5400)] impl S { }
130 //~^ WARN unknown lint: `x5400`
131 }
132
133 #[allow(x5300)]
134 //~^ WARN unknown lint: `x5300`
135 mod allow {
136 mod inner { #![allow(x5300)] }
137 //~^ WARN unknown lint: `x5300`
138
139 #[allow(x5300)] fn f() { }
140 //~^ WARN unknown lint: `x5300`
141
142 #[allow(x5300)] struct S;
143 //~^ WARN unknown lint: `x5300`
144
145 #[allow(x5300)] type T = S;
146 //~^ WARN unknown lint: `x5300`
147
148 #[allow(x5300)] impl S { }
149 //~^ WARN unknown lint: `x5300`
150 }
151
152 #[forbid(x5200)]
153 //~^ WARN unknown lint: `x5200`
154 mod forbid {
155 mod inner { #![forbid(x5200)] }
156 //~^ WARN unknown lint: `x5200`
157
158 #[forbid(x5200)] fn f() { }
159 //~^ WARN unknown lint: `x5200`
160
161 #[forbid(x5200)] struct S;
162 //~^ WARN unknown lint: `x5200`
163
164 #[forbid(x5200)] type T = S;
165 //~^ WARN unknown lint: `x5200`
166
167 #[forbid(x5200)] impl S { }
168 //~^ WARN unknown lint: `x5200`
169 }
170
171 #[deny(x5100)]
172 //~^ WARN unknown lint: `x5100`
173 mod deny {
174 mod inner { #![deny(x5100)] }
175 //~^ WARN unknown lint: `x5100`
176
177 #[deny(x5100)] fn f() { }
178 //~^ WARN unknown lint: `x5100`
179
180 #[deny(x5100)] struct S;
181 //~^ WARN unknown lint: `x5100`
182
183 #[deny(x5100)] type T = S;
184 //~^ WARN unknown lint: `x5100`
185
186 #[deny(x5100)] impl S { }
187 //~^ WARN unknown lint: `x5100`
188 }
189
190 #[macro_use]
191 mod macro_use {
192 mod inner { #![macro_use] }
193
194 #[macro_use] fn f() { }
195 //~^ WARN unused attribute
196
197 #[macro_use] struct S;
198 //~^ WARN unused attribute
199
200 #[macro_use] type T = S;
201 //~^ WARN unused attribute
202
203 #[macro_use] impl S { }
204 //~^ WARN unused attribute
205 }
206
207 #[macro_export = "4800"]
208 //~^ WARN unused attribute
209 mod macro_export {
210 mod inner { #![macro_export="4800"] }
211 //~^ WARN unused attribute
212
213 #[macro_export = "4800"] fn f() { }
214 //~^ WARN unused attribute
215
216 #[macro_export = "4800"] struct S;
217 //~^ WARN unused attribute
218
219 #[macro_export = "4800"] type T = S;
220 //~^ WARN unused attribute
221
222 #[macro_export = "4800"] impl S { }
223 //~^ WARN unused attribute
224 }
225
226 #[plugin_registrar = "4700"]
227 //~^ WARN unused attribute
228 mod plugin_registrar {
229 mod inner { #![plugin_registrar="4700"] }
230 //~^ WARN unused attribute
231
232 // for `fn f()` case, see gated-plugin_registrar.rs
233
234 #[plugin_registrar = "4700"] struct S;
235 //~^ WARN unused attribute
236
237 #[plugin_registrar = "4700"] type T = S;
238 //~^ WARN unused attribute
239
240 #[plugin_registrar = "4700"] impl S { }
241 //~^ WARN unused attribute
242 }
243
244 #[main = "4400"]
245 //~^ WARN unused attribute
246 mod main {
247 mod inner { #![main="4300"] }
248 //~^ WARN unused attribute
249
250 // for `fn f()` case, see feature-gate-main.rs
251
252 #[main = "4400"] struct S;
253 //~^ WARN unused attribute
254
255 #[main = "4400"] type T = S;
256 //~^ WARN unused attribute
257
258 #[main = "4400"] impl S { }
259 //~^ WARN unused attribute
260 }
261
262 #[start = "4300"]
263 //~^ WARN unused attribute
264 mod start {
265 mod inner { #![start="4300"] }
266 //~^ WARN unused attribute
267
268 // for `fn f()` case, see feature-gate-start.rs
269
270 #[start = "4300"] struct S;
271 //~^ WARN unused attribute
272
273 #[start = "4300"] type T = S;
274 //~^ WARN unused attribute
275
276 #[start = "4300"] impl S { }
277 //~^ WARN unused attribute
278 }
279
280 // At time of unit test authorship, if compiling without `--test` then
281 // non-crate-level #[test] attributes seem to be ignored.
282
283 #[test = "4200"]
284 mod test { mod inner { #![test="4200"] }
285
286 fn f() { }
287
288 struct S;
289
290 type T = S;
291
292 impl S { }
293 }
294
295 // At time of unit test authorship, if compiling without `--test` then
296 // non-crate-level #[bench] attributes seem to be ignored.
297
298 #[bench = "4100"]
299 mod bench {
300 mod inner { #![bench="4100"] }
301
302 #[bench = "4100"]
303 struct S;
304
305 #[bench = "4100"]
306 type T = S;
307
308 #[bench = "4100"]
309 impl S { }
310 }
311
312 #[repr = "3900"]
313 //~^ WARN unused attribute
314 //~| WARN `repr` attribute isn't configurable with a literal
315 mod repr {
316 mod inner { #![repr="3900"] }
317 //~^ WARN unused attribute
318 //~| WARN `repr` attribute isn't configurable with a literal
319
320 #[repr = "3900"] fn f() { }
321 //~^ WARN unused attribute
322 //~| WARN `repr` attribute isn't configurable with a literal
323
324 struct S;
325
326 #[repr = "3900"] type T = S;
327 //~^ WARN unused attribute
328 //~| WARN `repr` attribute isn't configurable with a literal
329
330 #[repr = "3900"] impl S { }
331 //~^ WARN unused attribute
332 //~| WARN `repr` attribute isn't configurable with a literal
333 }
334
335 #[path = "3800"]
336 mod path {
337 mod inner { #![path="3800"] }
338
339 #[path = "3800"] fn f() { }
340 //~^ WARN unused attribute
341
342 #[path = "3800"] struct S;
343 //~^ WARN unused attribute
344
345 #[path = "3800"] type T = S;
346 //~^ WARN unused attribute
347
348 #[path = "3800"] impl S { }
349 //~^ WARN unused attribute
350 }
351
352 #[abi = "3700"]
353 //~^ WARN unused attribute
354 mod abi {
355 mod inner { #![abi="3700"] }
356 //~^ WARN unused attribute
357
358 #[abi = "3700"] fn f() { }
359 //~^ WARN unused attribute
360
361 #[abi = "3700"] struct S;
362 //~^ WARN unused attribute
363
364 #[abi = "3700"] type T = S;
365 //~^ WARN unused attribute
366
367 #[abi = "3700"] impl S { }
368 //~^ WARN unused attribute
369 }
370
371 #[automatically_derived = "3600"]
372 //~^ WARN unused attribute
373 mod automatically_derived {
374 mod inner { #![automatically_derived="3600"] }
375 //~^ WARN unused attribute
376
377 #[automatically_derived = "3600"] fn f() { }
378 //~^ WARN unused attribute
379
380 #[automatically_derived = "3600"] struct S;
381 //~^ WARN unused attribute
382
383 #[automatically_derived = "3600"] type T = S;
384 //~^ WARN unused attribute
385
386 #[automatically_derived = "3600"] impl S { }
387 //~^ WARN unused attribute
388 }
389
390 #[no_mangle = "3500"]
391 mod no_mangle {
392 mod inner { #![no_mangle="3500"] }
393
394 #[no_mangle = "3500"] fn f() { }
395 //~^ WARN function is marked #[no_mangle], but not exported
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 }