Commit graph

4761 commits

Author SHA1 Message Date
Jack Huey
8ad7e5685e Fix new problem from rebase and a little cleanup 2021-03-31 10:16:37 -04:00
Jack Huey
6d5efa9f04 Add var to BoundRegion. Add query to get bound vars for applicable items. 2021-03-31 10:16:37 -04:00
Jack Huey
666859a6f8 Make late and late_anon regions track the bound var position 2021-03-31 10:15:56 -04:00
Jack Huey
84f82d348c Revert explicit lifetimes 2021-03-31 10:15:56 -04:00
Jack Huey
30187c81f6 Track bound vars 2021-03-31 10:15:27 -04:00
Jack Huey
62a49c3bb8 Add tcx lifetime to Binder 2021-03-31 10:13:57 -04:00
Jack Huey
74851f4cf3 count bound vars 2021-03-31 10:11:47 -04:00
Jack Huey
97a22a4f9c Add u32 for bound variables to Binder 2021-03-31 10:05:32 -04:00
Jack Huey
4955d755d3 Some rebinds and dummys 2021-03-31 10:05:32 -04:00
bors
a5029ac0ab Auto merge of #83684 - cjgillot:csp, r=petrochenkov
Remove hir::CrateItem.

The crate span is exactly the crate module's inner span. There is no need to store it twice.
2021-03-31 08:34:40 +00:00
bors
2a32abbcde Auto merge of #83681 - jyn514:blanket-impls-tweaks, r=Aaron1011
rustdoc: Only look at blanket impls in `get_blanket_impls`

The idea here is that all the work in 16156fb278/compiler/rustc_middle/src/ty/trait_def.rs (L172-L186) doesn't matter for `get_blanket_impls` - Rustdoc will already pick up on those blocks when it documents the item.
2021-03-31 05:47:22 +00:00
bors
6ff482bde5 Auto merge of #83666 - Amanieu:instrprof-order, r=tmandry
Run LLVM coverage instrumentation passes before optimization passes

This matches the behavior of Clang and allows us to remove several
hacks which were needed to ensure functions weren't optimized away
before reaching the instrumentation pass.

Fixes #83429

cc `@richkadel`

r? `@tmandry`
2021-03-31 03:20:33 +00:00
Dylan DPC
7d888d100f
Rollup merge of #83654 - JohnTitor:issue-83606, r=estebank
Do not emit a suggestion that causes the E0632 error

Fixes #83606
2021-03-31 01:14:46 +02:00
Camille GILLOT
9d8f833e05 Remove hir::CrateItem. 2021-03-30 20:31:06 +02:00
bors
926ec1cb8b Auto merge of #83639 - osa1:issue83638, r=estebank
Replace tabs in err messages before rendering

This is done in other call sites, but was missing in one place.

Fixes #83638
2021-03-30 17:07:19 +00:00
Joshua Nelson
6f06b761b9 Only look at blanket impls in get_blanket_impls 2021-03-30 12:28:33 -04:00
Dylan DPC
5b467787b6
Rollup merge of #83667 - estebank:cool-bears-hot-tip, r=lcnr
Suggest box/pin/arc ing receiver on method calls

_Extracted from https://fasterthanli.me/articles/pin-and-suffering_
2021-03-30 11:34:30 +02:00
bors
a0e229abad Auto merge of #83649 - bjorn3:dedup_providers, r=petrochenkov
Don't duplicate the extern providers once for each crate

This should give a small perf improvement for small crates by avoiding a memcpy of a pretty big struct for each loaded crate. In addition would be useful for replacing the sequential `CrateNum` everywhere with the hash based `StableCrateId` introduced in #81635, which would allow avoiding remapping of `CrateNum`'s when loading crate metadata. While this PR is not strictly needed for that, it is necessary to prevent a performance loss due to it.

I think this duplication was done in https://github.com/rust-lang/rust/pull/40008 (which introduced the query system) to make it possible to compile multiple crates in a single session in the future. I think this is unlikely to be implemented any time soon. In addition this PR can easily be reverted if necessary to implement this.
2021-03-30 06:22:29 +00:00
Amanieu d'Antras
cad9b6b695 Apply review feedback 2021-03-30 07:03:41 +01:00
Esteban Küber
0195f8d375 Hide unnecessary reference to trait
When the problem for a method not being found in its receiver is due to
arbitrary self-types, we don't want to mention importing or implementing
the trait, instead we suggest wrapping.
2021-03-29 20:39:42 -07:00
Esteban Küber
6f2d8a018e Suggest box/pin/arc ing receiver on method calls 2021-03-29 18:14:44 -07:00
Amanieu d'Antras
26d260bfa4 Run LLVM coverage instrumentation passes before optimization passes
This matches the behavior of Clang and allows us to remove several
hacks which were needed to ensure functions weren't optimized away
before reaching the instrumentation pass.
2021-03-30 02:10:28 +01:00
Dylan DPC
fca8e7dd88
Rollup merge of #83643 - JohnTitor:is-freeze-no-longer-uses-span, r=RalfJung
Remove a FIXME resolved by #73578

r? ``@RalfJung``
2021-03-30 00:32:24 +02:00
bors
48691ea6e6 Auto merge of #83185 - jyn514:remove-dead-code, r=oli-obk
Remove (lots of) dead code

Builds on
- [ ] https://github.com/rust-lang/rust/pull/83161
- [x] https://github.com/rust-lang/rust/pull/83230
- [x] https://github.com/rust-lang/rust/pull/83197.

Found with https://github.com/est31/warnalyzer.
See https://github.com/rust-lang/rust/pull/77739 for a similar change in the past.

Dubious changes:
- Maybe some of the dead code in rustc_data_structures should be kept, in case someone wants to use it in the future?

TODO:
- [ ] check if any of the comments on the deleted code should be kept.
- [x] update the compiler documentation; right now it fails to build
- [x] finish moving `cfg(test)` changes into https://github.com/rust-lang/rust/pull/83197

cc `@est31`
2021-03-29 19:44:27 +00:00
JohnTitor
7e6fd40614 Do not emit a suggestion that causes the E0632 error 2021-03-30 03:00:25 +09:00
Joshua Nelson
526bb10701 Revert changes to sync data structures
There isn't currently a good reviewer for these, and I don't want to
remove things that will just be added again. I plan to make a separate
PR for these changes so the rest of the cleanup can land.
2021-03-29 13:50:40 -04:00
bjorn3
cd7a011f37 Don't duplicate the extern providers once for each crate 2021-03-29 18:03:07 +02:00
JohnTitor
48f9f0864b Remove a FIXME resolved by #73578 2021-03-29 21:41:50 +09:00
Ömer Sinan Ağacan
8d7432af7b Replace tabs in err messages before rendering
This is done in other call sites, but was missing in one place.

Fixes #83638
2021-03-29 13:38:36 +03:00
bjorn3
5444b46234 Merge commit '0969bc6dde001e01e7e1f58c8ccd7750f8a49ae1' into sync_cg_clif-2021-03-29 2021-03-29 10:45:09 +02:00
bors
cc4103089f Auto merge of #83605 - RalfJung:unaligned, r=petrochenkov
unaligned_references: align(N) fields in packed(N) structs are fine

This removes some false positives from the unaligned_references lint: in a `repr(packed(2))` struct, fields of alignment 2 (and less) are guaranteed to be properly aligned, so we do not have to consider them "disaligned".
2021-03-29 00:17:23 +00:00
Vadim Petrochenkov
cc5392e76b linker: Use data execution prevention options by default when linker supports them 2021-03-28 23:44:40 +03:00
Ralf Jung
ee1caae33c unaligned_references: align(N) fields in packed(N) structs are fine 2021-03-28 12:54:19 +02:00
bors
505ed7fb1b Auto merge of #83593 - petrochenkov:nounwrap, r=nagisa
rustc_target: Avoid unwraps when adding linker flags

These `unwrap`s assume that some linker flags were already added by `*_base::opts()` methods, but that's doesn't necessarily remain the case when we are reducing the number of flags hardcoded in targets, as https://github.com/rust-lang/rust/pull/83587 shows.

r? `@nagisa`
2021-03-28 08:53:51 +00:00
Joshua Nelson
f3523544f1 Address more review comments
- Add back various diagnostic methods on `Session`.

  It seems unfortunate to duplicate these in so many places, but in the
  meantime, making the API inconsistent between `Session` and `Diagnostic`
  also seems unfortunate.

- Add back TyCtxtAt methods

  These will hopefully be used in the near future.

- Add back `with_const`, it would need to be added soon after anyway.
- Add back `split()` and `get_mut()`, they're useful.
2021-03-27 22:19:32 -04:00
Joshua Nelson
230e396a76 Fix compiler docs 2021-03-27 22:16:34 -04:00
Joshua Nelson
de0fda9558 Address review comments
- Add back `HirIdVec`, with a comment that it will soon be used.
- Add back `*_region` functions, with a comment they may soon be used.
- Remove `-Z borrowck_stats` completely. It didn't do anything.
- Remove `make_nop` completely.
- Add back `current_loc`, which is used by an out-of-tree tool.
- Fix style nits
- Remove `AtomicCell` with `cfg(parallel_compiler)` for consistency.
2021-03-27 22:16:34 -04:00
Joshua Nelson
441dc3640a Remove (lots of) dead code
Found with https://github.com/est31/warnalyzer.

Dubious changes:
- Is anyone else using rustc_apfloat? I feel weird completely deleting
  x87 support.
- Maybe some of the dead code in rustc_data_structures, in case someone
  wants to use it in the future?
- Don't change rustc_serialize

  I plan to scrap most of the json module in the near future (see
  https://github.com/rust-lang/compiler-team/issues/418) and fixing the
  tests needed more work than I expected.

TODO: check if any of the comments on the deleted code should be kept.
2021-03-27 22:16:33 -04:00
Joshua Nelson
785aeac521 Remove unused DiagnosticBuilder::sub function
`Diagnostic::sub` is only ever used directly; it doesn't need to be
included in the builder.
2021-03-27 22:16:33 -04:00
bors
3bfc85149e Auto merge of #83587 - petrochenkov:asneeded, r=nagisa
linker: Use `--as-needed` by default when linker supports it

Do it in a centralized way in `link.rs` instead of individual target specs.
Majority of relevant target specs were already passing it.
2021-03-28 01:00:25 +00:00
Vadim Petrochenkov
049a49b911 rustc_target: Avoid unwraps when adding linker flags 2021-03-28 02:28:48 +03:00
Vadim Petrochenkov
6615ee89be linker: Use --as-needed by default when linker supports it 2021-03-28 01:49:15 +03:00
bors
8cd7d86ce2 Auto merge of #83103 - petrochenkov:unilex, r=Aaron1011
resolve: Partially unify early and late scope-relative identifier resolution

Reuse `early_resolve_ident_in_lexical_scope` instead of a chunk of code in `resolve_ident_in_lexical_scope` doing the same job.

`early_resolve_ident_in_lexical_scope`/`visit_scopes` had to be slightly extended to be able to 1) start from a specific module instead of the current parent scope and 2) report one deprecation lint.
`early_resolve_ident_in_lexical_scope` still doesn't support walking through "ribs", that part is left in `resolve_ident_in_lexical_scope` (moreover, I'm pretty sure it's buggy, but that's a separate issue, cc https://github.com/rust-lang/rust/issues/52389 at least).
2021-03-27 22:19:17 +00:00
Vadim Petrochenkov
ee0357af3b resolve: Partially unify early and late scope-relative ident resolution 2021-03-27 23:38:17 +03:00
Dylan DPC
1115accccc
Rollup merge of #83548 - Aaron1011:capture-none-delims, r=petrochenkov
Always preserve `None`-delimited groups in a captured `TokenStream`

Previously, we would silently remove any `None`-delimiters when
capturing a `TokenStream`, 'flattenting' them to their inner tokens.
This was not normally visible, since we usually have
`TokenKind::Interpolated` (which gets converted to a `None`-delimited
group during macro invocation) instead of an actual `None`-delimited
group.

However, there are a couple of cases where this becomes visible to
proc-macros:
1. A cross-crate `macro_rules!` macro has a `None`-delimited group
   stored in its body (as a result of being produced by another
   `macro_rules!` macro). The cross-crate `macro_rules!` invocation
   can then expand to an attribute macro invocation, which needs
   to be able to see the `None`-delimited group.
