Incorrect reference resolution when crate contains a module with the same name as function being imported
See original GitHub issueIn the below example, the polygon
function and the rectangle
function are resolved incorrectly as the polygon.rs module and the rectangle.rs module respectively.
Cargo.toml
:
[package]
name = "rust_test"
version = "0.1.0"
authors = ["johnthagen <johnthagen@gmail.com>"]
[dependencies]
piston_window = "0.52.0"
main.rs
:
extern crate piston_window;
use piston_window::{
clear, // Correctly resolved as function.
PistonWindow,
polygon, // INCORRECTLY resolved as module polygon.rs (should be function polygon)
rectangle, // INCORRECTLY resolved as module rectangle.rs (should be function rectangle)
WindowSettings
};
const POLYGON: &'static [[f64; 2]] = &[
[0.0, -1.0 * 16.0 / 2.0],
[20.0, 0.0],
[0.0, 16.0 / 2.0]
];
fn main() {
let title = "Hello Piston! (press any key to enter inner loop)";
let mut window: PistonWindow = WindowSettings::new(title, [640, 480])
.exit_on_esc(true)
.build()
.unwrap_or_else(|error| { panic!("Failed to build PistonWindow: {}", error) });
while let Some(event) = window.next() {
const WHITE: [f32; 4] = [1.0, 1.0, 1.0, 1.0];
const DARK_GREEN: [f32; 4] = [0.0, 0.5, 0.0, 1.0];
window.draw_2d(&event,
|context, graphics| {
clear(WHITE, graphics);
rectangle(DARK_GREEN,
[50.0, 50.0, 100.0, 100.0],
context.transform,
graphics);
polygon(DARK_GREEN,
POLYGON,
context.transform,
graphics);
});
}
}
Tested in PyCharm 2016.2.3, Windows 10 x64, plugin v0.1.0.981.
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Name resolution question in macros - help - The Rust Programming ...
I'm trying to use the unicode-segmentation crate in some macros I'm writing. I've added "unicode-segmentation" = "version = "^0.1.2" to my Cargo.toml file....
Read more >How do I import from a sibling module? - rust - Stack Overflow
To import a module on the same level, do the following: ... directly both give // the same result, because they refer to...
Read more >1560-name-resolution - The Rust RFC Book
Internally, name resolution will be split into two parts - import resolution and name lookup. Import resolution is moved forward in time to...
Read more >Crates and Modules - The Rust Programming Language - MIT
Rust has two distinct terms that relate to the module system: 'crate' and 'module'. A crate is synonymous with a 'library' or 'package'...
Read more >Unable to resolve reference of Custom Dataweave Function ...
This error can occur while using the custom function in the main DW if the custom module/ Dataweave script is not properly imported....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Simplified example:
Should be fixed now!