]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoAuto merge of #82341 - GuillaumeGomez:rollup-t7y7tyg, r=GuillaumeGomez
bors [Sat, 20 Feb 2021 21:38:53 +0000 (21:38 +0000)]
Auto merge of #82341 - GuillaumeGomez:rollup-t7y7tyg, r=GuillaumeGomez

Rollup of 7 pull requests

Successful merges:

 - #80595 (`impl PartialEq<Punct> for char`; symmetry for #78636)
 - #81991 (Fix panic in 'remove semicolon' when types are not local)
 - #82176 (fix MIR fn-ptr pretty-printing)
 - #82244 (Keep consistency in example for Stdin StdinLock)
 - #82260 (rustc: Show ``@path`` usage in stable)
 - #82316 (Fix minor mistake in LTO docs.)
 - #82332 (Don't generate src link on dummy spans)

Failed merges:

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

3 years agoRollup merge of #82332 - GuillaumeGomez:no-src-link-on-dummy-spans, r=jyn514
Guillaume Gomez [Sat, 20 Feb 2021 19:37:04 +0000 (20:37 +0100)]
Rollup merge of #82332 - GuillaumeGomez:no-src-link-on-dummy-spans, r=jyn514

Don't generate src link on dummy spans

Just realized that the "auto trait impls" had `[src]` links were leading to the crate root because they were dummy spans. This PR fixes this issue.

cc `@jyn514`
r? `@camelid`

3 years agoRollup merge of #82316 - ehuss:lto-doc-fix, r=GuillaumeGomez
Guillaume Gomez [Sat, 20 Feb 2021 19:37:03 +0000 (20:37 +0100)]
Rollup merge of #82316 - ehuss:lto-doc-fix, r=GuillaumeGomez

Fix minor mistake in LTO docs.

`-C lto=true` isn't a valid option.

3 years agoRollup merge of #82260 - ojeda:rustc-argfile, r=jyn514
Guillaume Gomez [Sat, 20 Feb 2021 19:37:02 +0000 (20:37 +0100)]
Rollup merge of #82260 - ojeda:rustc-argfile, r=jyn514

rustc: Show `@path` usage in stable

The feature was stabilized in #66172, but the usage string was not updated to be shown.

3 years agoRollup merge of #82244 - pickfire:patch-6, r=dtolnay
Guillaume Gomez [Sat, 20 Feb 2021 19:37:01 +0000 (20:37 +0100)]
Rollup merge of #82244 - pickfire:patch-6, r=dtolnay

Keep consistency in example for Stdin StdinLock

Stdin uses handle whereas StdinLock uses stdin_lock, changed it to handle.

3 years agoRollup merge of #82176 - RalfJung:mir-fn-ptr-pretty, r=oli-obk
Guillaume Gomez [Sat, 20 Feb 2021 19:37:00 +0000 (20:37 +0100)]
Rollup merge of #82176 - RalfJung:mir-fn-ptr-pretty, r=oli-obk

fix MIR fn-ptr pretty-printing

An uninitialized function pointer would get printed as `{{uninit  fn()}` (notice the unbalanced parentheses), and a dangling fn ptr would ICE. This fixes both of that.

However, I have no idea how to add tests for this.

Also, I don't understand this MIR pretty-printing code. Somehow the print function `pretty_print_const_scalar` actually *returns* a transformed form of the const (but there is no doc comment explaining what is being returned); some match arms do `p!` while others do `self =`, and there's a wild mixture of `p!` and `write!`... all very mysterious and confusing.^^

r? ``@oli-obk``

3 years agoRollup merge of #81991 - osa1:issue81839, r=estebank
Guillaume Gomez [Sat, 20 Feb 2021 19:36:57 +0000 (20:36 +0100)]
Rollup merge of #81991 - osa1:issue81839, r=estebank

Fix panic in 'remove semicolon' when types are not local

It's not possible to check if removing a semicolon fixes the type error
when checking match arms and one or both of the last arm's and the
current arm's return types are imported "opaque" types. In these cases
we don't generate a "consider removing semicolon" suggestions.

Fixes #81839

---

I'm not sure how to add a test for this. I think the test would need at least two crates. Do we have any existing tests that do this so that I can take a look?

3 years agoRollup merge of #80595 - pthariensflame:patch-1, r=m-ou-se
Guillaume Gomez [Sat, 20 Feb 2021 19:36:54 +0000 (20:36 +0100)]
Rollup merge of #80595 - pthariensflame:patch-1, r=m-ou-se

`impl PartialEq<Punct> for char`; symmetry for #78636

Also fixes the "since" version of the original.

Pinging ``@dtolnay`` and ``@petrochenkov.``

3 years agoAuto merge of #70951 - cjgillot:anarchy, r=oli-obk
bors [Sat, 20 Feb 2021 18:58:05 +0000 (18:58 +0000)]
Auto merge of #70951 - cjgillot:anarchy, r=oli-obk

Move the query engine out of rustc_middle

The handling of queries is moved to a trait `QueryEngine`.
It replaces `query::Queries` in the `TyCtxt`, allowing to move the query engine out of librustc_middle.

There are 2 modes to access the query engine: through `TyCtxt` and dynamic dispatch,
or through a `QueryCtxt`. The `QueryCtxt` is  required for everything touching the `OnDiskCache`.

For now, I put it in librustc_incremental, which is very small.
This may not be the best place.

A significant part of the codegen time for librustc_middle is moved to the recipient crate.

This PR may require a perf run.

cc #65031
r? `@Zoxc`

