Skip to content

s/moved variable/moved value/ - #4493

Merged
pcwalton merged 1 commit into
rust-lang:incomingfrom
jbclements:rename-moved-variable-to-moved-value
Jan 16, 2013
Merged

s/moved variable/moved value/#4493
pcwalton merged 1 commit into
rust-lang:incomingfrom
jbclements:rename-moved-variable-to-moved-value

Conversation

@jbclements

Copy link
Copy Markdown
Contributor

I believe this implements the change I mentioned a few days ago. The tree appears to compile following this change.

r? @nikomatsakis

@nikomatsakis

Copy link
Copy Markdown
Contributor

r+ --- do you have privileges to push yourself?

@graydon

graydon commented Jan 15, 2013

Copy link
Copy Markdown
Contributor

He does now :)

pcwalton added a commit that referenced this pull request Jan 16, 2013
@pcwalton
pcwalton merged commit a2ec540 into rust-lang:incoming Jan 16, 2013
RalfJung added a commit to RalfJung/rust that referenced this pull request Jul 25, 2025
RalfJung added a commit to RalfJung/rust that referenced this pull request Jul 28, 2025
U007D pushed a commit to U007D/rust-mos that referenced this pull request Aug 21, 2026
4493: Provide builtin impls of Fn traits for fn-pointers r=flodiebold a=hban

Meant to be, but isn't actually a fix for rust-lang#2880.

Consider this snippet:

```rust
use std::marker::PhantomData;
use std::ops::Deref;

struct Lazy<T, F/* = fn() -> T*/>(F, PhantomData<T>);

impl<T, F> Lazy<T, F> {
    pub fn new(f: F) -> Lazy<T, F> {
        Lazy(f, PhantomData)
    }
}

impl<T, F: FnOnce() -> T> Deref for Lazy<T, F> {
    type Target = T;

    fn deref(&self) -> &T { todo!() }
}

fn test() {
    let lazy1: Lazy<u32, _> = Lazy::new(|| 0u32);
    let r1 = lazy1.to_string();

    fn make_u32_fn() -> u32 { todo!() }
    let make_u32_fn_ptr: fn() -> u32 = make_u32_fn;
    let lazy2: Lazy<u32, _> = Lazy::new(make_u32_fn_ptr);
    let r2 = lazy2.to_string();
}
```

* On current master:
  * When type default is commented-out, `r1` is correctly inferred, `r2` in _{unknown}_.
  * When type default is not commented-out, both `r1`  and `r2` are _{unknown}_.
* With this PR:
  * When type default is commented-out, both `r1` and `r2` are correctly inferred.
  * When type default is not commented-out, both `r1`  and `r2` are _{unknown}_.

Well, it's a improvement at least. I guess this thing with type defaults is a different problem.

I also tried add Fn impls for fn items, but wasn't successful. So this PR only adds those impls for fn pointers.

Co-authored-by: Hrvoje Ban <hban@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants