bors [Sun, 24 Jan 2021 02:59:14 +0000 (02:59 +0000)]
Auto merge of #80594 - bjorn3:abi_refactor3, r=petrochenkov
Various ABI refactorings
This includes changes to the rust abi and various refactorings that will hopefully make it easier to use the abi handling infrastructure of rustc in cg_clif. There are several refactorings that I haven't done. I am opening this draft PR to check that I haven't broken any non x86_64 architectures.
bors [Sat, 23 Jan 2021 21:13:14 +0000 (21:13 +0000)]
Auto merge of #81304 - jonas-schievink:rollup-d9kuugm, r=jonas-schievink
Rollup of 15 pull requests
Successful merges:
- #79841 (More clear documentation for NonNull<T>)
- #81072 (PlaceRef::ty: use method call syntax)
- #81130 (Edit rustc_middle::dep_graph module documentation)
- #81170 (Avoid hash_slice in VecDeque's Hash implementation)
- #81243 (mir: Improve size_of handling when arg is unsized)
- #81245 (Update cargo)
- #81249 (Lower closure prototype after its body.)
- #81252 (Add more self-profile info to rustc_resolve)
- #81275 (Fix <unknown> queries and add more timing info to render_html)
- #81281 (Inline methods of Path and OsString)
- #81283 (Note library tracking issue template in tracking issue template.)
- #81285 (Remove special casing of rustdoc in rustc_lint)
- #81288 (rustdoc: Fix visibility of trait and impl items)
- #81298 (replace RefCell with Cell in FnCtxt)
- #81301 (Fix small typo)
Aaron Hill [Mon, 7 Dec 2020 22:44:40 +0000 (17:44 -0500)]
Add disambiugator to ExpnData
Due to macro expansion, its possible to end up with two distinct
`ExpnId`s that have the same `ExpnData` contents. This violates the
contract of `HashStable`, since two unequal `ExpnId`s will end up with
equal `Fingerprint`s.
This commit adds a `disambiguator` field to `ExpnData`, which is used to
force two otherwise-equivalent `ExpnData`s to be distinct.
This happened because `alloc_query_strings` was never called.
## Add more timing info to render_html
This still has some issues I'm not sure how to work out:
- `create_renderer` and `renderer_after_krate` aren't shown by default.
I want something like `verbose_generic_activity_with_arg`, but it doesn't exist.
I'm also not sure how to show activities that aren't on by default - I
tried `-Z self-profile -Z self-profile-args=all`, but it didn't show up.
Jonas Schievink [Sat, 23 Jan 2021 19:16:09 +0000 (20:16 +0100)]
Rollup merge of #81252 - jyn514:resolve-timing, r=petrochenkov
Add more self-profile info to rustc_resolve
The idea is to help me find out where the time is being spent in compiling the docs for `windows-rs`: https://github.com/microsoft/windows-rs/issues/420#issuecomment-764991646
Jonas Schievink [Sat, 23 Jan 2021 19:16:05 +0000 (20:16 +0100)]
Rollup merge of #81245 - ehuss:update-cargo, r=ehuss
Update cargo
5 commits in a73e5b7d567c3036b296fc6b33ed52c5edcd882e..783bc43c660bf39c1e562c8c429b32078ad3099b
2021-01-12 23:45:39 +0000 to 2021-01-20 19:02:26 +0000
- Fix some issues with `cargo doc` and the new feature resolver. (rust-lang/cargo#9077)
- Implement support for rust-version field in project metadata (rust-lang/cargo#8037)
- Fix a bug in Cargo's cyclic dep graph detection (rust-lang/cargo#9075)
- Typo correction: artifcats -> artifacts (rust-lang/cargo#9081)
- Remove stray backtick from doc (rust-lang/cargo#9079)
Jonas Schievink [Sat, 23 Jan 2021 19:15:54 +0000 (20:15 +0100)]
Rollup merge of #79841 - fintelia:patch-6, r=kennytm
More clear documentation for NonNull<T>
Rephrase and hopefully clarify the discussion of covariance in `NonNull<T>` documentation.
I'm very much not an expert so someone should definitely double check the correctness of what I'm saying. At the same time, the new language makes more sense to me, so hopefully it also is more logical to others whose knowledge of covariance basically begins and ends with the [Rustonomicon chapter](https://doc.rust-lang.org/nomicon/subtyping.html).
bors [Sat, 23 Jan 2021 13:19:04 +0000 (13:19 +0000)]
Auto merge of #80579 - RalfJung:no-fallible-promotion, r=oli-obk
avoid promoting division, modulo and indexing operations that could fail
For division, `x / y` will still be promoted if `y` is a non-zero integer literal; however, `1/(1+1)` will not be promoted any more.
While at it, also see if we can reject promoting floating-point arithmetic (which are [complicated](https://github.com/rust-lang/unsafe-code-guidelines/issues/237) so maybe we should not promote them).
This will need a crater run to see if there's code out there that relies on these things being promoted.
If we can land this, promoteds in `fn`/`const fn` cannot fail to evaluate any more, which should let us do some simplifications in codegen/Miri!
Cc https://github.com/rust-lang/rfcs/pull/3027
Fixes https://github.com/rust-lang/rust/issues/61821
r? `@oli-obk`
bjorn3 [Sun, 27 Dec 2020 18:59:37 +0000 (19:59 +0100)]
Use PassMode::Pair by default for Abi::ScalarPair for all abi's and in return position
Abi::ScalarPair is only ever used for types that don't have a stable
layout anyway so this doesn't break any FFI. It does however reduce the
amount of special casing on the abi outside of the code responsible for
abi specific adjustments to the pass mode.
bors [Sat, 23 Jan 2021 09:25:11 +0000 (09:25 +0000)]
Auto merge of #80715 - JulianKnodt:skip_opt, r=nagisa
Change branching in `iter.skip()`
Optimize branching in `Skip`, which was brought up in #80416.
This assumes that if `next` is called, it's likely that there will be more calls to `next`, and the branch for skip will only be hit once thus it's unlikely to take that path. Even w/o the `unlikely` intrinsic, it compiles more efficiently, I believe because the path where `next` is called is always taken.
It should be noted there are very few places in the compiler where `Skip` is used, so probably won't have a noticeable perf impact.
bors [Sat, 23 Jan 2021 06:27:21 +0000 (06:27 +0000)]
Auto merge of #80065 - b-naber:parse-angle-arg-diagnostics, r=petrochenkov
Improve diagnostics when parsing angle args
https://github.com/rust-lang/rust/pull/79266 introduced parsing of generic arguments in associated type constraints, this however resulted in possibly very confusing error messages in cases in which closing angle brackets were missing such as in `Vec<(u32, _, _) = vec![]`, which outputs an incorrectly parsed equality constraint error, as noted by `@cynecx.`
This PR tries to provide better error messages in such cases.
bors [Sat, 23 Jan 2021 03:33:16 +0000 (03:33 +0000)]
Auto merge of #76391 - danii:master, r=cuviper
Split up core/test/iter.rs into multiple files
This PR removes the `// ignore-tidy-filelength` at the top of [iter.rs](https://github.com/rust-lang/rust/blob/04f44fb9232dc960d213d0df4a203c387215a5ff/library/core/tests/iter.rs) by splitting it into several sub files. I have split the file per test, based on what I felt the test was really trying to test.
Addresses issue #60302.
- [associated_util.rs](https://github.com/rust-lang/rust/blob/d29180a8ed2752c5dfa2bca1d28ca05dc9bf6bf1/library/core/tests/iter/associated_util.rs) - For testing the module level functions. (Maybe should be renamed?)
- [collection.rs](https://github.com/rust-lang/rust/blob/d29180a8ed2752c5dfa2bca1d28ca05dc9bf6bf1/library/core/tests/iter/collection.rs) - For testing methods that use the values of all the items in an iterator, and creates one value from them, whether it be a Vec of all the values, or a number that represents the sum.
- [mod.rs](https://github.com/rust-lang/rust/blob/d29180a8ed2752c5dfa2bca1d28ca05dc9bf6bf1/library/core/tests/iter/mod.rs) - For utility structs used in all tests, and other tests I didn't know where to place.
- [range.rs](https://github.com/rust-lang/rust/blob/d29180a8ed2752c5dfa2bca1d28ca05dc9bf6bf1/library/core/tests/iter/range.rs) - For testing ranges.
- [transformation.rs](https://github.com/rust-lang/rust/blob/d29180a8ed2752c5dfa2bca1d28ca05dc9bf6bf1/library/core/tests/iter/transformation.rs) - For testing methods that transform all the values in an iterator.
- [util.rs](https://github.com/rust-lang/rust/blob/d29180a8ed2752c5dfa2bca1d28ca05dc9bf6bf1/library/core/tests/iter/util.rs) - For testing methods that provide utility in more specific use cases.
"Programatically"
-----------------------
You may have noticed I "Programatically" split up the file. [This is how](https://gist.github.com/danii/a58b3bcafa9faf1c3e4b01ad7495baf4) I managed to do that. 😛 Hope that's fine.
bors [Sat, 23 Jan 2021 00:42:37 +0000 (00:42 +0000)]
Auto merge of #81017 - Aaron1011:collect-trailing-token, r=petrochenkov
Refactor token collection to capture trailing token immediately
Split out from https://github.com/rust-lang/rust/pull/80689 - when we start capturing more information about attribute targets, we'll need to know in advance if we're capturing a trailing token or not.
bors [Fri, 22 Jan 2021 21:48:41 +0000 (21:48 +0000)]
Auto merge of #79233 - yoshuawuyts:alloc-doc-alias, r=GuillaumeGomez
Add doc aliases for memory allocations
This patch adds doc aliases for various C allocation functions, making it possible to search for the C-equivalent of a function and finding the (safe) Rust counterpart:
It's worth noting that `Vec::new` does not allocate, so we don't link to it. Instead people are probably looking for `Vec::with_capacity` or `vec!`. I hope this will allow people comfortable with the system allocation APIs to make it easier to find what they may be looking for.
bors [Fri, 22 Jan 2021 16:04:36 +0000 (16:04 +0000)]
Auto merge of #81271 - m-ou-se:rollup-xv7gq3w, r=m-ou-se
Rollup of 10 pull requests
Successful merges:
- #80573 (Deny rustc::internal lints for rustdoc and clippy)
- #81173 (Expand docs on Iterator::intersperse)
- #81194 (Stabilize std::panic::panic_any.)
- #81202 (Don't prefix 0x for each segments in `dbg!(Ipv6)`)
- #81225 (Make 'docs' nullable in rustdoc-json output)
- #81227 (Remove doctree::StructType)
- #81233 (Document why not use concat! in dbg! macro)
- #81236 (Gracefully handle loop labels missing leading `'` in different positions)
- #81241 (Turn alloc's force_expr macro into a regular macro_rules.)
- #81242 (Enforce statically that `MIN_NON_ZERO_CAP` is calculated at compile time)
Mara Bos [Fri, 22 Jan 2021 14:30:21 +0000 (14:30 +0000)]
Rollup merge of #81241 - m-ou-se:force-expr-macro-rules, r=oli-obk
Turn alloc's force_expr macro into a regular macro_rules.
This turns `alloc`'s `force_expr` macro into a regular `macro_rules`.
Otherwise rust-analyzer doesn't understand `vec![]`. See https://github.com/rust-analyzer/rust-analyzer/issues/7349 and https://github.com/rust-lang/rust/pull/81080#issuecomment-764741721
Edit: See https://github.com/rust-lang/rust/pull/81241#issuecomment-764812660 for a discussion of alternatives.
Mara Bos [Fri, 22 Jan 2021 14:30:19 +0000 (14:30 +0000)]
Rollup merge of #81236 - estebank:everybody-loop-now, r=oli-obk
Gracefully handle loop labels missing leading `'` in different positions
Fix #81192.
* Account for labels when suggesting `loop` instead of `while true`
* Suggest `'a` when given `a` only when appropriate
* Add loop head span to hir
* Tweak error for invalid `break expr`
* Add more misspelled label tests
* Avoid emitting redundant "unused label" lint
* Parse loop labels missing a leading `'`
Mara Bos [Fri, 22 Jan 2021 14:30:17 +0000 (14:30 +0000)]
Rollup merge of #81233 - lzutao:dbg, r=KodrAus
Document why not use concat! in dbg! macro
Original title: Reduce code generated by `dbg!` macro
The expanded code before/after: <https://rust.godbolt.org/z/hE3j95>.
---
We cannot use `concat!` since `file!` could contains `{` or the expression is a block (`{ .. }`).
Using it will generated malformed format strings.
So let's document this reason why we don't use `concat!` macro at all.
Mara Bos [Fri, 22 Jan 2021 14:30:16 +0000 (14:30 +0000)]
Rollup merge of #81227 - CraftSpider:struct-type-clean, r=jyn514
Remove doctree::StructType
Also removes it from the Union type, as unions can only ever be 'Plain'. Adds a new StructType to JSON, 'union', as the easiest way to encode the type of a union there. This leaves only one item in doctree, `Module`.
Mara Bos [Fri, 22 Jan 2021 14:30:03 +0000 (14:30 +0000)]
Rollup merge of #80573 - jyn514:tool-lints, r=GuillaumeGomez
Deny rustc::internal lints for rustdoc and clippy
- Fix rustc::internal lints for rustdoc
- Deny internal lints only for rustdoc and clippy (previously the lints were ignored for clippy because -Zunstable-options didn't get passed)
bors [Fri, 22 Jan 2021 06:13:19 +0000 (06:13 +0000)]
Auto merge of #81135 - jyn514:no-backticks, r=flip1995
Fix formatting for removed lints
- Don't add backticks for the reason a lint was removed. This is almost
never a code block, and when it is the backticks should be in the reason
itself.
- Don't assume clippy is the only tool that needs to be checked for
backwards compatibility
I split this out of https://github.com/rust-lang/rust/pull/80527/ because it kept causing tests to fail, and it's a good change to have anyway.
Esteban Küber [Wed, 20 Jan 2021 01:51:48 +0000 (17:51 -0800)]
Suggest `'a` when given `a` only when appropriate
When encountering a name `a` that isn't resolved, but a label `'a` is
found in the current ribs, only suggest `'a` if this name is the value
expression of a `break` statement.
bors [Fri, 22 Jan 2021 02:42:38 +0000 (02:42 +0000)]
Auto merge of #81177 - Aaron1011:fix/force-capture-tokens, r=petrochenkov
Force token collection to run when parsing nonterminals
Fixes #81007
Previously, we would fail to collect tokens in the proper place when
only builtin attributes were present. As a result, we would end up with
attribute tokens in the collected `TokenStream`, leading to duplication
when we attempted to prepend the attributes from the AST node.
We now explicitly track when token collection must be performed due to
nomterminal parsing.