2. A proc-macro can invoke an attribute proc-macro with its re-collected
   input. If there are any nonterminals present in the input, they will
   get re-collected to `None`-delimited groups, which will then get
   captured as part of the attribute macro invocation.

Both of these cases are incredibly obscure, so there hopefully won't be
any breakage. This change will allow more agressive 'flattenting' of
nonterminals in #82608 without losing `None`-delimited groups.
2021-03-27 20:37:12 +01:00
Dylan DPC
b2e254318d
Rollup merge of #82917 - cuviper:iter-zip, r=m-ou-se
Add function core::iter::zip

This makes it a little easier to `zip` iterators:

```rust
for (x, y) in zip(xs, ys) {}
// vs.
for (x, y) in xs.into_iter().zip(ys) {}
```

You can `zip(&mut xs, &ys)` for the conventional `iter_mut()` and
`iter()`, respectively. This can also support arbitrary nesting, where
it's easier to see the item layout than with arbitrary `zip` chains:

```rust
for ((x, y), z) in zip(zip(xs, ys), zs) {}
for (x, (y, z)) in zip(xs, zip(ys, zs)) {}
// vs.
for ((x, y), z) in xs.into_iter().zip(ys).zip(xz) {}
for (x, (y, z)) in xs.into_iter().zip((ys.into_iter().zip(xz)) {}
```

It may also format more nicely, especially when the first iterator is a
longer chain of methods -- for example:

```rust
    iter::zip(
        trait_ref.substs.types().skip(1),
        impl_trait_ref.substs.types().skip(1),
    )
    // vs.
    trait_ref
        .substs
        .types()
        .skip(1)
        .zip(impl_trait_ref.substs.types().skip(1))
```

This replaces the tuple-pair `IntoIterator` in #78204.
There is prior art for the utility of this in [`itertools::zip`].

[`itertools::zip`]: https://docs.rs/itertools/0.10.0/itertools/fn.zip.html
2021-03-27 20:37:07 +01:00
Dylan DPC
ebea9d948f
Rollup merge of #82626 - lcnr:encode_with_shorthandb, r=estebank
update array missing `IntoIterator` msg

fixes #82602

r? ```@estebank``` do you know whether we can use the expr span in `rustc_on_unimplemented`? The label isn't too great rn
2021-03-27 20:37:06 +01:00
Dylan DPC
a900677eb9
Rollup merge of #82525 - RalfJung:unaligned-ref-warn, r=petrochenkov
make unaligned_references future-incompat lint warn-by-default

and also remove the safe_packed_borrows lint that it replaces.

`std::ptr::addr_of!` has hit beta now and will hit stable in a month, so I propose we start fixing https://github.com/rust-lang/rust/issues/27060 for real: creating a reference to a field of a packed struct needs to eventually become a hard error; this PR makes it a warn-by-default future-incompat lint. (The lint already existed, this just raises its default level.) At the same time I removed the corresponding code from unsafety checking; really there's no reason an `unsafe` block should make any difference here.

For references to packed fields outside `unsafe` blocks, this means `unaligned_refereces` replaces the previous `safe_packed_borrows` warning with a link to https://github.com/rust-lang/rust/issues/82523 (and no more talk about unsafe blocks making any difference). So behavior barely changes, the warning is just worded differently. For references to packed fields inside `unsafe` blocks, this PR shows a new future-incompat warning.

Closes https://github.com/rust-lang/rust/issues/46043 because that lint no longer exists.
2021-03-27 20:37:05 +01:00
Dylan DPC
520c9a25df
Rollup merge of #81351 - lcnr:big-money-big-prices, r=oli-obk
combine: stop eagerly evaluating consts

`super_relate_consts` eagerly evaluates constants which doesn't seem too great.

I now also finally understand why all of the unused substs test passed. The reason being
that we just evaluated the constants in `super_relate_consts` 😆

While this change isn't strictly necessary as evaluating consts here doesn't hurt, it still feels a lot cleaner to do it this way

r? `@oli-obk` `@nikomatsakis`
2021-03-27 20:37:04 +01:00
Yuki Okushi
fa70398d6d
Rollup merge of #83526 - klensy:lazy-too, r=petrochenkov
lazily calls some fns

Replaced some fn's with it's lazy variants.
2021-03-28 01:33:16 +09:00