Commit Graph

430 Commits

Author SHA1 Message Date
Celina G. Val e70839ac84 Add more SMIR internal impl and callback return value
In cases like Kani, we will invoke the rustc_internal run command
directly for now. It would be handly to be able to have a callback
that can return a value.

We also need extra methods to convert stable constructs into internal
ones, so we can break down the transition into finer grain commits.
2023-11-16 11:05:36 -08:00
Mark Rousskov db3e2bacb6 Bump cfg(bootstrap)s 2023-11-15 19:41:28 -05:00
bors 1500db7314 Auto merge of #117908 - lcnr:region-kind-rename, r=BoxyUwU
finish `RegionKind` renaming

second step of https://github.com/rust-lang/types-team/issues/95

continues the work from #117876. While working on this and I encountered a bunch of further cleanup which I'll either open a tracking issue for or will do in a separate PR:
- rewrite the `RegionKind` docs, they still talk about `ReEmpty` and are generally out of date
- rename `DescriptionCtx` to `DescriptionCtxt`
- what is `CheckRegions::Bound`?
- `collect_late_bound_regions` et al
- `erase_late_bound_regions` -> `instantiate_bound_regions_with_erased`?
- `EraseEarlyRegions` visitor should be removed, feels duplicate

r? `@BoxyUwU`
2023-11-15 12:55:42 +00:00
bors 698fcc8219 Auto merge of #117517 - klinvill:smir-projections, r=ouz-a
Add richer structure for Stable MIR Projections

Resolves https://github.com/rust-lang/project-stable-mir/issues/49.

Projections in Stable MIR are currently just strings. This PR replaces that representation with a richer structure, namely projections become vectors of `ProjectionElem`s, just as in MIR. The `ProjectionElem` enum is heavily based off of the MIR `ProjectionElem`.

This PR is a draft since there are several outstanding issues to resolve, including:

- How should `UserTypeProjection`s be represented in Stable MIR? In MIR, the projections are just a vector of `ProjectionElem<(),()>`, meaning `ProjectionElem`s that don't have Local or Type arguments (for `Index`, `Field`, etc. objects). Should `UserTypeProjection`s be represented this way in Stable MIR as well? Or is there a more user-friendly representation that wouldn't drag along all the `ProjectionElem` variants that presumably can't appear?
- What is the expected behavior of a `Place`'s `ty` function? Should it resolve down the chain of projections so that something like `*_1.f` would return the type referenced by field `f`?
- Tests should be added for `UserTypeProjection`
2023-11-15 06:05:54 +00:00
Kirby Linvill c036a10ed5
Make UserTypeProjection projections Opaque
Also shifts comments explaining why Stable MIR drops an optional variant
name field, for `Downcast` projection elements, to the `Place::stable`
function.
2023-11-14 19:19:35 -07:00
lcnr 15f21562e6 finish `RegionKind` rename
- `ReFree` -> `ReLateParam`
- `ReEarlyBound` -> `ReEarlyParam`
2023-11-14 13:13:27 +00:00
bors d97bb195bf Auto merge of #117787 - ouz-a:smir_coroutinewitness, r=celinval
Add CoroutineWitness to covered types in smir

Previously we accepted `CouroutineWitness` as `unreachable!` but https://github.com/rust-lang/project-stable-mir/issues/50 shows it is indeed reachable, this pr fixes that and covers `CouroutineWitness`
2023-11-14 13:10:25 +00:00
lcnr 86fa1317a3 rename `ReLateBound` to `ReBound`
other changes:
- `Region::new_late_bound` -> `Region::new_bound`
- `Region::is_late_bound` -> `Region::is_bound`
2023-11-13 14:13:54 +00:00
Oğuz Ağcayazı 6812f64c35 add CoroutineWitness to covered types 2023-11-10 17:02:08 +03:00
Kirby Linvill 2e70d95cdb
Remove rich UserTypeProjection projections in SMIR
It's not clear to me (klinvill) that UserTypeProjections are produced
anymore with the removal of type ascriptions as per
https://github.com/rust-lang/rfcs/pull/3307. Furthermore, it's not clear
to me which variants of ProjectionElem could appear in such projections.
For these reasons, I'm reverting projections in UserTypeProjections to
simple strings until I can get more clarity on UserTypeProjections.
2023-11-09 20:56:40 -07:00
Kirby Linvill b1585983cc
Add stable MIR Projections support based on MIR structure
This commit includes richer projections for both Places and
UserTypeProjections. However, the tests only touch on Places. There are
also outstanding TODOs regarding how projections should be resolved to
produce Place types, and regarding if UserTypeProjections should just
contain ProjectionElem<(),()> objects as in MIR.
2023-11-09 20:56:35 -07:00
Matthias Krüger 7fd7719ca1
Rollup merge of #117741 - eltociear:patch-23, r=compiler-errors
Fix typo in internal.rs

covert -> convert
2023-11-10 01:50:25 +01:00
Ikko Eltociear Ashimine b8648216a5
Fix typo in internal.rs
covert -> convert
2023-11-09 16:10:37 +09:00
lcnr 992d93f687 rename `BorrowKind::Shallow` to `Fake`
also adds some comments
2023-11-08 22:55:28 +01:00
bors 146dafa262 Auto merge of #114208 - GKFX:offset_of_enum, r=wesleywiser
Support enum variants in offset_of!

This MR implements support for navigating through enum variants in `offset_of!`, placing the enum variant name in the second argument to `offset_of!`. The RFC placed it in the first argument, but I think it interacts better with nested field access in the second, as you can then write things like

```rust
offset_of!(Type, field.Variant.field)
```

Alternatively, a syntactic distinction could be made between variants and fields (e.g. `field::Variant.field`) but I'm not convinced this would be helpful.

[RFC 3308 # Enum Support](https://rust-lang.github.io/rfcs/3308-offset_of.html#enum-support-offset_ofsomeenumstructvariant-field_on_variant)
Tracking Issue #106655.
2023-11-01 14:17:56 +00:00
George Bateman d995bd61e7
Enums in offset_of: update based on est31, scottmcm & llogiq review 2023-10-31 23:26:02 +00:00
George Bateman e936416a8d
Support enum variants in offset_of! 2023-10-31 23:25:54 +00:00
Matthias Krüger 290daf9318
Rollup merge of #117417 - celinval:smir-visitor, r=oli-obk
Add a stable MIR visitor

This change also adds a few utility functions as well and extend most `mir` and `ty` ADTs to implement `PartialEq` and `Eq`.

Fixes https://github.com/rust-lang/project-stable-mir/issues/32

r? `@oli-obk`
2023-10-31 19:03:21 +01:00
Celina G. Val af7472ecbc Add a stable MIR visitor
Add a few utility functions as well and extend most `mir` and `ty`
ADTs to implement `PartialEq` and `Eq`.
2023-10-30 13:11:14 -07:00
Nicholas Nethercote 8ff624a9f2 Clean up `rustc_*/Cargo.toml`.
- Sort dependencies and features sections.
- Add `tidy` markers to the sorted sections so they stay sorted.
- Remove empty `[lib`] sections.
- Remove "See more keys..." comments.

Excluded files:
- rustc_codegen_{cranelift,gcc}, because they're external.
- rustc_lexer, because it has external use.
- stable_mir, because it has external use.
2023-10-30 08:46:02 +11:00
bors 2cad938a81 Auto merge of #116447 - oli-obk:gen_fn, r=compiler-errors
Implement `gen` blocks in the 2024 edition

Coroutines tracking issue https://github.com/rust-lang/rust/issues/43122
`gen` block tracking issue https://github.com/rust-lang/rust/issues/117078

This PR implements `gen` blocks that implement `Iterator`. Most of the logic with `async` blocks is shared, and thus I renamed various types that were referring to `async` specifically.

An example usage of `gen` blocks is

```rust
fn foo() -> impl Iterator<Item = i32> {
    gen {
        yield 42;
        for i in 5..18 {
            if i.is_even() { continue }
            yield i * 2;
        }
    }
}
```

The limitations (to be resolved) of the implementation are listed in the tracking issue
2023-10-29 00:03:52 +00:00
Matthias Krüger 33744804fe
Rollup merge of #117262 - celinval:issue-38-norm, r=oli-obk
Create a new ConstantKind variant (ZeroSized) for StableMIR

ZeroSized constants can be represented as `mir::Const::Val` even if their layout is not yet known. In those cases, CrateItem::body() was crashing when trying to convert a `ConstValue::ZeroSized` into its stable counterpart  `ConstantKind::Allocated`.

Instead, we now map `ConstValue::ZeroSized` into a new variant: `ConstantKind::ZeroSized`.

**Note:** I didn't add any new test here since we already have covering tests in our project repository which I manually confirmed that will fix the issue.
2023-10-27 11:48:07 +02:00
Celina G. Val 613e6181a6 Specialize ZeroSized constants
ZeroSized constants can be represented as `mir::Const::Val` even if
their layout is not yet known. In those cases, CrateItem::body() was
crashing when trying to convert a `ConstValue::ZeroSized` into its
stable counterpart `ConstantKind::Allocated`.

Instead, we now map `ConstValue::ZeroSized` into a new variant:
`ConstantKind::ZeroSized`.
2023-10-26 20:17:44 -07:00
Matthias Krüger b66c6e719f
Rollup merge of #117095 - klinvill:smir-fn-arg-count, r=oli-obk
Add way to differentiate argument locals from other locals in Stable MIR

This PR resolves rust-lang/project-stable-mir#47 which request a way to differentiate argument locals in a SMIR `Body` from other locals.

Specifically, this PR exposes the `arg_count` field from the MIR `Body`. However, I'm opening this as a draft PR because I think there are a few outstanding questions on how this information should be exposed and described. Namely:

- Is exposing `arg_count` the best way to surface this information to SMIR users? Would it be better to leave `arg_count` as a private field and add public methods (e.g. `fn arguments(&self) -> Iter<'_, LocalDecls>`) that may use the underlying `arg_count` info from the MIR body, but expose this information to users in a more convenient form? Or is it best to stick close to the current MIR convention?
- If the answer to the above point is to stick with the current MIR convention (`arg_count`), is it reasonable to also commit to sticking to the current MIR convention that the first local is always the return local, while the next `arg_count` locals are always the (in-order) argument locals?
- Should `Body` in SMIR only represent function bodies (as implied by the comment I added)? That seems to be the current case in MIR, but should this restriction always be the case for SMIR?

r? `@celinval`
r? `@oli-obk`
2023-10-26 17:45:43 +02:00
Oli Scherer 14423080f1 Add hir::GeneratorKind::Gen 2023-10-26 07:10:25 +00:00
Matthias Krüger 4e4e5619af
Rollup merge of #117175 - oli-obk:gen_fn_split, r=compiler-errors
Rename AsyncCoroutineKind to CoroutineSource

pulled out of https://github.com/rust-lang/rust/pull/116447

Also refactors the printing infra of `CoroutineSource` to be ready for easily extending it with a `Gen` variant for `gen` blocks
2023-10-25 23:37:11 +02:00
Kirby Linvill 93d1b3e92a
Replace arg_count in public API with return/arg getters
This commit hides the arg_count field in Body and instead exposes more
stable and user-friendly methods to get the return and argument locals.
As a result, Body instances must now be constructed using the `new`
function.
2023-10-25 22:15:47 +01:00
Kirby Linvill e4c41b07f0
Add arg_count field to Body in Stable MIR
This field allows SMIR consumers to identify which locals correspond to
argument locals. It simply exposes the arg_count field from the MIR
representation.
2023-10-25 22:15:47 +01:00
Oli Scherer af8a998b1e Rename `AsyncCoroutineKind` to `CoroutineSource`
similar to how we have `MatchSource`, it explains where the desugaring came from.
2023-10-25 16:14:05 +00:00
bors b66fe58f68 Auto merge of #117113 - celinval:smir-stable-ty, r=oli-obk
Remove fold code and add `Const::internal()` to StableMIR

We are not planning to support user generated constant in the foreseeable future, so we are cleaning up the fold logic and user created type for now. Users should use `Instance::resolve` in order to trigger monomorphization.

The Instance::resolve was however incomplete, since we weren't handling internalizing constants yet. Thus, I added that.

I decided to keep the `Const` fields private in case we decide to translate them lazily.
2023-10-25 13:19:54 +00:00
bors 98108dc26c Auto merge of #116993 - compiler-errors:clause-kind, r=jackh726
Uplift `ClauseKind` and `PredicateKind` into `rustc_type_ir`

Uplift `ClauseKind` and `PredicateKind` into `rustc_type_ir`.

Blocked on #116951

r? `@ghost`
2023-10-25 05:02:04 +00:00
Celina G. Val 17f6df9c63 Use IndexMap for handling stable Ty 2023-10-24 15:37:43 -07:00
Celina G. Val 3f60165d27 Remove fold code and add Const::internal()
We are not planning to support user generated constant in the
foreseeable future, so we are removing the Fold logic for now in
favor of the Instance::resolve logic.

The Instance::resolve was however incomplete, since we weren't handling
internalizing constants yet. Thus, I added that.

I decided to keep the Const fields private in case we decide to
translate them lazily.
2023-10-24 14:50:58 -07:00
Celina G. Val ae86f59cc9 Add test and remove double ref 2023-10-23 21:36:43 -07:00
Celina G. Val 421631a3a1 Remove unsafe and `Rc` 2023-10-23 14:22:04 -07:00
Celina G. Val f613b26cfb Add `internal()` method counterpart to `stable()`
Note: We do not expect to provide internalizing methods for all
StableMIR constructs. They exist only to help migrating efforts to allow
users to mix StableMIR and internal constructs.
2023-10-23 12:11:07 -07:00
Celina G. Val 66a554b045 Add method to convert internal to stable constructs 2023-10-23 12:01:39 -07:00
Oli Scherer 4a5fecb187 Avoid having `rustc_smir` depend on `rustc_interface` or `rustc_driver` 2023-10-23 09:48:15 +00:00
Matthias Krüger b7035198e6
Rollup merge of #116964 - celinval:smir-mono-body, r=oli-obk
Add stable Instance::body() and RustcInternal trait

The `Instance::body()` returns a monomorphized body.

For that, we had to implement visitor that monomorphize types and constants. We are also introducing the RustcInternal trait that will allow us to convert back from Stable to Internal.

Note that this trait is not yet visible for our users as it depends on Tables. We should probably add a new trait that can be exposed.

The tests here are very simple, and I'm planning on creating more exhaustive tests in the project-mir repo. But I was hoping to get some feedback here first.

r? ```@oli-obk```
2023-10-21 10:08:17 +02:00
Michael Goulet 573f475853 Uplift ClauseKind and PredicateKind 2023-10-20 17:14:49 -07:00
Oli Scherer 2d91c76d5d Rename `CoroutineKind::Gen` to `::Coroutine` 2023-10-20 21:14:01 +00:00
Oli Scherer e96ce20b34 s/generator/coroutine/ 2023-10-20 21:14:01 +00:00
Oli Scherer 60956837cf s/Generator/Coroutine/ 2023-10-20 21:10:38 +00:00
Celina G. Val 6ed2a76bcc Add stable Instance::body() and RustcInternal trait
The `Instance::body()` returns a monomorphized body.

For that, we had to implement visitor that monomorphize types and
constants. We are also introducing the RustcInternal trait that will
allow us to convert back from Stable to Internal.

Note that this trait is not yet visible for our users as it depends on
Tables. We should probably add a new trait that can be exposed.
2023-10-19 17:12:26 -07:00
Celina G. Val 364f1a3f16 Add MonoItems and Instance to stable_mir
Also add a few methods to instantiate instances and get an instance
definition.

We're still missing support to actually monomorphize the instance body.
2023-10-16 12:01:24 -07:00
Oğuz Ağcayazı d6a55d3409 change fn name, return loc info, local name 2023-10-13 11:44:38 +03:00
Oğuz Ağcayazı 1d9481fdc8 implement get_filename/lines for span 2023-10-11 17:55:57 +03:00
bors 6d05c430d2 Auto merge of #115948 - notriddle:notriddle/logo-lockup, r=fmease
rustdoc: show crate name beside smaller logo

*Blocked on https://github.com/rust-lang/cargo/pull/12800*

## Summary

In this PR, the crate name and version are always shown in the sidebar, even in subpages, and the lateral navigation is always shown in the sidebar, even in modules.

