]> git.lizzy.rs Git - rust.git/blob - tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.rs
Rollup merge of #107306 - compiler-errors:correct-sugg-for-closure-arg-needs-borrow...
[rust.git] / tests / ui / feature-gates / issue-43106-gating-of-builtin-attrs.rs
1 //~ NOTE not a function
2 //~| NOTE not a foreign function or static
3 //~| NOTE cannot be applied to crates
4 //~| NOTE not an `extern` block
5 // This test enumerates as many compiler-builtin ungated attributes as
6 // possible (that is, all the mutually compatible ones), and checks
7 // that we get "expected" (*) warnings for each in the various weird
8 // places that users might put them in the syntax.
9 //
10 // (*): The word "expected" is in quotes above because the cases where
11 // warnings are and are not emitted might not match a user's intuition
12 // nor the rustc developers' intent. I am really just trying to
13 // capture today's behavior in a test, not so that it become enshrined
14 // as the absolute behavior going forward, but rather so that we do
15 // not change the behavior in the future without even being *aware* of
16 // the change when it happens.
17 //
18 // At the time of authoring, the attributes here are listed in the
19 // order that they occur in `librustc_feature`.
20 //
21 // Any builtin attributes that:
22 //
23 //  - are not stable, or
24 //
25 //  - could not be included here covering the same cases as the other
26 //    attributes without raising an *error* from rustc (note though
27 //    that warnings are of course expected)
28 //
29 // have their own test case referenced by filename in an inline
30 // comment.
31 //
32 // The test feeds numeric inputs to each attribute that accepts them
33 // without error. We do this for two reasons: (1.) to exercise how
34 // inputs are handled by each, and (2.) to ease searching for related
35 // occurrences in the source text.
36
37 // check-pass
38
39 #![feature(test)]
40 #![warn(unused_attributes, unknown_lints)]
41 //~^ NOTE the lint level is defined here
42 //~| NOTE the lint level is defined here
43
44 // UNGATED WHITE-LISTED BUILT-IN ATTRIBUTES
45
46 #![warn(x5400)] //~ WARN unknown lint: `x5400`
47 #![allow(x5300)] //~ WARN unknown lint: `x5300`
48 #![forbid(x5200)] //~ WARN unknown lint: `x5200`
49 #![deny(x5100)] //~ WARN unknown lint: `x5100`
50 #![macro_use] // (allowed if no argument; see issue-43160-gating-of-macro_use.rs)
51 // skipping testing of cfg
52 // skipping testing of cfg_attr
53 #![should_panic] //~ WARN `#[should_panic]` only has an effect
54 #![ignore] //~ WARN `#[ignore]` only has an effect on functions
55 #![no_implicit_prelude]
56 #![reexport_test_harness_main = "2900"]
57 // see gated-link-args.rs
58 // see issue-43106-gating-of-macro_escape.rs for crate-level; but non crate-level is below at "2700"
59 // (cannot easily test gating of crate-level #[no_std]; but non crate-level is below at "2600")
60 #![proc_macro_derive()] //~ WARN `#[proc_macro_derive]` only has an effect
61 #![doc = "2400"]
62 #![cold] //~ WARN attribute should be applied to a function
63 //~^ WARN this was previously accepted
64 #![link()] //~ WARN attribute should be applied to an `extern` block
65 //~^ WARN this was previously accepted
66 #![link_name = "1900"]
67 //~^ WARN attribute should be applied to a foreign function
68 //~^^ WARN this was previously accepted by the compiler
69 #![link_section = "1800"]
70 //~^ WARN attribute should be applied to a function or static
71 //~^^ WARN this was previously accepted by the compiler
72 #![must_use]
73 //~^ WARN `#[must_use]` has no effect
74 // see issue-43106-gating-of-stable.rs
75 // see issue-43106-gating-of-unstable.rs
76 // see issue-43106-gating-of-deprecated.rs
77 #![windows_subsystem = "windows"]
78
79 // UNGATED CRATE-LEVEL BUILT-IN ATTRIBUTES
80
81 #![crate_name = "0900"]
82 #![crate_type = "bin"] // cannot pass "0800" here
83
84 #![crate_id = "10"]
85 //~^ WARN use of deprecated attribute
86 //~| HELP remove this attribute
87 //~| NOTE `#[warn(deprecated)]` on by default
88
89 // FIXME(#44232) we should warn that this isn't used.
90 #![feature(rust1)]
91 //~^ WARN no longer requires an attribute to enable
92 //~| NOTE `#[warn(stable_features)]` on by default
93
94 #![no_start]
95 //~^ WARN use of deprecated attribute
96 //~| HELP remove this attribute
97
98 // (cannot easily gating state of crate-level #[no_main]; but non crate-level is below at "0400")
99 #![no_builtins]
100 #![recursion_limit = "0200"]
101 #![type_length_limit = "0100"]
102
103 // USES OF BUILT-IN ATTRIBUTES IN OTHER ("UNUSUAL") PLACES
104
105 #[warn(x5400)]
106 //~^ WARN unknown lint: `x5400`
107 mod warn {
108     mod inner { #![warn(x5400)] }
109     //~^ WARN unknown lint: `x5400`
110
111     #[warn(x5400)] fn f() { }
112     //~^ WARN unknown lint: `x5400`
113
114     #[warn(x5400)] struct S;
115     //~^ WARN unknown lint: `x5400`
116
117     #[warn(x5400)] type T = S;
118     //~^ WARN unknown lint: `x5400`
119
120     #[warn(x5400)] impl S { }
121     //~^ WARN unknown lint: `x5400`
122 }
123
124 #[allow(x5300)]
125 //~^ WARN unknown lint: `x5300`
126 mod allow {
127     mod inner { #![allow(x5300)] }
128     //~^ WARN unknown lint: `x5300`
129
130     #[allow(x5300)] fn f() { }
131     //~^ WARN unknown lint: `x5300`
132
133     #[allow(x5300)] struct S;
134     //~^ WARN unknown lint: `x5300`
135
136     #[allow(x5300)] type T = S;
137     //~^ WARN unknown lint: `x5300`
138
139     #[allow(x5300)] impl S { }
140     //~^ WARN unknown lint: `x5300`
141 }
142
143 #[forbid(x5200)]
144 //~^ WARN unknown lint: `x5200`
145 mod forbid {
146     mod inner { #![forbid(x5200)] }
147     //~^ WARN unknown lint: `x5200`
148
149     #[forbid(x5200)] fn f() { }
150     //~^ WARN unknown lint: `x5200`
151
152     #[forbid(x5200)] struct S;
153     //~^ WARN unknown lint: `x5200`
154
155     #[forbid(x5200)] type T = S;
156     //~^ WARN unknown lint: `x5200`
157
158     #[forbid(x5200)] impl S { }
159     //~^ WARN unknown lint: `x5200`
160 }
161
162 #[deny(x5100)]
163 //~^ WARN unknown lint: `x5100`
164 mod deny {
165     mod inner { #![deny(x5100)] }
166     //~^ WARN unknown lint: `x5100`
167
168     #[deny(x5100)] fn f() { }
169     //~^ WARN unknown lint: `x5100`
170
171     #[deny(x5100)] struct S;
172     //~^ WARN unknown lint: `x5100`
173
174     #[deny(x5100)] type T = S;
175     //~^ WARN unknown lint: `x5100`
176
177     #[deny(x5100)] impl S { }
178     //~^ WARN unknown lint: `x5100`
179 }
180
181 #[macro_use]
182 mod macro_use {
183     mod inner { #![macro_use] }
184
185     #[macro_use] fn f() { }
186     //~^ `#[macro_use]` only has an effect
187
188     #[macro_use] struct S;
189     //~^ `#[macro_use]` only has an effect
190
191     #[macro_use] type T = S;
192     //~^ `#[macro_use]` only has an effect
193
194     #[macro_use] impl S { }
195     //~^ `#[macro_use]` only has an effect
196 }
197
198 #[macro_export]
199 //~^ WARN `#[macro_export]` only has an effect on macro definitions
200 mod macro_export {
201     mod inner { #![macro_export] }
202     //~^ WARN `#[macro_export]` only has an effect on macro definitions
203
204     #[macro_export] fn f() { }
205     //~^ WARN `#[macro_export]` only has an effect on macro definitions
206
207     #[macro_export] struct S;
208     //~^ WARN `#[macro_export]` only has an effect on macro definitions
209
210     #[macro_export] type T = S;
211     //~^ WARN `#[macro_export]` only has an effect on macro definitions
212
213     #[macro_export] impl S { }
214     //~^ WARN `#[macro_export]` only has an effect on macro definitions
215 }
216
217 // At time of unit test authorship, if compiling without `--test` then
218 // non-crate-level #[test] attributes seem to be ignored.
219
220 #[test]
221 mod test { mod inner { #![test] }
222
223     fn f() { }
224
225     struct S;
226
227     type T = S;
228
229     impl S { }
230 }
231
232 // At time of unit test authorship, if compiling without `--test` then
233 // non-crate-level #[bench] attributes seem to be ignored.
234
235 #[bench]
236 mod bench {
237     mod inner { #![bench] }
238
239     #[bench]
240     struct S;
241
242     #[bench]
243     type T = S;
244
245     #[bench]
246     impl S { }
247 }
248
249 #[path = "3800"]
250 mod path {
251     mod inner { #![path="3800"] }
252
253     #[path = "3800"] fn f() { }
254     //~^ WARN `#[path]` only has an effect
255
256     #[path = "3800"]  struct S;
257     //~^ WARN `#[path]` only has an effect
258
259     #[path = "3800"] type T = S;
260     //~^ WARN `#[path]` only has an effect
261
262     #[path = "3800"] impl S { }
263     //~^ WARN `#[path]` only has an effect
264 }
265
266 #[automatically_derived]
267 //~^ WARN `#[automatically_derived]` only has an effect
268 mod automatically_derived {
269     mod inner { #![automatically_derived] }
270     //~^ WARN `#[automatically_derived]
271
272     #[automatically_derived] fn f() { }
273     //~^ WARN `#[automatically_derived]
274
275     #[automatically_derived] struct S;
276     //~^ WARN `#[automatically_derived]
277
278     #[automatically_derived] type T = S;
279     //~^ WARN `#[automatically_derived]
280
281     #[automatically_derived] impl S { }
282 }
283
284 #[no_mangle]
285 //~^ WARN attribute should be applied to a free function, impl method or static [unused_attributes]
286 //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
287 mod no_mangle {
288     //~^ NOTE not a free function, impl method or static
289     mod inner { #![no_mangle] }
290     //~^ WARN attribute should be applied to a free function, impl method or static [unused_attributes]
291     //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
292     //~| NOTE not a free function, impl method or static
293
294     #[no_mangle] fn f() { }
295
296     #[no_mangle] struct S;
297     //~^ WARN attribute should be applied to a free function, impl method or static [unused_attributes]
298     //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
299     //~| NOTE not a free function, impl method or static
300
301     #[no_mangle] type T = S;
302     //~^ WARN attribute should be applied to a free function, impl method or static [unused_attributes]
303     //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
304     //~| NOTE not a free function, impl method or static
305
306     #[no_mangle] impl S { }
307     //~^ WARN attribute should be applied to a free function, impl method or static [unused_attributes]
308     //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
309     //~| NOTE not a free function, impl method or static
310
311     trait Tr {
312         #[no_mangle] fn foo();
313         //~^ WARN attribute should be applied to a free function, impl method or static [unused_attributes]
314         //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
315         //~| NOTE not a free function, impl method or static
316
317         #[no_mangle] fn bar() {}
318         //~^ WARN attribute should be applied to a free function, impl method or static [unused_attributes]
319         //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
320         //~| NOTE not a free function, impl method or static
321     }
322 }
323
324 #[should_panic]
325 //~^ WARN `#[should_panic]` only has an effect on
326 mod should_panic {
327     mod inner { #![should_panic] }
328     //~^ WARN `#[should_panic]` only has an effect on
329
330     #[should_panic] fn f() { }
331
332     #[should_panic] struct S;
333     //~^ WARN `#[should_panic]` only has an effect on
334
335     #[should_panic] type T = S;
336     //~^ WARN `#[should_panic]` only has an effect on
337
338     #[should_panic] impl S { }
339     //~^ WARN `#[should_panic]` only has an effect on
340 }
341
342 #[ignore]
343 //~^ WARN `#[ignore]` only has an effect on functions
344 mod ignore {
345     mod inner { #![ignore] }
346     //~^ WARN `#[ignore]` only has an effect on functions
347
348     #[ignore] fn f() { }
349
350     #[ignore] struct S;
351     //~^ WARN `#[ignore]` only has an effect on functions
352
353     #[ignore] type T = S;
354     //~^ WARN `#[ignore]` only has an effect on functions
355
356     #[ignore] impl S { }
357     //~^ WARN `#[ignore]` only has an effect on functions
358 }
359
360 #[no_implicit_prelude]
361 mod no_implicit_prelude {
362     mod inner { #![no_implicit_prelude] }
363
364     #[no_implicit_prelude] fn f() { }
365     //~^ WARN `#[no_implicit_prelude]` only has an effect
366
367     #[no_implicit_prelude] struct S;
368     //~^ WARN `#[no_implicit_prelude]` only has an effect
369
370     #[no_implicit_prelude] type T = S;
371     //~^ WARN `#[no_implicit_prelude]` only has an effect
372
373     #[no_implicit_prelude] impl S { }
374     //~^ WARN `#[no_implicit_prelude]` only has an effect
375 }
376
377 #[reexport_test_harness_main = "2900"]
378 //~^ WARN crate-level attribute should be
379 mod reexport_test_harness_main {
380     mod inner { #![reexport_test_harness_main="2900"] }
381     //~^ WARN crate-level attribute should be
382
383     #[reexport_test_harness_main = "2900"] fn f() { }
384     //~^ WARN crate-level attribute should be
385
386     #[reexport_test_harness_main = "2900"] struct S;
387     //~^ WARN crate-level attribute should be
388
389     #[reexport_test_harness_main = "2900"] type T = S;
390     //~^ WARN crate-level attribute should be
391
392     #[reexport_test_harness_main = "2900"] impl S { }
393     //~^ WARN crate-level attribute should be
394 }
395
396 // Cannot feed "2700" to `#[macro_escape]` without signaling an error.
397 #[macro_escape]
398 //~^ WARN `#[macro_escape]` is a deprecated synonym for `#[macro_use]`
399 mod macro_escape {
400     mod inner { #![macro_escape] }
401     //~^ WARN `#[macro_escape]` is a deprecated synonym for `#[macro_use]`
402     //~| HELP try an outer attribute: `#[macro_use]`
403
404     #[macro_escape] fn f() { }
405     //~^ WARN `#[macro_escape]` only has an effect
406
407     #[macro_escape] struct S;
408     //~^ WARN `#[macro_escape]` only has an effect
409
410     #[macro_escape] type T = S;
411     //~^ WARN `#[macro_escape]` only has an effect
412
413     #[macro_escape] impl S { }
414     //~^ WARN `#[macro_escape]` only has an effect
415 }
416
417 #[no_std]
418 //~^ WARN crate-level attribute should be an inner attribute
419 mod no_std {
420     mod inner { #![no_std] }
421 //~^ WARN crate-level attribute should be in the root module
422
423     #[no_std] fn f() { }
424     //~^ WARN crate-level attribute should be an inner attribute
425
426     #[no_std] struct S;
427     //~^ WARN crate-level attribute should be an inner attribute
428
429     #[no_std] type T = S;
430     //~^ WARN crate-level attribute should be an inner attribute
431
432     #[no_std] impl S { }
433     //~^ WARN crate-level attribute should be an inner attribute
434 }
435
436 // At time of authorship, #[proc_macro_derive = "2500"] signals error
437 // when it occurs on a mod (apart from crate-level). Therefore it goes
438 // into its own file; see issue-43106-gating-of-proc_macro_derive.rs
439
440 #[doc = "2400"]
441 mod doc {
442     mod inner { #![doc="2400"] }
443
444     #[doc = "2400"] fn f() { }
445
446     #[doc = "2400"] struct S;
447
448     #[doc = "2400"] type T = S;
449
450     #[doc = "2400"] impl S { }
451 }
452
453 #[cold]
454 //~^ WARN attribute should be applied to a function
455 //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
456 mod cold {
457     //~^ NOTE not a function
458
459     mod inner { #![cold] }
460     //~^ WARN attribute should be applied to a function
461     //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
462     //~| NOTE not a function
463
464     #[cold] fn f() { }
465
466     #[cold] struct S;
467     //~^ WARN attribute should be applied to a function
468     //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
469     //~| NOTE not a function
470
471     #[cold] type T = S;
472     //~^ WARN attribute should be applied to a function
473     //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
474     //~| NOTE not a function
475
476     #[cold] impl S { }
477     //~^ WARN attribute should be applied to a function
478     //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
479     //~| NOTE not a function
480 }
481
482 #[link_name = "1900"]
483 //~^ WARN attribute should be applied to a foreign function or static [unused_attributes]
484 //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
485 mod link_name {
486     //~^ NOTE not a foreign function or static
487
488     #[link_name = "1900"]
489     //~^ WARN attribute should be applied to a foreign function or static [unused_attributes]
490     //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
491     //~| HELP try `#[link(name = "1900")]` instead
492     extern "C" { }
493     //~^ NOTE not a foreign function or static
494
495     mod inner { #![link_name="1900"] }
496     //~^ WARN attribute should be applied to a foreign function or static [unused_attributes]
497     //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
498     //~| NOTE not a foreign function or static
499
500     #[link_name = "1900"] fn f() { }
501     //~^ WARN attribute should be applied to a foreign function or static [unused_attributes]
502     //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
503     //~| NOTE not a foreign function or static
504
505     #[link_name = "1900"] struct S;
506     //~^ WARN attribute should be applied to a foreign function or static [unused_attributes]
507     //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
508     //~| NOTE not a foreign function or static
509
510     #[link_name = "1900"] type T = S;
511     //~^ WARN attribute should be applied to a foreign function or static [unused_attributes]
512     //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
513     //~| NOTE not a foreign function or static
514
515     #[link_name = "1900"] impl S { }
516     //~^ WARN attribute should be applied to a foreign function or static [unused_attributes]
517     //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
518     //~| NOTE not a foreign function or static
519 }
520
521 #[link_section = "1800"]
522 //~^ WARN attribute should be applied to a function or static [unused_attributes]
523 //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
524 mod link_section {
525     //~^ NOTE not a function or static
526
527     mod inner { #![link_section="1800"] }
528     //~^ WARN attribute should be applied to a function or static [unused_attributes]
529     //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
530     //~| NOTE not a function or static
531
532     #[link_section = "1800"] fn f() { }
533
534     #[link_section = "1800"] struct S;
535     //~^ WARN attribute should be applied to a function or static [unused_attributes]
536     //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
537     //~| NOTE not a function or static
538
539     #[link_section = "1800"] type T = S;
540     //~^ WARN attribute should be applied to a function or static [unused_attributes]
541     //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
542     //~| NOTE not a function or static
543
544     #[link_section = "1800"] impl S { }
545     //~^ WARN attribute should be applied to a function or static [unused_attributes]
546     //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
547     //~| NOTE not a function or static
548 }
549
550
551 // Note that this is a `check-pass` test, so it will never invoke the linker.
552
553 #[link()]
554 //~^ WARN attribute should be applied to an `extern` block
555 //~| WARN this was previously accepted
556 mod link {
557     //~^ NOTE not an `extern` block
558
559     mod inner { #![link()] }
560     //~^ WARN attribute should be applied to an `extern` block
561     //~| WARN this was previously accepted
562     //~| NOTE not an `extern` block
563
564     #[link()] fn f() { }
565     //~^ WARN attribute should be applied to an `extern` block
566     //~| WARN this was previously accepted
567     //~| NOTE not an `extern` block
568
569     #[link()] struct S;
570     //~^ WARN attribute should be applied to an `extern` block
571     //~| WARN this was previously accepted
572     //~| NOTE not an `extern` block
573
574     #[link()] type T = S;
575     //~^ WARN attribute should be applied to an `extern` block
576     //~| WARN this was previously accepted
577     //~| NOTE not an `extern` block
578
579     #[link()] impl S { }
580     //~^ WARN attribute should be applied to an `extern` block
581     //~| WARN this was previously accepted
582     //~| NOTE not an `extern` block
583
584     #[link()] extern "Rust" {}
585     //~^ WARN attribute should be applied to an `extern` block
586     //~| WARN this was previously accepted
587 }
588
589 struct StructForDeprecated;
590
591 #[deprecated]
592 mod deprecated {
593     mod inner { #![deprecated] }
594
595     #[deprecated] fn f() { }
596
597     #[deprecated] struct S1;
598
599     #[deprecated] type T = super::StructForDeprecated;
600
601     #[deprecated] impl super::StructForDeprecated { }
602 }
603
604 #[must_use] //~ WARN `#[must_use]` has no effect
605 mod must_use {
606     mod inner { #![must_use] } //~ WARN `#[must_use]` has no effect
607
608     #[must_use] fn f() { }
609
610     #[must_use] struct S;
611
612     #[must_use] type T = S; //~ WARN `#[must_use]` has no effect
613
614     #[must_use] impl S { } //~ WARN `#[must_use]` has no effect
615 }
616
617 #[windows_subsystem = "windows"]
618 //~^ WARN crate-level attribute should be an inner attribute
619 mod windows_subsystem {
620     mod inner { #![windows_subsystem="windows"] }
621     //~^ WARN crate-level attribute should be in the root module
622
623     #[windows_subsystem = "windows"] fn f() { }
624     //~^ WARN crate-level attribute should be an inner attribute
625
626     #[windows_subsystem = "windows"] struct S;
627     //~^ WARN crate-level attribute should be an inner attribute
628
629     #[windows_subsystem = "windows"] type T = S;
630     //~^ WARN crate-level attribute should be an inner attribute
631
632     #[windows_subsystem = "windows"] impl S { }
633     //~^ WARN crate-level attribute should be an inner attribute
634 }
635
636 // BROKEN USES OF CRATE-LEVEL BUILT-IN ATTRIBUTES
637
638 #[crate_name = "0900"]
639 //~^ WARN crate-level attribute should be an inner attribute
640 mod crate_name {
641     mod inner { #![crate_name="0900"] }
642 //~^ WARN crate-level attribute should be in the root module
643
644     #[crate_name = "0900"] fn f() { }
645     //~^ WARN crate-level attribute should be an inner attribute
646
647     #[crate_name = "0900"] struct S;
648     //~^ WARN crate-level attribute should be an inner attribute
649
650     #[crate_name = "0900"] type T = S;
651     //~^ WARN crate-level attribute should be an inner attribute
652
653     #[crate_name = "0900"] impl S { }
654     //~^ WARN crate-level attribute should be an inner attribute
655 }
656
657 #[crate_type = "0800"]
658 //~^ WARN crate-level attribute should be an inner attribute
659 mod crate_type {
660     mod inner { #![crate_type="0800"] }
661 //~^ WARN crate-level attribute should be in the root module
662
663     #[crate_type = "0800"] fn f() { }
664     //~^ WARN crate-level attribute should be an inner attribute
665
666     #[crate_type = "0800"] struct S;
667     //~^ WARN crate-level attribute should be an inner attribute
668
669     #[crate_type = "0800"] type T = S;
670     //~^ WARN crate-level attribute should be an inner attribute
671
672     #[crate_type = "0800"] impl S { }
673     //~^ WARN crate-level attribute should be an inner attribute
674 }
675
676 #[feature(x0600)]
677 //~^ WARN crate-level attribute should be an inner attribute
678 mod feature {
679     mod inner { #![feature(x0600)] }
680 //~^ WARN crate-level attribute should be in the root module
681
682     #[feature(x0600)] fn f() { }
683     //~^ WARN crate-level attribute should be an inner attribute
684
685     #[feature(x0600)] struct S;
686     //~^ WARN crate-level attribute should be an inner attribute
687
688     #[feature(x0600)] type T = S;
689     //~^ WARN crate-level attribute should be an inner attribute
690
691     #[feature(x0600)] impl S { }
692     //~^ WARN crate-level attribute should be an inner attribute
693 }
694
695
696 #[no_main]
697 //~^ WARN crate-level attribute should be an inner attribute
698 mod no_main_1 {
699     mod inner { #![no_main] }
700 //~^ WARN crate-level attribute should be in the root module
701
702     #[no_main] fn f() { }
703     //~^ WARN crate-level attribute should be an inner attribute
704
705     #[no_main] struct S;
706     //~^ WARN crate-level attribute should be an inner attribute
707
708     #[no_main] type T = S;
709     //~^ WARN crate-level attribute should be an inner attribute
710
711     #[no_main] impl S { }
712     //~^ WARN crate-level attribute should be an inner attribute
713 }
714
715 #[no_builtins]
716 //~^ WARN crate-level attribute should be an inner attribute
717 mod no_builtins {
718     mod inner { #![no_builtins] }
719     //~^ WARN crate-level attribute should be in the root module
720
721     #[no_builtins] fn f() { }
722     //~^ WARN crate-level attribute should be an inner attribute
723
724     #[no_builtins] struct S;
725     //~^ WARN crate-level attribute should be an inner attribute
726
727     #[no_builtins] type T = S;
728     //~^ WARN crate-level attribute should be an inner attribute
729
730     #[no_builtins] impl S { }
731     //~^ WARN crate-level attribute should be an inner attribute
732 }
733
734 #[recursion_limit="0200"]
735 //~^ WARN crate-level attribute should be an inner attribute
736 mod recursion_limit {
737     mod inner { #![recursion_limit="0200"] }
738 //~^ WARN crate-level attribute should be in the root module
739
740     #[recursion_limit="0200"] fn f() { }
741     //~^ WARN crate-level attribute should be an inner attribute
742
743     #[recursion_limit="0200"] struct S;
744     //~^ WARN crate-level attribute should be an inner attribute
745
746     #[recursion_limit="0200"] type T = S;
747     //~^ WARN crate-level attribute should be an inner attribute
748
749     #[recursion_limit="0200"] impl S { }
750     //~^ WARN crate-level attribute should be an inner attribute
751 }
752
753 #[type_length_limit="0100"]
754 //~^ WARN crate-level attribute should be an inner attribute
755 mod type_length_limit {
756     mod inner { #![type_length_limit="0100"] }
757 //~^ WARN crate-level attribute should be in the root module
758
759     #[type_length_limit="0100"] fn f() { }
760     //~^ WARN crate-level attribute should be an inner attribute
761
762     #[type_length_limit="0100"] struct S;
763     //~^ WARN crate-level attribute should be an inner attribute
764
765     #[type_length_limit="0100"] type T = S;
766     //~^ WARN crate-level attribute should be an inner attribute
767
768     #[type_length_limit="0100"] impl S { }
769     //~^ WARN crate-level attribute should be an inner attribute
770 }
771
772 fn main() {}