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

Need a solution for loading out-of-tree module source #8778

Closed
brson opened this issue Aug 27, 2013 · 7 comments
Closed

Need a solution for loading out-of-tree module source #8778

brson opened this issue Aug 27, 2013 · 7 comments
Labels
A-parser Area: The parsing of Rust source code to an AST C-enhancement Category: An issue proposing an enhancement or a PR with one.

Comments

@brson
Copy link
Contributor

brson commented Aug 27, 2013

Servo has two instances now where crates need to refer to generated modules that are created as part of another build step. Servo also only supports out-of-tree builds. The Rust parser expects to find source files laid out as a tree. As a result we are generating this source directly in the source tree and ignoring them with .gitignore. This is unpleasant.

I don't have any great ideas about how to make this work.

@brson
Copy link
Contributor Author

brson commented Aug 27, 2013

Nominating for feature complete.

@metajack
Copy link
Contributor

My only idea for this so far was basically adding an option to rustc to specify src search dirs, similarly to how -I foo works for cc. So if I said -I /path/to/foo and the compiler wanted bar/baz.rs, it would search /path/to/foo/bar/baz.rs as well.

@brson
Copy link
Contributor Author

brson commented Aug 27, 2013

We could do something like the existing #[path = "foo.rs"] attribute that would change where the source is searched from.

#[path_root = cfg_str!(build_dir)] mod foo;

This would basically transplant the current relative module path onto a different directory when searching for foo, then the build would pass --cfg "build_dir = \"my_build_dir\"" to rustc. Pretty hideous. Requires macros that expand to literals (which would be useful for other things too).

@brson
Copy link
Contributor Author

brson commented Aug 27, 2013

Or maybe just

#[path_dir = cfg_str!(generated_src_dir)] mod foo;

So we don't have to 'transplant' the relative directory onto the build dir root.

@emberian
Copy link
Member

cc @jbclements @paulstansifer how do you feel about the macro-based solution above?

Personally I'd rather just change the attribute sublanguage to allow #[path_root=build_dir] and it would know to look in the list of cfg variables for that.

@jbclements
Copy link
Contributor

generally speaking, I like the idea of using macros rather than extending the language... though it sounds like either one would require extending the language. If I was king of the world... oh, never mind. I think whichever one is simpler is probably the best choice :).

@alexcrichton
Copy link
Member

Through cargo we ended up developing include!(concat!(env!("FOO"), "/bar")) which I think suffices for now as at least "a way." We can add a follow-up issue if we'd like to modify #[path].

xFrednet pushed a commit to xFrednet/rust that referenced this issue May 21, 2022
Fix `cast_lossless` to avoid warning on `usize` to `f64` conversion.

Previously, the `cast_lossless` lint would issue a warning on code that
converted a `usize` value to `f64`, on 32-bit targets.

`usize` to `f64` is a lossless cast on 32-bit targets, however there is
no corresponding `f64::from` that takes a `usize`, so `cast_lossless`'s
suggested replacement does not compile.

This PR disables the lint in the case of casting from `usize` or `isize`.

Fixes rust-lang#3689.

changelog: [`cast_lossless`] no longer gives wrong suggestion on usize,isize->f64
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-parser Area: The parsing of Rust source code to an AST C-enhancement Category: An issue proposing an enhancement or a PR with one.
Projects
None yet
Development

No branches or pull requests

5 participants