Commit graph

127235 commits

Author SHA1 Message Date
Aaron Hill
fec0479075
Fully integrate token collection for additional AST structs
This commit contains miscellaneous changes that don't fit into any of
the other commits in this PR
2020-09-10 17:58:14 -04:00
Aaron Hill
156ef2bee8
Attach tokens to ast::Stmt
We currently only attach tokens when parsing a `:stmt` matcher for a
`macro_rules!` macro. Proc-macro attributes on statements are still
unstable, and need additional work.
2020-09-10 17:33:06 -04:00
Aaron Hill
c1011165e6
Attach TokenStream to ast::Visibility
A `Visibility` does not have outer attributes, so we only capture tokens
when parsing a `macro_rules!` matcher
2020-09-10 17:33:06 -04:00
Aaron Hill
55082ce413
Attach TokenStream to ast::Path 2020-09-10 17:33:06 -04:00
Aaron Hill
3815e91ccd
Attach tokens to NtMeta (ast::AttrItem)
An `AttrItem` does not have outer attributes, so we only capture tokens
when parsing a `macro_rules!` matcher
2020-09-10 17:33:06 -04:00
Aaron Hill
d5a04a9927
Collect tokens when handling :literal matcher
An `NtLiteral` just wraps an `Expr`, so we don't need to add a new `tokens`
field to an AST struct.
2020-09-10 17:33:06 -04:00
Aaron Hill
1823dea7df
Attach TokenStream to ast::Ty
A `Ty` does not have outer attributes, so we only capture tokens
when parsing a `macro_rules!` matcher
2020-09-10 17:33:05 -04:00
Aaron Hill
de4bd9f0f8
Attach TokenStream to ast::Block
A `Block` does not have outer attributes, so we only capture tokens when
parsing a `macro_rules!` matcher
2020-09-10 17:33:05 -04:00
bors
a1947b3f9e Auto merge of #76574 - flip1995:clippyup, r=Manishearth
Update Clippy

Biweekly Clippy update

r? `@Manishearth`
2020-09-10 21:25:55 +00:00
Aaron Hill
283d4c4d14
Ignore | and + tokens during proc-macro pretty-print check
Fixes #76182

This is an alternative to PR #76188

These tokens are not preserved in the AST in certain cases
(e.g. a leading `|` in a pattern or a trailing `+` in a trait bound).

This PR ignores them entirely during the pretty-print/reparse check
to avoid spuriously using the re-parsed tokenstream.
2020-09-10 16:20:05 -04:00
bors
ad3a6f70ac Auto merge of #76582 - tmandry:rollup-lwwc93b, r=tmandry
Rollup of 11 pull requests

Successful merges:

 - #75857 (Syntactically permit unsafety on mods)
 - #76289 (Add docs about crate level documentation support)
 - #76514 (Add revisions to const generic issue UI tests.)
 - #76524 (typeck: don't suggest inaccessible private fields)
 - #76548 (Validate removal of AscribeUserType, FakeRead, and Shallow borrow)
 - #76555 (Reword `trivial_casts` lint in rustc book to better explain what it does.)
 - #76559 (add the `const_evaluatable_checked` feature)
 - #76563 (small typo fix in rustc_parse docs)
 - #76565 (take reference to Place directly instead of taking reference to Box<Place>)
 - #76567 (use push(char) to add chars (single-char &strs) to strings instead of push_str(&str))
 - #76568 (Add missing examples on core traits' method)

Failed merges:

r? `@ghost`
2020-09-10 19:23:11 +00:00
Tyler Mandry
044f7179ba
Rollup merge of #76568 - GuillaumeGomez:add-missing-examples, r=jyn514
Add missing examples on core traits' method

Linked to #76450.

r? @jyn514
2020-09-10 12:20:15 -07:00
Tyler Mandry
c8f9c728c2
Rollup merge of #76567 - matthiaskrgr:clone_on_copy, r=varkor
use push(char) to add chars (single-char &strs) to strings instead of push_str(&str)
2020-09-10 12:20:12 -07:00
Tyler Mandry
94ae5d1866
Rollup merge of #76565 - matthiaskrgr:box_place, r=oli-obk
take reference to Place directly instead of taking reference to Box<Place>

clippy::borrowed_box
2020-09-10 12:20:11 -07:00
Tyler Mandry
ae46b9e483
Rollup merge of #76563 - yokodake:patch-1, r=jonas-schievink
small typo fix in rustc_parse docs

small typo in rustc_parse::new_parser_from_file's documentation

I'm not sure a PR is the way to do this though.
2020-09-10 12:20:09 -07:00
Tyler Mandry
ac85a4d71e
Rollup merge of #76559 - lcnr:const-evaluatable, r=oli-obk
add the `const_evaluatable_checked` feature

Implements a rather small subset of https://github.com/rust-lang/compiler-team/issues/340

Unlike the MCP, this does not try to compare different constant, but instead only adds the constants found in where clauses
to the predicates of a function. This PR adds the feature gate `const_evaluatable_checked`, without which nothing should change.

r? @oli-obk @eddyb
2020-09-10 12:20:07 -07:00
Tyler Mandry
f9df658aad
Rollup merge of #76555 - alilleybrinker:reword_trivial_casts_lint_doc, r=steveklabnik
Reword `trivial_casts` lint in rustc book to better explain what it does.

The current description of the trivial casts lint under the "allowed
by default" listing in the rustc book indicates the lint is for casts
which may be removed, which is less clear than saying it's for casts
which may be replaced by coercion (which is the wording used by the
error message included in the doc).

This commit changes the wording slightly to better describe what the
lint does.

This issue bit me in some recent code where I was attempting to
convert a `Vec<SomeType>` to a `Vec<SomeTraitObject>`, and
hit my project-wide `#![deny(trivial_casts)]` with
`map(|o| Box::new(o) as TraitObject)`. I'd read the book docs for
`trivial_casts` and was surprised by the error, as I took it to mean
the cast ought to be removed (rather than replaced by ascription
in this case). Removing the cast meant other code didn't compile,
and I then found issues like #23742 and realized my misunderstanding.
2020-09-10 12:20:06 -07:00
Tyler Mandry
2df1487fc9
Rollup merge of #76548 - tmiasko:validate, r=davidtwco
Validate removal of AscribeUserType, FakeRead, and Shallow borrow

Those statements are removed by CleanupNonCodegenStatements pass
in drop lowering phase, and should not occur afterwards.
2020-09-10 12:20:04 -07:00
Tyler Mandry
9f8a7827a1
Rollup merge of #76524 - davidtwco:issue-76077-inaccessible-private-fields, r=estebank
typeck: don't suggest inaccessible private fields

Fixes #76077.

This PR adjusts the missing field diagnostic logic in typeck so that when none of the missing fields in a struct expr are accessible then the error is less confusing.

r? @estebank
2020-09-10 12:20:02 -07:00
Tyler Mandry
7565ccc32c
Rollup merge of #76514 - hameerabbasi:const-generics-revs, r=lcnr
Add revisions to const generic issue UI tests.

Fixes #75279.

I have gotten into the flow, so I can do more of these if requested. I'm looking for feedback as to whether my work is on the right track so far.
2020-09-10 12:20:01 -07:00
Tyler Mandry
91c3ef8bef
Rollup merge of #76289 - arijit79:master, r=jyn514
Add docs about crate level documentation support

Wrote information about how to write documentation on the crate level in rhe rustdoc book
2020-09-10 12:19:59 -07:00
Tyler Mandry
5aed4957ff
Rollup merge of #75857 - dtolnay:unsafe, r=nagisa
Syntactically permit unsafety on mods

Similar to https://github.com/rust-lang/rust/pull/66183; we will accept these constructs syntactically but reject with a semantic check after macro expansion if a proc macro hasn't replaced it with something else meaningful to Rust.

```rust
#[mymacro]
unsafe mod m {
    ...
}

#[mymacro]
unsafe extern "C++" {
    ...
}
```

The intention is that this might be used as a kind of "item-level unsafe" in attribute macro DSLs -- holding things which are unsafe to declare but potentially safe to use. For example I look forward to using this in https://github.com/dtolnay/cxx.

In the absence of a procedural macro rewriting them to something else, they'll continue to be rejected at compile time though with a better error message than before.

### Before:

```console
error: expected item, found keyword `unsafe`
 --> src/main.rs:1:1
  |
1 | unsafe mod m {
  | ^^^^^^ expected item
```

### After:

```console
error: module cannot be declared unsafe
 --> src/main.rs:1:1
  |
1 | unsafe mod m {
  | ^^^^^^

error: extern block cannot be declared unsafe
 --> src/main.rs:4:1
  |
4 | unsafe extern "C++" {
  | ^^^^^^
```

Closes #68048.
2020-09-10 12:19:57 -07:00
David Wood
409c141973
typeck/pat: inaccessible private fields
This commit adjusts the missing field diagnostic logic for struct
patterns in typeck to improve the diagnostic when the missing fields are
inaccessible.

Signed-off-by: David Wood <david@davidtw.co>
2020-09-10 18:52:00 +01:00
David Wood
c0894e7232
typeck/expr: inaccessible private fields
This commit adjusts the missing field diagnostic logic for struct
expressions in typeck to improve the diagnostic when the missing
fields are inaccessible.

Signed-off-by: David Wood <david@davidtw.co>
2020-09-10 18:51:56 +01:00
bors
8c35a9279c Auto merge of #76564 - pietroalbini:ci-avoid-wasting-10-minutes, r=Mark-Simulacrum
ci: avoid moving the build directory on GHA

While waiting for a PR job to start testing my code, I noticed the symlink-build-dir step took 10 minutes to complete, so I investigated what caused that.

It seems like something changed in the build environment between version 20200901.1 (where the step took 45 seconds) and version 20200908.1 (where the step took 10 minutes). At the time of writing this commit, the rust-lang organization is on vertsion 20200908.1, while the rust-lang-ci organization is at version 20200901.1 (and is not affected by this yet).

There is no need for this step anymore on GHA, as our XL builders got an increase in the root paritition size, so this commit removes the code that moved stuff around on GHA (while keeping it on Azure).

For the record, at the time of writing this, the disk situation is:

```
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       667G   60G  607G   9% /
/dev/sdb1       110G  4.1G  101G   4% /mnt
```

r? `@Mark-Simulacrum`
2020-09-10 16:42:00 +00:00
Mark Rousskov
4f2d94180d Only copy LLVM into rust-dev with internal LLVM
This avoids needing to figure out where to locate each of the components with an
external LLVM.
2020-09-10 12:04:15 -04:00
flip1995
ca6c695320
Merge commit '5034d47f721ff4c3a3ff2aca9ef2ef3e1d067f9f' into clippyup 2020-09-10 17:47:07 +02:00
bors
5034d47f72 Auto merge of #5980 - matsujika:create-dir, r=flip1995
Add a lint to prevent `create_dir` from being used

This closes #5950
changelog: none
2020-09-10 14:34:22 +00:00
arijit79
fd5859a673 Add docs about crate level documentation support 2020-09-10 10:29:24 -04:00
Thomas de Zeeuw
7c3e1ffd7a Update libc in Cargo.lock 2020-09-10 16:27:28 +02:00
Thomas de Zeeuw
f7b6ace029 Use IOV_MAX and UIO_MAXIOV constants in limit vectored I/O
Also updates the libc dependency to 0.2.77 (from 0.2.74) as the
constants were only recently added.
2020-09-10 16:27:28 +02:00
bors
55efa96659 Auto merge of #5931 - montrivo:unit-arg, r=flip1995
improve the suggestion of the lint `unit-arg`

Fixes #5823
Fixes #6015

Changes
```
help: move the expression in front of the call...
  |
3 |     g();
  |
help: ...and use a unit literal instead
  |
3 |     o.map_or((), |i| f(i))
  |
```
into
```
help: move the expression in front of the call and replace it with the unit literal `()`
  |
3 |     g();
  |     o.map_or((), |i| f(i))
  |
```
changelog: improve the suggestion of the lint `unit-arg`
2020-09-10 14:11:27 +00:00
David Tolnay
fd4dd00dde
Syntactically permit unsafety on mods 2020-09-10 06:56:33 -07:00
bors
0e9769e787 Auto merge of #6023 - matthiaskrgr:box, r=flip1995
link to the Box docs in related lint documentation.

changelog: link to the box docs in lint docs
2020-09-10 13:49:50 +00:00
bors
87a4495b5d Auto merge of #6027 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2020-09-10 13:25:39 +00:00
flip1995
2d56512580
Cleanup of rustup 2020-09-10 15:23:38 +02:00
Guillaume Gomez
d7a9707051 Add missing examples on core traits' method 2020-09-10 14:34:43 +02:00
Matthias Krüger
9bb10cc907 use push(char) instead of push_str(&str) to add single chars to strings
clippy::single-char-push-str
2020-09-10 13:58:41 +02:00
Matthias Krüger
e11c667e4a don't clone types that are copy (clippy::clone_on_copy) 2020-09-10 13:26:36 +02:00
Matthias Krüger
e2a511fe20 use String::from instead of format!() macro to craft string clippy::useless_format 2020-09-10 13:22:51 +02:00
Matthias Krüger
6bfe132067 take reference to Place directly instead of taking reference to Box<Place>
clippy::borrowed_box
2020-09-10 13:08:28 +02:00
Pietro Albini
a5cdc06db8
ci: avoid moving the build directory on GHA
While waiting for a PR job to start testing my code, I noticed the
symlink-build-dir step took 10 minutes to complete, so I investigated
what caused that.

It seems like something changed in the build environment between version
20200901.1 (where the step took 45 seconds) and version 20200908.1
(where the step took 10 minutes). At the time of writing this commit,
the rust-lang organization is on vertsion 20200908.1, while the
rust-lang-ci organization is at version 20200901.1 (and is not affected
by this yet).

There is no need for this step anymore on GHA, as our XL builders got an
increase in the root paritition size, so this commit removes the code
that moved stuff around on GHA (while keeping it on Azure).

For the record, at the time of writing this, the disk situation is:

Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       667G   60G  607G   9% /
/dev/sdb1       110G  4.1G  101G   4% /mnt
2020-09-10 12:54:29 +02:00
bors
25b2f48612 Auto merge of #76378 - petrochenkov:lldtest, r=Mark-Simulacrum
rustbuild: Build tests with LLD if `use-lld = true` was passed

Addresses https://github.com/rust-lang/rust/pull/76127#discussion_r479932392.

Our test suite is generally ready to run with an explicitly specified linker (https://github.com/rust-lang/rust/pull/45191),
 so LLD specified with `use-lld = true` works as well.

Only 4 tests fail (on `x86_64-pc-windows-msvc`):
```
ui/panic-runtime/lto-unwind.rs
run-make-fulldeps/debug-assertions
run-make-fulldeps/foreign-exceptions
run-make-fulldeps/test-harness
```
All of them are legitimate issues with LLD (or at least with combination Rust+LLD) and manifest in segfaults on access to TLS (https://github.com/rust-lang/rust/pull/76127#issuecomment-683473325). UPD: These issues are caused by https://github.com/rust-lang/rust/issues/72145 and appear because I had `-Ctarget-cpu=native` set.

UPD: Further commits build tests with LLD for non-MSVC targets and propagate LLD to more places when `use-lld` is enabled.
2020-09-10 10:06:44 +00:00
Nanami
8b059980d7
small typo fix in rustc_parse docs 2020-09-10 11:56:11 +02:00
bors
a18b34d979 Auto merge of #76291 - matklad:spacing, r=petrochenkov
Rename IsJoint -> Spacing

Builds on #76286 and might conflict with #76285

r? `@petrochenkov`
2020-09-10 08:07:48 +00:00
bors
e0f46a19bc Auto merge of #6024 - matthiaskrgr:unit_type, r=phansch
print the unit type `()` in related lint messages.

changelog: print the unit type `()` in related lint messages
2020-09-10 07:49:07 +00:00
Bastian Kauschke
300b0acb85 fix tidy, small cleanup 2020-09-10 09:48:02 +02:00
Hameer Abbasi
bec8e5fc14 Add revisions to const generic UI tests. 2020-09-10 09:40:54 +02:00
Hameer Abbasi
36903d79c8 Add revisions to const generic default UI tests. 2020-09-10 09:18:40 +02:00
Hameer Abbasi
2815db1844 Respond to review comments. 2020-09-10 09:04:14 +02:00