Commit Graph

115597 Commits

Author SHA1 Message Date
Yuki Okushi b7863f91c6
Rollup merge of #83202 - pickfire:patch-6, r=JohnTitor
Show details in cfg version unstable book
2021-03-17 15:20:56 +09:00
Yuki Okushi 70edab895d
Rollup merge of #83092 - petrochenkov:qspan, r=estebank
More precise spans for HIR paths

`Ty::assoc_item` is lowered to `<Ty>::assoc_item` in HIR, but `Ty` got span from the whole path.
This PR fixes that, and adjusts some diagnostic code that relied on `Ty` having the whole path span.

This is a pre-requisite for https://github.com/rust-lang/rust/pull/82868 (we cannot report suggestions like `Tr::assoc` -> `<dyn Tr>::assoc` with the current imprecise spans).
r? ````@estebank````
2021-03-17 15:20:54 +09:00
bors 0c341226ad Auto merge of #83084 - nagisa:nagisa/features-native, r=petrochenkov
Adjust `-Ctarget-cpu=native` handling in cg_llvm

When cg_llvm encounters the `-Ctarget-cpu=native` it computes an
explciit set of features that applies to the target in order to
correctly compile code for the host CPU (because e.g. `skylake` alone is
not sufficient to tell if some of the instructions are available or
not).

However there were a couple of issues with how we did this. Firstly, the
order in which features were overriden wasn't quite right – conceptually
you'd expect `-Ctarget-cpu=native` option to override the features that
are implicitly set by the target definition. However due to how other
`-Ctarget-cpu` values are handled we must adopt the following order
of priority:

* Features from -Ctarget-cpu=*; are overriden by
* Features implied by --target; are overriden by
* Features from -Ctarget-feature; are overriden by
* function specific features.

Another problem was in that the function level `target-features`
attribute would overwrite the entire set of the globally enabled
features, rather than just the features the
`#[target_feature(enable/disable)]` specified. With something like
`-Ctarget-cpu=native` we'd end up in a situation wherein a function
without `#[target_feature(enable)]` annotation would have a broader
set of features compared to a function with one such attribute. This
turned out to be a cause of heavy run-time regressions in some code
using these function-level attributes in conjunction with
`-Ctarget-cpu=native`, for example.

With this PR rustc is more careful about specifying the entire set of
features for functions that use `#[target_feature(enable/disable)]` or
`#[instruction_set]` attributes.

Sadly testing the original reproducer for this behaviour is quite
impossible – we cannot rely on `-Ctarget-cpu=native` to be anything in
particular on developer or CI machines.

cc https://github.com/rust-lang/rust/issues/83027 `@BurntSushi`
2021-03-17 05:46:08 +00:00
Yuki Okushi 55bdf7f188 Add more test case 2021-03-17 11:41:05 +09:00
Ivan Tham 21c157442c Add pub as optional check_front_matter
async-pub check created a regression for default
2021-03-17 09:04:08 +08:00
Ivan Tham c44a5feb05 Add help assertion for async pub test 2021-03-17 09:02:19 +08:00
Ivan Tham 9321efd8f7 Detect pub fn attr wrong order like `async pub`
Redirects `const? async? unsafe? pub` to `pub const? async? unsafe?`.

Fix #76437
2021-03-17 09:02:19 +08:00
Yuki Okushi 2d99e68940 Emit more pretty diagnostics for qualified paths 2021-03-17 09:57:58 +09:00
Yuki Okushi 8240f1a3d3 Fix bad diagnostics for anon params with qualified paths 2021-03-17 07:45:19 +09:00
Yuki Okushi ea355bc6be Fix bad diagnostics for anon params with ref 2021-03-17 07:45:19 +09:00
Eric Huss 65c01104d2 Update cargo 2021-03-16 15:42:44 -07:00
Joshua Nelson e3031fe22a Allow registering tool lints with `register_tool`
Previously, there was no way to add a custom tool prefix, even if the tool
itself had registered a lint:

 ```
 #![feature(register_tool)]
 #![register_tool(xyz)]
 #![warn(xyz::my_lint)]
 ```

```
$ rustc unknown-lint.rs  --crate-type lib
error[E0710]: an unknown tool name found in scoped lint: `xyz::my_lint`
 --> unknown-lint.rs:3:9
  |
3 | #![warn(xyz::my_lint)]
  |         ^^^
```

This allows opting-in to lints from other tools using `register_tool`.
2021-03-16 17:33:03 -04:00
Simonas Kazlauskas 72fb4379d5 Adjust `-Ctarget-cpu=native` handling in cg_llvm
When cg_llvm encounters the `-Ctarget-cpu=native` it computes an
explciit set of features that applies to the target in order to
correctly compile code for the host CPU (because e.g. `skylake` alone is
not sufficient to tell if some of the instructions are available or
not).

However there were a couple of issues with how we did this. Firstly, the
order in which features were overriden wasn't quite right – conceptually
you'd expect `-Ctarget-cpu=native` option to override the features that
are implicitly set by the target definition. However due to how other
`-Ctarget-cpu` values are handled we must adopt the following order
of priority:

* Features from -Ctarget-cpu=*; are overriden by
* Features implied by --target; are overriden by
* Features from -Ctarget-feature; are overriden by
* function specific features.

Another problem was in that the function level `target-features`
attribute would overwrite the entire set of the globally enabled
features, rather than just the features the
`#[target_feature(enable/disable)]` specified. With something like
`-Ctarget-cpu=native` we'd end up in a situation wherein a function
without `#[target_feature(enable)]` annotation would have a broader
set of features compared to a function with one such attribute. This
turned out to be a cause of heavy run-time regressions in some code
using these function-level attributes in conjunction with
`-Ctarget-cpu=native`, for example.

With this PR rustc is more careful about specifying the entire set of
features for functions that use `#[target_feature(enable/disable)]` or
`#[instruction_set]` attributes.

Sadly testing the original reproducer for this behaviour is quite
impossible – we cannot rely on `-Ctarget-cpu=native` to be anything in
particular on developer or CI machines.
2021-03-16 21:32:55 +02:00
bors f5d8117c33 Auto merge of #82536 - sexxi-goose:handle-patterns-take-2, r=nikomatsakis
2229: Handle patterns within closures correctly when `capture_disjoint_fields` is enabled

This PR fixes several issues related to handling patterns within closures when `capture_disjoint_fields` is enabled.
1. Matching is always considered a use of the place, even with `_` patterns
2. Compiler ICE when capturing fields in closures through `let` assignments

To do so, we

- Introduced new Fake Reads
- Delayed use of `Place` in favor of `PlaceBuilder`
- Ensured that `PlaceBuilder` can be resolved before attempting to extract `Place` in any of the pattern matching code

Closes rust-lang/project-rfc-2229/issues/27
Closes rust-lang/project-rfc-2229/issues/24
r? `@nikomatsakis`
2021-03-16 19:19:06 +00:00
Jethro Beekman 5bd50ef9be Simplify C compilation for Fortanix-SGX target 2021-03-16 18:17:25 +01:00
Joshua Nelson c1b99f0b90 Don't warn about old rustdoc lint names (temporarily)
Right now, rustdoc users have an unpleasant situation: they can either
use the new tool lint names (`rustdoc::non_autolinks`) or they can use
the old names (`non_autolinks`). If they use the tool lints, they get a
hard error on stable compilers, because rustc rejects all tool names it
doesn't recognize. If they use the old name, they get a warning to
rename the lint to the new name. The only way to compile without
warnings is to add `#[allow(renamed_removed_lints)]`, which defeats the
whole point of the change: we *want* people to switch to the new name.

To avoid people silencing the lint and never migrating to the tool lint,
this avoids warning about the old name, while still allowing you to use
the new name. Once the new `rustdoc` tool name makes it to the stable
channel, we can change these lints to warn again.

This adds the new lint functions `register_alias` and `register_ignored`
- I didn't see an existing way to do this.
2021-03-16 13:13:59 -04:00
Eric Huss 0701b5e24a Update books 2021-03-16 09:23:11 -07:00
Ivan Tham b5ca329616
Show details in cfg version unstable book 2021-03-16 23:15:44 +08:00
klensy 22f25484d6 use checkout@v2 2021-03-16 17:54:09 +03:00
Yuki Okushi ec074276ab
Rollup merge of #83196 - tmiasko:valid-range-delay-span-bug, r=oli-obk
Use delay_span_bug instead of panic in layout_scalar_valid_range

#83054 introduced validation of scalar range attributes, but panicking
code that uses the attribute remained reachable. Use `delay_span_bug`
instead to avoid the ICE.

Fixes #83180.
2021-03-16 23:54:03 +09:00
Yuki Okushi b62997fd24
Rollup merge of #83172 - pnkfelix:bootstrap-tell-me-what-to-do-about-tidy-on-beta, r=Mark-Simulacrum
More informative diagnotic from `x.py test` attempt atop beta checkout

Make bootstrap be more informative when one does `x.py test` on a beta checkout without other mods.