3 years agoAdd test for no src links on dummy spans
Guillaume Gomez [Sat, 20 Feb 2021 14:06:20 +0000 (15:06 +0100)]
Add test for no src links on dummy spans

3 years agoDon't render [src] link on dummy spans
Guillaume Gomez [Sat, 20 Feb 2021 14:05:50 +0000 (15:05 +0100)]
Don't render [src] link on dummy spans

3 years agofn ptr pretty printing: fall back to raw ptr printing
Ralf Jung [Sat, 20 Feb 2021 10:34:35 +0000 (11:34 +0100)]
fn ptr pretty printing: fall back to raw ptr printing

3 years agoAuto merge of #82124 - tmiasko:op-ty-ref, r=oli-obk
bors [Sat, 20 Feb 2021 10:20:42 +0000 (10:20 +0000)]
Auto merge of #82124 - tmiasko:op-ty-ref, r=oli-obk

Pass large interpreter types by reference, not value

r? `@ghost`

3 years agoAuto merge of #81427 - klensy:eat-digits, r=m-ou-se
bors [Sat, 20 Feb 2021 07:31:43 +0000 (07:31 +0000)]
Auto merge of #81427 - klensy:eat-digits, r=m-ou-se

simplify eat_digits

Simplify eat_digits by checking values in iterator, plus decrease function size, by returning unchecked slices.

https://godbolt.org/z/cxjav4

3 years agoAuto merge of #78181 - GuillaumeGomez:sized-trait, r=jyn514
bors [Sat, 20 Feb 2021 04:35:58 +0000 (04:35 +0000)]
Auto merge of #78181 - GuillaumeGomez:sized-trait, r=jyn514

Add Sized trait display when implemented on type

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

I'm not too happy about the hack I had to add in here, however, it seems like the `Sized` trait is **very** special.

cc `@jyn514`
r? `@ollie27`

3 years agoFix minor mistake in LTO docs.
Eric Huss [Sat, 20 Feb 2021 03:34:46 +0000 (19:34 -0800)]
Fix minor mistake in LTO docs.

`-C lto=true` isn't a valid option.

3 years ago`impl PartialEq<Punct> for char`; symmetry for #78636
Alexander Ronald Altman [Fri, 1 Jan 2021 19:40:00 +0000 (11:40 -0800)]
`impl PartialEq<Punct> for char`; symmetry for #78636

Also fixes the "since" version of the original.

3 years agoAdd tests for !Sized trait display
Guillaume Gomez [Thu, 18 Feb 2021 19:46:34 +0000 (20:46 +0100)]
Add tests for !Sized trait display

3 years agoShow negative implementation of Sized trait
Guillaume Gomez [Thu, 18 Feb 2021 19:46:07 +0000 (20:46 +0100)]
Show negative implementation of Sized trait

3 years agoWorkaround rustdoc not honouring cfg(parallel_compiler).
Camille GILLOT [Fri, 19 Feb 2021 20:48:47 +0000 (21:48 +0100)]
Workaround rustdoc not honouring cfg(parallel_compiler).

3 years agoMove the query system to rustc_query_impl.
Camille GILLOT [Tue, 19 Jan 2021 19:40:16 +0000 (20:40 +0100)]
Move the query system to rustc_query_impl.

3 years agoIntroduce a QueryEngine trait object.
Camille GILLOT [Mon, 18 Jan 2021 21:32:20 +0000 (22:32 +0100)]
Introduce a QueryEngine trait object.

3 years agoMake encode_query_results more generic.
Camille GILLOT [Tue, 19 Jan 2021 19:04:40 +0000 (20:04 +0100)]
Make encode_query_results more generic.

3 years agoMove query names and Providers to parent module.
Camille GILLOT [Tue, 19 Jan 2021 18:44:27 +0000 (19:44 +0100)]
Move query names and Providers to parent module.

3 years agoWrap QueryDescription into a macro.
Camille GILLOT [Tue, 19 Jan 2021 18:43:59 +0000 (19:43 +0100)]
Wrap QueryDescription into a macro.

3 years agoSplit DepKindStruct in two.
Camille GILLOT [Tue, 19 Jan 2021 18:07:06 +0000 (19:07 +0100)]
Split DepKindStruct in two.

3 years agoUse QueryCtxt in DepKindStruct.
Camille GILLOT [Tue, 19 Jan 2021 17:24:08 +0000 (18:24 +0100)]
Use QueryCtxt in DepKindStruct.

3 years agoUse a QueryContext for try_mark_green.
Camille GILLOT [Mon, 18 Jan 2021 22:53:42 +0000 (23:53 +0100)]
Use a QueryContext for try_mark_green.

3 years agoSelect caching strategy per query.
Camille GILLOT [Wed, 18 Nov 2020 17:45:16 +0000 (18:45 +0100)]
Select caching strategy per query.

The per-Key choice was not used.

3 years agoMove definition of callbacks to parent module.
Camille GILLOT [Mon, 18 Jan 2021 21:21:29 +0000 (22:21 +0100)]
Move definition of callbacks to parent module.

3 years agoMove handle_deadlock where it is used.
Camille GILLOT [Wed, 18 Nov 2020 18:02:31 +0000 (19:02 +0100)]
Move handle_deadlock where it is used.

3 years agoMove try_load_from_on_disk_cache to the QueryContext.
Camille GILLOT [Tue, 5 Jan 2021 17:37:42 +0000 (18:37 +0100)]
Move try_load_from_on_disk_cache to the QueryContext.

