Skip to content
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

Odd "mismatched types" error message #9249

Closed
jruderman opened this issue Sep 17, 2013 · 4 comments · Fixed by #18099
Closed

Odd "mismatched types" error message #9249

jruderman opened this issue Sep 17, 2013 · 4 comments · Fixed by #18099
Labels
A-diagnostics Area: Messages for errors, warnings, and lints E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.

Comments

@jruderman
Copy link
Contributor

static DATA:&'static [&'static str] = ["my string"];
fn main() { }

The error message seems to confuse lifetime with size:

error: mismatched types:
    expected `&'static [&'static str]` 
    but found `[&'static str, .. 1]`
    ([] storage differs: expected &'static  but found 1)

Also note the extra space after &'static.

@alexcrichton
Copy link
Member

Closing as working as intended

The right hand side has type [&'static str, ..1] which will normally coerce to a &'static [&'static str] in code, but in statics there is no coercion. The right hand side will have to be &["my string"] to work.

@jruderman
Copy link
Contributor Author

The error message could use some improvement.

@ftxqxd
Copy link
Contributor

ftxqxd commented Oct 4, 2014

The given test case now compiles. Can this be closed, or is there some other case where coercion doesn’t occur?

@alexcrichton
Copy link
Member

Flagging as needstest

@alexcrichton alexcrichton added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Oct 6, 2014
bors added a commit that referenced this issue Oct 18, 2014
Closes #9249.
Closes #13105.
Closes #13837.
Closes #13847.
Closes #15207.
Closes #15261.
Closes #16048. 
Closes #16098.
Closes #16256.
Closes #16562.
Closes #16596.
Closes #16709.
Closes #16747.
Closes #17025.
Closes #17121.
Closes #17450.
Closes #17636.
flip1995 pushed a commit to flip1995/rust that referenced this issue Jul 28, 2022
…lip1995

Use `action/checkout@v3` in the book

As this type of document is often copied/pasted, using a newer version of `actions/checkout` would be better.

changelog: none

Signed-off-by: Yuki Okushi <jtitor@2k36.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants