about summary refs log tree commit diff
path: root/src/test
AgeCommit message (Collapse)AuthorLines
2020-12-02Tweak diagnostics on shadowing lifetimes/labelsYuki Okushi-94/+94
2020-12-01Auto merge of #78684 - devsnek:inline-asm-wasm, r=Amanieubors-2/+152
Add wasm32 support to inline asm There is some contention around inline asm and wasm, and I really only made this to figure out the process of hacking on rustc, but I figured as long as the code existed, it was worth uploading. cc `@Amanieu`
2020-12-01Add wasm32 support to inline asmGus Caplan-2/+152
2020-12-01Rollup merge of #79548 - CraftSpider:76998, r=jyn514Mara Bos-0/+10
Show since when a function is const in stdlib Fixes #76998 This makes it so that functions with the `#[rustc_const_stable()]` attribute now show from what version they were stably declared const, alongside what version they were declared stable. Example from `Result`: ![image](https://user-images.githubusercontent.com/13342132/100561194-1be60d00-3286-11eb-99ff-1e81201218a9.png) r? ``@jyn514``
2020-12-01Rollup merge of #79527 - jyn514:intra-doc-tests, r=ManishearthMara Bos-355/+351
Move intra-doc link tests into a subdirectory They were starting to get unwieldy. r? ``@Manishearth``
2020-12-01Rollup merge of #79525 - jyn514:feature-gate-normalize, r=GuillaumeGomezMara Bos-1/+1
Add -Z normalize-docs and enable it for compiler docs Works around https://github.com/rust-lang/rust/issues/79459 by only enabling normalization for the compiler itself (and anyone who opts-in on nightly). Eventually I want to remove this and enable normalization by default, but that's turned out to be [really hard](https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/How.20do.20I.20normalize.20projection.20types.20to.20a.20single.20type.3F/near/218125195). This uses a command line option instead of a feature gate so it's easier to pass it to all crates at once. Theoretically it's better to use a feature gate instead so that it's easier for people to use on docs.rs, but I'm also not terribly concerned with how easy it to use a temporary hack. Addresses https://github.com/rust-lang/rust/issues/77459.
2020-12-01Rollup merge of #79444 - sasurau4:test/move-const-ip, r=matkladMara Bos-13/+0
Move const ip in ui test to unit test Helps with #76268 r? ``@matklad``
2020-12-01Rollup merge of #79227 - sasurau4:test/move-cell-test-to-lib-core, r=jyn514Mara Bos-13/+0
Remove const_fn_feature_flags test ## Overview Helps with #76268 I found `const_fn_feature_flags` is targeting feature-gate and remove it. r? ``@matklad``
2020-12-01Rollup merge of #79038 - CDirkx:move-ui-tests, r=dtolnayMara Bos-828/+0
Change ui test that are run-pass and that do not test the compiler to library tests Part of #76268, these are some of the relevant ui tests I found that can be replaced by library tests. Note: this PR just moves the tests, I have not checked for any overlap between these tests and existing library tests. The only test I changed is `env_home_dir`, where I added code to restore the old home dir after testing. All moved tests: | ui test | library test file | test | | --- | --- | --- | | `const\ascii_ctype.rs` | `core\tests\ascii.rs` | `ascii_ctype_const` | | `const\const-str-ptr.rs` | `alloc\tests\str.rs` | `const_str_ptr` | | `assert-eq-trailing-comma.rs` | `core\tests\macros.rs` | `assert_eq_trailing_comma` | | `assert-escape.rs` | `core\tests\macros.rs` | `assert_escape` | | `assert-ne-trailing-comma.rs` | `core\tests\macros.rs` | `assert_ne_trailing_comma` | | `atomic-access-bool.rs` | `core\tests\atomic.rs` | `atomic_access_bool` | | `atomic-alignment.rs` | `core\tests\atomic.rs` | `atomic_alignment` | | `atomic-compare_exchange.rs` | `core\tests\atomic.rs` | `atomic_compare_exchange` | | ~~`atomic-print.rs`~~ | ~~`std\tests\process.rs`~~ | ~~`atomic_print`~~ | | `bool.rs` | `core\tests\bool.rs` | `test_bool` | | `bool_not.rs` | `core\tests\bool.rs` | `test_bool_not` | | `char_unicode.rs` | `core\tests\unicode.rs` | `version` | | `cmp-default.rs` | `core\tests\cmp.rs` | `cmp_default` | | `deref-mut-on-ref.rs` | `core\tests\ops.rs` | `deref_mut_on_ref` | | `deref-on-ref.rs` | `core\tests\ops.rs` | `deref_on_ref` | | `env-home-dir.rs` | `std\tests\env.rs` | `env_home_dir` | | ~~`env-vars.rs`~~ | ~~`std\tests\env.rs`~~ | ~~`env_vars`~~ | | `extend-for-unit.rs` | `core\tests\iter.rs` | `extend_for_unit` | | `offset_from.rs` | `core\tests\ptr.rs` | `offset_from` | | `option-ext.rs` | `core\tests\option.rs` | `option_ext` | | `result-opt-conversions.rs` | `core\tests\result.rs` | `result_opt_conversions` | | `sleep.rs` | `std\tests\thread.rs` | `sleep` | | ~~`try-wait.rs`~~ | ~~`std\tests\process.rs`~~ | ~~`try_wait`~~ | | `utf8.rs` | `alloc\tests\str.rs` | `utf8` | | `utf8_chars.rs` | `alloc\tests\str.rs` | `utf8_chars` | | `wrapping-int-api.rs` | `core\tests\num\wrapping.rs` | `wrapping_int_api` |
2020-12-01Auto merge of #78725 - sexxi-goose:fix-78720, r=nikomatsakisbors-0/+74
Remove extra call to upvar_tys We already visit the tuple of upvar_tys, we don't need to visit each individual type. Fixes #78720 r? `@ghost`
2020-11-30Auto merge of #76467 - jyn514:intra-link-self, r=Manishearthbors-0/+49
Fix intra-doc links for `Self` on cross-crate items and primitives - Remove the difference between `parent_item` and `current_item`; these should never have been different. - Remove `current_item` from `resolve` and `variant_field` so that `Self` is only substituted in one place at the very start. - Resolve the current item as a `DefId`, not a `HirId`. This is what actually fixed the bug. Hacks: - `clean` uses `TypedefItem` when it _really_ should be `AssociatedTypeItem`. I tried fixing this without success and hacked around it instead (see comments) - This second-guesses the `to_string()` impl since it wants fully-qualified paths. Possibly there's a better way to do this.
2020-11-29Add support for stable-const-since in docs on items (standalone or assoc)Rune Tynan-0/+10
2020-11-30Make ui test that are run-pass and do not test the compiler itself library testsChristiaan Dirkx-828/+0
2020-11-30Auto merge of #79329 - camelid:int-lit-suffix-error, r=davidtwcobors-13/+13
Update error to reflect that integer literals can have float suffixes For example, `1` is parsed as an integer literal, but it can be turned into a float with the suffix `f32`. Now the error calls them "numeric literals" and notes that you can add a float suffix since they can be either integers or floats.
2020-11-29Remove extra call to upvar_tysAman Arora-0/+74
Fixes #78720
2020-11-29Auto merge of #78122 - fusion-engineering-forks:fmt-write-bounds-check, ↵bors-0/+57
r=Mark-Simulacrum Avoid panic_bounds_check in fmt::write. Writing any fmt::Arguments would trigger the inclusion of usize formatting and padding code in the resulting binary, because indexing used in fmt::write would generate code using panic_bounds_check, which prints the index and length. These bounds checks are not necessary, as fmt::Arguments never contains any out-of-bounds indexes. This change replaces them with unsafe get_unchecked, to reduce the amount of generated code, which is especially important for embedded targets. --- Demonstration of the size of and the symbols in a 'hello world' no_std binary: <details> <summary>Source code</summary> ```rust #![feature(lang_items)] #![feature(start)] #![no_std] use core::fmt; use core::fmt::Write; #[link(name = "c")] extern "C" { #[allow(improper_ctypes)] fn write(fd: i32, s: &str) -> isize; fn exit(code: i32) -> !; } struct Stdout; impl fmt::Write for Stdout { fn write_str(&mut self, s: &str) -> fmt::Result { unsafe { write(1, s) }; Ok(()) } } #[start] fn main(_argc: isize, _argv: *const *const u8) -> isize { let _ = writeln!(Stdout, "Hello World"); 0 } #[lang = "eh_personality"] fn eh_personality() {} #[panic_handler] fn panic(_: &core::panic::PanicInfo) -> ! { unsafe { exit(1) }; } ``` </details> Before: ``` text data bss dec hex filename 6059 736 8 6803 1a93 before ``` ``` 0000000000001e00 T <T as core::any::Any>::type_id 0000000000003dd0 D core::fmt::num::DEC_DIGITS_LUT 0000000000001ce0 T core::fmt::num::imp::<impl core::fmt::Display for u64>::fmt 0000000000001ce0 T core::fmt::num::imp::<impl core::fmt::Display for usize>::fmt 0000000000001370 T core::fmt::write 0000000000001b30 t core::fmt::Formatter::pad_integral::write_prefix 0000000000001660 T core::fmt::Formatter::pad_integral 0000000000001350 T core::ops::function::FnOnce::call_once 0000000000001b80 t core::ptr::drop_in_place 0000000000001120 t core::ptr::drop_in_place 0000000000001c50 t core::iter::adapters::zip::Zip<A,B>::new 0000000000001c90 t core::iter::adapters::zip::Zip<A,B>::new 0000000000001b90 T core::panicking::panic_bounds_check 0000000000001c10 T core::panicking::panic_fmt 0000000000001130 t <&mut W as core::fmt::Write>::write_char 0000000000001200 t <&mut W as core::fmt::Write>::write_fmt 0000000000001250 t <&mut W as core::fmt::Write>::write_str ``` After: ``` text data bss dec hex filename 3068 600 8 3676 e5c after ``` ``` 0000000000001360 T core::fmt::write 0000000000001340 T core::ops::function::FnOnce::call_once 0000000000001120 t core::ptr::drop_in_place 0000000000001620 t core::iter::adapters::zip::Zip<A,B>::new 0000000000001660 t core::iter::adapters::zip::Zip<A,B>::new 0000000000001130 t <&mut W as core::fmt::Write>::write_char 0000000000001200 t <&mut W as core::fmt::Write>::write_fmt 0000000000001250 t <&mut W as core::fmt::Write>::write_str ```
2020-11-29Add -Z normalize-docs and enable it for compiler docsJoshua Nelson-1/+1
2020-11-29Auto merge of #79209 - spastorino:trait-inheritance-self, r=nikomatsakisbors-79/+192
Allow Trait inheritance with cycles on associated types Fixes #35237 r? `@nikomatsakis` cc `@estebank`
2020-11-29Add test for cross-crate SelfJoshua Nelson-0/+13
2020-11-29Auto merge of #79523 - Nadrieril:fix-usize-ranges, r=varkorbors-2/+8
Fix overlap detection of `usize`/`isize` range patterns `usize` and `isize` are a bit of a special case in the match usefulness algorithm, because the range of values they contain depends on the platform. Specifically, we don't want `0..usize::MAX` to count as an exhaustive match (see also [`precise_pointer_size_matching`](https://github.com/rust-lang/rust/issues/56354)). The way this was initially implemented is by treating those ranges like float ranges, i.e. with limited cleverness. This means we didn't catch the following as unreachable: ```rust match 0usize { 0..10 => {}, 10..20 => {}, 5..15 => {}, // oops, should be detected as unreachable _ => {}, } ``` This PRs fixes this oversight. Now the only difference between `usize` and `u64` range patterns is in what ranges count as exhaustive. r? `@varkor` `@rustbot` label +A-exhaustiveness-checking
2020-11-29Fix intra-doc links for `Self` on primitivesJoshua Nelson-0/+36
- Remove the difference between `parent_item` and `current_item`; these should never have been different. - Remove `current_item` from `resolve` and `variant_field` so that `Self` is only substituted in one place at the very start. - Resolve the current item as a `DefId`, not a `HirId`. This is what actually fixed the bug. Hacks: - `clean` uses `TypedefItem` when it _really_ should be `AssociatedTypeItem`. I tried fixing this without success and hacked around it instead (see comments) - This stringifies DefIds, then resolves them a second time. This is really silly and rustdoc should just use DefIds throughout. Fixing this is a larger task than I want to take on right now.
2020-11-29Auto merge of #78380 - bstrie:rm-old-num-const-from-tests, r=jyn514bors-492/+428
Update tests to remove old numeric constants Part of #68490. Care has been taken to leave the old consts where appropriate, for testing backcompat regressions, module shadowing, etc. The intrinsics docs were accidentally referring to some methods on f64 as std::f64, which I changed due to being contrary with how we normally disambiguate the shadow module from the primitive. In one other place I changed std::u8 to std::ops since it was just testing path handling in macros. For places which have legitimate uses of the old consts, deprecated attributes have been optimistically inserted. Although currently unnecessary, they exist to emphasize to any future deprecation effort the necessity of these specific symbols and prevent them from being accidentally removed.
2020-11-29Add test to check for fmt::write bloat.Mara Bos-0/+57
It checks that fmt::write by itself doesn't pull in any panicking or or display code.
2020-11-29Auto merge of #78863 - KodrAus:feat/simd-array, r=oli-obkbors-71/+306
Support repr(simd) on ADTs containing a single array field This is a squash and rebase of `@gnzlbg's` #63531 I've never actually written code in the compiler before so just fumbled my way around until it would build 😅 I imagine there'll be some work we need to do in `rustc_codegen_cranelift` too for this now, but might need some input from `@bjorn3` to know what that is. cc `@rust-lang/project-portable-simd` ----- This PR allows using `#[repr(simd)]` on ADTs containing a single array field: ```rust #[repr(simd)] struct S0([f32; 4]); #[repr(simd)] struct S1<const N: usize>([f32; N]); #[repr(simd)] struct S2<T, const N: usize>([T; N]); ``` This should allow experimenting with portable packed SIMD abstractions on nightly that make use of const generics.
2020-11-29args may be passed by valueAshley Mannix-4/+4
2020-11-29Auto merge of #79455 - CraftSpider:master, r=jyn514bors-0/+53
Remove doctree::Macro and distinguish between `macro_rules!` and `pub macro` This is a part of #78082, removing doctree::Macro. Uses the changes in #79372 Fixes #76761
2020-11-29Update tests to remove old numeric constantsbstrie-492/+428
Part of #68490. Care has been taken to leave the old consts where appropriate, for testing backcompat regressions, module shadowing, etc. The intrinsics docs were accidentally referring to some methods on f64 as std::f64, which I changed due to being contrary with how we normally disambiguate the shadow module from the primitive. In one other place I changed std::u8 to std::ops since it was just testing path handling in macros. For places which have legitimate uses of the old consts, deprecated attributes have been optimistically inserted. Although currently unnecessary, they exist to emphasize to any future deprecation effort the necessity of these specific symbols and prevent them from being accidentally removed.
2020-11-29Auto merge of #75752 - jakoschiko:test-suite-time, r=m-ou-sebors-53/+122
libtest: Print the total time taken to execute a test suite Print the total time taken to execute a test suite by default, without any kind of flag. Closes #75660 # Example ``` anon@anon:~/code/rust/example$ cargo test Compiling example v0.1.0 (/home/anon/code/rust/example) Finished test [unoptimized + debuginfo] target(s) in 0.18s Running target/debug/deps/example-745b64d3885c3565 running 3 tests test tests::foo ... ok test tests::bar ... ok test tests::baz ... ok test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; 1.2s Doc-tests example running 3 tests test src/lib.rs - foo (line 3) ... ok test src/lib.rs - bar (line 11) ... ok test src/lib.rs - baz (line 19) ... ok test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; 1.3s ``` ``` anon@anon:~/code/rust/example$ cargo test -- --format terse Finished test [unoptimized + debuginfo] target(s) in 0.08s Running target/debug/deps/example-745b64d3885c3565 running 3 tests ... test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; 1.2s Doc-tests example running 3 tests ... test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; 1.3s ``` ``` anon@anon:~/code/rust/example$ cargo test -- --format json -Z unstable-options Compiling example v0.1.0 (/home/anon/code/rust/example) Finished test [unoptimized + debuginfo] target(s) in 0.25s Running target/debug/deps/example-745b64d3885c3565 { "type": "suite", "event": "started", "test_count": 3 } { "type": "test", "event": "started", "name": "tests::bar" } { "type": "test", "event": "started", "name": "tests::baz" } { "type": "test", "event": "started", "name": "tests::foo" } { "type": "test", "name": "tests::foo", "event": "ok" } { "type": "test", "name": "tests::bar", "event": "ok" } { "type": "test", "name": "tests::baz", "event": "ok" } { "type": "suite", "event": "ok", "passed": 3, "failed": 0, "allowed_fail": 0, "ignored": 0, "measured": 0, "filtered_out": 0, "exec_time": "1.2s" } Doc-tests example { "type": "suite", "event": "started", "test_count": 3 } { "type": "test", "event": "started", "name": "src/lib.rs - bar (line 11)" } { "type": "test", "event": "started", "name": "src/lib.rs - baz (line 19)" } { "type": "test", "event": "started", "name": "src/lib.rs - foo (line 3)" } { "type": "test", "name": "src/lib.rs - foo (line 3)", "event": "ok" } { "type": "test", "name": "src/lib.rs - bar (line 11)", "event": "ok" } { "type": "test", "name": "src/lib.rs - baz (line 19)", "event": "ok" } { "type": "suite", "event": "ok", "passed": 3, "failed": 0, "allowed_fail": 0, "ignored": 0, "measured": 0, "filtered_out": 0, "exec_time": "1.3s" } ```
2020-11-28Add test for macro by example syntax in decl macros with only one optionRune Tynan-0/+7
2020-11-29Rollup merge of #79514 - Julian-Wollersberger:order-dependent-bounds, ↵Dylan DPC-0/+47
r=Mark-Simulacrum Add test for issue #54121: order dependent trait bounds This adds a test for #54121, which has already been fixed by #73905. Now that issue can be closed. I tested the test [on the playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=6cb061d3b81518f268649551eb67769f) where it indeed fails on stable 1.48, but compiles successfully on beta and nightly. fixes #54121
2020-11-29Rollup merge of #79464 - GuillaumeGomez:doc-keyword-ident, r=jyn514Dylan DPC-0/+17
Extend doc keyword feature by allowing any ident Part of #51315. As suggested by ``@danielhenrymantilla`` in [this comment](https://github.com/rust-lang/rust/issues/51315#issuecomment-733879934), this PR extends `#[doc(keyword = "...")]` to allow any ident to be used as keyword. The final goal is to allow (proc-)macro crates' owners to write documentation of the keywords they might introduce. r? ``@jyn514``
2020-11-29Rollup merge of #79395 - Havvy:test-move-if, r=Mark-SimulacrumDylan DPC-0/+0
Move ui if tests from top-level into `expr/if` This lowers the number of top-level files in src/test/ui from 1612 to 1604.
2020-11-29Rollup merge of #79340 - GuillaumeGomez:rename-stability, r=jyn514Dylan DPC-7/+7
Rename "stability" CSS class to "item-info" and combine `document_stability` with `document_short` Follow-up of #79300 The point of this PR is to make the CSS class more accurate since it's not only about stability anymore. r? ``@jyn514``
2020-11-28Move `src/test/rustdoc-ui` intra-doc tests into a subdirectoryJoshua Nelson-97/+97
This also changes the builder to allow using `x.py test src/test/rustdoc-ui/intra-doc`; before, it would panic that no paths were found.
2020-11-28Move `src/test/rustdoc` intra-doc link tests into a subdirectoryJoshua Nelson-258/+254
They were starting to get unwieldy.
2020-11-28Add support for multi-argument decl macrosRune Tynan-0/+17
2020-11-29libtest: Make `sed` arguments compatible with appleJakob Schikowski-2/+2
2020-11-29looser regex on local argsAshley Mannix-6/+6
2020-11-28Auto merge of #79511 - cjgillot:fitem-2, r=lcnrbors-0/+12
Do not visit ForeignItemRef for HIR indexing and validation. Similarly to what is done for ImplItemRef and TraitItemRef. Fixes #79487 r? `@lcnr`
2020-11-28Correctly detect `usize`/`isize` range overlapsNadrieril-2/+8
2020-11-28Add test for issue #54121:Julian Wollersberger-0/+47
"simple type inference fails depending on order of trait bounds"
2020-11-28Do not visit ForeignItemRef for HIR indexing and validation.Camille GILLOT-0/+12
Similarly to what is done for ImplItemRef and TraitItemRef. Fixes #79487
2020-11-28Rollup merge of #79486 - camelid:E0591-code-cleanup, r=lcnrJonas Schievink-5/+13
Slightly improve code samples in E0591 * Improve formatting * Don't hide `unsafe` block - it's important!
2020-11-28Auto merge of #78296 - Aaron1011:fix/stmt-tokens, r=petrochenkovbors-119/+376
Properly handle attributes on statements We now collect tokens for the underlying node wrapped by `StmtKind` nstead of storing tokens directly in `Stmt`. `LazyTokenStream` now supports capturing a trailing semicolon after it is initially constructed. This allows us to avoid refactoring statement parsing to wrap the parsing of the semicolon in `parse_tokens`. Attributes on item statements (e.g. `fn foo() { #[bar] struct MyStruct; }`) are now treated as item attributes, not statement attributes, which is consistent with how we handle attributes on other kinds of statements. The feature-gating code is adjusted so that proc-macro attributes are still allowed on item statements on stable. Two built-in macros (`#[global_allocator]` and `#[test]`) needed to be adjusted to support being passed `Annotatable::Stmt`.
2020-11-28Update src/test/rustdoc/decl_macro_priv.rsRune Tynan-0/+1
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-11-27Update error to reflect that integer literals can have float suffixesCamelid-13/+13
For example, `1` is parsed as an integer literal, but it can be turned into a float with the suffix `f32`. Now the error calls them "numeric literals" and notes that you can add a float suffix since they can be either integers or floats.
2020-11-27Slightly improve code samples in E0591Camelid-5/+13
* Improve formatting * Don't hide `unsafe` block - it's important!
2020-11-27Update decl_macro test, add decl_macro_priv test for --document-private-itemsRune Tynan-3/+15
2020-11-27Add test, fix pub macro impl, compile errorRune Tynan-0/+16
2020-11-28Auto merge of #79469 - rust-lang:revert-77467-query-docs, r=jyn514bors-0/+1
Revert "Normalize `<X as Y>::T` for rustdoc" Reverts rust-lang/rust#77467 by disabling normalization. See https://github.com/rust-lang/rust/issues/79459; I intend to reland normalization once that's fixed. r? `@Aaron1011` cc `@oli-obk` `@GuillaumeGomez`