Skip to content

explain the MIR const vs TY const situation #1793

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Sep 18, 2023

Conversation

RalfJung
Copy link
Member

No description provided.

src/mir/index.md Outdated
@@ -255,7 +255,66 @@ but [you can read about those below](#promoted)).

## Representing constants

*to be written*
When code has reached the MIR stage, constants can generally come in two forms: *MIR constants* ([`mir::Constant`]) and *type system constants* ([`ty::Const`]).
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oli-obk this makes me wonder if we should rename mir::Constant to mir::Const to match ty::Const...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea 😆 I wanted this forever, but never did it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can make a PR, but let's land rust-lang/rust#115865 first or this will be a hell of a conflict.^^

`"string literals"` and `b"byte string literals"`) has an optimized variant that
avoids the full overhead of the in-memory representation.

### ValTrees
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is arguably a bit misplaced in the MIR section, but I didn't find a "type system" section. previously it was in the const-eval section and that seems worse.

@tshepang tshepang merged commit 02a966c into rust-lang:master Sep 18, 2023
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Sep 26, 2023
Update books

## rust-embedded/book

1 commits in 99ad2847b865e96d8ae7b333d3ee96963557e621..eac173690b8cc99094e1d88bd49dd61127fbd285
2023-09-12 07:34:44 UTC to 2023-09-12 07:34:44 UTC

- USB connector-type correction (rust-embedded/book#360)

## rust-lang/nomicon

1 commits in e3f3af69dce71cd37a785bccb7e58449197d940c..ddfa4214487686e91b21aa29afb972c08a8f0d5b
2023-09-22 17:04:10 UTC to 2023-09-22 17:04:10 UTC

- Fill "Beneath `std`" (rust-lang/nomicon#413)

## rust-lang/reference

1 commits in ee7c676fd6e287459cb407337652412c990686c0..5262e1c3b43a2c489df8f6717683a44c7a2260fd
2023-09-18 18:28:31 UTC to 2023-09-18 18:28:31 UTC

- we reserve the right to reduce our amount of UB (rust-lang/reference#1397)

## rust-lang/rustc-dev-guide

8 commits in 08bb147..a13b7c2
2023-09-25 05:14:41 UTC to 2023-09-11 21:29:18 UTC

- Clarify all the `{AP,RP}IT{,IT}` impl trait types (rust-lang/rustc-dev-guide#1798)
- Modify build instructions for optimized build (rust-lang/rustc-dev-guide#1795)
- Remove outdated references to coverage debug code (rust-lang/rustc-dev-guide#1797)
- Add deep dive document about early/late bound parameters interacting with turbofish (rust-lang/rustc-dev-guide#1794)
- explain the MIR const vs TY const situation (rust-lang/rustc-dev-guide#1793)
- fix type name (rust-lang/rustc-dev-guide#1792)
- Clarify that `run-coverage` only runs in some of the CI jobs (rust-lang/rustc-dev-guide#1791)
- Document the `coverage-map` and `run-coverage` test suites (rust-lang/rustc-dev-guide#1790)
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Sep 26, 2023
Update books

## rust-embedded/book

1 commits in 99ad2847b865e96d8ae7b333d3ee96963557e621..eac173690b8cc99094e1d88bd49dd61127fbd285
2023-09-12 07:34:44 UTC to 2023-09-12 07:34:44 UTC

- USB connector-type correction (rust-embedded/book#360)

## rust-lang/nomicon

1 commits in e3f3af69dce71cd37a785bccb7e58449197d940c..ddfa4214487686e91b21aa29afb972c08a8f0d5b
2023-09-22 17:04:10 UTC to 2023-09-22 17:04:10 UTC

- Fill "Beneath `std`" (rust-lang/nomicon#413)

## rust-lang/reference

1 commits in ee7c676fd6e287459cb407337652412c990686c0..5262e1c3b43a2c489df8f6717683a44c7a2260fd
2023-09-18 18:28:31 UTC to 2023-09-18 18:28:31 UTC

- we reserve the right to reduce our amount of UB (rust-lang/reference#1397)

## rust-lang/rustc-dev-guide

8 commits in 08bb147..a13b7c2
2023-09-25 05:14:41 UTC to 2023-09-11 21:29:18 UTC

- Clarify all the `{AP,RP}IT{,IT}` impl trait types (rust-lang/rustc-dev-guide#1798)
- Modify build instructions for optimized build (rust-lang/rustc-dev-guide#1795)
- Remove outdated references to coverage debug code (rust-lang/rustc-dev-guide#1797)
- Add deep dive document about early/late bound parameters interacting with turbofish (rust-lang/rustc-dev-guide#1794)
- explain the MIR const vs TY const situation (rust-lang/rustc-dev-guide#1793)
- fix type name (rust-lang/rustc-dev-guide#1792)
- Clarify that `run-coverage` only runs in some of the CI jobs (rust-lang/rustc-dev-guide#1791)
- Document the `coverage-map` and `run-coverage` test suites (rust-lang/rustc-dev-guide#1790)
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Sep 26, 2023
Rollup merge of rust-lang#116153 - rustbot:docs-update, r=ehuss

Update books

## rust-embedded/book

1 commits in 99ad2847b865e96d8ae7b333d3ee96963557e621..eac173690b8cc99094e1d88bd49dd61127fbd285
2023-09-12 07:34:44 UTC to 2023-09-12 07:34:44 UTC

- USB connector-type correction (rust-embedded/book#360)

## rust-lang/nomicon

1 commits in e3f3af69dce71cd37a785bccb7e58449197d940c..ddfa4214487686e91b21aa29afb972c08a8f0d5b
2023-09-22 17:04:10 UTC to 2023-09-22 17:04:10 UTC

- Fill "Beneath `std`" (rust-lang/nomicon#413)

## rust-lang/reference

1 commits in ee7c676fd6e287459cb407337652412c990686c0..5262e1c3b43a2c489df8f6717683a44c7a2260fd
2023-09-18 18:28:31 UTC to 2023-09-18 18:28:31 UTC

- we reserve the right to reduce our amount of UB (rust-lang/reference#1397)

## rust-lang/rustc-dev-guide

8 commits in 08bb147..a13b7c2
2023-09-25 05:14:41 UTC to 2023-09-11 21:29:18 UTC

- Clarify all the `{AP,RP}IT{,IT}` impl trait types (rust-lang/rustc-dev-guide#1798)
- Modify build instructions for optimized build (rust-lang/rustc-dev-guide#1795)
- Remove outdated references to coverage debug code (rust-lang/rustc-dev-guide#1797)
- Add deep dive document about early/late bound parameters interacting with turbofish (rust-lang/rustc-dev-guide#1794)
- explain the MIR const vs TY const situation (rust-lang/rustc-dev-guide#1793)
- fix type name (rust-lang/rustc-dev-guide#1792)
- Clarify that `run-coverage` only runs in some of the CI jobs (rust-lang/rustc-dev-guide#1791)
- Document the `coverage-map` and `run-coverage` test suites (rust-lang/rustc-dev-guide#1790)
@@ -283,3 +351,5 @@ See the const-eval WG's [docs on promotion](https://github.com/rust-lang/const-e
[`ProjectionElem::Deref`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/enum.ProjectionElem.html#variant.Deref
[`Rvalue`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/enum.Rvalue.html
[`Operand`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/enum.Operand.html
[`mir::Constant`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/struct.Constant.html
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems the link is invalid right now and I can't easily find the corresponding struct type the link should point to.
@RalfJung: Can you please address it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mir::Constant has been renamed to this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! I'm going to include it in #2024.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants