Commit Graph

2035 Commits

Author SHA1 Message Date
Rich Kadel
c7ae4c2cb6 Splitting transform/instrument_coverage.rs into transform/coverage/... 2020-11-05 18:24:12 -08:00
Rich Kadel
c7747cc772 Rust coverage before splitting instrument_coverage.rs 2020-11-05 18:24:12 -08:00
est31
dfa5e46fd5 The renumber pass is long gone
Originally, there has been a dedicated pass for renumbering
AST NodeIds to have actual values. This pass had been added by
commit a5ad4c3794.

Then, later, this step was moved to where it resides now,
macro expansion. See commit c86c8d41a2
or PR #36438.

The comment snippet, added by the original commit, has
survived the times without any change, becoming outdated
at removal of the dedicated pass.

Nowadays, grepping for the next_node_id function will show up
multiple places in the compiler that call it, but the main
rewriting that the comment talks about is still done in the
expansion step, inside an innocious looking visit_id function
that's called during macro invocation collection.
2020-11-06 03:18:01 +01:00
est31
de2940ff63 rustc_expand: use collect_bang helper instead of manual reimplementation 2020-11-06 03:16:56 +01:00
Tomasz Miąsko
8a8ee1a3ed inliner: Use substs_for_mir_body
Changes from 68965 extended the kind of instances that are being
inlined. For some of those, the `instance_mir` returns a MIR body that
is already expressed in terms of the types found in substitution array,
and doesn't need further substitution.

Use `substs_for_mir_body` to take that into account.
2020-11-06 00:00:00 +00:00
Nadrieril
107a29a901 Emit lints in the order in which they occur in the file. 2020-11-05 22:17:26 +00:00
Nadrieril
25e272e388 Fix unreachable sub-branch detection
This fixes https://github.com/rust-lang/rust/issues/76836
2020-11-05 22:02:35 +00:00
Vadim Petrochenkov
8def2fc122 rustc_ast: Never clone empty token streams in mutable visitor 2020-11-06 00:59:08 +03:00
Vadim Petrochenkov
1e15606547 rustc_ast: Visit tokens stored in AST nodes in mutable visitor 2020-11-06 00:30:52 +03:00
Guillaume Gomez
99200f760b Fix even more URLs 2020-11-05 20:11:29 +01:00
Joshua Nelson
eed0cebea3 Recognize private_intra_doc_links as a lint
Previously, trying to allow this would give another error!

```
warning: unknown lint: `private_intra_doc_links`
 --> private.rs:1:10
  |
1 | #![allow(private_intra_doc_links)]
  |          ^^^^^^^^^^^^^^^^^^^^^^^ help: did you mean: `broken_intra_doc_links`
  |
  = note: `#[warn(unknown_lints)]` on by default

warning: public documentation for `DocMe` links to private item `DontDocMe`
 --> private.rs:2:11
  |
2 | /// docs [DontDocMe]
  |           ^^^^^^^^^ this item is private
  |
  = note: `#[warn(private_intra_doc_links)]` on by default
  = note: this link will resolve properly if you pass `--document-private-items`
```
2020-11-05 12:55:10 -05:00
Joshua Nelson
9d9292cfda deny(invalid_codeblock_attributes) 2020-11-05 12:13:28 -05:00
bors
b1d9f31e04 Auto merge of #78638 - vn-ki:bindigs-after-at-issue-69971, r=oli-obk
reverse binding order in matches to allow the subbinding of copyable fields in bindings after @

Fixes #69971

### TODO

- [x] Regression tests

r? `@oli-obk`
2020-11-05 13:26:08 +00:00
Mara Bos
8416e13d88
Rollup merge of #78758 - eltociear:patch-1, r=jyn514
Fixed typo in comment

paramter -> parameter
2020-11-05 10:30:04 +01:00
Mara Bos
5ffccc4dfa
Rollup merge of #78742 - vn-ki:fix-issue-78655, r=oli-obk
make intern_const_alloc_recursive return error

fix #78655

r? ``@oli-obk``
2020-11-05 10:29:59 +01:00
Mara Bos
171d29c9c5
Rollup merge of #78739 - hameerabbasi:issue-78654, r=nikomatsakis
Fix ICE on type error in async function

Fixes #78654
2020-11-05 10:29:57 +01:00
Mara Bos
8640360870
Rollup merge of #78733 - matthiaskrgr:cl11ppy, r=jyn514
fix a couple of clippy warnings:

filter_next
manual_strip
redundant_static_lifetimes
single_char_pattern
unnecessary_cast
unused_unit
op_ref
redundant_closure
useless_conversion
2020-11-05 10:29:53 +01:00
Guillaume Gomez
16ed8501ef Fix more URLs 2020-11-05 10:23:39 +01:00
Guillaume Gomez
9d114506c6 Rename lint to non_autolinks 2020-11-05 10:22:08 +01:00
Guillaume Gomez
60caf51b0d Rename automatic_links to url_improvements 2020-11-05 10:22:08 +01:00
Guillaume Gomez
55b4d21e25 Fix automatic_links warnings 2020-11-05 10:22:08 +01:00
Guillaume Gomez
7f839b2ece Improve automatic_links globally 2020-11-05 10:22:08 +01:00
Guillaume Gomez
a54f043733 Add documentation for automatic_links lint 2020-11-05 10:22:08 +01:00
Guillaume Gomez
2980367030 Add new lint for automatic_links improvements 2020-11-05 10:22:08 +01:00
Ikko Ashimine
873ebcb243
Fixed typo in comment
paramter -> parameter
2020-11-05 12:08:32 +09:00
Tomasz Miąsko
6ca43aca1d inliner: Copy unevaluated constants only after successful inlining
Inliner copies the unevaluated constants from the callee body to the
caller at the point where decision to inline is yet to be made. The
constants will be unnecessary if inlining were to fail.

Organize the code moving items from callee to the caller together in one
place to avoid the issue.
2020-11-05 00:00:00 +00:00
bors
0fb00251a5 Auto merge of #78662 - sexxi-goose:add_expr_id_to_delegate, r=nikomatsakis
Provide diagnostic suggestion in ExprUseVisitor Delegate

The [Delegate trait](981346fc07/compiler/rustc_typeck/src/expr_use_visitor.rs (L28-L38)) currently use `PlaceWithHirId` which is composed of Hir `Place` and the
corresponding expression id.

Even though this is an accurate way of expressing how a Place is used,
it can cause confusion during diagnostics.

Eg:

```
let arr : [String; 5];

let [a, ...]     =   arr;
 ^^^ E1 ^^^      =  ^^E2^^
 ```

 Here `arr` is moved because of the binding created E1. However, when we
 point to E1 in diagnostics with the message `arr` was moved, it can be
 confusing.  Rather we would like to report E2 to the user.

 Closes: https://github.com/rust-lang/project-rfc-2229/issues/20

r? `@ghost`
2020-11-04 22:45:15 +00:00
Vishnunarayan K I
bd7229daf0 make intern_const_alloc_recursive return error fix #78655 2020-11-04 23:22:14 +05:30
bors
89631663b7 Auto merge of #78280 - bugadani:span, r=lcnr
Codegen: Query span as late as possible
2020-11-04 17:17:01 +00:00
Hameer Abbasi
a70e0c20c3 Fix issue 78654. 2020-11-04 16:04:32 +00:00
bors
75f1db1102 Auto merge of #77227 - oli-obk:const_val_🌳_prelude, r=RalfJung
Refactorings in preparation for const value trees

cc #72396

This PR changes the `Scalar::Bits { data: u128, size: u8 }` variant to `Scalar::Bits(ScalarInt)` where `ScalarInt` contains the same information, but is `repr(packed)`. The reason for using a packed struct is to allow enum variant packing to keep the original size of `Scalar` instead of adding another word to its size due to padding.
Other than that the PR just gets rid of all the inspection of the internal fields of `Scalar::Bits` which were frankly scary. These fields have invariants that we need to uphold and we can't do that without making the fields private.

r? `@ghost`
2020-11-04 14:26:03 +00:00
Oli Scherer
332750f9eb
Update compiler/rustc_target/src/abi/mod.rs
Co-authored-by: Ralf Jung <post@ralfj.de>
2020-11-04 15:13:06 +01:00
Oli Scherer
5f087f089f
Update compiler/rustc_target/src/abi/mod.rs
Co-authored-by: Ralf Jung <post@ralfj.de>
2020-11-04 15:12:44 +01:00
oli
6e6c8a86e9 u64::try_from will now fail if ScalarInt isn't exactly 64 bits, thus we use to_bits with the correct size 2020-11-04 13:59:11 +00:00
oli
97bfff1f56 Make ScalarInt entirely independent of MIR interpretation 2020-11-04 13:55:29 +00:00
oli
2e53625421 Document an unwrap 2020-11-04 13:44:17 +00:00
oli
abacaf2aef u128 truncation and sign extension are not just interpreter related 2020-11-04 13:41:58 +00:00
Matthias Krüger
bcd2f2df67 fix a couple of clippy warnings:
filter_next
manual_strip
redundant_static_lifetimes
single_char_pattern
unnecessary_cast
unused_unit
op_ref
redundant_closure
useless_conversion
2020-11-04 13:48:50 +01:00
bors
601c13c6fd Auto merge of #78677 - Aaron1011:fix/capture-inner-attrs, r=petrochenkov
Use reparsed `TokenStream` if we captured any inner attributes

Fixes #78675

We now bail out of `prepend_attrs` if we ended up capturing any inner
attributes (which can happen in several places, due to token capturing
for `macro_rules!` arguments.
2020-11-04 11:37:36 +00:00
oli
e67c768110 Move ZST constant to the top of the impl block 2020-11-04 10:15:54 +00:00
Oli Scherer
cb1cf6ae95 Update compiler/rustc_middle/src/ty/consts/int.rs
Co-authored-by: Ralf Jung <post@ralfj.de>
2020-11-04 10:15:40 +00:00
oli
98b70c9ac0 Simplify assert_bits impl 2020-11-04 10:15:09 +00:00
oli
dad0036cb4 Do not raise interp errors from the scalar int module 2020-11-04 10:14:40 +00:00
oli
500af76831 Add helper for getting an int out of a Scalar 2020-11-04 10:13:59 +00:00
oli
f03b18b99b Add is_null helper
This is cheaper than creating a null-`ScalarInt` and comparing
and then just throwing it away.
2020-11-04 10:13:22 +00:00
oli
0347ca7d02 Explain why we forward to self-printing during self-printing 2020-11-04 10:13:09 +00:00
oli
d1074edb64 catch conversion errors during ptr_sized_op 2020-11-04 10:12:55 +00:00
oli
8282d526e0 Replace Scalar::zst with a Scalar::ZST constant 2020-11-04 10:12:41 +00:00
oli
b8751c1fbb No need for a zst constructor method when we can have a constant 2020-11-04 10:12:27 +00:00
oli
3ef9dfdd42 Update comment 2020-11-04 10:12:13 +00:00
oli
1eb300ede1 Unaligned reads are UB in Rust irrelevant on which platform we are 2020-11-04 10:11:59 +00:00
oli
e5258e6143 Remove outdated FIXME 2020-11-04 10:11:45 +00:00
oli
df4d717d0b s/Scalar::Raw/Scalar::Int 2020-11-04 10:11:31 +00:00
oli
3a7970848c Fix cranelift build 2020-11-04 10:10:44 +00:00
oli
c478574786 Explain the use of blocks around self.data accesses 2020-11-04 10:10:04 +00:00
oli
02131f4dcd Use packed struct instead of manually packing into an array 2020-11-04 10:09:10 +00:00
Oliver Scherer
ed7a4adeb3 32 bit platforms don't have 64 bit pointers 2020-11-04 09:58:59 +00:00
Oliver Scherer
eac309984f Encode ScalarInt::bytes as u128 instead of [u8; 16] to see if that caused the performance regression 2020-11-04 09:58:59 +00:00
Oliver Scherer
362123dd75 Split the "raw integer bytes" part out of Scalar 2020-11-04 09:58:59 +00:00
Tyson Nottingham
b71e627b26 incr-comp: hash span end line/column
Hash both the length and the end location (line/column) of a span. If we
hash only the length, for example, then two otherwise equal spans with
different end locations will have the same hash. This can cause a
problem during incremental compilation wherein a previous result for a
query that depends on the end location of a span will be incorrectly
reused when the end location of the span it depends on has changed. A
similar analysis applies if some query depends specifically on the
length of the span, but we only hash the end location. So hash both.

Fix #46744, fix #59954, fix #63161, fix #73640, fix #73967, fix #74890, fix #75900
2020-11-04 01:37:18 -08:00
Dhruv Jauhar
c9d9359b00 Address Pr comments regarding docstrings 2020-11-04 02:54:00 -05:00
Vadim Petrochenkov
90fafc8c8f rustc_ast: visit_mac -> visit_mac_call 2020-11-03 23:39:51 +03:00
bors
56293097f7 Auto merge of #78711 - m-ou-se:rollup-pxqnny7, r=m-ou-se
Rollup of 7 pull requests

Successful merges:

 - #77950 (Add support for SHA256 source file hashing)
 - #78624 (Sync rustc_codegen_cranelift)
 - #78626 (Improve errors about #[deprecated] attribute)
 - #78659 (Corrected suggestion for generic parameters in `function_item_references` lint)
 - #78687 (Suggest library/std when running all stage 0 tests)
 - #78699 (Show more error information in lldb_batchmode)
 - #78709 (Fix panic in bootstrap for non-workspace path dependencies.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2020-11-03 18:58:06 +00:00
Mara Bos
f347dab47c
Rollup merge of #78659 - ayrtonm:fn-ref-lint-fix, r=oli-obk
Corrected suggestion for generic parameters in `function_item_references` lint

This commit handles functions with generic type parameters like you pointed out as well as const generics. Also this is probably a minor thing, but the type alias you used in the example doesn't show up so the suggestion right now would be `size_of::<[u8; 16]> as fn() ->`. This is because the lint checker works with MIR instead of HIR. I don't think we can get the alias at that point, but let me know if I'm wrong and there's a way to fix this. Also I put you as the reviewer, but I'm not sure if you want to review it or if it makes more sense to ask one of the original reviewers of this lint.
closes #78571
2020-11-03 19:32:38 +01:00
Mara Bos
f0112928cb
Rollup merge of #78626 - fusion-engineering-forks:deprecated-trait-impl, r=estebank
Improve errors about #[deprecated] attribute

This change:

1. Turns `#[deprecated]` on a trait impl block into an error, which fixes #78625;
2. Changes these and other errors about `#[deprecated]` to use the span of the attribute instead of the item; and
3. Turns this error into a lint, to make sure it can be capped with `--cap-lints` and doesn't break any existing dependencies.

Can be reviewed per commit.

---
Example:
```rust
struct X;

#[deprecated = "a"]
impl Default for X {
    #[deprecated = "b"]
    fn default() -> Self {
        X
    }
}
```

Before:
```
error: This deprecation annotation is useless
 --> src/main.rs:6:5
  |
6 | /     fn default() -> Self {
7 | |         X
8 | |     }
  | |_____^
```

After:
```
error: this `#[deprecated]' annotation has no effect
 --> src/main.rs:3:1
  |
3 | #[deprecated = "a"]
  | ^^^^^^^^^^^^^^^^^^^ help: try removing the deprecation attribute
  |
  = note: `#[deny(useless_deprecated)]` on by default

error: this `#[deprecated]' annotation has no effect
 --> src/main.rs:5:5
  |
5 |     #[deprecated = "b"]
  |     ^^^^^^^^^^^^^^^^^^^ help: try removing the deprecation attribute
```
2020-11-03 19:32:36 +01:00
Mara Bos
39f5563e73
Rollup merge of #78624 - bjorn3:update_cg_clif-2020-11-01, r=jyn514
Sync rustc_codegen_cranelift

This fixes bootstrapping of rustc using cg_clif again. It regressed a while before #77975 got merged.

Fixes https://github.com/bjorn3/rustc_codegen_cranelift/issues/743
2020-11-03 19:32:34 +01:00
Mara Bos
52405f7c0c
Rollup merge of #77950 - arlosi:sha256, r=eddyb
Add support for SHA256 source file hashing

Adds support for `-Z src-hash-algorithm sha256`, which became available in LLVM 11.

Using an older version of LLVM will cause an error `invalid checksum kind` if the hash algorithm is set to sha256.

r? `@eddyb`
cc #70401 `@est31`
2020-11-03 19:32:26 +01:00
Vadim Petrochenkov
3237b3886c rustc_ast: Do not panic by default when visiting macro calls 2020-11-03 20:38:20 +03:00
bors
5cdf5b882d Auto merge of #76931 - oli-obk:const_prop_inline_lint_madness, r=wesleywiser
Properly handle lint spans after MIR inlining

The first commit shows what happens when we apply mir inlining and then cause lints on the inlined MIR.
The second commit fixes that.

r? `@wesleywiser`
2020-11-03 16:32:34 +00:00
bors
0cd1516696 Auto merge of #78597 - RalfJung:raw-retag, r=oli-obk
Retagging: do not retag 'raw reborrows'

When doing `&raw const (*raw_ptr).field`, we do not want any retagging; the original provenance should be fully preserved.

Fixes https://github.com/rust-lang/miri/issues/1608
Test added by https://github.com/rust-lang/miri/pull/1614

Not sure whom to ask for review on this... `@oli-obk` can you have a look? Or maybe highfive makes a good choice.^^
2020-11-03 13:48:54 +00:00
Wesley Wiser
efe703a01a [self-profiling] Include the estimated size of each cgu in the profile
This is helpful when looking for CGUs where the size estimate isn't a
good indicator of compilation time.

I verified that moving the profiling timer call doesn't affect the
results.
2020-11-03 07:55:17 -05:00
Vishnunarayan K I
5827fbadf6 review comments 2020-11-03 17:14:51 +05:30
bjorn3
216c4ae463 Merge commit '03f01bbe901d60b71cf2c5ec766aef5e532ab79d' into update_cg_clif-2020-11-01 2020-11-03 11:00:04 +01:00
bors
8e8939b804 Auto merge of #78489 - bugadani:array, r=estebank
Minor cleanup around incremental compilation

* Remove some short lived vectors
* Fix some typos
* Avoid some reallocations
2020-11-03 09:19:01 +00:00
bors
d662f80855 Auto merge of #78697 - JohnTitor:rollup-q0fchpv, r=JohnTitor
Rollup of 8 pull requests

Successful merges:

 - #78376 (Treat trailing semicolon as a statement in macro call)
 - #78400 (Fix unindent in doc comments)
 - #78575 (Add a test for compiletest rustc-env & unset-rustc-env directives)
 - #78616 (Document -Zinstrument-coverage)
 - #78663 (Fix ICE when a future-incompat-report has its command-line level capped)
 - #78664 (Fix intrinsic size_of stable link)
 - #78668 (inliner: Remove redundant loop)
 - #78676 (add mipsel-unknown-none target)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2020-11-03 06:56:46 +00:00
Vishnunarayan K I
f422e811e4 preserve bindings order for Some 2020-11-03 12:15:41 +05:30
Yuki Okushi
1cb137b3e9
Rollup merge of #78676 - kiffie:embedded-bare-mipsr2, r=jonas-schievink
add mipsel-unknown-none target

This adds a target for bare MIPS32r2, little endian, softfloat. This target can be used for PIC32 microcontrollers (or possibly for other devices that have a MIPS MCU core such as the M4K core).

Tried to find a name for the target that is in line with the naming scheme apparently used for the other MIPS targets.

r? `@jonas-schievink`
2020-11-03 15:27:21 +09:00
Yuki Okushi
cf062179a8
Rollup merge of #78668 - tmiasko:inline, r=oli-obk
inliner: Remove redundant loop

No functional changes intended.
2020-11-03 15:27:19 +09:00
Yuki Okushi
8894c903cb
Rollup merge of #78663 - Aaron1011:fix/cap-future-compat, r=tmandry
Fix ICE when a future-incompat-report has its command-line level capped

Fixes #78660

With PR https://github.com/rust-lang/rust/pull/75534 merged, we now run
more lint-related code for future-incompat-report, even when their final
level is Allow. Some lint-related code was not expecting `Level::Allow`,
and had an explicit panic.

This PR explicitly tracks the lint level set on the command line before
`--cap-lints` is applied. This is used to emit a more precise error
note (e.g. we don't say that `-W lint-name` was specified on the
command line just because a lint was capped to Warn). As a result, we
can now correctly emit a note that `-A` was used if we got
`Level::Allow` from the command line (before the cap is applied).
2020-11-03 15:27:16 +09:00
Yuki Okushi
0716724a0b
Rollup merge of #78376 - Aaron1011:feature/consistent-empty-expr, r=petrochenkov
Treat trailing semicolon as a statement in macro call

See #61733 (comment)

We now preserve the trailing semicolon in a macro invocation, even if
the macro expands to nothing. As a result, the following code no longer
compiles:

```rust
macro_rules! empty {
    () => { }
}

fn foo() -> bool { //~ ERROR mismatched
    { true } //~ ERROR mismatched
    empty!();
}
```

Previously, `{ true }` would be considered the trailing expression, even
though there's a semicolon in `empty!();`

This makes macro expansion more token-based.
2020-11-03 15:27:03 +09:00
bors
7b5a9e9cd2 Auto merge of #78448 - rylev:cache-foreign_modules, r=wesleywiser
foreign_modules query hash table lookups

When compiling a large monolithic crate we're seeing huge times in the `foreign_modules` query due to repeated iteration over foreign modules (in order to find a module by its id). This implements hash table lookups so that which massively reduces time spent in that query in this particular case. We'll need to see if the overhead of creating the hash table has a negative impact on performance in more normal compilation scenarios.

I'm working with `@wesleywiser` on this.
2020-11-03 04:27:27 +00:00
Bastian Kauschke
cc19df627e revert #75443 update mir validator 2020-11-02 23:57:03 +01:00
Stephan
1a232cb976 indicate calling convention 2020-11-02 23:29:00 +01:00
Stephan
96db99a145
improve comments
Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-11-02 23:18:32 +01:00
Vadim Petrochenkov
19dbb02a89 Expand NtExpr tokens only in key-value attributes 2020-11-03 00:53:43 +03:00
Stephan
7d2441134b add blacklist for unsupported calling conventions 2020-11-02 22:52:47 +01:00
Aaron Hill
22383b32b8
Use reparsed TokenStream if we captured any inner attributes
Fixes #78675

