Commit graph

307 commits

Author SHA1 Message Date
est31
2805a05154 Add bench_typed_arena_clear_100 bench 2020-09-18 05:52:45 +02:00
est31
daccd1709e Replace loop with drop_in_place call 2020-09-18 04:49:02 +02:00
est31
5acfcceb47 Dogfood new_uninit and maybe_uninit_slice in rustc_arena 2020-09-18 04:49:02 +02:00
Tyler Mandry
3bf66ae25f
Rollup merge of #76794 - richkadel:graphviz-font, r=ecstatic-morse
Make graphviz font configurable

Alternative to PR #76776.

To change the graphviz output to use an alternative `fontname` value,
add a command line option like: `rustc --graphviz-font=monospace`.

r? @ecstatic-morse
2020-09-16 12:24:30 -07:00
Tyler Mandry
cd766c9d09
Rollup merge of #76775 - ecstatic-morse:dataflow-extra-tab-diff, r=Mark-Simulacrum
Strip a single leading tab when rendering dataflow diffs

The `fmt_diff_with` formatter uses a tab to separate additions from subtractions. Strip it when rendering those diffs on separate lines.

r? @Mark-Simulacrum (since you're speedy)
2020-09-16 12:24:27 -07:00
Tyler Mandry
6e0131cd5b
Rollup merge of #76760 - matthiaskrgr:clippy_lazy_eval, r=varkor
don't lazily evaluate some trivial values for Option::None replacements (clippy::unnecessary_lazy_evaluations)
2020-09-16 12:24:23 -07:00
Tyler Mandry
a6c4d30c7b
Rollup merge of #76756 - matthiaskrgr:cl123ppy, r=Dylan-DPC
fix a couple of stylistic clippy warnings

namely:

clippy::redundant_pattern_matching
clippy::redundant_pattern
clippy::search_is_some
clippy::filter_next
clippy::into_iter_on_ref
clippy::clone_on_copy
clippy::needless_return
2020-09-16 12:24:17 -07:00
Tyler Mandry
a63f8c1cac
Rollup merge of #76719 - hameerabbasi:min-const-generics-ty, r=lcnr
Change error message for ty param in const

This PR introduces the following changes:

* Change error message for type param in a const expression when using
`min_const_generics`
* Change `ParamInNonTrivialAnonConst` to contain an extra `bool` used for
distinguishing whether the passed-in symbol is a type or a value.

Fixes #76701
2020-09-16 12:24:06 -07:00
Rich Kadel
3875abe32f Added RUSTC_GRAPHVIZ_FONT environment variable
Overrides the debugging_opts.graphviz_font setting.
2020-09-16 11:27:17 -07:00
Rich Kadel
5c29332ace Make graphviz font configurable
Alternative to PR ##76776.

To change the graphviz output to use an alternative `fontname` value,
add a command line option like: `rustc --graphviz-font=monospace`.
2020-09-16 08:10:06 -07:00
Dylan DPC
b25261f40c
Rollup merge of #76714 - camelid:patch-3, r=jonas-schievink
Small docs improvements

@rustbot modify labels: T-doc T-compiler
2020-09-16 12:34:27 +02:00
Dylan DPC
3f9e7fc049
Rollup merge of #76699 - lcnr:const-infer-err, r=varkor
improve const infer error

cc #72328

reduces it from
```
error[E0282]: type annotations needed
  --> src/main.rs:17:5
   |
17 |     Foo.bar().bar().bar().bar().baz();
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: unable to infer the value of a const parameter
```
to
```
error[E0282]: type annotations needed
  --> $DIR/method-chain.rs:21:33
   |
LL |     Foo.bar().bar().bar().bar().baz();
   |                                 ^^^
   |
   = note: cannot infer the value of the const parameter `N`
```

r? @varkor
2020-09-16 12:34:21 +02:00
Dylan DPC
54d77285fc
Rollup merge of #76695 - iximeow:trait-generic-bound-suggestion, r=estebank
fix syntax error in suggesting generic constraint in trait parameter

suggest `where T: Foo` for the first bound on a trait, then suggest
`, T: Foo` when the suggested bound would add to an existing set of
`where` clauses. `where T: Foo` may be the first bound if `T` has a
default, because we'd rather suggest
```
trait A<T=()> where T: Copy
```
than
```
trait A<T: Copy=()>
```
for legibility reasons.

the test case i added here is derived from [this reproduction](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=0bf3ace9f2a183d0bdbd748c6b8e3971):
```
struct B<T: Copy> {
    t: T
}

trait A<T = ()> {
    fn returns_constrained_type(&self, t: T) -> B<T> {
        B { t }
    }
}
```
where the suggested fix,
```
trait A<T = ()>, T: Copy { ... }
```
is in fact invalid syntax!

i also found an error in the existing suggestion for `trait Base<T = String>: Super<T>` where rustc would suggest `trait Base<T = String>: Super<T>, T: Copy`, but `T: Copy` is the first of the trait's `where` clauses and should be `where T: Copy` as well. the test for that suggestion expects invalid syntax, and has been revised to a compiler-pleasing `trait Base<T = String>: Super<T> where T: Copy`.

judging by https://github.com/rust-lang/rust/pull/70009 i'll.. cc @estebank ?
2020-09-16 12:34:20 +02:00
Dylan DPC
2c2f1c239e
Rollup merge of #76694 - wesleywiser:partitioning_cx_trait, r=davidtwco
Introduce a PartitioningCx struct

This contains all the data used by the partitioning algorithm and allows that data to be used at each stage of the partitioning. This is useful for other approaches to partitioning which may want different pieces of the data available at each step.

cc @rust-lang/wg-incr-comp
2020-09-16 12:34:18 +02:00
Ralf Jung
0bcc96dd3d
Rollup merge of #76641 - nox:pointee-random-stuff, r=eddyb
Some cleanup changes and commenting

r? @nikomatsakis
Cc @eddyb
2020-09-16 08:25:00 +02:00
Dylan MacKenzie
c910e038e8 Strip a single leading tab when rendering dataflow diffs 2020-09-15 18:32:12 -07:00
Dylan DPC
db228987ac
Rollup merge of #76048 - alistair23:alistair/rv32-linux, r=Amanieu
Initial support for riscv32gc_unknown_linux_gnu

Now that RISC-V 32-bit (RV32) support is in upstream glibc let's add support for userspace Rust.
2020-09-16 01:30:40 +02:00
Dylan DPC
fa4cfeb597
Rollup merge of #75304 - Aaron1011:feature/diag-deref-move-out, r=estebank
Note when a a move/borrow error is caused by a deref coercion

Fixes #73268

When a deref coercion occurs, we may end up with a move error if the
base value has been partially moved out of. However, we do not indicate
anywhere that a deref coercion is occuring, resulting in an error
message with a confusing span.

This PR adds an explicit note to move errors when a deref coercion is
involved. We mention the name of the type that the deref-coercion
resolved to, as well as the `Deref::Target` associated type being used.
2020-09-16 01:30:32 +02:00
Dylan DPC
fb9bb2b5ca
Rollup merge of #75146 - tmiasko:range-overflow, r=Mark-Simulacrum
Detect overflow in proc_macro_server subspan

* Detect overflow in proc_macro_server subspan
* Add tests for overflow in Vec::drain
* Add tests for overflow in String / VecDeque operations using ranges
2020-09-16 01:30:30 +02:00
Matthias Krüger
fd9be8f7aa don't lazily evaulate some trivial values for Option::None replacements (clippy::unnecessary_lazy_evaluations) 2020-09-15 23:17:51 +02:00
Matthias Krüger
73d4171ea6 fix a couple of stylistic clippy warnings
namely:

clippy::redundant_pattern_matching
clippy::redundant_pattern
clippy::search_is_some
clippy::filter_next
clippy::into_iter_on_ref
clippy::clone_on_copy
clippy::needless_return
2020-09-15 22:44:54 +02:00
SNCPlay42
4de9a53d98 improve diagnostics for lifetime after &mut 2020-09-15 10:36:06 -04:00
bors
90b1f5ae59 Auto merge of #76171 - estebank:turbofish-the-revenge, r=davidtwco
Detect turbofish with multiple type params missing leading `::`

Fix #76072.
2020-09-15 10:14:52 +00:00
Hameer Abbasi
5f0b775390
Remove redundant &format!.
Co-authored-by: Bastian Kauschke <bastian_kauschke@hotmail.de>
2020-09-15 11:11:18 +02:00
Hameer Abbasi
7d5db239e7 This commit introduces the following changes:
* Change error message for type param in a const expression when using
min_const_generics
* Change ParamInNonTrivialAnonConst to contain an extra bool used for
distinguishing whether the passed-in symbol is a type or a value.
2020-09-15 10:27:19 +02:00
Alistair Francis
82bd5a3e1d librustc_target: Address comments
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
2020-09-14 17:43:06 -07:00
Alistair Francis
a4183f0e61 librustc_target: Initial support for riscv32gc_unknown_linux_gnu
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
2020-09-14 17:40:29 -07:00
bors
255ceeb5ff Auto merge of #76612 - estebank:pat-missing-fields-suggestion, r=davidtwco
Provide suggestion for missing fields in patterns
2020-09-15 00:17:13 +00:00
bors
9b4154193e Auto merge of #76541 - matthiaskrgr:unstable_sort, r=davidtwco
use sort_unstable to sort primitive types

It's not important to retain original order if we have &[1, 1, 2, 3] for example.

clippy::stable_sort_primitive
2020-09-14 21:43:17 +00:00
iximeow
e1607c87f0 clean up comment text a bit
Co-authored-by: Esteban Küber <esteban@kuber.com.ar>
2020-09-14 13:13:02 -07:00
bors
41dc3942eb Auto merge of #75608 - estebank:suggest-boxed-match-exprs, r=lcnr,varkor
More structured suggestions for boxed trait objects instead of impl Trait on non-coerceable tail expressions

When encountering a `match` or `if` as a tail expression where the
different arms do not have the same type *and* the return type of that
`fn` is an `impl Trait`, check whether those arms can implement `Trait`
and if so, suggest using boxed trait objects.

Use structured suggestion for `impl T` to `Box<dyn T>`.

Fix https://github.com/rust-lang/rust/issues/69107
2020-09-14 19:57:57 +00:00
Esteban Küber
c6f2ddf1cb Fix rebase and add comments 2020-09-14 12:51:25 -07:00
Esteban Küber
62effcbd5b Detect turbofish with multiple type params missing leading ::
Fix #76072.
2020-09-14 12:06:51 -07:00
Camelid
5c1043a750 Fix diagram for DebruijnIndex 2020-09-14 10:45:56 -07:00
Camelid
15349ef5fa
Minor improvements to mir::Constant docs 2020-09-14 10:39:07 -07:00
Camelid
1f26a18955
Use intra-doc links for DelaySpanBugEmitted
Also improve the docs for it a bit.
2020-09-14 10:32:42 -07:00
Guillaume Gomez
d069c7e928 Stabilize doc_alias feature 2020-09-14 11:03:47 +02:00
Bastian Kauschke
035f879166 improve const infer err 2020-09-14 10:08:32 +02:00
Bastian Kauschke
dd57275c3e shrink const infer error 2020-09-14 09:45:22 +02:00
bors
b5f55b7e15 Auto merge of #76549 - ehuss:lints-comments, r=wesleywiser
Auto-generate lint documentation.

This adds a tool which will generate the lint documentation in the rustc book automatically. This is motivated by keeping the documentation up-to-date, and consistently formatted. It also ensures the examples are correct and that they actually generate the expected lint. The lint groups table is also auto-generated. See https://github.com/rust-lang/compiler-team/issues/349 for the original proposal.

An outline of how this works:
- The `declare_lint!` macro now accepts a doc comment where the documentation is written. This is inspired by how clippy works.
- A new tool `src/tools/lint-docs` scrapes the documentation and adds it to the rustc book during the build.
    - It runs each example and verifies its output and embeds the output in the book.
    - It does a few formatting checks.
    - It verifies that every lint is documented.
- Groups are collected from `rustc -W help`.

I updated the documentation for all the missing lints. I have also added an "Explanation" section to each lint providing a reason for the lint and suggestions on how to resolve it.

This can lead towards a future enhancement of possibly showing these docs via the `--explain` flag to make them easily accessible and discoverable.
2020-09-14 05:54:44 +00:00
iximeow
0eac38b7a6 fix syntax error in suggesting generic constraint in trait parameter
suggest `where T: Foo` for the first bound on a trait, then suggest
`, T: Foo` when the suggested bound would add to an existing set of
`where` clauses. `where T: Foo` may be the first bound if `T` has a
default, because we'd rather suggest
```
trait A<T=()> where T: Copy
```
than
```
trait A<T: Copy=()>
```
for legibility reasons.
2020-09-13 21:24:34 -07:00
bors
56d8a933b3 Auto merge of #76195 - lcnr:const-Self, r=varkor
allow concrete self types in consts

This is quite a bad hack to fix #75486. There might be a better way to check if the self type depends on generic parameters, but I wasn't able to come up with one.

r? `@varkor` cc `@petrochenkov`
2020-09-14 04:07:08 +00:00
bors
0b65a3d0a6 Auto merge of #76123 - tmiasko:inline-args-storage, r=wesleywiser
inliner: Emit storage markers for introduced arg temporaries

When introducing argument temporaries during inlining, emit storage
marker statements just before the assignment and in the beginning of
the return block.

This ensures that such temporaries will not be considered live across
yield points after inlining inside a generator.

Fixes #71793.
2020-09-14 02:13:02 +00:00
Wesley Wiser
c9686cb31a Introduce a PartitioningCx struct 2020-09-13 21:08:08 -04:00
bors
1eb00abf35 Auto merge of #76656 - jonas-schievink:fewer-unstable-metadata-queries, r=lcnr
Don't query stability data when `staged_api` is off

This data only needs to be encoded when `#![feature(staged_api)]` or `-Zforce-unstable-if-unmarked` is on. Running these queries takes measurable time on large crates with many items, so skip it when the unstable flags have not been enabled.
2020-09-14 00:26:43 +00:00
Bastian Kauschke
c552717e9d review, improve note span 2020-09-13 22:53:51 +02:00
Bastian Kauschke
e5b82a56c5 allow concrete self types in consts 2020-09-13 22:53:51 +02:00
Jonas Schievink
7b7f6f919d
Rollup merge of #76668 - pickfire:patch-9, r=jonas-schievink
Add visualization of rustc span in doc

It took me quite some time to figure out what Span::to means.
A picture is worth a thousand words.
2020-09-13 20:21:22 +02:00
Eric Huss
49a61f59df Make const_evaluatable_unchecked lint example not depend on the architecture pointer size. 2020-09-13 11:13:59 -07:00
bors
7402a39447 Auto merge of #76244 - vandenheuvel:remove__paramenv__def_id, r=nikomatsakis
Removing the `def_id` field from hot `ParamEnv` to make it smaller

This PR addresses https://github.com/rust-lang/rust/issues/74865.
2020-09-13 16:28:22 +00:00