by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Artur Jamro
    @Mrowqa

    @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?

    (mir dump somehow knows which monomorphized functions we are calling so I looked it up)
    Niko Matsakis
    @nikomatsakis
    @Mrowqa sorry I didn't get back to you last night: we could indeed walk HIR, but it will be tricky to catch everything
    I dont' think there's a "canned" solution for MIR either but it seems a bit easier to do :)
    but yeah I wanted to investigate and remind myself
    where the relevant things are stored
    I believe they would indeed be within a Constant
    note that in HIR you also would have to check Path
    e.g., for things like let x = foo::<T>; x(...)
    I suspect the right path for MIR is to extend MIR visitor somewhat
    we hvae visit_substs
    a "substs" is a list of values for a set of generic parameters
    however, we don't tell you what the substs is for
    we should be supplying a def-id or something
    however, that wouldn't I guess help you that much -- it seems to only be invoked currently for Foo { ... } struct expressions
    I guess the rest are constants
    @Mrowqa what do you mean by "doesn't seem to work"?
    Artur Jamro
    @Mrowqa

    @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.

    Niko Matsakis
    @nikomatsakis
    @Mrowqa argh sorry I forgot to write you back yesterday
    I don't think there's a lot of add'l work, but maybe a medium amount
    let me try to leave a comment on the PR
    Artur Jamro
    @Mrowqa
    @nikomatsakis thanks! I'll read it later and hopefully get to work this weekend :)
    Niko Matsakis
    @nikomatsakis
    @Mrowqa <3
    Artur Jamro
    @Mrowqa
    @nikomatsakis new update to PR has landed :) i have specified the next step and I guess I need to visit Rvalues, check Aggregate variant, and then check against Adt.
    Artur Jamro
    @Mrowqa
    Hm, it isn't Aggregate.
    Artur Jamro
    @Mrowqa
    Looking at the MIR it seems to be move, so the Use variant, but matching it further - it is not a Constant, so it is probably Lvalue - and I don't know where to go further; I'm going sleep soon.
    Artur Jamro
    @Mrowqa
    Move & Copy viarants have place param, but it didn't detected what I wanted :/
            error:  (test) detection
      --> lib.rs:213:19
       |
    18 |     SomeContainer(Foo(3));
       |                   ^^^^^^
       |
       = note: #[deny(unrooted_must_root)] on by default
    Niko Matsakis
    @nikomatsakis
    @Mrowqa I'll take a look :) I'm at this RUst All Hands all week
    so my time is very limited
    Niko Matsakis
    @nikomatsakis
    left a few notes, hope they are helpful
    Artur Jamro
    @Mrowqa
    @nikomatsakis I put an update on the PR.
    BTW Thursday morning I'm going home and I'm not gonna have the access to my dev machine until Wednesday next week.
    Artur Jamro
    @Mrowqa
    @nikomatsakis next update - with new commit :)
    Niko Matsakis
    @nikomatsakis
    @Mrowqa left a comment
    Artur Jamro
    @Mrowqa

    @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")

    i've done clean build of rustc (except rebuilding LLVM) and it didn't help
    same happens for another rust projects and -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)
    Niko Matsakis
    @nikomatsakis
    @Mrowqa huh. I have.. no idea
    Artur Jamro
    @Mrowqa
    do you know if servo should compile with latest nightly?
    Niko Matsakis
    @nikomatsakis
    I do not know
    I mean in principle yes but sometimes there are small adjustments needed
    jdm or others in #servo would prob know better
    Artur Jamro
    @Mrowqa
    jdm is on leave in April
    how can I check since which nightly is my fix available?

    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?

    Niko Matsakis
    @nikomatsakis
    how can I check since which nightly is my fix available?
    when you do rustup it tells you the commit
    so you can look through git log
    I don't know of an easier way
    Artur Jamro
    @Mrowqa
    ok