3 years agoMove try_print_query_stack to rustc_interface.
Camille GILLOT [Wed, 8 Apr 2020 18:47:36 +0000 (20:47 +0200)]
Move try_print_query_stack to rustc_interface.

3 years agoMake alloc_self_profile_query_strings a standalone function.
Camille GILLOT [Sun, 17 Jan 2021 13:57:34 +0000 (14:57 +0100)]
Make alloc_self_profile_query_strings a standalone function.

3 years agoMake QueryEngine opaque to TyCtxt.
Camille GILLOT [Sun, 11 Oct 2020 08:34:13 +0000 (10:34 +0200)]
Make QueryEngine opaque to TyCtxt.

3 years agoOpacify query invocation.
Camille GILLOT [Sun, 17 Jan 2021 13:58:34 +0000 (14:58 +0100)]
Opacify query invocation.

3 years agoWrap TyCtxt inside a QueryCtxt for queries.
Camille GILLOT [Wed, 8 Apr 2020 15:03:34 +0000 (17:03 +0200)]
Wrap TyCtxt inside a QueryCtxt for queries.

3 years agoDecouple the on-disk cache from the query engine.
Camille GILLOT [Mon, 4 Jan 2021 22:38:20 +0000 (23:38 +0100)]
Decouple the on-disk cache from the query engine.

3 years agoDecouple QueryContext from DepContext.
Camille GILLOT [Sun, 18 Oct 2020 19:01:36 +0000 (21:01 +0200)]
Decouple QueryContext from DepContext.

3 years agoRemove QueryAccessors::to_dep_node.
Camille GILLOT [Sun, 18 Oct 2020 19:00:24 +0000 (21:00 +0200)]
Remove QueryAccessors::to_dep_node.

3 years agoDon't require a QueryContext to access the DepGraph.
Camille GILLOT [Sun, 11 Oct 2020 08:34:50 +0000 (10:34 +0200)]
Don't require a QueryContext to access the DepGraph.

3 years agoGroup logic about the Providers struct.
Camille GILLOT [Thu, 9 Apr 2020 07:06:11 +0000 (09:06 +0200)]
Group logic about the Providers struct.

3 years agoAuto merge of #82020 - jyn514:mut-passes, r=camelid,GuillaumeGomez
bors [Fri, 19 Feb 2021 16:39:03 +0000 (16:39 +0000)]
Auto merge of #82020 - jyn514:mut-passes, r=camelid,GuillaumeGomez

Make `Clean` take &mut DocContext

- Take `FnMut` in `rustc_trait_selection::find_auto_trait_generics`
- Take `&mut DocContext` in most of `clean`
- Collect the iterator in auto_trait_impls instead of iterating lazily; the lifetimes were really bad.

This combined with https://github.com/rust-lang/rust/pull/82018 should hopefully help with https://github.com/rust-lang/rust/pull/82014 by allowing `cx.cache.exported_traits` to be modified in `register_res`. Previously it had to use interior mutability, which required either adding a RefCell to `cache.exported_traits` on *top* of the existing `RefCell<Cache>` or mixing reads and writes between `cx.exported_traits` and `cx.cache.exported_traits`. I don't currently have that working but I expect it to be reasonably easy to add after this.

3 years agosimplify eat_digits
klensy [Fri, 19 Feb 2021 15:47:22 +0000 (18:47 +0300)]
simplify eat_digits

3 years agoAuto merge of #82281 - Dylan-DPC:rollup-raob2tu, r=Dylan-DPC
bors [Fri, 19 Feb 2021 08:24:01 +0000 (08:24 +0000)]
Auto merge of #82281 - Dylan-DPC:rollup-raob2tu, r=Dylan-DPC

Rollup of 10 pull requests

Successful merges:

 - #79747 (Add explanations and suggestions to `irrefutable_let_patterns` lint)
 - #81496 (name async generators something more human friendly in type error diagnostic)
 - #81873 (Add Mutex::unlock)
 - #82093 (Add tests for Atomic*::fetch_{min,max})
 - #82238 (ast: Keep expansion status for out-of-line module items)
 - #82245 (Do not ICE when evaluating locals' types of invalid `yield`)
 - #82259 (Fix popping singleton paths in when generating E0433)
 - #82261 (rustdoc: Support argument files)
 - #82274 (libtest: Fix unwrap panic on duplicate TestDesc)
 - #82275 (Update cargo)

Failed merges:

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

3 years agoRollup merge of #82275 - ehuss:update-cargo, r=ehuss
Dylan DPC [Fri, 19 Feb 2021 01:49:14 +0000 (02:49 +0100)]
Rollup merge of #82275 - ehuss:update-cargo, r=ehuss

Update cargo

