]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoAuto merge of #81350 - tmiasko:instrument-debug, r=lcnr
bors [Thu, 11 Feb 2021 13:44:00 +0000 (13:44 +0000)]
Auto merge of #81350 - tmiasko:instrument-debug, r=lcnr

Reduce log level used by tracing instrumentation from info to debug

Restore log level to debug to avoid make info log level overly verbose (the uses of instrument attribute modified there, were for the most part a replacement for `debug!`;  one use was novel).

3 years agoAuto merge of #81129 - bugadani:lighter-move-errors, r=petrochenkov
bors [Thu, 11 Feb 2021 07:50:02 +0000 (07:50 +0000)]
Auto merge of #81129 - bugadani:lighter-move-errors, r=petrochenkov

Borrowck: don't calculate unused info when reporting move errors

3 years agoAuto merge of #81126 - oxalica:retain-early-drop, r=m-ou-se
bors [Thu, 11 Feb 2021 04:40:57 +0000 (04:40 +0000)]
Auto merge of #81126 - oxalica:retain-early-drop, r=m-ou-se

Optimize Vec::retain

Use `copy_non_overlapping` instead of `swap` to reduce memory writes, like what we've done in #44355 and `String::retain`.
#48065 already tried to do this optimization but it is reverted in #67300 due to bad codegen of `DrainFilter::drop`.