We now bail out of `prepend_attrs` if we ended up capturing any inner
attributes (which can happen in several places, due to token capturing
for `macro_rules!` arguments.
2020-11-02 13:22:03 -05:00
Stephan
6e58b1c3c9 add mipsel_unknown_none target 2020-11-02 19:11:24 +01:00
Aaron Hill
e78e9d4a06
Treat trailing semicolon as a statement in macro call
See https://github.com/rust-lang/rust/issues/61733#issuecomment-716188981

We now preserve the trailing semicolon in a macro invocation, even if
the macro expands to nothing. As a result, the following code no longer
compiles:

```rust
macro_rules! empty {
    () => { }
}

fn foo() -> bool { //~ ERROR mismatched
    { true } //~ ERROR mismatched
    empty!();
}
```

Previously, `{ true }` would be considered the trailing expression, even
though there's a semicolon in `empty!();`

This makes macro expansion more token-based.
2020-11-02 13:03:13 -05:00
Vishnunarayan K I
6bdce7bedd new fix method and update tests 2020-11-02 22:29:20 +05:30
bors
338f939a8d Auto merge of #78607 - HeroicKatora:post-order-walk-iter, r=davidtwco
Transform post order walk to an iterative approach

The previous recursive approach might overflow the stack when walking a
particularly deep, list-like, graph. In particular, dominator
calculation for borrow checking does such a traversal and very long
functions might lead to a region dependency graph with in this
problematic structure.

This addresses what appears to be the cause of #78567 (`@SunHao-0` thanks for the stack trace).
2020-11-02 16:01:10 +00:00
Mara Bos
9c647d1021 Improve deprecation attribute diagnostic messages.
(From the PR feedback.)

Co-authored-by: Esteban Küber <esteban@kuber.com.ar>
2020-11-02 13:21:18 +01:00
bors
4051473c8b Auto merge of #78661 - JohnTitor:rollup-er2isja, r=JohnTitor
Rollup of 5 pull requests

Successful merges:

 - #78606 (Clarify handling of final line ending in str::lines())
 - #78610 (Do not remove tokens before AST json serialization)
 - #78620 (Trivial fixes to bitwise operator documentation)
 - #78627 (Point out that total_cmp is no strict superset of partial comparison)
 - #78637 (Add fetch_update methods to AtomicBool and AtomicPtr)

Failed merges:

r? `@ghost`
2020-11-02 10:42:45 +00:00
bors
234099d1d1 Auto merge of #75020 - JohnTitor:fix-multispan, r=estebank,tmandry
Avoid complex diagnostics in snippets which contain newlines

Fixes #70935

r? `@estebank` `@tmandry`
2020-11-02 08:17:36 +00:00
Yuki Okushi
8d651013e4 Fix format 2020-11-02 16:59:11 +09:00
Yuki Okushi
54d9ffc0b9 Only separate notes if span is multiline 2020-11-02 16:54:53 +09:00
Yuki Okushi
2da86a1bfd Add "this has type {} which {}" note 2020-11-02 15:53:59 +09:00
Yuki Okushi
66226ca157 Address some code reviews 2020-11-02 15:53:59 +09:00
Yuki Okushi
ad978e5572 Separate complex multispan into some notes 2020-11-02 15:53:59 +09:00
Aaron Hill
6c1f15fa81
Fix ICE when a future-incompat-report has its command-line level capped
Fixes #78660

With PR https://github.com/rust-lang/rust/pull/75534 merged, we now run
more lint-related code for future-incompat-report, even when their final
level is Allow. Some lint-related code was not expecting `Level::Allow`,
and had an explicit panic.

This PR explicitly tracks the lint level set on the command line before
`--cap-lints` is applied. This is used to emit a more precise error
note (e.g. we don't say that `-W lint-name` was specified on the
command line just because a lint was capped to Warn). As a result, we
can now correctly emit a note that `-A` was used if we got
`Level::Allow` from the command line (before the cap is applied).
2020-11-02 01:43:25 -05:00
Dhruv Jauhar
1f53754236 Provide diagnostic suggestion in ExprUseVisitor Delegate
The [Delegate
trait](981346fc07/compiler/rustc_typeck/src/expr_use_visitor.rs (L28-L38))
currently use `PlaceWithHirId` which is composed of Hir `Place` and the
corresponding expression id.

Even though this is an accurate way of expressing how a Place is used,
it can cause confusion during diagnostics.

Eg:

```
let arr : [String; 5];

let [a, ...]     =   arr;
 ^^^ E1 ^^^      =  ^^E2^^
 ```

 Here `arr` is moved because of the binding created E1. However, when we
 point to E1 in diagnostics with the message `arr` was moved, it can be
 confusing.  Rather we would like to report E2 to the user.

 Closes: https://github.com/rust-lang/project-rfc-2229/issues/20
2020-11-02 01:31:34 -05:00
Yuki Okushi
61305d5ab4
Rollup merge of #78610 - petrochenkov:nostriptok, r=Aaron1011
Do not remove tokens before AST json serialization

`TokenStripper` is error-prone and introduces one more use of `MutVisitor`.
It's much simpler to treat serialization as just one more place that wants lazy token stream to turn into a real token stream.
Also, no code is better than more code, in general.
r? @Aaron1011

(I also merged tests for `TokenStripper` ICEs into one.)
2020-11-02 14:14:34 +09:00
bors
3e93027557 Auto merge of #78592 - fpoli:nll-facts-dir, r=matthewjasper
Add option to customize the nll-facts' folder location

This PR adds a `nll-facts-dir` option to specify the location of the directory in which NLL facts are dumped into. It works the same way `dump-mir-dir` controls the location used by the `dump-mir` option.
2020-11-02 04:39:05 +00:00
Ayrton
ace02c40f0 Corrected suggestion for generic parameters in function_item_references lint
This lint was incorrectly suggesting casting a function to a pointer without
specifying generic type parameters or const generics. This would cause a
compiler error since the missing parameters couldn't be inferred. This commit
fixed the suggestion and added a few tests with generics.
2020-11-01 23:50:17 -04:00
bors
d8ef0d7757 Auto merge of #78645 - JulianKnodt:i78622, r=estebank
Add delay_span_bug to no longer ICE

Fixes #78622

r? `@matthewjasper`
2020-11-02 02:18:36 +00:00
bors
3d0682b97a Auto merge of #78605 - nox:relax-elf-relocations, r=nagisa
Implement -Z relax-elf-relocations=yes|no

This lets rustc users tweak whether the linker should relax ELF relocations without recompiling a whole new target with its own libcore etc.
2020-11-02 00:12:32 +00:00
Tomasz Miąsko
c0cbf6368d inliner: Remove redundant loop
No functional changes intended.
2020-11-02 00:00:00 +00:00
kadmin
ab946dd3e7 Add delay_span_bug to no longer ICE 2020-11-01 22:31:19 +00:00
Mara Bos
6f1992a7d6 Turn 'useless #[deprecated]' error into a lint. 2020-11-01 20:48:58 +01:00
Mara Bos
706bc33651 Use the right span for errors about #[deprecated] attributes. 2020-11-01 20:48:58 +01:00
Mara Bos
0e2337a5d6 Deny #[deprecated] on trait impl blocks.
They have no effect there, but were silently accepted.
2020-11-01 20:48:58 +01:00
Vishnunarayan K I
c93d25b6af reverse binding order in matches ...
... to allow the subbinding of copyable fields in bindings after `@`

Fixes #69971
2020-11-02 00:05:55 +05:30
bors
b202532608 Auto merge of #75534 - Aaron1011:feature/new-future-breakage, r=pnkfelix
Implement rustc side of report-future-incompat

cc https://github.com/rust-lang/rust/issues/71249

This is an alternative to `@pnkfelix's` initial implementation in https://github.com/pnkfelix/rust/commits/prototype-rustc-side-of-report-future-incompat (mainly because I started working before seeing that branch 😄 ).

My approach outputs the entire original `Diagnostic`, in a way that is compatible with incremental compilation. This is not yet integrated with compiletest, but can be used manually by passing `-Z emit-future-incompat-report` to `rustc`.

Several changes are made to support this feature:
* The `librustc_session/lint` module is moved to a new crate `librustc_lint_defs` (name bikesheddable). This allows accessing lint definitions from `librustc_errors`.
* The `Lint` struct is extended with an `Option<FutureBreakage>`. When present, it indicates that we should display a lint in the future-compat report. `FutureBreakage` contains additional information that we may want to display in the report (currently, a `date` field indicating when the crate will stop compiling).
* A new variant `rustc_error::Level::Allow` is added. This is used when constructing a diagnostic for a future-breakage lint that is marked as allowed (via `#[allow]` or `--cap-lints`). This allows us to capture any future-breakage diagnostics in one place, while still discarding them before they are passed to the `Emitter`.
* `DiagnosticId::Lint` is extended with a `has_future_breakage` field, indicating whether or not the `Lint` has future breakage information (and should therefore show up in the report).
* `Session` is given access to the `LintStore` via a new `SessionLintStore` trait (since `librustc_session` cannot directly reference `LintStore` without a cyclic dependency). We use this to turn a string `DiagnosticId::Lint` back into a `Lint`, to retrieve the `FutureBreakage` data.

Currently, `FutureBreakage.date` is always set to `None`. However, this could potentially be interpreted by Cargo in the future.

I've enabled the future-breakage report for the `ARRAY_INTO_ITER` lint, which can be used to test out this PR. The intent is to use the field to allow Cargo to determine the date of future breakage (as described in [RFC 2834](https://github.com/rust-lang/rfcs/blob/master/text/2834-cargo-report-future-incompat.md)) without needing to parse the diagnostic itself.

cc `@pnkfelix`
2020-11-01 16:52:28 +00:00
bors
1899c489d4 Auto merge of #78553 - Nadrieril:fix-78549, r=varkor
Fix #78549

Before #78430, this worked because `specialize_constructor` didn't actually care too much which constructor was passed to it unless needed. That PR however handles `&str` as a special case, and I did not anticipate patterns for the `&str` type other than string literals.
I am not very confident there are not other similar oversights left, but hopefully only `&str` was different enough to break my assumptions.

Fixes https://github.com/rust-lang/rust/issues/78549
2020-11-01 14:37:50 +00:00
bors
e8cbaf2ae7 Auto merge of #78623 - m-ou-se:rollup-m6y5j0m, r=m-ou-se
Rollup of 6 pull requests

Successful merges:

 - #78073 (Add #[inline] to some functions in core::str.)
 - #78596 (Fix doc links to std::fmt)
 - #78599 (Add note to process::arg[s] that args shouldn't be escaped or quoted)
 - #78602 (fix various aliasing issues in the standard library)
 - #78603 (expand: Tweak a comment in implementation of `macro_rules`)
 - #78621 (Inline Default::default() for atomics)

Failed merges:

r? `@ghost`
2020-11-01 11:54:58 +00:00
Mara Bos
540d4743cc
Rollup merge of #78603 - petrochenkov:fourdigits, r=matthewjasper
expand: Tweak a comment in implementation of `macro_rules`

The answer to the removed FIXME is that we don't apply mark to the span `sp` just because that span is no longer used. We could apply it, but that would just be unnecessary extra work.

The comments in code tell why the span is unused, it's a span of `$var` literally, which is lost for `tt` variables because their tokens are outputted directly, but kept for other variables which are outputted as [groups](https://doc.rust-lang.org/nightly/proc_macro/struct.Group.html) and `sp` is kept as the group's span.

Closes https://github.com/rust-lang/rust/issues/2887
2020-11-01 11:53:37 +01:00
bors
1e37ba76d4 Auto merge of #78531 - cuviper:unwrap-metadata, r=tmandry
rustc_llvm: unwrap LLVMMetadataRef before casting

Directly casting the opaque pointer was [reported] to cause an
"incomplete type" error with GCC 9.3:

```
llvm-wrapper/RustWrapper.cpp:939:31:   required from here
/usr/include/c++/9.3/type_traits:1301:12: error: invalid use of incomplete type 'struct LLVMOpaqueMetadata'
 1301 |     struct is_base_of
      |            ^~~~~~~~~~
In file included from [...]/rust/src/llvm-project/llvm/include/llvm-c/BitReader.h:23,
                 from llvm-wrapper/LLVMWrapper.h:1,
                 from llvm-wrapper/RustWrapper.cpp:1:
[...]/rust/src/llvm-project/llvm/include/llvm-c/Types.h:89:16: note: forward declaration of 'struct LLVMOpaqueMetadata'
   89 | typedef struct LLVMOpaqueMetadata *LLVMMetadataRef;
      |                ^~~~~~~~~~~~~~~~~~
```

[reported]: https://zulip-archive.rust-lang.org/182449tcompilerhelp/12215halprustcllvmbuildfail.html#214915124

A simple `unwrap` fixes the issue.

r? `@eddyb`
2020-11-01 09:30:11 +00:00
bors
1d5b7c3c96 Auto merge of #78420 - estebank:suggest-assoc-fn, r=petrochenkov
Suggest calling associated `fn` inside `trait`s

When calling a function that doesn't exist inside of a trait's
associated `fn`, and another associated `fn` in that trait has that
name, suggest calling it with the appropriate fully-qualified path.

Expand the label to be more descriptive.

Prompted by the following user experience:
https://users.rust-lang.org/t/cannot-find-function/50663
2020-11-01 06:49:16 +00:00
Nadrieril
1bdcd02a70 The need for Single to cover Unlistable was a hack
It is now unneeded, since we handle `&str` patterns in a consistent way.
2020-11-01 02:05:58 +00:00
Nadrieril
4cd30197eb Fix #78549
Before #78430, string literals worked because `specialize_constructor`
didn't actually care too much which constructor was passed to it unless
needed. Since then, string literals are special cased and a bit hacky. I
did not anticipate patterns for the `&str` type other than string
literals, hence this bug. This makes string literals less hacky.
2020-11-01 02:04:42 +00:00
Vadim Petrochenkov
6b63e9b990 Do not remove tokens before AST json serialization 2020-11-01 00:03:35 +03:00
Tomasz Miąsko
3b7157dc1a Assert that locals have storage when used
The validator in visit_local asserts that local has a stroage when used,
but visit_local is never called so validation is ineffective.

Use super_statement and super_terminator to ensure that locals are visited.
2020-10-31 21:06:29 +01:00
Andreas Molzer
af72a70ee2 Move post order walk to iterative approach
The previous recursive approach might overflow the stack when walking a
particularly deep, list-like, graph. In particular, dominator
calculation for borrow checking does such a traversal and very long
functions might lead to a region dependency graph with in this
problematic structure.
2020-10-31 18:52:00 +01:00
Anthony Ramine
6febaf2419 Implement -Z relax-elf-relocations=yes|no
This lets rustc users tweak whether the linker should relax ELF relocations,
namely whether it should emit R_X86_64_GOTPCRELX relocations instead of
R_X86_64_GOTPCREL, as the former is allowed by the ABI to be further
optimised. The default value is whatever the target defines.
2020-10-31 17:16:56 +01:00
Vadim Petrochenkov
7652bc3f68 expand: Tweak a comment in implementation of macro_rules 2020-10-31 18:13:46 +03:00
Ralf Jung
289c0d8489 Retagging: do not retag 'raw reborrows' 2020-10-31 15:31:27 +01:00
Mara Bos
1873ca55b3
Rollup merge of #78587 - petrochenkov:lazytok, r=Aaron1011
parser: Cleanup `LazyTokenStream` and avoid some clones

by using a named struct instead of a closure.

r? @Aaron1011
2020-10-31 09:49:41 +01:00
Mara Bos
841f0e7f2c
Rollup merge of #78577 - tmiasko:validate-aliasing, r=jonas-schievink
validator: Extend aliasing check to a call terminator
2020-10-31 09:49:38 +01:00
Mara Bos
89aea55a7d
Rollup merge of #78526 - Aaron1011:fix/assoc-tokens, r=estebank
Strip tokens from trait and impl items before printing AST JSON

Fixes #78510
2020-10-31 09:49:34 +01:00
Aaron Hill
ac12e6fd0e
Fix test 2020-10-30 20:02:15 -04:00
Aaron Hill
6bdb4e3206
Some work 2020-10-30 20:02:14 -04:00
Aaron Hill
23018a55d9
Implement rustc side of report-future-incompat 2020-10-30 20:02:14 -04:00
Vadim Petrochenkov
d0c63bccc5 parser: Cleanup LazyTokenStream and avoid some clones
by using a named struct instead of a closure.
2020-10-31 01:56:34 +03:00
bors
0d033dee3e Auto merge of #78182 - LeSeulArtichaut:ty-visitor-contolflow, r=lcnr,oli-obk
TypeVisitor: use `std::ops::ControlFlow` instead of `bool`

Implements MCP rust-lang/compiler-team#374.

Blocked on FCP in rust-lang/compiler-team#374.
r? `@lcnr` cc `@jonas-schievink`
2020-10-30 22:53:55 +00:00
Federico Poli
97a65b6f81 Add option to customize the nll-facts' folder location 2020-10-30 21:33:08 +01:00
Matthew Jasper
4d60a80713 Address review comment and update chalk to 0.36.0 2020-10-30 19:39:33 +00:00
Matthew Jasper
acb6a06123 Fix various Chalk lowering bugs
- Add more well-known traits
- Use the correct binders when lowering trait objects
- Use correct substs when lowering trait objects
- Use the correct binders for opaque_ty_data
- Lower negative impls with the correct polarity
- Supply associated type values
- Use `predicates_defined_on` for where clauses
2020-10-30 19:39:33 +00:00
Matthew Jasper
299a65ff71 Update chalk 0.32.0 -> 0.35.0 2020-10-30 19:39:30 +00:00
Matthew Jasper
1f5c655d0c Fix query cycle when tracing explicit_item_bounds 2020-10-30 19:38:46 +00:00
Joshua Nelson
5339bd1ebe Add back missing comments 2020-10-30 10:13:41 -04:00
Joshua Nelson
57c6ed0c07 Fix even more clippy warnings 2020-10-30 10:13:39 -04:00
Joshua Nelson
bfecb18771 Fix some more clippy warnings 2020-10-30 10:12:56 -04:00
LeSeulArtichaut
9433eb83fe Remove implicit Continue type 2020-10-30 12:27:47 +01:00
LeSeulArtichaut
24e1a7e656 Use ControlFlow::is{break,continue} 2020-10-30 12:27:46 +01:00
LeSeulArtichaut
61f8182cec TypeVisitor: use ControlFlow in rustc_{mir,privacy,traits,typeck} 2020-10-30 12:27:44 +01:00
LeSeulArtichaut
4fe735b320 TypeVisitor: use ControlFlow in rustc_{infer,lint,trait_selection} 2020-10-30 12:27:34 +01:00
LeSeulArtichaut
2c85b6fae0 TypeVisitor: use std::ops::ControlFlow instead of bool 2020-10-30 12:25:24 +01:00
bors
388ef34904 Auto merge of #78562 - JohnTitor:rollup-otg906u, r=JohnTitor
Rollup of 8 pull requests

Successful merges:

 - #77334 (Reorder benches const variable)
 - #77888 (Simplify a nested bool match)
 - #77921 (f64: Refactor collapsible_if)
 - #78523 (Revert invalid `fn` return type parsing change)
 - #78524 (Avoid BorrowMutError with RUSTC_LOG=debug)
 - #78545 (Make anonymous binders start at 0)
 - #78554 (Improve wording of `core::ptr::drop_in_place` docs)
 - #78556 (Link to pass docs from NRVO module docs)

Failed merges:

 - #78424 (Fix some more clippy warnings)

r? `@ghost`
2020-10-30 10:01:49 +00:00
Yuki Okushi
2471a7cdaa
Rollup merge of #78556 - camelid:mir-opt-nrvo-docs, r=jyn514
Link to pass docs from NRVO module docs

It can be easy to miss that this is documented on the pass's struct if you are
looking at the module docs.

Cc https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/what.20is.20NRVO.3F
2020-10-30 18:00:58 +09:00
Yuki Okushi
05f80f03a9
Rollup merge of #78545 - jackh726:anonymous, r=oli-obk
Make anonymous binders start at 0

A few changes to some test outputs, but these actually look *more* correct to me.
2020-10-30 18:00:56 +09:00
Yuki Okushi
f8539221d0
Rollup merge of #78524 - tmiasko:source-files-borrow, r=Aaron1011
Avoid BorrowMutError with RUSTC_LOG=debug

```console
$ touch empty.rs
$ env RUSTC_LOG=debug rustc +stage1 --crate-type=lib empty.rs
```

Fails with a `BorrowMutError` because source map files are already
borrowed while `features_query` attempts to format a log message
containing a span.

Release the borrow before the query to avoid the issue.
2020-10-30 18:00:54 +09:00
Yuki Okushi
8111706c18
Rollup merge of #78523 - estebank:fix-return-type-parse-regression, r=dtolnay
Revert invalid `fn` return type parsing change

Revert one of the changes in #78379.

Fix #78507.
2020-10-30 18:00:53 +09:00
Yuki Okushi
439ea4b621
Rollup merge of #77888 - LingMan:ast_pretty_tt_prepend_space, r=jyn514
Simplify a nested bool match

Logically this first eliminates the innermost match by merging the patterns.
Then, in a second step, turns the newly innermost match into a `matches!` call.
2020-10-30 18:00:45 +09:00
bors
8df58ae03a Auto merge of #78393 - SNCPlay42:match-if-guard, r=tmandry
Always record reference to binding in match if guards

When encountering a binding from a `match` pattern in its `if` guard when computing a generator's interior types, we must always record the type of a reference to the binding because of how `if` guards are lowered to MIR. This was missed in #75213 because the binding in that test case was autorefed and we recorded that adjusted type anyway.

Fixes #78366
2020-10-30 07:05:57 +00:00
Camelid
f558d96253 Link to pass docs from NRVO module docs 2020-10-29 23:05:45 -07:00
bors
0d33ab7af4 Auto merge of #78432 - sexxi-goose:fix-77993-take3, r=nikomatsakis
Handle type errors in closure/generator upvar_tys

Fixes #77993
2020-10-30 03:00:13 +00:00
Tomasz Miąsko
b816e5dfb4 validator: Extend aliasing check to a call terminator 2020-10-30 00:00:00 +00:00
Jack Huey
41ce397990 Make anonymous binders start at 0 2020-10-29 18:50:23 -04:00
bors
a3d7a5e945 Auto merge of #78528 - jonas-schievink:rollup-e70g9zk, r=jonas-schievink
Rollup of 11 pull requests

Successful merges:

 - #75078 (Improve documentation for slice strip_* functions)
 - #76138 (Explain fully qualified syntax for `Rc` and `Arc`)
 - #78244 (Dogfood {exclusive,half-open} ranges in compiler (nfc))
 - #78422 (Do not ICE on invalid input)
 - #78423 (rustc_span: improve bounds checks in byte_pos_to_line_and_col)
 - #78431 (Prefer new associated numeric consts in float error messages)
 - #78462 (Use unwrapDIPtr because the Scope may be null.)
 - #78493 (Update cargo)
 - #78499 (Prevent String::retain from creating non-utf8 strings when abusing panic)
 - #78505 (Update Clippy - temporary_cstring_as_ptr deprecation)
 - #78527 (Fix some more typos)

Failed merges:

r? `@ghost`
2020-10-29 20:56:25 +00:00
bors
6bdae9edd0 Auto merge of #78508 - wesleywiser:optimize_visit_scopes, r=petrochenkov
[resolve] Use `unwrap_or_else` instead of `unwrap_or` in a hot path

This improves the performance of the `resolve_crate` function by 30% for
a very large single file crate with auto-generated C bindings.

cc `@rylev`
2020-10-29 18:34:59 +00:00
Josh Stone
dcbf2f324f rustc_llvm: unwrap LLVMMetadataRef before casting
Directly casting the opaque pointer was [reported] to cause an
"incomplete type" error with GCC 9.3:

```
llvm-wrapper/RustWrapper.cpp:939:31:   required from here
/usr/include/c++/9.3/type_traits:1301:12: error: invalid use of incomplete type 'struct LLVMOpaqueMetadata'
 1301 |     struct is_base_of
      |            ^~~~~~~~~~
In file included from [...]/rust/src/llvm-project/llvm/include/llvm-c/BitReader.h:23,
                 from llvm-wrapper/LLVMWrapper.h:1,
                 from llvm-wrapper/RustWrapper.cpp:1:
[...]/rust/src/llvm-project/llvm/include/llvm-c/Types.h:89:16: note: forward declaration of 'struct LLVMOpaqueMetadata'
   89 | typedef struct LLVMOpaqueMetadata *LLVMMetadataRef;
      |                ^~~~~~~~~~~~~~~~~~
```

[reported]: https://zulip-archive.rust-lang.org/182449tcompilerhelp/12215halprustcllvmbuildfail.html#214915124

A simple `unwrap` fixes the issue.
2020-10-29 09:45:15 -07:00
Jonas Schievink
e656e609ba
Rollup merge of #78527 - bugadani:typo3, r=jonas-schievink
Fix some more typos
2020-10-29 17:05:31 +01:00
Jonas Schievink
38c34098b1
Rollup merge of #78462 - danielframpton:fixnullisa, r=nagisa
Use unwrapDIPtr because the Scope may be null.

I ran into an assertion when using debug information on Windows with LLVM assertions enabled.

It seems like we are using unwrap here (which in turn calls isa and requires the pointer to be non-null) but we expect the value to be null because that is what we are passing from rustc.

This change uses unwrapDIPtr which explicitly allows nullptr.

The FFI prototype for this method on the rust side has the `LLVMMetadataRef` parameter as `Scope: Option<&'a DIScope>`, and we always pass `None` when `msvc_like_names` is true.
2020-10-29 17:05:23 +01:00
Jonas Schievink
31cfe63fb9
Rollup merge of #78431 - Rustin-Liu:rustin-patch-lint, r=estebank
Prefer new associated numeric consts in float error messages

Fix https://github.com/rust-lang/rust/issues/78382
2020-10-29 17:05:21 +01:00
Jonas Schievink
151db25599
Rollup merge of #78423 - tgnottingham:caching_source_map_bounds_check, r=oli-obk
rustc_span: improve bounds checks in byte_pos_to_line_and_col

The effect of this change is to consider edge-case spans that start or
end at the position one past the end of a file to be valid during span
hashing and encoding. This change means that these spans will be
preserved across incremental compilation sessions when they are part of
a serialized query result, instead of causing the dummy span to be used.
2020-10-29 17:05:17 +01:00
Jonas Schievink
7fa9e39682
Rollup merge of #78422 - estebank:fix-78372, r=pnkfelix
Do not ICE on invalid input

Fix #78372.
2020-10-29 17:05:14 +01:00
Jonas Schievink
9867e54bea
Rollup merge of #78244 - workingjubilee:dogfood-fancy-ranges, r=varkor
Dogfood {exclusive,half-open} ranges in compiler (nfc)

In particular, this allows us to write more explicit matches that
avoid the pitfalls of using a fully general fall-through case, yet
remain fairly ergonomic. Less logic is in guard cases, more is in
the actual exhaustive case analysis.

No functional changes.
2020-10-29 17:05:11 +01:00
Dániel Buga
3fba948510 Fix typos 2020-10-29 16:51:46 +01:00
Aaron Hill
4ba57aa703
Strip tokens from trait and impl items before printing AST JSON
Fixes #78510
2020-10-29 11:39:38 -04:00
Esteban Küber
f9a26643ec Revert invalid fn return type parsing change
Fix #78507.
2020-10-29 08:26:42 -07:00
bors
49720d2b9a Auto merge of #78512 - JohnTitor:rollup-a7qwjah, r=JohnTitor
Rollup of 11 pull requests

Successful merges:

 - #77213 (rustdoc options to set default theme (and other settings))
 - #78224 (min_const_generics: allow ty param in repeat expr)
 - #78428 (MinConstGenerics UI test for invalid values for bool & char)
 - #78460 (Adjust turbofish help message for const generics)
 - #78470 (Clean up intra-doc links in `std::path`)
 - #78475 (fix a comment in validity check)
 - #78478 (Add const generics tests for supertraits + dyn traits.)
 - #78487 (Fix typo "compiltest")
 - #78491 (Inline NonZeroN::from(n))
 - #78492 (Update books)
 - #78494 (Fix typos)

Failed merges:

r? `@ghost`
2020-10-29 03:57:54 +00:00
Jubilee Young
0e88db7db4 Dogfood {exclusive,half-open} ranges in compiler (nfc)
In particular, this allows us to write more explicit matches that
avoid the pitfalls of using a fully general fall-through case, yet
remain fairly ergonomic. Less logic is in guard cases, more is in
the actual exhaustive case analysis.

No functional changes.
2020-10-28 20:09:20 -07:00
Yuki Okushi
30d1d8f5da
Rollup merge of #78494 - bugadani:typo2, r=jonas-schievink
Fix typos
2020-10-29 12:09:03 +09:00
Yuki Okushi
5e3cc6e913
Rollup merge of #78475 - RalfJung:validity-comment, r=oli-obk
fix a comment in validity check

A few things changed since that comment was written; update it to the current reality.

r? @oli-obk
2020-10-29 12:08:55 +09:00
Yuki Okushi
a7a0538802
Rollup merge of #78460 - varkor:turbofish-string-generic, r=lcnr
Adjust turbofish help message for const generics

Types are no longer special. (This message arguably only makes sense with `min_const_generics` or more, but we'll be there soon.)

r? @lcnr
2020-10-29 12:08:50 +09:00
Yuki Okushi
270d2e0c2e
Rollup merge of #78224 - lcnr:repeat-expr, r=varkor
min_const_generics: allow ty param in repeat expr

implements https://rust-lang.zulipchat.com/#narrow/stream/260443-project-const-generics/topic/repeat.20expressions

Even with `min_const_generics` active, now keeps resulting in future compat warnings instead of hard errors.
Const parameters, for example `[0; N + 1]`, still result in hard errors during resolve.
```rust
#![allow(dead_code)]

fn foo<T>() {
    [0; std::mem::size_of::<*mut T>()];
}

struct Foo<T>(T);

impl<T> Foo<T> {
    const ASSOC: usize = 4;

    fn test() {
        [0; Self::ASSOC];
    }
}
```

r? @varkor cc @petrochenkov
2020-10-29 12:08:40 +09:00
Wesley Wiser
1c1c591c81 [resolve] Use unwrap_or_else instead of unwrap_or in a hot path
This improves the performance of the `resolve_crate` function by 30% for
a very large single file crate with auto-generated C bindings.
2020-10-28 21:53:25 -04:00
bors
f9187adaef Auto merge of #78430 - Nadrieril:taking-constructors-seriously2, r=varkor
Clarify main code paths in exhaustiveness checking

This PR massively clarifies the main code paths of exhaustiveness checking, by using the `Constructor` enum to a fuller extent. I've been itching to write it for more than a year, but the complexity of matching consts had prevented me. Behold a massive simplification :D.
This in particular removes a fair amount of duplication between various parts, localizes code into methods of relevant types when applicable, makes some implicit assumptions explicit, and overall improves legibility a lot (or so I hope). Additionally, after my changes undoing #76918 turned out to be a noticeable perf gain.

As usual I tried my best to make the commits self-contained and easy to follow. I've also tried to keep the code well-commented, but I tend to forget how complex this file is; I'm happy to clarify things as needed.
My measurements show good perf improvements on the two match-heavy benchmarks (-18.0% on `unicode_normalization-check`! :D); I'd like a perf run to check the overall impact.

r? `@varkor`
`@rustbot` modify labels: +A-exhaustiveness-checking
2020-10-29 01:37:49 +00:00
Tomasz Miąsko
79cc5099b1 Use RwLock instead of Lock for SourceMap::files 2020-10-29 18:09:53 +01:00
Tomasz Miąsko
2661a4edb9 Avoid BorrowMutError with RUSTC_LOG=debug
$ touch empty.rs
$ env RUSTC_LOG=debug rustc +stage1 --crate-type=lib empty.rs

Fails with a `BorrowMutError` because source map files are already
borrowed while `features_query` attempts to format a log message
containing a span.

Release the borrow before the query to avoid the issue.
2020-10-29 18:09:53 +01:00
bors
31ee872db5 Auto merge of #78415 - tgnottingham:expn_id_tag_hash, r=Aaron1011
rustc_span: avoid hashing ExpnId tag when using cached hash
2020-10-28 20:03:55 +00:00
Nadrieril
41a74ace4a Apply suggestions from code review
Co-authored-by: Who? Me?! <mark-i-m@users.noreply.github.com>
Co-authored-by: varkor <github@varkor.com>
2020-10-28 19:08:01 +00:00
Dániel Buga
0fabbf9713 Fix typos 2020-10-28 19:32:28 +01:00
bors
3dddf6ac1e Auto merge of #78414 - nox:function-sections, r=nagisa,bjorn3
Implement -Z function-sections=yes|no

This lets rustc users tweak whether all functions should be put in their own TEXT section, using whatever default value the target defines if the flag is missing.

I'm having fun experimenting with musl libc and trying to implement the start symbol in Rust, that means avoiding code that requires relocations, and AFAIK putting everything in its own section makes the toolchain generate `GOTPCREL` relocations for symbols that could use plain old PC-relative addressing (at least on `x86_64`) if they were all in the same section.
2020-10-28 17:47:36 +00:00
Dániel Buga
a8803d3c04 Delete files immediately, instead of collecting into vector 2020-10-28 17:22:10 +01:00
Dániel Buga
2fa359814a Avoid reallocating cgu_path_components 2020-10-28 17:22:10 +01:00
Dániel Buga
5248b20d9a Reuse memory 2020-10-28 17:22:10 +01:00
Dániel Buga
a21f3a76a9 Clean up encode_dep_graph 2020-10-28 17:22:05 +01:00
Dániel Buga
f3e6d882fe Fix typos and replace static vector with slice 2020-10-28 16:42:28 +01:00
varkor
a6d01da716 Remove irrelevant FIXME 2020-10-28 10:47:27 +00:00
varkor
6c73adf324 Adjust turbofish help message for const generics 2020-10-28 10:47:27 +00:00
Ralf Jung
c90ef979de fix a comment in validity check 2020-10-28 10:39:21 +01:00
bors
2eb4fc800a Auto merge of #78323 - est31:smaller_list_overlap, r=varkor
Iterate over the smaller list

If there are two lists of different sizes,
iterating over the smaller list and then
looking up in the larger list is cheaper
than vice versa, because lookups scale
sublinearly.
2020-10-28 03:58:32 +00:00
bors
db241bb0c8 Auto merge of #78458 - Dylan-DPC:rollup-tan044s, r=Dylan-DPC
Rollup of 10 pull requests

Successful merges:

 - #78152 (Separate unsized locals)
 - #78297 (Suggest calling await on method call and field access)
 - #78351 (Move "mutable thing in const" check from interning to validity)
 - #78365 (check object safety of generic constants)
 - #78379 (Tweak invalid `fn` header and body parsing)
 - #78391 (Add const_fn in generics test)
 - #78401 (resolve: private fields in tuple struct ctor diag)
 - #78408 (Remove tokens from foreign items in `TokenStripper`)
 - #78447 (Fix typo in  comment)
 - #78453 (Fix typo in comments)

Failed merges:

r? `@ghost`
2020-10-28 01:40:06 +00:00
Daniel Frampton
a3bff69134 Use unwrapDIPtr because the Scope may be passed as None 2020-10-27 18:05:16 -07:00
Dylan DPC
6967005e6e
Rollup merge of #78453 - Storyyeller:patch-1, r=jonas-schievink
Fix typo in comments
2020-10-28 01:21:39 +01:00
Dylan DPC
3349b6847f
Rollup merge of #78447 - bugadani:typo, r=matthewjasper
Fix typo in  comment

I hope I got all the typos in that word. :)
2020-10-28 01:21:37 +01:00
Dylan DPC
14b4ed20c7
Rollup merge of #78408 - Aaron1011:fix/remove-foreign-tokens, r=oli-obk
Remove tokens from foreign items in `TokenStripper`

Fixes #78398

I forgot to handle this case in #77255
2020-10-28 01:21:34 +01:00
Dylan DPC
c9279c845d
Rollup merge of #78401 - davidtwco:issue-75906-tuple-construct-private-field, r=estebank
resolve: private fields in tuple struct ctor diag

Fixes #75906.

This PR improves the diagnostic emitted when a tuple struct is being constructed which has private fields so that private fields are labelled and the message is improved.

r? @estebank
2020-10-28 01:21:31 +01:00
Dylan DPC
892ebe9afe
Rollup merge of #78379 - estebank:fn-signature-parse, r=varkor
Tweak invalid `fn` header and body parsing

* Rely on regular "expected"/"found" parser error for `fn`, fix #77115
* Recover empty `fn` bodies when encountering `}`
* Recover trailing `>` in return types
* Recover from non-type in array type `[<BAD TOKEN>; LEN]`
2020-10-28 01:21:24 +01:00
Dylan DPC
1a64e570c6
Rollup merge of #78365 - lcnr:const-eval-obj-safety, r=oli-obk
check object safety of generic constants

As `Self` can only be effectively used in constants with `const_evaluatable_checked` this should not matter outside of it.

Implements the first item of #72219

> Object safety interactions with constants

r? @oli-obk for now cc @nikomatsakis
2020-10-28 01:21:21 +01:00
Dylan DPC
54ea0f9ccd
Rollup merge of #78351 - RalfJung:validity-unsafe-cell, r=oli-obk
Move "mutable thing in const" check from interning to validity

This moves the check for mutable things (such as `UnsafeCell` or `&mut`) in a`const` from interning to validity. That means we can give more targeted error messages (pointing out *where* the problem lies), and we can simplify interning a bit.

Also fix the interning mode used for promoteds in statics.

r? @oli-obk
2020-10-28 01:21:18 +01:00
Dylan DPC
86a4a38177
Rollup merge of #78297 - estebank:match-semicolon-2, r=oli-obk
Suggest calling await on method call and field access

When encountering a failing method or field resolution on a `Future`,
look at the `Output` and try the same operation on it. If successful,
suggest calling `.await` on the `Future`.

This had already been introduced in #72784, but at some point they
stopped working.

Built on top of #78214, only last commit is relevant.

r? @oli-obk
2020-10-28 01:21:10 +01:00
Dylan DPC
346aeef496
Rollup merge of #78152 - spastorino:separate-unsized-locals, r=oli-obk
Separate unsized locals

Closes #71694

Takes over again #72029 and #74971

cc @RalfJung @oli-obk @pnkfelix @eddyb as they've participated in previous reviews of this PR.
2020-10-28 01:21:08 +01:00
Roxane
5229571a05 Address comments 2020-10-27 19:42:02 -04:00
bors
90e6d0d46b Auto merge of #75671 - nathanwhit:cstring-temp-lint, r=oli-obk
Uplift `temporary-cstring-as-ptr` lint from `clippy` into rustc

The general consensus seems to be that this lint covers a common enough mistake to warrant inclusion in rustc.
The diagnostic message might need some tweaking, as I'm not sure the use of second-person perspective matches the rest of rustc, but I'd like to hear others' thoughts on that.

(cc #53224).

r? `@oli-obk`
2020-10-27 22:59:13 +00:00
Tyson Nottingham
47dad31a04 rustc_span: represent line bounds with Range 2020-10-27 15:47:29 -07:00
Robert Grosse
710c1f4aca
Fix typo in comments 2020-10-27 14:23:58 -07:00
Ryan Levick
81444b2049 Remove some cruft from foreign_modules refactor 2020-10-27 20:17:48 +01:00
Santiago Pastorino
00fd703eb7
Use unsized_feature_enabled helper function 2020-10-27 14:45:42 -03:00
Santiago Pastorino
9584b00b1d
is -> are both 2020-10-27 14:45:41 -03:00
Santiago Pastorino
89eac50a87
Hide outermost_fn_param_pat, it's an internal detail 2020-10-27 14:45:40 -03:00
Santiago Pastorino
f0fe0a6eba
or -> and 2020-10-27 14:45:40 -03:00
Santiago Pastorino
497ee0e1ff
param -> parameter, pat -> pattern 2020-10-27 14:45:39 -03:00
Santiago Pastorino
bdd1b85f95
Rename within_fn_param to outermost_fn_param_pat 2020-10-27 14:45:39 -03:00
Santiago Pastorino
ca41681bf0
Do not use unsized_fn_params in patterns 2020-10-27 14:45:38 -03:00
Santiago Pastorino
58018d438b
Properly restore within_fn_param value to the previous state 2020-10-27 14:45:38 -03:00
Santiago Pastorino
953d7a64a5
Add unsized_locals to INCOMPLETE_FEATURES list 2020-10-27 14:45:28 -03:00
Santiago Pastorino
708fc3b1a2
Add unsized_fn_params feature 2020-10-27 14:45:02 -03:00
Dániel Buga
b01c74b73c Fix typo in vec_graph 2020-10-27 18:37:43 +01:00
Dániel Buga
99320b9404 Fix typos in arena comments 2020-10-27 18:14:21 +01:00
bors
07e968b640 Auto merge of #76269 - ayrtonm:function-reference-lint, r=oli-obk
added a lint against function references

this lint suggests casting function references to `*const ()`
closes #75239
r? `@RalfJung`
2020-10-27 16:32:23 +00:00
Dániel Buga
da64d07191 Fix typo in comment 2020-10-27 17:08:14 +01:00
Ryan Levick
69dc98161a Cache foreign_modules query 2020-10-27 16:21:55 +01:00
Ayrton
c791c64e84 Added suggestion to function_item_references lint and fixed warning message
Also updated tests accordingly and tweaked some wording in the lint declaration.
2020-10-27 11:04:04 -04:00
Ayrton
935fc3642a Added documentation for function_item_references lint
Added documentation for `function_item_references` lint to the rustc book and
fixed comments in the lint checker itself.
2020-10-27 11:04:04 -04:00
Ayrton
d6fa7e15d6 Fixed compiler error in lint checker triggered by associated types
When a function argument bound by `Pointer` is an associated type, we only
perform substitutions using the parameters from the callsite but don't attempt
to normalize since it may not succeed. A simplified version of the scenario that
triggered this error was added as a test case. Also fixed `Pointer::fmt` which
was being double-counted when called outside of macros and added a test case for
this.
2020-10-27 11:04:04 -04:00
Ayrton
432ebd57ef Removed test for unhandled case in function_item_references lint
Removed test for the unhandled case of calls to `fn f<T>(x: &T)` where `x` is a
function reference and is formatted as a pointer in `f`. This compiles since
`&T` implements `Pointer`, but is unlikely to occur in practice. Also tweaked
the lint's wording and modified tests accordingly.
2020-10-27 11:04:04 -04:00
Ayrton
511fe048b4 Changed lint to check for std::fmt::Pointer and transmute
The lint checks arguments in calls to `transmute` or functions that have
`Pointer` as a trait bound and displays a warning if the argument is a function
reference. Also checks for `std::fmt::Pointer::fmt` to handle formatting macros
although it doesn't depend on the exact expansion of the macro or formatting
internals. `std::fmt::Pointer` and `std::fmt::Pointer::fmt` were also added as
diagnostic items and symbols.
2020-10-27 11:04:04 -04:00
Ayrton
3214de7359 modified lint to work with MIR
Working with MIR let's us exclude expressions like `&fn_name as &dyn Something`
and `(&fn_name)()`. Also added ABI, unsafety and whether a function is variadic
in the lint suggestion, included the `&` in the span of the lint and updated the
test.
2020-10-27 11:04:04 -04:00
Ayrton
975547d475 changed lint to suggest casting to the proper function type and added a test 2020-10-27 11:04:03 -04:00
Ayrton
dd4d4e29c3 added a lint against function references
this lint suggests casting function references to `*const ()`
2020-10-27 11:04:03 -04:00
oli
888ef24c22 Address review comment 2020-10-27 14:16:23 +00:00
Oliver Scherer
c8a866ea17 Show the inline stack of MIR lints that only occur after inlining 2020-10-27 14:08:07 +00:00
bors
2a71e45411 Auto merge of #78434 - jonas-schievink:disable-miropt, r=wesleywiser
Disable "optimization to avoid load of address" in InstCombine

Same as #78195, fixes https://github.com/rust-lang/rust/issues/78192 (again).
2020-10-27 13:57:54 +00:00
bors
56d288fa46 Auto merge of #78227 - SergioBenitez:test-stdout-threading, r=m-ou-se
Capture output from threads spawned in tests

This is revival of #75172.

Original text:
> Fixes #42474.
>
> r? `@​dtolnay` since you expressed interest in this, but feel free to redirect if you aren't the right person anymore.

---

Closes #75172.
2020-10-27 11:43:18 +00:00
Jonas Schievink
0be35cf9c7 Disable "optimization to avoid load of address" in InstCombine 2020-10-27 10:59:28 +01:00
bors
20b1e05a8d Auto merge of #77502 - varkor:const-generics-suggest-enclosing-braces, r=petrochenkov
Suggest that expressions that look like const generic arguments should be enclosed in brackets

I pulled out the changes for const expressions from https://github.com/rust-lang/rust/pull/71592 (without the trait object diagnostic changes) and made some small changes; the implementation is `@estebank's.`

We're also going to want to make some changes separately to account for trait objects (they result in poor diagnostics, as is evident from one of the test cases here), such as an adaption of https://github.com/rust-lang/rust/pull/72273.

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

r? `@petrochenkov`
2020-10-27 09:25:54 +00:00
Dániel Buga
caf9131e65 Query span as late as possible 2020-10-27 10:17:01 +01:00
Aman Arora
f0ae24e100 Handle type errors in closure/generator upvar_tys
Co-authored-by: Roxane Fruytier <roxane.fruytier@hotmail.com>
2020-10-27 03:13:11 -04:00
bors
824f900a96 Auto merge of #77317 - varkor:break-diverging-value, r=nikomatsakis
Fix control flow check for breaking with diverging values

Fixes https://github.com/rust-lang/rust/issues/77156.
2020-10-27 07:10:55 +00:00
Rustin-Liu
650e3cb176 Prefer new associated numeric consts in float error messages 2020-10-27 14:14:08 +08:00
Nadrieril
766ab78a1c Simplify slice splitting a bit 2020-10-27 03:27:11 +00:00
Nadrieril
cd4c7144de Deduplicate work between splitting and subtraction
After splitting, subtraction becomes much simpler
2020-10-27 03:27:11 +00:00
Nadrieril
1fab669f8d Be honest about being able to list constructors
The test change is because we used to treat `&str` like other `&T`s, ie
as having a single constructor. That's not quite true though since we
consider `&str` constants as atomic instead of refs to `str` constants.
2020-10-27 03:09:55 +00:00
Nadrieril
db9a8480c4 Simplify specialize_constructor
Also removes the ugly caching that was introduced in #76918. It was
bolted on without deeper knowledge of the workings of the algorithm.
This commit manages to be more performant without any of the complexity.
It should be better on representative workloads too.
2020-10-27 03:08:38 +00:00
bors
28f03ac4c0 Auto merge of #78421 - JohnTitor:rollup-bq2d7fo, r=JohnTitor
Rollup of 16 pull requests

Successful merges:

 - #76635 (Add [T]::as_chunks(_mut))
 - #77703 (add system-llvm-libunwind config option)
 - #78219 (Prefer to use `print_def_path`)
 - #78298 (Add test for bad NLL higher-ranked subtype)
 - #78332 (Update description for error E0308)
 - #78342 (Use check-pass in single-use-lifetime ui tests)
 - #78347 (Add lexicographical comparison doc)
 - #78348 (Make some functions private that don't have to be public)
 - #78349 (Use its own `TypeckResults` to avoid ICE)
 - #78375 (Use ? in core/std macros)
 - #78377 (Fix typo in debug statement)
 - #78388 (Add some regression tests)
 - #78394 (fix(docs): typo in BufWriter documentation)
 - #78396 (Add compiler support for LLVM's x86_64 ERMSB feature)
 - #78405 (Fix typo in lint description)
 - #78412 (Improve formatting of hash collections docs)

Failed merges:

r? `@ghost`
2020-10-27 01:36:12 +00:00
Nadrieril
54fa70290d Unify the paths through is_useful 2020-10-27 00:49:32 +00:00
Nadrieril
c96bd28ab3 Recompute MissingConstructors when needed
This only happens in a slow (diagnostics) path, so the code clarity gain
is worth it.
2020-10-27 00:46:33 +00:00
Nadrieril
b49f90760d Pass more things through PatCtxt
This is even a perf improvement on the match-heavy benchmarks.
2020-10-27 00:46:33 +00:00
Nadrieril
cdafd1e1bd Let MissingConstructors handle the subtleties of missing constructors 2020-10-27 00:46:32 +00:00
Nadrieril
1190e7275c Cache head constructor in PatStack
Since the constructor is recomputed a lot, caching is worth it.
2020-10-27 00:46:32 +00:00
Nadrieril
833089fbc9 Unify the two kinds of specialization by adding a Wildcard ctor 2020-10-27 00:46:32 +00:00
Nadrieril
41e7ca499d Inline specialize_one_pattern 2020-10-27 00:46:32 +00:00
Nadrieril
c511955a9f Factor out the two specialization steps 2020-10-27 00:46:32 +00:00
Nadrieril
6ad9f44a50 Clarify specialization into two steps
First is checking for constructor overlap, second is extracting the
resulting fields.
2020-10-27 00:46:32 +00:00
Nadrieril
7c4f94be48 Use pat_constructor to simplify specialize_one_pattern 2020-10-27 00:46:32 +00:00
Nadrieril
feb1e13960 Split split_grouped_constructor into smaller functions 2020-10-27 00:46:32 +00:00
Esteban Küber
cd259dbd19 Do not ICE on invalid input 2020-10-26 17:42:46 -07:00
Yuki Okushi
7824d9abbd
Rollup merge of #78405 - notriddle:patch-3, r=lcnr
Fix typo in lint description
2020-10-27 08:45:27 +09:00
Yuki Okushi
46b8e46fe1
Rollup merge of #78396 - josephlr:ermsb, r=petrochenkov
Add compiler support for LLVM's x86_64 ERMSB feature

This change is needed for compiler-builtins to check for this feature
when implementing memcpy/memset. See:
  https://github.com/rust-lang/compiler-builtins/pull/365

Without this change, the following code compiles, but does nothing:
```rust
#[cfg(target_feature = "ermsb")]
pub unsafe fn ermsb_memcpy() { ... }
```

The change just does compile-time detection. I think that runtime
detection will have to come in a follow-up CL to std-detect.

Like all the CPU feature flags, this just references #44839

Signed-off-by: Joe Richey <joerichey@google.com>
2020-10-27 08:45:24 +09:00
Yuki Okushi
b72d70ef61
Rollup merge of #78377 - LeSeulArtichaut:patch-docs, r=jonas-schievink
Fix typo in debug statement
2020-10-27 08:45:14 +09:00
Yuki Okushi
6abd2a59e7
Rollup merge of #78349 - JohnTitor:issue-75962, r=davidtwco
Use its own `TypeckResults` to avoid ICE

Fixes #75962
2020-10-27 08:45:07 +09:00
Yuki Okushi
0b72ca6ea6
Rollup merge of #78332 - PoignardAzur:doc_E0308, r=camelid
Update description for error E0308

Fixes #76462

r? @camelid
2020-10-27 08:44:54 +09:00
Yuki Okushi
f3c94374b9
Rollup merge of #78219 - JohnTitor:print-def-path, r=estebank
Prefer to use `print_def_path`

Follow-up of https://github.com/rust-lang/rust/pull/71310#discussion_r415438577
2020-10-27 08:44:47 +09:00
Tyson Nottingham
df59a44fea rustc_span: improve bounds checks in byte_pos_to_line_and_col
The effect of this change is to consider edge-case spans that start or
end at the position one past the end of a file to be valid during span
hashing and encoding. This change means that these spans will be
preserved across incremental compilation sessions when they are part of
a serialized query result, instead of causing the dummy span to be used.
2020-10-26 16:34:04 -07:00
Esteban Küber
9e16213610 Suggest calling associated fn inside traits
When calling a function that doesn't exist inside of a trait's
associated `fn`, and another associated `fn` in that trait has that
name, suggest calling it with the appropriate fully-qualified path.

Expand the label to be more descriptive.

Prompted by the following user experience:
https://users.rust-lang.org/t/cannot-find-function/50663
2020-10-26 16:31:11 -07:00
bors
a4d30a7b49 Auto merge of #77876 - tmiasko:simplify-locals, r=wesleywiser
Remove unused set-discriminant statements and assignments regardless of rvalue

* Represent use counts with u32
* Unify use count visitors
* Change RemoveStatements visitor into a function
* Remove unused set-discriminant statements
* Use exhaustive match to clarify what is being optimized
* Remove unused assignments regardless of rvalue kind
2020-10-26 23:22:39 +00:00
Anthony Ramine
056942215c Implement -Z function-sections=yes|no
This lets rustc users tweak whether all functions should be put in their own
TEXT section, using whatever default value the target defines if the flag
is missing.
2020-10-26 23:26:43 +01:00
Nathan Whitaker
6ba127d3f0 Fix doctest 2020-10-26 18:19:49 -04:00
Nathan Whitaker
576eb2a30c Write docs for lint / fix review nit 2020-10-26 18:19:48 -04:00
Nathan Whitaker
1bcd2452fe Address review comments 2020-10-26 18:19:48 -04:00
Nathan Whitaker
737bfeffd2 Change to warn by default / fix typo 2020-10-26 18:19:48 -04:00
Nathan Whitaker
5643a0662a Tweak diagnostic 2020-10-26 18:19:47 -04:00
Nathan Whitaker
8b65df06ce Address review comments 2020-10-26 18:19:47 -04:00
Nathan Whitaker
8cf1b0e1ad Uplift temporary-cstring-as-ptr into rustc 2020-10-26 18:19:40 -04:00
varkor
ac1454001c Suggest expressions that look like const generic arguments should be enclosed in brackets
Co-Authored-By: Esteban Kuber <github@kuber.com.ar>
2020-10-26 21:54:45 +00:00
Tyson Nottingham
a3623e0542 rustc_span: avoid hashing ExpnId tag when using cached hash 2020-10-26 13:43:48 -07:00
Anthony Ramine
53fa22a6fb Fix some outdated comments 2020-10-26 20:57:05 +01:00
Aaron Hill
174ed0c23d
Remove tokens from foreign items in TokenStripper
Fixes #78398

I forgot to handle this case in #77255
2020-10-26 15:06:54 -04:00
bors
0da6d42f29 Auto merge of #68965 - eddyb:mir-inline-scope, r=nagisa,oli-obk
rustc_mir: track inlined callees in SourceScopeData.

We now record which MIR scopes are the roots of *other* (inlined) functions's scope trees, which allows us to generate the correct debuginfo in codegen, similar to what LLVM inlining generates.
This PR makes the `ui` test `backtrace-debuginfo` pass, if the MIR inliner is turned on by default.

Also, `#[track_caller]` is now correct in the face of MIR inlining (cc `@anp).`

Fixes #76997.

r? `@rust-lang/wg-mir-opt`
2020-10-26 18:50:22 +00:00
Michael Howell
74a9891235
Fix typo in lint description 2020-10-26 11:46:11 -07:00
Ethan Brierley
e750238404 Fix typo 2020-10-26 18:16:25 +00:00
Ethan Brierley
ad2d93da1f Apply suggested changes 2020-10-26 18:14:12 +00:00
bors
35debd4c11 Auto merge of #77975 - bjorn3:cg_clif_subtree3, r=Mark-Simulacrum
Add cg_clif as optional codegen backend

Rustc_codegen_cranelift is an alternative codegen backend for rustc based on Cranelift. It has the potential to improve compilation times in debug mode. In my experience the compile time improvements over debug mode LLVM for a clean build are about 20-30% in most cases.

This PR adds cg_clif as optional codegen backend. By default it is only enabled for `./x.py check`. It can be enabled for `./x.py build` too by adding `cranelift` to the `rust.codegen-backends` array in `config.toml`.

MCP: https://github.com/rust-lang/compiler-team/issues/270

r? `@Mark-Simulacrum`
2020-10-26 16:31:38 +00:00
Esteban Küber
28f02fbf3e Suggest calling await on method call and field access
When encountering a failing method or field resolution on a `Future`,
look at the `Output` and try the same operation on it. If successful,
suggest calling `.await` on the `Future`.

This had already been introduced in #72784, but at some point they
stopped working.
2020-10-26 08:11:43 -07:00
David Wood
27bb27f71c
resolve: private fields in tuple struct ctor diag
This commit improves the diagnostic emitted when a tuple struct is being
constructed which has private fields so that private fields are
labelled and the message is improved.

Signed-off-by: David Wood <david@davidtw.co>
2020-10-26 14:56:27 +00:00
Bastian Kauschke
60bcc58dce debug log AbstractConst::new 2020-10-26 14:56:58 +01:00
oli
7101ce9127 Deduplicate span and dbg_scope adjustment 2020-10-26 13:04:52 +00:00
oli
f8aae50469 Prefer bug! over unwrap() 2020-10-26 12:49:49 +00:00
Joe Richey
ad552bc17e
Add compiler support for LLVM's x86 ERMSB feature
This change is needed for compiler-builtins to check for this feature
when implementing memcpy/memset. See:
  https://github.com/rust-lang/compiler-builtins/pull/365

The change just does compile-time detection. I think that runtime
detection will have to come in a follow-up CL to std-detect.

Like all the CPU feature flags, this just references #44839

Signed-off-by: Joe Richey <joerichey@google.com>
2020-10-26 03:46:54 -07:00
Tomasz Miąsko
4c3e06a0ba simplify-locals: Remove unused assignments regardless of rvalue kind 2020-10-26 10:48:28 +01:00
Tomasz Miąsko
52d3782685 simplify-locals: Remove unused set-discriminant statements
Update affected ui & incremental tests to use a user declared variable
bindings instead of temporaries. The former are preserved because of
debuginfo, the latter are not.
2020-10-26 10:41:44 +01:00
Tomasz Miąsko
e1e48ae29b simplify-locals: Change RemoveStatements visitor into a function
No functionl changes intended.
2020-10-26 10:33:45 +01:00
Tomasz Miąsko
a6b64be8b5 simplify-locals: Unify use count visitors
The simplify locals implementation uses two different visitors to update
the locals use counts. The DeclMarker calculates the initial use counts.
The StatementDeclMarker updates the use counts as statements are being
removed from the block.

Replace them with a single visitor that can operate in either mode,
ensuring consistency of behaviour.

Additionally use exhaustive match to clarify what is being optimized.

No functional changes intended.
2020-10-26 10:33:39 +01:00
Tomasz Miąsko
11269536e2 simplify-locals: Represent use counts with u32 2020-10-26 10:33:31 +01:00
SNCPlay42
8bf9abbb7b always record reference to binding in match if guards 2020-10-26 09:29:50 +00:00
bors
b9a94c919b Auto merge of #78324 - RalfJung:uninhabited-statics, r=oli-obk
ensure that statics are inhabited

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

r? `@oli-obk`
2020-10-26 09:11:34 +00:00
bjorn3
ac4f7deb2f Add 'compiler/rustc_codegen_cranelift/' from commit '793d26047f994e23415f8f6bb5686ff25d3dda92'
git-subtree-dir: compiler/rustc_codegen_cranelift
git-subtree-mainline: cf798c1ec6
git-subtree-split: 793d26047f
2020-10-26 09:53:27 +01:00
bjorn3
cf798c1ec6 Add support for using cg_clif to bootstrap rustc 2020-10-26 09:52:59 +01:00