To be clear, by default running `x.py test` on a checkout of the beta branch
currently fails, and with this change will continue to fail, because `x.py
tests` runs `x.py test src/tools/tidy` which tries to run `rustfmt` and that
will fail because the `rustfmt` binary is pinned to the current nighlty and we
do not attempt to distribute one for the beta builds.

This change gives a better error message than the current message, which is just
"./x.py fmt is not supported on this channel" without providing any hint about
what one might do about that problem.
2021-03-16 23:54:02 +09:00
Yuki Okushi 896b44ab60
Rollup merge of #83157 - nagisa:nagisa/portability-background, r=GuillaumeGomez
No background for code in portability snippets

This better matches the appearance of this kind of snippet in the full
item view and is less jarring to read due to repeated
foreground-background changes.

![Listing of items in a module with some portability snippets attached to some of the items (light theme). The portability snippet has a light blue background and all of the text in it, monospace or not, is the same colour – black](https://user-images.githubusercontent.com/679122/111196363-1900f500-85b5-11eb-8f97-e283c59002a4.png)
![Listing of items in a module with some portability snippets attached to some of the items (dark theme). The portability snippet has a light blue background and all of the text in it, monospace or not, is the same colour – black](https://user-images.githubusercontent.com/679122/111196366-19998b80-85b5-11eb-9914-4d14d9d13ed3.png)

There should be no observable changes to the ayu theme.
2021-03-16 23:53:59 +09:00
Yuki Okushi 0f6b206ab4
Rollup merge of #83156 - nagisa:nagisa/sans-serif-please, r=GuillaumeGomez
Fall-back to sans-serif if Arial is not available

Otherwise on systems where Arial is not available the UA will
fallback to a serif font, rather than a sans-serif one.

This is especially relevant on acessibility-conscious setups (such as is
mine) that have web-fonts disabled and a limited set of fonts available
on the system.

r? ```@GuillaumeGomez``` cc ```@jsha```
2021-03-16 23:53:58 +09:00
Yuki Okushi dbdb2a1312
Rollup merge of #83077 - notriddle:gc-cleanup-rustdoc-search, r=GuillaumeGomez
rustdoc: reduce GC work during search
2021-03-16 23:53:55 +09:00
Daniel Silverstone bd2737fc96
ci/docker: Add SDK/NDK level 21 to android docker for 32bit platforms
Certain features of Linux (getauxval() and epoll_create1()) are only
available in android SDK/NDK levels 18 and 21 respectively.  The 32bit
platform is currently on level 14 for compatibility with Android 4.0.

This patch adds SDK/NDK level 21 to the docker for 32 bit platforms,
while leaving the default setup at level 14.

With this done, projects such as `rustup` which rely on these dockers
can build with modern ecosystem crates such as tokio 1.0, by using
the level 21 toolchain, but those which do not need to switch will
be unaffected, since the level 14 toolchain remains available.

Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2021-03-16 10:50:45 +00:00
Markus Westerlind 7cf8d3ac2b feat: Update hashbrown to instantiate less llvm IR
Includes https://github.com/rust-lang/hashbrown/pull/204 and https://github.com/rust-lang/hashbrown/pull/205 (not yet merged) which both server to reduce the amount of IR generated for hashmaps.

Inspired by the llvm-lines data gathered in https://github.com/rust-lang/rust/pull/76680
2021-03-16 11:20:26 +01:00
bors f24ce9b014 Auto merge of #82838 - Amanieu:rustdoc_asm, r=nagisa
Allow rustdoc to handle asm! of foreign architectures

This allows rustdoc to process code containing `asm!` for architectures other than the current one. Since this never reaches codegen, we just replace target-specific registers and register classes with a dummy one.

Fixes #82869
2021-03-16 10:05:46 +00:00
Vadim Petrochenkov d1522b39dd ast: Reduce size of `ExprKind` by boxing fields of `ExprKind::Struct` 2021-03-16 11:41:24 +03:00
Vadim Petrochenkov b25d3ba781 ast/hir: Rename field-related structures
StructField -> FieldDef ("field definition")
Field -> ExprField ("expression field", not "field expression")
FieldPat -> PatField ("pattern field", not "field pattern")

Also rename visiting and other methods working on them.
2021-03-16 11:41:24 +03:00
bors 195ad4830e Auto merge of #82898 - oli-obk:tait_🧊, r=nikomatsakis
Add a `min_type_alias_impl_trait` feature gate

This new feature gate only permits type alias impl trait to be constrained by function and trait method return types. All other possible constraining sites like const/static types, closure return types and binding types are now forbidden and gated under the `type_alias_impl_trait` and `impl_trait_in_bindings` feature gates (which are both marked as incomplete, as they have various ways to ICE the compiler or cause query cycles where they shouldn't).

r? `@nikomatsakis`

This is best reviewed commit-by-commit
2021-03-16 04:24:48 +00:00
Felix S. Klock II d6de60fb32 Make bootstrap be more informative when one does `x.py test` on a beta checkout without other mods.
To be clear, by default running `x.py test` on a checkout of the beta branch
currently fails, and with this change will continue to fail, because `x.py
tests` runs `x.py test src/tools/tidy` which tries to run `rustfmt` and that
will fail because the `rustfmt` binary is pinned to the current nighlty and we
do not attempt to distribute one for the beta builds.

This change gives a better error message than the current message, which is just
"./x.py fmt is not supported on this channel" without providing any hint about
what one might do about that problem.

(update: placated tidy.)
2021-03-15 23:19:35 -04:00
Tomasz Miąsko 0d84e0b68c Add test case for -Zinline-mir & -Zinstrument-coverage 2021-03-16 00:00:00 +00:00
Tomasz Miąsko 335427a3db Use delay_span_bug instead of panic in layout_scalar_valid_range
83054 introduced validation of scalar range attributes, but panicking
code that uses the attribute remained reachable. Use `delay_span_bug`
instead to avoid the ICE.
2021-03-16 00:00:00 +00:00
Tomasz Miąsko 4b6cc0c204 Add support for compile-flags in coverage tests 2021-03-15 23:26:03 +01:00
Tomasz Miąsko ad8f9af7cb Remove inline-instrument-coverage-fail.rs test case 2021-03-15 23:26:03 +01:00
Vadim Petrochenkov e98b7d1bcf Update clippy tests 2021-03-16 00:12:38 +03:00
Aaron Hill d6a7c1d47f
Extend `proc_macro_back_compat` lint to `procedural-masquerade`
We now lint on *any* use of `procedural-masquerade` crate. While this
crate still exists, its main reverse dependency (`cssparser`) no longer
depends on it. Any crates still depending off should stop doing so, as
it only exists to support very old Rust versions.

If a crate actually needs to support old versions of rustc via
`procedural-masquerade`, then they'll just need to accept the warning
until we remove it entirely (at the same time as the back-compat hack).
The latest version of `procedural-masquerade` does not work with the
latest rustc, but trying to check for the version seems like more
trouble than it's worth.

While working on this, I realized that the `proc-macro-hack` check was
never actually doing anything. The corresponding enum variant in
`proc-macro-hack` is named `Value` or `Nested` - it has never been
called `Input`. Due to a strange Crater issue, the Crater run that
tested adding this did *not* end up testing it - some of the crates that
would have failed did not actually have their tests checked, making it
seem as though the `proc-macro-hack` check was working.

The Crater issue is being discussed at
https://rust-lang.zulipchat.com/#narrow/stream/242791-t-infra/topic/Nearly.20identical.20Crater.20runs.20processed.20a.20crate.20differently/near/230406661

Despite the `proc-macro-hack` check not actually doing anything, we
haven't gotten any reports from users about their build being broken.
I went ahead and removed it entirely, since it's clear that no one is
being affected by the `proc-macro-hack` regression in practice.
2021-03-15 16:00:49 -04:00
Vadim Petrochenkov 7e66e9d6b0 More precise spans for HIR paths 2021-03-15 22:13:45 +03:00
Michael Howell dcba95f43e Declare `word` outside the loop, as recommended by eslint 2021-03-15 11:58:34 -07:00
Oli Scherer e67594166e Run tests in nll mode 2021-03-15 18:35:47 +00:00
Oli Scherer 6109d73112 🍼 for tidy 2021-03-15 17:39:13 +00:00
Oli Scherer 4a6dc8e203 Only allow tait defining uses in function and method return position 2021-03-15 17:36:57 +00:00
Simonas Kazlauskas 9aa48ba13b No background for code in portability snippets
This better matches the appearance of this kind of snippet in the full
item view and is less jarring to read due to repeated
foreground-background changes.
2021-03-15 19:36:27 +02:00
Oli Scherer 3abdb08351 Add a test showing how `impl_trait_in_bindings` is a breaking change 2021-03-15 17:33:20 +00:00
Oli Scherer 1f7df1956a Replace `type_alias_impl_trait` by `min_type_alias_impl_trait` with no actual changes in behaviour
This makes `type_alias_impl_trait` not actually do anything anymore
2021-03-15 17:32:43 +00:00
Simonas Kazlauskas 7134b0ee67 Fall-back to sans-serif if Arial is not available
Otherwise on systems where Arial is not available the system will
fallback to a serif font, rather than a sans-serif one.

This is especially relevant on acessibility-conscious setups (such as is
mine) that have web-fonts disabled and a limited set of fonts available
on the system.
2021-03-15 19:22:15 +02:00
Roxane 189d206522 Fix error after rebase 2021-03-15 13:16:18 -04:00
Roxane 22eaffe71a Add comments with examples and tests 2021-03-15 13:16:04 -04:00
Oli Scherer 19dce738f9 Delete non-revision ui test output file if revisions are used 2021-03-15 16:56:19 +00:00
Oli Scherer 5553301137 Make regression test succeed as long as it ICEs 2021-03-15 16:56:12 +00:00
Oli Scherer 327cc62b0d Add reproduction test 2021-03-15 16:46:45 +00:00
Dylan DPC 2816c110e0
Rollup merge of #83144 - hyd-dev:parse-sess-created, r=oli-obk
Introduce `rustc_interface::interface::Config::parse_sess_created` callback

Resolves #82900.

cc `@oli-obk`
2021-03-15 16:23:00 +01:00
Dylan DPC 13eac5b236
Rollup merge of #83141 - lnicola:rust-analyzer-2021-03-15, r=jonas-schievink
⬆️ rust-analyzer
2021-03-15 16:22:59 +01:00
Dylan DPC 9b16c7a712
Rollup merge of #83132 - Aaron1011:fix/incr-cache-dummy, r=estebank
Don't encode file information for span with a dummy location

Fixes #83112

The location information for a dummy span isn't real, so don't encode
it. This brings the incr comp cache code into line with the Span
`StableHash` impl, which doesn't hash the location information for dummy
spans.

Previously, we would attempt to load the 'original' file from a dummy
span - if the file id changed (e.g. due to being moved on disk), we would get an
ICE, since the Span was still valid due to its hash being unchanged.
2021-03-15 16:22:58 +01:00
Dylan DPC d1f5f1d156
Rollup merge of #83127 - Aaron1011:time-macros-impl-warn, r=petrochenkov
Introduce `proc_macro_back_compat` lint, and emit for `time-macros-impl`

Now that future-incompat-report support has landed in nightly Cargo, we
can start to make progress towards removing the various proc-macro
back-compat hacks that have accumulated in the compiler.

This PR introduces a new lint `proc_macro_back_compat`, which results in
a future-incompat-report entry being generated. All proc-macro
back-compat warnings will be grouped under this lint. Note that this
lint will never actually become a hard error - instead, we will remove
the special cases for various macros, which will cause older versions of
those crates to emit some other error.

I've added code to fire this lint for the `time-macros-impl` case. This
is the easiest case out of all of our current back-compat hacks - the
crate was renamed to `time-macros`, so seeing a filename with
`time-macros-impl` guarantees that an older version of the parent `time`
crate is in use.

When Cargo's future-incompat-report feature gets stabilized, affected
users will start to see future-incompat warnings when they build their
crates.
2021-03-15 16:22:57 +01:00
Dylan DPC 75a15bf275
Rollup merge of #83098 - camelid:more-doc-attr-check, r=davidtwco
Find more invalid doc attributes

- Lint on `#[doc(123)]`, `#[doc("hello")]`, etc.
- Lint every attribute; e.g., will now report two warnings for `#[doc(foo, bar)]`
- Add hyphen to "crate level"
- Display paths like `#[doc(foo::bar)]` correctly instead of as an empty string
2021-03-15 16:22:52 +01:00
Dylan DPC b8622f2b3b
Rollup merge of #83054 - tmiasko:rustc_layout_scalar_valid_range, r=davidtwco
Validate rustc_layout_scalar_valid_range_{start,end} attributes

Fixes #82251, fixes #82981.
2021-03-15 16:22:51 +01:00
Dylan DPC 4eca4929ec
Rollup merge of #82989 - Smittyvb:other-lang-literal-errors, r=varkor
Custom error on literal names from other languages

This detects all Java literal types and all single word C data types, and suggests the corresponding Rust literal type.
2021-03-15 16:22:50 +01:00
hyd-dev 0bbfd548ec
Fix `src/test/run-make-fulldeps/issue-19371` 2021-03-15 21:16:39 +08:00
Smitty 5eae9af193 Custom error on literal names from other languages
This detects all Java literal types and all single word C data types,
and suggests the corresponding Rust literal type.
2021-03-15 08:11:02 -04:00
Laurențiu Nicola ebe51cfced ⬆️ rust-analyzer 2021-03-15 13:55:56 +02:00
bors 7a7bbdb3ab Auto merge of #83118 - erikdesjardins:removezst, r=oli-obk
Rebase and fixup #80493: Remove MIR assignments to ZST types

closes #80493

cc `@simonvandel`

r? `@oli-obk`
2021-03-15 11:30:33 +00:00
hyd-dev 176bb6bd38
Use `rustc_interface::interface::Config::parse_sess_created` in Clippy 2021-03-15 18:25:04 +08:00
hyd-dev d7ab3c77b3
Add `rustc_interface::interface::Config::parse_sess_created` 2021-03-15 18:24:58 +08:00
bors 3963c3da02 Auto merge of #83074 - Aaron1011:new-sort-fix, r=jackh726
Avoid sorting predicates by `DefId`

Fixes issue #82920

Even if an item does not change between compilation sessions, it may end
up with a different `DefId`, since inserting/deleting an item affects
the `DefId`s of all subsequent items. Therefore, we use a `DefPathHash`
in the incremental compilation system, which is stable in the face of
changes to unrelated items.

In particular, the query system will consider the inputs to a query to
be unchanged if any `DefId`s in the inputs have their `DefPathHash`es
unchanged. Queries are pure functions, so the query result should be
unchanged if the query inputs are unchanged.

Unfortunately, it's possible to inadvertantly make a query result
incorrectly change across compilations, by relying on the specific value
of a `DefId`. Specifically, if the query result is a slice that gets
sorted by `DefId`, the precise order will depend on how the `DefId`s got
assigned in a particular compilation session. If some definitions end up
with different `DefId`s (but the same `DefPathHash`es) in a subsequent
compilation session, we will end up re-computing a *different* value for
the query, even though the query system expects the result to unchanged
due to the unchanged inputs.

It turns out that we have been sorting the predicates computed during
`astconv` by their `DefId`. These predicates make their way into the
`super_predicates_that_define_assoc_type`, which ends up getting used to
compute the vtables of trait objects. This, re-ordering these predicates
between compilation sessions can lead to undefined behavior at runtime -
the query system will re-use code built with a *differently ordered*
vtable, resulting in the wrong method being invoked at runtime.

This PR avoids sorting by `DefId` in `astconv`, fixing the
miscompilation. However, it's possible that other instances of this
issue exist - they could also be easily introduced in the future.

To fully fix this issue, we should
1. Turn on `-Z incremental-verify-ich` by default. This will cause the
   compiler to ICE whenver an 'unchanged' query result changes between
   compilation sessions, instead of causing a miscompilation.
2. Remove the `Ord` impls for `CrateNum` and `DefId`. This will make it
   difficult to introduce ICEs in the first place.
2021-03-15 06:20:24 +00:00
Aaron Hill f190bc4f47
Introduce `proc_macro_back_compat` lint, and emit for `time-macros-impl`
Now that future-incompat-report support has landed in nightly Cargo, we
can start to make progress towards removing the various proc-macro
back-compat hacks that have accumulated in the compiler.

This PR introduces a new lint `proc_macro_back_compat`, which results in
a future-incompat-report entry being generated. All proc-macro
back-compat warnings will be grouped under this lint. Note that this
lint will never actually become a hard error - instead, we will remove
the special cases for various macros, which will cause older versions of
those crates to emit some other error.

I've added code to fire this lint for the `time-macros-impl` case. This
is the easiest case out of all of our current back-compat hacks - the
crate was renamed to `time-macros`, so seeing a filename with
`time-macros-impl` guarantees that an older version of the parent `time`
crate is in use.

When Cargo's future-incompat-report feature gets stabilized, affected
users will start to see future-incompat warnings when they build their
crates.
2021-03-14 21:31:46 -04:00
Aaron Hill 7429c688a5
Don't encode file information for span with a dummy location
Fixes #83112

The location information for a dummy span isn't real, so don't encode
it. This brings the incr comp cache code into line with the Span
`StableHash` impl, which doesn't hash the location information for dummy
spans.

Previously, we would attempt to load the 'original' file from a dummy
span - if the file id changed (e.g. due to being moved on disk), we would get an
ICE, since the Span was still valid due to its hash being unchanged.
2021-03-14 20:22:13 -04:00
Roxane fb3b77a8c8 Add fake_read() to clippy 2021-03-14 19:45:24 -04:00
Roxane 74fc64303f Only borrow place for matching under specific conditions 2021-03-14 19:42:00 -04:00
Roxane 685a4c6b6b Use the correct FakeReadCause 2021-03-14 19:28:57 -04:00
Amanieu d'Antras ba00ddc39a Address review comments 2021-03-14 23:21:03 +00:00
Michael Howell 8eba927a3e Make nameWithoutUndescores lowercased
This basically fixes a search bug introduced by earlier changes.
2021-03-14 14:45:00 -07:00
bors d6eaea1c88 Auto merge of #83062 - JohnTitor:improve-reassign-err, r=davidtwco
Improve the wording for the `can't reassign` error

Follow-up for https://github.com/rust-lang/rust/pull/71976#discussion_r448186151.
Fixes #66736
2021-03-14 21:10:50 +00:00
Roxane b6cf070eb4 Attempt to deal with nested closures properly 2021-03-14 17:07:59 -04:00
Camelid 13076f90d2 Tweak diagnostics
- Tweak lint message
- Display multi-segment paths correctly
2021-03-14 14:00:02 -07:00
Roxane ec10b71d42 Introduce new fake reads 2021-03-14 16:31:26 -04:00
Erik Desjardins 1b7b33e513 bless tests (32-bit) 2021-03-14 13:53:16 -04:00
Michael Howell f57d71533e Use a number for row.id, instead of a string
There's no reason for it to be a string, since it's only used for
de-duplicating the results arrays anyhow.
2021-03-14 10:17:20 -07:00
Michael Howell 0bfd142926 Avoid generating new strings for names that have no undescores
This should have negligible effect on time, but it cuts about 1MiB
off of resident memory usage.
2021-03-14 10:16:09 -07:00
Vadim Petrochenkov a4cc3cae04 expand: Resolve and expand inner attributes on out-of-line modules 2021-03-14 18:10:29 +03:00
bors 84c08f82b4 Auto merge of #83044 - kubo39:set-llvm-code-model, r=nikic
Add support for storing code model to LLVM module IR

This patch avoids undefined behavior by linking different object files.
Also this would it could be propagated properly to LTO.

See https://reviews.llvm.org/D52322 and https://reviews.llvm.org/D52323.

This patch is based on https://github.com/rust-lang/rust/pull/74002
2021-03-14 11:46:57 +00:00
bors f293f70dd8 Auto merge of #83094 - GuillaumeGomez:crates-js-location, r=Nemo157
crates.js should use root_path and not static_root_path

r? `@Nemo157`
2021-03-14 09:16:23 +00:00
bors 2caeeb0527 Auto merge of #83028 - GuillaumeGomez:prevent-js-error-if-no-filter, r=Nemo157
Prevent JS error when there is no dependency or other crate documented (or --disable-per-crate-search has been used)

When there is only one crate, the dropdown is removed, creating an error (that you can see pretty easily on docs.rs for example).

r? `@jyn514`
2021-03-14 06:35:19 +00:00
Yuki Okushi f8206ac63d
Rollup merge of #83081 - hyd-dev:assert-message, r=m-ou-se
Fix panic message of `assert_failed_inner`

cc https://github.com/rust-lang/rust/pull/79100#discussion_r593731020

r? ``@m-ou-se``
2021-03-14 13:07:37 +09:00
Yuki Okushi bc79367d32
Rollup merge of #83070 - ehuss:update-cargo, r=ehuss
Update cargo

7 commits in 970bc67c3775781b9708c8a36893576b9459c64a..32da9eaa5de5be241cf8096ca6b749a157194f77
2021-03-07 18:09:40 +0000 to 2021-03-13 01:18:40 +0000
- Fix logic for determining prefer-dynamic for a dylib. (rust-lang/cargo#9252)
- Fix issue with filtering exclusive target dependencies. (rust-lang/cargo#9255)
- Update pkgid-spec docs. (rust-lang/cargo#9249)
- Wordsmith the edition documentation a bit more (rust-lang/cargo#9233)
- Package ID specification urls must contain a host (rust-lang/cargo#9188)
- Add documentation for JSON message_path. (rust-lang/cargo#9247)
- Fix filter_platform to run on targets other than x86. (rust-lang/cargo#9246)
2021-03-14 13:07:36 +09:00
Yuki Okushi 33614023a1
Rollup merge of #82798 - jyn514:rustdoc-group, r=Manishearth,GuillaumeGomez
Rename `rustdoc` to `rustdoc::all`

When rustdoc lints were changed to be tool lints, the `rustdoc` group was removed, leading to spurious warnings like

```
warning: unknown lint: `rustdoc`
```

The lint group still worked when rustdoc ran, since rustdoc added the group itself.

This renames the group to `rustdoc::all` for consistency with `clippy::all` and the rest of the rustdoc lints.

Follow-up to #80527.
r? ``@Manishearth``
2021-03-14 13:07:32 +09:00
Yuki Okushi 0d9a6edb50
Rollup merge of #82789 - csmoe:issue-82772, r=estebank
Get with field index from pattern slice instead of directly indexing

Closes #82772
r? ``@estebank``

https://github.com/rust-lang/rust/pull/82789#issuecomment-796921977
> ``@estebank`` So the real cause is we only generate single pattern for Box here
615b03aeaa/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs (L1130-L1132)
But in the replacing function, it tries to index on the 1-length pattern slice with field 1, thus out of bounds.
615b03aeaa/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs (L1346)
2021-03-14 13:07:31 +09:00
Erik Desjardins 0f9af604cf bless tests 2021-03-13 23:04:38 -05:00
Camelid 13884dc2af Update `rustdoc-ui` versions of the `doc-attr` test
It seems there are two copies of it: one in `src/test/ui/attributes/`
and one in `src/test/rustdoc-ui/`. I'm guessing this is to test that the
lint is emitted both when you run the compiler and when you run rustdoc.
2021-03-13 16:36:38 -08:00
Camelid 5134047c40 Add hyphen to "crate level"
"crate level attribute" -> "crate-level attribute"
2021-03-13 16:29:49 -08:00
Simon Vandel Sillesen 35566bfd7d Do not emit alloca for ZST local even if it is uninitialized 2021-03-13 18:01:14 -05:00
Simon Vandel Sillesen bb36e3c7e7 Move ZST check inside UsedLocals 2021-03-13 18:00:28 -05:00
Simon Vandel Sillesen 4e901be57d Extend SimplifyLocals to remove ZST writes 2021-03-13 17:58:11 -05:00
Camelid fe64970ed1 Add another test case 2021-03-13 13:55:15 -08:00
Camelid 7e972a39b8 Report error for each invalid nested attribute 2021-03-13 13:55:15 -08:00
Camelid 7189c05bf8 Lint non-meta doc attributes
E.g., `#[doc(123)]`.
2021-03-13 13:25:27 -08:00
Amanieu d'Antras fa3694fada Always lower asm! to valid HIR 2021-03-13 20:49:32 +00:00
Guillaume Gomez 48a3bcd860 crates.js should use root_path and not static_root_path 2021-03-13 21:21:03 +01:00
Aaron Hill 06546d4b40
Avoid sorting predicates by `DefId`
Fixes issue #82920

Even if an item does not change between compilation sessions, it may end
up with a different `DefId`, since inserting/deleting an item affects
the `DefId`s of all subsequent items. Therefore, we use a `DefPathHash`
in the incremental compilation system, which is stable in the face of
changes to unrelated items.

In particular, the query system will consider the inputs to a query to
be unchanged if any `DefId`s in the inputs have their `DefPathHash`es
unchanged. Queries are pure functions, so the query result should be
unchanged if the query inputs are unchanged.

Unfortunately, it's possible to inadvertantly make a query result
incorrectly change across compilations, by relying on the specific value
of a `DefId`. Specifically, if the query result is a slice that gets
sorted by `DefId`, the precise order will depend on how the `DefId`s got
assigned in a particular compilation session. If some definitions end up
with different `DefId`s (but the same `DefPathHash`es) in a subsequent
compilation session, we will end up re-computing a *different* value for
the query, even though the query system expects the result to unchanged
due to the unchanged inputs.

It turns out that we have been sorting the predicates computed during
`astconv` by their `DefId`. These predicates make their way into the
`super_predicates_that_define_assoc_type`, which ends up getting used to
compute the vtables of trait objects. This, re-ordering these predicates
between compilation sessions can lead to undefined behavior at runtime -
the query system will re-use code built with a *differently ordered*
vtable, resulting in the wrong method being invoked at runtime.

This PR avoids sorting by `DefId` in `astconv`, fixing the
miscompilation. However, it's possible that other instances of this
issue exist - they could also be easily introduced in the future.

To fully fix this issue, we should
1. Turn on `-Z incremental-verify-ich` by default. This will cause the
   compiler to ICE whenver an 'unchanged' query result changes between
   compilation sessions, instead of causing a miscompilation.
2. Remove the `Ord` impls for `CrateNum` and `DefId`. This will make it
   difficult to introduce ICEs in the first place.
2021-03-13 13:45:12 -05:00
Michael Howell d92f8405ce Remove tab character 2021-03-13 10:29:21 -07:00