These are chat archives for rust-lang/rust

16th
Jan 2018
Bradley Weston
@bweston92
Jan 16 2018 15:14
Steve Klabnik
@steveklabnik
Jan 16 2018 15:14
it's inside the box
Future<Item=(), Error=()> + Send
+ lets you bound by multiple traits
so this says that the thign in the box implments both Future and Send
Bradley Weston
@bweston92
Jan 16 2018 15:15
Ok that sounds fair, the syntax threw me of a bit :p
Steve Klabnik
@steveklabnik
Jan 16 2018 15:15
:)
Bradley Weston
@bweston92
Jan 16 2018 15:16
Thanks :D
Steve Klabnik
@steveklabnik
Jan 16 2018 15:16
no problem :)
Michal 'vorner' Vaner
@vorner
Jan 16 2018 18:57
@nikomatsakis Hello. I'd like to ask about the compiler book you're planning. Has the work already started? If so, where should I go for more details?
Niko Matsakis
@nikomatsakis
Jan 16 2018 19:12
@vorner argh no but I was hoping to create a repo this week -- prob tomorrow
I guess there are still some open questions
well, main one is can we check links somehow
but I liked the idea of creating initially a separate repo
and iterating more rapidly there
Michal 'vorner' Vaner
@vorner
Jan 16 2018 19:14
Ok. I'll keep an eye on the discussion thread for some more info, then :-).
Anyway, what exact links do you want to check? Into generated docs of rustc or somewhere else?
Niko Matsakis
@nikomatsakis
Jan 16 2018 19:15
I'd like to be able to e.g. say "this is handle by the function foo"
and then if foo gets renamed
have the build fail :)
but I think this can wait until the stuff gets merged
might be worth trying to have some conventions though
so we know what is a reference into the compiler source
(even better ish would be some way to display snippets, sort of like GH does, but that can wait)
vorner @vorner will try to come up with idea how to check it at least semi-manually, for now… but can't promise a working solution very soon :-|
Niko Matsakis
@nikomatsakis
Jan 16 2018 19:23
@vorner I think all we really need for now is some sort of convention
but I admit I don't even know what that would be
I really would prefer something mega-lightweight, e.g., my ideal would be that you just write foo and we check that some symbol in the compielr has that name
except that of course we'll want to make "throw-away variables" like x and things
and that's maybe even too weak, though maybe not
Michal 'vorner' Vaner
@vorner
Jan 16 2018 19:26
I'm trying to read the mdbook manual. I was actually thinking about something like foo, just like in normal in-crate documentation, but with the variable to be expanded later on. But I can't find if mdbook could expand variables, maybe not.
Arg, this chat also expands markdown
[`foo`]($COMPILER_DOCS/crate/function.foo.html)
But that's probably quite verbose to be comfortable
Niko Matsakis
@nikomatsakis
Jan 16 2018 19:27
yeah that's my concern
I know I personally won't always make those links :)
nikomatsakis @nikomatsakis lazy
Niko Matsakis
@nikomatsakis
Jan 16 2018 19:28
but I guess it'd be ok to start
@vorner btw, if you are itching to get started =), if I created a repo in rust-lang-nursery, would you be up for taking the initiative to populating it with some dummy stuff?
and/or maybe copying in some of the readmes
Michal 'vorner' Vaner
@vorner
Jan 16 2018 19:32
I could try, but I can't promise when I get the time. I just dropped by to check I haven't missed the start, but it's close to bed time in my time zone and I'm in the middle of a commit somewhere else.
I could try getting to it before the end of the week, hopefully.
Niko Matsakis
@nikomatsakis
Jan 16 2018 19:39
@vorner ok no worries I'll try to do it tomorrow
just wanted to check if you were like "ah I allocated an hour to work on this RIGHT NOW"
Michal 'vorner' Vaner
@vorner
Jan 16 2018 19:41
Heh, no, I have like an infinite TODO list for the occasions when I manage to get a hour somehow. But the compiler book sounds fun, so it might get quite high in that TODO list. Definitely more useful than playing with a crate nobody cares about.
dunnousername
@dunnousername
Jan 16 2018 20:02
Is there any way for a pointer to be initialized as null? Can't you not declare something without giving it a value?
Michal 'vorner' Vaner
@vorner
Jan 16 2018 20:02
You can initialize a pointer to NULL, but pointers are quite rare and you don't want to use them. Most things are not pointers.
What you look for is probably Option, you can initialize it to None.
dunnousername
@dunnousername
Jan 16 2018 20:03
I'm pretty sure I never set any pointer to 0.
Steve Klabnik
@steveklabnik
Jan 16 2018 20:03
std::ptr::null()
dunnousername
@dunnousername
Jan 16 2018 20:03
I have to use pointers, as I'm doing low level stuff like implementing malloc
dunnousername
@dunnousername
Jan 16 2018 20:05
I never use that either; could it be a result of weird scope problems?
dunnousername
@dunnousername
Jan 16 2018 20:33

I'm trying to debug a rust kernel with gdb, but I get

(gdb) bt
#0  0x00000000001028d6 in blog_os::panic_fmt (fm=..., file=..., line=62)
    at src/lib.rs:165
#1  0x000000000010612c in core::panicking::panic_fmt ()
#2  0x0000000000113320 in stack_bottom ()
#3  0x0000000000000001 in ?? ()
#4  0x0000000000000000 in ?? ()

Which doesn't really say much. It seems that it discards the backtrace, clears the stack, and jumps to panic_fmt. Can I make it not do this? Or can I make my panic_fmt display a backtrace? (i.e., can rust code display a backtrace)

I have an assertion that is causing this, can I backtrace assertions?
dunnousername
@dunnousername
Jan 16 2018 21:06
Apparently, when I put a Drop-able type in a raw pointer, it doesn't realize it is being used, and the data gets lost. This Drop-able type calls my free(...) on itself (frees self.ptr) and self.ptr is 0, so a null pointer is freed. My Vec<T> type is a raw pointer to an 'array' of my Box<T> type and a len property that shows the length of the array. I'm not sure if this is the problem, but I don't see free(...) called anywhere else in my code.
Steve Klabnik
@steveklabnik
Jan 16 2018 23:41
yeah, raw pointers don't have ownership
so it's not gonna cal drop when it goes out of scope
dunnousername
@dunnousername
Jan 16 2018 23:44
I'm trying to make core::ops with generics, using bit shifts (assigns) to malloc and free, because why not. Does that even work? The struct itself is not a generic