Clicking the crate name does the same thing clicking the logo always did: take you to the crate root (the crate's home page, at least within Rustdoc).

The Rust logo is also no longer shown by default for non-Rust docs.

### Screenshots

<details><summary>Before</summary>

| | Macro | Module |
|--|-------|--------|
| In crate | ![image](https://github.com/rust-lang/rust/assets/1593513/d5db0a46-2bb6-44a2-a3aa-2d915ecb8595) |![image](https://github.com/rust-lang/rust/assets/1593513/61f8c1ee-c298-4e2c-b791-18ecb79ab83b)
| In module[^1] | ![image](https://github.com/rust-lang/rust/assets/1593513/73abca59-0b69-4650-a1e2-7278ca34795c) | ![image](https://github.com/rust-lang/rust/assets/1593513/0baf02c2-2ec7-4674-80e5-a6a74a973376)

[^1]: This PR also includes a bug fix for derive macros not showing up in the lateral navigation part of the sidebar

</details>

#### Whole sidebar screenshots

| | Macro | Module |
|--|-------|--------|
| In crate | ![image](https://github.com/rust-lang/rust/assets/1593513/75d1bd07-41f7-4f11-ba24-fd5476e0586a) | ![image](https://github.com/rust-lang/rust/assets/1593513/52960259-2b65-4131-b380-01826f0a0eb7)
| In module | ![image](https://github.com/rust-lang/rust/assets/1593513/06e57928-8cb0-41bd-b152-be16cc53e5ec) | ![image](https://github.com/rust-lang/rust/assets/1593513/37291c69-2a07-4467-a382-d9b029084a47)

#### Different logo configurations

|         | Short crate name | Long crate name |
|---------|------------------|-----------------|
| Root    | ![short-root]    | ![long-root]
| Subpage | ![short-subpage] | ![long-subpage]

[short-root]: https://github.com/rust-lang/rust/assets/1593513/9e2b4fa8-f581-4106-b562-1e0372c13f79
[short-subpage]: https://github.com/rust-lang/rust/assets/1593513/8331cdb8-fa13-4671-a1e2-dcc1cdca7451
[long-root]: https://github.com/rust-lang/rust/assets/1593513/7d377fec-0f1d-4343-9f82-0e35a8f58056
[long-subpage]: https://github.com/rust-lang/rust/assets/1593513/3b3094a4-63c9-477c-8c15-b6075837df30

##### Without a logo

![image](https://github.com/rust-lang/rust/assets/1593513/66672b79-6c59-4be8-a527-25ef6f0b04ab)

### Preview pages

https://notriddle.com/rustdoc-html-demo-5/sidebar-layout-rocket/rocket/index.html

https://notriddle.com/rustdoc-html-demo-5/sidebar-layout-rocket/rocket_sync_db_pools/index.html

https://notriddle.com/rustdoc-html-demo-5/sidebar-layout-rust-compiler/index.html

https://notriddle.com/rustdoc-html-demo-5/sidebar-layout-rust/std/index.html

https://notriddle.com/rustdoc-html-demo-5/sidebar-layout-rocket/tokio/index.html

## Motivation

This improves visual information density (the construct with the logo and crate name is *shorter* than the logo on its own, because it's not square) and navigation clarity (we can now see what clicking the Rust logo does, specifically).

Compare this with the layout at [Phoenix's Hexdocs] (which is what this proposal is closely based on), the old proposal on [Internals Discourse] (which always says "Rust standard library" in the sidebar, but doesn't do the side-by-side layout).

[Phoenix's Hexdocs]: https://hexdocs.pm/phoenix/1.7.7/overview.html
[Internals Discourse]: https://internals.rust-lang.org/t/poc-of-a-new-design-for-the-generated-rustdoc/11018

## Guide-level explanation

This PR cleans up some of the sidebar navigation.

It makes the logo in the desktop sidebar a bit smaller, and puts the crate name and version next to it (either beside it, or below it, depending on if there's space), making it clearer what clicking on it does: click the crate name to open the crate's home page. It also removes the Rust logo from non-official-Rust crates, again to make the navigation and supply chain clearer (since the crate name has been added, the logo is no longer necessary for navigation).

It adds a bit more clarifying information for lateral navigation. On items that don't add their own sidebar items, it just shows its siblings directly below the crate name and logo, but for other items, it shows "In crate alloc" instead of just "In alloc". It also shows the lateral navigation tools on module pages, making modules consistent with every other item.

## Drawbacks

While this actually takes up less screen real estate than the old layout on desktop, it takes up more HTML. It's also a bit more visually complex.

## Rationale and alternatives

I could do what the Internals POC did and keep the vertically stacked layout all the time, instead of doing a horizontal stack where possible. It would take up more screen real estate, though.

## Prior art

This design is lifted almost verbatim from Hexdocs. It seems to work for them. [`opentelemetry_process_propagator`], for example, has a long application name.

[`opentelemetry_process_propagator`]: https://hexdocs.pm/opentelemetry_process_propagator/OpentelemetryProcessPropagator.html

## Unresolved questions

Maybe we should encourage crate authors to include their own logo more often? It certainly helps give people a better sense of "place." This seems to be blocked on coming up with an API to do it without requiring them to host the file somewhere.

## Future possibilities

Beyond this, plenty of other changes could be made to improve the layout, like

* Fix things so that clicking an item in the sidebar doesn't cause it to scroll back to the top.
  * The [Internals demo](https://utherii.github.io/new.html) does this right: clicking an item in the sidebar changes the content area, but the sidebar itself does not change. This is nice, because clicking is cheap and I can skim the opening few paragraphs while browsing.
  * The layout of the docs sidebar causes trouble to implement this, because it's different on different pages, but at least fix this on the file browser.
* Come up with a less cluttered way to do disclosure. There's a lot of `[-]` on the page.
  * We don't lack ideas to fix this one. We have *too many*.
* Do a better job of separating local navigation (vec::Vec links to vec::IntoIter) and the table of contents (vec::Vec links to vec::Vec::new).
  * A possibility: add a Back arrow next to the "In [module]" header?
    ![image](https://github.com/rust-lang/rust/assets/1593513/e969faf7-7722-457a-b8c6-8d962e9e1e23)
* Give readers more control of how much rustdoc shows them, and giving doc authors more control of how much it generates. Basically, https://github.com/rust-lang/rust/pull/115660 is great, let's do it too.

But those are mostly orthogonal, not future possibilities unlocked by this change.
2023-10-11 06:28:36 +00:00
Guillaume Gomez 100713ef08
Rollup merge of #116560 - ouz-a:efficient_ids, r=oli-obk
In smir use `FxIndexMap` to store indexed ids

Previously we used `vec` for storing indexed types, which is fine for small cases but will lead to huge performance issues when we use `smir` for real world cases.

Addresses https://github.com/rust-lang/project-stable-mir/issues/35

r? ``@oli-obk``
2023-10-10 18:44:46 +02:00
Oğuz Ağcayazı 0bcb058fb1 add new wrapper for FxIndexMap 2023-10-10 13:18:31 +03:00
Oğuz Ağcayazı 77df2cd9a5 spans are now indexmapped 2023-10-09 13:03:58 +03:00
Oğuz Ağcayazı 5f079dd2ff alloc id is indexmapped 2023-10-09 12:58:41 +03:00
Oğuz Ağcayazı 0f27c1b5b5 defids are indexmapped 2023-10-09 12:56:14 +03:00
Oğuz Ağcayazı 4ff6e87a8c return crates instead of a crate 2023-10-09 10:33:23 +03:00
Michael Howell c6e6ecb1af rustdoc: remove rust logo from non-Rust crates 2023-10-08 20:17:53 -07:00
Nicholas Nethercote e7dabc9f87 Remove unnecessary `pub`. 2023-10-06 14:59:11 +11:00
Nicholas Nethercote 093b435b78 Remove unneeded features. 2023-10-06 14:58:01 +11:00
Nicholas Nethercote 4b51a3eb52 Remove unneeded dependency.
Also sort them.
2023-10-06 14:57:25 +11:00
Oğuz Ağcayazı a49138e46e impl stable for kinds 2023-10-05 11:15:34 +03:00
ouz-a a79567b01c add span to statements 2023-10-05 11:15:34 +03:00
ouz-a 999a354a81 add span to terminator 2023-09-30 16:52:10 +03:00
ouz-a 9130484db9 create localdecl and add span to it 2023-09-30 16:40:15 +03:00
ouz-a 34f10e2ab9 remove unimplemented 2023-09-28 19:52:41 +03:00
ouz-a bb17fe8bf5 add real folder to Region 2023-09-28 12:32:15 +03:00
ouz-a da2f897e59 remove un-needed variants 2023-09-28 11:43:21 +03:00
ouz-a 2069e8c218 fix imports 2023-09-28 11:36:53 +03:00
ouz-a 5dc2214884 add stable for RegionKind 2023-09-28 11:19:51 +03:00
ouz-a e49aa04000 add RegionDef 2023-09-28 11:19:51 +03:00
Oli Scherer 411e431c70 Rebase fallout 2023-09-25 15:02:10 +00:00
Oli Scherer a38e98371b Split out the stable part of smir into its own crate to prevent accidental usage of forever unstable things 2023-09-25 14:38:27 +00:00
Oli Scherer 19f1d782d5 Move `Opaque` to `stable_mir` 2023-09-25 14:38:27 +00:00
Oli Scherer 33998a9751 Fix test by adding a stable way to get an opaque DefKind 2023-09-25 14:38:27 +00:00
Oli Scherer 55b6f64902 Eliminate escape hatch 2023-09-25 14:38:26 +00:00
Oli Scherer e02a139a23 Eliminate `with_tables` helper 2023-09-25 14:38:26 +00:00
Camille GILLOT 26cb34cd18 Remove span from BrAnon. 2023-09-24 09:46:55 +00:00
Camille GILLOT 44ac8dcc71 Remove GeneratorWitness and rename GeneratorWitnessMIR. 2023-09-23 13:47:30 +00:00
Guillaume Gomez 208f6ed95c
Rollup merge of #115972 - RalfJung:const-consistency, r=oli-obk
rename mir::Constant -> mir::ConstOperand, mir::ConstKind -> mir::Const

Also, be more consistent with the `to/eval_bits` methods... we had some that take a type and some that take a size, and then sometimes the one that takes a type is called `bits_for_ty`.

Turns out that `ty::Const`/`mir::ConstKind` carry their type with them, so we don't need to even pass the type to those `eval_bits` functions at all.

However this is not properly consistent yet: in `ty` we have most of the methods on `ty::Const`, but in `mir` we have them on `mir::ConstKind`. And indeed those two types are the ones that correspond to each other. So `mir::ConstantKind` should actually be renamed to `mir::Const`. But what to do with `mir::Constant`? It carries around a span, that's really more like a constant operand that appears as a MIR operand... it's more suited for `syntax.rs` than `consts.rs`, but the bigger question is, which name should it get if we want to align the `mir` and `ty` types? `ConstOperand`? `ConstOp`? `Literal`? It's not a literal but it has a field called `literal` so it would at least be consistently wrong-ish...

``@oli-obk`` any ideas?
2023-09-21 13:25:39 +02:00
Ralf Jung c94410c145 rename mir::Constant -> mir::ConstOperand, mir::ConstKind -> mir::Const 2023-09-21 08:12:30 +02:00
Ralf Jung ea22adbabd adjust constValue::Slice to work for arbitrary slice types 2023-09-19 20:17:43 +02:00
Ralf Jung 5a0a1ff0cd move ConstValue into mir
this way we have mir::ConstValue and ty::ValTree as reasonably parallel
2023-09-19 11:11:02 +02:00
Matthias Krüger 4f90a52ae6
Rollup merge of #115772 - ouz-a:smir_span2, r=oli-obk
Improve Span in smir

Addressing https://github.com/rust-lang/project-stable-mir/issues/31

r? ``@oli-obk``
2023-09-14 19:12:31 +02:00
Ralf Jung 430c386821 make it more clear which functions create fresh AllocId 2023-09-14 07:27:31 +02:00
Ralf Jung 0f8908da27 cleanup op_to_const a bit; rename ConstValue::ByRef → Indirect 2023-09-14 07:27:30 +02:00
Ralf Jung 551f481ffb use AllocId instead of Allocation in ConstValue::ByRef 2023-09-14 07:26:24 +02:00
ouz-a fa57a48cf5 span is index 2023-09-14 00:32:21 +03:00
bors 1fe747c160 Auto merge of #115793 - spastorino:smir-explicit-predicates-of, r=oli-obk
Add explicit_predicates_of to SMIR

Adding `explicit_predicates_of` so we can use it from Mir formality.

r? `@oli-obk`
2023-09-13 04:51:19 +00:00
Santiago Pastorino 3678dbc382
Add explicit_predicates_of to SMIR 2023-09-12 15:12:02 -03:00
Matthias Krüger 2a087be735
Rollup merge of #115749 - oli-obk:smir_consts, r=compiler-errors
Allow loading the SMIR for constants and statics

cc https://github.com/rust-lang/project-stable-mir/issues/34

before this PR we were ICEing when trying to access the SMIR of anything other than functions
2023-09-11 21:16:23 +02:00
Matthias Krüger c943ec2fba
Rollup merge of #115730 - bjorn3:some_driver_refactors, r=compiler-errors
Some more small driver refactors

To improve clarity and simplify some code.
2023-09-11 21:16:22 +02:00
Matthias Krüger e7a347baf8
Rollup merge of #115727 - fee1-dead-contrib:effect-fallback, r=oli-obk
Implement fallback for effect param

r? `@oli-obk` or `@lcnr`

tracking issue for this ongoing work: https://github.com/rust-lang/rust/issues/110395
2023-09-11 17:03:31 +02:00
Deadbeef 9654d5ceaf add `is_host_effect` to `GenericParamDefKind::Const` and address review 2023-09-11 13:18:36 +00:00
Oli Scherer c2e790044c Allow loading the SMIR for constants and statics 2023-09-11 08:14:56 +00:00
bjorn3 2eca717a24 Remove EarlyErrorHandler argument from after_analysis callback
It is only used by miri which can create a new one using the Session.
2023-09-10 09:44:03 +00:00
ouz-a d190ebf2fc add function that returns span of an item 2023-09-09 14:17:36 +03:00
Matthias Krüger 9a901dad6f
Rollup merge of #115605 - ouz-a:smir_better_debug, r=oli-obk
Better Debug for `Ty` in smir

Similar to what I did here https://github.com/rust-lang/rust/pull/115534.

r? ``@oli-obk``
2023-09-06 19:31:51 +02:00
ouz-a cc7c5ad20b Ty Debug now prints id and kind 2023-09-06 15:02:03 +03:00
Oli Scherer 0f4ff52e00 Implement and test monomorphization 2023-09-06 08:16:04 +00:00
Oli Scherer 202fbed1a6 Allow fetching the SMIR body of FnDefs 2023-09-06 08:16:04 +00:00
Oli Scherer 98d26d9c4d Deopaquify `ParamConst` 2023-09-06 08:16:04 +00:00
Oli Scherer 627fa80bdf Add types to all constants 2023-09-06 08:16:04 +00:00
Oli Scherer a370f1baa3 Also use `Const` in `SMIR` instead of just `ConstantKind` 2023-09-06 08:16:04 +00:00
Oli Scherer b43e3b9f41 Add type folder to SMIR 2023-09-06 08:15:42 +00:00
Celina G. Val d10d8290ac Add tests and use ControlFlow 2023-09-05 09:19:56 -07:00
Celina G. Val 1a8a5d0a29 SMIR: Allow users to pick if compilation continues
Currently we stop compilation, but some users might want to keep going.
This is needed for us to test against rustc tests. Other tools, such as
Kani, also implements parts of their logic as a backend so it is
important for compilation to continue.
2023-09-05 08:54:03 -07:00
Celina G. Val 3b01f65aa5 Diferentiate between ICE and compilation error 2023-09-05 08:54:03 -07:00
Celina G. Val 2db01be584 Adjust StableMIR interface to return and not crash
Invoking StableMir::run() on a crate that has any compilation error was
crashing the entire process. Instead, return a `CompilerError` so the
user knows compilation did not succeed.

I believe ICE will also be converted to `CompilerError`.

I'm also adding a return value to the callback, because I think it will
be handy for users (at least it was for my current task of implementing
a tool to validate stable-mir). However, if people disagree,
I can remove that.
2023-09-05 08:54:03 -07:00
ouz-a 56d10a883e provide more useful info for DefId Debug 2023-09-04 19:13:43 +03:00
bors 7cc5ac267f Auto merge of #115470 - ericmarkmartin:stable-prov, r=oli-obk
add stable provenance

r? `@spastorino`

implements rust-lang/project-stable-mir#22
2023-09-03 07:38:55 +00:00
Eric Mark Martin cb7d020fb6 add stable provenance 2023-09-02 01:53:06 -04:00
Oli Scherer 85a1679df9 Create a SMIR visitor 2023-09-01 16:32:22 +00:00
Oli Scherer 92cfd209f1 Move some logic using rustc datastructures to the `rustc_smir` module 2023-08-30 08:10:28 +00:00
Oli Scherer 03b03f9fee Reuse the `ty::Const: Stable` impl 2023-08-30 08:09:41 +00:00
Oli Scherer 3a736a747d Exhaustively match on `ty::Const::kind` 2023-08-30 08:08:39 +00:00
Oli Scherer 9b8e3eb8f7 Move around constants' `Stable` impls a bit 2023-08-30 08:08:39 +00:00
Matthias Krüger a51e8308c8
Rollup merge of #115300 - spastorino:smir-tweaks, r=oli-obk
Tweaks and improvements on SMIR around generics_of and predicates_of

r? `@oli-obk`

This allows an API like the following ...

```rust
    let trait_decls = stable_mir::all_trait_decls().iter().map(|trait_def| {
        let trait_decl = stable_mir::trait_decl(trait_def);
        let generics = trait_decl.generics_of();
        let predicates = trait_decl.predicates_of().predicates;
```

I didn't like that much `trait_def.trait_decl()` which is it possible but adding a method to a def_id that loads up a whole trait definition looks backwards to me.
2023-08-29 20:49:05 +02:00
ouz-a c2fe0bf253 Create StableMir replacer for SMirCalls 2023-08-29 16:30:50 +03:00
Santiago Pastorino 5ab9616d03
Call these methods from high level stable_mir::trait_decl(trait_def) and so on 2023-08-29 08:34:34 -03:00
Santiago Pastorino 079e3732cc
Implement generics_of and predicates_of only for TraitDecl for now 2023-08-29 08:34:33 -03:00
Santiago Pastorino 0c301e9d36
Deduplicate GenericPredicates 2023-08-29 08:34:28 -03:00
Santiago Pastorino 17ffb59d39
Index def_ids directly 2023-08-29 08:34:27 -03:00
Santiago Pastorino af6299a1f7
Add stable_mir::DefId as new type wrapper 2023-08-29 08:28:48 -03:00
Santiago Pastorino e9710f1faa
Context::generics _of/predicates_of should receive stable_mir::DefId 2023-08-28 14:55:42 -03:00
Santiago Pastorino 7a653feffb
Remove stable_mir::generics_of/predicates_of those shouldn't be exposed 2023-08-28 14:55:08 -03:00
bors c5035271ac Auto merge of #115211 - spastorino:add-missing-smir-generics-of, r=compiler-errors
Add missing high-level stable_mir::generics_of fn

We forgot to add this function in https://github.com/rust-lang/rust/pull/115092, as we have done on https://github.com/rust-lang/rust/pull/115084 and other high level APIs.

At some point I think we should re-organize the structure of the code but this is what we have for now.

r? `@compiler-errors`
Would have assigned `@oli-obk` but he is still on vacations
2023-08-26 00:32:16 +00:00
bors 734a0d0aa0 Auto merge of #115202 - ouz-a:more_smir, r=spastorino
Add stable for Constant in smir

Previously https://github.com/rust-lang/rust/pull/114587 we covered much of the groundwork needed to cover Const in smir, so there is no reason keep `Constant` as String.

r? `@spastorino`
2023-08-25 20:35:39 +00:00
Santiago Pastorino 3dd1c6bc98
Add missing high-level stable_mir::generics_of fn 2023-08-25 09:42:57 -03:00
bors 738df13e8a Auto merge of #115093 - Zalathar:smir-coverage, r=cjgillot,oli-obk
Treat `StatementKind::Coverage` as completely opaque for SMIR purposes

Coverage statements in MIR are heavily tied to internal details of the coverage implementation that are likely to change, and are unlikely to be useful to third-party tools for the foreseeable future.
2023-08-25 11:43:05 +00:00
bors b60f7b51a2 Auto merge of #115045 - RalfJung:unwind-terminate-reason, r=davidtwco
when terminating during unwinding, show the reason why

With this, the output on double-panic becomes something like that:
```
thread 'main' panicked at src/tools/miri/tests/fail/panic/double_panic.rs:15:5:
first
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at src/tools/miri/tests/fail/panic/double_panic.rs:10:9:
second
stack backtrace:
   0:           0xbe273a - std::backtrace_rs::backtrace::miri::trace_unsynchronized::<&mut [closure@std::sys_common::backtrace::_print_fmt::{closure#1}]>
                               at /home/r/src/rust/rustc.3/library/std/src/../../backtrace/src/backtrace/miri.rs:99:5
   1:           0xbe22e6 - std::backtrace_rs::backtrace::miri::trace::<&mut [closure@std::sys_common::backtrace::_print_fmt::{closure#1}]>
                               at /home/r/src/rust/rustc.3/library/std/src/../../backtrace/src/backtrace/miri.rs:62:14
   2:           0xbe1086 - std::backtrace_rs::backtrace::trace_unsynchronized::<[closure@std::sys_common::backtrace::_print_fmt::{closure#1}]>
                               at /home/r/src/rust/rustc.3/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   3:           0xba3afd - std::sys_common::backtrace::_print_fmt
                               at /home/r/src/rust/rustc.3/library/std/src/sys_common/backtrace.rs:67:5
   4:           0xba2471 - <std::sys_common::backtrace::_print::DisplayBacktrace as std::fmt::Display>::fmt
                               at /home/r/src/rust/rustc.3/library/std/src/sys_common/backtrace.rs:44:22
   5:           0xbcf754 - core::fmt::rt::Argument::<'_>::fmt
                               at /home/r/src/rust/rustc.3/library/core/src/fmt/rt.rs:138:9
   6:           0x9b8f81 - std::fmt::write
                               at /home/r/src/rust/rustc.3/library/core/src/fmt/mod.rs:1094:17
   7:           0x21391d - <std::sys::unix::stdio::Stderr as std::io::Write>::write_fmt
                               at /home/r/src/rust/rustc.3/library/std/src/io/mod.rs:1714:15
   8:           0xba37b1 - std::sys_common::backtrace::_print
                               at /home/r/src/rust/rustc.3/library/std/src/sys_common/backtrace.rs:47:5
   9:           0xba365b - std::sys_common::backtrace::print
                               at /home/r/src/rust/rustc.3/library/std/src/sys_common/backtrace.rs:34:9
  10:           0x143c67 - std::panic_hook_with_disk_dump::{closure#1}
                               at /home/r/src/rust/rustc.3/library/std/src/panicking.rs:278:22
  11:           0x144187 - std::panic_hook_with_disk_dump
                               at /home/r/src/rust/rustc.3/library/std/src/panicking.rs:312:9
  12:           0x143659 - std::panicking::default_hook
                               at /home/r/src/rust/rustc.3/library/std/src/panicking.rs:239:5
  13:           0x1482a7 - std::panicking::rust_panic_with_hook
                               at /home/r/src/rust/rustc.3/library/std/src/panicking.rs:729:13
  14:           0x1475d5 - std::rt::begin_panic::<&str>::{closure#0}
                               at /home/r/src/rust/rustc.3/library/std/src/panicking.rs:650:9
  15:           0xba496a - std::sys_common::backtrace::__rust_end_short_backtrace::<[closure@std::rt::begin_panic<&str>::{closure#0}], !>
                               at /home/r/src/rust/rustc.3/library/std/src/sys_common/backtrace.rs:170:18
  16:           0x147599 - std::rt::begin_panic::<&str>
                               at /home/r/src/rust/rustc.3/library/std/src/panicking.rs:649:12
  17:            0x31916 - <Foo as std::ops::Drop>::drop
                               at src/tools/miri/tests/fail/panic/double_panic.rs:10:9
  18:           0x1a2b5e - std::ptr::drop_in_place::<Foo> - shim(Some(Foo))
                               at /home/r/src/rust/rustc.3/library/core/src/ptr/mod.rs:497:1
  19:            0x202bf - main
                               at src/tools/miri/tests/fail/panic/double_panic.rs:16:1
  20:            0xcc6a8 - <fn() as std::ops::FnOnce<()>>::call_once - shim(fn())
                               at /home/r/src/rust/rustc.3/library/core/src/ops/function.rs:250:5
  21:           0xba47d9 - std::sys_common::backtrace::__rust_begin_short_backtrace::<fn(), ()>
                               at /home/r/src/rust/rustc.3/library/std/src/sys_common/backtrace.rs:154:18
  22:           0x141a6a - std::rt::lang_start::<()>::{closure#0}
                               at /home/r/src/rust/rustc.3/library/std/src/rt.rs:166:18
  23:            0xcca18 - std::ops::function::impls::<impl std::ops::FnOnce<()> for &dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe>::call_once
                               at /home/r/src/rust/rustc.3/library/core/src/ops/function.rs:284:13
  24:           0x146469 - std::panicking::try::do_call::<&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe, i32>
                               at /home/r/src/rust/rustc.3/library/std/src/panicking.rs:524:40
  25:           0x145e09 - std::panicking::try::<i32, &dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe>
                               at /home/r/src/rust/rustc.3/library/std/src/panicking.rs:488:19
  26:            0x7b0ac - std::panic::catch_unwind::<&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe, i32>
                               at /home/r/src/rust/rustc.3/library/std/src/panic.rs:142:14
  27:           0x14189b - std::rt::lang_start_internal::{closure#2}
                               at /home/r/src/rust/rustc.3/library/std/src/rt.rs:148:48
  28:           0x146481 - std::panicking::try::do_call::<[closure@std::rt::lang_start_internal::{closure#2}], isize>
                               at /home/r/src/rust/rustc.3/library/std/src/panicking.rs:524:40
  29:           0x145e2c - std::panicking::try::<isize, [closure@std::rt::lang_start_internal::{closure#2}]>
                               at /home/r/src/rust/rustc.3/library/std/src/panicking.rs:488:19
  30:            0x7b0d5 - std::panic::catch_unwind::<[closure@std::rt::lang_start_internal::{closure#2}], isize>
                               at /home/r/src/rust/rustc.3/library/std/src/panic.rs:142:14
  31:           0x1418b0 - std::rt::lang_start_internal
                               at /home/r/src/rust/rustc.3/library/std/src/rt.rs:148:20
  32:           0x141a97 - std::rt::lang_start::<()>
                               at /home/r/src/rust/rustc.3/library/std/src/rt.rs:165:17
thread 'main' panicked at /home/r/src/rust/rustc.3/library/core/src/panicking.rs:126:5:
panic in a destructor during cleanup
stack backtrace:
   0:           0xe9f6d7 - std::backtrace_rs::backtrace::miri::trace_unsynchronized::<&mut [closure@std::sys_common::backtrace::_print_fmt::{closure#1}]>
                               at /home/r/src/rust/rustc.3/library/std/src/../../backtrace/src/backtrace/miri.rs:99:5
   1:           0xe9f27d - std::backtrace_rs::backtrace::miri::trace::<&mut [closure@std::sys_common::backtrace::_print_fmt::{closure#1}]>
                               at /home/r/src/rust/rustc.3/library/std/src/../../backtrace/src/backtrace/miri.rs:62:14
   2:           0xe9e016 - std::backtrace_rs::backtrace::trace_unsynchronized::<[closure@std::sys_common::backtrace::_print_fmt::{closure#1}]>
                               at /home/r/src/rust/rustc.3/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   3:           0xba3afd - std::sys_common::backtrace::_print_fmt
                               at /home/r/src/rust/rustc.3/library/std/src/sys_common/backtrace.rs:67:5
   4:           0xba2471 - <std::sys_common::backtrace::_print::DisplayBacktrace as std::fmt::Display>::fmt
                               at /home/r/src/rust/rustc.3/library/std/src/sys_common/backtrace.rs:44:22
   5:           0xbcf754 - core::fmt::rt::Argument::<'_>::fmt
                               at /home/r/src/rust/rustc.3/library/core/src/fmt/rt.rs:138:9
   6:           0x9b8f81 - std::fmt::write
                               at /home/r/src/rust/rustc.3/library/core/src/fmt/mod.rs:1094:17
   7:           0x4d0895 - <std::sys::unix::stdio::Stderr as std::io::Write>::write_fmt
                               at /home/r/src/rust/rustc.3/library/std/src/io/mod.rs:1714:15
   8:           0xba37b1 - std::sys_common::backtrace::_print
                               at /home/r/src/rust/rustc.3/library/std/src/sys_common/backtrace.rs:47:5
   9:           0xba365b - std::sys_common::backtrace::print
                               at /home/r/src/rust/rustc.3/library/std/src/sys_common/backtrace.rs:34:9
  10:           0x400bd4 - std::panic_hook_with_disk_dump::{closure#1}
                               at /home/r/src/rust/rustc.3/library/std/src/panicking.rs:278:22
  11:           0x144187 - std::panic_hook_with_disk_dump
                               at /home/r/src/rust/rustc.3/library/std/src/panicking.rs:312:9
  12:           0x143659 - std::panicking::default_hook
                               at /home/r/src/rust/rustc.3/library/std/src/panicking.rs:239:5
  13:           0x1482a7 - std::panicking::rust_panic_with_hook
                               at /home/r/src/rust/rustc.3/library/std/src/panicking.rs:729:13
  14:           0x40403b - std::panicking::begin_panic_handler::{closure#0}
                               at /home/r/src/rust/rustc.3/library/std/src/panicking.rs:619:13
  15:           0xe618b3 - std::sys_common::backtrace::__rust_end_short_backtrace::<[closure@std::panicking::begin_panic_handler::{closure#0}], !>
                               at /home/r/src/rust/rustc.3/library/std/src/sys_common/backtrace.rs:170:18
  16:           0x403fc8 - std::panicking::begin_panic_handler
                               at /home/r/src/rust/rustc.3/library/std/src/panicking.rs:617:5
  17:           0xee23e9 - core::panicking::panic_nounwind_fmt
                               at /home/r/src/rust/rustc.3/library/core/src/panicking.rs:96:14
  18:           0xee29e6 - core::panicking::panic_nounwind
                               at /home/r/src/rust/rustc.3/library/core/src/panicking.rs:126:5
  19:           0xee365e - core::panicking::panic_in_cleanup
                               at /home/r/src/rust/rustc.3/library/core/src/panicking.rs:206:5
  20:            0x2028a - main
                               at src/tools/miri/tests/fail/panic/double_panic.rs:13:1
  21:           0x3895ee - <fn() as std::ops::FnOnce<()>>::call_once - shim(fn())
                               at /home/r/src/rust/rustc.3/library/core/src/ops/function.rs:250:5
  22:           0xe61725 - std::sys_common::backtrace::__rust_begin_short_backtrace::<fn(), ()>
                               at /home/r/src/rust/rustc.3/library/std/src/sys_common/backtrace.rs:154:18
  23:           0x3fe9aa - std::rt::lang_start::<()>::{closure#0}
                               at /home/r/src/rust/rustc.3/library/std/src/rt.rs:166:18
  24:           0x389962 - std::ops::function::impls::<impl std::ops::FnOnce<()> for &dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe>::call_once
                               at /home/r/src/rust/rustc.3/library/core/src/ops/function.rs:284:13
  25:           0x4033b9 - std::panicking::try::do_call::<&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe, i32>
                               at /home/r/src/rust/rustc.3/library/std/src/panicking.rs:524:40
  26:           0x402d58 - std::panicking::try::<i32, &dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe>
                               at /home/r/src/rust/rustc.3/library/std/src/panicking.rs:488:19
  27:           0x337ff7 - std::panic::catch_unwind::<&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe, i32>
                               at /home/r/src/rust/rustc.3/library/std/src/panic.rs:142:14
  28:           0x3fe7e7 - std::rt::lang_start_internal::{closure#2}
                               at /home/r/src/rust/rustc.3/library/std/src/rt.rs:148:48
  29:           0x4033d6 - std::panicking::try::do_call::<[closure@std::rt::lang_start_internal::{closure#2}], isize>
                               at /home/r/src/rust/rustc.3/library/std/src/panicking.rs:524:40
  30:           0x402d7f - std::panicking::try::<isize, [closure@std::rt::lang_start_internal::{closure#2}]>
                               at /home/r/src/rust/rustc.3/library/std/src/panicking.rs:488:19
  31:           0x338028 - std::panic::catch_unwind::<[closure@std::rt::lang_start_internal::{closure#2}], isize>
                               at /home/r/src/rust/rustc.3/library/std/src/panic.rs:142:14
  32:           0x1418b0 - std::rt::lang_start_internal
                               at /home/r/src/rust/rustc.3/library/std/src/rt.rs:148:20
  33:           0x3fe9dc - std::rt::lang_start::<()>
                               at /home/r/src/rust/rustc.3/library/std/src/rt.rs:165:17
thread caused non-unwinding panic. aborting.
```
If we also land https://github.com/rust-lang/rust/pull/115020, the 2nd backtrace disappears, hopefully making the "panic in a destructor during cleanup" easier to see.

Fixes https://github.com/rust-lang/rust/issues/114954.
2023-08-25 08:47:18 +00:00
ouz-a cab9fc99c9 Add stable for Constant in smir 2023-08-25 09:25:57 +03:00
Ralf Jung 4c53783f3c when terminating during unwinding, show the reason why 2023-08-24 13:28:26 +02:00
Eric Mark Martin 107cb5c904
predicates of 2023-08-23 11:47:13 -03:00
Eric Mark Martin 735e9c0c51
stable types for predicates 2023-08-23 10:43:10 -03:00
ouz-a 015b5cb306 add generics_of to smir 2023-08-22 21:47:46 +03:00
Zalathar 1fac8a0eab Treat `StatementKind::Coverage` as completely opaque for SMIR purposes
Coverage statements in MIR are heavily tied to internal details of the coverage
implementation that are likely to change, and are unlikely to be useful to
third-party tools for the foreseeable future.
2023-08-22 20:37:19 +10:00
Ralf Jung 44cc3105b1 stable_mir: docs clarification 2023-08-21 13:55:17 +02:00
Ralf Jung 818ec8e23a give some unwind-related terminators a more clear name 2023-08-20 15:52:38 +02:00
Santiago Pastorino 66573b5781
Add missing Clone/Debug impls to SMIR Trait related tys 2023-08-16 13:10:52 -03:00
Matthias Krüger b54fe76494
Rollup merge of #114859 - spastorino:add-smir-cx-trait-fns, r=compiler-errors
Add trait related queries to SMIR's rustc_internal

r? `@oli-obk`
2023-08-16 08:43:52 +02:00
bors 656ee47db3 Auto merge of #114689 - m-ou-se:stabilize-thread-local-cell-methods, r=thomcc
Stabilize thread local cell methods.

Closes #92122.
2023-08-16 02:37:29 +00:00
Santiago Pastorino 826471e93b
Add trait related queries to SMIR's rustc_internal 2023-08-15 13:37:47 -03:00
Matthias Krüger 106d686e98
Rollup merge of #114745 - ouz-a:smir_const, r=spastorino
Make Const more useful in smir

Since https://github.com/rust-lang/rust/pull/114587 is merged, we can make use of what we built and make Const more useful by making it not `Opaque`

r? `@spastorino`
2023-08-14 21:57:51 +02:00
Matthias Krüger 1d0792bd80
Rollup merge of #114703 - ouz-a:smir_allocation, r=oli-obk
Cover ParamConst in smir

Others variants won't be useful for a while or ever(?), but we might need this one.

r? ````@oli-obk````
2023-08-12 12:06:37 +02:00
ouz-a d5120d4a46 Make Const more useful in smir 2023-08-11 23:43:58 +03:00
ouz-a c80281a861 cover ParamConst 2023-08-10 21:04:03 +03:00
Santiago Pastorino 5f0e662523
Add impl trait declarations to SMIR 2023-08-10 14:17:50 -03:00
Santiago Pastorino 8b29ad7215
Fix copy & paste doc error 2023-08-10 14:17:08 -03:00
Mara Bos dc3cbc1e56 Stabilize thread local cell methods. 2023-08-10 17:33:40 +02:00
Matthias Krüger bbc1109b79
Rollup merge of #114587 - ouz-a:smir_allocation, r=oli-obk
Convert Const to Allocation in smir

Continuation of previous pr https://github.com/rust-lang/rust/pull/114466

cc https://github.com/rust-lang/project-stable-mir/issues/15

r? `@oli-obk`
2023-08-09 23:00:00 +02:00
ouz-a 8f1ea576b7 only allocate bytes within AllocRange 2023-08-09 21:05:03 +03:00
ouz-a c41339a52f Convert Const to Allocation in smir 2023-08-09 15:00:00 +03:00
Seth Pellegrino d88ab223c5 fix: add RiscvInterrupt* cconv to smir
These new interrupt calling conventions are not themselves stabilized,
but there are other unstable calling conventions present in the SMIR
mapping (e.g. AVR interrupts) and the mapping appears to be "complete"
so far, with no obvious way to represent unstable conventions separately
from the stable ones.
2023-08-08 18:09:56 -07:00
Santiago Pastorino 6e4d7bd90e
Add TraitDef::trait_decl method 2023-08-07 10:24:12 -03:00
Santiago Pastorino 0e69a8ad20
Add all_trait_decls to SMIR 2023-08-07 10:24:11 -03:00
Santiago Pastorino 496faa857c
Convert trait declaration to SMIR 2023-08-07 10:24:08 -03:00
Santiago Pastorino 4199a3c13a
Convert unsafety using the stable method and reuse mir::Safety 2023-08-07 10:23:20 -03:00
ouz-a b9a539e0a3 Add alocation to smir 2023-08-06 15:06:04 +03:00
ouz-a 2ff62fdfcc clean up, use opaque types 2023-08-01 17:48:20 +03:00
ouz-a 206bfc47ea Cover statements for stable_mir 2023-08-01 12:57:13 +03:00
Matthias Krüger 35ba616850
Rollup merge of #114165 - ouz-a:smir1, r=spastorino
Add missing rvalues to smir

Added few missing rvalues to smir, not entirely confident about changes to `Aggregate`

cc https://github.com/rust-lang/project-stable-mir/issues/13

r? `@oli-obk`
2023-07-31 22:51:14 +02:00
ouz-a 2a3da87c0e add missing rvalues to smir 2023-07-31 22:48:55 +03:00
Matthias Krüger 3ce90b1649 inline format!() args up to and including rustc_codegen_llvm 2023-07-30 14:22:50 +02:00
Matthias Krüger 17e4f80257
Rollup merge of #114082 - ericmarkmartin:smir-nullary-op, r=spastorino
add stable NullaryOp

r? `@spastorino`
2023-07-27 06:04:14 +02:00
Santiago Pastorino 7af1697138
Add Bound ty to SMIR 2023-07-26 09:26:39 -03:00
Santiago Pastorino 648cf070eb
Add Param ty to SMIR 2023-07-26 09:26:39 -03:00
Eric Mark Martin 933fc180bd add stable NullaryOp 2023-07-26 00:22:38 -04:00
Eric Mark Martin 0a0ce4905d factor out more stable impls 2023-07-25 00:49:49 -04:00
Eric Mark Martin badb617eb5 Dynamic for smir 2023-07-24 00:17:45 -04:00
Eric Mark Martin c2158a44e1 generic smir stable impl for Binder 2023-07-24 00:06:29 -04:00
Eric Mark Martin aa33e8945c add Alias for smir 2023-07-22 15:38:41 -04:00
Santiago Pastorino 634db101ec
Implement Stable for ty::Ty 2023-07-21 11:56:49 -03:00
Santiago Pastorino 17b8977f9b
Add FnPtr ty to SMIR 2023-07-20 23:18:40 -03:00
Santiago Pastorino 93bcc2ef98
Implement Stable for ty::GenericArgs 2023-07-20 23:18:33 -03:00
Santiago Pastorino cbabd00c12
Add tables to Stable::stable 2023-07-20 22:20:53 -03:00
Santiago Pastorino c5819b2b9b
Remove FIXMEs a lot of things need fixes 2023-07-19 11:05:21 -03:00
Santiago Pastorino db35f1de2f
Extract generic_args function 2023-07-19 11:05:14 -03:00
Santiago Pastorino ed32347689
Add Generator to SMIR 2023-07-19 11:02:38 -03:00
Santiago Pastorino c5c38cdee8
Add Closure ty to SMIR 2023-07-19 11:02:37 -03:00
Santiago Pastorino e5c0b96e24
Add FnDef ty to SMIR 2023-07-19 11:02:37 -03:00
Santiago Pastorino 68077d5827
Rename SMIR AdtSubsts to GenericArgs 2023-07-19 11:02:34 -03:00
Santiago Pastorino caa01adbd0
Add Never to SMIR 2023-07-18 13:58:41 -03:00
Santiago Pastorino 9b32319205
Add Foreign to SMIR 2023-07-18 13:58:41 -03:00
Eric Mark Martin c8ee46be75 conversions to smir RawPtr and Ref 2023-07-17 21:08:49 -04:00
Eric Mark Martin 08e89acd2e add RawPtr 2023-07-17 20:47:27 -04:00
Eric Mark Martin 285920ea2d move const definition 2023-07-17 20:47:27 -04:00
bors bacf5bcbc7 Auto merge of #112982 - lukas-code:bootstrap-alias-default-crates, r=albertlarsan68
bootstrap: update defaults for `compiler` and `library` aliases

* `x doc compiler` now documents all of compiler, not just `rustc_driver`.
* `x doc` with compiler docs enabled now includes `rustc-main` and `rustc_smir`. `rustc_codegen_llvm` is only included if the LLVM backend is enabled, which is the default.
* `x doc library` now excludes `sysroot`.
* `x check compiler` and `x check library` now properly check tests/benches/examples of all compiler or library crates, respectively. Note that `x check compiler` will check the library artifacts, but not tests.

fixes the fallout from https://github.com/rust-lang/rust/pull/111955, cc `@jyn514`
2023-07-14 12:09:27 +00:00
Lukas Markeffsky 9d6bfc281d fix docs for `rustc_smir` 2023-07-14 09:41:42 +00:00
Eric Mark Martin fd5553ffea add str, slice, and array to smir types 2023-07-13 20:59:44 -04:00
Matthias Krüger 017112f834
Rollup merge of #113629 - spastorino:smir-types-3, r=oli-obk
Add Adt to SMIR

r? ````@oli-obk````
2023-07-13 22:33:25 +02:00
Santiago Pastorino c80a0f3178
Add Adt to SMIR 2023-07-13 12:00:46 -03:00
Matthias Krüger 66233fbb32
Rollup merge of #113553 - spastorino:smir-types-2, r=oli-obk
Make Placeholder, GeneratorWitness*, Infer and Error unreachable on SMIR rustc_ty_to_ty

Let's remove these todos to not confuse ``@ericmarkmartin`` if they pick some conversion up.

r? ``@oli-obk``
2023-07-13 12:19:22 +02:00
Santiago Pastorino 5cf570f325
DefIds are not only about CrateItem 2023-07-12 16:26:05 -03:00
Santiago Pastorino 715cd99450
Make Placeholder, GeneratorWitness*, Infer and Error unreachable on SMIR rustc_ty_to_ty 2023-07-11 12:59:38 -03:00
Celina G. Val b9f378b19b Implement a few more rvalue translation to smir
- Introduce an Opaque type for adding information that is still
   internal to the compiler.
2023-07-10 11:47:48 -07:00
Celina G. Val 697563289d Implement Stable for AssertMessage 2023-07-10 10:06:18 -07:00
Celina G. Val 44d0fce150 Fix standalone build
Add extern declarations and optional dependencies to fix build done
directly via `cargo build`.
2023-07-10 10:06:18 -07:00
Matthias Krüger 39f558f8cf
Rollup merge of #113412 - spastorino:smir-types-1, r=oli-obk
Add basic types to SMIR

Still incomplete but I think this can be merged and we can keep iterating over it.

r? ``@oli-obk``
2023-07-08 15:49:47 +02:00
Santiago Pastorino 9ca51b92d4
Add Float ty to SMIR 2023-07-07 13:47:55 -03:00
Santiago Pastorino 42eccffce3
Add Uint ty to SMIR 2023-07-07 13:47:33 -03:00
Santiago Pastorino 458ead41d6
Add Int ty to SMIR 2023-07-07 13:47:09 -03:00
Santiago Pastorino 73e816e37c
Add Char ty to SMIR 2023-07-07 13:46:40 -03:00
Santiago Pastorino 61adcaf87b
Add rustc_ty_to_ty basic tests 2023-07-07 13:45:54 -03:00
Santiago Pastorino 284df9fc34
Wrap SMIR bool and tuple into a Rigid variant 2023-07-06 15:34:42 -03:00
yukang 361df86a8d Use scoped-tls for SMIR to map between TyCtxt and SMIR datastructures 2023-07-02 07:48:41 +08:00
Michael Goulet 31d1fbf8d2
Rollup merge of #112232 - fee1-dead-contrib:match-eq-const-msg, r=b-naber
Better error for non const `PartialEq` call generated by `match`

Resolves #90237
2023-06-19 17:53:33 -07:00
Scott McMurray 39788e07ba Promote unchecked_add/sub/mul/shl/shr to mir::BinOp 2023-06-19 01:47:03 -07:00
Deadbeef 89c24af133 Better error for non const `PartialEq` call generated by `match` 2023-06-18 05:24:38 +00:00
Celina G. Val af4040a5c1 Use a Stable trait to translate mir -> smir
I was wondering if this would be a bit cleaner.
2023-06-13 15:17:01 -07:00
Santiago Pastorino 313143b6a3
Add Terminator::InlineAsm conversion from MIR to SMIR 2023-06-08 16:53:41 -03:00
Matthias Krüger 1788d49789
Rollup merge of #111250 - spastorino:smir-terminator-2, r=oli-obk
Add Terminator conversion from MIR to SMIR, part #2

r? `@oli-obk`
2023-06-06 22:00:18 +02:00
Camille GILLOT 844c1cc5fe Remove DesugaringKind::Replace. 2023-05-25 17:40:46 +00:00
Santiago Pastorino 5749bd08e8
Add unreachable cases to Terminator 2023-05-11 14:44:53 +02:00
Oli Scherer 5c6e2342f6 Encode types in SMIR 2023-05-08 14:23:19 +00:00
Oli Scherer 7f74ae57e8 Create a trait to abstract over the smir API 2023-05-08 14:23:04 +00:00
Santiago Pastorino 698acc645e
Add GeneratorDrop terminator to SMIR 2023-05-05 10:34:55 -03:00
Santiago Pastorino 4b85bea4ae
Add Assert terminator to SMIR 2023-05-05 10:34:52 -03:00
Santiago Pastorino 7dd59fceef
Add Drop terminator to SMIR 2023-05-03 18:38:15 -03:00
Santiago Pastorino 2f503345b4
Add Call terminator to SMIR 2023-04-20 12:00:41 -03:00
Oli Scherer e404e77c0b Add a stable MIR way to get the main function 2023-04-14 07:28:56 +00:00
Gary Guo bf6b84b10a Fix new usage of old api 2023-04-06 09:34:16 +01:00
Oli Scherer 480e042097 Add Debug and Clone derives for stable mir datastructures 2023-03-16 16:17:25 +00:00
Oli Scherer 942cac1b8d Implement a minimal subset of MIR statements and terminators for smir 2023-03-16 16:06:12 +00:00
Oli Scherer 6fe982283d Remove `DefId` from `CrateItem` in favor of a lookup table 2023-03-16 14:53:57 +00:00
Celina G. Val 5eaeb71b9f Change item collection to be on demand 2023-03-07 12:47:25 -08:00
Celina G. Val b66db7e4e0 Create new rustc_smir struct to map future crates
+ Add some information to the README.md
2023-03-06 21:57:46 -08:00
Celina G. Val 40185dba54 Delete old re-exports from rustc_smir
This approach didn't seem to work well.
2023-03-03 16:56:07 -08:00
Camille GILLOT ffe20d61d6 Only keep one version of ImplicitSelfKind. 2022-09-13 19:18:23 +02:00
5225225 09ea9f0a87 Add diagnostic translation lints to crates that don't emit them 2022-08-18 19:29:02 +01:00
Oli Scherer 7cba9ed4f7 Rustfmt 2022-06-02 10:29:00 +00:00
Oli Scherer 0324ac8ae0 List all crates used in crate source in Cargo.toml 2022-06-02 10:15:07 +00:00
Oli Scherer bec75389a3 Add 'compiler/rustc_smir/' from commit '9abcb5c7b574cf316eb23d3f469187bb86ba3019'
git-subtree-dir: compiler/rustc_smir
git-subtree-mainline: fb1976011e
git-subtree-split: 9abcb5c7b5
2022-06-02 10:07:25 +00:00