summary refs log tree commit diff
path: root/compiler/rustc_builtin_macros/src/test.rs
AgeCommit message (Collapse)AuthorLines
2023-06-25Migrate some rustc_builtin_macros to SessionDiagnosticHe1pa-6/+1
2023-06-19use `ErrorGuaranteed` instead of booleansLukas Markeffsky-59/+52
2023-06-07Deny non-lifetime generics for test functions.Lukas Markeffsky-18/+15
Previously, these were allowed if the function returned `()`, but always led to an ambiguity error.
2023-06-06Fix ICE for nested test function with arguments.Lukas Markeffsky-6/+6
2023-04-25Fix static string lintsclubby789-12/+4
2023-04-11refactor: extract `not_testable_error` into functionEzra Shaw-32/+32
2023-04-07fix: ensure bad `#[test]` invocs retain correct ASTEzra Shaw-22/+40
2023-04-04box a bunch of large typesOli Scherer-22/+26
2023-04-04Split out ast::ItemKind::Const into its own structOli Scherer-5/+5
2023-03-22rustc: Remove unused `Session` argument from some attribute functionsVadim Petrochenkov-13/+9
2023-03-20Rollup merge of #109301 - Ezrashaw:fix-ctf-ice, r=NilstriebMatthias Krüger-2/+24
fix: fix ICE in `custom-test-frameworks` feature Fixes #107454 Simple fix to emit error instead of ICEing. At some point, all the code in `tests.rs` should be refactored, there is a bit of duplication (this PR's code is repeated five times over lol). r? `@Nilstrieb` (active on the linked issue?)
2023-03-19fix: fix ICE in `custom-test-frameworks` featureEzra Shaw-2/+24
2023-03-15Implementing "<test_binary> --list --format json" #107307 #49359Partha P. Das-1/+26
2023-02-21Use `ThinVec` in a few more AST types.Nicholas Nethercote-2/+2
2023-02-21Use `ThinVec` in various AST types.Nicholas Nethercote-9/+9
This commit changes the sequence parsers to produce `ThinVec`, which triggers numerous conversions.
2022-12-18avoid .into() conversion to identical typesMatthias Krüger-2/+1
2022-12-06`rustc_builtin_macros`: remove `ref` patternsMaybe Waffle-43/+49
... and other pattern matching improvements
2022-11-29Avoid more `MetaItem`-to-`Attribute` conversions.Nicholas Nethercote-15/+3
There is code for converting `Attribute` (syntactic) to `MetaItem` (semantic). There is also code for the reverse direction. The reverse direction isn't really necessary; it's currently only used when generating attributes, e.g. in `derive` code. This commit adds some new functions for creating `Attributes`s directly, without involving `MetaItem`s: `mk_attr_word`, `mk_attr_name_value_str`, `mk_attr_nested_word`, and `ExtCtxt::attr_{word,name_value_str,nested_word}`. These new methods replace the old functions for creating `Attribute`s: `mk_attr_inner`, `mk_attr_outer`, and `ExtCtxt::attribute`. Those functions took `MetaItem`s as input, and relied on many other functions that created `MetaItems`, which are also removed: `mk_name_value_item`, `mk_list_item`, `mk_word_item`, `mk_nested_word_item`, `{MetaItem,MetaItemKind,NestedMetaItem}::token_trees`, `MetaItemKind::attr_args`, `MetaItemLit::{from_lit_kind,to_token}`, `ExtCtxt::meta_word`. Overall this cuts more than 100 lines of code and makes thing simpler.
2022-11-27Prefer doc comments over `//`-comments in compilerMaybe Waffle-7/+7
2022-11-11Rollup merge of #103445 - fmease:fix-50291, r=estebankDylan DPC-6/+12
`#[test]`: Point at return type if `Termination` bound is unsatisfied Together with #103142 (already merged) this fully fixes #50291. I don't consider my current solution of changing a few spans “here and there” very clean since the failed obligation is a `FunctionArgumentObligation` and we point at a type instead of a function argument. If you agree with me on this point, I can offer to keep the spans of the existing nodes and instead inject `let _: AssertRetTyIsTermination<$ret_ty>;` (type to be defined in `libtest`) similar to `AssertParamIsEq` etc. used by some built-in derive-macros. I haven't tried that approach yet though and cannot promise that it would actually work out or be “cleaner” for that matter. ````@rustbot```` label A-libtest A-diagnostics r? ````@estebank````
2022-10-24Rollup merge of #99939 - saethlin:pre-sort-tests, r=thomcc,jackh726Yuki Okushi-12/+25
Sort tests at compile time, not at startup Recently, another Miri user was trying to run `cargo miri test` on the crate `iced-x86` with `--features=code_asm,mvex`. This configuration has a startup time of ~18 minutes. That's ~18 minutes before any tests even start to run. The fact that this crate has over 26,000 tests and Miri is slow makes a lot of code which is otherwise a bit sloppy but fine into a huge runtime issue. Sorting the tests when the test harness is created instead of at startup time knocks just under 4 minutes out of those ~18 minutes. I have ways to remove most of the rest of the startup time, but this change requires coordinating changes of both the compiler and libtest, so I'm sending it separately. (except for doctests, because there is no compile-time harness)
2022-10-23test attr: point at return type if Termination bound unsatisfiedLeón Orell Valerian Liehr-6/+12
2022-10-02Fix duplicate usage of `a` article.Petr Portnov-1/+1
This fixes a typo first appearing in #94624 in which test-macro diagnostic uses "a" article twice. Since I searched sources for " a a " sequences, I also fixed the same issue in a few source files where I found it. Signed-off-by: Petr Portnov <gh@progrm-jarvis.ru>
2022-09-01Always import all tracing macros for the entire crate instead of piecemeal ↵Oli Scherer-1/+1
by module
2022-09-01Sort tests at compile time, not at startupBen Kimock-12/+25
Recently, another Miri user was trying to run `cargo miri test` on the crate `iced-x86` with `--features=code_asm,mvex`. This configuration has a startup time of ~18 minutes. That's ~18 minutes before any tests even start to run. The fact that this crate has over 26,000 tests and Miri is slow makes a lot of code which is otherwise a bit sloppy but fine into a huge runtime issue. Sorting the tests when the test harness is created instead of at startup time knocks just under 4 minutes out of those ~18 minutes. I have ways to remove most of the rest of the startup time, but this change requires coordinating changes of both the compiler and libtest, so I'm sending it separately.
2022-08-29Replace `rustc_data_structures::thin_vec::ThinVec` with `thin_vec::ThinVec`.Nicholas Nethercote-5/+3
`rustc_data_structures::thin_vec::ThinVec` looks like this: ``` pub struct ThinVec<T>(Option<Box<Vec<T>>>); ``` It's just a zero word if the vector is empty, but requires two allocations if it is non-empty. So it's only usable in cases where the vector is empty most of the time. This commit removes it in favour of `thin_vec::ThinVec`, which is also word-sized, but stores the length and capacity in the same allocation as the elements. It's good in a wider variety of situation, e.g. in enum variants where the vector is usually/always non-empty. The commit also: - Sorts some `Cargo.toml` dependency lists, to make additions easier. - Sorts some `use` item lists, to make additions easier. - Changes `clean_trait_ref_with_bindings` to take a `ThinVec<TypeBinding>` rather than a `&[TypeBinding]`, because this avoid some unnecessary allocations.
2022-08-22Use `AttrVec` in more places.Nicholas Nethercote-2/+3
In some places we use `Vec<Attribute>` and some places we use `ThinVec<Attribute>` (a.k.a. `AttrVec`). This results in various points where we have to convert between `Vec` and `ThinVec`. This commit changes the places that use `Vec<Attribute>` to use `AttrVec`. A lot of this is mechanical and boring, but there are some interesting parts: - It adds a few new methods to `ThinVec`. - It implements `MapInPlace` for `ThinVec`, and introduces a macro to avoid the repetition of this trait for `Vec`, `SmallVec`, and `ThinVec`. Overall, it makes the code a little nicer, and has little effect on performance. But it is a precursor to removing `rustc_data_structures::thin_vec::ThinVec` and replacing it with `thin_vec::ThinVec`, which is implemented more efficiently.
2022-06-13remove unnecessary `to_string` and `String::new`Takayuki Maeda-1/+1
2022-03-04Downgrade `#[test]` on macro call to warningEsteban Kuber-8/+12
Follow up to #92959. Address #94508.
2022-02-24Include ignore message in libtest outputAntonio Yang-0/+23
As an example: #[test] #[ignore = "not yet implemented"] fn test_ignored() { ... } Will now render as: running 2 tests test tests::test_ignored ... ignored, not yet implemented test result: ok. 1 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in 0.00s
2022-02-18Rollup merge of #92959 - asquared31415:test-non-fn-help, r=estebankMatthias Krüger-6/+16
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-01-28remove allow_fail test flagyuhaixin.hx-9/+0
2022-01-17add more info to invalid use of #[test] on invalid itemsasquared31415-6/+16
2021-12-15Add a lint for duplicated attributes.Ethiraric-1/+4
2021-11-07ast: Fix naming conventions in AST structuresVadim Petrochenkov-2/+2
TraitKind -> Trait TyAliasKind -> TyAlias ImplKind -> Impl FnKind -> Fn All `*Kind`s in AST are supposed to be enums. Tuple structs are converted to braced structs for the types above, and fields are reordered in syntactic order. Also, mutable AST visitor now correctly visit spans in defaultness, unsafety, impl polarity and constness.
2021-10-03Practice diagnostic message conventionHirochika Matsumoto-1/+1
2021-05-03proof of concept add test type on printsAliénore Bouttefeux-0/+4
2021-02-01Box the biggest ast::ItemKind variantsDániel Buga-2/+2
2020-11-24Handle `Annotatable::Stmt` in some builtin macrosAaron Hill-10/+30
This is preparation for PR #78296, which will require us to handle statement items in addition to normal items.
2020-09-10Attach `TokenStream` to `ast::Visibility`Aaron Hill-3/+6
A `Visibility` does not have outer attributes, so we only capture tokens when parsing a `macro_rules!` matcher
2020-08-30mv compiler to compiler/mark-0/+471