Commit Graph

12777 Commits

Author SHA1 Message Date
Guillaume Gomez
223f107b48
Rollup merge of #96415 - ehuss:git-io, r=bjorn3
Remove references to git.io

The git.io service is shutting down soon (see https://github.blog/changelog/2022-04-25-git-io-deprecation/). This removes the references of those short links with the actual destination.
2022-04-26 13:22:31 +02:00
Guillaume Gomez
f908391136
Rollup merge of #96400 - JakobDegen:shallow-init-docs, r=Dylan-DPC
Correct documentation for `Rvalue::ShallowInitBox`

As a part of the big MIR docs PR, I had added a comment indicating that `Rvalue::ShallowInitBox` is disallowed after drop elaboration, but this is not true (no idea why I thought it was). Codegen has support for it, and trying to enforce this rule in the validator causes compiling core to ICE on the very first `box` statement.

That being said, this `Rvalue` probably *should* be banned after drop elaboration - it doesn't seem like it's still useful for much. However, I do not have time right now to actually go investigate how difficult a change that is to make, so in the meantime fixing the docs to reflect the current situation seems like the right step.

r? rust-lang/mir-opt
2022-04-26 13:22:30 +02:00
Guillaume Gomez
a818173e63
Rollup merge of #96386 - SparrowLii:des_field, r=jackh726
simplify `describe_field` func in borrowck's diagnostics part

This PR simplify the `describe_field` func in borrowck's diagnostics part, besides fix the FIXME in it.
2022-04-26 13:22:29 +02:00
Guillaume Gomez
bb6265a739
Rollup merge of #96372 - compiler-errors:field-method-suggest, r=oli-obk
Suggest calling method on nested field when struct is missing method

Similar to the suggestion to change `x.field` to `x.nested.field`, implement a similar suggestion for when `x.method()` should be replaced with `x.nested.method()`.
2022-04-26 13:22:29 +02:00
Guillaume Gomez
fe49981ea0
Rollup merge of #94703 - kjetilkjeka:nvptx-kernel-args-abi2, r=nagisa
Fix codegen bug in "ptx-kernel" abi related to arg passing

I found a codegen bug in the nvptx abi related to that args are passed as ptrs ([see comment](https://github.com/rust-lang/rust/issues/38788#issuecomment-1048999928)), this is not as specified in the [ptx-interoperability doc](https://docs.nvidia.com/cuda/ptx-writers-guide-to-interoperability/) or how C/C++ does it. It will also almost always fail in practice since device/host uses different memory spaces for most hardware.

This PR fixes the bug and add tests for passing structs to ptx kernels.

I observed that all nvptx assembly tests had been marked as [ignore a long time ago](https://github.com/rust-lang/rust/pull/59752#issuecomment-501713428). I'm not sure if the new one should be marked as ignore, it passed on my computer but it might fail if ptx-linker is missing on the server? I guess this is outside scope for this PR and should be looked at in a different issue/PR.

I only fixed the nvptx64-nvidia-cuda target and not the potential code paths for the non-existing 32bit target. Even though 32bit nvptx is not a supported target there are still some code under the hood supporting codegen for 32 bit ptx. I was advised to create an MCP to find out if this code should be removed or updated.

Perhaps ``@RDambrosio016`` would have interest in taking a quick look at this.
2022-04-26 13:22:27 +02:00
bors
d6a57d3730 Auto merge of #94034 - willcrichton:fix-trait-suggestion-for-binops, r=estebank
Fix incorrect suggestion for trait bounds involving binary operators

This PR fixes #93927, #92347, #93744 by replacing the bespoke trait-suggestion logic in `op.rs` with a more common code path.

The downside is that this fix causes some suggestions to not include an `Output=` type, reducing their usefulness.

Note that this causes one case in the `missing-bounds.rs` test to fail rustfix. So I would need to move that code into a separate non-fix test if this PR is otherwise acceptable.
2022-04-26 07:29:15 +00:00
Will Crichton
dc41dbaf8e Update unop path, fix tests 2022-04-25 19:14:09 -07:00
bors
9ea4d4127f Auto merge of #96414 - Dylan-DPC:rollup-t4ofhoa, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #90312 (Fix some confusing wording and improve slice-search-related docs)
 - #96149 (Remove unused macro rules)
 - #96279 (rustdoc: Remove .woff font files)
 - #96355 (Better handle too many `#` recovery in raw str)
 - #96379 (delay bug when adjusting `NeverToAny` twice during diagnostic code)
 - #96384 (do not consider two extern types to be similar)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-04-26 01:52:46 +00:00
Will Crichton
4d0fe27896 Replace suggest_constraining_param with suggest_restricting_param_bound
to fix incorrect suggestion for trait bounds involving binary operators.
Fixes #93927, #92347, #93744.
2022-04-25 18:12:15 -07:00
Eric Huss
159b95d5bb Remove references to git.io 2022-04-25 17:05:58 -07:00
Dylan DPC
f0b2dccc21
Rollup merge of #96384 - lcnr:extern-types-similar, r=compiler-errors
do not consider two extern types to be similar
2022-04-26 01:21:24 +02:00
Dylan DPC
8038a9ece3
Rollup merge of #96379 - PrestonFrom:issue_96335, r=compiler-errors
delay bug when adjusting `NeverToAny` twice during diagnostic code

Addresses Issue 96335 (https://github.com/rust-lang/rust/issues/96335) by using `delay_span_bug` instead of an assert and returning an error type from `check_expr_meets_expectation_or_error`.

Fixes #96335
2022-04-26 01:21:23 +02:00
Dylan DPC
77031f3d99
Rollup merge of #96355 - estebank:issue-95030, r=compiler-errors
Better handle too many `#` recovery in raw str

Point at all the unnecessary trailing `#`.
Better handle interaction with outer attributes when `;` is missing.

Fix #95030.
2022-04-26 01:21:22 +02:00
Dylan DPC
93db30aa7f
Rollup merge of #96149 - est31:remove_unused_macro_matchers, r=petrochenkov
Remove unused macro rules

Removes rules of internal macros that weren't triggered.
2022-04-26 01:21:20 +02:00
bors
ec8619dca2 Auto merge of #96294 - Emilgardis:def_id-in-unsafetyviolationdetails, r=oli-obk
Display function path in unsafety violations - E0133

adds `DefId` to `UnsafetyViolationDetails`

this enables consumers to access the function definition that was reported to be unsafe and also changes the output for some E0133 diagnostics
2022-04-25 23:03:50 +00:00
bors
055bf4ccd5 Auto merge of #96116 - ouz-a:mir-opt, r=oli-obk
Make derefer work everwhere

Follow up work on previous PR's #95649 and #95857.

r? rust-lang/mir-opt

_Co-Authored-By: `@oli-obk_`
2022-04-25 19:34:52 +00:00
Jakob Degen
941e19468a Correct documentation for ShallowInitBox 2022-04-25 14:24:14 -04:00
bors
18b53cefdf Auto merge of #95604 - nbdd0121:used2, r=petrochenkov
Generate synthetic object file to ensure all exported and used symbols participate in the linking

Fix #50007 and #47384

This is the synthetic object file approach that I described in https://github.com/rust-lang/rust/pull/95363#issuecomment-1079932354, allowing all exported and used symbols to be linked while still allowing them to be GCed.

Related #93791, #95363

r? `@petrochenkov`
cc `@carbotaniuman`
2022-04-25 16:14:54 +00:00
Gary Guo
6f9b2b3247 Stop exporting rust_eh_personality and friends from cdylib 2022-04-25 14:06:30 +01:00
bors
7417110cef Auto merge of #96246 - SparrowLii:bound_contxet, r=compiler-errors
Add `BoundKind` in `visit_param_bounds` to check questions in bounds

From the FIXME in the impl of `AstValidator`. Better bound checks by adding `BoundCtxt` type parameter to `visit_param_bound`

cc `@ecstatic-morse`
2022-04-25 10:46:58 +00:00
SparrowLii
74853eedfe simplify describe_field func in borrowck's diagnostics part 2022-04-25 16:09:36 +08:00
lcnr
5594db0975 do not consider two extern types to be similar 2022-04-25 08:51:26 +02:00
Preston From
5165295452 Delay bug when adjusting NeverToAny twice during diagnostic 2022-04-24 23:52:55 -06:00
Michael Goulet
dff7f25981 suggestion if struct field has method 2022-04-24 16:47:19 -07:00
Matthias Krüger
433f1f425e
Rollup merge of #96215 - nikic:legacy-pm-removal, r=nagisa
Drop support for legacy PM with LLVM 15

LLVM 15 already removes some of the legacy PM APIs we're using. This patch forces use of NewPM with LLVM 15 (with `-Z new-llvm-pass-manager=no` throwing a warning) and stubs out various FFI methods with a report_fatal_error on LLVM 15.

For LLVMPassManagerBuilderPopulateLTOPassManager() I went with adding our own wrapper, as the alternative would be to muck about with weak symbols, which seems to be non-trivial as far as cross-platform support is concerned (std has `weak!` for this purpose, but only as an internal utility.)

Fixes #96072.
Fixes #96362.
2022-04-25 00:11:02 +02:00
Matthias Krüger
ddbeda1302
Rollup merge of #96090 - JakobDegen:mir-tests, r=nagisa
Implement MIR opt unit tests

This implements rust-lang/compiler-team#502 .

There's not much to say here, this implementation does everything as proposed. I also added the flag to a bunch of existing tests (mostly those to which I could add it without causing huge diffs due to changes in line numbers). Summarizing the changes to test outputs:
 - Every time an `MirPatch` is created, it adds a cleanup block to the body if it did not exist already. If this block is unused (as is usually the case), it usually gets removed soon after by some pass calling `SimplifyCFG` for unrelated reasons (in many cases this cycle happens quite a few times for a single body). We now run `SimplifyCFG` less often, so those blocks end up in some of our outputs. I looked at changing `MirPatch` to not do this, but that seemed too complicated for this PR. I may still do that in a follow-up.
 - The `InstCombine` test had set `-C opt-level=0` in its flags and so there were no storage markers. I don't really see a good motivation for doing this, so bringing it back in line with what everything else does seems correct.
 - One of the `EarlyOtherwiseBranch` tests had `UnreachableProp` running on it. Preventing that kind of thing is the goal of this feature, so this seems fine.

For the remaining tests for which this feature might be useful, we can gradually migrate them as opportunities present themselves.

In terms of documentation, I plan on submitting a PR to the rustc dev guide in the near future documenting this and other recent changes to MIR. If there's any other places to update, do let me know

r? `@nagisa`
2022-04-25 00:10:59 +02:00
Michael Goulet
319fbe371d Fix suggestion for _ on return type for fn in impl for Trait 2022-04-24 14:50:48 -07:00
Michael Goulet
42dbbabcb0 Suggest replacing _ in type signature of impl for Trait 2022-04-24 14:49:29 -07:00
Gary Guo
1af3e0a65e Ensure #[used] symbols are preserved in LTO 2022-04-24 22:32:05 +01:00
Emil Gardström
2e47271cb8
only show a simple description in E0133 span label 2022-04-24 18:33:07 +02:00
Emil Gardström
8b8f6653cf
add DefId to unsafety violations and display function path in E0133
this enables consumers to access the function definition that was reported to be unsafe
2022-04-24 18:33:06 +02:00
Matthias Krüger
aef9eb50cd
Rollup merge of #96352 - marmeladema:fix-nll-lifetime-bound-suggestions, r=jackh726
Improve span for `consider adding an explicit lifetime bound` suggestions under NLL

Because NLL borrowck is run after typeck, `in_progress_typeck_results` was always `None` which was preventing the retrieval of the span to which the suggestion is suppose to add the lifetime bound.
We now manually pass the `LocalDefId` owner to `construct_generic_bound_failure` so that under NLL, we give the owner id of the current body.

This helps with #96332
2022-04-24 18:00:27 +02:00
bors
d8e59edbfa Auto merge of #96359 - SparrowLii:drop_kind, r=oli-obk
make `classify_drop_access_kind` iterate

This PR:
1. fixes the FIXME of `classify_drop_access_kind` func in the borrowck part. The process of obtaining `StorageDeadOrDrop` has been changed from recursive to iterative.
2. gets `place_ty` in each iteration, avoid repeatedly getting the `ty` of the same place (O(n^2) => O(n))
2022-04-24 12:58:16 +00:00
Gary Guo
9ebeb284b5 Fix MSVC hang issue 2022-04-24 13:13:41 +01:00
SparrowLii
a34e1b58cb make classify_drop_access_kind iterate 2022-04-24 17:27:05 +08:00
marmeladema
53120b59ae Recover missing suggestion part under NLL 2022-04-24 09:36:23 +02:00
marmeladema
7b0db3e7c8 Improve span for consider adding an explicit lifetime bound suggestions under NLL
Because NLL borrowck is run after typeck, `in_progress_typeck_results`
was always `None` which was preventing the retrieval of the span to which
the suggestion is suppose to add the lifetime bound.

We now manually pass the `LocalDefId` owner to `construct_generic_bound_failure`
so that under NLL, we give the owner id of the current body.
2022-04-24 09:34:50 +02:00
Jeremy Fitzhardinge
9102edf208 Add support for nounused --extern flag
This adds `nounused` to the set of extern flags:
`--extern nounused:core=/path/to/core/libcore.rlib`.

The effect of this flag is to suppress `unused-crate-dependencies`
warnings relating to the crate.
2022-04-23 23:31:54 -07:00
Esteban Küber
3587406967 Better handle too many # recovery in raw str
Point at all the unnecessary trailing `#`.
Better handle interaction with outer attributes when `;` is missing.

Fix #95030.
2022-04-23 19:51:11 -07:00
bors
b21759f550 Auto merge of #96281 - SparrowLii:const_prop, r=wesleywiser
Optimize `const_prop` mir-opt by accessing `local_decls` through `ecx`

From the FIXME in the impl of `ConstPropagator`. Accessing `local_decls` and `scource_scopes` from `ecx` can reduce `clone` calls and save compile time.
Besides, according to #96213 , the FIXME about writing `layouts` to `ecx` in advance can also be removed.
2022-04-24 01:09:11 +00:00
bors
143eaa8d44 Auto merge of #93970 - cjgillot:novis, r=petrochenkov
Remove visibility information from HIR

The resolver exports all the necessary visibility information through the `tcx.visibility` query.
This PR stops having a dedicated visibility field in HIR, in order to use this query.
We keep a `vis_span` field for diagnostic purposes.
2022-04-23 22:25:51 +00:00
Camille GILLOT
c3276c6691 Hash visibilities in crate_hash. 2022-04-23 23:03:18 +02:00
Camille GILLOT
9861bc8d52 Compute has_pub_restricted in the resolver. 2022-04-23 23:03:18 +02:00
Camille GILLOT
423a712a16 Fix lints. 2022-04-23 23:01:19 +02:00
bors
de1026a67b Auto merge of #96326 - JakobDegen:relax-operand, r=oli-obk
Relax restrictions for copy operands

This was [discussed on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Removing.20requirement.20that.20.60Copy.60.20operands.20have.20.60Copy.60.20types/near/279102313). Details about motivation and such can be found there

r? `@oli-obk`
2022-04-23 19:32:05 +00:00
bors
c212fc4aa7 Auto merge of #96323 - bjorn3:sync_cg_clif-2022-04-22, r=bjorn3
Sync rustc_codegen_cranelift

Mostly fixing bugs this time, but also a Cranelift update.

r? `@ghost`

`@rustbot` label +A-codegen +A-cranelift +T-compiler
2022-04-23 10:37:35 +00:00
Camille GILLOT
4bbe078d92 Drop vis in Item. 2022-04-23 09:59:24 +02:00
Camille GILLOT
a6e3124d2c Drop vis in ImplItem. 2022-04-23 09:57:00 +02:00
Camille GILLOT
2827007d32 Drop vis from ForeignItem. 2022-04-23 09:56:37 +02:00
Camille GILLOT
a62680d108 Drop vis in FieldDef. 2022-04-23 09:56:15 +02:00