Commit Graph

13423 Commits

Author SHA1 Message Date
Oli Scherer
0a6b69106e Add a query for checking whether a function is an intrinsic. 2022-05-16 07:07:44 +00:00
bors
42e1761c70 Auto merge of #97057 - bjorn3:sync_cg_clif-2022-05-15, r=bjorn3
Sync rustc_codegen_cranelift

Since the last sync there have mostly been fixes of various sorts. I also changed cg_clif from using a custom driver to `-Zcodegen-backend` when built as separate project. When built as part of rust it was already using `-Zcodegen-backend`.

r? `@ghost`

`@rustbot` label +A-codegen +A-cranelift +T-compiler
2022-05-15 21:17:46 +00:00
bors
0f202d22c5 Auto merge of #96895 - SparrowLii:interval, r=Mark-Simulacrum
optimize `insert_range` method of `IntervalSet`

This PR fixes the FIXME in the `insert_range` method that avoids recurse calculations when overlaping
2022-05-15 16:27:43 +00:00
bjorn3
a06deb5191 Compute pre_compiled_cgus more eagerly
This reduces the complexity of this code a lot
2022-05-15 11:49:25 +00:00
bjorn3
1c1f16c3e3 Move cgu_reuse a bit earlier
There is no reason it needs to be lazily computed at the first iteration
of the cgu loop.
2022-05-15 11:49:25 +00:00
bors
10b3a0d209 Auto merge of #96885 - petrochenkov:linkstrict2, r=cjgillot,luqmana
rustc: Stricter checking for #[link] attributes

A subset of https://github.com/rust-lang/rust/pull/94962 that doesn't touch library renaming/reordering/deduplication.

`#[link]` attributes are checked for all kinds of unexpected arguments inside them.
I also tried to make wording for these errors more consistent, that's why some existing errors are changed, including errors for command line `-l` options.
Spans are also made more precise where possible.
2022-05-15 11:19:27 +00:00
bjorn3
ecd8fa1a75 Merge commit '63734fcdd718cca089f84c42f3a42c0096cfd431' into sync_cg_clif-2022-05-15 2022-05-15 12:32:19 +02:00
Matthias Krüger
673d45124b
Rollup merge of #97032 - est31:unused_macro_rules, r=petrochenkov
Allow the unused_macro_rules lint for now

It was newly added by #96150 with warn by default, which is great as it gave exposure to the community, and their feedback gave me ideas for improvements.

Allowing the lint is good for two reasons:

* It makes the transition easier as e.g. allow directives won't fire the unknown lint warning once it is turned to warn by default in the future. The [commit that allowed the lint in fuchsia](https://fuchsia.googlesource.com/fuchsia/+/9d8f96517c3963de2f0e25598fd36061914524cd%5E%21/) had to allow unknown lints for example.
This is especially important compared to other lints in the unused group,
because the _ prefix trick doesn't exist for macro rules, allowing is the
only option (either of unused_macro_rules, or of the entire unused group,
but that is not as informative to readers). Allowing the lint also makes it
possible to work on possible heuristics for disabling the macro in specific
cases.
* It gives time for implementing heuristics for when to suppress the lint, e.g.
when `compile_error!` is invoked by that arm (so it's only there to yield an error).

See: https://github.com/rust-lang/rust/pull/96150#issuecomment-1126599107

I would also like this to be backported to the 1.62 beta branch (cc #97016).
2022-05-15 08:10:42 +02:00
bors
2a8a0fc423 Auto merge of #96883 - jackh726:early-binder-2, r=oli-obk
Add EarlyBinder

Chalk has no concept of `Param` (e0ade19d13/chalk-ir/src/lib.rs (L579)) or `ReEarlyBound` (e0ade19d13/chalk-ir/src/lib.rs (L1308)). Everything  is just "bound" - the equivalent of rustc's late-bound. It's not completely clear yet whether to move everything to the same time of binder in rustc or add `Param` and `ReEarlyBound` in Chalk.

Either way, tracking when we have or haven't already substituted out these in rustc can be helpful.

As a first step, I'm just adding a `EarlyBinder` newtype that is required to call `subst`. I also add a couple "transparent" `bound_*` wrappers around a couple query that are often immediately substituted.

r? `@nikomatsakis`
2022-05-14 23:53:11 +00:00
Vadim Petrochenkov
4fa24bcb54 rustc: Stricter checking for #[link] attributes 2022-05-15 02:45:47 +03:00
Miguel Guarniz
48fd66613b allocate string only when error will be emitted
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-14 12:23:23 -04:00
bors
b36be12d97 Auto merge of #97039 - cjgillot:no-rpit-hrtb, r=jackh726
Forbid nested opaque types to reference HRTB from opaque types.

Avoids https://github.com/rust-lang/rust/issues/96194
Alternative to https://github.com/rust-lang/rust/pull/96970

r? `@oli-obk`
2022-05-14 15:47:22 +00:00
Miguel Guarniz
f77658b470 use opt_item_name to pattern match items with names
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-14 11:02:14 -04:00
Miguel Guarniz
959636d531 avoid fetching HIR when handling Impl assoc items
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-14 11:01:33 -04:00
Jack Huey
06a1e8854c Add rustc_on_unimplemented to Subst 2022-05-14 10:16:59 -04:00
Jack Huey
91afd02632 Add bound_explicit_item_bounds and bound_item_bounds 2022-05-14 10:16:49 -04:00
bors
2d69117088 Auto merge of #96345 - petrochenkov:linclean, r=notriddle
rustdoc: Cleanup doc link resolution

See individual commits for specific changes
2022-05-14 13:24:34 +00:00
bors
8019fa0dc0 Auto merge of #95826 - carbotaniuman:miri-permissive-provenance, r=RalfJung
Initial work on Miri permissive-exposed-provenance

Rustc portion of the changes for portions of a permissive ptr-to-int model for Miri. The main changes here are changing `ptr_get_alloc` and `get_alloc_id` to return an Option, and also making ptr-to-int casts have an expose side effect.
2022-05-14 10:36:47 +00:00
est31
015e2ae769 Allow the unused_macro_rules lint for now
This makes the transition easier as e.g. allow directives
won't fire the unknown lint warning once it is turned to
warn by default in the future. This is especially
important compared to other lints in the unused group
because the _ prefix trick doesn't exist for macro rules,
so allowing is the only option (either of unused_macro_rules,
or of the entire unused group, but that is not as informative
to readers). Allowing the lint also makes it possible to work
on possible heuristics for disabling the macro in specific
cases.
2022-05-14 12:31:14 +02:00
Camille GILLOT
b276b65f46 Forbid nested opaque types to reference HRTB from opaque types. 2022-05-14 11:38:25 +02:00
bors
17180f4a56 Auto merge of #94872 - mati865:mingw-llvm-target, r=petrochenkov
Add MVP LLVM based mingw-w64 targets

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

Those are `rustc` side changes to create working x86_64 and AArch64 Rustc hosts and targets.
Apart from this PR changes to various crates are required which I'll do once this is accepted.

I'm expecting more changes on `rustc` side later on as I cannot even run full testsuite at this moment because passing JSON spec breaks paths in various tests.

Tier 3 policy:

> A tier 3 target must have a designated developer or developers (the "target maintainers") on record to be CCed when issues arise regarding the target. (The mechanism to track and CC such developers may evolve over time.)

I pledge to do my best maintaining it, MSYS2 is one of interested consumers so it should have enough testing (after the releases).

 > Targets must use naming consistent with any existing targets; for instance, a target for the same CPU or OS as an existing Rust target should use the same name for that CPU or OS. Targets should normally use the same names and naming conventions as used elsewhere in the broader ecosystem beyond Rust (such as in other toolchains), unless they have a very good reason to diverge. Changing the name of a target can be highly disruptive, especially once the target reaches a higher tier, so getting the name right is important even for a tier 3 target.

This triple name was discussed at [`t-compiler/LLVM+mingw-w64 Windows targets`](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/LLVM.2Bmingw-w64.20Windows.20targets)

> Target names should not introduce undue confusion or ambiguity unless absolutely necessary to maintain ecosystem compatibility. For example, if the name of the target makes people extremely likely to form incorrect beliefs about what it targets, the name should be changed or augmented to disambiguate it.

I think the explanation in platform support doc is enough to make this aspect clear.

> Tier 3 targets may have unusual requirements to build or use, but must not create legal issues or impose onerous legal terms for the Rust project or for Rust developers or users.

It's using open source tools only.

> The target must not introduce license incompatibilities.

It's even more liberal than already existing `*-pc-windows-gnu`.

> Anything added to the Rust repository must be under the standard Rust license (MIT OR Apache-2.0).

Understood.

> The target must not cause the Rust tools or libraries built for any other host (even when supporting cross-compilation to the target) to depend on any new dependency less permissive than the Rust licensing policy. This applies whether the dependency is a Rust crate that would require adding new license exceptions (as specified by the tidy tool in the rust-lang/rust repository), or whether the dependency is a native library or binary. In other words, the introduction of the target must not cause a user installing or running a version of Rust or the Rust tools to be subject to any new license requirements.

There are no new dependencies/features required.

> Compiling, linking, and emitting functional binaries, libraries, or other code for the target (whether hosted on the target itself or cross-compiling from another target) must not depend on proprietary (non-FOSS) libraries. Host tools built for the target itself may depend on the ordinary runtime libraries supplied by the platform and commonly used by other applications built for the target, but those libraries must not be required for code generation for the target; cross-compilation to the target must not require such libraries at all. For instance, rustc built for the target may depend on a common proprietary C runtime library or console output library, but must not depend on a proprietary code generation library or code optimization library. Rust's license permits such combinations, but the Rust project has no interest in maintaining such combinations within the scope of Rust itself, even at tier 3.

As previously said it's using open source tools only.

> "onerous" here is an intentionally subjective term. At a minimum, "onerous" legal/licensing terms include but are not limited to: non-disclosure requirements, non-compete requirements, contributor license agreements (CLAs) or equivalent, "non-commercial"/"research-only"/etc terms, requirements conditional on the employer or employment of any particular Rust developers, revocable terms, any requirements that create liability for the Rust project or its developers or users, or any requirements that adversely affect the livelihood or prospects of the Rust project or its developers or users.

There are no such terms present/

> Neither this policy nor any decisions made regarding targets shall create any binding agreement or estoppel by any party. If any member of an approving Rust team serves as one of the maintainers of a target, or has any legal or employment requirement (explicit or implicit) that might affect their decisions regarding a target, they must recuse themselves from any approval decisions regarding the target's tier status, though they may otherwise participate in discussions.

I'm not the reviewer here.

> This requirement does not prevent part or all of this policy from being cited in an explicit contract or work agreement (e.g. to implement or maintain support for a target). This requirement exists to ensure that a developer or team responsible for reviewing and approving a target does not face any legal threats or obligations that would prevent them from freely exercising their judgment in such approval, even if such judgment involves subjective matters or goes beyond the letter of these requirements.

Again I'm not the reviewer here.

> Tier 3 targets should attempt to implement as much of the standard libraries as possible and appropriate (core for most targets, alloc for targets that can support dynamic memory allocation, std for targets with an operating system or equivalent layer of system-provided functionality), but may leave some code unimplemented (either unavailable or stubbed out as appropriate), whether because the target makes it impossible to implement or challenging to implement. The authors of pull requests are not obligated to avoid calling any portions of the standard library on the basis of a tier 3 target not implementing those portions.

> The target must provide documentation for the Rust community explaining how to build for the target, using cross-compilation if possible. If the target supports running binaries, or running tests (even if they do not pass), the documentation must explain how to run such binaries or tests for the target, using emulation if possible or dedicated hardware if necessary.

Building is described in platform support doc, running tests doesn't work right now (without hacks) because Rust's build system doesn't seem to support testing targets built from `.json`.
Docs will be updated once this lands in beta allowing master branch to build and run tests without `.json` files.

> Tier 3 targets must not impose burden on the authors of pull requests, or other developers in the community, to maintain the target. In particular, do not post comments (automated or manual) on a PR that derail or suggest a block on the PR based on a tier 3 target. Do not send automated messages or notifications (via any medium, including via `@)` to a PR author or others involved with a PR regarding a tier 3 target, unless they have opted into such messages.

Understood.

> Backlinks such as those generated by the issue/PR tracker when linking to an issue or PR are not considered a violation of this policy, within reason. However, such messages (even on a separate repository) must not generate notifications to anyone involved with a PR who has not requested such notifications.

Understood.

 > Patches adding or updating tier 3 targets must not break any existing tier 2 or tier 1 target, and must not knowingly break another tier 3 target without approval of either the compiler team or the maintainers of the other tier 3 target.

I believe I didn't break any other target.

> In particular, this may come up when working on closely related targets, such as variations of the same architecture with different features. Avoid introducing unconditional uses of features that another variation of the target may not have; use conditional compilation or runtime detection, as appropriate, to let each target run code supported by that target.

I think there are no such problems in this PR.
2022-05-14 08:20:11 +00:00
Yuki Okushi
e239fd2b88
Rollup merge of #97031 - eholk:drop-tracking-type-error, r=compiler-errors
Drop tracking: handle invalid assignments better

Previously this test case was crashing with an index out of bounds error deep in the call to `needs_drop`. We avoid this by detecting clearly invalid assignees in the `mutate` callback and ignoring these.
2022-05-14 13:42:55 +09:00
Yuki Okushi
e6fc0c4b43
Rollup merge of #97005 - est31:master, r=petrochenkov
Two small improvements of rustc_expand

I found them while doing #96150

r? ``@petrochenkov``
2022-05-14 13:42:53 +09:00
Yuki Okushi
c031413f28
Rollup merge of #96986 - kdashg:save-an-enum-vars, r=oli-obk
[save-analysis] Reference the variant not enum at struct-literal cons…

…truction.

Closes #96985
2022-05-14 13:42:50 +09:00
Eric Holk
6665a4328b Fix nit 2022-05-13 19:32:53 -07:00
Eric Holk
5c98737715 Drop tracking: handle invalid assignments better
Previously this test case was crashing with an index out of bounds error
deep in the call to `needs_drop`. We avoid this by detecting clearly
invalid assignees in the `mutate` callback and ignoring these.
2022-05-13 16:25:22 -07:00
Jack Huey
0247faed29 Add bound_impl_trait_ref 2022-05-13 18:27:40 -04:00
Jack Huey
6c05e8d009 Add bound_fn_sig 2022-05-13 18:27:40 -04:00
Jack Huey
c92248ab9f Add bound_type_of 2022-05-13 18:27:18 -04:00
Vadim Petrochenkov
9ba5281c76 resolve: Move collection of all macro_rules in the crate to rustdoc 2022-05-13 21:43:36 +03:00
Mateusz Mikuła
60361f2ca3 Add LLVM based mingw-w64 targets 2022-05-13 20:14:15 +02:00
carbotaniuman
bd5fce65c6 Rustc changes for permissive provenance 2022-05-13 12:30:25 -05:00
Miguel Guarniz
f1c256d168 remove redundant branch
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13 11:46:06 -04:00
Miguel Guarniz
17e86d9ff9 remove unnecessary methods from HirIdValidator
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13 11:46:06 -04:00
Miguel Guarniz
433a5f1144 avoid converting to DefId from LocalDefId when using query
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13 11:46:06 -04:00
Miguel Guarniz
91223acde3 use for_each_module instead of iterating over Item's
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13 11:46:06 -04:00
Miguel Guarniz
df119428a2 change for_each_module's parameter to FnMut
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13 11:46:06 -04:00
Miguel Guarniz
cad1fd2f16 update rustdoc code to use new method name
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13 11:46:06 -04:00
Miguel Guarniz
2e98879403 change back to using tcx.hir() visit-item method
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13 11:46:06 -04:00
Miguel Guarniz
f975d05116 rename visit item-like methods
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13 11:46:06 -04:00
Miguel Guarniz
7e44078e9a update comments about visitor strategy
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13 11:46:06 -04:00
Miguel Guarniz
93616dd539 remove ItemLikeVisitor and DeepVisitor
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13 11:46:06 -04:00
Miguel Guarniz
0b7dd95475 remove HirVisitor
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13 11:46:06 -04:00
Miguel Guarniz
885b90bb34 remove DebuggerVisualizerCollector
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13 11:46:06 -04:00
Miguel Guarniz
cdba1dcef6 add module_items
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13 11:46:06 -04:00
Miguel Guarniz
e166409f0d remove Visitor impl for PrivateItemsInPublicInterfacesChecker
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13 11:46:06 -04:00
Miguel Guarniz
e8ef5bf464 remove TraitVisitor
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13 11:46:06 -04:00
Miguel Guarniz
eea16de9f7 replace hir().def_kind for def_kind query in rustc_passes
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13 11:46:05 -04:00
Miguel Guarniz
90685c6333 check def_kind before fetching item
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13 11:46:05 -04:00
Miguel Guarniz
0a029e2ed0 remove CollectPrivateImplItemsVisitor
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13 11:46:05 -04:00
Miguel Guarniz
45c37da0f7 remove LayoutTest
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13 11:46:05 -04:00
Miguel Guarniz
0ef16feb72 remove OuterVisitor
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13 11:46:05 -04:00
Miguel Guarniz
b1f0209cd1 optimize find_item to fetch Item only when needed
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13 11:46:05 -04:00
Miguel Guarniz
fb73ae2c8a remove ItemLikeVisitor impl for EntryContext
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13 11:46:05 -04:00
Miguel Guarniz
dab0e75911 remove DiagnosticItemCollector
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13 11:46:05 -04:00
Miguel Guarniz
52f833a254 remove LifeSeeder
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13 11:46:05 -04:00
Miguel Guarniz
00260347e3 replace usage of visit_item_likes_in_modules with hir_module_items query
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13 11:46:05 -04:00
Miguel Guarniz
bd2b210c59 Remove CheckConstTraitVisitor
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13 11:46:05 -04:00
Matthias Krüger
384caefbb6
Rollup merge of #96982 - klensy:no-expect, r=Dylan-DPC
fix clippy expect_fun_call
2022-05-13 16:03:24 +02:00
bors
a7d6408b05 Auto merge of #96899 - oli-obk:closure_wf_check_bounds, r=nikomatsakis
Check that closures satisfy their where bounds

fixes https://github.com/rust-lang/rust/issues/53092
fixes https://github.com/rust-lang/rust/issues/90409

based on https://github.com/rust-lang/rust/pull/96736
2022-05-13 11:18:01 +00:00
Oli Scherer
7a4ac84a90 For non-defining opaque type usage errors, don't try to also prove all trait bounds 2022-05-13 10:09:11 +00:00
Oli Scherer
253408b409 Check that closures satisfy their where bounds 2022-05-13 10:09:11 +00:00
Oli Scherer
59bbbe78e2 Avoid invoking the full eq infrastructure when all we want is to check a discriminant 2022-05-13 09:31:46 +00:00
bors
1c80ac003b Auto merge of #96930 - ayrtonm:mips32-tmp-file, r=petrochenkov
Fix e_flags for 32-bit MIPS targets in generated object file

In #95604 the compiler started generating a temporary symbols.o which is added to the linker invocation. This object file has an `e_flags` which is invalid for 32-bit MIPS targets. Even though symbols.o doesn't contain code, linking these targets with [lld fails](https://github.com/llvm/llvm-project/blob/main/lld/ELF/Arch/MipsArchTree.cpp#L76-L79) with
```
rust-lld: error: foo-cgu.0.rcgu.o: ABI 'o32' is incompatible with target ABI 'n64'
```
because it omits the ABI bits (`EF_MIPS_ABI_O32`) so lld assumes it's using the N64 ABI. This breaks linking on nightly for the out-of-tree [mipsel-sony-psx target](https://github.com/ayrtonm/psx-sdk-rs/issues/9), the builtin mipsel-sony-psp target (cc `@overdrivenpotato)` and probably any other 32-bit MIPS target using lld.

This PR sets the ABI in `e_flags` to O32 since that's the only ABI for 32-bit MIPS that LLVM supports. It also sets other `e_flags` bits based on the target to avoid similar issues with the object file arch and PIC. I had to bump the object crate version since some of these constants were [added recently](https://github.com/gimli-rs/object/pull/433). I'm not sure if this PR needs a test, but I can confirm that it fixes the linking issue on both targets I mentioned.
2022-05-13 08:48:31 +00:00
est31
e6ccf9b5d8 Use pluralize in one instance 2022-05-13 08:48:35 +02:00
est31
cc3c5d2700 Improve name and documentation of generic_extension
This function doesn't *create* a (rules based) macro, it *expands* it.
Thus, the documentation was wrong.
2022-05-13 08:42:39 +02:00
bors
97d48bec2d Auto merge of #96965 - oli-obk:flaky_inliner_ice, r=cjgillot
Gracefully handle normalization failures in the prospective inliner cycle detector

Preliminary work for adding the regression test in #96950 to our test suite (it was flaky on glacier).

If this PR solves the flakiness on glacier, we can then merge #96950
2022-05-13 06:20:56 +00:00
Camille GILLOT
29f3b3fe49 Do not cache item_attrs. 2022-05-13 08:06:48 +02:00
Camille GILLOT
9900ea352b Cache more queries on disk. 2022-05-13 08:06:48 +02:00
Matthias Krüger
f2100daf32
Rollup merge of #96989 - cjgillot:defpath-use, r=davidtwco
Be more precise than DefPathData::Misc.

This variant was used for two unrelated things. Let's make this cleaner.
2022-05-13 05:33:13 +02:00
Kelsey Gilbert
5fde765df0 [save-analysis] Reference the variant not enum at struct-literal construction.
Closes #96985
2022-05-12 16:34:02 -07:00
Camille GILLOT
ecbda428ec Correct comment. 2022-05-12 20:16:11 +02:00
Camille GILLOT
dde7bff574 Replace DefPathData::Misc by two appropriately-named variants. 2022-05-12 20:12:35 +02:00
klensy
7f318256c9 fix clippy expect_fun_call 2022-05-12 19:26:52 +03:00
bors
c6499fd998 Auto merge of #96974 - matthiaskrgr:rollup-jd4otnc, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #95896 (Note the contacts for the nvptx64 target(s))
 - #96860 (openbsd: convert futex timeout managment to Timespec usage)
 - #96939 (Fix settings page CSS)
 - #96941 (update graphviz links)
 - #96968 (Add tests for #96806)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-05-12 15:07:35 +00:00
Matthias Krüger
47e4c9efdc
Rollup merge of #96941 - nannany:master, r=lcnr,JohnTitor
update graphviz links

Update graphviz links.
2022-05-12 16:41:05 +02:00
bors
481db40311 Auto merge of #95562 - lcnr:attr-no-encode, r=davidtwco
don't encode only locally used attrs

Part of https://github.com/rust-lang/compiler-team/issues/505.

We now filter builtin attributes before encoding them in the crate metadata in case they should only be used in the local crate. To prevent accidental misuse `get_attrs` now requires the caller to state which attribute they are interested in. For places where that isn't trivially possible, I've added a method `fn get_attrs_unchecked` which I intend to remove in a followup PR.

After this pull request landed, we can then slowly move all attributes to only be used in the local crate while being certain that we don't accidentally try to access them from extern crates.

cc https://github.com/rust-lang/rust/pull/94963#issuecomment-1082924289
2022-05-12 12:48:30 +00:00
Oli Scherer
72f144de24 Give the inliner some hints 2022-05-12 11:29:01 +00:00
bors
18bd2dd5cd Auto merge of #96853 - davidtwco:diagnostic-translation-unit-and-more-porting, r=oli-obk
diagnostics: port more diagnostics to derive + support for `()` fields

- Extend diagnostic derive so that spanless subdiagnostics (e.g. some uses of `help`/`note`) can be applied via attributes to fields of type `()` (currently spanless subdiagnostics are applied via attributes on the diagnostic struct itself). A consequence of this is that `Option<()>` fields can be used to represent optional spanless subdiagnostics, which are sometimes useful (e.g. for a `help` that should only show on nightly builds).
- Simplify the "explicit generic args with impl trait" diagnostic struct (from #96760) using support for `Option<()>` spanless subdiagnostics.
- Change `DiagnosticBuilder::set_arg`, used to provide context for Fluent messages, so that it takes anything that implements `IntoDiagnosticArg`, rather than `DiagnosticArgValue` - this improves the ergonomics of manual implementations of `SessionDiagnostic` which are translatable.
- Port "the type parameter `T` must be explicitly specified", "manual implementations of `X` are experimental", "could not resolve substs on overridden impl" diagnostics to diagnostic structs.
- When testing macros from `rustc_macros` in `ui-fulldeps` tests, sometimes paths from the compiler source tree can be shown in error messages - these need to be normalized in `compiletest`.

r? `@oli-obk`
cc `@pvdrz`
2022-05-12 10:22:07 +00:00
Oli Scherer
e02129fec0 Use IndexSet for deterministic order 2022-05-12 10:03:41 +00:00
minami.yoshihiko
2c604f63fc update graphviz links
add subdomain
2022-05-12 18:31:42 +09:00
Oli Scherer
af0a464311 Gracefully handle normalization failures in the prospective inliner cycle detector 2022-05-12 08:22:36 +00:00
bors
4f8e2e3ad9 Auto merge of #96940 - TaKO8Ki:stop-suggesting-wrong-fully-qualified-path, r=estebank
Stop suggesting non-existing fully qualified paths

This patch fixes a part of #96295.

r? `@estebank`
2022-05-12 07:44:31 +00:00
David Wood
47582471c6 typeck: port "no resolve overridden impl substs"
Port "could not resolve substs on overridden impl" diagnostic to use the
diagnostic derive.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-05-12 07:21:51 +01:00
David Wood
664733efd5 typeck: port "manual implementations"
Port the "manual implementations of `X` are experimental" diagnostic to
use the diagnostic derive.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-05-12 07:21:51 +01:00
David Wood
78cc331bd7 typeck: port "missing type params"
Port the "the type parameter `T` must be explicitly specified"
diagnostic to using a diagnostic struct.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-05-12 07:21:51 +01:00
David Wood
de3e8ca2f3 errors: set_arg takes IntoDiagnosticArg
Manual implementors of translatable diagnostics will need to call
`set_arg`, not just the derive, so make this function a bit more
ergonomic by taking `IntoDiagnosticArg` rather than
`DiagnosticArgValue`.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-05-12 07:21:51 +01:00
David Wood
5685abc96b typeck: simplify error type using () field
Using new support for spanless subdiagnostics from `()` fields in the
diagnostic derive, simplify the "explicit generic args with impl trait"
diagnostic's struct.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-05-12 07:21:51 +01:00
David Wood
7b7061dd89 macros: spanless subdiagnostics from () fields
Type attributes could previously be used to support spanless
subdiagnostics but these couldn't easily be made optional in the same
way that spanned subdiagnostics could by using a field attribute on a
field with an `Option<Span>` type. Spanless subdiagnostics can now be
specified on fields with `()` type or `Option<()>` type.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-05-12 07:21:51 +01:00
bors
3a08bd7873 Auto merge of #96889 - Aaron1011:place-ref-remove, r=compiler-errors
Remove `PartialOrd`/`Ord` impl for `PlaceRef`

This is a new attempt at #93315. It removes one usage
of the `Ord` impl for `DefId`, which should make it easier
to eventually remove that impl.
2022-05-12 05:03:48 +00:00
bors
1d2ea98cff Auto merge of #95837 - scottmcm:ptr-offset-from-unsigned, r=oli-obk
Add `sub_ptr` on pointers (the `usize` version of `offset_from`)

We have `add`/`sub` which are the `usize` versions of `offset`, this adds the `usize` equivalent of `offset_from`.  Like how `.add(d)` replaced a whole bunch of `.offset(d as isize)`, you can see from the changes here that it's fairly common that code actually knows the order between the pointers and *wants* a `usize`, not an `isize`.

As a bonus, this can do `sub nuw`+`udiv exact`, rather than `sub`+`sdiv exact`, which can be optimized slightly better because it doesn't have to worry about negatives.  That's why the slice iterators weren't using `offset_from`, though I haven't updated that code in this PR because slices are so perf-critical that I'll do it as its own change.

This is an intrinsic, like `offset_from`, so that it can eventually be allowed in CTFE.  It also allows checking the extra safety condition -- see the test confirming that CTFE catches it if you pass the pointers in the wrong order.
2022-05-12 02:49:00 +00:00
Scott McMurray
003b954a43 Apply CR suggestions; add real tracking issue 2022-05-11 17:16:25 -07:00
Scott McMurray
4bb15b3797 Add a debug check for ordering, and check for isize overflow in CTFE 2022-05-11 17:16:25 -07:00
Scott McMurray
e76b3f3b5b Rename unsigned_offset_from to sub_ptr 2022-05-11 17:16:25 -07:00
Scott McMurray
89a18cb600 Add unsigned_offset_from on pointers
Like we have `add`/`sub` which are the `usize` version of `offset`, this adds the `usize` equivalent of `offset_from`.  Like how `.add(d)` replaced a whole bunch of `.offset(d as isize)`, you can see from the changes here that it's fairly common that code actually knows the order between the pointers and *wants* a `usize`, not an `isize`.

As a bonus, this can do `sub nuw`+`udiv exact`, rather than `sub`+`sdiv exact`, which can be optimized slightly better because it doesn't have to worry about negatives.  That's why the slice iterators weren't using `offset_from`, though I haven't updated that code in this PR because slices are so perf-critical that I'll do it as its own change.

This is an intrinsic, like `offset_from`, so that it can eventually be allowed in CTFE.  It also allows checking the extra safety condition -- see the test confirming that CTFE catches it if you pass the pointers in the wrong order.
2022-05-11 17:16:25 -07:00
bors
0cd939e36c Auto merge of #96150 - est31:unused_macro_rules, r=petrochenkov
Implement a lint to warn about unused macro rules

This implements a new lint to warn about unused macro rules (arms/matchers), similar to the `unused_macros` lint added by #41907 that warns about entire macros.

```rust
macro_rules! unused_empty {
    (hello) => { println!("Hello, world!") };
    () => { println!("empty") }; //~ ERROR: 1st rule of macro `unused_empty` is never used
}

fn main() {
    unused_empty!(hello);
}
```

Builds upon #96149 and #96156.

Fixes #73576
2022-05-12 00:08:08 +00:00
Gary Guo
c586bc3d76 Prevent unwinding when -C panic=abort is used regardless declared ABI 2022-05-12 00:03:48 +01:00
bors
cb9cb4d4e1 Auto merge of #96806 - cjgillot:codegen-fulfill-nice, r=oli-obk
Gracefully fail to resolve associated items instead of `delay_span_bug`.

`codegen_fulfill_obligation` is used during instance resolution for trait items.

In case of insufficient normalization issues during MIR inlining, it caused ICEs.
It's better to gracefully refuse to resolve the associated item, and let the caller decide what to do with this.

Split from https://github.com/rust-lang/rust/pull/91743
Closes #69121
Closes #73021
Closes #88599
Closes #93008
Closes #93248
Closes #94680
Closes #96170
r? `@oli-obk`
2022-05-11 21:39:02 +00:00
Aaron Hill
6b747aa397
Remove PartialOrd/Ord impl for PlaceRef
This is a new attempt at #93315. It removes one usage
of the `Ord` impl for `DefId`, which should make it easier
to eventually remove that impl.
2022-05-11 16:22:23 -04:00
bors
6dd68402c5 Auto merge of #96220 - RalfJung:scalar-no-padding, r=oli-obk
tighten sanity checks around Scalar and ScalarPair

While investigating https://github.com/rust-lang/rust/issues/96185 I noticed codegen has tighter sanity checks here than Miri does, so I added some more assertions. Strangely, some of them fail, so I also needed to add a HACK... that is probably worth looking into.

This does not fix that issue, but it changes the ICE messages, making it quite clear that we have a scalar whose size is not the same as that of the surrounding layout.

r? `@oli-obk`
2022-05-11 18:34:14 +00:00
bors
08b4f1be33 Auto merge of #96942 - Dylan-DPC:rollup-p8bcly2, r=Dylan-DPC
Rollup of 4 pull requests

Successful merges:

 - #91518 (Add readable rustdoc display for RISC-V target)
 - #95281 (Fix inaccurate function name in `rustc_const_eval` docs)
 - #96898 (logging: add env var to control verbose scope entry/exit logging)
 - #96936 (⬆️ rust-analyzer)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-05-11 13:47:38 +00:00
Dylan DPC
afb9171b64
Rollup merge of #96898 - RalfJung:interpret-pop-debug, r=oli-obk
logging: add env var to control verbose scope entry/exit logging

~~This got removed in https://github.com/rust-lang/rust/pull/75143, and I find this makes long traces a lot harder to read, so I propose we add this back.~~

Example trace:
```
│ │ ├─0ms  INFO rustc_const_eval::interpret::step return
│ │ ├─0ms  INFO rustc_const_eval::interpret::eval_context popping stack frame (returning from function)
│ │┌┘rustc_const_eval::interpret::eval_context::frame std::ptr::mut_ptr::<impl *mut u8>::guaranteed_eq
│ ├┘rustc_const_eval::interpret::eval_context::frame std::ptr::mut_ptr::<impl *mut u8>::is_null
│ ├─1ms  INFO rustc_const_eval::interpret::step // executing bb2
│ ├─1ms  INFO rustc_const_eval::interpret::step StorageDead(_4)
│ ├─1ms  INFO rustc_const_eval::interpret::step StorageDead(_2)
│ ├─1ms  INFO rustc_const_eval::interpret::step return
│ ├─1ms  INFO rustc_const_eval::interpret::eval_context popping stack frame (returning from function)
│┌┘rustc_const_eval::interpret::eval_context::frame std::ptr::mut_ptr::<impl *mut u8>::is_null
├┘rustc_const_eval::interpret::eval_context::frame std::sys_common::thread_local_dtor::register_dtor_fallback::run_dtors
├─178ms  INFO rustc_const_eval::interpret::step // executing bb2
├─178ms  INFO rustc_const_eval::interpret::step StorageDead(_5)

```

r? `@oli-obk`
2022-05-11 13:49:29 +02:00
Dylan DPC
0c2cee2e9d
Rollup merge of #95281 - pierwill:fix-85513, r=Dylan-DPC
Fix inaccurate function name in `rustc_const_eval` docs

Looks to me like this fixes #85513. I had trouble making a intra-docs link to `eval_place_to_op` work, though...
2022-05-11 13:49:28 +02:00
Ralf Jung
14f6daf935 avoid computing Scalar size/align in debug builds 2022-05-11 13:32:19 +02:00
Takayuki Maeda
daeec7e22d stop suggesting non-existing fully qualified paths 2022-05-11 19:18:02 +09:00
Vadim Petrochenkov
f2b7fa4847 ast: Introduce some traits to get AST node properties generically
And use them to avoid constructing some artificial `Nonterminal` tokens during expansion
2022-05-11 12:43:27 +03:00
Ralf Jung
831bd96967 rustc_log: add env var to set verbose entry/exit behavior 2022-05-11 09:14:31 +02:00
bors
ee6eaabdd4 Auto merge of #96931 - JohnTitor:rollup-3um8o4j, r=JohnTitor
Rollup of 7 pull requests

Successful merges:

 - #96543 (Remove hacks in `make_token_stream`.)
 - #96887 (rustdoc: correct path to type alias methods)
 - #96896 (Add regression test for #68408)
 - #96900 (Fix js error)
 - #96903 (Use lifetimes on type-alias-impl-trait used in function signatures to infer output type lifetimes)
 - #96916 (simplify length count)
 - #96925 (Fix issue #95151)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-05-11 06:29:04 +00:00
Camille GILLOT
6cfe52c094 Gracefully fail to resolve associated items instead of delay_span_bug. 2022-05-11 08:28:02 +02:00
Yuki Okushi
304c116b40
Rollup merge of #96916 - matthiaskrgr:simpl_count, r=compiler-errors
simplify length count
2022-05-11 13:16:34 +09:00
Yuki Okushi
17a735b69a
Rollup merge of #96903 - oli-obk:opaque_type_lifetime_constraints, r=compiler-errors
Use lifetimes on type-alias-impl-trait used in function signatures to infer output type lifetimes

fixes https://github.com/rust-lang/rust/issues/96564

TLDR:

```rust
fn execute(ty: Ty<'_>) -> &str { todo!() }
```

(`Ty` being a type alias impl trait) used to produce the following error before this PR

```
error[E0581]: return type references an anonymous lifetime, which is not constrained by the fn input types
 --> src/lib.rs:4:27
  |
4 | fn execute(ty: Ty<'_>) -> &str { todo!() }
  |                           ^^^^
  |
  = note: lifetimes appearing in an associated type are not considered constrained
```
2022-05-11 13:16:34 +09:00
Yuki Okushi
81c0a2d96c
Rollup merge of #96543 - nnethercote:rm-make_token_stream-hacks, r=Aaron1011
Remove hacks in `make_token_stream`.

`make_tokenstream` has three commented hacks, and a comment at the top
referring to #67062. These hacks have no observable effect, at least as judged
by running the test suite. The hacks were added in #82608, with an explanation
[here](https://github.com/rust-lang/rust/pull/82608#issuecomment-812877329). It
appears that one of the following is true: (a) they never did anything useful,
(b) they do something useful but we have no test coverage for them, or (c)
something has changed in the meantime that means they are no longer necessary.

This commit removes the hacks and the comments, in the hope that (b) is not
true.

r? `@Aaron1011`
2022-05-11 13:16:30 +09:00
bors
b862b438db Auto merge of #96888 - Aaron1011:fake-borrow-no-sort, r=petrochenkov
Use `FxIndexSet` to avoid sorting fake borrows

This fixes #96449, but I haven't yet been able to
make the reproducer work using `#[cfg]` attributes,
so we can't use the 'revision' infra to write a test

The previous implementation relied on sorting by `PlaceRef`.
This requires sorting by a `DefId`, which uses untracked state
(see #93315)
2022-05-11 04:09:45 +00:00
Ayrton
3d5b1eeb75 Fix e_flags for 32-bit MIPS targets in generated object file
In #95604 the compiler started generating a temporary symbols.o which is added
to the linker invocation. This object file has an `e_flags` which may be invalid
for 32-bit MIPS targets. Even though symbols.o doesn't contain code, linking
    with [lld fails](https://github.com/llvm/llvm-project/blob/main/lld/ELF/Arch/MipsArchTree.cpp#L79) with
```
rust-lld: error: foo-cgu.0.rcgu.o: ABI 'o32' is incompatible with target ABI 'n64'
```
because it omits the ABI bits (EF_MIPS_ABI_O32) so lld assumes it's using the
N64 ABI. This breaks linking on nightly for the out-of-tree [psx
target](https://github.com/ayrtonm/psx-sdk-rs/issues/9), the builtin
mipsel-sony-psp target (cc @overdrivenpotato) and any other 32-bit MIPS
target using lld.

This PR sets the ABI in `e_flags` to O32 since that's the only ABI for 32-bit
MIPS that LLVM supports. It also sets other `e_flags` bits based on the target.
I had to bump the object crate version since some of these constants were [added
recently](https://github.com/gimli-rs/object/pull/433). I'm not sure if this
PR needs a test, but I can confirm that it fixes the linking issue on both
targets I mentioned.
2022-05-10 22:48:19 -04:00
Jack Huey
319575ae8c Introduce EarlyBinder 2022-05-10 22:47:18 -04:00
Nicholas Nethercote
3cd8e9866d Remove some unnecessary invisible delimiter checks.
These seem to have no useful effect... they don't seem useful from a
code inspection point of view, and they affect anything in the test
suite.
2022-05-11 10:14:49 +10:00
Eric Holk
5ba2e09bde Fix addassign-yield.rs by implementing fake_read 2022-05-10 13:43:51 -07:00
Matthias Krüger
e2dc3967fa simplify length count 2022-05-10 20:42:45 +02:00
bors
d4c364347c Auto merge of #96904 - JohnTitor:rollup-f1sz5x0, r=JohnTitor
Rollup of 6 pull requests

Successful merges:

 - #96717 (Handle mismatched generic param kinds in trait impls betterly)
 - #96725 (Expose process windows_process_extensions_main_thread_handle on Windows)
 - #96849 (Move some tests to more reasonable places)
 - #96861 (Use Rust 2021 prelude in std itself.)
 - #96879 (rustdoc: search result ranking fix)
 - #96882 (Don't subst an AdtDef with its own substs)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-05-10 15:58:17 +00:00
Yuki Okushi
c5f2c4476e
Rollup merge of #96882 - jackh726:no-subst, r=oli-obk
Don't subst an AdtDef with its own substs
2022-05-11 00:09:36 +09:00
Yuki Okushi
77030b7825
Rollup merge of #96717 - BoxyUwU:gats_const_param_types_mismatch_err, r=lcnr
Handle mismatched generic param kinds in trait impls betterly

- Check that generic params on a generic associated type are the same as in the trait definition
- Check that const generics are not used in place of type generics (and the other way round too)

r? `@lcnr`
2022-05-11 00:09:31 +09:00
Oli Scherer
d63f82e1ef Use lifetimes on type-alias-impl-trait used in function signatures to infer output type lifetimes 2022-05-10 14:50:31 +00:00
bors
eead58e75b Auto merge of #96736 - oli-obk:tait_missing_wf_check, r=davidtwco
Check hidden types for well formedness at the definition site instead of only at the opaque type itself

work towards #90409 . We'll need to look into closure and generator bodies of closures and generators nested inside the hidden type in order to fix that. In hindsight this PR is not necessary for that, but it may be a bit easier with it and we'll get better diagnostics from it on its own.
2022-05-10 13:39:43 +00:00
Ralf Jung
761077e19e fmt 2022-05-10 14:38:00 +02:00
Ralf Jung
aef8a9306d update/remove some old comments 2022-05-10 14:23:32 +02:00
Ralf Jung
600d960261 even tighter checks for layouts on immediate field projections 2022-05-10 14:23:32 +02:00
Ralf Jung
79c169d5cf disable one check for now until #96185 is fixed 2022-05-10 14:23:32 +02:00
Oli Scherer
824e9e47f7 Use InternedObligationCauseCode everywhere 2022-05-10 12:01:56 +00:00
Ralf Jung
719655658a tighten sanity checks around Scalar and ScalarPair 2022-05-10 13:32:20 +02:00
SparrowLii
eead168dd7 optimize insert_range method of IntervalSet 2022-05-10 19:27:40 +08:00
Oli Scherer
213c17486e Make FunctionArgumentObligation also use the "no allocation for misc" trick 2022-05-10 11:26:53 +00:00
Oli Scherer
1b51e1ad20 Don't allocate misc obligation parents of derived obligations 2022-05-10 11:14:07 +00:00
Oli Scherer
9ba6ddb929 Make the derived obligation cause parent private 2022-05-10 11:10:27 +00:00
Oli Scherer
5b5b549580 Add a helper function for a common piece of code 2022-05-10 11:03:52 +00:00
bors
c51871c469 Auto merge of #94799 - lcnr:list-ty-perf, r=petrochenkov
update `hash_stable` for `List<Ty<'tcx>>`

cc https://github.com/rust-lang/rust/pull/93505#issuecomment-1047538798

this is the hottest part changed since the pre-merge perf run
2022-05-10 10:53:47 +00:00
Oli Scherer
05a62c5527 Remove clone_code method 2022-05-10 10:42:29 +00:00
Oli Scherer
dc21fcb2fc Remove another use of clone_code 2022-05-10 10:32:35 +00:00
Oli Scherer
063795ce4a Remove another use of clone_code 2022-05-10 10:26:43 +00:00
lcnr
ebf95836e3 fix typo 2022-05-10 12:07:36 +02:00
lcnr
7cf9f1ab91 change some attrs to only_local 2022-05-10 12:07:36 +02:00
lcnr
5ee1b18a14 update clippy 2022-05-10 12:07:35 +02:00
lcnr
6c8265dc56 only_local: always check for misuse 2022-05-10 12:07:35 +02:00
Oli Scherer
704bbe5210 Move an extension trait method onto the type directly and reuse it 2022-05-10 09:26:09 +00:00
Oli Scherer
7e2e3d4ebe Don't lose an obligation cause 2022-05-10 08:50:32 +00:00
Oli Scherer
312d27d0a2 Remove some unnecessary clones 2022-05-10 08:43:39 +00:00
bors
d53f1e8fbf Auto merge of #96891 - Dylan-DPC:rollup-echa4wg, r=Dylan-DPC
Rollup of 5 pull requests

Successful merges:

 - #93661 (Add missing rustc arg docs)
 - #96674 (docs: add link explaining variance to NonNull docs)
 - #96812 (Do not lint on explicit outlives requirements from external macros.)
 - #96823 (Properly fix #96638)
 - #96872 (make sure ScalarPair enums have ScalarPair variants; add some layout sanity checks)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-05-10 08:12:50 +00:00
Oli Scherer
2ea2ced2be Simplify derived obligation peeling 2022-05-10 07:50:39 +00:00
Oli Scherer
f667e952f8 Check hidden types for well formedness at the definition site instead of only at the opaque type itself 2022-05-10 07:20:00 +00:00
lcnr
58781edc54 update coherence docs, fix opaque type + generator ice 2022-05-10 09:09:06 +02:00
Dylan DPC
ec53c379cc
Rollup merge of #96872 - RalfJung:layout-sanity, r=eddyb
make sure ScalarPair enums have ScalarPair variants; add some layout sanity checks

`@eddyb` suggested that it might be reasonable for `ScalarPair` enums to simply adjust the ABI of their variants accordingly, such that the layout invariant Miri expects actually holds. This PR implements that. I should note though that I don't know much about this layout computation code and what non-Miri consumers expect from it, so tread with caution!

I also added a function to sanity-check that computed layouts are internally consistent. This helped a lot in figuring out the final shape of this PR, though I am also not 100% sure that these sanity checks are the right ones.

Cc `@oli-obk`
Fixes https://github.com/rust-lang/rust/issues/96221
2022-05-10 08:24:05 +02:00
Dylan DPC
9a3f17b34d
Rollup merge of #96823 - jackh726:params-heuristics-fix, r=estebank
Properly fix #96638

Closes #96638

The main part of this change is `Error::Invalid` now returns both the input and arg indices. However, I realized the code here was kind of confusing and not internally consistent (and thus I was having trouble getting the right behavior). So I've also switched `input_indices` and `arg_indices` to more closely match some naming in `checks` (although I think a more thorough cleanup there could be beneficial). I've added comments, but essentially `input_indices` refers to *user provided* inputs and `arg_indices` refers to *expected* args.
2022-05-10 08:24:04 +02:00
Dylan DPC
7b32e9304b
Rollup merge of #96812 - cjgillot:no-lint-outllives-macro, r=petrochenkov
Do not lint on explicit outlives requirements from external macros.

The current implementation of the list rightfully skipped where predicates from external macros.
However, if the where predicate came from the current macro but the bounds were from an external macro, the lint still fired.

Closes https://github.com/rust-lang/rust/issues/96640
2022-05-10 08:24:03 +02:00
lcnr
fc128b6764 add check and don't encode #[inline] 2022-05-10 08:09:37 +02:00
lcnr
b618cdb224 fix comment 2022-05-10 08:09:37 +02:00
lcnr
74b6d296db don't encode only locally used attrs 2022-05-10 08:09:37 +02:00
bors
2226f19f70 Auto merge of #96808 - cjgillot:impossible-trait, r=compiler-errors
Detect trait fulfillment in `subst_and_check_impossible_predicates`

Split from https://github.com/rust-lang/rust/pull/91743
r? `@compiler-errors`
2022-05-10 05:27:54 +00:00
Aaron Hill
aa0cc9c1e2
Use FxIndexSet to avoid sorting fake borrows
This fixes #96449, but I haven't yet been able to
make the reproducer work using `#[cfg]` attributes,
so we can't use the 'revision' infra to write a test

The previous implementation relied on sorting by `PlaceRef`.
This requires sorting by a `DefId`, which uses untracked state
(see #93315)
2022-05-09 22:29:46 -04:00
bors
362010d6be Auto merge of #96715 - cjgillot:trait-alias-loop, r=compiler-errors
Fortify handing of where bounds on trait & trait alias definitions

Closes https://github.com/rust-lang/rust/issues/96664
Closes https://github.com/rust-lang/rust/issues/96665

Since https://github.com/rust-lang/rust/pull/93803, when listing all bounds and predicates we now need to account for the possible presence of predicates on any of the generic parameters.  Both bugs were hidden by the special handling of bounds at  the generic parameter declaration position.

Trait alias expansion used to confuse predicates on `Self` and where predicates.
Exiting too late when listing all the bounds caused a cycle error.
2022-05-10 00:40:57 +00:00
bors
cb390735b0 Auto merge of #96838 - tmiasko:lazy-switch-sources, r=oli-obk
Optimize switch sources representation and usage

* Avoid constructing switch sources unless necessary - switch sources are used by backward analysis with a custom switch int edge effects, but are otherwise unnecessarily computed.
* Use sparse representation of switch sources to avoid quadratic space overhead.
2022-05-09 22:15:30 +00:00
Jack Huey
cb1c0c6516 Don't subst an adt def 2022-05-09 16:07:10 -04:00
bors
88860d5474 Auto merge of #96473 - lcnr:querify-codegen-fn-attrs, r=cjgillot
store `codegen_fn_attrs` in crate metadata

extracted from #95562 because the change isn't trivial.
2022-05-09 19:52:59 +00:00
Ralf Jung
02eca34534 also sanity-check Abi::Vector, and slight refactoring 2022-05-09 21:40:33 +02:00
Jack Huey
1d68e6d674 Properly fix issue 96638 2022-05-09 13:53:16 -04:00
Camille GILLOT
e947fad68c Point to the empty trait alias. 2022-05-09 19:03:37 +02:00
Matthias Krüger
0e00ed5f48
Rollup merge of #96854 - jackh726:subst-cleanup, r=compiler-errors
Some subst cleanup

Two separate things here. Both changes are useful for some refactoring I'm doing to add an "EarlyBinder" newtype. (Part of chalkification).

1) Remove `subst_spanned` and just use `subst`. It wasn't used much anyways. In practice, I think we can probably get most of the info just from the actual error message. If not, outputting logs should do the trick. (The specific line probably wouldn't help much anyways).

2) Call `.subst()` before `replace_bound_vars_with_fresh_vars` and `erase_late_bound_regions` in three places that do the opposite. I think there might have been some time in the past that the order here matter for something, but this shouldn't be the case anymore. Conceptually, it makes more sense to the of the *early bound* vars on `fn`s as "outside" the late bound vars.
2022-05-09 18:45:39 +02:00
Matthias Krüger
84a8f8dedf
Rollup merge of #96844 - Badel2:actually-fix-96583, r=compiler-errors
Actually fix ICE from #96583

PR #96746 fixed a very similar bug, so the same logic is used in a different place.

I originally concluded that the two issues (#96583 and #96738) were identical by comparing the backtrace, but I didn't look close enough.
2022-05-09 18:45:38 +02:00
Matthias Krüger
6c8001b85c
Rollup merge of #96008 - fmease:warn-on-useless-doc-hidden-on-assoc-impl-items, r=lcnr
Warn on unused `#[doc(hidden)]` attributes on trait impl items

[Zulip conversation](https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/.E2.9C.94.20Validy.20checks.20for.20.60.23.5Bdoc.28hidden.29.5D.60).

Whether an associated item in a trait impl is shown or hidden in the documentation entirely depends on the corresponding item in the trait declaration. Rustdoc completely ignores `#[doc(hidden)]` attributes on impl items. No error or warning is emitted:

```rust
pub trait Tr { fn f(); }
pub struct Ty;
impl Tr for Ty { #[doc(hidden)] fn f() {} }
//               ^^^^^^^^^^^^^^ ignored by rustdoc and currently
//                              no error or warning issued
```

This may lead users to the wrong belief that the attribute has an effect. In fact, several such cases are found in the standard library (I've removed all of them in this PR).
There does not seem to exist any incentive to allow this in the future either: Impl'ing a trait for a type means the type *fully* conforms to its API. Users can add `#[doc(hidden)]` to the whole impl if they want to hide the implementation or add the attribute to the corresponding associated item in the trait declaration to hide the specific item. Hiding an implementation of an associated item does not make much sense: The associated item can still be found on the trait page.

This PR emits the warn-by-default lint `unused_attribute` for this case with a future-incompat warning.

`@rustbot` label T-compiler T-rustdoc A-lint
2022-05-09 18:45:36 +02:00
lcnr
32b13ac928 review 2022-05-09 18:40:18 +02:00
lcnr
d371ebe117 only compute codegen_fn_attrs where needed 2022-05-09 18:40:18 +02:00
Ralf Jung
2c11c3d86c make sure ScalarPair enums have ScalarPair variants; add some layout sanity checks 2022-05-09 17:46:35 +02:00
lcnr
66ff6c32e5 only cache codegen_fn_attrs on disk if its local 2022-05-09 16:48:30 +02:00
lcnr
501067cb05 move panic-in-drop=abort check for drop_in_place
Whether `drop_in_place` can abort does depend on the
`panic-in-drop` option while compiling the current crate,
not `core`
2022-05-09 16:48:30 +02:00
lcnr
bd1d18660b store codegen_fn_attrs in crate metadata 2022-05-09 16:48:30 +02:00
SparrowLii
5251a80c0a use hir::Let in hir::Guard 2022-05-09 20:35:58 +08:00
bors
e013f9e0ca Auto merge of #96815 - SparrowLii:promote_const, r=oli-obk
optimize `promote_consts` by caching the results of `validate_local`

From the FIXME in the impl of `promote_consts`. Early return the `validate_local` should save some compile time.

`qualif_local` is similar to this, but requires futher changing because there are different types of qualif checks. If this PR is effective, I will do it as well.
2022-05-09 11:49:09 +00:00
SparrowLii
b890037af3 use Result<(),()> instead of Validity enum 2022-05-09 17:13:30 +08:00
bors
8a2fe75d0e Auto merge of #95960 - jhpratt:remove-rustc_deprecated, r=compiler-errors
Remove `#[rustc_deprecated]`

This removes `#[rustc_deprecated]` and introduces diagnostics to help users to the right direction (that being `#[deprecated]`). All uses of `#[rustc_deprecated]` have been converted. CI is expected to fail initially; this requires #95958, which includes converting `stdarch`.

I plan on following up in a short while (maybe a bootstrap cycle?) removing the diagnostics, as they're only intended to be short-term.
2022-05-09 04:47:30 +00:00
Jack Huey
657499df64 Reorder erasing/replacing late bound vars and substs 2022-05-08 22:02:54 -04:00
Jack Huey
e14eae6226 Remove subst_spanned 2022-05-08 21:53:25 -04:00
bors
a57117982a Auto merge of #95542 - xFrednet:rfc-2383-expect-query, r=wesleywiser
Support tool lints with the `#[expect]` attribute (RFC 2383)

This PR fixes the ICE https://github.com/rust-lang/rust/issues/94953 by making the assert for converted expectation IDs conditional.

Additionally, it moves the lint expectation check into a separate query to support rustdoc and other tools. On the way, I've also added some tests to ensure that the attribute works for Clippy and rustdoc lints.

The number of changes comes from the long test file. This may look like a monster PR, this may smell like a monster PR and this may be a monster PR, but it's a harmless monster. 🦕

---

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

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

r? `@wesleywiser`

cc: `@rust-lang/rustdoc`
2022-05-09 00:02:55 +00:00
Tomasz Miąsko
2be012a0c6 Use sparse representation of switch sources
to avoid quadratic space overhead
2022-05-08 23:48:23 +02:00
Tomasz Miąsko
fbc3cc18be Avoid constructing switch sources unless necessary
Switch sources are used by backward analysis with a custom switch int
edge effects, but are otherwise unnecessarily computed.

Delay the computation until we know that switch sources are indeed
required and avoid the computation otherwise.
2022-05-08 23:14:56 +02:00
León Orell Valerian Liehr
9d157ada35 Warn on unused doc(hidden) on trait impl items 2022-05-08 22:53:14 +02:00
Matthias Krüger
cdaa5c03c9
Rollup merge of #96617 - ken-matsui:fix-incorrect-syntax-suggestion-with-pub-async-fn, r=cjgillot
Fix incorrect syntax suggestion with `pub async fn`

This PR closes: https://github.com/rust-lang/rust/issues/96555
2022-05-08 21:31:16 +02:00
Badel2
84adf0d8dd Actually fix ICE from #96583
PR #96746 fixed a very similar bug, so the same logic is used in a
different place.
2022-05-08 19:57:47 +02:00
Fridtjof Stoldt
9516a40f1e
Fixed typo in docs and correct doc links
Co-authored-by: Philipp Krones <hello@philkrones.com>
2022-05-08 17:24:15 +02:00
bors
ed3164baf0 Auto merge of #96770 - flip1995:fix-trait-type-in-bounds, r=cjgillot
Track if a where bound comes from a impl Trait desugar

With https://github.com/rust-lang/rust/pull/93803 `impl Trait` function arguments get desugared to hidden where bounds. However, Clippy needs to know if a bound was originally a `impl Trait` or an actual bound. This adds a field to the `WhereBoundPredicate` struct to keep track of this information during AST->HIR lowering.

r? `@cjgillot`

cc `@estebank` (as the reviewer of #93803)
2022-05-08 14:10:12 +00:00
xFrednet
2c5e85249f
Move lint expectation checking into a separate query (RFC 2383) 2022-05-08 14:37:14 +02:00
xFrednet
7f03681cd9
Only assert for unstable expectation ids after conversion (RFC 2383)
This ICE was reported by `@matthiaskrgr`. A big THANK YOU to him. See `rust#94953`
2022-05-08 14:37:14 +02:00
bors
030c886c29 Auto merge of #96155 - jackh726:param-heuristics-followup, r=estebank
Followups for method call error change

Each commit is self-contained. Fixes most of the followup reviews from that PR.

r? `@estebank`
2022-05-08 04:05:36 +00:00
Ken Matsui
8b89a1280c
Fix incorrect syntax suggestion with pub async fn 2022-05-08 09:34:02 +09:00
Matthias Krüger
c5d6f82cb7
Rollup merge of #96769 - Undin:remove-adx_target_feature-from-active, r=joshtriplett
Remove `adx_target_feature` feature from active features list

The feature was stabilized in https://github.com/rust-lang/rust/pull/93745
2022-05-07 22:44:42 +02:00
Camille GILLOT
69e5b2fde0 Do not report overflow error. 2022-05-07 18:18:03 +02:00
flip1995
dd1ff405e3
Track if a where bound comes from a impl Trait desugar
With #93803 `impl Trait` function arguments get desugared to hidden
where bounds. However, Clippy needs to know if a bound was originally a
impl Trait or an actual bound. This adds a field to the
`WhereBoundPredicate` struct to keep track of this information during
HIR lowering.
2022-05-07 17:10:30 +02:00
Guillaume Gomez
27a2bae89c
Rollup merge of #96788 - JakobDegen:checked-binop, r=oli-obk
Improve validator around field projections and checked bin ops

The two commits are unrelated. In both cases, these rules were already documented in MIR docs.
2022-05-07 15:23:47 +02:00
Guillaume Gomez
a644197391
Rollup merge of #96760 - davidtwco:diagnostic-translation-vec, r=oli-obk
diagnostics: port more diagnostics to derive + add support for `Vec` fields

- Port "unconstrained opaque type" diagnostic to using the derive.
- Allow `Vec` fields in diagnostic derive - enables support for diagnostics that have multiple primary spans, or have subdiagnostics repeated at multiple locations. `Vec<..>` fields in the diagnostic derive become loops in the generated code.
- Add `create_{err,warning}` - there wasn't a way to create a diagnostic from a struct and not emit it straight away.
- Port "explicit generic args w/ impl trait" diagnostic to using the derive.

r? `````@oli-obk`````
cc `````@pvdrz`````
2022-05-07 15:23:46 +02:00
Guillaume Gomez
c29f8575ac
Rollup merge of #96581 - RalfJung:debug-size-align, r=oli-obk
make Size and Align debug-printing a bit more compact

In particular in `{:#?}`-mode, these take up a lot of space, so I think this is the better alternative (even though it is a bit longer in `{:?}` mode, I think it is still more readable).

We could make it even smaller by deviating further from what the actual code looks like, e.g. via something like `Size(4 bytes)`. Not sure what people would think about that?

Cc `````@oli-obk`````
2022-05-07 15:23:44 +02:00
SparrowLii
cb7f116c04 optimize promote_consts by cache the validate check 2022-05-07 21:02:25 +08:00
Camille GILLOT
96321ed756 Do not lint on explicit outlives requirements from external macros. 2022-05-07 12:41:15 +02:00
Camille GILLOT
6b348257a1 Cleanup opaque type storage after checking impossible predicates. 2022-05-07 10:25:57 +02:00