rust/compiler
Matthias Krüger 659382fa47
Rollup merge of #92959 - asquared31415:test-non-fn-help, r=estebank
Add more info and suggestions to use of #[test] on invalid items

This pr changes the diagnostics for using `#[test]` on an item that can't be used as a test to explain that the attribute has no meaningful effect on non-functions and suggests the use of `#[cfg(test)]` for conditional compilation instead.

Example change:
```rs
#[test]
mod test {}
```
previously output
```
error: only functions may be used as tests
 --> src/lib.rs:2:1
  |
2 | mod test {}
  | ^^^^^^^^^^^
  ```
  now outputs
  ```
error: the `#[test]` attribute may only be used on a non-associated function
  --> $DIR/test-on-not-fn.rs:3:1
     |
LL | #[test]
     | ^^^^^^^
LL | mod test {}
     | ----------- expected a non-associated function, found a module
     |
     = note: the `#[test]` macro causes a a function to be run on a test and has no effect on non-functions
help: replace with conditional compilation to make the item only exist when tests are being run
     |
LL | #[cfg(test)]
     | ~~~~~~~~~~~~
   ```
2022-02-18 16:23:29 +01:00
..
rustc remove unused jemallocator crate 2022-01-28 16:56:05 +01:00
rustc_apfloat
rustc_arena Remove unused dep from rustc_arena 2022-02-02 17:37:14 +01:00
rustc_ast Auto merge of #93752 - eholk:drop-tracking-break-continue, r=nikomatsakis 2022-02-15 02:27:37 +00:00
rustc_ast_lowering Revert "Auto merge of #91403 - cjgillot:inherit-async, r=oli-obk" 2022-02-17 16:00:04 +00:00
rustc_ast_passes Auto merge of #93561 - Amanieu:more-unwind-abi, r=nagisa 2022-02-08 03:20:05 +00:00
rustc_ast_pretty Pretty print ItemKind::Use in rustfmt style 2022-02-07 21:51:05 -08:00
rustc_attr Ensure that queries only return Copy types. 2022-02-09 20:07:38 +01:00
rustc_borrowck Auto merge of #94088 - oli-obk:revert, r=jackh726 2022-02-18 07:35:37 +00:00
rustc_builtin_macros Rollup merge of #92959 - asquared31415:test-non-fn-help, r=estebank 2022-02-18 16:23:29 +01:00
rustc_codegen_cranelift Overhaul Const. 2022-02-15 16:19:59 +11:00
rustc_codegen_gcc Unconditionally update symbols 2022-02-10 18:27:18 +01:00
rustc_codegen_llvm Rollup merge of #94043 - DrMeepster:box_alloc_ice, r=oli-obk 2022-02-17 23:01:01 +01:00
rustc_codegen_ssa Rollup merge of #94011 - est31:let_else, r=lcnr 2022-02-17 23:00:59 +01:00
rustc_const_eval Support pretty printing of invalid constants 2022-02-16 00:38:59 +01:00
rustc_data_structures Address review comments. 2022-02-15 16:20:01 +11:00
rustc_driver Remove Config::stderr 2022-02-13 11:49:52 +01:00
rustc_error_codes Revert "Auto merge of #91403 - cjgillot:inherit-async, r=oli-obk" 2022-02-17 16:00:04 +00:00
rustc_errors add a rustc::query_stability lint 2022-02-01 10:15:59 +01:00
rustc_expand add a rustc::query_stability lint 2022-02-01 10:15:59 +01:00
rustc_feature Rollup merge of #93337 - Amanieu:asm_tracking, r=tmiasko 2022-02-17 23:00:55 +01:00
rustc_fs_util
rustc_graphviz
rustc_hir Auto merge of #93938 - BoxyUwU:fix_res_self_ty, r=lcnr 2022-02-14 12:26:43 +00:00
rustc_hir_pretty Rollup merge of #93746 - cjgillot:nodefii, r=nikomatsakis 2022-02-09 14:12:22 +09:00
rustc_incremental add a rustc::query_stability lint 2022-02-01 10:15:59 +01:00
rustc_index Adopt let_else in even more places 2022-02-16 22:43:39 +01:00
rustc_infer Rollup merge of #92683 - jackh726:issue-92033, r=estebank 2022-02-18 16:23:28 +01:00
rustc_interface Rollup merge of #92933 - bjorn3:no_bin_lib_mixing, r=estebank 2022-02-18 16:23:28 +01:00
rustc_lexer
rustc_lint Overhaul Const. 2022-02-15 16:19:59 +11:00
rustc_lint_defs implement lint for suspicious auto trait impls 2022-02-01 09:55:19 +01:00
rustc_llvm llvm: migrate to new parameter-bearing uwtable attr 2022-02-14 16:09:53 -05:00
rustc_log
rustc_macros Make Decodable and Decoder infallible. 2022-01-22 10:38:31 +11:00
rustc_metadata rustdoc: Collect traits in scope for lang items 2022-02-18 16:11:23 +08:00
rustc_middle Rollup merge of #92683 - jackh726:issue-92033, r=estebank 2022-02-18 16:23:28 +01:00
rustc_mir_build use AllocId and Ty in ExprKind::StaticRef and delay ConstValue construction 2022-02-15 21:18:33 +01:00
rustc_mir_dataflow Overhaul TyS and Ty. 2022-02-15 16:03:24 +11:00
rustc_mir_transform Rollup merge of #94011 - est31:let_else, r=lcnr 2022-02-17 23:00:59 +01:00
rustc_monomorphize Rollup merge of #94011 - est31:let_else, r=lcnr 2022-02-17 23:00:59 +01:00
rustc_parse Rollup merge of #94011 - est31:let_else, r=lcnr 2022-02-17 23:00:59 +01:00
rustc_parse_format Correctly mark the span of captured arguments in format_args!() 2022-02-16 07:34:06 +00:00
rustc_passes change to a struct variant 2022-02-12 11:23:53 +00:00
rustc_plugin_impl
rustc_privacy Overhaul Const. 2022-02-15 16:19:59 +11:00
rustc_query_impl Overhaul Const. 2022-02-15 16:19:59 +11:00
rustc_query_system Revert "Auto merge of #92007 - oli-obk:lazy_tait2, r=nikomatsakis" 2022-02-11 07:18:06 +00:00
rustc_resolve Auto merge of #94088 - oli-obk:revert, r=jackh726 2022-02-18 07:35:37 +00:00
rustc_save_analysis change to a struct variant 2022-02-12 11:23:53 +00:00
rustc_serialize Drop json::from_reader 2022-02-05 15:07:10 -05:00
rustc_session Add support for control-flow protection 2022-02-14 08:31:24 -08:00
rustc_span Destabilize cfg(target_has_atomic_load_store = ...) 2022-02-16 10:28:12 -05:00
rustc_symbol_mangling Overhaul Const. 2022-02-15 16:19:59 +11:00
rustc_target Auto merge of #93577 - nikic:llvm-14, r=nagisa 2022-02-17 13:08:46 +00:00
rustc_trait_selection Rollup merge of #92683 - jackh726:issue-92033, r=estebank 2022-02-18 16:23:28 +01:00
rustc_traits Overhaul Const. 2022-02-15 16:19:59 +11:00
rustc_ty_utils Overhaul RegionKind and Region. 2022-02-15 16:08:52 +11:00
rustc_type_ir Inline UnifyKey::index and UnifyKey::from_index 2022-02-15 19:07:06 +01:00
rustc_typeck Rollup merge of #92683 - jackh726:issue-92033, r=estebank 2022-02-18 16:23:28 +01:00