Commit graph

127038 commits

Author SHA1 Message Date
Hirochika Matsumoto
a899ad2e12 Change suggestion to create_dir_all({}) from std::fs::create_dir_all({}) 2020-09-08 23:35:19 +09:00
Takayuki Nakata
1d8ae3aa12 Address items_after_statement 2020-09-08 23:12:04 +09:00
Takayuki Nakata
952c04674e Refactoring: tests in same_item_push 2020-09-08 23:03:15 +09:00
Takayuki Nakata
2c9f82e7d2 Add some tests to same_item_push
Add tests in which the variable is initialized with a match expression and function call
2020-09-08 22:45:27 +09:00
bors
7bc0bf7254 Auto merge of #76469 - RalfJung:miri, r=RalfJung
update Miri

Fixes https://github.com/rust-lang/rust/issues/76337
r? `@ghost` Cc `@rust-lang/miri`
2020-09-08 11:56:09 +00:00
Matthias Krüger
0065e33c24 rustbuild: don't set PYTHON_EXECUTABLE and WITH_POLLY cmake vars since they are no longer supported by llvm
CMake Warning:
  Manually-specified variables were not used by the project:

    PYTHON_EXECUTABLE
    WITH_POLLY
2020-09-08 11:32:25 +02:00
bors
5a6b426e34 Auto merge of #76308 - wesleywiser:enable_simplifyarmidentity_mir_opt, r=oli-obk
Enable the SimplifyArmIdentity MIR optimization at mir-opt-level=1

r? `@ghost`
2020-09-08 09:27:23 +00:00
ortem
c8262fd87b Add missed spaces to GCC-WARNING.txt 2020-09-08 12:20:49 +03:00
Ralf Jung
fb9702404e update Miri 2020-09-08 10:50:52 +02:00
Pietro Albini
f64ddc60a5
triagebot: enable github releases synchronization 2020-09-08 10:43:52 +02:00
bors
35fc835986 Auto merge of #76423 - Mark-Simulacrum:stable-bootstrap, r=jyn514
Make bootstrap build on beta

This is generally a good idea, and will help with being able to build bootstrap
without Python over time as it means we can "just" build with cargo +beta build
rather than needing the user to set environment variables. This is a minor step,
but a necessary one on that road.

r? `@jyn514`
2020-09-08 07:08:50 +00:00
bors
e82584a77d Auto merge of #75585 - RalfJung:demotion, r=oli-obk
Do not promote &mut of a non-ZST ever

Since ~pre-1.0~ 1.36, we have accepted code like this:
```rust
static mut TEST: &'static mut [i32] = {
    let x = &mut [1,2,3];
    x
};
```
I tracked it back to https://github.com/rust-lang/rust/pull/21744, but unfortunately could not find any discussion or RFC that would explain why we thought this was a good idea. And it's not, it breaks all sorts of things -- see https://github.com/rust-lang/rust/issues/75556.

To fix https://github.com/rust-lang/rust/issues/75556, we have to stop promoting non-ZST mutable references no matter the context, which is what this PR does. It's a breaking change.

Notice that this still works, since it does not rely on promotion:
```rust
static mut TEST: &'static mut [i32] = &mut [0,1,2];
```

Cc `@rust-lang/wg-const-eval`
2020-09-08 05:13:42 +00:00
bors
fa79db83f6 Auto merge of #76210 - Mark-Simulacrum:tracing-update, r=oli-obk
Tracing update

This does not bring the more significant changes that are coming down the pipeline, but since I've already prepared the PR leaving it up :)

See https://github.com/rust-lang/rust/pull/76210#issuecomment-685065938:
> Unfortunately, tracing 0.1.20 — which contained the change to reduce the amount of code generated by the tracing macros — had to be yanked, as it broke previously-compiling code for some downstream crates. I've not yet had the chance to fix this and release a new patch. So, in order to benefit from the changes to reduce generated code, you'll need to wait until there's a new version of tracing as well as tracing-attributes and tracing-core.
2020-09-08 03:22:31 +00:00
Joshua Nelson
0c9bf13f5f Add a script to automatically update Rust/Clang versions 2020-09-07 22:06:23 -04:00
Camelid
98a5506647 Add "For example," 2020-09-07 18:48:22 -07:00
Camelid
1f78509afe Improve wording of E0607 explanation 2020-09-07 18:41:55 -07:00
Ivan Tham
3a3a08585f
Unstable book rust-attrs does not work on generics
Co-authored-by: Peter Todd <pete@petertodd.org>
2020-09-08 09:08:25 +08:00
bors
71569e4201 Auto merge of #75138 - jumbatm:session-diagnostic-derive, r=oli-obk
Add derive macro for specifying diagnostics using attributes.

Introduces `#[derive(SessionDiagnostic)]`, a derive macro for specifying structs that can be converted to Diagnostics using directions given by attributes on the struct and its fields. Currently, the following attributes have been implemented:
- `#[code = "..."]` -- this sets the Diagnostic's error code, and must be provided on the struct iself (ie, not on a field). Equivalent to calling `code`.
- `#[message = "..."]` -- this sets the Diagnostic's primary error message.
- `#[label = "..."]` -- this must be applied to fields of type `Span`, and is equivalent to `span_label`
- `#[suggestion(..)]` -- this allows a suggestion message to be supplied. This attribute must be applied to a field of type `Span` or `(Span, Applicability)`, and is equivalent to calling `span_suggestion`. Valid arguments are:
    - `message = "..."` -- this sets the suggestion message.
    - (Optional) `code = "..."` -- this suggests code for the suggestion. Defaults to empty.

`suggestion`also  comes with other variants: `#[suggestion_short(..)]`, `#[suggestion_hidden(..)]` and `#[suggestion_verbose(..)]` which all take the same keys.

Within the strings passed to each attribute, fields can be referenced without needing to be passed explicitly into the format string -- eg, `#[error = "{ident} already declared"] ` will set the error message to `format!("{} already declared", &self.ident)`. Any fields on the struct can be referenced in this way.

Additionally, for any of these attributes, Option fields can be used to only optionally apply the decoration -- for example:

```rust
#[derive(SessionDiagnostic)]
#[code = "E0123"]
struct SomeKindOfError {
    ...
    #[suggestion(message = "informative error message")]
    opt_sugg: Option<(Span, Applicability)>
    ...
}
```
will not emit a suggestion if `opt_sugg` is `None`.

We plan on iterating on this macro further; this PR is a start.

Closes #61132.

r? `@oli-obk`
2020-09-08 00:58:43 +00:00
Joshua Nelson
ed4dcc04d8 Make rustdoc output deterministic for UI tests 2020-09-07 20:32:09 -04:00
Takayuki Nakata
5d085ad011 Some refactoring 2020-09-08 08:34:51 +09:00
Takayuki Nakata
619ca76731 Refactoring: use inner function 2020-09-08 08:25:31 +09:00
bors
3ffe9f843c Auto merge of #76044 - ecstatic-morse:dataflow-lattice, r=oli-obk
Support dataflow problems on arbitrary lattices

This PR implements last of the proposed extensions I mentioned in the design meeting for the original dataflow refactor. It extends the current dataflow framework to work with arbitrary lattices, not just `BitSet`s. This is a prerequisite for dataflow-enabled MIR const-propagation. Personally, I am skeptical of the usefulness of doing const-propagation pre-monomorphization, since many useful constants only become known after monomorphization (e.g. `size_of::<T>()`) and users have a natural tendency to hand-optimize the rest. It's probably worth exprimenting with, however, and others have shown interest cc `@rust-lang/wg-mir-opt.`

The `Idx` associated type is moved from `AnalysisDomain` to `GenKillAnalysis` and replaced with an associated `Domain` type that must implement `JoinSemiLattice`. Like before, each `Analysis` defines the "bottom value" for its domain, but can no longer override the dataflow join operator. Analyses that want to use set intersection must now use the `lattice::Dual` newtype. `GenKillAnalysis` impls have an additional requirement that `Self::Domain: BorrowMut<BitSet<Self::Idx>>`, which effectively means that they must use `BitSet<Self::Idx>` or `lattice::Dual<BitSet<Self::Idx>>` as their domain.

Most of these changes were mechanical. However, because a `Domain` is no longer always a powerset of some index type, we can no longer use an `IndexVec<BasicBlock, GenKillSet<A::Idx>>>` to store cached block transfer functions. Instead, we use a boxed `dyn Fn` trait object. I discuss a few alternatives to the current approach in a commit message.

The majority of new lines of code are to preserve existing Graphviz diagrams for those unlucky enough to have to debug dataflow analyses. I find these diagrams incredibly useful when things are going wrong and considered regressing them unacceptable, especially the pretty-printing of `MovePathIndex`s, which are used in many dataflow analyses. This required a parallel `fmt` trait used only for printing dataflow domains, as well as a refactoring of the `graphviz` module now that we cannot expect the domain to be a `BitSet`. Some features did have to be removed, such as the gen/kill display mode (which I didn't use but existed to mirror the output of the old dataflow framework) and line wrapping. Since I had to rewrite much of it anyway, I took the opportunity to switch to a `Visitor` for printing dataflow state diffs instead of using cursors, which are error prone for code that must be generic over both forward and backward analyses. As a side-effect of this change, we no longer have quadratic behavior when writing graphviz diagrams for backward dataflow analyses.

r? `@pnkfelix`
2020-09-07 21:29:43 +00:00
bors
0e2c1281e9 Auto merge of #76044 - ecstatic-morse:dataflow-lattice, r=oli-obk
Support dataflow problems on arbitrary lattices

This PR implements last of the proposed extensions I mentioned in the design meeting for the original dataflow refactor. It extends the current dataflow framework to work with arbitrary lattices, not just `BitSet`s. This is a prerequisite for dataflow-enabled MIR const-propagation. Personally, I am skeptical of the usefulness of doing const-propagation pre-monomorphization, since many useful constants only become known after monomorphization (e.g. `size_of::<T>()`) and users have a natural tendency to hand-optimize the rest. It's probably worth exprimenting with, however, and others have shown interest cc `@rust-lang/wg-mir-opt.`

The `Idx` associated type is moved from `AnalysisDomain` to `GenKillAnalysis` and replaced with an associated `Domain` type that must implement `JoinSemiLattice`. Like before, each `Analysis` defines the "bottom value" for its domain, but can no longer override the dataflow join operator. Analyses that want to use set intersection must now use the `lattice::Dual` newtype. `GenKillAnalysis` impls have an additional requirement that `Self::Domain: BorrowMut<BitSet<Self::Idx>>`, which effectively means that they must use `BitSet<Self::Idx>` or `lattice::Dual<BitSet<Self::Idx>>` as their domain.

Most of these changes were mechanical. However, because a `Domain` is no longer always a powerset of some index type, we can no longer use an `IndexVec<BasicBlock, GenKillSet<A::Idx>>>` to store cached block transfer functions. Instead, we use a boxed `dyn Fn` trait object. I discuss a few alternatives to the current approach in a commit message.

The majority of new lines of code are to preserve existing Graphviz diagrams for those unlucky enough to have to debug dataflow analyses. I find these diagrams incredibly useful when things are going wrong and considered regressing them unacceptable, especially the pretty-printing of `MovePathIndex`s, which are used in many dataflow analyses. This required a parallel `fmt` trait used only for printing dataflow domains, as well as a refactoring of the `graphviz` module now that we cannot expect the domain to be a `BitSet`. Some features did have to be removed, such as the gen/kill display mode (which I didn't use but existed to mirror the output of the old dataflow framework) and line wrapping. Since I had to rewrite much of it anyway, I took the opportunity to switch to a `Visitor` for printing dataflow state diffs instead of using cursors, which are error prone for code that must be generic over both forward and backward analyses. As a side-effect of this change, we no longer have quadratic behavior when writing graphviz diagrams for backward dataflow analyses.

r? `@pnkfelix`
2020-09-07 21:29:43 +00:00
Camelid
bf09a529ee rustdoc: Fix font CSS for crate lists
I had put it in the wrong file in #76126. This should fix it now. Thank
you to @ollie27 for pointing this out!
2020-09-07 13:57:33 -07:00
kadmin
ee55c1f1d2 Add regression test and help note 2020-09-07 20:12:02 +00:00
Mark Rousskov
aa4554f42d Dedicated rust development tarball
This currently includes libLLVM, llvm-config, and FileCheck, but will perhaps
expand to more tooling overtime. It should be considered entirely unstable and
may change at any time.
2020-09-07 16:10:29 -04:00
Takayuki Nakata
3d30ef7818 Restrict same_item_push to suppress false positives
It emits a lint when the pushed item is a literal, a constant and an immutable binding that are initialized with those.
2020-09-07 23:46:43 +09:00
Aaron Hill
f422ef141a
Add CONST_ITEM_MUTATION lint
Fixes #74053
Fixes #55721

This PR adds a new lint `CONST_ITEM_MUTATION`.
Given an item `const FOO: SomeType = ..`, this lint fires on:

* Attempting to write directly to a field (`FOO.field = some_val`) or
  array entry (`FOO.array_field[0] = val`)
* Taking a mutable reference to the `const` item (`&mut FOO`), including
  through an autoderef `FOO.some_mut_self_method()`

The lint message explains that since each use of a constant creates a
new temporary, the original `const` item will not be modified.
2020-09-07 08:44:35 -04:00
bors
9fe551ae49 Auto merge of #74366 - t-rapp:tr-bufreader-pos, r=LukasKalbertodt
Implement Seek::stream_position() for BufReader

Optimization over `BufReader::seek()` for getting the current position without flushing the internal buffer.

Related to #31100. Based on the code in #70577.
2020-09-07 11:09:41 +00:00
bors
f76eda3f01 Auto merge of #76395 - dylni:adjust-documentation-for-slice-check-range, r=jyn514
Adjust documentation for slice_check_range

Adjust documentation for #76393.
2020-09-07 09:16:46 +00:00
Tobias Rapp
246d3271fe Implement Seek::stream_position() for BufReader
Optimization over BufReader::seek() for getting the current position
without flushing the internal buffer.

Related to #31100. Based on code in #70577.
2020-09-07 09:26:48 +02:00
Ivan Tham
3740b0064d
Add align to rustc-attrs unstable book 2020-09-07 15:10:31 +08:00
bors
e114d6228b Auto merge of #76368 - ayushmishra2005:move_str_contact_library, r=jyn514
Added str tests in library

Added str tests in library  as a part of #76268

r? @matklad
2020-09-07 05:20:46 +00:00
bors
c133aac1e9 Auto merge of #76409 - jonas-schievink:fix-r-a-on-libcore, r=Mark-Simulacrum
Remove unneeded `#[cfg(not(test))]` from libcore

This fixes rust-analyzer inside these modules (currently it does not analyze them, assuming they're configured out).
2020-09-07 02:20:44 +00:00
Rich Kadel
9046a9343b Improved the MIR spanview output
* Adds missing "tail" spans (spans that continue beyond the end of
overlapping spans)
* Adds a caret to highlight empty spans associated with MIR elements
that have a position, but otherwise would not be visible.
* Adds visual pointing brackets at the beginning and end of each span
2020-09-06 19:04:08 -07:00
Mark Rousskov
2656d3414c Make bootstrap build on stable
This is generally a good idea, and will help with being able to build bootstrap
without Python over time as it means we can "just" build with cargo +beta build
rather than needing the user to set environment variables. This is a minor step,
but a necessary one on that road.
2020-09-06 21:26:09 -04:00
bors
838325726a Auto merge of #76422 - Dylan-DPC:rollup-0579ucb, r=Dylan-DPC
Rollup of 18 pull requests

Successful merges:

 - #76273 (Move some Vec UI tests into alloc unit tests)
 - #76274 (Allow try blocks as the argument to return expressions)
 - #76287 (Remove an unnecessary allowed lint)
 - #76293 (Implementation of incompatible features error)
 - #76299 (Make `Ipv4Addr` and `Ipv6Addr` const tests unit tests under `library`)
 - #76302 (Address review comments on `Peekable::next_if`)
 - #76303 (Link to `#capacity-and-reallocation` when using with_capacity)
 - #76305 (Move various ui const tests to `library`)
 - #76309 (Indent a note to make folding work nicer)
 - #76312 (time.rs: Make spelling of "Darwin" consistent)
 - #76318 (Use ops::ControlFlow in rustc_data_structures::graph::iterate)
 - #76324 (Move Vec slice UI tests in library)
 - #76338 (add some intra-doc links to `Iterator`)
 - #76340 (Remove unused duplicated `trivial_dropck_outlives`)
 - #76344 (Improve docs for `std::env::args()`)
 - #76346 (Docs: nlink example typo)
 - #76358 (Minor grammar fix in doc comment for soft-deprecated methods)
 - #76364 (Disable atomics on avr target.)

Failed merges:

 - #76304 (Make delegation methods of `std::net::IpAddr` unstably const)

r? @ghost
2020-09-07 00:33:47 +00:00
Dylan DPC
23f8dd19ff
Rollup merge of #76364 - fusion-engineering-forks:avr-no-atomic, r=jonas-schievink
Disable atomics on avr target.

`max_atomic_width` was missing in the spec, which means it fell back to the pointer width of 16 bits.

Fixes #76363.
2020-09-07 01:18:17 +02:00
Dylan DPC
5d8925905c
Rollup merge of #76358 - Wilfred:patch-3, r=lcnr
Minor grammar fix in doc comment for soft-deprecated methods
2020-09-07 01:18:15 +02:00
Dylan DPC
d444913840
Rollup merge of #76346 - gillespiecd:nlinks-docs, r=Dylan-DPC
Docs: nlink example typo

Small typo fix for the `nlink` function, extra whitespace before the `use` declaration
2020-09-07 01:18:13 +02:00
Dylan DPC
346d54d1f8
Rollup merge of #76344 - camelid:patch-6, r=KodrAus
Improve docs for `std::env::args()`

@rustbot modify labels: T-doc
2020-09-07 01:18:12 +02:00
Dylan DPC
1db9290a83
Rollup merge of #76340 - jonas-schievink:rm-dupe, r=Mark-Simulacrum
Remove unused duplicated `trivial_dropck_outlives`

The copy that is actually in use now lives here:

d2454643e1/compiler/rustc_trait_selection/src/traits/query/dropck_outlives.rs (L84)
2020-09-07 01:18:10 +02:00
Dylan DPC
9f69a232a6
Rollup merge of #76338 - euclio:intra-link-iterator, r=jyn514
add some intra-doc links to `Iterator`
2020-09-07 01:18:08 +02:00
Dylan DPC
1b24f1401d
Rollup merge of #76324 - ayushmishra2005:move_vec_tests_in_library, r=matklad
Move Vec slice UI tests in library

Moved some of Vec slice UI tests in Library as a part of #76268

r? @matklad
2020-09-07 01:18:07 +02:00
Dylan DPC
acd33e1d14
Rollup merge of #76318 - scottmcm:one-control-flow, r=ecstatic-morse
Use ops::ControlFlow in rustc_data_structures::graph::iterate

Since I only know about this because you mentioned it,
r? @ecstatic-morse

If we're not supposed to use new `core` things in compiler for a while then feel free to close, but it felt reasonable to merge the two types since they're the same, and it might be convenient for people to use `?` in their traversal code.

(This doesn't do the type parameter swap; NoraCodes has signed up to do that one.)
2020-09-07 01:18:05 +02:00
Dylan DPC
e735247289
Rollup merge of #76312 - numbermaniac:patch-1, r=shepmaster
time.rs: Make spelling of "Darwin" consistent

On line 89 of this file, the OS name is written as "Darwin", but on line 162 it is written in all-caps. Darwin is usually spelt as a standard proper noun, i.e. "Darwin", rather than in all-caps.

This change makes that form consistent in both places.
2020-09-07 01:18:03 +02:00
Dylan DPC
8ff13f4fd2
Rollup merge of #76309 - lzutao:indent-note, r=jyn514
Indent a note to make folding work nicer

Sublime Text folds code based on indentation. It maybe an unnecessary change, but does it look nicer after that ?
2020-09-07 01:18:01 +02:00
Dylan DPC
52d9162645
Rollup merge of #76305 - CDirkx:const-tests, r=matklad
Move various ui const tests to `library`

Move:
 - `src\test\ui\consts\const-nonzero.rs` to `library\core`
 - `src\test\ui\consts\ascii.rs` to `library\core`
 - `src\test\ui\consts\cow-is-borrowed` to `library\alloc`

Part of #76268

r? @matklad
2020-09-07 01:17:59 +02:00
Dylan DPC
5b8f76d564
Rollup merge of #76303 - jyn514:vec-assert-doc, r=Dylan-DPC
Link to `#capacity-and-reallocation` when using with_capacity

Follow up to https://github.com/rust-lang/rust/pull/76058#discussion_r479655750.
r? @pickfire
2020-09-07 01:17:56 +02:00
Dylan DPC
ee840db718
Rollup merge of #76302 - jyn514:peekable-2, r=Dylan-DPC
Address review comments on `Peekable::next_if`

r? @pickfire
See https://github.com/rust-lang/rust/pull/72310#pullrequestreview-480895893 for context.
2020-09-07 01:17:54 +02:00