This PR re-implement the drop-then-move approach. I did a [benchmark](https://gist.github.com/oxalica/3360eec9376f22533fcecff02798b698) on small-no-drop, small-need-drop, large-no-drop elements with different predicate functions. It turns out that the new implementation is >20% faster in average for almost all cases. Only 2/24 cases are slower by 3% and 5%. See the link above for more detail.

I think regression in may-panic cases is due to drop-guard preventing some optimization. If it's permitted to leak elements when predicate function of element's `drop` panic, the new implementation should be almost always faster than current one.
I'm not sure if we should leak on panic, since there is indeed an issue (#52267) complains about it before.

3 years agoAuto merge of #80860 - camelid:nodeid-docs, r=sanxiyn
bors [Thu, 11 Feb 2021 00:51:45 +0000 (00:51 +0000)]
Auto merge of #80860 - camelid:nodeid-docs, r=sanxiyn

Document `NodeId`

3 years agoAuto merge of #80762 - petrochenkov:visclean, r=varkor
bors [Wed, 10 Feb 2021 21:48:07 +0000 (21:48 +0000)]
Auto merge of #80762 - petrochenkov:visclean, r=varkor

resolve: Cleanup visibility resolution for enum variants and trait items

by always delegating it to `fn resolve_visibility`.

Also remove some special treatment of visibility on enum variants and trait items remaining from pre-`pub(restricted)` times.

3 years agoresolve: Remove visibility hacks for enum variants and trait items
Vadim Petrochenkov [Wed, 6 Jan 2021 15:07:47 +0000 (18:07 +0300)]
resolve: Remove visibility hacks for enum variants and trait items

Special treatment like this was necessary before `pub(restricted)` had been implemented and only two visibilities existed - `pub` and non-`pub`.
Now it's no longer necessary and the desired behavior follows from `pub(restricted)`-style visibilities naturally assigned to enum variants and trait items.

3 years agoresolve: Cleanup visibility resolution in enums and traits
Vadim Petrochenkov [Wed, 6 Jan 2021 14:19:47 +0000 (17:19 +0300)]
resolve: Cleanup visibility resolution in enums and traits

3 years agoAuto merge of #79804 - tmiasko:improper-ctypes-no-niche, r=pnkfelix
bors [Wed, 10 Feb 2021 12:56:09 +0000 (12:56 +0000)]
Auto merge of #79804 - tmiasko:improper-ctypes-no-niche, r=pnkfelix

Types with a hidden niche are not known to be non-null

Fixes #79787.

3 years agoAuto merge of #81768 - calebcartwright:bump-rls-rustfmt, r=Xanewok
bors [Wed, 10 Feb 2021 10:00:01 +0000 (10:00 +0000)]
Auto merge of #81768 - calebcartwright:bump-rls-rustfmt, r=Xanewok

update RLS and rustfmt

Fixes #81582 and fixes #81583

r? `@Xanewok`

I was originally surprised by the size of lockfile diff, though after looking at the RLS changes it makes a bit more sense to me now

3 years agoOnly initialize what is used
Dániel Buga [Sun, 17 Jan 2021 19:20:16 +0000 (20:20 +0100)]
Only initialize what is used

3 years agoAuto merge of #81929 - pietroalbini:pgo-bootstrap, r=Mark-Simulacrum
bors [Wed, 10 Feb 2021 07:10:43 +0000 (07:10 +0000)]
Auto merge of #81929 - pietroalbini:pgo-bootstrap, r=Mark-Simulacrum

Allow unstable features in some PGO benchmarks

Some of the benchmarks we're using for PGO require unstable features (such as compiling the standard library and some rustc-perf benchmarks), breaking CI on the beta and stable branches. For the past two releases we cherry-picked a commit directly onto the beta branch that unconditionally sets `RUSTC_BOOTSTRAP=1`, and this PR backports a similar change to the master branch.

The difference between this commit and the one we backported previously (483c1a83ca7cf53fd8f3432edb32cbe70ba39d45) is that this is more scoped in which benchmarks we allow unstable features, to prevent unintentionally enabling unstable features.

r? `@Mark-Simulacrum`

3 years agoAuto merge of #81952 - JohnTitor:rollup-i28kgfb, r=JohnTitor
bors [Wed, 10 Feb 2021 03:30:17 +0000 (03:30 +0000)]
Auto merge of #81952 - JohnTitor:rollup-i28kgfb, r=JohnTitor

Rollup of 11 pull requests

Successful merges:

 - #79849 (Clarify docs regarding sleep of zero duration)
 - #80438 (Add `Box::into_inner`.)
 - #81466 (Add suggest mut method for loop)
 - #81687 (Make Vec::split_at_spare_mut public)
 - #81904 (Bump stabilization version for const int methods)
 - #81909 ([compiler/rustc_typeck/src/check/expr.rs] Remove unnecessary refs in pattern matching)
 - #81910 (Use format string in bootstrap panic instead of a string directly)
 - #81913 (Rename HIR UnOp variants)
 - #81925 (Add long explanation for E0547)
 - #81926 (add suggestion to use the `async_recursion` crate)
 - #81951 (Update cargo)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

3 years agoRollup merge of #81951 - ehuss:update-cargo, r=ehuss
Yuki Okushi [Wed, 10 Feb 2021 03:24:32 +0000 (12:24 +0900)]
Rollup merge of #81951 - ehuss:update-cargo, r=ehuss

Update cargo

5 commits in 34170fcd6e0947808a1ac63ac85ffc0da7dace2f..ab64d1393b5b77c66b6534ef5023a1b89ee7bf64
2021-02-04 15:52:52 +0000 to 2021-02-10 00:19:10 +0000
- Allow `true` and `false` as options for `strip` option (rust-lang/cargo#9153)
- Change git dependencies to use `HEAD` by default (rust-lang/cargo#9133)
- appendix auth gcm link to new repo (which is xplat) (rust-lang/cargo#9152)
- Fix warnings of the new non_fmt_panic lint (rust-lang/cargo#9148)
- Fix panic with doc collision orphan. (rust-lang/cargo#9142)

3 years agoRollup merge of #81926 - henryboisdequin:fix-81907, r=estebank
Yuki Okushi [Wed, 10 Feb 2021 03:24:30 +0000 (12:24 +0900)]
Rollup merge of #81926 - henryboisdequin:fix-81907, r=estebank

add suggestion to use the `async_recursion` crate

Closes #81907

CC `@estebank`

3 years agoRollup merge of #81925 - jesusprubio:add-long-explanation-e0547, r=GuillaumeGomez
Yuki Okushi [Wed, 10 Feb 2021 03:24:29 +0000 (12:24 +0900)]
Rollup merge of #81925 - jesusprubio:add-long-explanation-e0547, r=GuillaumeGomez

Add long explanation for E0547

Helps with #61137

3 years agoRollup merge of #81913 - osa1:rename_unop_variants, r=matthewjasper
Yuki Okushi [Wed, 10 Feb 2021 03:24:28 +0000 (12:24 +0900)]
Rollup merge of #81913 - osa1:rename_unop_variants, r=matthewjasper

Rename HIR UnOp variants

This renames the variants in HIR UnOp from

    enum UnOp {
        UnDeref,
        UnNot,
        UnNeg,
    }

to

    enum UnOp {
        Deref,
        Not,
        Neg,
    }

Motivations:

- This is more consistent with the rest of the code base where most enum
  variants don't have a prefix.

- These variants are never used without the `UnOp` prefix so the extra
  `Un` prefix doesn't help with readability. E.g. we don't have any
  `UnDeref`s in the code, we only have `UnOp::UnDeref`.

- MIR `UnOp` type variants don't have a prefix so this is more
  consistent with MIR types.

- "un" prefix reads like "inverse" or "reverse", so as a beginner in
  rustc code base when I see "UnDeref" what comes to my mind is
  something like `&*` instead of just `*`.

3 years agoRollup merge of #81910 - jyn514:bootstrap-1.52, r=jackh726
Yuki Okushi [Wed, 10 Feb 2021 03:24:26 +0000 (12:24 +0900)]
Rollup merge of #81910 - jyn514:bootstrap-1.52, r=jackh726

Use format string in bootstrap panic instead of a string directly

This fixes the following warning when compiling with nightly:

```
warning: panic message is not a string literal
    --> src/bootstrap/builder.rs:1515:24
     |
1515 |                 panic!(out);
     |                        ^^^
     |
     = note: `#[warn(non_fmt_panic)]` on by default
     = note: this is no longer accepted in Rust 2021
help: add a "{}" format string to Display the message
     |
1515 |                 panic!("{}", out);
     |                        ^^^^^
help: or use std::panic::panic_any instead
     |
1515 |                 std::panic::panic_any(out);
     |                 ^^^^^^^^^^^^^^^^^^^^^^
```

Found while working on https://github.com/rust-lang/rust/pull/79540. cc https://github.com/rust-lang/rust/pull/81645, which landed in 1.51.

3 years agoRollup merge of #81909 - wcampbell0x2a:remove-unnecessary-refs, r=estebank
Yuki Okushi [Wed, 10 Feb 2021 03:24:25 +0000 (12:24 +0900)]
Rollup merge of #81909 - wcampbell0x2a:remove-unnecessary-refs, r=estebank

[compiler/rustc_typeck/src/check/expr.rs] Remove unnecessary refs in pattern matching

3 years agoRollup merge of #81904 - jhpratt:const_int_fn-stabilization, r=jyn514
Yuki Okushi [Wed, 10 Feb 2021 03:24:23 +0000 (12:24 +0900)]
Rollup merge of #81904 - jhpratt:const_int_fn-stabilization, r=jyn514

Bump stabilization version for const int methods

These methods missed the beta cutoff. See #80962 for details.

`@rustbot` modify labels to +A-const-fn, +A-intrinsics

r? `@m-ou-se`

3 years agoRollup merge of #81687 - WaffleLapkin:split_at_spare, r=KodrAus
Yuki Okushi [Wed, 10 Feb 2021 03:24:22 +0000 (12:24 +0900)]
Rollup merge of #81687 - WaffleLapkin:split_at_spare, r=KodrAus

Make Vec::split_at_spare_mut public

This PR introduces a new method to the public API, under
`vec_split_at_spare` feature gate:

```rust
impl<T, A: Allocator> impl Vec<T, A> {
    pub fn split_at_spare_mut(&mut self) -> (&mut [T], &mut [MaybeUninit<T>]);
}
```

The method returns 2 slices, one slice references the content of the vector,
and the other references the remaining spare capacity.

The method was previously implemented while adding `Vec::extend_from_within` in #79015,
and used to implement `Vec::spare_capacity_mut` (as the later is just a
subset of former one).

See also previous [discussion in `Vec::spare_capacity_mut` tracking issue](https://github.com/rust-lang/rust/issues/75017#issuecomment-770381335).

## Unresolved questions

- [ ] Should we consider changing the name? `split_at_spare_mut` doesn't seem like an intuitive name
- [ ] Should we deprecate `Vec::spare_capacity_mut`? Any usecase of `Vec::spare_capacity_mut` can be replaced with `Vec::split_at_spare_mut` (but not vise-versa)

r? `@KodrAus`

3 years agoRollup merge of #81466 - sasurau4:fix/enhance-sugget-mut-method-for-loop, r=oli-obk
Yuki Okushi [Wed, 10 Feb 2021 03:24:21 +0000 (12:24 +0900)]
Rollup merge of #81466 - sasurau4:fix/enhance-sugget-mut-method-for-loop, r=oli-obk

Add suggest mut method for loop

Part of #49839

This PR focus on [the comment case](https://github.com/rust-lang/rust/issues/49839#issuecomment-761930746)

3 years agoRollup merge of #80438 - crlf0710:box_into_inner, r=m-ou-se
Yuki Okushi [Wed, 10 Feb 2021 03:24:19 +0000 (12:24 +0900)]
Rollup merge of #80438 - crlf0710:box_into_inner, r=m-ou-se

Add `Box::into_inner`.

This adds a `Box::into_inner` method to the `Box` type. <del>I actually suggest deprecating the compiler magic of `*b` if this gets stablized in the future.</del>

r? `@m-ou-se`

3 years agoRollup merge of #79849 - Digital-Chaos:sleep-zero, r=m-ou-se
Yuki Okushi [Wed, 10 Feb 2021 03:24:18 +0000 (12:24 +0900)]
Rollup merge of #79849 - Digital-Chaos:sleep-zero, r=m-ou-se

Clarify docs regarding sleep of zero duration

Clarify that the behaviour of sleep() when given a duration of zero is actually platform specific.

3 years agoUpdate cargo
Eric Huss [Wed, 10 Feb 2021 02:59:47 +0000 (18:59 -0800)]
Update cargo

3 years agoremove unused backtrace refs
Caleb Cartwright [Wed, 10 Feb 2021 01:56:18 +0000 (19:56 -0600)]
remove unused backtrace refs

3 years agoupdate RLS and rustfmt
Caleb Cartwright [Wed, 10 Feb 2021 01:52:54 +0000 (19:52 -0600)]
update RLS and rustfmt

3 years agoAuto merge of #81411 - Skgland:deprecate_expr_method_call, r=varkor
bors [Wed, 10 Feb 2021 00:25:11 +0000 (00:25 +0000)]
Auto merge of #81411 - Skgland:deprecate_expr_method_call, r=varkor

Remove usages of `expr_method_call` in derive(Ord,PartialOrd,RustcEncode,RustcDecode)

Preparing for deprecation of `expr_method_call`  (#81295), by removing the remaining usages not covered by (#81294).

I am not sure about the changes to `derive(RustcEncode,RustcDecode)`

3 years agoupdate tracking issue for vec_split_at_spare
Ashley Mannix [Tue, 9 Feb 2021 23:50:59 +0000 (09:50 +1000)]
update tracking issue for vec_split_at_spare

3 years agoAuto merge of #81132 - bugadani:map-prealloc, r=matthewjasper
bors [Tue, 9 Feb 2021 21:28:58 +0000 (21:28 +0000)]
Auto merge of #81132 - bugadani:map-prealloc, r=matthewjasper

Borrowck: refactor visited map to a bitset

This PR refactors `Borrows`  and the `precompute_borrows_out_of_scope` function so that this initial phase has a much reduced memory pressure. This is achieved by reducing what is stored on the heap, and also reusing heap memory as much as possible.

3 years agoAuto merge of #81892 - jyn514:no-inline, r=cjgillot
bors [Tue, 9 Feb 2021 18:37:33 +0000 (18:37 +0000)]
Auto merge of #81892 - jyn514:no-inline, r=cjgillot

[experiment] remove `#[inline]` from rustc_query_system::plumbing

These functions have a ton of generic parameters and are instantiated
over and over again. Hopefully this will reduce binary bloat and speed
up bootstrapping times.

r? `@cjgillot`

3 years agoAuto merge of #79540 - jyn514:no-xpy, r=Mark-Simulacrum
bors [Tue, 9 Feb 2021 15:28:28 +0000 (15:28 +0000)]
Auto merge of #79540 - jyn514:no-xpy, r=Mark-Simulacrum

Allow building rustdoc without first building rustc (MVP)

 ## Motivation

The compile times for rustc are extremely long and a major issue for
recruiting new contributors to rustdoc. People interested in joining
often give up after running into issues with submodules or python
versions. stage1 rustdoc fundamentally doesn't care about bootstrapping
or stages, it just needs `rustc_private` available.

## Summary of Changes

- Add an opt-in `[rust] download_rustc` option
- Determine the version of the compiler to download using `log --author=bors`
- Do no work for any component other than `Rustdoc` for any stage. Instead, copy the CI artifacts from the downloaded sysroot stage0/ to stage0-sysroot/ or stage1/ in `Sysroot`. This is done with an `ENABLE_DOWNLOAD_STAGE1` constant which is off by default.
- Don't download different versions of rustfmt or cargo - those should still use the beta version (rustfmt especially).

The vast majority of work is done in bootstrap.py, which downloads the artifacts and extracts them to stage0/ in place of the beta compiler. Rustbuild just takes care of copying the artifacts to stage1 if necessary.

## Future work

- I turned off verification for the commit tarballs because the .sha256 URLs gave a 404. This seems not ideal, it would be nice to start signing them.
- This will break if you rebase an old enough branch (I think commits are kept at most 160 days?). This doesn't need to be supported, but it would be nice to give a reasonable error. https://github.com/rust-lang/rust/pull/79540#issuecomment-751481291
- Right now, every time you rebase, stage0 tools (bootstrap, tidy, ...) will have to be recompiled. Additionally running `x.py setup tools` will compile rustbuild twice. Instead, this should download a separate beta compiler for stage0 and only use CI artifacts for stage1 onward. https://github.com/rust-lang/rust/pull/79540#issuecomment-757047321
- Add `x.py setup tools` to enable this conveniently (it doesn't make sense to use this for compiler developers). https://github.com/jyn514/rust/commit/cb5d8c85226c501bf9deb39082a08af0ebfae850
- Compile a new version of tracing so that rustdoc still gets debug logging (since CI artifacts always disable `debug` and `trace` logging). https://github.com/rust-lang/rust/pull/79540#issuecomment-742756411, https://github.com/jyn514/rust/commit/6a5d5124209bec7652e745725a995bd77bb3f881
- Right now only rustdoc is ever rebuilt. This is not ideal and should probably at least compile compiler tools (rustfmt, clippy, miri). https://github.com/rust-lang/rust/pull/79540#issuecomment-775634693
- Using `git log --author=bors` sometimes breaks. This should use `git merge-base` instead. https://github.com/rust-lang/rust/pull/79540#discussion_r572572280
- It would be nice to support cross-compiling the standard library. Right now this gives an assertion failure I think.

Some of this work has already been done in (the history for) https://github.com/jyn514/rust/commit/673476c785bc1fbff175cb7f49ad487c7a2b0337.

3 years agoci: allow unstable features in some PGO benchmarks
Pietro Albini [Tue, 29 Dec 2020 20:18:40 +0000 (15:18 -0500)]
ci: allow unstable features in some PGO benchmarks

3 years agoUpdate compiler/rustc_error_codes/src/error_codes/E0547.md
Jesús Rubio [Tue, 9 Feb 2021 13:13:40 +0000 (14:13 +0100)]
Update compiler/rustc_error_codes/src/error_codes/E0547.md

Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
3 years agoadd suggestion to use the `async_recursion` crate
Henry Boisdequin [Tue, 9 Feb 2021 13:13:39 +0000 (18:43 +0530)]
add suggestion to use the `async_recursion` crate

3 years agoLost text re-added
Jesus Rubio [Tue, 9 Feb 2021 13:09:19 +0000 (14:09 +0100)]
Lost text re-added

3 years agofix derive(RustcEncodable, RustcDecodable)
Skgland [Thu, 4 Feb 2021 21:49:50 +0000 (22:49 +0100)]
fix derive(RustcEncodable, RustcDecodable)

3 years agouse ufcs in derive(RustDecodable)
Skgland [Tue, 26 Jan 2021 14:06:01 +0000 (15:06 +0100)]
use ufcs in derive(RustDecodable)

3 years agouse ufcs in derive(RustEncodable)
Skgland [Tue, 26 Jan 2021 14:05:11 +0000 (15:05 +0100)]
use ufcs in derive(RustEncodable)

3 years agoadd method to construct def site path as a vec of idents
Skgland [Tue, 26 Jan 2021 14:04:09 +0000 (15:04 +0100)]
add method to construct def site path as a vec of idents

like std_path but used dummy span for all path elements and does not perpend kw:DollarCrate

3 years agouse ufcs in derive(Ord) and derive(PartialOrd)
Skgland [Tue, 9 Feb 2021 12:41:34 +0000 (13:41 +0100)]
use ufcs in derive(Ord) and derive(PartialOrd)

3 years agoAuto merge of #81916 - RalfJung:miri, r=RalfJung
bors [Tue, 9 Feb 2021 11:38:47 +0000 (11:38 +0000)]
Auto merge of #81916 - RalfJung:miri, r=RalfJung

update Miri

Fixes https://github.com/rust-lang/rust/issues/81868
Cc `@rust-lang/miri` r? `@ghost`

3 years agoupdate Miri
Ralf Jung [Tue, 9 Feb 2021 10:05:42 +0000 (11:05 +0100)]
update Miri

3 years agoAuto merge of #81384 - tmiasko:partial-ord, r=petrochenkov
bors [Tue, 9 Feb 2021 08:47:38 +0000 (08:47 +0000)]
Auto merge of #81384 - tmiasko:partial-ord, r=petrochenkov

Fix derived PartialOrd operators

The derived implementation of `partial_cmp` compares matching fields one
by one, stopping the computation when the result of a comparison is not
equal to `Some(Equal)`.

On the other hand the derived implementation for `lt`, `le`, `gt` and
`ge` continues the computation when the result of a field comparison is
`None`, consequently those operators are not transitive and inconsistent
with `partial_cmp`.

Fix the inconsistency by using the default implementation that fall-backs
to the `partial_cmp`. This also avoids creating very deeply nested
closures that were quite costly to compile.

Fixes #81373.
Helps with #81278, #80118.

3 years agoRename HIR UnOp variants
Ömer Sinan Ağacan [Tue, 9 Feb 2021 08:15:53 +0000 (11:15 +0300)]
Rename HIR UnOp variants

This renames the variants in HIR UnOp from

    enum UnOp {
        UnDeref,
        UnNot,
        UnNeg,
    }

to

    enum UnOp {
        Deref,
        Not,
        Neg,
    }

Motivations:

- This is more consistent with the rest of the code base where most enum
  variants don't have a prefix.

- These variants are never used without the `UnOp` prefix so the extra
  `Un` prefix doesn't help with readability. E.g. we don't have any
  `UnDeref`s in the code, we only have `UnOp::UnDeref`.

- MIR `UnOp` type variants don't have a prefix so this is more
  consistent with MIR types.

- "un" prefix reads like "inverse" or "reverse", so as a beginner in
  rustc code base when I see "UnDeref" what comes to my mind is
  something like "&*" instead of just "*".

3 years agoAuto merge of #81905 - Dylan-DPC:rollup-mxpz1j7, r=Dylan-DPC
bors [Tue, 9 Feb 2021 05:57:18 +0000 (05:57 +0000)]
Auto merge of #81905 - Dylan-DPC:rollup-mxpz1j7, r=Dylan-DPC

Rollup of 11 pull requests

Successful merges:

 - #72209 (Add checking for no_mangle to unsafe_code lint)
 - #80732 (Allow Trait inheritance with cycles on associated types take 2)
 - #81697 (Add "every" as a doc alias for "all".)
 - #81826 (Prefer match over combinators to make some Box methods inlineable)
 - #81834 (Resolve typedef in HashMap lldb pretty-printer only if possible)
 - #81841 ([rustbuild] Output rustdoc-json-types docs )
 - #81849 (Expand the docs for ops::ControlFlow a bit)
 - #81876 (parser: Fix panic in 'const impl' recovery)
 - #81882 (:arrow_up: rust-analyzer)
 - #81888 (Fix pretty printer macro_rules with semicolon.)
 - #81896 (Remove outdated comment in windows' mutex.rs)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

3 years agoUse `log --author=bors` instead of `merge-base`
Joshua Nelson [Fri, 22 Jan 2021 06:00:51 +0000 (01:00 -0500)]
Use `log --author=bors` instead of `merge-base`

3 years agoAbsolute bare minimum for downloading rustc from CI
Joshua Nelson [Fri, 22 Jan 2021 05:31:17 +0000 (00:31 -0500)]
Absolute bare minimum for downloading rustc from CI

- Use the same compiler for stage0 and stage1. This should be fixed at
  some point (so bootstrap isn't constantly rebuilt).
- Make sure `x.py build` and `x.py check` work.
- Use `git merge-base` to determine the most recent commit to download.
- Copy stage0 to the various sysroots in `Sysroot`, and delegate to
  Sysroot in Assemble. Leave all other code unchanged.
- Rename date -> key

  This can also be a commit hash, so 'date' is no longer a good name.

- Add the commented-out option to config.toml.example
- Disable all steps by default when `download-rustc` is enabled

  Most steps don't make sense when downloading a compiler, because they'll
  be pre-built in the sysroot. Only enable the ones that might be useful,
  in particular Rustdoc and all `check` steps.

  At some point, this should probably enable other tools, but rustdoc is
  enough to test out `download-rustc`.

- Don't print 'Skipping' twice in a row

  Bootstrap forcibly enables a dry run if it isn't already set, so
  previously it would print the message twice:

  ```
  Skipping bootstrap::compile::Std because it is not enabled for `download-rustc`
  Skipping bootstrap::compile::Std because it is not enabled for `download-rustc`
  ```

  Now it correctly only prints once.

 ## Future work

- Add FIXME about supporting beta commits
- Debug logging will never work. This should be fixed.

3 years agoUse format string in bootstrap panic instead of a string directly
Joshua Nelson [Tue, 9 Feb 2021 03:51:21 +0000 (22:51 -0500)]
Use format string in bootstrap panic instead of a string directly

This fixes the following warning when compiling with nightly:

```
warning: panic message is not a string literal
    --> src/bootstrap/builder.rs:1515:24
     |
1515 |                 panic!(out);
     |                        ^^^
     |
     = note: `#[warn(non_fmt_panic)]` on by default
     = note: this is no longer accepted in Rust 2021
help: add a "{}" format string to Display the message
     |
1515 |                 panic!("{}", out);
     |                        ^^^^^
help: or use std::panic::panic_any instead
     |
1515 |                 std::panic::panic_any(out);
     |                 ^^^^^^^^^^^^^^^^^^^^^^
```

3 years agoAuto merge of #81901 - Mark-Simulacrum:use-string-not-cow, r=jackh726
bors [Tue, 9 Feb 2021 03:06:42 +0000 (03:06 +0000)]
Auto merge of #81901 - Mark-Simulacrum:use-string-not-cow, r=jackh726

Switch query descriptions to just String

In practice we never used the borrowed variant anyway.

3 years agoRemove unnecessary refs in pattern matching
wcampbell [Tue, 9 Feb 2021 03:02:35 +0000 (22:02 -0500)]
Remove unnecessary refs in pattern matching

Signed-off-by: wcampbell <wcampbell1995@gmail.com>
3 years agoAdd `Box::into_inner`.
Charles Lew [Mon, 28 Dec 2020 12:47:19 +0000 (20:47 +0800)]
Add `Box::into_inner`.

3 years agoRollup merge of #81896 - m-ou-se:oudated-comment, r=Mark-Simulacrum
Dylan DPC [Tue, 9 Feb 2021 01:40:06 +0000 (02:40 +0100)]
Rollup merge of #81896 - m-ou-se:oudated-comment, r=Mark-Simulacrum

Remove outdated comment in windows' mutex.rs

After https://github.com/rust-lang/rust/pull/81250, this `Mutex` no longer falls back to the `ReentrantMutex` implementation, so this comment is no longer relevant.

3 years agoRollup merge of #81888 - ehuss:macro_rules-pp, r=petrochenkov
Dylan DPC [Tue, 9 Feb 2021 01:40:05 +0000 (02:40 +0100)]
Rollup merge of #81888 - ehuss:macro_rules-pp, r=petrochenkov

Fix pretty printer macro_rules with semicolon.

The pretty printer was not including the trailing semicolon for a macro_rules definition that used parenthesis or brackets, which results in invalid code. This adds the semicolon in those two cases.

3 years agoRollup merge of #81882 - lnicola:rust-analyzer-2021-02-08, r=jonas-schievink
Dylan DPC [Tue, 9 Feb 2021 01:40:03 +0000 (02:40 +0100)]
Rollup merge of #81882 - lnicola:rust-analyzer-2021-02-08, r=jonas-schievink

:arrow_up: rust-analyzer

r? `@jonas-schievink`

3 years agoRollup merge of #81876 - osa1:issue81806, r=matthewjasper
Dylan DPC [Tue, 9 Feb 2021 01:40:01 +0000 (02:40 +0100)]
Rollup merge of #81876 - osa1:issue81806, r=matthewjasper

parser: Fix panic in 'const impl' recovery

The panic happens when in recovery parsing a full `impl`
(`parse_item_impl`) fails and we drop the `DiagnosticBuilder` for the
recovery suggestion and return the `parse_item_impl` error.

We now raise the original error "expected identifier found `impl`" when
parsing the `impl` fails.

Note that the regression test is slightly simplified version of the
original repro in #81806, to make the error output smaller and more
resilient to unrelated changes in parser error messages.

Fixes #81806

3 years agoRollup merge of #81849 - scottmcm:control-flow-comments, r=Mark-Simulacrum
Dylan DPC [Tue, 9 Feb 2021 01:39:59 +0000 (02:39 +0100)]
Rollup merge of #81849 - scottmcm:control-flow-comments, r=Mark-Simulacrum

Expand the docs for ops::ControlFlow a bit

Since I was writing some examples for an RFC anyway.

And I almost made the mistake of reordering the variants, so added a note and a test about that.

3 years agoRollup merge of #81841 - aDotInTheVoid:rdj_docs, r=jyn514
Dylan DPC [Tue, 9 Feb 2021 01:39:57 +0000 (02:39 +0100)]
Rollup merge of #81841 - aDotInTheVoid:rdj_docs, r=jyn514

[rustbuild] Output rustdoc-json-types docs

`@rustbot` modify labels +A-rustdoc-json +T-doc +T-rustdoc +A-rustbuild +A-contributor-roadblock

3 years agoRollup merge of #81834 - ortem:fix-LLDB-hashmap-pretty-printers, r=Mark-Simulacrum
Dylan DPC [Tue, 9 Feb 2021 01:39:55 +0000 (02:39 +0100)]
Rollup merge of #81834 - ortem:fix-LLDB-hashmap-pretty-printers, r=Mark-Simulacrum

Resolve typedef in HashMap lldb pretty-printer only if possible

Fixes https://github.com/rust-lang/rust/issues/81814

Previously, `GetTypedefedType` was invoked unconditionally.
But this did not work in case of `rust-lldb` without Rust patches since there was no typedef.

3 years agoRollup merge of #81826 - tesuji:inline-box-zeros, r=Amanieu
Dylan DPC [Tue, 9 Feb 2021 01:39:53 +0000 (02:39 +0100)]
Rollup merge of #81826 - tesuji:inline-box-zeros, r=Amanieu

Prefer match over combinators to make some Box methods inlineable

Hopefully this patch would make two snippets generated identical code: <https://rust.godbolt.org/z/fjrj4E>.

3 years agoRollup merge of #81697 - xfix:every-doc-alias, r=Mark-Simulacrum
Dylan DPC [Tue, 9 Feb 2021 01:39:51 +0000 (02:39 +0100)]
Rollup merge of #81697 - xfix:every-doc-alias, r=Mark-Simulacrum

Add "every" as a doc alias for "all".

This matches [Array#every](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every) in JavaScript.

Oddly enough, `core::iter::Iterator::all` appears twice. This appears to be a rustdoc bug which I decided to fill in as #81696.

![image](https://user-images.githubusercontent.com/1297598/106717890-94f43e80-6600-11eb-9428-2cd425823df9.png)

3 years agoRollup merge of #80732 - spastorino:trait-inheritance-self2, r=nikomatsakis
Dylan DPC [Tue, 9 Feb 2021 01:39:50 +0000 (02:39 +0100)]
Rollup merge of #80732 - spastorino:trait-inheritance-self2, r=nikomatsakis

Allow Trait inheritance with cycles on associated types take 2

This reverts the revert of #79209 and fixes the ICEs that's occasioned by that PR exposing some problems that are addressed in #80648 and #79811.
For easier review I'd say, check only the last commit, the first one is just a revert of the revert of #79209 which was already approved.

This also could be considered part or the actual fix of #79560 but I guess for that to be closed and fixed completely we would need to land #80648 and #79811 too.

r? `@nikomatsakis`
cc `@Aaron1011`

3 years agoRollup merge of #72209 - Nemo157:lint-no-mangle-in-unsafe-code, r=nikomatsakis
Dylan DPC [Tue, 9 Feb 2021 01:39:45 +0000 (02:39 +0100)]
Rollup merge of #72209 - Nemo157:lint-no-mangle-in-unsafe-code, r=nikomatsakis

Add checking for no_mangle to unsafe_code lint

fixes #72188

r? `@estebank`

3 years agoBump stabilization version for const int methods
Jacob Pratt [Tue, 9 Feb 2021 00:22:08 +0000 (19:22 -0500)]
Bump stabilization version for const int methods

These methods missed the beta cutoff

3 years ago./x.py test --bless
Tomasz Miąsko [Tue, 9 Feb 2021 00:00:00 +0000 (00:00 +0000)]
./x.py test --bless

3 years agoFix derived PartialOrd operators
Tomasz Miąsko [Mon, 25 Jan 2021 00:00:00 +0000 (00:00 +0000)]
Fix derived PartialOrd operators

The derived implementation of `partial_cmp` compares matching fields one
by one, stopping the computation when the result of a comparison is not
equal to `Some(Equal)`.

On the other hand the derived implementation for `lt`, `le`, `gt` and
`ge` continues the computation when the result of a field comparison is
`None`, consequently those operators are not transitive and inconsistent
with `partial_cmp`.

Fix the inconsistency by using the default implementation that fall-backs
to the `partial_cmp`. This also avoids creating very deeply nested
closures that were quite costly to compile.

3 years agoAuto merge of #81361 - ssomers:btree_drainy_refactor_7, r=Mark-Simulacrum
bors [Mon, 8 Feb 2021 23:37:06 +0000 (23:37 +0000)]
Auto merge of #81361 - ssomers:btree_drainy_refactor_7, r=Mark-Simulacrum

BTreeMap: lightly refactor the split_off implementation

r? `@Mark-Simulacrum`

3 years agoSwitch query descriptions to just String
Mark Rousskov [Mon, 8 Feb 2021 22:20:41 +0000 (17:20 -0500)]
Switch query descriptions to just String

In practice we never used the borrowed variant anyway.

3 years agoRemove outdated comment.
Mara Bos [Mon, 8 Feb 2021 21:27:34 +0000 (22:27 +0100)]
Remove outdated comment.

3 years agoAuto merge of #81889 - m-ou-se:rollup-k63log3, r=m-ou-se
bors [Mon, 8 Feb 2021 20:52:54 +0000 (20:52 +0000)]
Auto merge of #81889 - m-ou-se:rollup-k63log3, r=m-ou-se

Rollup of 9 pull requests

Successful merges:

 - #71531 (Move treat err as bug tests to ui)
 - #81356 (libtest: allow multiple filters)
 - #81735 (faster few span methods)
 - #81779 (improve error message for disallowed ptr-to-int casts in const eval)
 - #81817 (Add option to emit compiler stderr per bitwidth.)
 - #81828 (parse_format: treat r" as a literal)
 - #81840 (fix formatting of std::iter::Map)
 - #81861 (Show MIR bytes separately in -Zmeta-stats output)
 - #81865 (Clean up weird Option mapping)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

3 years agoFix pretty printer macro_rules with semicolon.
Eric Huss [Mon, 8 Feb 2021 18:03:57 +0000 (10:03 -0800)]
Fix pretty printer macro_rules with semicolon.

3 years ago[experiment] remove `#[inline]` from rustc_query_system::plumbing
Joshua Nelson [Mon, 8 Feb 2021 19:57:15 +0000 (14:57 -0500)]
[experiment] remove `#[inline]` from rustc_query_system::plumbing

These functions have a ton of generic parameters and are instantiated
over and over again. Hopefully this will reduce binary bloat and speed
up bootstrapping times.

3 years agoAnonymize late bound regions on transitive bounds that define assoc type
Santiago Pastorino [Fri, 5 Feb 2021 18:52:57 +0000 (15:52 -0300)]
Anonymize late bound regions on transitive bounds that define assoc type

3 years agoRemove RCs from Borrows
Dániel Buga [Sun, 7 Feb 2021 21:32:50 +0000 (22:32 +0100)]
Remove RCs from Borrows

3 years agoRollup merge of #81865 - bugadani:typeck2, r=jyn514
Mara Bos [Mon, 8 Feb 2021 18:28:25 +0000 (19:28 +0100)]
Rollup merge of #81865 - bugadani:typeck2, r=jyn514

Clean up weird Option mapping

3 years agoRollup merge of #81861 - tmiasko:mir-bytes, r=wesleywiser
Mara Bos [Mon, 8 Feb 2021 18:28:23 +0000 (19:28 +0100)]
Rollup merge of #81861 - tmiasko:mir-bytes, r=wesleywiser

Show MIR bytes separately in -Zmeta-stats output

The size of serialized MIR is substantial enough to deserve its own category.

3 years agoRollup merge of #81840 - ibraheemdev:patch-1, r=dtolnay
Mara Bos [Mon, 8 Feb 2021 18:28:22 +0000 (19:28 +0100)]
Rollup merge of #81840 - ibraheemdev:patch-1, r=dtolnay

fix formatting of std::iter::Map

3 years agoRollup merge of #81828 - davidhewitt:capture-raw-format-strings, r=estebank
Mara Bos [Mon, 8 Feb 2021 18:28:20 +0000 (19:28 +0100)]
Rollup merge of #81828 - davidhewitt:capture-raw-format-strings, r=estebank

parse_format: treat r" as a literal

This PR changes `format_args!` internal parsing machinery to treat raw strings starting `r"` as a literal.

Currently `"` and `r#` are recognised as valid starting combinations for string literals, but `r"` is not.

This was noticed when debugging https://github.com/rust-lang/rust/issues/67984#issuecomment-753413156

As well as fixing the behavior observed in that comment, this improves diagnostic spans for `r"` formatting strings.

3 years agoRollup merge of #81817 - hameerabbasi:mcp-635, r=oli-obk
Mara Bos [Mon, 8 Feb 2021 18:28:18 +0000 (19:28 +0100)]
Rollup merge of #81817 - hameerabbasi:mcp-635, r=oli-obk

Add option to emit compiler stderr per bitwidth.

See rust-lang/compiler-team#365

r? `@oli-obk`

3 years agoRollup merge of #81779 - geogriff:const-ptr-to-int-error, r=lcnr
Mara Bos [Mon, 8 Feb 2021 18:28:17 +0000 (19:28 +0100)]
Rollup merge of #81779 - geogriff:const-ptr-to-int-error, r=lcnr

improve error message for disallowed ptr-to-int casts in const eval

Improves an error message as [suggested](https://github.com/rust-lang/rust/issues/80875#issuecomment-762754580) in #80875.

Does the wording make enough sense? I tried to follow precedent for error message style while maintaining brevity.

It seems like the rest of the `ConstEvalErrKind::NeedsRfc` error messages could be improved as well. I could give that a go if this approach works.

Closes #80875

3 years agoRollup merge of #81735 - klensy:span-fix, r=varkor
Mara Bos [Mon, 8 Feb 2021 18:28:15 +0000 (19:28 +0100)]
Rollup merge of #81735 - klensy:span-fix, r=varkor

faster few span methods

Touched few methods, so it should be (hopefully) faster.

First two changes: instead splitting string from start and taking only last piece, split it from the end.
Last: swapped conditions, to first check boolean parameter.

3 years agoRollup merge of #81356 - ehuss:libtest-filters, r=m-ou-se
Mara Bos [Mon, 8 Feb 2021 18:28:13 +0000 (19:28 +0100)]
Rollup merge of #81356 - ehuss:libtest-filters, r=m-ou-se

libtest: allow multiple filters

Libtest ignores any filters after the first. This changes it so that if multiple filters are passed, it will test against all of them.

This also affects compiletest to do the same.

Closes #30422

3 years agoRollup merge of #71531 - spastorino:move-treat-err-as-bug-tests-to-ui, r=oli-obk
Mara Bos [Mon, 8 Feb 2021 18:28:09 +0000 (19:28 +0100)]
Rollup merge of #71531 - spastorino:move-treat-err-as-bug-tests-to-ui, r=oli-obk

Move treat err as bug tests to ui

cc `@oli-obk`

3 years agoAdd long explanation for E0547
Jesus Rubio [Mon, 8 Feb 2021 17:25:05 +0000 (18:25 +0100)]
Add long explanation for E0547

3 years ago:arrow_up: rust-analyzer
Laurențiu Nicola [Mon, 8 Feb 2021 14:14:06 +0000 (16:14 +0200)]
:arrow_up: rust-analyzer

3 years agoAuto merge of #81313 - LeSeulArtichaut:revert-32558, r=jyn514
bors [Mon, 8 Feb 2021 10:46:10 +0000 (10:46 +0000)]
Auto merge of #81313 - LeSeulArtichaut:revert-32558, r=jyn514

Restore linking to itself in implementors section of trait page

Reverts #32558 as proposed in [this Zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/Trait.20implementation.20self-links/near/223773273)
r? `@jyn514` cc `@camelid`

3 years agoAuto merge of #79245 - ssomers:btree_curb_ord_bound, r=dtolnay
bors [Mon, 8 Feb 2021 07:56:04 +0000 (07:56 +0000)]
Auto merge of #79245 - ssomers:btree_curb_ord_bound, r=dtolnay

BTree: remove Ord bound where it is absent elsewhere

Some btree methods don't really need an Ord bound and don't have one, while some methods that more obviously don't need it, do have one.

An example of the former is `iter`, even though it explicitly exposes the work of the Ord implementation (["sorted by key"](https://doc.rust-lang.org/std/collections/struct.BTreeMap.html#method.iter) - but I'm not suggesting it should have the Ord bound). An example of the latter is `new`, which doesn't involve any keys whatsoever.

3 years agoparser: Fix panic in 'const impl' recovery
Ömer Sinan Ağacan [Mon, 8 Feb 2021 07:43:54 +0000 (10:43 +0300)]
parser: Fix panic in 'const impl' recovery

The panic happens when in recovery parsing a full `impl`
(`parse_item_impl`) fails and we drop the `DiagnosticBuilder` for the
recovery suggestion and return the `parse_item_impl` error.

We now raise the original error "expected identifier found `impl`" when
parsing the `impl` fails.

Note that the regression test is slightly simplified version of the
original repro in #81806, to make the error output smaller and more
resilient to unrelated changes in parser error messages.

Fixes #81806

3 years agoAuto merge of #80962 - jhpratt:const_int_fn-stabilization, r=dtolnay
bors [Mon, 8 Feb 2021 05:05:55 +0000 (05:05 +0000)]
Auto merge of #80962 - jhpratt:const_int_fn-stabilization, r=dtolnay

Stabilize remaining integer methods as `const fn`

This pull request stabilizes the following methods as `const fn`:

- `i*::checked_div`
- `i*::checked_div_euclid`
- `i*::checked_rem`
- `i*::checked_rem_euclid`
- `i*::div_euclid`
- `i*::overflowing_div`
- `i*::overflowing_div_euclid`
- `i*::overflowing_rem`
- `i*::overflowing_rem_euclid`
- `i*::rem_euclid`
- `i*::wrapping_div`
- `i*::wrapping_div_euclid`
- `i*::wrapping_rem`
- `i*::wrapping_rem_euclid`
- `u*::checked_div`
- `u*::checked_div_euclid`
- `u*::checked_rem`
- `u*::checked_rem_euclid`
- `u*::div_euclid`
- `u*::overflowing_div`
- `u*::overflowing_div_euclid`
- `u*::overflowing_rem`
- `u*::overflowing_rem_euclid`
- `u*::rem_euclid`
- `u*::wrapping_div`
- `u*::wrapping_div_euclid`
- `u*::wrapping_rem`
- `u*::wrapping_rem_euclid`

These can all be implemented on the current stable (1.49). There are two unstable details: const likely/unlikely and unchecked division/remainder. Both of these are for optimizations, and are in no way required to make the methods function; there is no exposure of these details publicly. Per comments below, it seems best practice is to stabilize the intrinsics. As such, `intrinsics::unchecked_div` and `intrinsics::unchecked_rem` have been stabilized as `const` as part of this pull request as well. The methods themselves remain unstable.

I believe part of the reason these were not stabilized previously was the behavior around division by 0 and modulo 0. After testing on nightly, the diagnostic for something like `const _: i8 = 5i8 % 0i8;` is similar to that of `const _: i8 = 5i8.rem_euclid(0i8);` (assuming the appropriate feature flag is enabled). As such, I believe these methods are ready to be stabilized as `const fn`.

This pull request represents the final methods mentioned in #53718. As such, this PR closes #53718.

`@rustbot` modify labels to +A-const-fn, +T-libs

3 years agoClarify docs for `DUMMY_NODE_ID`
Camelid [Mon, 8 Feb 2021 03:42:12 +0000 (19:42 -0800)]
Clarify docs for `DUMMY_NODE_ID`

3 years agoAuto merge of #72603 - jsgf:extern-loc, r=nikomatsakis
bors [Mon, 8 Feb 2021 02:23:17 +0000 (02:23 +0000)]
Auto merge of #72603 - jsgf:extern-loc, r=nikomatsakis

Implement `--extern-location`

This PR implements `--extern-location` as a followup to #72342 as part of the implementation of #57274. The goal of this PR is to allow rustc, in coordination with the build system, to present a useful diagnostic about how to remove an unnecessary dependency from a dependency specification file (eg Cargo.toml).

EDIT: Updated to current PR state.

The location is specified for each named crate - that is, for a given `--extern foo[=path]` there can also be `--extern-location foo=<location>`. It supports ~~three~~ two styles of location:
~~1. `--extern-location foo=file:<path>:<line>` - a file path and line specification
1. `--extern-location foo=span:<path>:<start>:<end>` - a span specified as a file and start and end byte offsets~~
1. `--extern-location foo=raw:<anything>` - a raw string which is included in the output
1. `--extern-location foo=json:<anything>` - an arbitrary Json structure which is emitted via Json diagnostics in a `tool_metadata` field.

~~1 & 2 are turned into an internal `Span`, so long as the path exists and is readable, and the location is meaningful (within the file, etc). This is used as the `Span` for a fix suggestion which is reported like other fix suggestions.~~

`raw` and `json` are for the case where the location isn't best expressed as a file and location within that file. For example, it could be a rule name and the name of a dependency within that rule. `rustc` makes no attempt to parse the raw string, and simply includes it in the output diagnostic text. `json` is only included in json diagnostics. `raw` is emitted as text and also as a json string in `tool_metadata`.

If no `--extern-location` option is specified then it will emit a default json structure consisting of `{"name": name, "path": path}` corresponding to the name and path in `--extern name=path`.

This is a prototype/RFC to make some of the earlier conversations more concrete. It doesn't stand on its own - it's only useful if implemented by Cargo and other build systems. There's also a ton of implementation details which I'd appreciate a second eye on as well.

~~**NOTE** The first commit in this PR is #72342 and should be ignored for the purposes of review. The first commit is a very simplistic implementation which is basically raw-only, presented as a MVP. The second implements the full thing, and subsequent commits are incremental fixes.~~

cc `@ehuss` `@est31` `@petrochenkov` `@estebank`

3 years agofix formatting of std::iter::Map
Ibraheem Ahmed [Sat, 6 Feb 2021 20:47:12 +0000 (15:47 -0500)]
fix formatting of std::iter::Map

3 years agoClean up weird option mapping
Dániel Buga [Sun, 7 Feb 2021 22:05:15 +0000 (23:05 +0100)]
Clean up weird option mapping

3 years agoMake sure all fields are accounted for in `encode_fields!`
Jeremy Fitzhardinge [Sun, 7 Feb 2021 04:29:04 +0000 (20:29 -0800)]
Make sure all fields are accounted for in `encode_fields!`

This will make sure the encoder will get updated if any new fields are
added to Diagnostic.

3 years agoImplement Encoder for Diagnostic manually
Jeremy Fitzhardinge [Mon, 18 Jan 2021 22:10:31 +0000 (14:10 -0800)]
Implement Encoder for Diagnostic manually

...so we can skip serializing `tool_metadata` if it hasn't been set.
This makes the output a bit cleaner, and avoiding having to update a
bunch of unrelated tests.

3 years agoAdd `--extern-loc` to augment unused crate dependency diagnostics
Jeremy Fitzhardinge [Mon, 25 May 2020 23:21:25 +0000 (16:21 -0700)]
Add `--extern-loc` to augment unused crate dependency diagnostics

This allows a build system to indicate a location in its own dependency
specification files (eg Cargo's `Cargo.toml`) which can be reported
along side any unused crate dependency.

This supports several types of location:
 - 'json' - provide some json-structured data, which is included in the json diagnostics
     in a `tool_metadata` field
 - 'raw' - emit the provided string into the output. This also appears as a json string in
     `tool_metadata`.

If no `--extern-location` is explicitly provided then a default json entry of the form
`"tool_metadata":{"name":<cratename>,"path":<cratepath>}` is emitted.

3 years agoAuto merge of #80652 - calebzulawski:simd-lanes, r=nagisa
bors [Sun, 7 Feb 2021 22:25:14 +0000 (22:25 +0000)]
Auto merge of #80652 - calebzulawski:simd-lanes, r=nagisa

Improve SIMD type element count validation

Resolves rust-lang/stdsimd#53.

These changes are motivated by `stdsimd` moving in the direction of const generic vectors, e.g.:
```rust
#[repr(simd)]
struct SimdF32<const N: usize>([f32; N]);
```

This makes a few changes:
* Establishes a maximum SIMD lane count of 2^16 (65536).  This value is arbitrary, but attempts to validate lane count before hitting potential errors in the backend.  It's not clear what LLVM's maximum lane count is, but cranelift's appears to be much less than `usize::MAX`, at least.
* Expands some SIMD intrinsics to support arbitrary lane counts.  This resolves the ICE in the linked issue.
* Attempts to catch invalid-sized vectors during typeck when possible.

Unresolved questions:
* Generic-length vectors can't be validated in typeck and are only validated after monomorphization while computing layout.  This "works", but the errors simply bail out with no context beyond the name of the type.  Should these errors instead return `LayoutError` or otherwise provide context in some way?  As it stands, users of `stdsimd` could trivially produce monomorphization errors by making zero-length vectors.

cc `@bjorn3`

3 years agoOptimize Borrows
Dániel Buga [Sun, 17 Jan 2021 20:20:21 +0000 (21:20 +0100)]
Optimize Borrows

Reuse as much memory as possible, reduce number of allocations.
Use BitSet instead of a HashMap, since only a single bit of
information was used as the map's value.

3 years agoAuto merge of #79078 - petrochenkov:derattr, r=Aaron1011
bors [Sun, 7 Feb 2021 19:36:10 +0000 (19:36 +0000)]
Auto merge of #79078 - petrochenkov:derattr, r=Aaron1011

expand/resolve: Turn `#[derive]` into a regular macro attribute

This PR turns `#[derive]` into a regular attribute macro declared in libcore and defined in `rustc_builtin_macros`, like it was previously done with other "active" attributes in https://github.com/rust-lang/rust/pull/62086, https://github.com/rust-lang/rust/pull/62735 and other PRs.
This PR is also a continuation of #65252, #69870 and other PRs linked from them, which layed the ground for converting `#[derive]` specifically.

`#[derive]` still asks `rustc_resolve` to resolve paths inside `derive(...)`, and `rustc_expand` gets those resolution results through some backdoor (which I'll try to address later), but otherwise `#[derive]` is treated as any other macro attributes, which simplifies the resolution-expansion infra pretty significantly.

The change has several observable effects on language and library.
Some of the language changes are **feature-gated** by [`feature(macro_attributes_in_derive_output)`](https://github.com/rust-lang/rust/issues/81119).

#### Library

- `derive` is now available through standard library as `{core,std}::prelude::v1::derive`.

#### Language

- `derive` now goes through name resolution, so it can now be renamed - `use derive as my_derive; #[my_derive(Debug)] struct S;`.
- `derive` now goes through name resolution, so this resolution can fail in corner cases. Crater found one such regression, where import `use foo as derive` goes into a cycle with `#[derive(Something)]`.
- **[feature-gated]** `#[derive]` is now expanded as any other attributes in left-to-right order. This allows to remove the restriction on other macro attributes following `#[derive]` (https://github.com/rust-lang/reference/issues/566). The following macro attributes become a part of the derive's input (this is not a change, non-macro attributes following `#[derive]` were treated in the same way previously).
- `#[derive]` is now expanded as any other attributes in left-to-right order. This means two derive attributes `#[derive(Foo)] #[derive(Bar)]` are now expanded separately rather than together. It doesn't generally make difference, except for esoteric cases. For example `#[derive(Foo)]` can now produce an import bringing `Bar` into scope, but previously both `Foo` and `Bar` were required to be resolved before expanding any of them.
- **[feature-gated]** `#[derive()]` (with empty list in parentheses) actually becomes useful. For historical reasons `#[derive]` *fully configures* its input, eagerly evaluating `cfg` everywhere in its target, for example on fields.
Expansion infra doesn't do that for other attributes, but now when macro attributes attributes are allowed to be written after `#[derive]`, it means that derive can *fully configure* items for them.
    ```rust
#[derive()]
#[my_attr]
struct S {
#[cfg(FALSE)] // this field in removed by `#[derive()]` and not observed by `#[my_attr]`
field: u8
}
    ```
- `#[derive]` on some non-item targets is now prohibited. This was accidentally allowed as noop in the past, but was warned about since early 2018 (#50092), despite that crater found a few such cases in unmaintained crates.
- Derive helper attributes used before their introduction are now reported with a deprecation lint. This change is long overdue (since macro modularization, https://github.com/rust-lang/rust/issues/52226#issuecomment-422605033), but it was hard to do without fixing expansion order for derives. The deprecation is tracked by #79202.
```rust
    #[trait_helper] // warning: derive helper attribute is used before it is introduced
    #[derive(Trait)]
    struct S {}
```

Crater analysis: https://github.com/rust-lang/rust/pull/79078#issuecomment-731436821

3 years agoRemove treat-err-as-bug delay_span_bug test from run-make-fulldeps
Santiago Pastorino [Sun, 7 Feb 2021 04:50:17 +0000 (01:50 -0300)]
Remove treat-err-as-bug delay_span_bug test from run-make-fulldeps

3 years agoCreate ui test for -Ztreat-err-as-bug delay_span_bug
Santiago Pastorino [Sun, 7 Feb 2021 04:44:29 +0000 (01:44 -0300)]
Create ui test for -Ztreat-err-as-bug delay_span_bug