Commit Graph

122829 Commits

Author SHA1 Message Date
Dylan DPC
c4e15b5c5a
Rollup merge of #73667 - nrabulinski:master, r=Dylan-DPC
Update BTreeMap::new() doc

Updates the documentation according to [this comment](0c5c644c91 (r433232581)) on #72876
2020-06-24 14:28:45 +02:00
Dylan DPC
2a6e660ae1
Rollup merge of #73652 - da-x:add-reexported-to-use-suggestions, r=petrochenkov
Add re-exports to use suggestions

In the following example, an inaccessible path is suggested via `use foo::bar::X;` whereas an accessible public exported path can be suggested instead.

```rust
mod foo {
    mod bar {
        pub struct X;
    }
    pub use self::bar::X;
}

fn main() { X; }
```

This fixes the issue.
2020-06-24 14:28:43 +02:00
Dylan DPC
45de677b1e
Rollup merge of #73646 - JohnTitor:add-tests, r=Dylan-DPC
Add some regression tests

Closes #44861
Closes #51506
Closes #59435
Closes #69840
2020-06-24 14:28:41 +02:00
Dylan DPC
1d1c400324
Rollup merge of #73639 - ayazhafiz:i/73553, r=davidtwco
Change heuristic for determining range literal

Currently, rustc uses a heuristic to determine if a range expression is
not a literal based on whether the expression looks like a function call
or struct initialization. This fails for range literals whose
lower/upper bounds are the results of function calls. A possibly-better
heuristic is to check if the expression contains `..`, required in range
literals.

Of course, this is also not perfect; for example, if the range
expression is a struct which includes some text with `..` this will
fail, but in general I believe it is a better heuristic.

A better alternative altogether is to add the `QPath::LangItem` enum
variant suggested in #60607. I would be happy to do this as a precursor
to this patch if someone is able to provide general suggestions on how
usages of `QPath` need to be changed later in the compiler with the
`LangItem` variant.

Closes #73553
2020-06-24 14:28:39 +02:00
Dylan DPC
38c85b7393
Rollup merge of #73638 - yuqio:remove-unused-crate-imports, r=nikomatsakis
Remove unused crate imports in 2018 edition crates

Closes #73570
2020-06-24 14:28:33 +02:00
bors
0b66a89735 Auto merge of #73679 - ehuss:update-cargo, r=ehuss
Update cargo

9 commits in 089cbb80b73ba242efdcf5430e89f63fa3b5328d..c26576f9adddd254b3dd63aecba176434290a9f6
2020-06-15 14:38:34 +0000 to 2020-06-23 16:21:21 +0000
- Adding environment variable CARGO_PKG_LICENSE_FILE (rust-lang/cargo#8387)
- Enable "--target-dir" in "cargo install" (rust-lang/cargo#8391)
- Add support for `workspace.metadata` table (rust-lang/cargo#8323)
- Fix overzealous `clean -p` for reserved names. (rust-lang/cargo#8398)
- Fix order-dependent feature resolution. (rust-lang/cargo#8395)
- Correct mispelling of `cargo`. (rust-lang/cargo#8389)
- Add missing license field. (rust-lang/cargo#8386)
- Adding environment variable CARGO_PKG_LICENSE (rust-lang/cargo#8325)
- Cut down on data fetch from git dependencies (rust-lang/cargo#8363)
2020-06-24 12:08:53 +00:00
Alexis Bourget
03661630c9 Document the self keyword 2020-06-24 13:52:57 +02:00
Guillaume Gomez
65becefd4a Clean up E0701 explanation 2020-06-24 13:19:06 +02:00
David Wood
4504648090
improper_ctypes: only allow params in defns mode
This commit adjusts the behaviour introduced in a previous commit so
that generic parameters and projections are only allowed in the
definitions mode - and are otherwise a bug. Generic parameters in
declarations are prohibited earlier in the compiler, so if that branch
were reached, it would be a bug.

Signed-off-by: David Wood <david@davidtw.co>
2020-06-24 12:09:39 +01:00
David Wood
5c8634805c
improper_ctypes: allow pointers to sized types
This commit changes the improper ctypes lint (when operating on
definitions) to consider raw pointers or references to sized types as
FFI-safe.

Signed-off-by: David Wood <david@davidtw.co>
2020-06-24 12:09:37 +01:00
David Wood
14ea7a777f
lints: add improper_ctypes_definitions
This commit adds a new lint - `improper_ctypes_definitions` - which
functions identically to `improper_ctypes`, but on `extern "C" fn`
definitions (as opposed to `improper_ctypes`'s `extern "C" {}`
declarations).

Signed-off-by: David Wood <david@davidtw.co>
2020-06-24 12:09:35 +01:00
Adrian Cruceru
f3b1582bb9 Update libunwind build process for x86_64-fortanix-unknown-sgx target 2020-06-24 11:28:41 +02:00
Alexis Bourget
d8ea10c95f Document the return keyword
Apply suggestions from code review

Co-authored-by: Josh Triplett <josh@joshtriplett.org>
2020-06-24 09:23:55 +02:00
Ralf Jung
35911eeb93 reduce sanity check in debug mode 2020-06-24 09:03:01 +02:00
Anirban
3b5d7f8cf6
Minor correction to sentence structure 2020-06-24 10:29:35 +05:30
Jack Huey
ecb8b9f9f7 Update Chalk 2020-06-24 00:48:33 -04:00
Eric Huss
7b9b580614 Update cargo 2020-06-23 19:59:10 -07:00
Tshepang Lekhonkhobe
b23baa78dc fix
See b65ea1bef1 (r444376289)
2020-06-24 04:47:20 +02:00
Keno Fischer
0c88dd663a
Update Box::from_raw example to generalize better
I know very little about rust, so I saw this example and tried to generalize it by writing,
```
    let layout = Layout:🆕:<T>();
    let new_obj = unsafe {
        let ptr = alloc(layout) as *mut T;
        *ptr = obj;
        Box::from_raw(ptr)
    };
```
for some more complicated `T`, which ended up crashing with SIGSEGV,
because it tried to `drop_in_place` the previous object in `ptr` which is
of course garbage. I also added a comment that explains why `.write`
is used, but I think adding that comment is optional and may be too verbose
here. I do however think that changing this example is a good idea to
suggest the correct generalization. `.write` is also used in most of the rest
of the documentation here, even if the example is `i32`, so it would additionally
be more consistent.
2020-06-23 22:42:35 -04:00
bors
3c90ae8404 Auto merge of #73293 - Aaron1011:feature/macro-rules-arg-capture, r=petrochenkov
Always capture tokens for `macro_rules!` arguments

When we invoke a proc-macro, the `TokenStream` we pass to it may contain 'interpolated' AST fragments, represented by `rustc_ast::token::Nonterminal`. In order to correctly, pass a `Nonterminal` to a proc-macro, we need to have 'captured' its `TokenStream` at the time the AST was parsed.

Currently, we perform this capturing when attributes are present on items and expressions, since we will end up using a `Nonterminal` to pass the item/expr to any proc-macro attributes it is annotated with. However, `Nonterminal`s are also introduced by the expansion of metavariables in `macro_rules!` macros. Since these metavariables may be passed to proc-macros, we need to have tokens available to avoid the need to pretty-print and reparse (see https://github.com/rust-lang/rust/issues/43081).

This PR unconditionally performs token capturing for AST items and expressions that are passed to a `macro_rules!` invocation. We cannot know in advance if captured item/expr will be passed to proc-macro, so this is needed to ensure that tokens will always be available when they are needed.

This ensures that proc-macros will receive tokens with proper `Spans` (both location and hygiene) in more cases. Like all work on https://github.com/rust-lang/rust/issues/43081, this will cause regressions in proc-macros that were relying on receiving tokens with dummy spans.

In this case, Crater revealed only one regression: the [Pear](https://github.com/SergioBenitez/Pear) crate (a helper for [rocket](https://github.com/SergioBenitez/Rocket)), which was previously [fixed](https://github.com/SergioBenitez/Pear/pull/25) as part of https://github.com/rust-lang/rust/pull/73084.

This regression manifests itself as the following error:

```
[INFO] [stdout] error: proc macro panicked
[INFO] [stdout]    --> /opt/rustwide/cargo-home/registry/src/github.com-1ecc6299db9ec823/rocket_http-0.4.5/src/parse/uri/parser.rs:119:34
[INFO] [stdout]     |
[INFO] [stdout] 119 |             let path_and_query = pear_try!(path_and_query(is_pchar));
[INFO] [stdout]     |                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[INFO] [stdout]     |
[INFO] [stdout]     = help: message: called `Option::unwrap()` on a `None` value
[INFO] [stdout]     = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
```

It can be fixed by running `cargo update -p pear`, which updates your `Cargo.lock` to use the latest version of Pear (which includes a bugfix for the regression).

Split out from https://github.com/rust-lang/rust/pull/73084/
2020-06-24 01:24:38 +00:00
Eric Huss
e02dafcaaa Update books 2020-06-23 17:56:33 -07:00
Esteban Küber
5aab1a9a88 Tweak binop errors
* Suggest potentially missing binop trait bound (fix #73416)
* Use structured suggestion for dereference in binop
2020-06-23 17:32:06 -07:00
Eric Huss
9bb414faff Fix ptr doc warnings. 2020-06-23 16:25:01 -07:00
bors
0c04344d86 Auto merge of #73669 - Manishearth:rollup-0n4u7vq, r=Manishearth
Rollup of 11 pull requests

Successful merges:

 - #72780 (Enforce doc alias check)
 - #72876 (Mention that BTreeMap::new() doesn't allocate)
 - #73244 (Check for assignments between non-conflicting generator saved locals)
 - #73488 (code coverage foundation for hash and num_counters)
 - #73523 (Fix -Z unpretty=everybody_loops)
 - #73587 (Move remaining `NodeId` APIs from `Definitions` to `Resolver`)
 - #73601 (Point at the call span when overflow occurs during monomorphization)
 - #73613 (The const propagator cannot trace references.)
 - #73614 (fix `intrinsics::needs_drop` docs)
 - #73630 (Provide context on E0308 involving fn items)
 - #73665 (rustc: Modernize wasm checks for atomics)

Failed merges:

r? @ghost
2020-06-23 21:33:22 +00:00
Manish Goregaokar
6ed6a844e1
Rollup merge of #73665 - alexcrichton:update-wasm-atomics-feature, r=davidtwco
rustc: Modernize wasm checks for atomics

This commit modernizes how rustc checks for whether the `atomics`
feature is enabled for the wasm target. The `sess.target_features` set
is consulted instead of fiddling around with dealing with various
aspects of LLVM and that syntax.
2020-06-23 13:10:19 -07:00
Manish Goregaokar
4f2e540520
Rollup merge of #73630 - estebank:fn-item-e0308, r=davidtwco
Provide context on E0308 involving fn items

Fix #73487.
2020-06-23 13:10:17 -07:00
Manish Goregaokar
f7d5687eba
Rollup merge of #73614 - lcnr:patch-4, r=Dylan-DPC
fix `intrinsics::needs_drop` docs
2020-06-23 13:10:15 -07:00
Manish Goregaokar
d8b4604f41
Rollup merge of #73613 - oli-obk:const_prop_miscompile, r=wesleywiser
The const propagator cannot trace references.

Thus we avoid propagation of a local the moment we encounter references to it.

fixes #73609

cc @RalfJung

r? @wesleywiser
2020-06-23 13:10:13 -07:00
Manish Goregaokar
30fba22a9b
Rollup merge of #73601 - Aaron1011:fix/better-mono-overflow-err, r=ecstatic-morse
Point at the call span when overflow occurs during monomorphization

This improves the output for issue #72577, but there's still more work
to be done.

Currently, an overflow error during monomorphization results in an error
that points at the function we were unable to monomorphize. However, we
don't point at the call that caused the monomorphization to happen. In
the overflow occurs in a large recursive function, it may be difficult
to determine where the issue is.

This commit tracks and `Span` information during collection of
`MonoItem`s, which is used when emitting an overflow error. `MonoItem`
itself is unchanged, so this only affects
`src/librustc_mir/monomorphize/collector.rs`
2020-06-23 13:10:11 -07:00
Manish Goregaokar
045761c8d0
Rollup merge of #73587 - marmeladema:hir-id-ification-final, r=petrochenkov
Move remaining `NodeId` APIs from `Definitions` to `Resolver`

Implements https://github.com/rust-lang/rust/pull/73291#issuecomment-643515557

TL;DR: it moves all fields that are only needed during name resolution passes into the `Resolver` and keep the rest in `Definitions`. This effectively enforces that all references to `NodeId`s are gone once HIR lowering is completed.

After this, the only remaining work for #50928 should be to adjust the dev guide.

r? @petrochenkov
2020-06-23 13:10:09 -07:00
Manish Goregaokar
505cf52c53
Rollup merge of #73523 - jyn514:everybody_loops, r=ecstatic-morse
Fix -Z unpretty=everybody_loops

It turns out that this has not been working for who knows how long.
Previously:

```
pub fn h() { 1 + 2; }
```

After this change:

```
pub fn h() { loop { } }
```

This only affected the pass when run with the command line
pretty-printing option, so rustdoc was still replacing bodies with
`loop {}`.
2020-06-23 13:10:07 -07:00
Manish Goregaokar
f5e46fe46c
Rollup merge of #73488 - richkadel:llvm-coverage-map-gen, r=tmandry
code coverage foundation for hash and num_counters

This PR is the next iteration after PR #73011 (which is still waiting on bors to merge).

@wesleywiser - PTAL
r? @tmandry

(FYI, I'm also working on injecting the coverage maps, in another branch, while waiting for these to merge.)

Thanks!
2020-06-23 13:10:05 -07:00
Manish Goregaokar
781b589997
Rollup merge of #73244 - ecstatic-morse:validate-generator-mir, r=tmandry
Check for assignments between non-conflicting generator saved locals

This is to prevent future changes to the generator transform from reintroducing the problem that caused #73137. Namely, a store between two generator saved locals whose storage does not conflict.

My ultimate goal is to introduce a modified version of #71956 that handles this case properly.

r? @tmandry
2020-06-23 13:10:03 -07:00
Manish Goregaokar
317a15142e
Rollup merge of #72876 - TrolledWoods:patch-2, r=Dylan-DPC
Mention that BTreeMap::new() doesn't allocate

I think it would be nice to mention this, so you don't have to dig through the src to look at the definition of new().
2020-06-23 13:10:01 -07:00
Manish Goregaokar
7d2fba1bd2
Rollup merge of #72780 - GuillaumeGomez:enforce-doc-alias-check, r=ollie27
Enforce doc alias check

Part of #50146.

r? @ollie27
2020-06-23 13:09:59 -07:00
Esteban Küber
6e8aa1ff27 review comments: wording and style 2020-06-23 13:01:24 -07:00
Dan Aloni
037e930df7 Review fixes 2020-06-23 22:30:09 +03:00
Nikodem Rabuliński
f37c157f2c
Update map.rs 2020-06-23 20:06:44 +02:00
bors
ff5b446d2f Auto merge of #73644 - ollie27:rustdoc_alias_filter, r=GuillaumeGomez
rustdoc: Fix doc aliases with crate filtering

Fix a crash when searching for an alias contained in the currently selected filter crate.

Also remove alias search results for crates that should be filtered out.

The test suite needed to be fixed to actually take into account the crate filtering and check that there are no results when none are expected.

Needs to be backported to beta to fix the `std` docs.

Fixes #73620

r? @GuillaumeGomez
2020-06-23 17:30:54 +00:00
Alex Crichton
0c2b02536c rustc: Modernize wasm checks for atomics
This commit modernizes how rustc checks for whether the `atomics`
feature is enabled for the wasm target. The `sess.target_features` set
is consulted instead of fiddling around with dealing with various
aspects of LLVM and that syntax.
2020-06-23 09:41:56 -07:00
Ayaz Hafiz
86f6c0e086
Record span of const kw in GenericParamKind
Context: this is needed to fix https://github.com/rust-lang/rustfmt/issues/4263,
which currently records the span of a const generic param incorrectly
because the location of the `const` kw is not known.

I am not sure how to add tests for this; any guidance in how to do so
would be appreciated 🙂
2020-06-23 09:25:46 -07:00
flip1995
a2c0499b39
Merge commit 'c2c07fa9d095931eb5684a42942a7b573a0c5238' into clippyup 2020-06-23 17:05:22 +02:00
bors
c2c07fa9d0 Auto merge of #5740 - lzutao:unused-unused, r=flip1995
Remove unused allowed unused attributes

changelog: none
2020-06-23 14:34:18 +00:00
Dylan McKay
50f20ec576 [AVR] Update the rust-lang/llvm-project submodule to include AVR fixes recently merged
This commit updates rustc's LLVM submodule to include new AVR-specific
fixes recently merged on the Rust LLVM 'rustc/10.0-2020-05-05' branch.

All of these cherry-picked commits exist in upstream LLVM and were
cherry-picked into Rust's LLVM fork in commit 6c040dd86ed.

  |- 6c040dd86ed Merge pull request #66 from dylanmckay/avr-pick-upstream-llvm-fixes
    |- 12dfdd3aed7 [AVR] Rewrite the function calling convention.
    |- 118ac53f12b [AVR] Don't adjust for instruction size
    |- bc27c282e13 [AVR] Fix miscompilation of zext + add
    |- cfbe205a7e8 [AVR] Remove faulty stack pushing behavior
    |- 143e1469e96 [AVR] Fix stack size in functions with a frame pointer
    |- 6b2445d841e [LLVM][AVR] Support for R_AVR_6 fixup
    |- 93ee4da19cf [AVR]  Fix I/O instructions on XMEGA
    |- 962c2415ffb [AVR] Do not place functions in .progmem.data
    |- 65b8b170aef [AVR] Do not use divmod calls for bigger integers
    |- 93a3b595d1c [AVR] Generalize the previous interrupt bugfix to signal
    |- handlers too
    |- cc4286349b4 [AVR] Respect the 'interrupt' function attribute
    |- 954d0a92205 [AVR] Fix reads of uninitialized variables from constructor of AVRSubtarget
    |- 1c0ddae73c9 [AVR] Fix read of uninitialized variable AVRSubtarget:::ELFArch
    |- 0ed0823fe60 [AVR] Fix incorrect register state for LDRdPtr
    |- 96075fc433d [AVR] Don't adjust addresses by 2 for absolute values
    |- 6dfc55ba53b [AVR] Use correct register class for mul instructions

These changes include both correctness fixes and LLVM assertion error
fixes. Once all of these commits have been cherry-picked, all of the
LLVM plumbing for rust-lang/master to compile the AVR blink program will
be in place. Once this commit is merged, only PR rust-lang/rust#73270 will
be blocking successful compilation and emission of the AVR LED blink program.
2020-06-24 02:16:30 +12:00
bors
c420382ac2 Auto merge of #5738 - mikerite:loops-20200623-2, r=matthiaskrgr
Improve end of expression check in for loop lints

changelog: none
2020-06-23 14:05:45 +00:00
Lzu Tao
7374185b36 Remove unused allowed unused attributes 2020-06-23 20:59:35 +07:00
bors
9504efc94e Auto merge of #5735 - lzutao:issue-temp, r=flip1995
Add more specific GitHub issue templates

changelog: Make it easier to create feature request and bug reports with issue templates.
2020-06-23 13:40:02 +00:00
bors
b452ad3c0b Auto merge of #5741 - flip1995:rollup-8chbwhy, r=flip1995
Rollup of 9 pull requests

Successful merges:

 - #5178 (clippy-driver: pass all args to rustc if --rustc is present)
 - #5705 (Downgrade unnested_or_patterns to pedantic)
 - #5709 (Fix ICE in consts::binop)
 - #5710 (typo)
 - #5712 (Remove `bar` from blacklisted names)
 - #5713 (Use lints in Clippy that are enabled in rustc bootstrap)
 - #5716 (Fix typo in wildcard_imports)
 - #5724 (redundant_pattern_matching: avoid non-`const fn` calls in const contexts)
 - #5726 (Fix typo)

Failed merges:

r? @ghost

changelog: rollup
2020-06-23 12:52:46 +00:00
Philipp Krones
e4cbd1df4e
Rollup merge of #5726 - sozysozbot:patch-1, r=flip1995
Fix typo

changelog: extending it's lifetime -> extending its lifetime
2020-06-23 14:39:50 +02:00
Philipp Krones
f562117788
Rollup merge of #5724 - ebroto:5697_const_result_option, r=Manishearth
redundant_pattern_matching: avoid non-`const fn` calls in const contexts

changelog: Avoid suggesting non-`const fn` calls in const contexts in [`redundant_pattern_matching`]

Fixes #5697
2020-06-23 14:39:49 +02:00