Skip to content

port the "autoref-arg" code used in overloaded operators to use the ptr adjustment table #3548

New issue

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

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

Already on GitHub? Sign in to your account

Closed
nikomatsakis opened this issue Sep 20, 2012 · 19 comments · Fixed by #42281
Closed
Labels
A-codegen Area: Code generation A-type-system Area: Type system C-cleanup Category: PRs that clean code up or issues documenting cleanup.

Comments

@nikomatsakis
Copy link
Contributor

We have this nice table in the tcx called adjustments that's supposed to track when an expression is being auto-ref'd or auto-deref'd. It would make borrowck, trans, and other pieces of code that are concerned with this "just work". But it's not being used for overloaded operators right now.

@pcwalton
Copy link
Contributor

This is more of cleanup than an enhancement. Punting to 0.6.

@graydon
Copy link
Contributor

graydon commented Mar 25, 2013

non-critical for 0.6, de-milestoning

@jld
Copy link
Contributor

jld commented Mar 25, 2013

#5304 is the const part of this, I think. There might be other pieces that are already done; it looked as if expr translation was using adjustments when I was fixing consts, I think.

@nikomatsakis
Copy link
Contributor Author

@jld expr translation does use adjustments in general, but not to handle the autoref of arguments associated with operators.

@graydon
Copy link
Contributor

graydon commented May 29, 2013

Confirmed 2013-05-29, this is still legit and is not a backwards compatibility risk, just eliminating redundancy inside the compiler.

@graydon
Copy link
Contributor

graydon commented Aug 15, 2013

Visiting again for triage. Still appears to be a living issue in the compiler.

@emberian
Copy link
Member

Visiting for triage, FIXME still present.

@nikomatsakis
Copy link
Contributor Author

I have a branch that implemented this. It turns out to be somewhat more difficult than I anticipated, because the current rules permit things that autoref cannot currently express, such as using both autoref from an adjustment AND the magical operator autoref. I'm not a fan of supporting this anyhow but I deferred this branch in favor of finishing up some more pressing matters.

@ghost
Copy link

ghost commented Nov 16, 2014

@nikomatsakis Can this be closed?

@nikomatsakis
Copy link
Contributor Author

Sadly no. However, the difficulties I mentioned in my previous comment probably no longer apply since method dispatch has been made more regular.

@nikomatsakis
Copy link
Contributor Author

(Actually, I wonder if it can be closed.. I may have accidentally done this while doing the method dispatch operator overloading.)

@nikomatsakis
Copy link
Contributor Author

Well, I don't think we can close it, because the autoref machinery is still there, but it might be that all the interesting work is done.

@nikomatsakis
Copy link
Contributor Author

and what remains is to remove the outdated code

@steveklabnik
Copy link
Member

Triage: this seems to be about deep compiler stuff that's probably gone by now. Is that true, @nikomatsakis ?

@nikomatsakis
Copy link
Contributor Author

Sadly it is not gone by now. But it's also a long standing bug that is not that important, MIR makes it even less relevant.

@eddyb
Copy link
Member

eddyb commented Apr 15, 2017

For the record, this is currently handled in rustc_mir::hair::cx::expr for comparison binops and deref.

@nikomatsakis
Copy link
Contributor Author

@eddyb maybe we should just close this? I feel like it'll be fixed "in passing" at some point, but I'm not sure that keeping the bug open is very valuable.

@eddyb
Copy link
Member

eddyb commented Apr 18, 2017

Agreed, the only realistic way this may happen if HAIR is output from typeck.

@eddyb eddyb closed this as completed Apr 18, 2017
@eddyb
Copy link
Member

eddyb commented May 28, 2017

Turns out that it's not that hard of a change, so I'm doing it as minor cleanup in a future PR.

@eddyb eddyb reopened this May 28, 2017
bors added a commit that referenced this issue Jun 1, 2017
Decompose Adjustment into smaller steps and remove the method map.

The method map held method callee information for:
* actual method calls (`x.f(...)`)
* overloaded unary, binary, indexing and call operators
* *every overloaded deref adjustment* (many can exist for each expression)

That last one was a historical ~~accident~~ hack, and part of the motivation for this PR, along with:
* a desire to compose adjustments more freely
* containing the autoderef logic better to avoid mutation within an inference snapshot
* not creating `TyFnDef` types which are incompatible with the original one
  * i.e. we used to take a`TyFnDef`'s `for<'a> &'a T -> &'a U` signature and instantiate `'a` using a region inference variable, *then* package the resulting `&'b T -> &'b U` signature in another `TyFnDef`, while keeping *the same* `DefId` and `Substs`
* to fix #3548 by explicitly writing autorefs for the RHS of comparison operators

Individual commits tell their own story, of "atomic" changes avoiding breaking semantics.

Future work based on this PR could include:
* removing the signature from `TyFnDef`, now that it's always "canonical"
  * some questions of variance remain, as subtyping *still* treats the signature differently
* moving part of the typeck logic for methods, autoderef and coercion into `rustc::traits`
* allowing LUB coercions (joining multiple expressions) to "stack up" many adjustments
* transitive coercions (e.g. reify or unsize after multiple steps of autoderef)

r? @nikomatsakis
bors pushed a commit to rust-lang-ci/rust that referenced this issue May 15, 2021
…ttributes

Fix normalisation of multiline doc attributes
RalfJung pushed a commit to RalfJung/rust that referenced this issue May 4, 2024
make many-seeds a mode of ./miri run rather than a separate command

Also parallelize it so we use all cores to try seeds at the same time.

Fixes rust-lang/miri#3509 by not alternating between different build modes (with/without dev-dependencies) all the time.
RalfJung pushed a commit to RalfJung/rust that referenced this issue May 4, 2024
make many-seeds a mode of ./miri run rather than a separate command

Also parallelize it so we use all cores to try seeds at the same time.

Fixes rust-lang/miri#3509 by not alternating between different build modes (with/without dev-dependencies) all the time.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation A-type-system Area: Type system C-cleanup Category: PRs that clean code up or issues documenting cleanup.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants