Commit graph

172 commits

Author SHA1 Message Date
bors
5cf2920ef3 Auto merge of #94468 - Amanieu:global_asm_sym, r=nagisa
Implement sym operands for global_asm!

Tracking issue: #93333

This PR is pretty much a complete rewrite of `sym` operand support for inline assembly so that the same implementation can be shared by `asm!` and `global_asm!`. The main changes are:
- At the AST level, `sym` is represented as a special `InlineAsmSym` AST node containing a path instead of an `Expr`.
- At the HIR level, `sym` is split into `SymStatic` and `SymFn` depending on whether the path resolves to a static during AST lowering (defaults to `SynFn` if `get_early_res` fails).
  - `SymFn` is just an `AnonConst`. It runs through typeck and we just collect the resulting type at the end. An error is emitted if the type is not a `FnDef`.
  - `SymStatic` directly holds a path and the `DefId` of the `static` that it is pointing to.
- The representation at the MIR level is mostly unchanged. There is a minor change to THIR where `SymFn` is a constant instead of an expression.
- At the codegen level we need to apply the target's symbol mangling to the result of `tcx.symbol_name()` depending on the target. This is done by calling the LLVM name mangler, which handles all of the details.
  - On Mach-O, all symbols have a leading underscore.
  - On x86 Windows, different mangling is used for cdecl, stdcall, fastcall and vectorcall.
  - No mangling is needed on other platforms.

r? `@nagisa`
cc `@eddyb`
2022-04-16 04:46:01 +00:00
Vadim Petrochenkov
6f825246f8 clippy: Update full path to CString 2022-04-15 16:52:58 +03:00
Amanieu d'Antras
0de314b3b3 Reimplement lowering of sym operands for asm! so that it also works with global_asm! 2022-04-14 15:32:03 +01:00
bors
27634b03ea Auto merge of #94255 - b-naber:use-mir-constant-in-thir, r=oli-obk
Use mir constant in thir instead of ty::Const

This is blocked on https://github.com/rust-lang/rust/pull/94059 (does include its changes, the first two commits in this PR correspond to those changes) and https://github.com/rust-lang/rust/pull/93800 being reinstated (which had to be reverted). Mainly opening since `@lcnr` offered to give some feedback and maybe also for a perf-run (if necessary).

This currently contains a lot of duplication since some of the logic of `ty::Const` had to be copied to `mir::ConstantKind`, but with the introduction of valtrees a lot of that functionality will disappear from `ty::Const`.

Only the last commit contains changes that need to be reviewed here. Did leave some `FIXME` comments regarding future implementation decisions and some things that might be incorrectly implemented.

r? `@oli-obk`
2022-04-13 07:50:56 +00:00
Jakob Degen
62d912e24d Add new Deinit statement kind 2022-04-11 08:55:03 -04:00
flip1995
71131351de Merge commit '984330a6ee3c4d15626685d6dc8b7b759ff630bd' into clippyup 2022-04-08 10:06:10 +01:00
David Wood
c8b9e85b20 span: move MultiSpan
`MultiSpan` contains labels, which are more complicated with the
introduction of diagnostic translation and will use types from
`rustc_errors` - however, `rustc_errors` depends on `rustc_span` so
`rustc_span` cannot use types like `DiagnosticMessage` without
dependency cycles. Introduce a new `rustc_error_messages` crate that can
contain `DiagnosticMessage` and `MultiSpan`.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05 07:01:00 +01:00
b-naber
bca346b90b rebase and use ty::Const in patterns again 2022-04-02 12:21:00 +02:00
lcnr
104ba478f2 clippy: nameres for primitive type impls 2022-03-30 11:57:53 +02:00
lcnr
148b593954 get clippy to compile again 2022-03-30 11:23:58 +02:00
Oli Scherer
b3535a1549 Remove opaque type obligation and just register opaque types as they are encountered.
This also registers obligations for the hidden type immediately.
2022-03-28 16:57:45 +00:00
Oli Scherer
46e832e1ee Revert "Auto merge of #93893 - oli-obk:sad_revert, r=oli-obk"
This reverts commit 6499c5e7fc173a3f55b7a3bd1e6a50e9edef782d, reversing
changes made to 78450d2d602b06d9b94349aaf8cece1a4acaf3a8.
2022-03-28 16:27:14 +00:00
flip1995
1fa3d66e62 Merge commit 'd0cf3481a84e3aa68c2f185c460e282af36ebc42' into clippyup 2022-03-24 14:50:04 +01:00
flip1995
d1b087fdee Merge commit 'dc5423ad448877e33cca28db2f1445c9c4473c75' into clippyup 2022-03-14 12:02:53 +01:00
Nicholas Nethercote
e110231260 Improve AdtDef interning.
This commit makes `AdtDef` use `Interned`. Much the commit is tedious
changes to introduce getter functions. The interesting changes are in
`compiler/rustc_middle/src/ty/adt.rs`.
2022-03-11 13:31:24 +11:00
lcnr
a4d6c61bdc add #[rustc_pass_by_value] to more types 2022-03-08 15:39:52 +01:00
Eric Holk
b86620da37 Stabilize const_fn_fn_ptr_basics and const_fn_trait_bound 2022-03-07 08:47:15 -08:00
Nicholas Nethercote
96eb1168d1 Introduce ConstAllocation.
Currently some `Allocation`s are interned, some are not, and it's very
hard to tell at a use point which is which.

This commit introduces `ConstAllocation` for the known-interned ones,
which makes the division much clearer. `ConstAllocation::inner()` is
used to get the underlying `Allocation`.

In some places it's natural to use an `Allocation`, in some it's natural
to use a `ConstAllocation`, and in some places there's no clear choice.
I've tried to make things look as nice as possible, while generally
favouring `ConstAllocation`, which is the type that embodies more
information. This does require quite a few calls to `inner()`.

The commit also tweaks how `PartialOrd` works for `Interned`. The
previous code was too clever by half, building on `T: Ord` to make the
code shorter. That caused problems with deriving `PartialOrd` and `Ord`
for `ConstAllocation`, so I changed it to build on `T: PartialOrd`,
which is slightly more verbose but much more standard and avoided the
problems.
2022-03-07 08:25:50 +11:00
Jack Huey
9bee01eb91 Change syntax for TyAlias where clauses 2022-03-05 13:13:45 -05:00
flip1995
35020280a0 Merge commit 'e329249b6a3a98830d860c74c8234a8dd9407436' into clippyup 2022-02-26 14:26:21 +01:00
Eduard-Mihai Burtescu
88483bd4b7 Replace &mut DiagnosticBuilder, in signatures, with &mut Diagnostic. 2022-02-23 05:38:19 +00:00
lcnr
e390e6c469 update clippy 2022-02-21 07:09:11 +01:00
Nicholas Nethercote
64ae3ae006 Overhaul Const.
Specifically, rename the `Const` struct as `ConstS` and re-introduce `Const` as
this:
```
pub struct Const<'tcx>(&'tcx Interned<ConstS>);
```
This now matches `Ty` and `Predicate` more closely, including using
pointer-based `eq` and `hash`.

Notable changes:
- `mk_const` now takes a `ConstS`.
- `Const` was copy, despite being 48 bytes. Now `ConstS` is not, so need a
  we need separate arena for it, because we can't use the `Dropless` one any
  more.
- Many `&'tcx Const<'tcx>`/`&Const<'tcx>` to `Const<'tcx>` changes
- Many `ct.ty` to `ct.ty()` and `ct.val` to `ct.val()` changes.
- Lots of tedious sigil fiddling.
2022-02-15 16:19:59 +11:00
Nicholas Nethercote
5fa961b951 Overhaul TyS and Ty.
Specifically, change `Ty` from this:
```
pub type Ty<'tcx> = &'tcx TyS<'tcx>;
```
to this
```
pub struct Ty<'tcx>(Interned<'tcx, TyS<'tcx>>);
```
There are two benefits to this.
- It's now a first class type, so we can define methods on it. This
  means we can move a lot of methods away from `TyS`, leaving `TyS` as a
  barely-used type, which is appropriate given that it's not meant to
  be used directly.
- The uniqueness requirement is now explicit, via the `Interned` type.
  E.g. the pointer-based `Eq` and `Hash` comes from `Interned`, rather
  than via `TyS`, which wasn't obvious at all.

Much of this commit is boring churn. The interesting changes are in
these files:
- compiler/rustc_middle/src/arena.rs
- compiler/rustc_middle/src/mir/visit.rs
- compiler/rustc_middle/src/ty/context.rs
- compiler/rustc_middle/src/ty/mod.rs

Specifically:
- Most mentions of `TyS` are removed. It's very much a dumb struct now;
  `Ty` has all the smarts.
- `TyS` now has `crate` visibility instead of `pub`.
- `TyS::make_for_test` is removed in favour of the static `BOOL_TY`,
  which just works better with the new structure.
- The `Eq`/`Ord`/`Hash` impls are removed from `TyS`. `Interned`s impls
  of `Eq`/`Hash` now suffice. `Ord` is now partly on `Interned`
  (pointer-based, for the `Equal` case) and partly on `TyS`
  (contents-based, for the other cases).
- There are many tedious sigil adjustments, i.e. adding or removing `*`
  or `&`. They seem to be unavoidable.
2022-02-15 16:03:24 +11:00
Ellen
7c94736953 change to a struct variant 2022-02-12 11:23:53 +00:00
bors
bb7131c6dd Auto merge of #93893 - oli-obk:sad_revert, r=oli-obk
Revert lazy TAIT PR

Revert https://github.com/rust-lang/rust/pull/92306 (sorry `@Aaron1011,` will include your changes in the fix PR)
Revert https://github.com/rust-lang/rust/pull/93783
Revert https://github.com/rust-lang/rust/pull/92007

fixes https://github.com/rust-lang/rust/issues/93788
fixes https://github.com/rust-lang/rust/issues/93794
fixes https://github.com/rust-lang/rust/issues/93821
fixes https://github.com/rust-lang/rust/issues/93831
fixes https://github.com/rust-lang/rust/issues/93841
2022-02-11 17:39:34 +00:00
Oli Scherer
8173abad57 Revert "Auto merge of #92007 - oli-obk:lazy_tait2, r=nikomatsakis"
This reverts commit e7cc3bddbe0d0e374d05e7003e662bba1742dbae, reversing
changes made to 734368a200904ef9c21db86c595dc04263c87be0.
2022-02-11 07:18:06 +00:00
flip1995
611d039814 Merge commit '57b3c4b90f4346b3990c1be387c3b3ca7b78412c' into clippyup 2022-02-10 18:40:06 +01:00
Oli Scherer
69872175ee Lazily resolve type-alias-impl-trait defining uses
by using an opaque type obligation to bubble up comparisons between opaque types and other types

Also uses proper obligation causes so that the body id works, because out of some reason nll uses body ids for logic instead of just diagnostics.
2022-02-02 15:40:11 +00:00
lcnr
99af4c8971 remove TyS::same_type
it ignored regions and constants in adts,
but didn't do so for references or any other types.
This seemed quite weird
2022-02-01 11:21:26 +01:00
bors
b606d160c8 Auto merge of #90891 - nbdd0121:format, r=Mark-Simulacrum
Create `core::fmt::ArgumentV1` with generics instead of fn pointer

Split from (and prerequisite of) #90488, as this seems to have perf implication.

`@rustbot` label: +T-libs
2022-01-31 00:04:46 +00:00
Gary Guo
4119f60c1f Create core::fmt::ArgumentV1 with generics instead of fn pointer 2022-01-29 13:52:19 +00:00
flip1995
bf66aeda0a Merge commit 'a98e7ab8b94485be6bd03e0c6b8682ecab5b52e6' into clippyup 2022-01-27 15:12:45 +01:00
Vadim Petrochenkov
aee89cdff1 Update clippy 2022-01-23 19:31:32 +08:00
Cameron Steffen
82f613ee3b Remove a span from hir::ExprKind::MethodCall 2022-01-21 07:48:10 -06:00
bors
5a25c0e6e9 Auto merge of #87648 - JulianKnodt:const_eq_constrain, r=oli-obk
allow eq constraints on associated constants

Updates #70256

(cc `@varkor,` `@Centril)`
2022-01-18 09:58:39 +00:00
kadmin
05b8c727d8 Add term
Instead of having a separate enum variant for types and consts have one but have either a const
or type.
2022-01-17 17:20:57 +00:00
kadmin
7383a61968 add eq constraints on associated constants 2022-01-17 17:20:57 +00:00
bors
8f481167da Auto merge of #90986 - camsteffen:nested-filter, r=cjgillot
Replace `NestedVisitorMap` with generic `NestedFilter`

This is an attempt to make the `intravisit::Visitor` API simpler and "more const" with regard to nested visiting.

With this change, `intravisit::Visitor` does not visit nested things by default, unless you specify `type NestedFilter = nested_filter::OnlyBodies` (or `All`). `nested_visit_map` returns `Self::Map` instead of `NestedVisitorMap<Self::Map>`. It panics by default (unreachable if `type NestedFilter` is omitted).

One somewhat trixty thing here is that `nested_filter::{OnlyBodies, All}` live in `rustc_middle` so that they may have `type Map = map::Map` and so that `impl Visitor`s never need to specify `type Map` - it has a default of `Self::NestedFilter::Map`.
2022-01-17 14:50:50 +00:00
bors
55fa2ea00c Auto merge of #92816 - tmiasko:rm-llvm-asm, r=Amanieu
Remove deprecated LLVM-style inline assembly

The `llvm_asm!` was deprecated back in #87590 1.56.0, with intention to remove
it once `asm!` was stabilized, which already happened in #91728 1.59.0. Now it
is time to remove `llvm_asm!` to avoid continued maintenance cost.

Closes #70173.
Closes #92794.
Closes #87612.
Closes #82065.

cc `@rust-lang/wg-inline-asm`

r? `@Amanieu`
2022-01-17 09:40:29 +00:00
Cameron Steffen
eb80da175c Fix Visitor::NestedFilter in Clippy 2022-01-16 16:02:36 -06:00
Cameron Steffen
94dd91524b Format clippy 2022-01-16 16:02:36 -06:00
bors
f4a88f23c1 Auto merge of #92805 - BoxyUwU:revert-lazy-anon-const-substs, r=lcnr
partially revertish `lazily "compute" anon const default substs`

reverts #87280 except for some of the changes around `ty::Unevaluated` having a visitor and a generic for promoted
why revert: <https://github.com/rust-lang/rust/pull/92805#issuecomment-1010736049>

r? `@lcnr`
2022-01-16 11:19:21 +00:00
Camille GILLOT
0a48547140 Return a LocalDefId in get_parent_item. 2022-01-15 21:26:20 +01:00
Ellen
fb86f844a4 nyahggdshjjghsdfhgsf 2022-01-15 01:16:55 +00:00
Ellen
377870a136 initial revert 2022-01-15 01:16:55 +00:00
Matthias Krüger
d7024acb32 Rollup merge of #92849 - flip1995:clippyup, r=Manishearth
Clippyup

r? ```@Manishearth```
2022-01-14 07:47:37 +01:00
bors
2e3b64deef Auto merge of #89861 - nbdd0121:closure, r=wesleywiser
Closure capture cleanup & refactor

Follow up of #89648

Each commit is self-contained and the rationale/changes are documented in the commit message, so it's advisable to review commit by commit.

The code is significantly cleaner (at least IMO), but that could have some perf implication, so I'd suggest a perf run.

r? `@wesleywiser`
cc `@arora-aman`
2022-01-13 18:51:07 +00:00
flip1995
7e267c23d6 Fix Clippy sync fallout 2022-01-13 13:37:29 +01:00
flip1995
fb0142ae41 Merge commit '97a5daa65908e59744e2bc625b14849352231c75' into clippyup 2022-01-13 13:18:19 +01:00