Commit Graph

13124 Commits

Author SHA1 Message Date
bors
343889b723 Auto merge of #96683 - nnethercote:speed-up-Token-ident-lifetime, r=petrochenkov
Speed up `Token::{ident,lifetime}`

Some speed and cleanliness improvements.

r? `@petrochenkov`
2022-05-04 15:24:02 +00:00
bors
364bf39e31 Auto merge of #94775 - oli-obk:operand_order, r=davidtwco
Fix constants not getting dropped if part of a diverging expression

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

cc `@RalfJung`
2022-05-04 12:54:02 +00:00
Josh Triplett
0fc5c524f5 Stabilize bool::then_some 2022-05-04 13:22:08 +02:00
Oli Scherer
db02e61038 Generate an intermediate temporary for Drop constants.
To limit the fallout from this, don't do this for the last (or only) operand in an rvalue.
2022-05-04 09:09:52 +00:00
Yuki Okushi
731ad8a3c1
Rollup merge of #96684 - tmiasko:mir-downcast, r=petrochenkov
Update `ProjectionElem::Downcast` documentation

`ProjectionElem:::Downcast` is used when downcasting to a variant of
an enum or a generator, regardless of the number of variants.
2022-05-04 17:13:15 +09:00
Yuki Okushi
d0a7a4c6e6
Rollup merge of #96679 - ricked-twice:issue-96223-fix, r=jackh726
Quick fix for #96223.

This PR is a quick fix regarding #96223.

As mentioned in the issue, others modification could be added to not elide types with bound vars from suggestions.

Special thanks to ``@jackh726`` for mentoring and ``@Manishearth`` for minimal test case.

r? ``@jackh726``
2022-05-04 17:13:14 +09:00
Jack Huey
8e31cdefc4 Revert #92191 Prefer projection candidates instead of param_env candidates for Sized predicates 2022-05-04 01:55:23 -04:00
bors
9add63257b Auto merge of #96353 - estebank:issue-95413, r=compiler-errors
When suggesting to import an item, also suggest changing the path if appropriate

When we don't find an item we search all of them for an appropriate
import and suggest `use`ing it. This is sometimes done for expressions
that have paths with more than one segment. We now also suggest changing
that path to work with the `use`.

Fix #95413
2022-05-04 01:58:23 +00:00
Nicholas Nethercote
5022d764cf Show invisible delimeters (within comments) when pretty printing. 2022-05-04 10:06:06 +10:00
bors
1b2e0b60cc Auto merge of #95380 - compiler-errors:unit-destructure-assign, r=nikomatsakis
Fix unit struct/enum variant in destructuring assignment

See https://github.com/rust-lang/rfcs/blob/master/text/2909-destructuring-assignment.md#guide-level-explanation, "including **unit** and tuple structs"

Fixes #94319
2022-05-03 22:29:58 +00:00
Tomasz Miąsko
a63d414031 Update ProjectionElem::Downcast documentation
`ProjectionElem:::Downcast` is used when downcasting to a variant of
an enum or a generator, regardless of the number of variants.
2022-05-03 22:29:51 +02:00
ricked-twice
574bee35fb
Taking review hints into account. 2022-05-03 22:23:30 +02:00
Nicholas Nethercote
1d2e172935 Remove unnecessary NtIdent in Token::is_whole_expr.
The comment on this function explains that it's a specialized version of
`maybe_whole_expr`. But `maybe_whole_expr` doesn't do anything with
`NtIdent`, so `is_whole_expr` also doesn't need to.
2022-05-04 06:15:36 +10:00
Nicholas Nethercote
bbef9756ea Fix spelling of an identifier. 2022-05-04 06:15:36 +10:00
Nicholas Nethercote
637a93cb5d Speed up Token::{ident,lifetime}.
They're hot enough that the repeated matching done by `uninterpolate`
has a measurable effect.
2022-05-04 06:15:29 +10:00
bors
e1b71feb59 Auto merge of #96558 - bjorn3:librarify_parse_format, r=davidtwco
Make rustc_parse_format compile on stable

This allows it to be used by lightweight formatting systems and may allow it to be used by rust-analyzer.
2022-05-03 20:03:54 +00:00
ricked-twice
bfcd191905
Quick fix for #96223. 2022-05-03 21:16:03 +02:00
ridwanabdillahi
175a4eab84 Add support for a new attribute #[debugger_visualizer] to support embedding debugger visualizers into a generated PDB.
Cleanup `DebuggerVisualizerFile` type and other minor cleanup of queries.

Merge the queries for debugger visualizers into a single query.

Revert move of `resolve_path` to `rustc_builtin_macros`. Update dependencies in Cargo.toml for `rustc_passes`.

Respond to PR comments. Load visualizer files into opaque bytes `Vec<u8>`. Debugger visualizers for dynamically linked crates should not be embedded in the current crate.

Update the unstable book with the new feature. Add the tracking issue for the debugger_visualizer feature.

Respond to PR comments and minor cleanups.
2022-05-03 10:53:54 -07:00
Gary Guo
6baaa527ce Allow inline consts to reference generic params 2022-05-03 15:22:03 +01:00
Oli Scherer
efc6a6f1bd Report that opaque types are not allowed in impls even in the presence of other errors 2022-05-03 13:53:53 +00:00
Gary Guo
bf4d7fa43f Hide InlineConst's generic arg during print
The generic arg is for type inference only and shouldn't be exposed
to users.
2022-05-03 14:37:16 +01:00
bors
e1df625306 Auto merge of #96601 - tmiasko:ssa-rpo, r=davidtwco
Use reverse postorder in `non_ssa_locals`

The reverse postorder, unlike preorder, is now cached inside the MIR
body. Code generation uses reverse postorder anyway, so it might be
a small perf improvement to use it here as well.
2022-05-03 12:16:00 +00:00
bjorn3
d33140d2dc Make rustc_parse_format compile on stable
This allows it to be used by lightweight formatting systems and may
allow it to be used by rust-analyzer.
2022-05-03 11:26:58 +02:00
Yuki Okushi
279d80127a
Rollup merge of #96646 - estebank:issue-96638, r=jackh726
Mitigate impact of subtle invalid call suggestion logic

