Commit graph

3521 commits

Author SHA1 Message Date
Joakim Åkerblom
1d03648e67 Fix spelling in documentation for error E0207
I have trouble parsing the the wording "type parameter parameter".
2021-01-24 20:31:42 +01:00
Vadim Petrochenkov
bd07165690 parser: Collect tokens for values in key-value attributes 2021-01-24 17:11:56 +03:00
Mara Bos
a730970dff Only call span.rust_2021() when necessary. 2021-01-24 14:19:05 +01:00
Ralf Jung
48f9dbfd59 clean up some const error reporting around promoteds 2021-01-24 13:34:34 +01:00
Dániel Buga
f8416faaaf Clean up dominators_given_rpo 2021-01-24 13:32:18 +01:00
bors
72c7b70267 Auto merge of #80838 - nagisa:nagisa/stack-probe-type, r=cuviper
Target stack-probe support configurable finely

This adds capability to configure the target's stack probe support in a
more precise manner than just on/off. In particular now we allow
choosing between always inline-asm, always call or either one of those
depending on the LLVM version.

Note that this removes the ability to turn off the generation of the
stack-probe attribute. This is valid to replace it with inline-asm for all targets because
`probe-stack="inline-asm"` will not generate any machine code on targets
that do not currently support stack probes. This makes support for stack
probes on targets that don't have any right now automatic with LLVM
upgrades in the future.

(This is valid to do based on the fact that clang unconditionally sets
this attribute when `-fstack-clash-protection` is used, AFAICT)

cc #77885
r? `@cuviper`
2021-01-24 09:44:42 +00:00
bors
85e355ea9b Auto merge of #80919 - cjgillot:defkey-span, r=oli-obk
Generate metadata by iterating on DefId instead of traversing the HIR tree 1/N

Sample from #80347.
2021-01-24 06:51:17 +00:00
bors
446cbc9db0 Auto merge of #80594 - bjorn3:abi_refactor3, r=petrochenkov
Various ABI refactorings

This includes changes to the rust abi and various refactorings that will hopefully make it easier to use the abi handling infrastructure of rustc in cg_clif. There are several refactorings that I haven't done. I am opening this draft PR to check that I haven't broken any non x86_64 architectures.

r? `@ghost`
2021-01-24 02:59:14 +00:00
est31
14aa12fcc2 Replace version_check dependency with own version parsing code
This gives compiler maintainers a better degree of control
over how the version gets parsed and is a good way to ensure
that there are no changes of behaviour in the future.

Also, issue a warning if the version is invalid instead of erroring
so that we stay forwards compatible with possible future changes
of the versioning scheme.

Last, this improves the present test a little.
2021-01-24 01:56:54 +01:00
bors
26c2d1f408 Auto merge of #79811 - Aaron1011:expn-data-disambig, r=petrochenkov
Add disambiugator to ExpnData

I still need to write a bunch of comments. Opening to see how bad the perf impact is.

cc https://github.com/rust-lang/rust/issues/79560
2021-01-24 00:10:20 +00:00
Aaron Hill
3540f9396a
Add disambiugator to ExpnData
Due to macro expansion, its possible to end up with two distinct
`ExpnId`s that have the same `ExpnData` contents. This violates the
contract of `HashStable`, since two unequal `ExpnId`s will end up with
equal `Fingerprint`s.

This commit adds a `disambiguator` field to `ExpnData`, which is used to
force two otherwise-equivalent `ExpnData`s to be distinct.
2021-01-23 15:41:17 -05:00
Jonas Schievink
be3723c488
Rollup merge of #81298 - lcnr:big-money-big-prices, r=oli-obk
replace RefCell with Cell in FnCtxt

small cleanup
2021-01-23 20:16:17 +01:00
Jonas Schievink
81647c627a
Rollup merge of #81275 - jyn514:time-render, r=wesleywiser
Fix <unknown> queries and add more timing info to render_html

Closes https://github.com/rust-lang/rust/issues/81251.

##  Fix `<unknown>` queries

This happened because `alloc_query_strings` was never called.

##  Add more timing info to render_html

This still has some issues I'm not sure how to work out:

- `create_renderer` and `renderer_after_krate` aren't shown by default.
  I want something like `verbose_generic_activity_with_arg`, but it doesn't exist.

I'm also not sure how to show activities that aren't on by default - I
tried `-Z self-profile -Z self-profile-args=all`, but it didn't show up.

r? `@wesleywiser`
2021-01-23 20:16:10 +01:00
Jonas Schievink
7038bb1eb2
Rollup merge of #81252 - jyn514:resolve-timing, r=petrochenkov
Add more self-profile info to rustc_resolve

The idea is to help me find out where the time is being spent in compiling the docs for `windows-rs`: https://github.com/microsoft/windows-rs/issues/420#issuecomment-764991646
2021-01-23 20:16:09 +01:00
Jonas Schievink
fcf11296f6
Rollup merge of #81249 - cjgillot:issue-79537, r=oli-obk
Lower closure prototype after its body.

Fixes #79537.

r? `@Mark-Simulacrum`
2021-01-23 20:16:07 +01:00
Jonas Schievink
3a3470bf04
Rollup merge of #81243 - osa1:fix_80742_2, r=RalfJung
mir: Improve size_of handling when arg is unsized

As discussed on Zulip with `@RalfJung.`
2021-01-23 20:16:04 +01:00
Jonas Schievink
57d655368b
Rollup merge of #81130 - pierwill:edit-depnode, r=jyn514
Edit rustc_middle::dep_graph module documentation

This is similar to work approved and then closed in https://github.com/rust-lang/rust/pull/80325 due to a bad rebase.
2021-01-23 20:16:00 +01:00
Jonas Schievink
3382771dfd
Rollup merge of #81072 - RalfJung:place-ref-ty, r=oli-obk
PlaceRef::ty: use method call syntax
2021-01-23 20:15:59 +01:00
bjorn3
fa12fdbc29 Fix review comments 2021-01-23 17:55:39 +01:00
oli
209889ddc1 Leave some notes for future changes to the MIR opt level of mir inlining 2021-01-23 16:51:23 +00:00
oli
0491e74dd9 Make sure that const prop does not produce unsilenceable lints after inlining 2021-01-23 16:51:23 +00:00
oli
b8727e2d60 Prevent query cycles during inlining 2021-01-23 16:51:22 +00:00
Joshua Nelson
3b8f1b7883 Make -Z time-passes less noisy
- Add the module name to `pre_AST_expansion_passes` and don't make it a
  verbose event (since it normally doesn't take very long, and it's
  emitted many times)
- Don't make the following rustdoc events verbose; they're emitted many times.
  + build_extern_trait_impl
  + build_local_trait_impl
  + build_primitive_trait_impl
  + get_auto_trait_impls
  + get_blanket_trait_impls
- Remove `get_auto_trait_and_blanket_synthetic_impls`; it's wholly
  covered by get_{auto,blanket}_trait_impls and not very useful.
2021-01-23 11:44:46 -05:00
Joshua Nelson
ca72f9ed70 Calculate self-profile strings in Compiler::enter instead in codegen
This avoids each tool having to separately find and call
`self_profile_alloc_strings`.

- Don't compute the global context if it hasn't yet been computed

  This avoids giving extraneous errors about unresolved names if an error
  occurs during parsing.
2021-01-23 11:42:15 -05:00
bors
4d0dd02ee0 Auto merge of #80579 - RalfJung:no-fallible-promotion, r=oli-obk
avoid promoting division, modulo and indexing operations that could fail

For division, `x / y` will still be promoted if `y` is a non-zero integer literal; however, `1/(1+1)` will not be promoted any more.

While at it, also see if we can reject promoting floating-point arithmetic (which are [complicated](https://github.com/rust-lang/unsafe-code-guidelines/issues/237) so maybe we should not promote them).

This will need a crater run to see if there's code out there that relies on these things being promoted.

If we can land this, promoteds in `fn`/`const fn` cannot fail to evaluate any more, which should let us do some simplifications in codegen/Miri!

Cc https://github.com/rust-lang/rfcs/pull/3027
Fixes https://github.com/rust-lang/rust/issues/61821
r? `@oli-obk`
2021-01-23 13:19:04 +00:00
Camille GILLOT
97ee7c7e5a Allow to query the HIR crate node. 2021-01-23 13:58:09 +01:00
Camille GILLOT
89360931f2 Fix proc macro crate encoding. 2021-01-23 13:57:43 +01:00
Camille GILLOT
4eb0bbd2a8 Filter stability. 2021-01-23 13:57:17 +01:00
Camille GILLOT
4e60ecf783 Iterate on deprecation. 2021-01-23 13:56:50 +01:00
Camille GILLOT
4468473e1b Iterate on const_stability. 2021-01-23 13:56:24 +01:00
Camille GILLOT
f1a7e1df3a Iterate on stability. 2021-01-23 13:55:57 +01:00
Camille GILLOT
7a5620c63a Iterate DefId to encode expn_that_defined. 2021-01-23 13:55:35 +01:00
Camille GILLOT
293e885daa Iterate DefId to encode attributes. 2021-01-23 13:54:22 +01:00
Camille GILLOT
f1bf6d0e48 Iterate DefId to encode visibility. 2021-01-23 13:53:26 +01:00
Camille GILLOT
a185cdbc59 Iterate to encode def_kind. 2021-01-23 13:51:00 +01:00
Camille GILLOT
c58a6fa422 Iterate DefId to encode spans. 2021-01-23 13:44:02 +01:00
Camille GILLOT
0b6c9e9f88 Encode DefKind directly. 2021-01-23 13:42:56 +01:00
Camille GILLOT
064a351953 Infallible version of def_span. 2021-01-23 13:35:22 +01:00
bjorn3
c3367dbc6f Add some comments to PassMode 2021-01-23 12:57:35 +01:00
oli
14f39aa81a Do not allow arbitrary mutable references in static mut, just keep with the existing exceptions 2021-01-23 11:33:45 +00:00
oli
00e62fabf1 Adjust wording of a diagnostic 2021-01-23 11:33:45 +00:00
oli
d118021f8b Permit mutable references in all const contexts 2021-01-23 11:33:45 +00:00
Bastian Kauschke
688cf6406a replace RefCell with Cell in FnCtxt 2021-01-23 11:47:38 +01:00
bjorn3
794880c6b5 Don't provide backend_optimization_level query for extern crates 2021-01-23 11:11:51 +01:00
bjorn3
a93dace55c Never create an temporary PassMode::Direct when it is not a valid pass mode for a type 2021-01-23 10:30:39 +01:00
bjorn3
ba484de538 Move some code around 2021-01-23 10:30:39 +01:00
bjorn3
da0309c711 Use PassMode::Pair by default for Abi::ScalarPair for all abi's and in return position
Abi::ScalarPair is only ever used for types that don't have a stable
layout anyway so this doesn't break any FFI. It does however reduce the
amount of special casing on the abi outside of the code responsible for
abi specific adjustments to the pass mode.
2021-01-23 10:30:38 +01:00
bjorn3
2bde7d21cc Remove unused dependency 2021-01-23 10:30:38 +01:00
bors
1986b58c64 Auto merge of #80065 - b-naber:parse-angle-arg-diagnostics, r=petrochenkov
Improve diagnostics when parsing angle args

https://github.com/rust-lang/rust/pull/79266 introduced parsing of generic arguments in associated type constraints, this however resulted in possibly very confusing error messages in cases in which closing angle brackets were missing such as in `Vec<(u32, _, _) = vec![]`, which outputs an incorrectly parsed equality constraint error, as noted by `@cynecx.`

This PR tries to provide better error messages in such cases.

r? `@petrochenkov`
2021-01-23 06:27:21 +00:00
Dhruv Jauhar
e94cf57c3e Make functional record update/struct update syntax works inside closures when feature capture_disjoint_fields is enabled 2021-01-22 23:10:24 -05:00
bors
693ed05bbd Auto merge of #81017 - Aaron1011:collect-trailing-token, r=petrochenkov
Refactor token collection to capture trailing token immediately

Split out from https://github.com/rust-lang/rust/pull/80689 - when we start capturing more information about attribute targets, we'll need to know in advance if we're capturing a trailing token or not.

r? `@ghost`
2021-01-23 00:42:37 +00:00
Tomasz Miąsko
99a1dea1b7 Do not mark unit variants as used when in path pattern
Record that we are processing a pattern so that code responsible for
handling path resolution can correctly decide whether to mark it as
used or not.
2021-01-23 00:00:00 +00:00
pierwill
b29353af09 Edit rustc_middle::dep_graph module documentation
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
Co-authored-by: Camelid <camelidcamel@gmail.com>
2021-01-22 15:15:05 -08:00
Joshua Nelson
0679a4cd93 Remove special casing of rustdoc in rustc_lint
This is no longer necessary now that rustdoc doesn't run
everybody_loops.
2021-01-22 14:50:21 -05:00
Dániel Buga
f29b32983d Fix formatting 2021-01-22 18:55:37 +01:00
Dániel Buga
aa4f5833e1 Only query associated_items once 2021-01-22 18:36:33 +01:00
Dániel Buga
ee639de007 Only guess span if absolutely necessary 2021-01-22 18:36:33 +01:00
Dániel Buga
d63b278c2f Only scan through assoc items once in check_impl_items_against_trait 2021-01-22 18:36:30 +01:00
flip1995
e25959b417
Make more traits of the From/Into family diagnostic items
Following traits are now diagnostic items:
- `From` (unchanged)
- `Into`
- `TryFrom`
- `TryInto`

This also adds symbols for those items:
- `into_trait`
- `try_from_trait`
- `try_into_trait`
2021-01-22 18:07:00 +01:00
b-naber
728d257839 improve diagnostics for angle args 2021-01-22 17:07:27 +01:00
bors
b814b63983 Auto merge of #81271 - m-ou-se:rollup-xv7gq3w, r=m-ou-se
Rollup of 10 pull requests

Successful merges:

 - #80573 (Deny rustc::internal lints for rustdoc and clippy)
 - #81173 (Expand docs on Iterator::intersperse)
 - #81194 (Stabilize std::panic::panic_any.)
 - #81202 (Don't prefix 0x for each segments in `dbg!(Ipv6)`)
 - #81225 (Make 'docs' nullable in rustdoc-json output)
 - #81227 (Remove doctree::StructType)
 - #81233 (Document why not use concat! in dbg! macro)
 - #81236 (Gracefully handle loop labels missing leading `'` in different positions)
 - #81241 (Turn alloc's force_expr macro into a regular macro_rules.)
 - #81242 (Enforce statically that `MIN_NON_ZERO_CAP` is calculated at compile time)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-01-22 16:04:36 +00:00
Mara Bos
3682a06dcf
Rollup merge of #81236 - estebank:everybody-loop-now, r=oli-obk
Gracefully handle loop labels missing leading `'` in different positions

Fix #81192.

* Account for labels when suggesting `loop` instead of `while true`
* Suggest `'a` when given `a` only when appropriate
* Add loop head span to hir
* Tweak error for invalid `break expr`
* Add more misspelled label tests
* Avoid emitting redundant "unused label" lint
* Parse loop labels missing a leading `'`

Each commit can be reviewed in isolation.
2021-01-22 14:30:19 +00:00
bors
f2de221b00 Auto merge of #81101 - tmiasko:combine-now, r=nagisa
Combine instructions immediately
2021-01-22 13:10:48 +00:00
bors
bbc01bb624 Auto merge of #80558 - lcnr:gat-variance, r=matthewjasper
require gat substs to be invariant

fixes #69184, fixes #80766

r? `@matthewjasper` probably
2021-01-22 10:12:05 +00:00
Ralf Jung
f62cecd807 do promote array indexing if we know it is in-bounds 2021-01-22 10:36:25 +01:00
Ralf Jung
69a997bef2 update const_err description 2021-01-22 10:21:52 +01:00
Ralf Jung
5be27b7a70 avoid promoting division, modulo and indexing operations that could fail 2021-01-22 10:21:49 +01:00
Dániel Buga
9988821a04 Move missing_item check inside condition 2021-01-22 08:22:15 +01:00
Dániel Buga
58a90de9ad No peeking 2021-01-22 08:14:25 +01:00
Dániel Buga
3e9f27dadf Remove unnecessary closure 2021-01-22 08:06:01 +01:00
bors
25f39fe802 Auto merge of #81135 - jyn514:no-backticks, r=flip1995
Fix formatting for removed lints

- Don't add backticks for the reason a lint was removed. This is almost
never a code block, and when it is the backticks should be in the reason
itself.
- Don't assume clippy is the only tool that needs to be checked for
backwards compatibility

I split this out of https://github.com/rust-lang/rust/pull/80527/ because it kept causing tests to fail, and it's a good change to have anyway.

r? `@flip1995`
2021-01-22 06:13:19 +00:00
Esteban Küber
9e82329c8f Do not suggest using a break label when one is already present 2021-01-21 21:43:29 -08:00
Esteban Küber
7698807770 Fix clippy and comment 2021-01-21 21:43:28 -08:00
Esteban Küber
8c5dafdcb8 Parse loop labels missing a leading '
When encountering the following typo:

```rust
a: loop { break 'a; }
```

provide an appropriate suggestion.
2021-01-21 21:41:47 -08:00
Esteban Küber
74ddaf000c Avoid emitting redundant "unused label" lint 2021-01-21 21:41:46 -08:00
Esteban Küber
8a13abba1d Tweak error for invalid break expr
Point at loop head on invalid `break expr`.
Suggest removing `expr` or using label if available.
2021-01-21 21:41:46 -08:00
Esteban Küber
060dba67b7 Add loop head span to hir 2021-01-21 21:41:46 -08:00
Esteban Küber
a701ff981d Suggest 'a when given a only when appropriate
When encountering a name `a` that isn't resolved, but a label `'a` is
found in the current ribs, only suggest `'a` if this name is the value
expression of a `break` statement.

Solve FIXME.
2021-01-21 21:41:46 -08:00
Esteban Küber
707ce2b798 Account for labels when suggesting loop instead of while true 2021-01-21 21:41:46 -08:00
Aaron Hill
ccfc292999
Refactor token collection to capture trailing token immediately 2021-01-22 00:33:03 -05:00
bors
dc1eee2f25 Auto merge of #81177 - Aaron1011:fix/force-capture-tokens, r=petrochenkov
Force token collection to run when parsing nonterminals

Fixes #81007

Previously, we would fail to collect tokens in the proper place when
only builtin attributes were present. As a result, we would end up with
attribute tokens in the collected `TokenStream`, leading to duplication
when we attempted to prepend the attributes from the AST node.

We now explicitly track when token collection must be performed due to
nomterminal parsing.
2021-01-22 02:42:38 +00:00
Dan Gohman
9abcfa55c3 Don't link with --export-dynamic on wasm32-wasi
Remove --export-dynamic from the link arguments on the wasm32-wasi
target, as it emits spurious exports and increases code size.

Leave it in place for wasm32-unknown-unknown and
wasm32-unknown-emscripten. Even though it isn't a great solution
there, users are likely depending on its behavior there.
2021-01-21 16:13:43 -08:00
Joshua Nelson
5f74ab4969 Add more self-profile info to rustc_resolve 2021-01-21 18:15:17 -05:00
Camille GILLOT
3f42abec58 Lower closure prototype after its body. 2021-01-21 22:59:07 +01:00
Ömer Sinan Ağacan
e3faeb486a mir: Improve size_of handling when arg is unsized 2021-01-21 22:17:05 +03:00
bors
65767e5653 Auto merge of #81122 - tmiasko:no-drop, r=davidtwco
Visit only terminators when removing unneeded drops

No functional changes intended
2021-01-21 17:02:49 +00:00
Bastian Kauschke
f32a6acdab require gat substs to be invariant 2021-01-21 17:35:44 +01:00
Yuki Okushi
2ebc036220
Rollup merge of #81187 - eltociear:patch-6, r=jonas-schievink
Fix typo in counters.rs

formating -> formatting
2021-01-21 20:04:55 +09:00
Yuki Okushi
bc950c85c5
Rollup merge of #81185 - osa1:fix_80742, r=oli-obk
Fix ICE in mir when evaluating SizeOf on unsized type

Not quite ready yet. This tries to fix #80742 as discussed on [Zulip topic][1],
by using `delay_span_bug`.

I don't understand what `delay_span_bug` does. It seems like my error message
is never used. With this patch, in this program:

```rust
#![allow(incomplete_features)]
#![feature(const_evaluatable_checked)]
#![feature(const_generics)]

use std::fmt::Debug;
use std::marker::PhantomData;
use std::mem::size_of;

struct Inline<T>
where
    [u8; size_of::<T>() + 1]: ,
{
    _phantom: PhantomData<T>,
    buf: [u8; size_of::<T>() + 1],
}

impl<T> Inline<T>
where
    [u8; size_of::<T>() + 1]: ,
{
    pub fn new(val: T) -> Inline<T> {
        todo!()
    }
}

fn main() {
    let dst = Inline::<dyn Debug>::new(0); // line 27
}
```

these errors are printed, both for line 27 (annotated line above):

- "no function or associated item named `new` found for struct `Inline<dyn
  Debug>` in the current scope"
- "the size for values of type `dyn Debug` cannot be known at compilation time"

Second error makes sense, but I'm not sure about the first one and why it's
even printed.

Finally, I'm not sure about the span passing in `const_eval`.

[1]: https://rust-lang.zulipchat.com/#narrow/stream/269128-miri/topic/Help.20fixing.20.2380742
2021-01-21 20:04:53 +09:00
Yuki Okushi
cd0c54abb9
Rollup merge of #81178 - tmiasko:no-landing-pads, r=oli-obk
Visit only terminators when removing landing pads

No functional changes intended
2021-01-21 20:04:48 +09:00
Yuki Okushi
a77c1d836a
Rollup merge of #81046 - rylev:unknown-external-crate, r=estebank
Improve unknown external crate error

This improves error messages when unknown items in the crate root are encountered.

Fixes #63799

r? ```@estebank```
2021-01-21 20:04:45 +09:00
Aaron Hill
11b1e37016
Force token collection to run when parsing nonterminals
Fixes #81007

Previously, we would fail to collect tokens in the proper place when
only builtin attributes were present. As a result, we would end up with
attribute tokens in the collected `TokenStream`, leading to duplication
when we attempted to prepend the attributes from the AST node.

We now explicitly track when token collection must be performed due to
nomterminal parsing.
2021-01-20 18:09:32 -05:00
bors
a4cbb44ae2 Auto merge of #81118 - ojeda:metadata-obj, r=nagisa
Skip linking if it is not required

This allows to use `--emit=metadata,obj` and other metadata + non-link combinations.

Fixes #81117.
2021-01-20 07:15:40 +00:00
Ramon de C Valle
737867618b Fix sysroot option not being honored across rustc
Change link_sanitizer_runtime() to check if the sanitizer library exists
in the specified/session sysroot, and if it doesn't exist, use the
default sysroot.
2021-01-19 21:32:39 -08:00
Simonas Kazlauskas
1b15ec656b Use a call probe on the x86_64-uefi target
Fixes #81196
2021-01-20 01:37:45 +02:00
bors
c5a96fb797 Auto merge of #80957 - tgnottingham:direct_serialize_depgraph, r=michaelwoerister
Serialize dependency graph directly from DepGraph

Reduce memory usage by serializing dep graph directly from `DepGraph`,
rather than copying it into `SerializedDepGraph` and serializing that.
2021-01-19 19:36:41 +00:00
Ömer Sinan Ağacan
3fb53c2c85 Fix ICE in mir when evaluating SizeOf on unsized type
Fixes #80742
2021-01-19 18:35:21 +03:00
Ikko Ashimine
203df1764c
Fix typo in counters.rs
formating -> formatting
2021-01-19 23:42:18 +09:00
bors
f09fb488f7 Auto merge of #81186 - GuillaumeGomez:rollup-y2d04g9, r=GuillaumeGomez
Rollup of 8 pull requests

Successful merges:

 - #80382 (Improve search result tab handling)
 - #81112 (Remove unused alloc::std::ops re-export.)
 - #81115 (BTreeMap: prefer bulk_steal functions over specialized ones)
 - #81147 (Fix structured suggestion for explicit `drop` call)
 - #81161 (Remove inline script tags)
 - #81164 (Fix typo in simplify.rs)
 - #81166 (remove some outdated comments regarding  debug assertions)
 - #81168 (Fixes #81109 - Typo in pointer::wrapping_sub)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-01-19 12:04:22 +00:00
Guillaume Gomez
2f1d5c4d40
Rollup merge of #81164 - eltociear:patch-5, r=jonas-schievink
Fix typo in simplify.rs

prexisting -> preexisting
2021-01-19 10:28:00 +01:00
Guillaume Gomez
348997a05f
Rollup merge of #81147 - estebank:drop-suggestion, r=varkor
Fix structured suggestion for explicit `drop` call
2021-01-19 10:27:56 +01:00
bors
47121d6d88 Auto merge of #81110 - LeSeulArtichaut:fix-unused-unsafe-label, r=RalfJung
Fix `unused_unsafe` label with `unsafe_block_in_unsafe_fn

Previously, the following code:

```rust
#![feature(unsafe_block_in_unsafe_fn)]

unsafe fn foo() {
    unsafe { unsf() }
}

unsafe fn unsf() {}
```

Would give the following warning:

```
warning: unnecessary `unsafe` block
 --> src/lib.rs:4:5
  |
4 |     unsafe { unsf() }
  |     ^^^^^^ unnecessary `unsafe` block
  |
  = note: `#[warn(unused_unsafe)]` on by default
```
which doesn't point out that the block is in an `unsafe fn`.

Tracking issue: #71668
cc #79208
2021-01-19 08:59:37 +00:00
bors
94e6ea9fc9 Auto merge of #81103 - zackmdavis:comma_trail, r=davidtwco
don't suggest erroneous trailing comma after `..`

In #76612, suggestions were added for missing fields in patterns. However, the suggestions are being inserted just at the end
of the last field in the pattern—before any trailing comma after the last field. This resulted in the "if you don't care about missing fields" suggestion to recommend code with a trailing comma after the field ellipsis (`..,`), which is actually not legal ("`..` must be at the end and cannot have a trailing comma")!

Incidentally, the doc-comment on `error_unmentioned_fields` was using `you_cant_use_this_field` as an example field name (presumably copy-paste inherited from the description of Issue #76077), but the present author found this confusing, because unmentioned fields aren't necessarily unusable.

The suggested code in the diff this commit introduces to `destructuring-assignment/struct_destructure_fail.stderr` doesn't work, but it didn't work beforehand, either (because of the "found reserved identifier `_`" thing), so you can't really call it a regression; it could be fixed in a separate PR.

Resolves #78511.

r? `@davidtwco` or `@estebank`
2021-01-19 02:54:58 +00:00
bors
4ba1aaf35f Auto merge of #81042 - sasurau4:fix/unclear-error-with-trait, r=estebank
Add suggestion for impl_candidates with E0283

Fix #42226
2021-01-19 00:00:21 +00:00
bors
d98d2f57d9 Auto merge of #80707 - oli-obk:stability_hole_const_intrinsics, r=RalfJung
Stability oddity with const intrinsics

cc `@RalfJung`

In https://github.com/rust-lang/rust/pull/80699#discussion_r551495670 `@usbalbin` realized we accepted some intrinsics as `const` without a `#[rustc_const_(un)stable]` attribute. I did some digging, and that example works because intrinsics inherit their stability from their parents... including `#[rustc_const_(un)stable]` attributes. While we may want to fix that (not sure, wasn't there just a MCPed PR that caused this on purpose?), we definitely want tests for it, thus this PR adding tests and some fun tracing statements.
2021-01-18 20:54:36 +00:00
LeSeulArtichaut
50e1ae15e9 Use ty::{IntTy,UintTy,FloatTy} in rustc 2021-01-18 21:09:30 +01:00
LeSeulArtichaut
933bb18956 Use rustc_type_ir::{IntTy,UintTy,FloatTy} instead of the rustc_ast` ones in types 2021-01-18 21:09:23 +01:00
LeSeulArtichaut
0724573448 Move a few more types to rustc_type_ir 2021-01-18 21:06:12 +01:00
Camelid
def0e9b8a4 Fix ICE with ReadPointerAsBytes validation error 2021-01-18 11:51:18 -08:00
Cameron Steffen
21fb586c0c Query for TypeckResults in LateContext::qpath_res
Actually fulfills the documented guarantees.
2021-01-18 13:38:14 -06:00
Cameron Steffen
63a1eeea23 Reset LateContext enclosing body in nested items
Prevents LateContext::maybe_typeck_results() from returning data in a
nested item without a body. Consequently, LateContext::qpath_res is less
likely to ICE when called in a nested item. Would have prevented
rust-lang/rust-clippy#4545, presumably.
2021-01-18 13:38:14 -06:00
bors
5e91c4ecc0 Auto merge of #81165 - KodrAus:rollup-s7llxis, r=KodrAus
Rollup of 12 pull requests

Successful merges:

 - #81038 (Update Clippy)
 - #81071 (rustc_parse_format: Fix character indices in find_skips)
 - #81100 (prevent potential bug in `encode_with_shorthand`.)
 - #81105 (Initialize a few variables directly)
 - #81116 (ConstProp: Copy body span instead of querying it)
 - #81121 (Avoid logging the whole MIR body in SimplifyCfg)
 - #81123 (Update cmp.rs)
 - #81125 (Add track_caller to .steal())
 - #81128 (validation test: turn some const_err back into validation failures)
 - #81131 (Edit rustc_middle::ty::cast docs)
 - #81142 (Replace let Some(..) = with .is_some())
 - #81153 (Remove unused linkcheck exceptions)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-01-18 14:36:30 +00:00
Daiki Ihara
db95b5ca9b Add suggestion for impl_candidates with E0283
Update compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs

Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com>
2021-01-18 21:57:15 +09:00
Tomasz Miąsko
508eec49e9 Combine instructions immediately
No functional changes intended
2021-01-18 13:15:27 +01:00
Tomasz Miąsko
a9292d871c Remove disabled transformation from instcombine 2021-01-18 13:15:27 +01:00
Ashley Mannix
0068358ba4
Rollup merge of #81142 - wcampbell0x2a:replace-Some-with-is-some, r=jonas-schievink
Replace let Some(..) = with .is_some()
2021-01-18 21:53:41 +10:00
Ashley Mannix
d3cc598a02
Rollup merge of #81131 - pierwill:edit-rustc_middle-cast, r=varkor
Edit rustc_middle::ty::cast docs

Link to RFC 401 and add missing punctuation.
2021-01-18 21:53:40 +10:00
Ashley Mannix
f82100eeed
Rollup merge of #81125 - jyn514:track-caller, r=lcnr
Add track_caller to .steal()

Before:

```
thread 'rustc' panicked at 'attempt to read from stolen value', /home/joshua/rustc/compiler/rustc_data_structures/src/steal.rs:43:15
```

After:

```
thread 'rustc' panicked at 'attempt to steal from stolen value', compiler/rustc_mir/src/transform/mod.rs:423:25
```

r? `@lcnr`
2021-01-18 21:53:35 +10:00
Ashley Mannix
e1d70bc697
Rollup merge of #81121 - tmiasko:simplify-cfg-no-dbg, r=jonas-schievink
Avoid logging the whole MIR body in SimplifyCfg
2021-01-18 21:53:31 +10:00
Ashley Mannix
064e47b99e
Rollup merge of #81116 - bugadani:body-span, r=wesleywiser
ConstProp: Copy body span instead of querying it
2021-01-18 21:53:30 +10:00
Ashley Mannix
b4defec768
Rollup merge of #81105 - LingMan:init_directly, r=nagisa
Initialize a few variables directly

Currently they are declared as `mut`, get initialized to a default value, and
then possibly overwritten.

By initializing to the final value directly, they don't need to be `mut` and
it's clear that they don't get mutated elsewhere later on.
2021-01-18 21:53:28 +10:00
Ashley Mannix
d3ff9ac8e8
Rollup merge of #81100 - lcnr:encode_with_shorthand, r=oli-obk
prevent potential bug in `encode_with_shorthand`.

see https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Remove.20PredicateKind.20in.20favor.20of.20only.20Bin.E2.80.A6.20compiler-team.23397/near/223012169
2021-01-18 21:53:26 +10:00
Ashley Mannix
c7ca540da2
Rollup merge of #81071 - osa1:fix_81006, r=estebank
rustc_parse_format: Fix character indices in find_skips

Fixes #81006
2021-01-18 21:53:24 +10:00
Ikko Ashimine
222e0e4fe2
Fix typo in simplify.rs
prexisting -> preexisting
2021-01-18 20:52:10 +09:00
bors
66eb982166 Auto merge of #81015 - jyn514:feature-gate-ptr, r=camelid
Feature-gate `pointer` and `reference` in intra-doc links

r? `@camelid`

Addresses (but does not close) https://github.com/rust-lang/rust/issues/80896.
2021-01-18 11:35:19 +00:00
oli
5bac1c9229 Only inherit const stability for methods of impl const Trait blocks 2021-01-18 11:07:35 +00:00
Ryan Levick
d829e40c7b Improve unknown external crate error 2021-01-18 12:05:07 +01:00
bors
86e0ff47a0 Auto merge of #80995 - tmandry:instrument-method-checker, r=lcnr
Add tracing instrumentation to method typeck

I was recently digging into how this code works, and this instrumentation was helpful.
2021-01-18 08:39:31 +00:00
bors
0677d97293 Auto merge of #80865 - oliviacrain:proj_based, r=RalfJung
Use PlaceRef projection abstractions more consistently in rustc_mir

PlaceRef contains abstractions for dealing with the `projections` array. This PR uses these abstractions more consistently within the `rustc_mir` crate.

See associated issue: rust-lang/rust#80647.

r? `@RalfJung`
2021-01-18 05:44:40 +00:00
Esteban Küber
70a43e07f6 Fix structured suggestion for explicit drop call 2021-01-17 16:48:52 -08:00
wcampbell
e23acc341c
Replace let Some(..) = with .is_some()
Signed-off-by: wcampbell <wcampbell1995@gmail.com>
2021-01-17 19:06:12 -05:00
Tomasz Miąsko
96e9562a7e Visit only terminators when removing landing pads
No functional changes intended
2021-01-18 00:00:00 +00:00
Joshua Nelson
77b5ced3aa Fix formatting for removed lints
- Don't add backticks for the reason a lint was removed. This is almost
never a code block, and when it is the backticks should be in the reason
itself.
- Don't assume clippy is the only tool that needs to be checked for
backwards compatibility
2021-01-17 16:18:02 -05:00
bors
4253153db2 Auto merge of #80679 - jackh726:predicate-kind-take2, r=lcnr
Remove PredicateKind and instead only use Binder<PredicateAtom>

Originally brought up in https://github.com/rust-lang/rust/pull/76814#discussion_r546858171

r? `@lcnr`
2021-01-17 20:49:11 +00:00
Joshua Nelson
fc53594756 Feature-gate pointer and reference in intra-doc links
- Only feature gate associated items
- Add docs to unstable book
2021-01-17 15:27:35 -05:00
pierwill
34debb640b Edit rustc_middle::ty::cast docs
Link to RFC 401 and add missing punctuation.
2021-01-17 11:30:18 -08:00
bors
1f0fc02cc8 Auto merge of #80524 - jyn514:unknown-tool-lints, r=flip1995,matthewjasper
Don't make tools responsible for checking unknown and renamed lints

Previously, clippy (and any other tool emitting lints) had to have their
own separate UNKNOWN_LINTS pass, because the compiler assumed any tool
lint could be valid. Now, as long as any lint starting with the tool
prefix exists, the compiler will warn when an unknown lint is present.

This may interact with the unstable `tool_lint` feature, which I don't entirely understand, but it will take the burden off those external tools to add their own lint pass, which seems like a step in the right direction to me.

- Don't mark `ineffective_unstable_trait_impl` as an internal lint
- Use clippy's more advanced lint suggestions
- Deprecate the `UNKNOWN_CLIPPY_LINTS` pass (and make it a no-op)
- Say 'unknown lint `clippy::x`' instead of 'unknown lint x'

This is tested by existing clippy tests. When https://github.com/rust-lang/rust/pull/80527 merges, it will also be tested in rustdoc tests. AFAIK there is no way to test this with rustc directly.
2021-01-17 17:52:01 +00:00
Jack Huey
c4376ba24a
Whitespace and typo 2021-01-17 12:50:04 -05:00
Jack Huey
d797a85491 Add comment about Encodable/Decodable impl 2021-01-17 12:32:05 -05:00
Joshua Nelson
394d7018b9 Add track_caller to .steal()
Before:

```
thread 'rustc' panicked at 'attempt to read from stolen value', /home/joshua/rustc/compiler/rustc_data_structures/src/steal.rs:43:15
```

After:

```
thread 'rustc' panicked at 'attempt to steal from stolen value', compiler/rustc_mir/src/transform/mod.rs:423:25
```
2021-01-17 12:27:20 -05:00
LeSeulArtichaut
2136a5cfad Fix unused_unsafe label with `unsafe_block_in_unsafe_fn 2021-01-17 16:42:27 +01:00
Tomasz Miąsko
c7bad7ba5d Avoid logging the whole MIR body in SimplifyCfg 2021-01-17 15:57:21 +01:00
Miguel Ojeda
f9275e1092 Skip linking if it is not required
This allows to use `--emit=metadata,obj` and other metadata
+ non-link combinations.

Fixes #81117.

Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2021-01-17 15:44:42 +01:00
Ömer Sinan Ağacan
9111e9dd01 rustc_parse_format: Fix character indices in find_skips
Fixes #81006
2021-01-17 17:40:58 +03:00
Dániel Buga
428f948096 Copy body span instead of querying it 2021-01-17 14:50:47 +01:00
oli
949bdd8b79 Add regression test 2021-01-17 13:40:29 +00:00
oli
ad5aa2359d Remove an unnecessary field from a NonConstOp 2021-01-17 13:40:29 +00:00
Mara Bos
7e2425ab73
Rollup merge of #81095 - LingMan:unwrap, r=oli-obk
Use Option::unwrap_or instead of open-coding it

r? ```@oli-obk``` Noticed this while we were talking about the other PR just now 😆
```@rustbot``` modify labels +C-cleanup +T-compiler
2021-01-17 12:24:59 +00:00
Mara Bos
34e073f44b
Rollup merge of #81084 - LingMan:map, r=oli-obk
Use Option::map instead of open-coding it

r? ```@oli-obk```
```@rustbot``` modify labels +C-cleanup +T-compiler
2021-01-17 12:24:58 +00:00
Mara Bos
19370a4860
Rollup merge of #81080 - bugadani:vec-diag, r=oli-obk,m-ou-se
Force vec![] to expression position only

r? `@oli-obk`

I went with the lazy way of only changing what broke. I moved the test to ui/macros because the diagnostics no longer give suggestions.

Closes #61933
2021-01-17 12:24:54 +00:00
Mara Bos
8f2ee87965
Rollup merge of #80983 - bjorn3:no_dup_is_dllimport_foreign_item, r=nagisa
Remove is_dllimport_foreign_item definition from cg_ssa

It overwrites the definition from rustc_metadata.

cc https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/query.20provided.20twice/near/218927806

Marked as draft to test if this breaks anything.
2021-01-17 12:24:51 +00:00
Mara Bos
ffcbeefd64
Rollup merge of #80765 - petrochenkov:traitsinscope, r=matthewjasper
resolve: Simplify collection of traits in scope

"Traits in scope" for a given location are collected by walking all scopes in type namespace, collecting traits in them and pruning traits that don't have an associated item with the given name and namespace.

Previously we tried to prune traits using some kind of hygienic resolution for associated items, but that was complex and likely incorrect, e.g. in #80762 correction to visibilites of trait items caused some traits to not be in scope anymore.
I previously had some comments and concerns about this in https://github.com/rust-lang/rust/pull/65351.

In this PR we are doing some much simpler pruning based on `Symbol` and `Namespace` comparisons, it should be enough to throw away 99.9% of unnecessary traits.
It is not necessary for pruning to be precise because for trait aliases, for example, we don't do any pruning at all, and precise hygienic resolution for associated items needs to be done in typeck anyway.

The somewhat unexpected effect is that trait imports introduced by macros 2.0 now bring traits into scope due to the removed hygienic check on associated item names.
I'm not sure whether it is desirable or not, but I think it's acceptable for now.
The old check was certainly incorrect because macros 2.0 did bring trait aliases into scope.
If doing this is not desirable, then we should come up with some other way to avoid bringing traits from macros 2.0 into scope, that would accommodate for trait aliases as well.

---

The PR also contains a couple of pure refactorings
- Scope walk is done by using `visit_scopes` instead of a hand-rolled version.
- Code is restructured to accomodate for rustdoc that also wants to query traits in scope, but doesn't want to filter them by associated items at all.

r? ```@matthewjasper```
2021-01-17 12:24:47 +00:00
Mara Bos
19f97802ca
Rollup merge of #80635 - sexxi-goose:use-place-instead-of-symbol, r=nikomatsakis`
Improve diagnostics when closure doesn't meet trait bound

Improves the diagnostics when closure doesn't meet trait bound by modifying `TypeckResuts::closure_kind_origins` such that `hir::Place` is used instead of `Symbol`. Using `hir::Place` to describe which capture influenced the decision of selecting a trait a closure satisfies to (Fn/FnMut/FnOnce, Copy) allows us to show precise path in the diagnostics when `capture_disjoint_field` feature is enabled.

Closes rust-lang/project-rfc-2229/issues/21

r? ```@nikomatsakis```
2021-01-17 12:24:44 +00:00
Mara Bos
3d5e7e0f47
Rollup merge of #80031 - petrochenkov:builtina, r=estebank
resolve: Reject ambiguity built-in attr vs different built-in attr

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

Resolution ensures that inert attributes cannot be used through imports like this, but built-in attributes don't go through initial resolution (only through resolution validation), so we have to keep some extra data (the built-in attribute name) to prevent it from happening.
2021-01-17 12:24:41 +00:00
Mara Bos
f783871ab1
Rollup merge of #79298 - lcnr:new-elysium, r=matthewjasper
correctly deal with late-bound lifetimes in anon consts

adds support for using late bound lifetimes of the parent context in anon consts.
```rust
#![feature(const_generics)]
const fn inner<'a>() -> usize where &'a (): Sized { 3 }

fn test<'a>() {
    let _: [u8; inner::<'a>()];
}
```
The lifetime `'a` is late bound in `test` so it's not included in its generics but is instead dealt with separately in borrowck.
This didn't previously work for anon consts as they have to use the late bound lifetimes of their parent which has
to be explicitly handled.

r? ```@matthewjasper``` cc ```@varkor``` ```@eddyb```
2021-01-17 12:24:39 +00:00
Ryan Levick
f07dd6d41a Remove dead code 2021-01-17 12:45:48 +01:00
Jack Huey
c76f47832a Don't derive TyEncodable/TyDecodable for Binder 2021-01-17 04:13:51 -05:00
Jack Huey
674735b109 Impl EncodableWithShorthand for PredicateKind 2021-01-17 02:49:30 -05:00
Aaron Hill
056fbbf7ee
Undo assertion change 2021-01-16 21:37:53 -05:00
LingMan
0a74e17211 Initialize a few variables directly
Currently they are declared as `mut`, get initialized to a default value, and
then possibly overwritten.

By initializing to the final value directly, they don't need to be `mut` and
it's clear that they don't get mutated elsewhere later on.
2021-01-17 02:07:37 +01:00
Jack Huey
f2ed9a3a8c Can't use EncodableWithShorthand for Predicate 2021-01-16 19:17:59 -05:00
Zack M. Davis
14eb94fe7a don't suggest erroneous trailing comma after ..
In #76612, suggestions were added for missing fields in
patterns. However, the suggestions are being inserted just at the end
of the last field in the pattern—before any trailing comma after the
last field. This resulted in the "if you don't care about missing
fields" suggestion to recommend code with a trailing comma after the
field ellipsis (`..,`), which is actually not legal ("`..` must be at
the end and cannot have a trailing comma")!

Incidentally, the doc-comment on `error_unmentioned_fields` was using
`you_cant_use_this_field` as an example field name (presumably
copy-paste inherited from the description of Issue #76077), but
the present author found this confusing, because unmentioned fields
aren't necessarily unusable.

The suggested code in the diff this commit introduces to
`destructuring-assignment/struct_destructure_fail.stderr` doesn't
work, but it didn't work beforehand, either (because of the "found
reserved identifier `_`" thing), so you can't really call it a
regression; it could be fixed in a separate PR.

Resolves #78511.
2021-01-16 16:01:36 -08:00
Tomasz Miąsko
d0a756719f Visit only terminators when removing unneeded drops
No functional changes intended
2021-01-17 00:00:00 +00:00
Jack Huey
dcad9f1893 More review comments 2021-01-16 18:56:37 -05:00
Jack Huey
3dea68de1d Review changes 2021-01-16 18:56:37 -05:00
Jack Huey
66c179946b Use no_bound_vars 2021-01-16 18:50:34 -05:00
Jack Huey
476bd53058 Cleanup 2021-01-16 18:50:34 -05:00
Jack Huey
e76476afe4 Cleanup 2021-01-16 18:40:47 -05:00
Jack Huey
876192e8cd fold_with not super_fold_with in TypeFoldable impl for Predicate 2021-01-16 18:40:47 -05:00
Jack Huey
4cd6f85a07 Remove PredicateKind 2021-01-16 18:40:47 -05:00
Jack Huey
4cb3d6f983 Intermediate formatting and such 2021-01-16 18:40:47 -05:00
Jack Huey
8278314a8b Remove PredicateKind::Atom 2021-01-16 18:40:47 -05:00
Bastian Kauschke
84b056d597 prevent potential bug in encode_with_shorthand. 2021-01-17 00:34:54 +01:00
Aaron Hill
02952372c4
Implement Debug for DefIdForest 2021-01-16 17:56:32 -05:00
Aaron Hill
6417760632
Run fmt 2021-01-16 17:53:02 -05:00
Aaron Hill
93ab705655
Print result on unstable fingerprint error 2021-01-16 17:53:02 -05:00
Aaron Hill
7afb32557d
Enforce that query results implement Debug 2021-01-16 17:53:02 -05:00
Vadim Petrochenkov
7f9a2cfa1b resolve: Reject ambiguity built-in attr vs different built-in attr 2021-01-17 01:48:17 +03:00
bors
8a6518427e Auto merge of #81089 - m-ou-se:rollup-z7iac6i, r=m-ou-se
Rollup of 17 pull requests

Successful merges:

 - #78455 (Introduce {Ref, RefMut}::try_map for optional projections in RefCell)
 - #80144 (Remove giant badge in README)
 - #80614 (Explain why borrows can't be held across yield point in async blocks)
 - #80670 (TrustedRandomAaccess specialization composes incorrectly for nested iter::Zips)
 - #80681 (Clarify what the effects of a 'logic error' are)
 - #80764 (Re-stabilize Weak::as_ptr and friends for unsized T)
 - #80901 (Make `x.py --color always` apply to logging too)
 - #80902 (Add a regression test for #76281)
 - #80941 (Do not suggest invalid code in pattern with loop)
 - #80968 (Stabilize the poll_map feature)
 - #80971 (Put all feature gate tests under `feature-gates/`)
 - #81021 (Remove doctree::Import)
 - #81040 (doctest: Reset errors before dropping the parse session)
 - #81060 (Add a regression test for #50041)
 - #81065 (codegen_cranelift: Fix redundant semicolon warn)
 - #81069 (Add sample code for Rc::new_cyclic)
 - #81081 (Add test for #34792)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-01-16 20:26:20 +00:00
LingMan
5a706cfc49 Use Option::unwrap_or instead of open-coding it 2021-01-16 20:13:06 +01:00
LingMan
76003f31f1 Use Option::map instead of open-coding it 2021-01-16 20:05:02 +01:00
flip1995
5e3df4266a
More advanced unknown lint suggestion
This copies the unknown_lints code clippy uses for its
unknown_clippy_lints lint to rustc. The unknown_clippy_lints code is
more advanced, because it doesn't suggest renamed or removed lints and
correctly suggest lower casing lints.
2021-01-16 19:44:46 +01:00
Bastian Kauschke
15f0921d0c correctly deal with late-bound lifetimes in anon consts 2021-01-16 19:27:42 +01:00
Mara Bos
61be4e8024
Rollup merge of #81065 - osa1:cranelift_semicolon_warning, r=jyn514
codegen_cranelift: Fix redundant semicolon warn
2021-01-16 17:30:13 +00:00
Mara Bos
79a8499f77
Rollup merge of #80941 - JohnTitor:ref-mut-pat-in-loops, r=varkor
Do not suggest invalid code in pattern with loop

Fixes #80913
2021-01-16 17:30:02 +00:00
Mara Bos
af5b0d9883
Rollup merge of #80614 - 1000teslas:issue-78938-fix, r=tmandry
Explain why borrows can't be held across yield point in async blocks

For https://github.com/rust-lang/rust/issues/78938.
2021-01-16 17:29:49 +00:00
bors
492b83c697 Auto merge of #80290 - RalfJung:less-intrinsic-write, r=lcnr
implement ptr::write without dedicated intrinsic

This makes `ptr::write` more consistent with `ptr::write_unaligned`, `ptr::read`, `ptr::read_unaligned`, all of which are implemented in terms of `copy_nonoverlapping`.

This means we can also remove `move_val_init` implementations in codegen and Miri, and its special handling in the borrow checker.

Also see [this Zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/ptr.3A.3Aread.20vs.20ptr.3A.3Awrite).
2021-01-16 17:28:32 +00:00
Olivia Crain
65b5e4386b Use PlaceRef more consistently in rustc_mir 2021-01-16 10:44:23 -06:00
bors
63a83c5f55 Auto merge of #81077 - bugadani:shrink, r=Mark-Simulacrum
Remove unnecessary manual shrink_to_fit calls
2021-01-16 14:04:43 +00:00
Dániel Buga
dc932cdf88 Remove unnecessary manual shrink_to_fit calls 2021-01-16 14:02:36 +01:00
Ralf Jung
1b09dc2596 PlaceRef::ty: use method call syntax 2021-01-16 11:38:14 +01:00
Simonas Kazlauskas
007080b607 Target stack-probe support configurable finely
This adds capability to configure the target's stack probe support in a
more precise manner than just on/off. In particular now we allow
choosing between always inline-asm, always call or either one of those
depending on the LLVM version on a per-target basis.
2021-01-16 12:38:02 +02:00
Ömer Sinan Ağacan
b681631eff codegen_cranelift: Fix redundant semicolon warn 2021-01-16 07:17:13 +03:00
bors
635ccfe01c Auto merge of #77885 - erikdesjardins:probeasm, r=cuviper
Use probe-stack=inline-asm in LLVM 11+

Fixes (?) #74405, related to #43241

r? `@cuviper`
2021-01-16 03:10:52 +00:00
Chris Pardy
2624b3e443 Improve diagnostics for Precise Capture 2021-01-15 19:39:24 -05:00
bors
6c869d34ae Auto merge of #81057 - GuillaumeGomez:rollup-yl2kqst, r=GuillaumeGomez
Rollup of 6 pull requests

Successful merges:

 - #77693 (Add test for #59352)
 - #80515 (Improve JS performance by storing length before comparing to it in loops)
 - #81030 (Update mdbook)
 - #81033 (Remove useless `clean::Variant` struct)
 - #81049 (inline: Round word-size cost estimates up)
 - #81054 (Drop a few unneeded borrows)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-01-16 00:13:26 +00:00
Joshua Nelson
c819a4c025 Don't mark ineffective_unstable_trait_impl as an internal lint
It's not an internal lint:
- It's not in the rustc::internal lint group
- It's on unconditionally, because it actually lints `staged_api`, not
  the compiler

This fixes a bug where `#[deny(rustc::internal)]` would warn that
`rustc::internal` was an unknown lint.
2021-01-15 17:31:10 -05:00
Guillaume Gomez
f8b1baac11
Rollup merge of #81054 - LingMan:rem_as_ref, r=jyn514
Drop a few unneeded borrows

`@rustbot` modify labels +C-cleanup +T-compiler
2021-01-15 23:31:03 +01:00
bors
fcbd305ee9 Auto merge of #80602 - tgnottingham:cratemetadata_you_aint_special, r=michaelwoerister
Remove DepKind::CrateMetadata and pre-allocation of DepNodes

Remove much of the special-case handling around crate metadata
dependency tracking by replacing `DepKind::CrateMetadata` and the
pre-allocation of corresponding `DepNodes` with on-demand invocation
of the `crate_hash` query.
2021-01-15 21:13:35 +00:00
Joshua Nelson
5053db7c00 Don't make tools responsible for checking unknown and renamed lints
Previously, clippy (and any other tool emitting lints) had to have their
own separate UNKNOWN_LINTS pass, because the compiler assumed any tool
lint could be valid. Now, as long as any lint starting with the tool
prefix exists, the compiler will warn when an unknown lint is present.
2021-01-15 16:08:28 -05:00
Matthew Jasper
5db5d8f87e Make hitting the recursion limit in projection non-fatal
This is relied on by wundergraph.
2021-01-15 20:45:38 +00:00
LingMan
ba1f036c7a Drop a few unneeded borrows 2021-01-15 21:29:28 +01:00
1000teslas
3e9c95b9d4
Update compiler/rustc_mir/src/borrow_check/diagnostics/conflict_errors.rs
Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com>
2021-01-16 03:32:54 +11:00
Yuki Okushi
ce06df2e4a
Rollup merge of #81008 - tmiasko:generator-layout-err, r=tmandry
Don't ICE when computing a layout of a generator tainted by errors

Fixes #80998.
2021-01-15 18:26:16 +09:00
Yuki Okushi
a584d87417
Rollup merge of #80944 - LingMan:map_or, r=nagisa
Use Option::map_or instead of `.map(..).unwrap_or(..)`

``@rustbot`` modify labels +C-cleanup +T-compiler
2021-01-15 18:26:14 +09:00
Yuki Okushi
0dedc6c054
Rollup merge of #80254 - Aaron1011:rustdoc-auto-param-env, r=estebank
Don't try to add nested predicate to Rustdoc auto-trait `ParamEnv`

Fixes #80233

We already have logic in `evaluate_predicates` that tries to add
unimplemented predicates to our `ParamEnv`. Trying to add a predicate
that already holds can lead to errors later on, since projection
will prefer trait candidates from the `ParamEnv` to predicates from an
impl.
2021-01-15 18:26:04 +09:00
1000teslas
5468d9805a Simplify E0373 async code example 2021-01-15 16:50:48 +11:00
bors
dcf622eb70 Auto merge of #80993 - Aaron1011:collect-set-tokens, r=petrochenkov
Set tokens on AST node in `collect_tokens`

A new `HasTokens` trait is introduced, which is used to move logic from
the callers of `collect_tokens` into the body of `collect_tokens`.

In addition to reducing duplication, this paves the way for PR #80689,
which needs to perform additional logic during token collection.
2021-01-15 05:36:48 +00:00
Erik Desjardins
cd25807223 Use probe-stack=inline-asm in LLVM 11+ 2021-01-14 22:49:16 -05:00
Tomasz Miąsko
a65c050333 inline: Round word-size cost estimates up 2021-01-15 00:00:00 +00:00
bors
e38fb306b7 Auto merge of #81018 - m-ou-se:rollup-7202dc7, r=m-ou-se
Rollup of 17 pull requests

Successful merges:

 - #79982 (Add missing methods to unix ExitStatusExt)
 - #80017 (Suggest `_` and `..` if a pattern has too few fields)
 - #80169 (Recommend panic::resume_unwind instead of panicking.)
 - #80217 (Add a `std::io::read_to_string` function)
 - #80444 (Add as_ref and as_mut methods for Bound)
 - #80567 (Add Iterator::intersperse_with)
 - #80829 (Get rid of `DepConstructor`)
 - #80895 (Fix handling of malicious Readers in read_to_end)
 - #80966 (Deprecate atomic::spin_loop_hint in favour of hint::spin_loop)
 - #80969 (Use better ICE message when no MIR is available)
 - #80972 (Remove unstable deprecated Vec::remove_item)
 - #80973 (Update books)
 - #80980 (Fixed incorrect doc comment)
 - #80981 (Fix -Cpasses=list and llvm version print with -vV)
 - #80985 (Fix stabilisation version of slice_strip)
 - #80990 (llvm: Remove the unused context from CreateDebugLocation)
 - #80991 (Fix formatting specifiers doc links)

Failed merges:

 - #80944 (Use Option::map_or instead of `.map(..).unwrap_or(..)`)

r? `@ghost`
`@rustbot` modify labels: rollup
2021-01-14 20:21:20 +00:00
LingMan
a56bffb4f9 Use Option::map_or instead of .map(..).unwrap_or(..) 2021-01-14 19:23:59 +01:00
Mara Bos
494cb3cc7c
Rollup merge of #80990 - cuviper:unused-debug-context, r=nagisa
llvm: Remove the unused context from CreateDebugLocation

This went unused in commit 88d874de63, part of #68965.
2021-01-14 18:00:29 +00:00
Mara Bos
ce3bc76a86
Rollup merge of #80981 - bjorn3:bjorn3-patch-1, r=jonas-schievink
Fix -Cpasses=list and llvm version print with -vV

cc https://github.com/rust-lang/rust/pull/77975#issuecomment-759362933
2021-01-14 18:00:25 +00:00
Mara Bos
90cc815829
Rollup merge of #80969 - camelid:monomorph-ice-msg, r=nagisa
Use better ICE message when no MIR is available

The ICE message is somewhat confusing and overly specific - the issue is
that there's no MIR available.

This should make debugging these ICEs easier since the error tells you
what's actually wrong, not what it was trying to do when it failed.

cc https://github.com/rust-lang/rust/pull/80952#issuecomment-759198841
cc `````@jyn514`````
2021-01-14 18:00:16 +00:00
Mara Bos
9e9aba87af
Rollup merge of #80829 - jyn514:dep-constructor, r=michaelwoerister
Get rid of `DepConstructor`

This removes fully 235 unused functions.

Follow-up to https://github.com/rust-lang/rust/pull/80325#discussion_r548491999.

r? ``@michaelwoerister``
cc ``@cjgillot``
2021-01-14 18:00:09 +00:00
Mara Bos
d3b31065e3
Rollup merge of #80017 - camelid:sugg-rest-pattern, r=estebank
Suggest `_` and `..` if a pattern has too few fields

Fixes #80010.
2021-01-14 17:59:55 +00:00
bors
4275ef6c9d Auto merge of #79689 - Vooblin:patch1, r=tmandry
Update tests of "unused_lifetimes" lint for async functions and corresponding source code

Before this PR the following code would cause an error:
```
#![deny(unused_lifetimes)]
async fn f<'a>(_: &'a i32) {}
fn main() {}
```
It was happening because of the desugaring of return type in async functions. As a result of the desugaring, the return type contains all lifetimes involved in the function signature. And these lifetimes were interpreted separately from the same in the function scope => so they are unused.

Now, all lifetimes from the return type are interpreted as used. It is also not perfect, but at least this lint doesn't cause wrong errors now.

This PR connected to issues #78522, #77217
2021-01-14 17:27:15 +00:00
bors
d03fe84169 Auto merge of #79328 - c410-f3r:hir-if, r=matthewjasper
Reintroduce hir::ExprKind::If

Basically copied and paste #59288/https://github.com/rust-lang/rust-clippy/pull/4080 with some modifications.

The vast majority of tests were fixed and now there are only a few remaining. Since I am still unable to figure out the missing pieces, any help with the following list is welcome.

- [ ] **Unnecessary `typeck` exception**: [Cheated on this one to make CI green.](https://github.com/rust-lang/rust/pull/79328/files#diff-3faee9ba23fc54a12b7c43364ba81f8c5660045c7e1d7989a02a0cee1c5b2051)
- [x] **Incorrect span**: [Span should reference `then` and `else` separately.](https://github.com/rust-lang/rust/pull/79328/files#diff-cf2c46e82222ee4b1037a68fff8a1af3c4f1de7a6b3fd798aacbf3c0475abe3d)
- [x] **New note regarding `assert!`**: [Modified but not "wrong". Maybe can be a good thing?](https://github.com/rust-lang/rust/pull/79328/files#diff-9e0d7c89ed0224e2b62060c957177c27db43c30dfe3c2974cb6b5091cda9cfb5)
- [x] **Inverted report location**: [Modified but not "wrong". Locations were inverted.](https://github.com/rust-lang/rust/pull/79328/files#diff-f637ce7c1f68d523a165aa9651765df05e36c4d7d279194b1a6b28b48a323691)
- [x] **`src/test/ui/point-to-type-err-cause-on-impl-trait-return.rs` has weird errors**: [Not sure why this is happening.](https://github.com/rust-lang/rust/pull/79328/files#diff-c823c09660f5b112f95e97e8ff71f1797b6c7f37dbb3d16f8e98bbaea8072e95)
- [x] **Missing diagnostic**: [???](https://github.com/rust-lang/rust/pull/79328/files#diff-6b8ab09360d725ba4513933827f9796b42ff9522b0690f80b76de067143af2fc)
2021-01-14 14:41:58 +00:00
Tomasz Miąsko
5ea1d0e865 Don't ICE when computing a layout of a generator tainted by errors 2021-01-14 13:13:13 +01:00
1000teslas
63deae5e25 Fix E0373 code example 2021-01-14 21:52:38 +11:00
1000teslas
174135fb3b Fix error E0373 documentation 2021-01-14 17:15:04 +11:00
Aaron Hill
a961e6785c
Set tokens on AST node in collect_tokens
A new `HasTokens` trait is introduced, which is used to move logic from
the callers of `collect_tokens` into the body of `collect_tokens`.

In addition to reducing duplication, this paves the way for PR #80689,
which needs to perform additional logic during token collection.
2021-01-13 22:10:36 -05:00
Tyler Mandry
6af831ace6 Add tracing instrumentation to method typeck
I was recently digging into how this code works, and this
instrumentation was helpful.
2021-01-14 01:38:02 +00:00
Tomasz Miąsko
ea4cbff264 Encode optimized MIR of generators when emitting metadata 2021-01-14 00:00:00 +00:00
bors
180fdffa17 Auto merge of #80654 - Aaron1011:fix/dummy-span-ctxt, r=wesleywiser
Properly handle `SyntaxContext` of dummy spans in incr comp

Fixes #80336

Due to macro expansion, we may end up with spans with an invalid
location and non-root `SyntaxContext`. This commits preserves the
`SyntaxContext` of such spans in the incremental cache, and ensures
that we always hash the `SyntaxContext` when computing the `Fingerprint`
of a `Span`

Previously, we would discard the `SyntaxContext` during serialization to
the incremental cache, causing the span's `Fingerprint` to change across
compilation sessions.
2021-01-13 23:24:31 +00:00
Jacob Pratt
edf2e3725e
Use unsigned_abs throughout repository 2021-01-13 17:58:08 -05:00
bors
a62a76047e Auto merge of #77524 - Patryk27:fixes/66228, r=estebank
Rework diagnostics for wrong number of generic args (fixes #66228 and #71924)

This PR reworks the `wrong number of {} arguments` message, so that it provides more details and contextual hints.
2021-01-13 20:35:58 +00:00
Aaron Hill
482a67d20f
Properly handle SyntaxContext of dummy spans in incr comp
Fixes #80336

Due to macro expansion, we may end up with spans with an invalid
location and non-root `SyntaxContext`. This commits preserves the
`SyntaxContext` of such spans in the incremental cache, and ensures
that we always hash the `SyntaxContext` when computing the `Fingerprint`
of a `Span`

Previously, we would discard the `SyntaxContext` during serialization to
the incremental cache, causing the span's `Fingerprint` to change across
compilation sessions.
2021-01-13 15:20:29 -05:00
Josh Stone
0342fd16ff Remove the unused context from CreateDebugLocation
This went unused in commit 88d874de63, part of #68965.
2021-01-13 11:55:49 -08:00
bors
9bc8b00b4a Auto merge of #80718 - tmiasko:skip-opt-mir, r=oli-obk
Consistently avoid constructing optimized MIR when not doing codegen

The optimized MIR for closures is being encoded unconditionally, while
being unnecessary for cargo check. This turns out to be especially
costly with MIR inlining enabled, since it triggers computation of
optimized MIR for all callees that are being examined for inlining
purposes https://github.com/rust-lang/rust/pull/77307#issuecomment-751915450.

Skip encoding of optimized MIR for closures, enum constructors, struct
constructors, and trait fns when not doing codegen, like it is already
done for other items since 49433.
2021-01-13 17:48:41 +00:00
bjorn3
7aca2fa7c6 Remove is_dllimport_foreign_item def from cg_ssa
It overwrites the definition from rustc_metadata
2021-01-13 18:47:26 +01:00
1000teslas
a9ead34371 Fix whitespace 2021-01-14 01:21:27 +11:00
Mark Rousskov
4614671cae Update code to account for extern ABI requirement 2021-01-13 07:49:45 -05:00
Mark Rousskov
920b5ee722 Lint on extern in item declaration position 2021-01-13 07:49:16 -05:00
Mark Rousskov
8a3edb1d66 Update tests for extern block linting 2021-01-13 07:49:16 -05:00
Mark Rousskov
c4a8d7f86a Introduce missing ABI lint on extern blocks 2021-01-13 07:49:16 -05:00
1000teslas
7f41465f6d Move help link to error index 2021-01-13 23:37:49 +11:00
bjorn3
64c1b0d614
Fix -Cpasses=list and llvm version print with -vV 2021-01-13 12:15:42 +01:00
Tyson Nottingham
09067db8a0 Serialize dependency graph directly from DepGraph
Reduce memory usage by serializing dep graph directly from `DepGraph`,
rather than copying it into `SerializedDepGraph` and serializing that.
2021-01-12 22:20:29 -08:00
Camelid
e8c87935e0 Include .. suggestion if fields are all wildcards 2021-01-12 21:20:26 -08:00
Camelid
c3f7429fb4 Use better ICE message when no MIR is available
The ICE message is somewhat confusing and overly specific - the issue is
that there's no MIR available.

This should make debugging these ICEs easier since the error tells you
what's actually wrong, not what it was trying to do when it failed.

cc https://github.com/rust-lang/rust/pull/80952#issuecomment-759198841
2021-01-12 20:54:35 -08:00
bors
fc93e4719c Auto merge of #80960 - Dylan-DPC:rollup-89tri8x, r=Dylan-DPC
Rollup of 10 pull requests

Successful merges:

 - #78901 (diagnostics: Note capturing closures can't be coerced to fns)
 - #79588 (Provide more information for HRTB lifetime errors involving closures)
 - #80232 (Remove redundant def_id lookups)
 - #80662 (Added support for i386-unknown-linux-gnu and i486-unknown-linux-gnu)
 - #80736 (use Once instead of Mutex to manage capture resolution)
 - #80796 (Update to LLVM 11.0.1)
 - #80859 (Fix --pretty=expanded with --remap-path-prefix)
 - #80922 (Revert "Auto merge of #76896 - spastorino:codegen-inline-fns2)
 - #80924 (Fix rustdoc --test-builder argument parsing)
 - #80935 (Rename `rustc_middle::lint::LevelSource` to `LevelAndSource`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-01-13 04:29:45 +00:00
Camelid
d7307a71f5 Always show suggestions in their own subwindows 2021-01-12 19:25:51 -08:00
Camelid
9959d6deed Only suggest .. if more than one field is missing 2021-01-12 19:25:51 -08:00
Camelid
fe82cc38a0 Specialize .. help message for all fields vs. the rest 2021-01-12 19:25:50 -08:00
Camelid
a5e8e6ec2d Pluralize 'parenthesis' correctly
It's 'parentheses', not 'parenthesis', when you have more than one.
2021-01-12 19:25:50 -08:00
Camelid
f3d9df54ee Suggest Variant(..) if all of the mentioned fields are _ 2021-01-12 19:25:50 -08:00
Camelid
5fe61a79cc Simplify code
Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com>
2021-01-12 19:25:50 -08:00
Camelid
16692ab66a Suggest _ and .. if a pattern has too few fields
For example, this code:

    struct S(i32, f32);

    let S(x) = S(0, 1.0);

will make the compiler suggest either:

    let S(x, _) = S(0, 1.0);

or:

    let S(x, ..) = S(0, 1.0);
2021-01-12 19:25:49 -08:00