Skip to content

Conversation

@pcwalton
Copy link
Contributor

This breaks code like:

struct Point<T> {
    x: T,
    y: T,
}

let pt = Point::<bool> {
    x: 1,
    y: 2,
};

Change this code to not contain a type error. For example:

let pt = Point::<int> {
    x: 1,
    y: 2,
};

Closes #15875.

[breaking-change]

r? @huonw

Copy link
Contributor

Choose a reason for hiding this comment

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

First sentence here, I assume you mean "and the corresponding type has no type parameters".

@pcwalton
Copy link
Contributor Author

@kballard Fixed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we use the full word "structure" in other errors, instead of "struct"? Similarly, do we have precedent for the phrase "structure constructor"? My inclination is to call it a "struct literal".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, we use "structure" in other errors.

@pcwalton
Copy link
Contributor Author

I realized this doesn't handle some edge cases. Going to rework a bit.

@lilyball
Copy link
Contributor

Just yesterday I was wondering if Point::<int> { ... } actually worked. So I'm happy to see you fixing this :) But I'll let someone else review for correctness, I don't know this section of the code.

@huonw
Copy link
Contributor

huonw commented Jul 24, 2014

I assume this closes #9620 too.

@pcwalton
Copy link
Contributor Author

re-r? @huonw

Copy link
Contributor

Choose a reason for hiding this comment

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

Travis says this line has trailing whitespace.

This breaks code like:

    struct Point<T> {
        x: T,
        y: T,
    }

    let pt = Point::<bool> {
        x: 1,
        y: 2,
    };

Change this code to not contain a type error. For example:

    let pt = Point::<int> {
        x: 1,
        y: 2,
    };

Closes rust-lang#9620.
Closes rust-lang#15875.

[breaking-change]
@pcwalton
Copy link
Contributor Author

@huonw Fixed.

matthiaskrgr pushed a commit to matthiaskrgr/rust that referenced this pull request Mar 10, 2024
…over, r=Veykril

feat: add hover display for trait assoc items

This PR enable preview assoc items when hover on `trait`

![image](https://github.com/rust-lang/rust-analyzer/assets/71162630/d9c3949c-33cf-4a32-aa97-3af46b28033a)

inspired by rust-lang/rust-analyzer#15847
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.

Struct literal constructors don't check type parameters on typedefs

3 participants