There's some subtle interaction between inferred expressions being
passed as an argument to fn calls with fewer than expected arguments. To
avoid the ICE, I'm changing indexing operations with `.get(idx)`, but
the underlying logic still needs to be audited as it was written with
the assumption that `final_arg_types` and `provided_args` have the right
length.

Address #96638.
2022-05-03 14:59:03 +09:00
Yuki Okushi
1e6b880b84
Rollup merge of #96641 - oli-obk:bool_args, r=wesleywiser
Use a yes/no enum instead of a bool.

The bool's meaning wasn't obvious to me at some call sites.
2022-05-03 14:59:01 +09:00
Yuki Okushi
0340703b78
Rollup merge of #96629 - ken-matsui:fix-invalid-keyword-order-for-function-declarations, r=davidtwco
Fix invalid keyword order for function declarations

Closes: https://github.com/rust-lang/rust/issues/94879
2022-05-03 14:59:01 +09:00
Yuki Okushi
61c687a0db
Rollup merge of #96599 - tmiasko:discriminant-docs, r=estebank
Update `RValue::Discriminant` documentation

`RValue::Discriminant` returns zero for types without discriminant.
This guarantee is already documented for `discriminant_value`
intrinsics which is implemented in terms of `RValue::Discriminant`.
2022-05-03 14:58:59 +09:00
Yuki Okushi
a58703677b
Rollup merge of #96589 - Badel2:source-callsite, r=michaelwoerister
Use source callsite in check_argument_types suggestion

This makes the "remove extra arguement" suggestion valid when the function argument is a macro.

Additionally, this may fix #96225, but the only way I can reproduce that issue is using the playground, so we will need to wait until after this is merged to ensure it's fixed.
2022-05-03 14:58:58 +09:00
Yuki Okushi
329a73dbd6
Rollup merge of #96587 - bjorn3:refactor_backend_write, r=michaelwoerister
Refactor the WriteBackendMethods and ExtraBackendMethods traits

The new interface is slightly less confusing and is easier to implement for non-LLVM backends.
2022-05-03 14:58:57 +09:00
Tomasz Miąsko
e62663492b Collect function instance used in global_asm! sym operand
The constants used in SymFn operands have FnDef type,
so the type of the constant identifies the function.
2022-05-03 07:12:43 +02:00
Esteban Kuber
4934a9e643 Tweak wording 2022-05-03 02:07:47 +00:00
Esteban Küber
57967269e9 When suggesting to import an item, also suggest changing the path if appropriate
When we don't find an item we search all of them for an appropriate
import and suggest `use`ing it. This is sometimes done for expressions
that have paths with more than one segment. We now also suggest changing
that path to work with the `use`.

Fix #95413
2022-05-03 02:00:38 +00:00
bors
c110cfa161 Auto merge of #96580 - CAD97:E0705-no-ignore, r=michaelwoerister
Remove `ignore` from E0705 test

Spotted this, and I think this can be made to test now.
2022-05-03 00:45:18 +00:00
Elliot Roberts
7907385999 fix most compiler/ doctests 2022-05-02 17:40:30 -07:00
Esteban Kuber
7790b6e1c0 Mitigate impact of subtle invalid call suggestion logic
There's some subtle interaction between inferred expressions being
passed as an argument to fn calls with fewer than expected arguments. To
avoid the ICE, I'm changing indexing operations with `.get(idx)`, but
the underlying logic still needs to be audited as it was written with
the assumption that `final_arg_types` and `provided_args` have the right
length.

Address 96638.
2022-05-02 19:24:56 +00:00
bors
bed05e996e Auto merge of #96578 - tmiasko:chunked-bit-set-fmt, r=nnethercote
Fix -Zdump-mir-dataflow by implementing DebugWithContext for ChunkedBitSet

`DebugWithContext` is used to format changes to dataflow state along with MIR
in graphviz dot files. In the case of `ChunkedBitSet` it was left unimplemented,
so attempts to use `-Zdump-mir-dataflow -Zdump-mir=all` resulted in an ICE:

> thread 'rustc' panicked at 'not implemented: implement when/if needed',

Provide the missing implementation.

r? `@nnethercote`
2022-05-02 18:57:32 +00:00
bors
24c8985043 Auto merge of #96436 - petrochenkov:nowhole2, r=wesleywiser
linker: Stop using whole-archive on dependencies of dylibs

https://github.com/rust-lang/rust/pull/95604 implemented a better and more fine-grained way of keeping exported symbols alive.

Addresses the second question from https://github.com/rust-lang/rust/pull/93901#issuecomment-1041325522.
r? `@wesleywiser`
2022-05-02 16:28:47 +00:00
Oli Scherer
0349f8bd79 Use a yes/no enum instead of a bool.
The bool's meaning wasn't obvious to me at some call sites.
2022-05-02 15:39:13 +00:00
bors
879fb42596 Auto merge of #96431 - petrochenkov:parent, r=cjgillot
rustc: Panic by default in `DefIdTree::parent`

Only crate root def-ids don't have a parent, and in majority of cases the argument of `DefIdTree::parent` cannot be a crate root.
So we now panic by default in `parent` and introduce a new non-panicing function `opt_parent` for cases where the argument can be a crate root.

Same applies to `local_parent`/`opt_local_parent`.
2022-05-02 14:03:20 +00:00
Ken Matsui
6c7f4dee8f
Fix invalid keyword order for function declarations 2022-05-02 18:14:43 +09:00
Vadim Petrochenkov
5b5964f569 rustc: Panic by default in DefIdTree::parent
Only crate root def-ids don't have a parent, and in majority of cases the argument of `DefIdTree::parent` cannot be a crate root.
So we now panic by default in `parent` and introduce a new non-panicing function `opt_parent` for cases where the argument can be a crate root.

Same applies to `local_parent`/`opt_local_parent`.
2022-05-02 01:56:50 +03:00
bors
4dd8b420c0 Auto merge of #96521 - petrochenkov:docrules, r=notriddle,GuillaumeGomez
rustdoc: Resolve doc links referring to `macro_rules` items

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

UPD: the fallback to considering *all* `macro_rules` in the crate for unresolved names is not removed in this PR, it will be removed separately and will be run through crater.
2022-05-01 20:28:10 +00:00
bors
a933de8398 Auto merge of #96582 - petrochenkov:finalize, r=cjgillot
resolve: Cleanup path resolution finalization

Some cleanup after https://github.com/rust-lang/rust/pull/95255 and https://github.com/rust-lang/rust/pull/95405.
r? `@cjgillot`
2022-05-01 18:05:57 +00:00
bors
6eda7642bd Auto merge of #96549 - ouz-a:mir-opt, r=oli-obk
Move Derefer before Retag

_Follow up work to #96116 #95857 #95649_

This moves `Derefer` before `Retag` and creates a new `LocalInfo` called `Temp` to avoid retagging created temp values.

Zulip discussion [link](https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/deref.20as.20first.20and.20only.20projection)

r? `@oli-obk`
2022-05-01 15:25:16 +00:00
Vadim Petrochenkov
7841247ca9 resolve: Rename unusable_binding to ignore_binding 2022-05-01 18:02:37 +03:00
Vadim Petrochenkov
f0e0434feb resolve: Merge last_import_segment into Finalize 2022-05-01 18:02:35 +03:00
Vadim Petrochenkov
ffedcec4e8 resolve: Pass full Finalize in nearly all cases 2022-05-01 18:02:01 +03:00
Vadim Petrochenkov
900607f49a resolve: Turn enum Finalize into an optional struct 2022-05-01 17:42:22 +03:00
bors
508e0584e3 Auto merge of #96376 - scottmcm:do-yeet, r=oli-obk
Add `do yeet` expressions to allow experimentation in nightly

Two main goals for this:
- Ensure that trait restructuring in https://github.com/rust-lang/rust/issues/84277#issuecomment-1066120333 doesn't accidentally close us off from the possibility of doing this in future, as sketched in https://rust-lang.github.io/rfcs/3058-try-trait-v2.html#possibilities-for-yeet
- Experiment with the *existence* of syntax for this, to be able to weight the syntax-vs-library tradeoffs better than we can right now.  Notably the syntax (with `do`) and name in this PR are not intended as candidates for stabilization, but they make a good v0 PR for adding this with minimal impact to compiler maintenance or priming one possible name choice over another.

r? `@oli-obk`
The lang `second` for doing this: https://github.com/rust-lang/lang-team/issues/160#issuecomment-1107896716

Tracking issues
- Lang, https://github.com/rust-lang/rust/issues/96373
- Libs-api, https://github.com/rust-lang/rust/issues/96374
2022-05-01 13:10:21 +00:00
Tomasz Miąsko
fa41852c7a Use reverse postorder in non_ssa_locals
The reverse postorder, unlike preorder, is now cached inside the MIR
body. Code generation uses reverse postorder anyway, so it might be
a small perf improvement to use it here as well.
2022-05-01 14:58:29 +02:00
ouz-a
d9ddb6446d re-name stuff 2022-05-01 15:38:22 +03:00
bors
637b3f6807 Auto merge of #96576 - oli-obk:post_monomorphization_error_backtrace, r=lqd
Also report the call site of PME errors locally.

Note this does not produce a full stack all the way to the first call that specifies all monomorphic parameters, it's just shallowly mentioning the last call site.

previous work: https://github.com/rust-lang/rust/pull/85633
tracking issue: https://github.com/rust-lang/rust/issues/85155

r? `@lqd`

I figured we could get some improvement for traces in local crates without going into the backtrace hell you landed in last time
2022-05-01 10:29:39 +00:00
Tomasz Miąsko
b37fb23d9f Update RValue::Discriminant documentation
`RValue::Discriminant` returns zero for types without discriminant.
This guarantee is already documented for `discriminant_value`
intrinsics which is implemented in terms of `RValue::Discriminant`.
2022-05-01 11:49:46 +02:00
Scott McMurray
b317ec1697 Feature-gate do yeet inside cfgs too 2022-04-30 18:10:01 -07:00
Scott McMurray
e094ee5f10 Add do yeet expressions to allow experimentation in nightly
Using an obviously-placeholder syntax.  An RFC would still be needed before this could have any chance at stabilization, and it might be removed at any point.

But I'd really like to have it in nightly at least to ensure it works well with try_trait_v2, especially as we refactor the traits.
2022-04-30 17:40:27 -07:00
bors
2c858a7c3f Auto merge of #93815 - camsteffen:intravisit-docs, r=cjgillot
Update intravisit docs

Follow-up to #90986.

r? `@cjgillot`
2022-04-30 21:24:53 +00:00
Vadim Petrochenkov
8b21421873 rustdoc: Track macro_rules scopes during early doc link resolution
This way links referring to `macro_rules` items are resolved correctly
2022-05-01 00:02:15 +03:00
Badel2
685f66b6b1 Use source callsite in check_argument_types suggestion
This makes the "remove extra arguement" suggestion valid when the
function argument is a macro
2022-04-30 22:44:20 +02:00
Vadim Petrochenkov
044e45c595 rustdoc: Keep full ParentScope during early doc link resolution 2022-04-30 23:06:48 +03:00
bjorn3
78c65a52db Merge new_metadata into codegen_allocator 2022-04-30 21:20:08 +02:00
bjorn3
fab72301d9 Remove config parameter of optimize_fat and avoid interior mutability for module 2022-04-30 20:58:42 +02:00
bjorn3
ee94ff254a Let LtoModuleCodegen::optimize take self by value 2022-04-30 20:51:17 +02:00
bjorn3
336bb0afea Rename run_lto_pass_manager to optimize_fat and remove thin parameter 2022-04-30 20:50:17 +02:00
bors
7c4b476969 Auto merge of #96347 - estebank:issue-96292, r=compiler-errors
Erase type params when suggesting fully qualified path

When suggesting the use of a fully qualified path for a method call that
is ambiguous because it has multiple candidates, erase type params in
the resulting code, as they would result in an error when applied. We
replace them with `_` in the output to rely on inference. There might be
cases where this still produces slighlty incomplete suggestions, but it
otherwise produces many more errors in relatively common cases.

Fix #96292
2022-04-30 18:44:01 +00:00
Cameron Steffen
61ba32b768 Update intravisit docs 2022-04-30 12:27:27 -05:00
CAD97
09f758fe3b Remove ``` `ignore``` from E0705 test 2022-04-30 10:48:38 -05:00
Tomasz Miąsko
0e7d54c9e7 Fix -Zdump-mir-dataflow by implementing DebugWithContext for ChunkedBitSet 2022-04-30 16:40:54 +02:00
Tomasz Miąsko
cdfdb99c9e Add element iterator for ChunkedBitSet 2022-04-30 16:40:49 +02:00
Camille GILLOT
39c67b2133 Correct comment. 2022-04-30 13:55:17 +02:00
Camille GILLOT
74583852e8 Save colon span to suggest bounds. 2022-04-30 13:55:17 +02:00
Camille GILLOT
94449e6101 Store all generic bounds as where predicates. 2022-04-30 13:55:13 +02:00
Camille GILLOT
05b29f9a92 Inline WhereClause into Generics. 2022-04-30 13:51:49 +02:00
Camille GILLOT
71b4e2d852 Box HIR Generics and Impl. 2022-04-30 13:51:49 +02:00
Oli Scherer
91f422dfda Also report the call site of PME errors locally.
Note this does not produce a full stack all the way to the first call that specifies all monomorphic parameters, it's just shallowly mentioning the last call site.
2022-04-30 09:04:15 +00:00
bors
76d4862fdd Auto merge of #95776 - cjgillot:ast-lifetimes-static, r=petrochenkov
Enforce static lifetimes in consts during late resolution

This PR moves the handling of implicitly and explicitly static lifetimes in constants from HIR to the AST.
2022-04-30 07:52:18 +00:00
bors
9a98c63b30 Auto merge of #96500 - SparrowLii:rpo, r=tmiasko
Reduce duplication of RPO calculation of mir

Computing the RPO of mir is not a low-cost thing, but it is duplicate in many places. In particular the `iterate_to_fixpoint` method which is called multiple times when computing the data flow.
This PR reduces the number of times the RPO is recalculated as much as possible, which should save some compile time.
2022-04-30 05:06:47 +00:00
Esteban Kuber
bce5ab2c78 Use newtype enums instead of bool 2022-04-30 02:40:36 +00:00
Esteban Kuber
09f3ea1692 When encountering a binding that could be a const or unit variant, suggest the right path 2022-04-30 02:27:25 +00:00
Camille GILLOT
865d0fef2f Ban non-static lifetimes from AnonConst on AST.
The extra diagnostics come from the compiler no longer aborting before
typeck.
2022-04-30 00:28:42 +02:00
bors
05c07386b4 Auto merge of #96566 - Dylan-DPC:rollup-fo7rd98, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #96390 (Switch JS code to ES6 - part 2)
 - #96527 (RustWrapper: explicitly don't handle DXILPointerTyID)
 - #96536 (rustdoc: fix missing method list for primitive deref target)
 - #96559 (Use the correct lifetime binder for elided lifetimes in path.)
 - #96560 (Remove unnecessary environment variable in cf-protection documentation)
 - #96562 (Fix duplicate directory separator in --remap-path-prefix.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-04-29 22:27:10 +00:00
Dylan DPC
548fca6927
Rollup merge of #96562 - michaelwoerister:path-remapping-fixes, r=oli-obk
Fix duplicate directory separator in --remap-path-prefix.

The compiler will currently emit duplicate directory separators when `--remap-path-prefix` has an exact match of the working directory and it is invoked with a relative path to the main source file. For example

```bash
rustc src/main.rs -Cdebuginfo=2 --remap-path-prefix="$(pwd)=abc"
```

will produce the path `abc//src/main.rs` in debuginfo. This is because `some_path.join("")` will append a directory separator to `some_path` and then LLVM does not check if the working directory already ends a directory separator before concatenating it with the relative path.
2022-04-29 23:54:43 +02:00
Dylan DPC
2003d833a5
Rollup merge of #96559 - cjgillot:elided-path-fn, r=petrochenkov
Use the correct lifetime binder for elided lifetimes in path.

Fixes https://github.com/rust-lang/rust/issues/96540
2022-04-29 23:54:41 +02:00
Dylan DPC
041f3b64dd
Rollup merge of #96527 - durin42:llvm-15-werror-wswitch, r=nikic
RustWrapper: explicitly don't handle DXILPointerTyID

This new enum entry was introduced in https://reviews.llvm.org/D122268,
and if I'm reading correctly there's no case where we'd ever encounter
it in our uses of LLVM. To preserve the ability to compile this file
with -Werror -Wswitch we add an explicit case for this entry.

r? nikic
2022-04-29 23:54:38 +02:00
Camille GILLOT
6e349c7f07 Remove error variable. 2022-04-29 22:26:22 +02:00
bors
a707f40107 Auto merge of #95819 - oli-obk:mir_can't_hold_all_these_lifetimes, r=estebank
Enforce Copy bounds for repeat elements while considering lifetimes

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

this is a breaking change in order to fix a soundness bug.

Before this PR we only checked whether the repeat element type had an `impl Copy`, but not whether that impl also had the appropriate lifetimes. E.g. if the impl was for `YourType<'static>` and not a general `'a`, then copying any type other than a `'static` one should have been rejected, but wasn't.

r? `@lcnr`
2022-04-29 20:00:47 +00:00
SparrowLii
7149bbcdc5 Eliminate duplication of RPO calculation for mir
add `postorder_cache` to mir Body

add `ReversePostorderCache` struct

correct struct name and comments
2022-04-30 03:42:57 +08:00
Michael Woerister
3614bd3c45 Fix duplicate directory separator in --remap-path-prefix. 2022-04-29 21:09:12 +02:00
Oli Scherer
67ce547f47 Refactor and document the repeat length check 2022-04-29 18:56:57 +00:00
Oli Scherer
be54947315 Extract copy bound check into a function 2022-04-29 18:49:02 +00:00
bors
1c8966e5e9 Auto merge of #96474 - SparrowLii:langcall, r=lcnr
Eliminate duplication code of building panic langcall during codegen

From the FIXME in the `codegen_panic_intrinsic` func.
2022-04-29 17:20:00 +00:00
Camille GILLOT
f66de50f8a Use the correct lifetime binder for elided lifetimes in path. 2022-04-29 18:51:21 +02:00
ouz-a
4d4b0f140f remove and bless 2022-04-29 18:29:38 +03:00
bors
683c582c1e Auto merge of #96468 - davidtwco:diagnostic-translation-subdiagnostic, r=oli-obk
macros: subdiagnostic derive

Add a new macro, `#[derive(SessionSubdiagnostic)]`, which can be applied to structs that represent subdiagnostics, such as labels, notes, helps or suggestions.

`#[derive(SessionSubdiagnostic)]` can be used with the existing `#[derive(SessionDiagnostic)]`. All diagnostics implemented using either derive are translatable, and this new derive should make it easier to port existing diagnostics to using these derives.

For example, consider the following subdiagnostic types...

```rust
#[derive(SessionSubdiagnostic)]
pub enum ExpectedIdentifierLabel<'tcx> {
    #[label(slug = "parser-expected-identifier")]
    WithoutFound {
        #[primary_span]
        span: Span,
    }
    #[label(slug = "parser-expected-identifier-found")]
    WithFound {
        #[primary_span]
        span: Span,
        found: String,
    }
}

#[derive(SessionSubdiagnostic)]
#[suggestion_verbose(slug = "parser-raw-identifier")]
pub struct RawIdentifierSuggestion<'tcx> {
    #[primary_span]
    span: Span,
    #[applicability]
    applicability: Applicability,
    ident: Ident,
}
```

...and the corresponding Fluent messages:

```fluent
parser-expected-identifier = expected identifier

parser-expected-identifier-found = expected identifier, found {$found}

parser-raw-identifier = escape `{$ident}` to use it as an identifier
```

These can be emitted using the new `subdiagnostic` function on `Diagnostic`...

```rust
diag.subdiagnostic(ExpectedIdentifierLabel::WithoutFound { span });
diag.subdiagnostic(RawIdentifierSuggestion { span, applicability, ident });
```

...or as part of a larger `#[derive(SessionDiagnostic)]`:

```rust
#[derive(SessionDiagnostic)]
#[error(slug = "parser-expected-identifier")]
pub struct ExpectedIdentifier {
    #[primary_span]
    span: Span,
    token_descr: String,
    #[subdiagnostic]
    label: ExpectedIdentifierLabel,
    #[subdiagnostic]
    raw_identifier_suggestion: Option<RawIdentifierSuggestion>,
}
```

```rust
sess.emit_err(ExpectedIdentifier { ... });
```

r? `@oli-obk`
cc `@pvdrz`
2022-04-29 11:58:24 +00:00
ouz-a
f1c5f34f76 exp-stuff-dirty 2022-04-29 14:42:24 +03:00
Dylan DPC
48199e0e3f
Rollup merge of #96523 - nbdd0121:windows, r=petrochenkov
Add `@feat.00` symbol to symbols.o for COFF

Fix #96498

This is based on top of #96444.

r? ``@petrochenkov``
2022-04-29 11:23:16 +02:00
Dylan DPC
109008a1c1
Rollup merge of #96516 - oli-obk:impl_trait_inference_accidental_permitted, r=jackh726
Revert diagnostic duplication and accidental stabilization

fixes #96460

this is an accidental stabilization that we should put into the beta. I believe it is low-risk, because it was literally what we had before #94081

The effect on tests is massive, but mostly deduplication of diagnostics and some minor span changes.
2022-04-29 11:23:15 +02:00
Dylan DPC
31693cbef7
Rollup merge of #96477 - alexcrichton:update-wasm64-data-layout, r=wesleywiser
Update data layout string for wasm64-unknown-unknown

Looks like this changed in a recent LLVM update but wasm64 isn't built
on CI so it wasn't caught until now.

Closes #96463
2022-04-29 11:23:12 +02:00
Nicholas Nethercote
ae5f67f9e8 Remove the T::VISIT_TOKENS test in visit_mac_args.
The two paths are equivalent -- they both end up calling `visit_expr()`.
I have kept the more restrictive path, the one that requires that
`token` be an expression nonterminal. (The next commit will simplify this
function further.)
2022-04-29 17:47:52 +10:00
bors
5560c51738 Auto merge of #96444 - nbdd0121:used2, r=petrochenkov
Use decorated names for linked_symbols on Windows

Fix #96423

r? `@petrochenkov`
2022-04-29 05:34:29 +00:00
Nicholas Nethercote
cde25f8dbe Simplify lower_mac_args.
The `token` is always an interpolated non-terminal expression, and
always a literal in valid code. This commit simplifies the processing
accordingly, by directly extracting and using the literal.
2022-04-29 15:14:31 +10:00
Nicholas Nethercote
481a4461ae Rename visit_interpolated as visit_nonterminal.
Because `Nonterminal` is the type it visits.
2022-04-29 15:00:32 +10:00
Nicholas Nethercote
5a05b614bf Tweak print_attr_item.
This commit rearranges the `match`. The new code avoids testing for
`MacArgs::Eq` twice, at the cost of repeating the `self.print_path()`
call. I think this is worthwhile because it puts the `match` in a more
standard and readable form.
2022-04-29 15:00:32 +10:00
David Wood
dca88612b9 macros: add interop between diagnostic derives
Add `#[subdiagnostic]` field attribute to the diagnostic derive which
is applied to fields that have types which use the subdiagnostic derive.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-29 02:12:10 +01:00
David Wood
e5d9371b30 macros: allow setting applicability in attribute
In the initial implementation of the `SessionSubdiagnostic`, the
`Applicability` of a suggestion can be set both as a field and as part
of the attribute, this commit adds the same support to the original
`SessionDiagnostic` derive.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-29 02:12:10 +01:00
David Wood
e8ee0d7a20 macros: add more documentation comments
Documentation comments are always good.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-29 02:12:10 +01:00
David Wood
2647a4812c macros: reuse SetOnce trait in diagnostic derive
`SetOnce` trait was introduced in the subdiagnostic derive to simplify
the code a little bit, re-use it in the diagnostic derive too.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-29 02:12:10 +01:00
David Wood
36a396ce51 macros: add helper functions for invalid attrs
Remove some duplicated code between both diagnostic derives by
introducing helper functions for reporting an error in case of a invalid
attribute.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-29 02:12:10 +01:00
David Wood
071f07274b macros: split diagnostic derives into modules
Split `SessionDiagnostic` and `SessionSubdiagnostic` derives and the
various helper functions into multiple modules.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-29 02:12:08 +01:00
David Wood
49ec909ca7 macros: subdiagnostic derive
Add a new derive, `#[derive(SessionSubdiagnostic)]`, which enables
deriving structs for labels, notes, helps and suggestions.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-29 02:05:20 +01:00
David Wood
73fa217bc1 errors: span_suggestion takes impl ToString
Change `span_suggestion` (and variants) to take `impl ToString` rather
than `String` for the suggested code, as this simplifies the
requirements on the diagnostic derive.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-29 02:05:20 +01:00
Camille GILLOT
a87ab48099 Ban non-static in const generics in AST. 2022-04-29 00:02:49 +02:00
Gary Guo
0fce0db96f Add @feat.00 symbol to symbols.o for COFF 2022-04-28 21:33:23 +01:00
Dylan DPC
0cbf3b2b30
Rollup merge of #96433 - petrochenkov:delim, r=nnethercote
rustc_ast: Harmonize delimiter naming with `proc_macro::Delimiter`

