These are chat archives for rust-lang/rust

29th
May 2017
Sebastian Blei
@iamsebastian
May 29 2017 08:26
Hello.
Can I access another method from a Trait without self instance?
http://play.integer32.com/?gist=7a1cba71ec8dc4fc3b8e0ec580245c94&version=undefined
Aleksey Kladov
@matklad
May 29 2017 08:26
Yep, you need Self (note the capital S).
Sebastian Blei
@iamsebastian
May 29 2017 08:28
Ty. But what's wrong in the Gist then?
Aleksey Kladov
@matklad
May 29 2017 08:28
    fn create()  {
        println!("{}", Self::get_meta());
    }
Sebastian Blei
@iamsebastian
May 29 2017 08:28
Argh.
Monday.
Ty.
Aleksey Kladov
@matklad
May 29 2017 08:29
You need Self::, not Self.f. Note also that create returns Self, so it must call some other non-defalt fn which produces Self.
Sebastian Blei
@iamsebastian
May 29 2017 08:29
Yeah. Just noticed it. Thank you.
Joonas Koivunen
@koivunej
May 29 2017 11:28
hmm really interesting, my app takes 30 seconds to initialize when compiled with --release and is immediate in debug mode (this is not compilation time), using recent-ish a few days old nightly. does this sound like a known bug? currently trying to triangulate this with debug!(...) logging and recompilation which is a bit slow :)
triangulated to let file = std::fs::OpenOptions::new().read(true).open(&self.path).map_err(CustomErrorType)?; CustomErrorType is using error_chain so probably backtrace?
vigneshwer dhinakaran
@dvigneshwer
May 29 2017 11:32
did the ownership/borrowing concept exist/implemeted before Rust? Or is it a new thing?
Aleksey Kladov
@matklad
May 29 2017 11:33
There was Cyclon language which was a major inspiration for this part of Rust.
The move semantics also exists in C++ now, and in general is known as "linear/affine types" in the literature for a long time.
Joonas Koivunen
@koivunej
May 29 2017 11:34
@dvigneshwer i have read an article where it was explained in terms of old C "patterns" but I have been unable to find the same doc again. in C it'd been manually implemented/checked of course
looks like for my problem, the 20s of cpu 100% goes away when turning RUST_BACKTRACE=0, also it'd seem that no backtrace is ever generated..
Aleksey Kladov
@matklad
May 29 2017 11:39
@koivunej ah, I've seen that one!
Joonas Koivunen
@koivunej
May 29 2017 11:40
@matklad does using gold as linker sound familiar as well?
the stacktrace was generated (this time, though I might have just messed up logging it the first by using {} and not {:?})
Aleksey Kladov
@matklad
May 29 2017 11:41
Nope, but there was definitely an issue when running compiler with RUST_BACTRACE was super slow, even for an empy file
rust-lang/rust#37477
Joonas Koivunen
@koivunej
May 29 2017 11:45
hmm a bit similarly time seems to be spent heavily on __rbt_backtrace_alloc
this is on rustc 1.19.0-nightly (5f3966864 2017-05-25) with error_chain 0.8.1, let's try updating to latest nightly
Aleksey Kladov
@matklad
May 29 2017 11:47
Yeah, IIRC the original issue was never really fix: the library used by rustc for allocating stactraces tends to allocate massive amount of information, and now one understands why.
Hm, IIRC, error_chain uses it's own backtrace collecting machinery, and I bet it uses the same underlying library, and is susceptible to the exact same problem! It might be a good idea to rise an issue on error_chain and link to the one from rustc.
Joonas Koivunen
@koivunej
May 29 2017 11:48
oh interesting! this is the first time I've ran into this, so from my point of view this cannot be more than a week old change in somewhere (i have been tracking the latest nightlies for CARGO_INCREMENTAL)
Joonas Koivunen
@koivunej
May 29 2017 11:59
yeah, reproduces with latest nightly as well, only with --release
Joonas Koivunen
@koivunej
May 29 2017 12:18
not sure how to create a minimized example
Joonas Koivunen
@koivunej
May 29 2017 13:04
this seems to happen even if I don't involve error_chain, as in instead of ? just .unwrap(), and I get to watch in slow motion as the functions are found, it's fast up until 9th step, then taking much longer on step 10, rest are fast
the step 10 is
  10: <core::iter::Map<I, F> as core::iter::iterator::Iterator>::next
             at /checkout/src/libcore/result.rs:737
             at src/db/checkpoint.rs:183
             at /checkout/src/libcore/ops.rs:2633
             at /checkout/src/libcore/ops.rs:2731
             at /checkout/src/libcore/option.rs:398
             at /checkout/src/libcore/iter/mod.rs:1065
             at /checkout/src/libcore/iter/mod.rs:1065
Joonas Koivunen
@koivunej
May 29 2017 14:14
same issue with nightly-2017-04-05
AjBreidenbach
@AjBreidenbach
May 29 2017 14:52

does anybody know why the JsonNode type allows indexing with [] but not []=?

that is you can get a field by string, but not with an int

AjBreidenbach
@AjBreidenbach
May 29 2017 15:02
shit wrong language
Fra ns
@snarf95_twitter
May 29 2017 17:35
Lel
Ashley Mannix
@KodrAus
May 29 2017 21:33
@koivunej Oh that's interesting... error-chain uses the backtrace library. I'm stuck on an old version of error-chain until errors are Send again so hopefully I don't get stuck :smile:
Sergey Noskov
@Albibek
May 29 2017 21:37
@KodrAus you can turn backtrace off in features
Ashley Mannix
@KodrAus
May 29 2017 21:41
Sync I mean... @Albibek Yeh that's a reasonable workaround for the way we're holding it. Just expose as a feature and enable when debugging an error