Commit graph

134391 commits

Author SHA1 Message Date
Joshua Nelson 6ab1f05697 Fix intra-doc links for Self on 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 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-29 13:40:08 -05:00
unknown de3a0bdf05 Fixes #79357 unstable or-pat suggestions 2020-11-29 15:31:45 -03:00
bors 88b81970ba Auto merge of #79482 - faern:bump-dependencies-invalidly-assuming-mem-layout, r=Mark-Simulacrum
Bump dependencies invalidly assuming memory layout of SocketAddr

Bumps net2, socket2 and miow.
Helps unblock #78802

Done as separate PR since frequent lockfile collisions is a thing... And since the main PR can't be merged until large parts of the ecosystem uses the newer crates only, so we have to start somewhere.
2020-11-29 16:39:23 +00:00
Eric Huss a90fdfc701 lint-docs: Use strip-prefix to simplify. 2020-11-29 07:57:55 -08:00
Eric Huss 228510b0ec lint-docs: Add some extra detail to the error message.
This will hopefully help users figure out what was wrong and how
to fix it.
2020-11-29 07:39:36 -08:00
bors af780e569d Auto merge of #78380 - bstrie:rm-old-num-const-from-tests, r=jyn514
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 14:29:23 +00:00
bors 2e5723137b Auto merge of #77616 - jyn514:no-normalize, r=lcnr
Don't run `resolve_vars_if_possible` in `normalize_erasing_regions`

Neither `@eddyb` nor I could figure out what this was for. I changed it to `assert_eq!(normalized_value, infcx.resolve_vars_if_possible(&normalized_value));` and it passed the UI test suite.

<details><summary>

Outdated, I figured out the issue - `needs_infer()` needs to come _after_ erasing the lifetimes

</summary>

Strangely, if I change it to `assert!(!normalized_value.needs_infer())` it panics almost immediately:

```
query stack during panic:
#0 [normalize_generic_arg_after_erasing_regions] normalizing `<str::IsWhitespace as str::pattern::Pattern>::Searcher`
#1 [needs_drop_raw] computing whether `str::iter::Split<str::IsWhitespace>` needs drop
#2 [mir_built] building MIR for `str::<impl str>::split_whitespace`
#3 [unsafety_check_result] unsafety-checking `str::<impl str>::split_whitespace`
#4 [mir_const] processing MIR for `str::<impl str>::split_whitespace`
#5 [mir_promoted] processing `str::<impl str>::split_whitespace`
#6 [mir_borrowck] borrow-checking `str::<impl str>::split_whitespace`
#7 [analysis] running analysis passes on this crate
end of query stack
```

I'm not entirely sure what's going on - maybe the two disagree?

</details>

For context, this came up while reviewing https://github.com/rust-lang/rust/pull/77467/ (cc `@lcnr).`

Possibly this needs a crater run?

r? `@nikomatsakis`
cc `@matthewjasper`
2020-11-29 11:37:44 +00:00
Mara Bos 1da5780303 Add test to check for fmt::write bloat.
It checks that fmt::write by itself doesn't pull in any panicking or
or display code.
2020-11-29 11:38:51 +01:00
Linus Färnstrand f9220c3b14 Bump dependencies invalidly assuming memory layout of SocketAddr
Bumps net2, socket2 and miow.
Helps unblock https://github.com/rust-lang/rust/pull/78802
2020-11-29 10:51:03 +01:00
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