Compiler cannot reuse `proc_macro::Delimiter` directly due to extra impls, but can at least use the same naming.

After this PR the only difference between these two enums is that `proc_macro::Delimiter::None` is turned into `token::Delimiter::Invisible`.
It's my mistake that the invisible delimiter is called `None` on stable, during the stabilization I audited the naming and wrote the docs, but missed the fact that the `None` naming gives a wrong and confusing impression about what this thing is.

cc https://github.com/rust-lang/rust/pull/96421
r? ``@nnethercote``
2022-04-28 20:13:02 +02:00
Dylan DPC
cbfbc3be7d
Rollup merge of #96409 - marmeladema:fix-nll-introduce-named-lifetime-suggestion, r=jackh726
Recover suggestions to introduce named lifetime under NLL

Fixes #96157

r? ```@jackh726```

Built on top of #96385 so only the second commit is relevant
2022-04-28 20:13:01 +02:00
Dylan DPC
b3329f84f4
Rollup merge of #96405 - pvdrz:ambiguous-plus-diagnostic, r=davidtwco
Migrate ambiguous plus diagnostic to the new derive macro

r? ````@davidtwco```` ````@jyn514````
2022-04-28 20:12:59 +02:00
Augie Fackler
e8ae06a31b RustWrapper: explicitly don't handle DXILPointerTyID
This new enum entry was introduced in https://reviews.llvm.org/D122268,
and if I'm reading correctly there's no case where we'd ever encounter
it in our uses of LLVM. To preserve the ability to compile this file
with -Werror -Wswitch we add an explicit case for this entry.
2022-04-28 13:53:52 -04:00
Oli Scherer
d22c439989 Revert diagnostic duplication and accidental stabilization 2022-04-28 13:25:36 +00:00
bors
b2c2a32870 Auto merge of #95976 - b-naber:valtree-constval-conversion, r=oli-obk
Implement Valtree to ConstValue conversion

Once we start to use `ValTree`s in the type system we will need to be able to convert them into `ConstValue` instances, which we want to continue to use after MIR construction.

r? `@oli-obk`

cc `@RalfJung`
2022-04-28 13:18:22 +00:00
SparrowLii
cf00142b4d use tcx.require_lang_item() instead 2022-04-28 20:18:01 +08:00
Oli Scherer
018f9347fc Update the diagnostic message to match the new span 2022-04-28 09:40:42 +00:00
Oli Scherer
4e6e68e27a Check that repeat expression elements are Copy (ignoring lifetimes) in typeck and that they are Copy (with proper lifetime checks) in borrowck 2022-04-28 09:19:42 +00:00
Vadim Petrochenkov
2733ec1be3 rustc_ast: Harmonize delimiter naming with proc_macro::Delimiter 2022-04-28 10:04:29 +03:00
bors
0e7915d11f Auto merge of #96085 - jsgf:deny-unused-deps, r=compiler-errors
Make sure `-Dunused-crate-dependencies --json unused-externs` makes rustc exit with error status

This PR:
- fixes compiletest to understand unused extern notifications
- adds tests for `--json unused-externs`
- makes sure that deny-level unused externs notifications are treated as compile errors
  - refactors the `emit_unused_externs` callstack to plumb through the level as an enum as a string, and adds `Level::is_error`

Update: adds `--json unused-externs-silent` with the original behaviour since Cargo needs it. Should address `@est31's` concerns.

Fixes: https://github.com/rust-lang/rust/issues/96068
2022-04-28 04:17:52 +00:00
bors
81799cd8fd Auto merge of #96495 - Dylan-DPC:rollup-9lm4tpp, r=Dylan-DPC
Rollup of 7 pull requests

Successful merges:

 - #96377 (make `fn() -> _ { .. }` suggestion MachineApplicable)
 - #96397 (Make EncodeWide implement FusedIterator)
 - #96421 (Less `NoDelim`)
 - #96432 (not need `Option` for `dbg_scope`)
 - #96466 (Better error messages when collecting into `[T; n]`)
 - #96471 (replace let else with `?`)
 - #96483 (Add missing `target_feature` to the list of well known cfg names)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-04-28 01:37:03 +00:00
Dylan DPC
89db345859
Rollup merge of #96483 - Urgau:check-cfg-target_feature, r=petrochenkov
Add missing `target_feature` to the list of well known cfg names

This PR adds the missing `target_feature` cfg name to the list of well known cfg names.

It was notice missing in https://github.com/rust-lang/rust/issues/96472 thanks to `@bjorn3,` the reason being that `--check-cfg=names()` automatically inherit the names passed by `--cfg` (or internal to `rustc`) and is seems that the vast majority of targets have at least one target feature leading to `target_feature` being a well known name in most target but it should always be a well known name so this PR add it unconditionally to list.

r? `@petrochenkov`
2022-04-28 02:40:37 +02:00
Dylan DPC
4c628bbb1c
Rollup merge of #96471 - BoxyUwU:let_else_considered_harmful, r=lcnr
replace let else with `?`

r? `@oli-obk`
2022-04-28 02:40:36 +02:00
Dylan DPC
6f6fe3e651
Rollup merge of #96466 - compiler-errors:error-collect-array, r=davidtwco
Better error messages when collecting into `[T; n]`

Fixes #96461
2022-04-28 02:40:35 +02:00
Dylan DPC
d956d014f2
Rollup merge of #96432 - SparrowLii:dbg_scope, r=davidtwco
not need `Option` for `dbg_scope`

This PR fixes a few FIXME about not using `Option` in `dbg_scope` field of `DebugScope`, during `create_function_debug_context` func in codegen parts.
Added a `BitSet<SourceScope>` parameter to `make_mir_scope` to indicate whether the `DebugScope` has been instantiated.
cc ````@eddyb````
2022-04-28 02:40:34 +02:00
Dylan DPC
80045d65e1
Rollup merge of #96421 - nnethercote:less-NoDelim, r=petrochenkov
Less `NoDelim`

Currently there are several places where `NoDelim` (which really means "implicit delimiter" or "invisible delimiter") is used to mean "no delimiter". The name `NoDelim` is a bit misleading, and may be a cause.

This PR changes these places, e.g. by changing a `DelimToken` to `Option<DelimToken>` and then using `None` to mean "no delimiter". As a result, the *only* place where `NoDelim` values are now produced is within:
- `Delimiter::to_internal()`, when converting from `Delimiter::None`.
- `FlattenNonterminals::process_token()`, when converting `TokenKind::Interpolated`.

r? ````@petrochenkov````
2022-04-28 02:40:34 +02:00
Dylan DPC
4a7483c905
Rollup merge of #96377 - compiler-errors:infer-rustfix, r=petrochenkov
make `fn() -> _ { .. }` suggestion MachineApplicable

This might not be valid, but it would be nice to promote this to `MachineApplicable` so people can use rustfix here.

Also de65fcf009d07019689cfad7f327667e390a325d is to [restore the suggestion for `issue-77179.rs`](de65fcf009 (diff-12e43fb5d6d12ec7cb5c6b48204a18d113cf5de0e12eb71a358b639bd9aadaf0R8)). (though in this case, the code in that issue still doesn't compile, so it's not marked with rustfix).
2022-04-28 02:40:32 +02:00
bors
c95346b8ac Auto merge of #91557 - cjgillot:ast-lifetimes-named, r=petrochenkov
Perform lifetime resolution on the AST for lowering

Lifetime resolution is currently implemented several times. Once during lowering in order to introduce in-band lifetimes, and once in the resolve_lifetimes query. However, due to the global nature of lifetime resolution and how it interferes with hygiene, it is better suited on the AST.

This PR implements a first draft of lifetime resolution on the AST. For now, we specifically target named lifetimes and everything we need to remove lifetime resolution from lowering. Some diagnostics have already been ported, and sometimes made more precise using available hygiene information. Follow-up PRs will address in particular the resolution of anonymous lifetimes on the AST.

We reuse the rib design of the current resolution framework. Specific `LifetimeRib` and `LifetimeRibKind` types are introduced. The most important variant is `LifetimeRibKind::Generics`, which happens each time we encounter something which may introduce generic lifetime parameters. It can be an item or a `for<...>` binder. The `LifetimeBinderKind` specifies how this rib behaves with respect to in-band lifetimes.

r? `@petrochenkov`
2022-04-27 23:13:28 +00:00
marmeladema
2c94218238 Recover suggestions to introduce named lifetime under NLL 2022-04-27 22:36:40 +02:00
Camille GILLOT
21b6d23890 Collect extra lifetime parameters during late resolution. 2022-04-27 22:03:26 +02:00
Camille GILLOT
b590e3062c Refactor generic collection. 2022-04-27 22:03:19 +02:00
Camille GILLOT
6857a8d14e Create a specific struct for lifetime capture. 2022-04-27 22:03:12 +02:00
Camille GILLOT
f901df3739 Handle TAIT. 2022-04-27 22:00:44 +02:00
Camille GILLOT
f385f856cd Use LifetimeRes during lowering. 2022-04-27 22:00:15 +02:00
Camille GILLOT
69985f0175 Do not resolve elided lifetimes in path twice. 2022-04-27 21:59:47 +02:00
Camille GILLOT
38a4c2cc44 Update comment. 2022-04-27 21:59:47 +02:00
Loïc BRANSTETT
beb4e16f05 Add missing target_feature to the list of well known cfg names 2022-04-27 19:11:56 +02:00
Jeremy Fitzhardinge
c6bafa7322 Add --json unused-externs-silent with original behaviour
Since Cargo wants to do its own fatal error handling for unused
dependencies, add the option `--json unused-externs-silent` which
has the original behaviour of not indicating non-zero exit status for
`deny`/`forbid`-level unused dependencies.
2022-04-27 10:04:25 -07:00
Jeremy Fitzhardinge
0529a13b5d Plumb through rustc_lint_defs::Level as enum rather than string. 2022-04-27 10:04:25 -07:00
Jeremy Fitzhardinge
39f2f18463 Make --json unused-extern deny/forbid level messages cause exit with error status
Closes: https://github.com/rust-lang/rust/issues/96068
2022-04-27 10:04:25 -07:00
b-naber
ef5f07256c combine all unsized types and add another recursive call to process nested unsized types correctly 2022-04-27 16:58:16 +02:00
Alex Crichton
d51702ae84 Update data layout string for wasm64-unknown-unknown
Looks like this changed in a recent LLVM update but wasm64 isn't built
on CI so it wasn't caught until now.

