Skip to content

Conversation

@bcata6
Copy link

@bcata6 bcata6 commented Apr 8, 2020

Originally suggested by @eddyb.

@rust-highfive
Copy link
Contributor

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @matthewjasper (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 8, 2020
@eddyb
Copy link
Member

eddyb commented Apr 8, 2020

cc @rust-lang/wg-mir-opt

&mut self,
place: &mir::Place<'tcx>,
rvalue: &mir::Rvalue<'tcx>,
rvalue: &mir::Op<'tcx>,
Copy link
Member

Choose a reason for hiding this comment

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

Probably the next thing to do here would be to rename rvalue variables.

rvalue: &mir::Op<'tcx>,
location: Location,
) {
debug!("visit_assign(place={:?}, rvalue={:?})", place, rvalue);
Copy link
Member

Choose a reason for hiding this comment

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

Including debug messages, heh.

}

///////////////////////////////////////////////////////////////////////////
/// Rvalues
Copy link
Contributor

Choose a reason for hiding this comment

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

This documentation should also be adjusted

@oli-obk
Copy link
Contributor

oli-obk commented Apr 8, 2020

What does Op mean here? Operation? Operand makes no sense, we already have it.

/// extract and return it. This represents the final type of the
/// rvalue and will be unified with the inferred type.
fn rvalue_user_ty(&self, rvalue: &Rvalue<'tcx>) -> Option<UserTypeAnnotationIndex> {
fn rvalue_user_ty(&self, rvalue: &Op<'tcx>) -> Option<UserTypeAnnotationIndex> {
Copy link
Contributor

Choose a reason for hiding this comment

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

also loads of function that should get renamed, not just variables

@eddyb
Copy link
Member

eddyb commented Apr 8, 2020

Operand makes no sense, we already have it.
Yeah, operands are the arguments to an operation (or "operator" I guess).

We could even rename Op::BinaryOp to Op::Binary, which reads really nice to me.

@wesleywiser
Copy link
Member

@eddyb What's the motivation for this? Rvalue is much more descriptive and easier to grep for.

///
/// There is no separate `eval_rvalue` function. Instead, the code for handling each rvalue
/// type writes its results directly into the memory specified by the place.
pub fn eval_rvalue_into_place(
Copy link
Contributor

Choose a reason for hiding this comment

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

another function name that needs a rename

@oli-obk
Copy link
Contributor

oli-obk commented Apr 8, 2020

I'm not sure about the rename, but I'm not against it either. Rvalue was some jargon I had to learn for compilers, but beyond my understanding that it means "right hand side of assignment" I never pretended to understand all the around *values properly.

Operation would be more descriptive, but quite long.

@eddyb
Copy link
Member

eddyb commented Apr 8, 2020

@eddyb What's the motivation for this? Rvalue is much more descriptive and easier to grep for.

A long time ago, we got rid of "lvalue" everywhere and "rvalue" everywhere outside MIR.
This has been a TODO ever since, although the replacement is definitely a matter of bikeshed.

Anyway one of the reasons I told @bcata6 to open this before spending more time on it is so we can make sure it's not a dead-end (i.e. it's not a big deal if we just close this PR).

@wesleywiser
Copy link
Member

Got it, thanks! Op is a bit short for my taste, I think I would prefer if the whole word was spelled out. However, I don't feel strongly.

@eddyb
Copy link
Member

eddyb commented Apr 8, 2020

Alright, I'm cc-ing the broader @rust-lang/compiler, and nominating this as a bikeshed item.

@eddyb eddyb added I-nominated S-waiting-on-bikeshed Status: Awaiting a decision on trivial things. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 8, 2020
@wesleywiser
Copy link
Member

wesleywiser commented Apr 8, 2020

I think before merging this, we should also try to enumerate the other places that will need to be updated with this change and have a plan for updating those as well. For example,

  • various methods with rvalue in the name as @oli-obk has already pointed out
  • doc comments mentioning rvalues
  • rustc dev guide has plenty of Rvalue mentions I'm sure
  • miri
  • cg_cranelift (would be nice to leave a PR for @bjorn3 so they don't have to deal with this)
  • the reference
  • unsafe code guidelines
  • others?
@rust-highfive
Copy link
Contributor

The job mingw-check of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2020-04-08T14:33:50.9583789Z ========================== Starting Command Output =========================== 2020-04-08T14:33:50.9586443Z [command]/bin/bash --noprofile --norc /home/vsts/work/_temp/98b3ff92-06c0-477b-9a72-eabddd7908b2.sh 2020-04-08T14:33:50.9586702Z 2020-04-08T14:33:50.9591558Z ##[section]Finishing: Disable git automatic line ending conversion 2020-04-08T14:33:50.9611381Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/70928/merge to s 2020-04-08T14:33:50.9614926Z Task : Get sources 2020-04-08T14:33:50.9615263Z Description : Get sources from a repository. Supports Git, TfsVC, and SVN repositories. 2020-04-08T14:33:50.9615543Z Version : 1.0.0 2020-04-08T14:33:50.9615735Z Author : Microsoft --- 2020-04-08T14:33:52.1867629Z ##[command]git remote add origin https://github.com/rust-lang/rust 2020-04-08T14:33:52.1875853Z ##[command]git config gc.auto 0 2020-04-08T14:33:52.1881615Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader 2020-04-08T14:33:52.1888670Z ##[command]git config --get-all http.proxy 2020-04-08T14:33:52.1898935Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/70928/merge:refs/remotes/pull/70928/merge --- 2020-04-08T14:37:15.2654908Z ---> 3fc1b512c57b 2020-04-08T14:37:15.2655442Z Step 6/7 : ENV RUN_CHECK_WITH_PARALLEL_QUERIES 1 2020-04-08T14:37:15.2655854Z ---> Using cache 2020-04-08T14:37:15.2656167Z ---> 5ee4295733f4 2020-04-08T14:37:15.2657881Z Step 7/7 : ENV SCRIPT python2.7 ../x.py test src/tools/expand-yaml-anchors && python2.7 ../x.py check --target=i686-pc-windows-gnu --host=i686-pc-windows-gnu && python2.7 ../x.py build --stage 0 src/tools/build-manifest && python2.7 ../x.py test --stage 0 src/tools/compiletest && python2.7 ../x.py test src/tools/tidy && /scripts/validate-toolstate.sh 2020-04-08T14:37:15.2659187Z ---> 3d07a0fa42fe 2020-04-08T14:37:15.2717384Z Successfully built 3d07a0fa42fe 2020-04-08T14:37:15.2769170Z Successfully tagged rust-ci:latest 2020-04-08T14:37:15.3110310Z Built container sha256:3d07a0fa42feb5754fc13bb2f7010ebe13e4b8b8cdbebed0c75d8da320c8c8ad 2020-04-08T14:37:15.3110310Z Built container sha256:3d07a0fa42feb5754fc13bb2f7010ebe13e4b8b8cdbebed0c75d8da320c8c8ad 2020-04-08T14:37:15.3124223Z Looks like docker image is the same as before, not uploading 2020-04-08T14:37:23.0446389Z [CI_JOB_NAME=mingw-check] 2020-04-08T14:37:23.0718559Z [CI_JOB_NAME=mingw-check] 2020-04-08T14:37:23.0749162Z == clock drift check == 2020-04-08T14:37:23.0759219Z local time: Wed Apr 8 14:37:23 UTC 2020 2020-04-08T14:37:23.3647607Z network time: Wed, 08 Apr 2020 14:37:23 GMT 2020-04-08T14:37:23.3678145Z Starting sccache server... 2020-04-08T14:37:23.4522506Z configure: processing command line 2020-04-08T14:37:23.4522727Z configure: 2020-04-08T14:37:23.4523524Z configure: rust.parallel-compiler := True --- 2020-04-08T14:41:04.6660176Z Checking rustc_span v0.0.0 (/checkout/src/librustc_span) 2020-04-08T14:41:09.3847513Z Checking rustc_errors v0.0.0 (/checkout/src/librustc_errors) 2020-04-08T14:41:10.6426696Z Checking rustc_feature v0.0.0 (/checkout/src/librustc_feature) 2020-04-08T14:41:10.6627845Z Checking fmt_macros v0.0.0 (/checkout/src/libfmt_macros) 2020-04-08T14:41:10.8595263Z Checking rustc_query_system v0.0.0 (/checkout/src/librustc_query_system) 2020-04-08T14:41:11.7227429Z Checking rustc_hir v0.0.0 (/checkout/src/librustc_hir) 2020-04-08T14:41:11.7352482Z Checking rustc_session v0.0.0 (/checkout/src/librustc_session) 2020-04-08T14:41:13.3378744Z Checking rustc_attr v0.0.0 (/checkout/src/librustc_attr) 2020-04-08T14:41:13.8449108Z Checking rustc_parse v0.0.0 (/checkout/src/librustc_parse) --- 2020-04-08T14:43:11.2341418Z configure: build.locked-deps := True 2020-04-08T14:43:11.2341718Z configure: llvm.ccache := sccache 2020-04-08T14:43:11.2342902Z configure: build.cargo-native-static := True 2020-04-08T14:43:11.2343357Z configure: dist.missing-tools := True 2020-04-08T14:43:11.2343946Z configure: build.configure-args := ['--enable-sccache', '--disable-manage-submodu ... 2020-04-08T14:43:11.2344772Z configure: writing `config.toml` in current directory 2020-04-08T14:43:11.2345029Z configure: 2020-04-08T14:43:11.2345667Z configure: run `python /checkout/x.py --help` 2020-04-08T14:43:11.2345895Z configure: --- 2020-04-08T14:44:37.9873562Z Hugepagesize: 2048 kB 2020-04-08T14:44:37.9873787Z DirectMap4k: 145344 kB 2020-04-08T14:44:37.9873992Z DirectMap2M: 4048896 kB 2020-04-08T14:44:37.9874198Z DirectMap1G: 5242880 kB 2020-04-08T14:44:37.9886191Z + python2.7 ../x.py test src/tools/expand-yaml-anchors 2020-04-08T14:44:39.3265931Z Ensuring the YAML anchors in the GitHub Actions config were expanded 2020-04-08T14:44:39.3265931Z Ensuring the YAML anchors in the GitHub Actions config were expanded 2020-04-08T14:44:39.3279121Z Building stage0 tool expand-yaml-anchors (x86_64-unknown-linux-gnu) 2020-04-08T14:44:39.5535345Z Compiling unicode-xid v0.2.0 2020-04-08T14:44:39.6821404Z Compiling syn v1.0.11 2020-04-08T14:44:40.5800880Z Compiling linked-hash-map v0.5.2 2020-04-08T14:44:40.5811673Z Compiling lazy_static v1.4.0 2020-04-08T14:44:40.5811673Z Compiling lazy_static v1.4.0 2020-04-08T14:44:40.8163942Z Compiling yaml-rust v0.4.3 2020-04-08T14:44:45.3482552Z Compiling quote v1.0.2 2020-04-08T14:45:00.8308795Z Compiling thiserror-impl v1.0.5 2020-04-08T14:45:05.8444763Z Compiling thiserror v1.0.5 2020-04-08T14:45:05.9050432Z Compiling yaml-merge-keys v0.4.0 2020-04-08T14:45:07.1866825Z Compiling expand-yaml-anchors v0.1.0 (/checkout/src/tools/expand-yaml-anchors) 2020-04-08T14:45:09.4065534Z Build completed successfully in 0:00:31 2020-04-08T14:45:09.4071260Z + python2.7 ../x.py check --target=i686-pc-windows-gnu --host=i686-pc-windows-gnu 2020-04-08T14:45:09.6670500Z Finished dev [unoptimized] target(s) in 0.19s 2020-04-08T14:45:10.7883457Z Checking rustdoc artifacts (x86_64-unknown-linux-gnu -> i686-pc-windows-gnu) --- 2020-04-08T14:47:18.0216409Z Checking rustc_span v0.0.0 (/checkout/src/librustc_span) 2020-04-08T14:47:22.6575838Z Checking rustc_errors v0.0.0 (/checkout/src/librustc_errors) 2020-04-08T14:47:23.9255137Z Checking rustc_feature v0.0.0 (/checkout/src/librustc_feature) 2020-04-08T14:47:24.0553277Z Checking fmt_macros v0.0.0 (/checkout/src/libfmt_macros) 2020-04-08T14:47:24.2674162Z Checking rustc_query_system v0.0.0 (/checkout/src/librustc_query_system) 2020-04-08T14:47:25.0251629Z Checking rustc_hir v0.0.0 (/checkout/src/librustc_hir) 2020-04-08T14:47:25.0954961Z Checking rustc_session v0.0.0 (/checkout/src/librustc_session) 2020-04-08T14:47:26.6791218Z Checking rustc_attr v0.0.0 (/checkout/src/librustc_attr) 2020-04-08T14:47:27.1957408Z Checking rustc_parse v0.0.0 (/checkout/src/librustc_parse) --- 2020-04-08T14:51:44.5693449Z skip untracked path cpu-usage.csv during rustfmt invocations 2020-04-08T14:51:44.5699312Z skip untracked path src/doc/book/ during rustfmt invocations 2020-04-08T14:51:44.5699984Z skip untracked path src/doc/rust-by-example/ during rustfmt invocations 2020-04-08T14:51:44.5704729Z skip untracked path src/llvm-project/ during rustfmt invocations 2020-04-08T14:51:48.5386079Z Diff in /checkout/src/librustc_mir/borrow_check/mod.rs at line 14: 2020-04-08T14:51:48.5386493Z Operand, Place, PlaceElem, PlaceRef, ReadOnlyBodyAndCache, 2020-04-08T14:51:48.5386714Z }; 2020-04-08T14:51:48.5387029Z use rustc_middle::mir::{AggregateKind, BasicBlock, BorrowCheckResult, BorrowKind}; 2020-04-08T14:51:48.5388060Z -use rustc_middle::mir::{Field, ProjectionElem, Promoted, Op, Statement, StatementKind}; 2020-04-08T14:51:48.5388490Z +use rustc_middle::mir::{Field, Op, ProjectionElem, Promoted, Statement, StatementKind}; 2020-04-08T14:51:48.5388879Z use rustc_middle::mir::{Terminator, TerminatorKind}; 2020-04-08T14:51:48.5389169Z use rustc_middle::ty::query::Providers; 2020-04-08T14:51:48.5389451Z use rustc_middle::ty::{self, RegionVid, TyCtxt}; 2020-04-08T14:51:48.5389786Z Diff in /checkout/src/librustc_mir/borrow_check/mod.rs at line 1335: 2020-04-08T14:51:48.5390129Z let stmt = &bbd.statements[loc.statement_index]; 2020-04-08T14:51:48.5390520Z debug!("temporary assigned in: stmt={:?}", stmt); 2020-04-08T14:51:48.5390804Z 2020-04-08T14:51:48.5391567Z - if let StatementKind::Assign(box (_, Op::Ref(_, _, source))) = stmt.kind 2020-04-08T14:51:48.5392082Z - { 2020-04-08T14:51:48.5392855Z + if let StatementKind::Assign(box (_, Op::Ref(_, _, source))) = stmt.kind { 2020-04-08T14:51:48.5393302Z propagate_closure_used_mut_place(self, source); 2020-04-08T14:51:48.5396743Z bug!( 2020-04-08T14:51:48.5396743Z bug!( 2020-04-08T14:51:48.5399456Z Running `"/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/rustfmt" "--config-path" "/checkout" "--edition" "2018" "--unstable-features" "--skip-children" "--check" "/checkout/src/librustc_mir/borrow_check/mod.rs"` failed. 2020-04-08T14:51:48.5400689Z If you're running `tidy`, try again with `--bless` flag. Or, you just want to format code, run `./x.py fmt` instead. 2020-04-08T14:51:48.5412972Z Build completed unsuccessfully in 0:00:41 2020-04-08T14:51:48.5459833Z == clock drift check == 2020-04-08T14:51:48.5472700Z local time: Wed Apr 8 14:51:48 UTC 2020 2020-04-08T14:51:48.5472700Z local time: Wed Apr 8 14:51:48 UTC 2020 2020-04-08T14:51:48.8354256Z network time: Wed, 08 Apr 2020 14:51:48 GMT 2020-04-08T14:51:50.3779991Z 2020-04-08T14:51:50.3779991Z 2020-04-08T14:51:50.3868514Z ##[error]Bash exited with code '1'. 2020-04-08T14:51:50.3886987Z ##[section]Finishing: Run build 2020-04-08T14:51:50.3971570Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/70928/merge to s 2020-04-08T14:51:50.3977001Z Task : Get sources 2020-04-08T14:51:50.3977381Z Description : Get sources from a repository. Supports Git, TfsVC, and SVN repositories. 2020-04-08T14:51:50.3977697Z Version : 1.0.0 2020-04-08T14:51:50.3977905Z Author : Microsoft 2020-04-08T14:51:50.3977905Z Author : Microsoft 2020-04-08T14:51:50.3978405Z Help : [More Information](https://go.microsoft.com/fwlink/?LinkId=798199) 2020-04-08T14:51:50.3978809Z ============================================================================== 2020-04-08T14:51:50.7366056Z Cleaning any cached credential from repository: rust-lang/rust (GitHub) 2020-04-08T14:51:50.7405463Z ##[section]Finishing: Checkout rust-lang/rust@refs/pull/70928/merge to s 2020-04-08T14:51:50.7493784Z Cleaning up task key 2020-04-08T14:51:50.7495660Z Start cleaning up orphan processes. 2020-04-08T14:51:50.7673269Z Terminate orphan process: pid (3511) (python) 2020-04-08T14:51:50.7850129Z ##[section]Finishing: Finalize Job 

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @rust-lang/infra. (Feature Requests)

@Centril
Copy link
Contributor

Centril commented Apr 8, 2020

others?

The reference and the UCG.

I personally think "rvalue" is fairly established terminology by now, and Op vs. Operand makes it harder to grep for, so I don't find the churn here useful.

@eddyb
Copy link
Member

eddyb commented Apr 8, 2020

I personally think "rvalue" is fairly established terminology by now

It's no more established than it was at the time of e.g. rust-lang/rust-by-example#1028 (sadly, it looks like we didn't track this properly, which explains how we lost sight of mir::Rvalue).

@pnkfelix
Copy link
Contributor

discussed in ad hoc triage after friday planning meeting.

my inclination is to close this. I don't think Op is an improvement over Rvalue. We can separately bikeshed potential alternatives.

@rfcbot fcp close

@rfcbot
Copy link

rfcbot commented Apr 10, 2020

Team member @pnkfelix has proposed to close this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-close This PR / issue is in PFCP or FCP with a disposition to close it. labels Apr 10, 2020
@crlf0710
Copy link
Member

I think exactly this bike-shedding has happened before in wg-ucg, cc @RalfJung

Personally i prefer something like ValExpr here (if "expr" part is not good, maybe replace it with something like "form"), and i really wish the "left/right" terminology be entirely removed from Rust for consistency.

@eddyb
Copy link
Member

eddyb commented Apr 12, 2020

Personally i prefer something like ValExpr here (if "expr" part is not good, maybe replace it with something like "form")

ValOp and ValKind are two quick ideas based on that.

@petrochenkov
Copy link
Contributor

I mostly have no idea about what's happening here, but I've checked my box because while name Rvalue could give some intuition about its meaning, the name Op can mean absolutely anything.

@bors
Copy link
Collaborator

bors commented Apr 13, 2020

☔ The latest upstream changes (presumably #71079) made this pull request unmergeable. Please resolve the merge conflicts.

@bors bors added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Apr 13, 2020
@RalfJung
Copy link
Member

RalfJung commented Apr 13, 2020

I think exactly this bike-shedding has happened before in wg-ucg,

Indeed, and Op is a bad name here I think. We already have Operand, so this basically means we have two distinct concepts with the same name.

Value would be in accordance with the conclusion of the UCG bikeshedding and consistent with Place.

I like ValExpr (and it is also consistent with UCG bikeshedding) but then it also should be PlaceExpr (and Operand -> OpExpr, maybe).

i really wish the "left/right" terminology be entirely removed from Rust for consistency

Agreed. It is particularly confusing and inconsistent to have "rvalues" but not "lvalues", I think.

@eddyb
Copy link
Member

eddyb commented Apr 16, 2020

Indeed, and Op is a bad name here I think. We already have Operand, so this basically means we have two distinct concepts with the same name.

I still think "operands" are what "operators"/"operations" operate on/with. Am I missing something?

@RalfJung
Copy link
Member

RalfJung commented Apr 16, 2020

I still think "operands" are what "operators"/"operations" operate on. Am I missing something?

Well, yes, but that's not helpful here. By that standard mir::StatementKind::Assign has two operands, one on the left and one on the right, which are the two things the assignment operates on.

The way I view it, the fundamental notions are places and values. This is reflected by the reference. Assignment puts a value into a place.

mir::Operand is an implementation detail, which for simplicity and effieiciency carves out a subset of values that can be directly passed to primitive operations and functions -- but in principle, at least as far as a MIR spec is concerned, there should be no problem at all in supporting arbitrary MIR value expressions (mir::Rvalue) anywhere that we currently use mir::Operand. (Miri exploits the simpler nature of mir::Operand for its "lazy" implementation of copying, but that should be an unobservable implementation detail of the interpreter, not something that exists in the MIR spec.)

@nikomatsakis
Copy link
Contributor

For what it's worth, I have found the term "place" to be "not great" when talking to people, particularly when it's referring (ultimately) to a place expression. I spend a while thinking about this in the polonius talk and I landed on "path expression" (or frequently just "path") as the term for "place expression", because it seemed like whenever I would try to explain what a "place" is, I always explained it by saying "it's a path, like a.b.c", and people understood that.

In short, I think I largely agree with @RalfJung's proposed nomenclature of places and values as things that occur at runtime.

I could live with place/value expressions as the thing we manipulate in our MIR programs (that will be evaluated to particular places/values), but actually I think the symmetry isn't that great, because it makes the terms rather verbose, and I think people won't want to use them. PlaceExpr and PlaceExpression are long and unwieldy.

Personally, I prefer place/path -- i.e., what we call Place in MIR we would call Path, and a place would be the dynamic stack slot or whatever that a path evaluates to.

I was going to say I'd prefer value/expression, but I realize I can't really decide whether I think that expression should an Rvalue or an Operand =) Probably Rvalue.

Maybe we ought to try and draw up a big table with the options... or maybe introducing place/path is not helpful here. But it would be good to settle these names (and align them with UCG terminology).

@RalfJung
Copy link
Member

Personally, I prefer place/path -- i.e., what we call Place in MIR we would call Path, and a place would be the dynamic stack slot or whatever that a path evaluates to.

I feel rather strongly that it would be strange to call the dynamic concept a place and the static concept a path -- that sounds like they are unrelated. It should be "path expression" and "path value" or so.

but I realize I can't really decide whether I think that expression should an Rvalue or an Operand =) Probably Rvalue.

Hm, I thought we had consensus for "value expression" in the UCG discussion, and that's also what the reference uses, for whatever that is worth.

@nikomatsakis
Copy link
Contributor

Heh, I'm probably just wrong -- or at least "unique" -- in finding four distinct, short words more memorable and evocative than compound terms like "place expression". I can certainly see that having the symmetry could help people trying to get their head around the distinctions at play. I still fear that the terms "place expression" and "value expression" are unwieldy and people will tend not to use them in full, but I will happily yield to the UCG consensus and stop trying to derail. =)

But I do have a point of clarification...

Hm, I thought we had consensus for "value expression" in the UCG discussion, and that's also what the reference uses, for whatever that is worth.

But what does it use it to refer to -- what we call "rvalues" here or "operands"? Given your point (which I agree with) that the a-normalized form of MIR is a convenient implementation detail and not something "fundamental", I would expect that "value expressions" refers to "rvalues", and that operands are a kind of subset of that which we happen to find convenient (and hence they could, for example, be called "value subexpressions" or something like that, too).

@RalfJung
Copy link
Member

RalfJung commented Apr 18, 2020

But what does it use it to refer to -- what we call "rvalues" here or "operands"? Given your point (which I agree with) that the a-normalized form of MIR is a convenient implementation detail and not something "fundamental", I would expect that "value expressions" refers to "rvalues",

Yes that is my understanding, too. Hence the suggestion to rename "rvalue" to "value" in this PR. (The "expression" is implicit from being in the mir module, which contains static representations, as opposed to the interp module which contains dynamic representations.)

and that operands are a kind of subset of that which we happen to find convenient (and hence they could, for example, be called "value subexpressions" or something like that, too).

Operands are a subset of values, but a "subexpression" is something else. I think "operand" is not bad, if I had to come up with a name I might have called it a "leaf value expression" or so (since operands are the leaves of value expressions).

@nikomatsakis
Copy link
Contributor

For the record, I'm fine with the names

  • Rvalue => Value
  • Operand => Operand

That said, from that link you sent, @RalfJung:

A subexpression is a part of an expression that is by itself a correct expression.

In what way is an operand not itself a correct expression? I think that's what the Rvalue::Use variant is -- basically "upcasting" an Operand into an Rvalue.

@RalfJung
Copy link
Member

RalfJung commented Apr 20, 2020

Renaming "operand" to "subexpression" is not even "well-typed" in some ontological sense... there is no such thing as a "subexpression" in a global way, there are just "subexpressions of some given expression E". In other way, "subexpression" is a binary relation on expressions (it has type expr -> expr -> Prop). But "operand" is just a (sub)set of expressions, or equivalently a predicate on expressions, it has type expr -> Prop.

In what way is an operand not itself a correct expression?

Uh, it is, but so what? The defining property of an operand is not "this is a subexpression of some e". The defining property is "this is an expression that satisfies these additional constraints".

Renaming "operand" to "subexpression" is a bit like renaming "square" to "subshape" because, you know, every "square" is a "shape".

@spastorino
Copy link
Member

Unnominating as it was discussed already in our last meeting.

@spastorino
Copy link
Member

spastorino commented Apr 22, 2020

Renominated with the purpose of mentioning in the meeting that the discussion is still ongoing and maybe that the right place for the ongoing discussion is a specific Zulip topic.

@Dylan-DPC-zz Dylan-DPC-zz changed the title [WIP] Rename mir::Rvalue to Op. Rename mir::Rvalue to Op. Apr 22, 2020
@pnkfelix
Copy link
Contributor

Okay I'm officially moving the bikeshed regarding the name over to Zulip.

Here is the Zulip thread for the bikeshed: https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/To.20what.20to.20rename.20mir.3A.3ARvalue.20.2370928/near/195072985

I think we are all agreed that we won't land the renaming as encoded in this PR, so I am going to go ahead and close this PR. Thank you very much for the PR, @bcata6 !

@pnkfelix pnkfelix closed this Apr 23, 2020
@rfcbot rfcbot removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-close This PR / issue is in PFCP or FCP with a disposition to close it. labels Apr 23, 2020
@RalfJung
Copy link
Member

So my understanding is that if a PR was opened that renamed Rvalue to Value, that would be accepted? Or is more discussion needed first?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. S-waiting-on-bikeshed Status: Awaiting a decision on trivial things. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.