-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Fix a bug with statics inside blocks in generic fns #8843
Conversation
@alexcrichton how does this handle the following case: pub fn foo() {
static x: int = 42;
{
static x; int = 42;
printfln!(x);
}
printfln!(x);
} |
It uses a visitor to recurse inside of a function to visit all the items, and the default implementation of a visitor would recurse to each of those items. The name mangling for them happens elsewhere. That also compiles fine today, the problem that this is addressing is when those statics are inside of a generic function which is then compiled into a library because the function itself isn't actually instantiated anywhere. |
@@ -37,6 +37,8 @@ use std::vec; | |||
use syntax::ast_map::{path, path_mod, path_name}; | |||
use syntax::ast_util; | |||
use syntax::{ast, ast_map}; | |||
use syntax::visit; | |||
use syntax::visit::Visitor; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Visitor
isn't actually used; this line causes an unused-import error at stage1 compilation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes, you are correct, the perils of not running tests!
This appears to fix #8835, though I'm not done compiling yet (stage1 compilation seems to be working though). |
Whenever a generic function was encountered, only the top-level items were recursed upon, even though the function could contain items inside blocks or nested inside of other expressions. This fixes the existing code from traversing just the top level items to using a Visitor to deeply recurse and find any items which need to be translated. This was uncovered when building code with --lib, because the encode_symbol function would panic once it found that an item hadn't been translated. Closes rust-lang#8134
Whenever a generic function was encountered, only the top-level items were recursed upon, even though the function could contain items inside blocks or nested inside of other expressions. This fixes the existing code from traversing just the top level items to using a Visitor to deeply recurse and find any items which need to be translated. This was uncovered when building code with --lib, because the encode_symbol function would panic once it found that an item hadn't been translated. Closes #8134
Collect renamed lints changelog: Display past names of renamed lints on Clippy's lint list cc rust-lang#7172 r? `@xFrednet`
Whenever a generic function was encountered, only the top-level items were
recursed upon, even though the function could contain items inside blocks or
nested inside of other expressions. This fixes the existing code from traversing
just the top level items to using a Visitor to deeply recurse and find any items
which need to be translated.
This was uncovered when building code with --lib, because the encode_symbol
function would panic once it found that an item hadn't been translated.
Closes #8134