Closes #96463
2022-04-27 07:29:44 -07:00
Gary Guo
4f9acb2687 Use decorated names for linked_symbols on Windows 2022-04-27 13:17:13 +01:00
SparrowLii
d735aa6810 Eliminate duplication of building panic langcall in codegen 2022-04-27 18:58:59 +08:00
Christian Poveda
e7ae9eb3f2
rename sum_with_parens 2022-04-27 12:03:16 +02:00
Ellen
f697955c1e tut tut tut 2022-04-27 08:51:33 +01:00
Michael Goulet
83d701e569 Better error messages when collecting into [T; n] 2022-04-26 21:37:10 -07:00
Michael Goulet
f9e7489f87 TAITs are suggestable 2022-04-26 18:55:55 -07:00
Michael Goulet
ae42f22ba0 make fn() -> _ {} suggestion MachineApplicable 2022-04-26 18:50:46 -07:00
bors
99b70ee230 Auto merge of #96459 - Dylan-DPC:rollup-de6ud9d, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #92569 (Improve Error Messaging for Unconstructed Structs and Enum Variants in Generic Contexts)
 - #96370 (Cleanup `report_method_error` a bit)
 - #96383 (Fix erased region escaping into wfcheck due to #95395)
 - #96385 (Recover most `impl Trait` and `dyn Trait` lifetime bound suggestions under NLL)
 - #96410 (rustdoc: do not write `{{root}}` in `pub use ::foo` docs)
 - #96430 (Fix handling of `!` in rustdoc search)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-04-27 01:01:58 +00:00
Dylan DPC
dc1f98c655
Rollup merge of #96385 - marmeladema:nll-fix-trait-lifetime-bound-suggestions, r=jackh726
Recover most `impl Trait` and `dyn Trait` lifetime bound suggestions under NLL

This is done by replacing the duplicated (and very partial) implementation from borrowck with one inspsired from `NiceRegionError::try_report_static_impl_trait` and by re-using `suggest_new_region_bound`.

Fixes #96277

r? ```@jackh726```
2022-04-27 02:47:11 +02:00
Dylan DPC
5645732b04
Rollup merge of #96383 - compiler-errors:issue-96381, r=estebank
Fix erased region escaping into wfcheck due to #95395

We can just use `liberate_late_bound_regions` instead of `erase_late_bound_regions`... This gives us `ReEarlyBound` instead of `ReErased`, the former being something typeck actually knows how to deal with...

Fixes #96381

Side-note: We only actually get far enough in the compiler pipeline to cause this ICE when we're invoking rustdoc. We actually abort rustc right before wfcheck because of the error that we emit (having `_` in the type signature). Why does rustdoc keep going even though we raise an error?
2022-04-27 02:47:10 +02:00
Dylan DPC
e63da0ba00
Rollup merge of #96370 - compiler-errors:cleanup-report_method_error, r=estebank
Cleanup `report_method_error` a bit

1. Remove an unnecessary indentation level
2. Split out a couple of large functions from this humongo function body
2022-04-27 02:47:07 +02:00
Nicholas Nethercote
9665da35cc Avoid producing NoDelim values in FrameData. 2022-04-27 10:35:29 +10:00
bors
a7197189cd Auto merge of #96425 - oli-obk:fix_incremental_regression_unsafety_checking, r=compiler-errors
Fix incremental perf regression unsafety checking

Perf regression introduced in #96294

We will simply avoid emitting the name of the unsafe function in MIR unsafeck, since we're moving to THIR unsafeck anyway.
2022-04-26 22:35:40 +00:00
Nicholas Nethercote
a8e862cb7d Avoid producing NoDelim values in Frame.
The code currently ignores the actual delimiter on the RHS and fakes up
a `NoDelim`/`DelimSpan::dummy()` one. This commit changes it to use the
actual delimiter.

The commit also reorders the fields for the `Delimited` variant to match
the `Sequence` variant.
2022-04-27 08:25:22 +10:00
Nicholas Nethercote
6b367a0532 Avoid producing NoDelim values in MacArgs::delim(). 2022-04-27 08:15:12 +10:00
Nicholas Nethercote
f0bbc782ac Avoid producing NoDelim values in TokenCursorFrame. 2022-04-27 08:15:05 +10:00
George
14a127be3e Add new diagnostic 2022-04-26 17:04:44 -04:00
Vadim Petrochenkov
4136b8feb0 linker: Generate symbols.o for dylibs 2022-04-26 23:16:08 +03:00
Vadim Petrochenkov
73317f8b0d linker: Stop using whole-archive on dependencies of dylibs
https://github.com/rust-lang/rust/pull/95604 implemented a better and more fine-grained way of keeping exported symbols alive.
2022-04-26 23:16:07 +03:00
b-naber
bfefb4d74c account for custom DSTs in valtree -> constvalue conversion 2022-04-26 18:40:15 +02:00
Oli Scherer
3568bdc6cd Revert "add DefId to unsafety violations and display function path in E0133"
This reverts commit 8b8f6653cf.
2022-04-26 14:49:28 +00:00
SparrowLii
843e8d19ec not need Option for dbg_scope 2022-04-26 21:00:19 +08:00
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
b-naber
6fc3e630fb add hacky closure to struct_tail_with_normalize in order to allow us to walk valtrees in lockstep with the type 2022-04-26 11:48:59 +02:00
Christian Poveda
1e35bab104
separate messages by a newline 2022-04-26 11:13:23 +02:00
Christian Poveda
6c3e793fb3
move AmbigousPlus outside 2022-04-26 11:12:48 +02:00
Christian Poveda
35b42cb9ec
avoid format! 2022-04-26 11:11:23 +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
Christian Poveda
2e261a82f3
add struct_warn method 2022-04-25 23:49:53 +02:00
Christian Poveda
530f4dce29
remove old code 2022-04-25 23:26:52 +02:00
Christian Poveda
5874b09806
fix formatting 2022-04-25 23:17:32 +02:00
Christian Poveda
519dd8e9de
migrate ambiguous plus diagnostic 2022-04-25 22:55:15 +02:00
Christian Poveda
eb55cdce4b
use ParseSess instead of Session in into_diagnostic 2022-04-25 22:54:16 +02:00
Michael Goulet
8a28aa48d2 Fix issue 96381 2022-04-25 13:31:53 -07: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
marmeladema
e1b074a2a8 Recover most impl Trait and dyn Trait lifetime bound suggestions under NLL 2022-04-25 09:14:44 +02:00
lcnr
5594db0975 do not consider two extern types to be similar 2022-04-25 08:51:26 +02:00