bors [Sun, 29 Nov 2020 23:14:40 +0000 (23:14 +0000)]
Auto merge of #78122 - fusion-engineering-forks:fmt-write-bounds-check, 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:
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
```
bors [Sun, 29 Nov 2020 18:50:19 +0000 (18:50 +0000)]
Auto merge of #79523 - Nadrieril:fix-usize-ranges, r=varkor
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.
Joshua Nelson [Tue, 8 Sep 2020 04:07:40 +0000 (00:07 -0400)]
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.
bors [Sun, 29 Nov 2020 16:39:23 +0000 (16:39 +0000)]
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.
bors [Sun, 29 Nov 2020 14:29:23 +0000 (14:29 +0000)]
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.
bors [Sun, 29 Nov 2020 11:37:44 +0000 (11:37 +0000)]
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).`
bors [Sun, 29 Nov 2020 09:28:09 +0000 (09:28 +0000)]
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:
bstrie [Sat, 24 Oct 2020 23:21:40 +0000 (19:21 -0400)]
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.
bors [Sun, 29 Nov 2020 04:54:20 +0000 (04:54 +0000)]
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
```
bors [Sun, 29 Nov 2020 02:45:48 +0000 (02:45 +0000)]
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)
Dylan DPC [Sun, 29 Nov 2020 02:14:26 +0000 (03:14 +0100)]
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.
Dylan DPC [Sun, 29 Nov 2020 02:14:22 +0000 (03:14 +0100)]
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.
Dylan DPC [Sun, 29 Nov 2020 02:14:21 +0000 (03:14 +0100)]
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.
Dylan DPC [Sun, 29 Nov 2020 02:14:19 +0000 (03:14 +0100)]
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:
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?
Dylan DPC [Sun, 29 Nov 2020 02:14:07 +0000 (03:14 +0100)]
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.
```
Jonas Schievink [Sat, 28 Nov 2020 14:58:26 +0000 (15:58 +0100)]
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.
Jonas Schievink [Sat, 28 Nov 2020 14:58:19 +0000 (15:58 +0100)]
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](https://github.com/rust-lang/rust/blob/32da90b431919eedb3e281a91caea063ba4edb77/src/bootstrap/install.rs#L79) the install prefix path. `mkdir -p` gets invoked on the [install script](https://github.com/rust-lang/rust-installer/blob/d66f476b4d5e7fdf1ec215c9ac16c923dc292324/install-template.sh#L149).
Jonas Schievink [Sat, 28 Nov 2020 14:58:17 +0000 (15:58 +0100)]
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.
Jonas Schievink [Sat, 28 Nov 2020 14:58:15 +0000 (15:58 +0100)]
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
bors [Sat, 28 Nov 2020 07:48:56 +0000 (07:48 +0000)]
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`.
Camelid [Sun, 22 Nov 2020 22:29:46 +0000 (14:29 -0800)]
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.
bors [Sat, 28 Nov 2020 00:53:02 +0000 (00:53 +0000)]
Auto merge of #79469 - rust-lang:revert-77467-query-docs, r=jyn514
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.
bors [Fri, 27 Nov 2020 22:34:59 +0000 (22:34 +0000)]
Auto merge of #79284 - Nadrieril:constructor-module, r=varkor
Split match exhaustiveness into two files
I feel the constructor-related things in the `_match` module make enough sense on their own so I split them off. It makes `_match` feel less like a complicated mess. I'm not aware of PRs in progress against this module apart from my own so hopefully I'm not annoying too many people.
I have a lot of questions about the conventions in naming and modules around the compiler. Like, why is the module named `_match`? Could I rename it to `usefulness` maybe? Should `deconstruct_pat` be a submodule of `_match` since only `_match` uses it? Is it ok to move big piles of code around even if it makes git blame more difficult?
bors [Fri, 27 Nov 2020 19:30:58 +0000 (19:30 +0000)]
Auto merge of #79372 - jyn514:more-cleanup, r=GuillaumeGomez
Cleanup more of rustdoc
- Use `Item::from_def_id` for StructField
- Use `from_def_id_and_parts` for primitives and keywords
- Take `String` instead of `Symbol` in `from_def_id` - this avoids having to intern then immediately stringify the existing string.
- Remove unused `get_stability` and `get_deprecation`
- Remove unused `attrs` field from `primitives`
- Remove unused `attrs` field from `keywords`
This will probably conflict with https://github.com/rust-lang/rust/pull/79335 and I would prefer for that PR to land first - I'm anxious for https://github.com/rust-lang/rust/pull/77467 to land :)
Makes https://github.com/rust-lang/rust/issues/76998 easier to add.
bors [Fri, 27 Nov 2020 15:58:26 +0000 (15:58 +0000)]
Auto merge of #77484 - terhechte:support-ios-catalyst-macabi-arm64-target-triple, r=nikomatsakis
Add support for Arm64 Catalyst on ARM Macs
This is an iteration on https://github.com/rust-lang/rust/pull/63467 which was merged a while ago. In the aforementioned PR, I added support for the `X86_64-apple-ios-macabi` target triple, which is Catalyst, iOS apps running on macOS.
Very soon, Apple will launch ARM64 based Macs which will introduce `aarch64_apple_darwin.rs`, macOS apps using the Darwin ABI running on ARM. This PR adds support for Catalyst apps on ARM Macs: iOS apps compiled for the darwin ABI.
I don't have access to a Apple Developer Transition Kit (DTK), so I can't really test if the generated binaries work correctly. I'm vaguely hopeful that somebody with access to a DTK could give this a spin.