The Servo browser engine | Conduct: https://www.rust-lang.org/conduct.html | https://github.com/servo/servo | https://dxr.mozilla.org/servo/
@nikomatsakis idea: having a function definition we want to traverse its body to find calls to another functions, then check their generic params if they are must_root in case they must be must_root.
I browsed the docs and I don't know how to iterate over function calls in MIR (I don't understand everything there, though), but I found a way how to check it with HIR: we can use walk_expr/visit_expr (like it is done in current code) and then match expr.node against ExprCall and ExprMethodCall. ExprMethodCall -> PathSegment -> parameters (PathParameters) -> types. In case of ExprCall -> check inner expression and if it is ExprPath then match against QPath. TypeRelative has PathSegment like ExprMethodCall, so it's okay. Resolved I need to traverse Path.segments.
What do you think about it?
Constant
Path
let x = foo::<T>; x(...)
visit_substs
substs is for
Foo { ... } struct expressions
@nikomatsakis I tried to quickly write down the HIR check in meantime, but I stopped at the problem with converting hir::Ty to ty::TyS (haven't investigated it though).
Anyway, my MIR check:
fn visit_constant(&mut self, constant: &mir::Constant<'tcx>, location: mir::Location) {
self.super_constant(constant, location);
let ur_cx = &self.unrooted_cx;
if ur_cx.is_unrooted_ty(constant.ty, false) {
ur_cx.late_cx.span_lint(UNROOTED_MUST_ROOT, constant.span, "error visit_constant")
}
}Where ur_cx is like in PR right know. What I mean by "doesn't seem to work" is that it doesn't fail at
fn foo<#[must_root] T>(val: &T) {
bar(val);
}
fn bar<T>(val: T) {}Now everything just mixed up in my head if it goes what I tried to check with visit_constant.
So, do I understand you right, that visit_constant should be enough?
PS this week I focused mainly on this PR postponing all of my university assignments, so I'd like to focus more on them in the first place if this PR requires a lot of additional work.
@nikomatsakis I've run into a problem; I wanted to continue the work, fixed one problem (pointed by jdm), and then started to check what exactly fails in Servo build; so I pulled the latest master, rebased my branch and did mach.bat build -d. It has updated the toolchain and...
1) it broke rustup.exe; everything (file indexer) saw this file, but explorer.exe nor ls/dir commands didn't; chkdsk /f didn't helped too; i fixed it by restarting and then overwriting old file, so the filesystem should be okay; i've reinstalled rustup and it works fine now, but
2) i've got strange error for my custom toolchain (I built it since servo doesn't use nightly with my fix); it is:
> mach.bat build -d
error: unable to hard link fallback exe
info: caused by: Nie można odnaleźć określonego pliku. (os error 2)
Build FAILED in 0:00:02(the foreign text reads "the file cannot be found")
-v doesn't help:$ cargo +stage2 build -v
error: unable to hard link fallback exe
info: caused by: Nie można odnaleźć określonego pliku. (os error 2)
another question:
> mach.bat clean
error: toolchain 'nightly-2018-04-04-x86_64-pc-windows-msvc' does not have the binary `cargo.exe`how can i check if given nightly have some binaries?