8 commits in ab64d1393b5b77c66b6534ef5023a1b89ee7bf64..bf5a5d5e5d3ae842a63bfce6d070dfd438cf6070
2021-02-10 00:19:10 +0000 to 2021-02-18 15:49:14 +0000
- Propagate `lto=off` harder (rust-lang/cargo#9182)
- refactor: make deref intentions more straightforward (rust-lang/cargo#9183)
- Update link for no_std attribute. (rust-lang/cargo#9174)
- Remove mention of --message-format taking multiple values (rust-lang/cargo#9173)
- Emit warning on env variable case mismatch (rust-lang/cargo#9169)
- Implement Rustdoc versioning checks (rust-lang/cargo#8640)
- Bump to 0.53.0, update changelog (rust-lang/cargo#9168)
- Prevent testsuite from loading config out of sandbox. (rust-lang/cargo#9164)

3 years agoRollup merge of #82274 - andersk:test-unwrap, r=Mark-Simulacrum
Dylan DPC [Fri, 19 Feb 2021 01:49:13 +0000 (02:49 +0100)]
Rollup merge of #82274 - andersk:test-unwrap, r=Mark-Simulacrum

libtest: Fix unwrap panic on duplicate TestDesc

It is possible for different tests to collide to the same `TestDesc` when macros are involved. That is a bug, but it didn’t cause a panic until #81367. For now, change the code to ignore this problem.

Fixes #81852.

This will need to be applied to `beta` too.

3 years agoRollup merge of #82261 - ojeda:rustdoc-argfile, r=jyn514
Dylan DPC [Fri, 19 Feb 2021 01:49:12 +0000 (02:49 +0100)]
Rollup merge of #82261 - ojeda:rustdoc-argfile, r=jyn514

rustdoc: Support argument files

Factors out the `rustc_driver` logic that handles argument files so that rustdoc supports them as well, e.g.:

    rustdoc `@argfile`

This is needed to be able to generate docs for projects that already use argument files when compiling them, e.g. projects that pass a huge number of `--cfg` arguments.

The feature was stabilized for `rustc` in #66172.

3 years agoRollup merge of #82259 - osa1:issue82156, r=petrochenkov
Dylan DPC [Fri, 19 Feb 2021 01:49:11 +0000 (02:49 +0100)]
Rollup merge of #82259 - osa1:issue82156, r=petrochenkov

Fix popping singleton paths in when generating E0433

Fixes #82156

---

This was introduced with #72923, so pinging `@Patryk27` for reviews.

3 years agoRollup merge of #82245 - estebank:issue-78653, r=matthewjasper
Dylan DPC [Fri, 19 Feb 2021 01:49:09 +0000 (02:49 +0100)]
Rollup merge of #82245 - estebank:issue-78653, r=matthewjasper

Do not ICE when evaluating locals' types of invalid `yield`

When a `yield` is outside of a generator, check its value regardless to
avoid an ICE while trying to get all locals' types in writeback.

Fix #78653.

3 years agoRollup merge of #82238 - petrochenkov:nocratemod, r=Aaron1011
Dylan DPC [Fri, 19 Feb 2021 01:49:08 +0000 (02:49 +0100)]
Rollup merge of #82238 - petrochenkov:nocratemod, r=Aaron1011

ast: Keep expansion status for out-of-line module items

I.e. whether a module `mod foo;` is already loaded from a file or not.
This is a pre-requisite to correctly treating inner attributes on such modules (https://github.com/rust-lang/rust/issues/81661).

With this change AST structures for `mod` items diverge even more for AST structure for the crate root, which previously used `ast::Mod`.
Therefore this PR removes `ast::Mod` from `ast::Crate` in the first commit, these two things are sufficiently different from each other, at least at syntactic level.
Customization points for visiting a "`mod` item or crate root" were also removed from AST visitors (`fn visit_mod`).
`ast::Mod` itself was refactored away in the second commit in favor of `ItemKind::Mod(Unsafe, ModKind)`.

3 years agoRollup merge of #82093 - bjorn3:more_atomic_tests, r=kennytm
Dylan DPC [Fri, 19 Feb 2021 01:49:07 +0000 (02:49 +0100)]
Rollup merge of #82093 - bjorn3:more_atomic_tests, r=kennytm

Add tests for Atomic*::fetch_{min,max}

This ensures that all atomic operations except for fences are tested. This has been useful to test my work on using atomic instructions for atomic operations in cg_clif instead of a global lock.

3 years agoRollup merge of #81873 - mark-i-m:unlock, r=m-ou-se
Dylan DPC [Fri, 19 Feb 2021 01:49:06 +0000 (02:49 +0100)]
Rollup merge of #81873 - mark-i-m:unlock, r=m-ou-se

Add Mutex::unlock

Tracking issue: https://github.com/rust-lang/rust/issues/81872

Discussion: https://github.com/rust-lang/rust/pull/79434#issuecomment-757135874

r? `@m-ou-se`

3 years agoRollup merge of #81496 - guswynn:expected_async_block, r=oli-obk
Dylan DPC [Fri, 19 Feb 2021 01:49:00 +0000 (02:49 +0100)]
Rollup merge of #81496 - guswynn:expected_async_block, r=oli-obk

name async generators something more human friendly in type error diagnostic

fixes #81457

Some details:

1. I opted to load the generator kind from the hir in TyCategory. I also use 1 impl in the hir for the descr
2. I named both the source of the future, in addition to the general type (`future`), not sure what is preferred
3. I am not sure what is required to make sure "generator" is not referred to anywhere. A brief `rg "\"generator\"" showed me that most diagnostics correctly distinguish from generators and async generator, but the `descr` of `DefKind` is pretty general (not sure how thats used)
4. should the descr impl of AsyncGeneratorKind use its display impl instead of copying the string?

3 years agoRollup merge of #79747 - camelid:irrefut-lint-link, r=varkor
Dylan DPC [Fri, 19 Feb 2021 01:48:59 +0000 (02:48 +0100)]
Rollup merge of #79747 - camelid:irrefut-lint-link, r=varkor

Add explanations and suggestions to `irrefutable_let_patterns` lint

Fixes #79716.

3 years agorustdoc: Support argument files
Miguel Ojeda [Thu, 18 Feb 2021 15:15:24 +0000 (16:15 +0100)]
rustdoc: Support argument files

Factors out the `rustc_driver` logic that handles argument files
so that rustdoc supports them as well, e.g.:

    rustdoc @argfile

This is needed to be able to generate docs for projects that
already use argument files when compiling them, e.g. projects
that pass a huge number of `--cfg` arguments.

The feature was stabilized for `rustc` in #66172.

Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
3 years agoAdd explanations and suggestions to `irrefutable_let_patterns` lint
Camelid [Sat, 5 Dec 2020 21:12:39 +0000 (13:12 -0800)]
Add explanations and suggestions to `irrefutable_let_patterns` lint

3 years agoUpdate cargo
Eric Huss [Thu, 18 Feb 2021 21:04:05 +0000 (13:04 -0800)]
Update cargo

3 years agolibtest: Fix unwrap panic on duplicate TestDesc.
Anders Kaseorg [Thu, 18 Feb 2021 20:41:08 +0000 (12:41 -0800)]
libtest: Fix unwrap panic on duplicate TestDesc.

It is possible for different tests to collide to the same TestDesc
when macros are involved.  That is a bug, but it didn’t cause a panic
until #81367.  For now, change the code to ignore this problem.

Fixes #81852.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
3 years agoAuto merge of #82263 - Dylan-DPC:rollup-cypm2uw, r=Dylan-DPC
bors [Thu, 18 Feb 2021 19:45:42 +0000 (19:45 +0000)]
Auto merge of #82263 - Dylan-DPC:rollup-cypm2uw, r=Dylan-DPC

Rollup of 10 pull requests

Successful merges:

 - #81546 ([libtest] Run the test synchronously when hitting thread limit)
 - #82066 (Ensure valid TraitRefs are created for GATs)
 - #82112 (const_generics: Dont evaluate array length const when handling yet another error )
 - #82194 (In some limited cases, suggest `where` bounds for non-type params)
 - #82215 (Replace if-let and while-let with `if let` and `while let`)
 - #82218 (Make sure pdbs are copied along with exe and dlls when bootstrapping)
 - #82236 (avoid converting types into themselves (clippy::useless_conversion))
 - #82246 (Add long explanation for E0549)
 - #82248 (Optimize counting digits in line numbers during error reporting)
 - #82256 (Print -Ztime-passes (and misc stats/logs) on stderr, not stdout.)

Failed merges:

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

3 years agoadd Mutex::unlock
mark [Mon, 8 Feb 2021 04:50:02 +0000 (22:50 -0600)]
add Mutex::unlock

3 years agoignore file length
Gus Wynn [Thu, 18 Feb 2021 16:17:43 +0000 (08:17 -0800)]
ignore file length

3 years agoFix popping singleton paths in when generating E0433
Ömer Sinan Ağacan [Thu, 18 Feb 2021 14:53:09 +0000 (17:53 +0300)]
Fix popping singleton paths in when generating E0433

Fixes #82156

3 years agoRollup merge of #82256 - eddyb:time-passes-stderr, r=varkor
Dylan DPC [Thu, 18 Feb 2021 15:57:43 +0000 (16:57 +0100)]
Rollup merge of #82256 - eddyb:time-passes-stderr, r=varkor

Print -Ztime-passes (and misc stats/logs) on stderr, not stdout.

I've tried not to change anything that looked similar to `rustc --print`, where people might use automation, and/or any "bulk" prints, such as dumping an entire Graphviz (`dot`) graph on stdout.

The reason I want `-Ztime-passes` to be on stderr like debug logging is I can get a complete (and correctly interleaved) view just by looking at stderr, which is merely a convenience when running `rustc`/Cargo directly, but even more important when it's nested in a build script, as Cargo will split the build script output into stdout (named `output`) and `stderr`.

3 years agoRollup merge of #82248 - nhwn:optimize-counting-digits, r=varkor
Dylan DPC [Thu, 18 Feb 2021 15:57:42 +0000 (16:57 +0100)]
Rollup merge of #82248 - nhwn:optimize-counting-digits, r=varkor

Optimize counting digits in line numbers during error reporting

Replaces `.to_string().len()` with simple loop and integer division, which avoids an unnecessary allocation.

Although I couldn't figure out how to directly profile `rustc`'s error reporting, I ran a microbenchmark on my machine (2.9 GHz Dual-Core Intel Core i5) on the two strategies for `0..100_000`, and the results seem promising:
```
test to_string_len ... bench:  12,124,792 ns/iter (+/- 700,652)
test while_loop    ... bench:      30,333 ns/iter (+/- 562)
```
The x86_64 disassembly reduces integer division to a multiplication + shift, so I don't think there's any problems with using integer division.

For more (micro)optimization, it would be nice if we could avoid the initial check to see if the line number is nonzero, but I don't think `self.get_max_line_num(span, children)` _guarantees_ a nonzero line number.

3 years agoRollup merge of #82246 - jesusprubio:add-long-explanation-e0549, r=GuillaumeGomez
Dylan DPC [Thu, 18 Feb 2021 15:57:41 +0000 (16:57 +0100)]
Rollup merge of #82246 - jesusprubio:add-long-explanation-e0549, r=GuillaumeGomez

Add long explanation for E0549

Helps with #61137

3 years agoRollup merge of #82236 - matthiaskrgr:useless_conv, r=jyn514
Dylan DPC [Thu, 18 Feb 2021 15:57:40 +0000 (16:57 +0100)]
Rollup merge of #82236 - matthiaskrgr:useless_conv, r=jyn514

avoid converting types into themselves (clippy::useless_conversion)

3 years agoRollup merge of #82218 - rylev:copy-pdbs, r=Mark-Simulacrum
Dylan DPC [Thu, 18 Feb 2021 15:57:38 +0000 (16:57 +0100)]
Rollup merge of #82218 - rylev:copy-pdbs, r=Mark-Simulacrum

Make sure pdbs are copied along with exe and dlls when bootstrapping

This makes it easier to find the pdbs when wanting to debug the compiler on Windows.

3 years agoRollup merge of #82215 - TaKO8Ki:replace-if-let-while-let, r=varkor
Dylan DPC [Thu, 18 Feb 2021 15:57:37 +0000 (16:57 +0100)]
Rollup merge of #82215 - TaKO8Ki:replace-if-let-while-let, r=varkor

Replace if-let and while-let with `if let` and `while let`

This pull request replaces if-let and while-let with `if let` and `while let`.

closes https://github.com/rust-lang/rust/issues/82205

3 years agoRollup merge of #82194 - estebank:arbitrary-bounds-suggestion, r=petrochenkov
Dylan DPC [Thu, 18 Feb 2021 15:57:36 +0000 (16:57 +0100)]
Rollup merge of #82194 - estebank:arbitrary-bounds-suggestion, r=petrochenkov

In some limited cases, suggest `where` bounds for non-type params

Partially address #81971.

3 years agoRollup merge of #82112 - BoxyUwU:tumbleweed, r=varkor
Dylan DPC [Thu, 18 Feb 2021 15:57:35 +0000 (16:57 +0100)]
Rollup merge of #82112 - BoxyUwU:tumbleweed, r=varkor

const_generics: Dont evaluate array length const when handling yet another error

Same ICE as #82009 except triggered by a different error.
cc ``@lcnr``
r? ``@varkor``

3 years agoRollup merge of #82066 - matthewjasper:trait-ref-fix, r=jackh726
Dylan DPC [Thu, 18 Feb 2021 15:57:34 +0000 (16:57 +0100)]
Rollup merge of #82066 - matthewjasper:trait-ref-fix, r=jackh726

Ensure valid TraitRefs are created for GATs

This fixes `ProjectionTy::trait_ref` to use the correct substs. Places that need all of the substs have been updated to not use `trait_ref`.

r? ````@jackh726````

3 years agoRollup merge of #81546 - hyd-dev:libtest-run-out-of-threads, r=Mark-Simulacrum
Dylan DPC [Thu, 18 Feb 2021 15:57:33 +0000 (16:57 +0100)]
Rollup merge of #81546 - hyd-dev:libtest-run-out-of-threads, r=Mark-Simulacrum

[libtest] Run the test synchronously when hitting thread limit

libtest currently panics if it hits the thread limit. This often results in spurious test failures (<code>thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 11, kind: WouldBlock, message: "Resource temporarily unavailable" }'</code> ... `error: test failed, to rerun pass '--lib'`). This PR makes it continue to run the test synchronously if it runs out of threads.

Closes #78165.

``@rustbot`` label: A-libtest T-libs

3 years agorustc: Show `@path` usage in stable
Miguel Ojeda [Thu, 18 Feb 2021 15:10:28 +0000 (16:10 +0100)]
rustc: Show `@path` usage in stable

The feature was stabilized in #66172, but the usage string was not
updated to be shown.

Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
3 years agonhwn: optimize counting digits in line numbers
Nathan Nguyen [Thu, 18 Feb 2021 05:44:37 +0000 (23:44 -0600)]
nhwn: optimize counting digits in line numbers

3 years agoAdd regression test
Ömer Sinan Ağacan [Thu, 18 Feb 2021 13:47:01 +0000 (16:47 +0300)]
Add regression test

3 years agoUpdate 'match-prev-arm-needing-semi'
Ömer Sinan Ağacan [Thu, 11 Feb 2021 17:17:57 +0000 (20:17 +0300)]
Update 'match-prev-arm-needing-semi'

3 years agoCheck opaque type def ids before bailing out
Ömer Sinan Ağacan [Thu, 11 Feb 2021 10:37:00 +0000 (13:37 +0300)]
Check opaque type def ids before bailing out

3 years agoFix panic in 'remove semicolon' when types are not local
Ömer Sinan Ağacan [Thu, 11 Feb 2021 09:53:42 +0000 (12:53 +0300)]
Fix panic in 'remove semicolon' when types are not local

It's not possible to check if removing a semicolon fixes the type error
when checking match arms and one or both of the last arm's and the
current arm's return types are imported "opaque" types. In these cases
we don't generate a "consider removing semicolon" suggestions.

Fixes #81839

3 years agoPrint -Ztime-passes (and misc stats/logs) on stderr, not stdout.
Eduard-Mihai Burtescu [Thu, 18 Feb 2021 12:13:38 +0000 (14:13 +0200)]
Print -Ztime-passes (and misc stats/logs) on stderr, not stdout.

3 years agoAuto merge of #81574 - tmiasko:p, r=oli-obk
bors [Thu, 18 Feb 2021 10:13:36 +0000 (10:13 +0000)]
Auto merge of #81574 - tmiasko:p, r=oli-obk

Precompute ancestors when checking privacy

Precompute ancestors of the old error node set so that check for private
types and traits in public interfaces can in constant time determine if
the current item has any descendants in the old error set.

This removes disparity in compilation time between public and private type
aliases reported in #50614 (from 30 s to 5 s, in an example making extensive use
of private type aliases).

No functional changes intended.

3 years agoast: Keep expansion status for out-of-line module items
Vadim Petrochenkov [Tue, 16 Feb 2021 21:56:07 +0000 (00:56 +0300)]
ast: Keep expansion status for out-of-line module items

Also remove `ast::Mod` which is mostly redundant now

3 years agoast: Stop using `Mod` in `Crate`
Vadim Petrochenkov [Sun, 14 Feb 2021 18:14:12 +0000 (21:14 +0300)]
ast: Stop using `Mod` in `Crate`

Crate root is sufficiently different from `mod` items, at least at syntactic level.

Also remove customization point for "`mod` item or crate root" from AST visitors.

3 years agoUpdate compiler/rustc_error_codes/src/error_codes/E0549.md
Jesús Rubio [Thu, 18 Feb 2021 09:03:01 +0000 (10:03 +0100)]
Update compiler/rustc_error_codes/src/error_codes/E0549.md

Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
3 years agoUpdate compiler/rustc_error_codes/src/error_codes/E0549.md
Jesús Rubio [Thu, 18 Feb 2021 08:38:42 +0000 (09:38 +0100)]
Update compiler/rustc_error_codes/src/error_codes/E0549.md

Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
3 years agoUpdate compiler/rustc_error_codes/src/error_codes/E0549.md
Jesús Rubio [Thu, 18 Feb 2021 08:23:21 +0000 (09:23 +0100)]
Update compiler/rustc_error_codes/src/error_codes/E0549.md

Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
3 years agoAuto merge of #82249 - JohnTitor:rollup-3jbqija, r=JohnTitor
bors [Thu, 18 Feb 2021 07:22:30 +0000 (07:22 +0000)]
Auto merge of #82249 - JohnTitor:rollup-3jbqija, r=JohnTitor

Rollup of 8 pull requests

Successful merges:

 - #82055 (Add diagnostics for specific cases for const/type mismatch err)
 - #82155 (Use !Sync std::lazy::OnceCell in usefulness checking)
 - #82202 (add specs for riscv32/riscv64 musl targets)
 - #82203 (Move some tests to more reasonable directories - 4)
 - #82211 (make `suggest_setup` help messages better)
 - #82212 (Remove redundant rustc_data_structures path component)
 - #82240 (remove useless ?s (clippy::needless_question_marks))
 - #82243 (Add more intra-doc links to std::io)

Failed merges:

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

3 years agoRollup merge of #82243 - pickfire:patch-5, r=jyn514
Yuki Okushi [Thu, 18 Feb 2021 06:57:34 +0000 (15:57 +0900)]
Rollup merge of #82243 - pickfire:patch-5, r=jyn514

Add more intra-doc links to std::io

3 years agoRollup merge of #82240 - matthiaskrgr:qmark, r=Dylan-DPC
Yuki Okushi [Thu, 18 Feb 2021 06:57:33 +0000 (15:57 +0900)]
Rollup merge of #82240 - matthiaskrgr:qmark, r=Dylan-DPC

remove useless ?s (clippy::needless_question_marks)

Example code:
```rust
fn opts() -> Option<String> {
    let s: Option<String> = Some(String::new());
    Some(s?) // this can just be "s"
}
```

3 years agoRollup merge of #82212 - est31:graph_graph_graph, r=oli-obk
Yuki Okushi [Thu, 18 Feb 2021 06:57:32 +0000 (15:57 +0900)]
Rollup merge of #82212 - est31:graph_graph_graph, r=oli-obk

Remove redundant rustc_data_structures path component

3 years agoRollup merge of #82211 - henryboisdequin:make-setup-msgs-better, r=jyn514
Yuki Okushi [Thu, 18 Feb 2021 06:57:30 +0000 (15:57 +0900)]
Rollup merge of #82211 - henryboisdequin:make-setup-msgs-better, r=jyn514

make `suggest_setup` help messages better

When I first built the compiler and didn't create a `config.toml.example`, the following was emitted:

```
help: consider running `x.py setup` or copying `config.toml.example`
```

I ran `x.py setup` but got an error so in this PR I made the help messages a little clearer.

3 years agoRollup merge of #82203 - c410-f3r:tests-tests-tests, r=Dylan-DPC
Yuki Okushi [Thu, 18 Feb 2021 06:57:29 +0000 (15:57 +0900)]
Rollup merge of #82203 - c410-f3r:tests-tests-tests, r=Dylan-DPC

Move some tests to more reasonable directories - 4

cc #81941

3 years agoRollup merge of #82202 - kraj:kraj/riscv-musl, r=estebank
Yuki Okushi [Thu, 18 Feb 2021 06:57:28 +0000 (15:57 +0900)]
Rollup merge of #82202 - kraj:kraj/riscv-musl, r=estebank

add specs for riscv32/riscv64 musl targets

Signed-off-by: Khem Raj <raj.khem@gmail.com>
3 years agoRollup merge of #82155 - tmiasko:once, r=matthewjasper
Yuki Okushi [Thu, 18 Feb 2021 06:57:27 +0000 (15:57 +0900)]
Rollup merge of #82155 - tmiasko:once, r=matthewjasper

Use !Sync std::lazy::OnceCell in usefulness checking

The `rustc_data_structures::sync::OnceCell` is thread-safe when building
a parallel compiler. This is unnecessary for the purposes of pattern
usefulness checking. Use `!Sync` `std::lazy::OnceCell` instead.

3 years agoRollup merge of #82055 - JulianKnodt:ty_where_const, r=estebank
Yuki Okushi [Thu, 18 Feb 2021 06:57:26 +0000 (15:57 +0900)]
Rollup merge of #82055 - JulianKnodt:ty_where_const, r=estebank

Add diagnostics for specific cases for const/type mismatch err

For now, this adds at least more information so better diagnostics can be emitted for const mismatch errors.

I'm not sure what exactly we want to emit, so I've left notes there temporarily, also to see if this is the right approach

r? ```@lcnr```
cc: ```@estebank```

3 years agoAdd long explanation for E0549
Jesus Rubio [Thu, 18 Feb 2021 05:53:01 +0000 (06:53 +0100)]
Add long explanation for E0549

3 years agoDo not ICE when evaluating locals' types of invalid `yield`
Esteban Küber [Thu, 18 Feb 2021 04:44:00 +0000 (20:44 -0800)]
Do not ICE when evaluating locals' types of invalid `yield`

When a `yield` is outside of a generator, check its value regardless to
avoid an ICE while trying to get all locals' types in writeback.

Fix #78653.

3 years agoAuto merge of #81172 - SimonSapin:ptr-metadata, r=oli-obk
bors [Thu, 18 Feb 2021 04:22:16 +0000 (04:22 +0000)]
Auto merge of #81172 - SimonSapin:ptr-metadata, r=oli-obk

Implement RFC 2580: Pointer metadata & VTable

RFC: https://github.com/rust-lang/rfcs/pull/2580

~~Before merging this PR:~~

* [x] Wait for the end of the RFC’s [FCP to merge](https://github.com/rust-lang/rfcs/pull/2580#issuecomment-759145278).
* [x] Open a tracking issue: https://github.com/rust-lang/rust/issues/81513
* [x] Update `#[unstable]` attributes in the PR with the tracking issue number

----

This PR extends the language with a new lang item for the `Pointee` trait which is special-cased in trait resolution to implement it for all types. Even in generic contexts, parameters can be assumed to implement it without a corresponding bound.

For this I mostly imitated what the compiler was already doing for the `DiscriminantKind` trait. I’m very unfamiliar with compiler internals, so careful review is appreciated.

This PR also extends the standard library with new unstable APIs in `core::ptr` and `std::ptr`:

```rust
pub trait Pointee {
    /// One of `()`, `usize`, or `DynMetadata<dyn SomeTrait>`
    type Metadata: Copy + Send + Sync + Ord + Hash + Unpin;
}

pub trait Thin = Pointee<Metadata = ()>;

pub const fn metadata<T: ?Sized>(ptr: *const T) -> <T as Pointee>::Metadata {}

pub const fn from_raw_parts<T: ?Sized>(*const (), <T as Pointee>::Metadata) -> *const T {}
pub const fn from_raw_parts_mut<T: ?Sized>(*mut (),<T as Pointee>::Metadata) -> *mut T {}

impl<T: ?Sized> NonNull<T> {
    pub const fn from_raw_parts(NonNull<()>, <T as Pointee>::Metadata) -> NonNull<T> {}

    /// Convenience for `(ptr.cast(), metadata(ptr))`
    pub const fn to_raw_parts(self) -> (NonNull<()>, <T as Pointee>::Metadata) {}
}

impl<T: ?Sized> *const T {
    pub const fn to_raw_parts(self) -> (*const (), <T as Pointee>::Metadata) {}
}

impl<T: ?Sized> *mut T {
    pub const fn to_raw_parts(self) -> (*mut (), <T as Pointee>::Metadata) {}
}

/// `<dyn SomeTrait as Pointee>::Metadata == DynMetadata<dyn SomeTrait>`
pub struct DynMetadata<Dyn: ?Sized> {
    // Private pointer to vtable
}

impl<Dyn: ?Sized> DynMetadata<Dyn> {
    pub fn size_of(self) -> usize {}
    pub fn align_of(self) -> usize {}
    pub fn layout(self) -> crate::alloc::Layout {}
}

unsafe impl<Dyn: ?Sized> Send for DynMetadata<Dyn> {}
unsafe impl<Dyn: ?Sized> Sync for DynMetadata<Dyn> {}
impl<Dyn: ?Sized> Debug for DynMetadata<Dyn> {}
impl<Dyn: ?Sized> Unpin for DynMetadata<Dyn> {}
impl<Dyn: ?Sized> Copy for DynMetadata<Dyn> {}
impl<Dyn: ?Sized> Clone for DynMetadata<Dyn> {}
impl<Dyn: ?Sized> Eq for DynMetadata<Dyn> {}
impl<Dyn: ?Sized> PartialEq for DynMetadata<Dyn> {}
impl<Dyn: ?Sized> Ord for DynMetadata<Dyn> {}
impl<Dyn: ?Sized> PartialOrd for DynMetadata<Dyn> {}
impl<Dyn: ?Sized> Hash for DynMetadata<Dyn> {}
```

API differences from the RFC, in areas noted as unresolved questions in the RFC:

* Module-level functions instead of associated `from_raw_parts` functions on `*const T` and `*mut T`, following the precedent of `null`, `slice_from_raw_parts`, etc.
* Added `to_raw_parts`

3 years agoKeep consistency in example for Stdin StdinLock
Ivan Tham [Thu, 18 Feb 2021 02:11:57 +0000 (10:11 +0800)]
Keep consistency in example for Stdin StdinLock

Stdin uses handle whereas StdinLock uses stdin_lock, changed it to handle.

3 years agoAdd missing link from stdio doc
Ivan Tham [Thu, 18 Feb 2021 01:58:15 +0000 (09:58 +0800)]
Add missing link from stdio doc