Commit graph

3247 commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
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