Commit Graph

134432 Commits

Author SHA1 Message Date
bors
760430e6fd Auto merge of #78863 - KodrAus:feat/simd-array, r=oli-obk
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-29 09:28:09 +00:00
Ashley Mannix
354c7d0ab8 args may be passed by value 2020-11-29 18:36:30 +10:00
bors
3cbb56f80b Auto merge of #79455 - CraftSpider:master, r=jyn514
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-29 07:05:49 +00:00
bstrie
90a2e5e3fe 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-29 00:55:55 -05:00
bors
6add378d6b Auto merge of #75752 - jakoschiko:test-suite-time, r=m-ou-se
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-29 04:54:20 +00:00
bors
40d7efad5e Auto merge of #79529 - Dylan-DPC:rollup-6k20msr, r=Dylan-DPC
Rollup of 11 pull requests

Successful merges:

 - #79327 (Require allocator to be static for boxed `Pin`-API)
 - #79340 (Rename "stability" CSS class to "item-info" and combine `document_stability` with `document_short`)
 - #79363 (BTreeMap: try to enhance various comments)
 - #79395 (Move ui if tests from top-level into `expr/if`)
 - #79443 (Improve rustdoc JS tests error output)
 - #79464 (Extend doc keyword feature by allowing any ident)
 - #79484 (add enable-full-tools to freebsd builds to prevent occasional link er…)
 - #79505 (Cleanup: shorter and faster code)
 - #79514 (Add test for issue #54121: order dependent trait bounds)
 - #79516 (Remove unnecessary `mut` binding)
 - #79528 (Fix a bootstrap comment)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2020-11-29 02:45:48 +00:00
Rune Tynan
d23b57c1a8
Add test for macro by example syntax in decl macros with only one option 2020-11-28 21:32:07 -05:00
Dylan DPC
d0515ce7ef
Rollup merge of #79528 - nooberfsh:fix_doc, r=Mark-Simulacrum
Fix a bootstrap comment
2020-11-29 03:14:29 +01:00
Dylan DPC
47e74a9a51
Rollup merge of #79516 - jyn514:cleanup-trait-solver, r=Aaron1011
Remove unnecessary `mut` binding

Found while fiddling around with https://github.com/rust-lang/rust/issues/77459.
2020-11-29 03:14:27 +01:00
Dylan DPC
f0e41ce495
Rollup merge of #79514 - Julian-Wollersberger:order-dependent-bounds, 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-29 03:14:26 +01:00
Dylan DPC
6eb5245555
Rollup merge of #79505 - matklad:cleanup, r=jonas-schievink
Cleanup: shorter and faster code
2020-11-29 03:14:24 +01:00
Dylan DPC
c9c81d92a9
Rollup merge of #79484 - sreehax:master, r=Mark-Simulacrum
add enable-full-tools to freebsd builds to prevent occasional link er…

On FreeBSD, there is sometimes an issue where linking a rust program will fail due to rust not finding a linker, even though lld is included in the base system. This seems to mostly affect bare metal/cross compilation things, such as wasm builds and arm/riscv bare metal work (eg. when trying to compile [this](https://github.com/quantumscraps/scraps)). On Linux and other operating systems, full tools are enabled for builds of rust, so there are no linking issues. This pr should enable fully functional builds on FreeBSD, assuming rust builds correctly with these options.
2020-11-29 03:14:22 +01:00
Dylan DPC
ca8a1b05c6
Rollup merge of #79464 - GuillaumeGomez:doc-keyword-ident, r=jyn514
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-29 03:14:21 +01:00
Dylan DPC
d5d6036478
Rollup merge of #79443 - GuillaumeGomez:improve-rustdoc-js-error-output, r=jyn514
Improve rustdoc JS tests error output

It's pretty common when starting to add new tests for rustdoc-js to have issues to understand the errors. With this, it should make things a bit simpler. So now, in case of an error, it displays:

```
---- [js-doc-test] rustdoc-js/basic.rs stdout ----

error: rustdoc-js test failed!
failed to decode compiler output as json: line: {
output: Checking "basic" ... FAILED
==> Result not found in 'others': '{"path":"basic","name":"Fo"}'
Diff of first error:
{
    "path": "basic",
    - "name": "Fo",
    + "name": "Foo",
}
thread '[js-doc-test] rustdoc-js/basic.rs' panicked at 'explicit panic', src/tools/compiletest/src/json.rs:126:21
```

I think it was ``@camelid`` who asked about it a few days ago?

r? ``@jyn514``
2020-11-29 03:14:19 +01:00
Dylan DPC
851def274d
Rollup merge of #79395 - Havvy:test-move-if, r=Mark-Simulacrum
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-29 03:14:17 +01:00
Dylan DPC
bfa854dbe5
Rollup merge of #79363 - ssomers:btree_cleanup_comments, r=Mark-Simulacrum
BTreeMap: try to enhance various comments

All in internal documentation, propagating the "key-value pair" notation from public documentation.

r? ``@Mark-Simulacrum``
2020-11-29 03:14:15 +01:00
Dylan DPC
858b44a433
Rollup merge of #79340 - GuillaumeGomez:rename-stability, r=jyn514
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-29 03:14:13 +01:00
Joshua Nelson
872acb0c35 Move src/test/rustdoc-ui intra-doc tests into a subdirectory
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-28 21:14:09 -05:00
Dylan DPC
a2b4d97984
Rollup merge of #79327 - TimDiekmann:static-alloc-pin-in-box, r=Mark-Simulacrum
Require allocator to be static for boxed `Pin`-API

Allocators has to retain their validity until the instance and all of its clones are dropped. When pinning a value, it must live forever, thus, the allocator requires a `'static` lifetime for pinning a value. [Example from reddit](https://www.reddit.com/r/rust/comments/jymzdw/the_story_continues_vec_now_supports_custom/gd7qak2?utm_source=share&utm_medium=web2x&context=3):

```rust
let alloc = MyAlloc(/* ... */);
let pinned = Box::pin_in(42, alloc);
mem::forget(pinned); // Now `value` must live forever
// Otherwise `Pin`'s invariants are violated, storage invalidated
// before Drop was called.
// borrow of `memory` can end here, there is no value keeping it.
drop(alloc); // Oh, value doesn't live forever.
```
2020-11-29 03:14:07 +01:00
Joshua Nelson
ddfb581fb9 Move src/test/rustdoc intra-doc link tests into a subdirectory
They were starting to get unwieldy.
2020-11-28 21:13:55 -05:00
nooberfsh
331d52643a Fix a bootstrap comment 2020-11-29 10:02:24 +08:00
Rune Tynan
ff690931b7
Add support for multi-argument decl macros 2020-11-28 20:51:48 -05:00
Jakob Schikowski
322f53d8a8 libtest: Make sed arguments compatible with apple 2020-11-29 02:14:49 +01:00
Ashley Mannix
90255c8da6 looser regex on local args 2020-11-29 10:18:07 +10:00
bors
914d07ae5f Auto merge of #79511 - cjgillot:fitem-2, r=lcnr
Do not visit ForeignItemRef for HIR indexing and validation.

Similarly to what is done for ImplItemRef and TraitItemRef.

Fixes #79487

r? `@lcnr`
2020-11-28 22:52:18 +00:00
Nadrieril
bdd2bdb53b Don't store ty and span in IntRange
We prefer to grab `ty` and `span` from `pcx`. This makes it consistent
with other constructors.
2020-11-28 22:07:15 +00:00
Eric Huss
d2d91b42a5 lint-docs: Add --validate flag to validate lint docs separately. 2020-11-28 13:39:02 -08:00
Eric Huss
f17e6487b2 lint-docs: Move free functions into methods of LintExtractor.
This helps avoid needing to pass so many parameters around.
2020-11-28 13:38:58 -08:00
Nadrieril
d8983655c1 Correctly detect usize/isize range overlaps 2020-11-28 21:23:38 +00:00
Joshua Nelson
870a041262 Remove unnecessary mut binding 2020-11-28 14:52:25 -05:00
Julian Wollersberger
1fa43257eb Add test for issue #54121:
"simple type inference fails depending on order of trait bounds"
2020-11-28 19:44:31 +01:00
Camille GILLOT
5bd197921a Do not visit ForeignItemRef for HIR indexing and validation.
Similarly to what is done for ImplItemRef and TraitItemRef.

Fixes #79487
2020-11-28 18:08:17 +01:00
bors
e37f25aa3f Auto merge of #79507 - jonas-schievink:rollup-e5yeayh, r=jonas-schievink
Rollup of 10 pull requests

Successful merges:

 - #78086 (Improve doc for 'as _')
 - #78853 (rustc_parse: fix ConstBlock expr span)
 - #79234 (Resolve typedefs in HashMap gdb/lldb pretty-printers)
 - #79344 (Convert UNC path to local path to satisfy install script on Windows)
 - #79383 (Fix bold code formatting in keyword docs)
 - #79460 (Remove intermediate vectors from `add_bounds`)
 - #79474 (Change comments on types to doc-comments)
 - #79476 (Sync rustc_codegen_cranelift)
 - #79478 (Expand docs on Peekable::peek_mut)
 - #79486 (Slightly improve code samples in E0591)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2020-11-28 15:17:13 +00:00
J. Ryan Stinnett
8b18f41b98 Derive Debug for DebugInfo
This was useful during testing of `dsymutil` code paths.
2020-11-28 15:07:51 +00:00
Jonas Schievink
208d680f77
Rollup merge of #79486 - camelid:E0591-code-cleanup, r=lcnr
Slightly improve code samples in E0591

* Improve formatting
* Don't hide `unsafe` block - it's important!
2020-11-28 15:58:30 +01:00
Jonas Schievink
248e5ad299
Rollup merge of #79478 - lukaslueg:peek_mut_docs, r=m-ou-se
Expand docs on Peekable::peek_mut

Slightly expand docs on `std::iter::Peekable::peek_mut`, tracked in #78302

r? `@m-ou-se`
2020-11-28 15:58:28 +01:00
Jonas Schievink
dd0f953378
Rollup merge of #79476 - bjorn3:sync_cg_clif-2020-11-27, r=bjorn3
Sync rustc_codegen_cranelift

This implements a few extra simd intrinsics, fixes yet another 128bit bug and updates a few dependencies. It also fixes an cg_clif subtree update that did compile, but that caused a panic when compiling libcore. Other than that this is mostly cleanups.

`@rustbot` modify labels: +A-codegen +A-cranelift +T-compiler
2020-11-28 15:58:26 +01:00
Jonas Schievink
afc5542a9b
Rollup merge of #79474 - jyn514:query-mode, r=Aaron1011
Change comments on types to doc-comments

Found while investigating https://github.com/rust-lang/rust/issues/79459.

r? `@Aaron1011`
2020-11-28 15:58:25 +01:00
Jonas Schievink
fe9a02c211
Rollup merge of #79460 - bugadani:simplify, r=jonas-schievink
Remove intermediate vectors from `add_bounds`

This PR removes two short lived vectors that don't serve any obvious purpose.
2020-11-28 15:58:23 +01:00
Jonas Schievink
13375864ed
Rollup merge of #79383 - abdnh:patch-1, r=shepmaster
Fix bold code formatting in keyword docs
2020-11-28 15:58:21 +01:00
Jonas Schievink
f4301a26be
Rollup merge of #79344 - JRF63:fix_install_script_win, r=Mark-Simulacrum
Convert UNC path to local path to satisfy install script on Windows

`mkdir` with the `-p` flag attempts to create `//?` if passed a UNC path. This fails on both MSYS2 and Git Bash.

The UNC paths come from [canonicalizing](32da90b431/src/bootstrap/install.rs (L79)) the install prefix path. `mkdir -p` gets invoked on the [install script](d66f476b4d/install-template.sh (L149)).
2020-11-28 15:58:19 +01:00
Jonas Schievink
93d830ed50
Rollup merge of #79234 - ortem:fix-hashmap-pretty-printers, r=Mark-Simulacrum
Resolve typedefs in HashMap gdb/lldb pretty-printers

`GetTypedefedType` (LLDB) and `strip_typedefs` (GDB) calls are needed to resolve key and value types completely.
Without these calls, debugger doesn't show the actual type.

**Before** (without `GetTypedefedType`):
```
(lldb) frame variable hm[0]
(T) hm[0] = { ... }
```

**After** (with `GetTypedefedType`):
```
(lldb) frame variable hm[0]
((i32, alloc::string::String)) hm[0] = { ... }
```

Based on https://github.com/intellij-rust/intellij-rust/pull/6258
2020-11-28 15:58:17 +01:00
Jonas Schievink
a732c3a369
Rollup merge of #78853 - calebcartwright:fix-const-block-expr-span, r=spastorino
rustc_parse: fix ConstBlock expr span

The span for a ConstBlock expression should presumably run through the end of the block it contains and not stop at the keyword, just like is done with similar block-containing expression kinds, such as a TryBlock
2020-11-28 15:58:15 +01:00
Jonas Schievink
772b1a6d79
Rollup merge of #78086 - poliorcetics:as-placeholder, r=Mark-Simulacrum
Improve doc for 'as _'

Fix #78042.

`@rustbot` modify labels: A-coercions T-doc
2020-11-28 15:58:13 +01:00
Aleksey Kladov
30d331ffb6 Cleanup: shorter and faster code 2020-11-28 17:47:34 +03:00
Tim Diekmann
7387f48e50 Require allocator to be static for boxed Pin-API 2020-11-28 15:24:44 +01:00
Stein Somers
d1a2c0f99c BTreeMap: try to enhance various comments & local identifiers 2020-11-28 10:35:02 +01:00
bors
4ae328bef4 Auto merge of #78296 - Aaron1011:fix/stmt-tokens, r=petrochenkov
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-28 07:48:56 +00:00
Rune Tynan
a61c09a897
Update src/test/rustdoc/decl_macro_priv.rs
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-11-28 00:02:46 -05:00
bors
f8e5209a21 Auto merge of #79353 - cjgillot:procmacro, r=petrochenkov
Setup proc-macro metadata at encoding instead of decoding

This should improve the common non-proc-macro case for metadata decoding.
2020-11-28 03:20:09 +00:00