Skip to content

Static Vec fails on Rust 0.11.0 with ugly error #15627

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
ghost opened this issue Jul 12, 2014 · 1 comment
Closed

Static Vec fails on Rust 0.11.0 with ugly error #15627

ghost opened this issue Jul 12, 2014 · 1 comment

Comments

@ghost
Copy link

ghost commented Jul 12, 2014

Code: static val: Vec<u64> = vec!(1, 2, 3);
Errors:

<std macros>:4:25: 4:47 error: static items are not allowed to have destructors
<std macros>:4         let mut _temp = ::std::vec::Vec::new();
                                       ^~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 9:2 note: in expansion of vec!
euler/primes.rs:1:26: 1:40 note: expansion site
<std macros>:5:11: 5:16 error: static items are not allowed to have destructors
<std macros>:5         $(_temp.push($e);)*
                         ^~~~~
<std macros>:1:1: 9:2 note: in expansion of vec!
euler/primes.rs:1:26: 1:40 note: expansion site
<std macros>:5:11: 5:16 error: static items are not allowed to have destructors
<std macros>:5         $(_temp.push($e);)*
                         ^~~~~
<std macros>:1:1: 9:2 note: in expansion of vec!
euler/primes.rs:1:26: 1:40 note: expansion site
<std macros>:5:11: 5:16 error: static items are not allowed to have destructors
<std macros>:5         $(_temp.push($e);)*
                         ^~~~~
<std macros>:1:1: 9:2 note: in expansion of vec!
euler/primes.rs:1:26: 1:40 note: expansion site
<std macros>:6:9: 6:14 error: static items are not allowed to have destructors
<std macros>:6         _temp
                       ^~~~~
<std macros>:1:1: 9:2 note: in expansion of vec!
euler/primes.rs:1:26: 1:40 note: expansion site
error: aborting due to 5 previous errors
@ghost ghost changed the title Static Vec fails on Rust 0.11.0 without friendly error Static Vec fails on Rust 0.11.0 with ugly error Jul 13, 2014
@thestinger
Copy link
Contributor

This is a consequence of using a macro for something like this. There are already some bugs about improving macro expansion errors, and I don't think there's a unique aspect to this error.

bors added a commit to rust-lang-ci/rust that referenced this issue Dec 11, 2023
feat: Prioritize import suggestions based on the expected type

Hi, this is a draft PR to solve rust-lang#15384. `Adt` types work and now I have a few questions :)

1. What other types make sense in this context? Looking at [ModuleDef](https://github.com/rust-lang/rust-analyzer/blob/05666441bafd6010787a4097a6bd44266ad21018/crates/hir/src/lib.rs#L275) I am thinking everything except Modules.
2. Is there an existing way of converting between `ModeuleDef` and `hir::Type` in the rustanalyzer code base?
3. Does this approach seem sound to you?

Ups: Upon writing this I just realised that the enum test is invalided as there are no enum variants and this no variant is passed as a function argument.
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

No branches or pull requests

1 participant