Stream: t-compiler/help

Topic: hello


Welcome Bot (Jan 22 2019 at 16:34, on Zulip):

Welcome to #t-compiler/help.

Description: Questions about hacking on the compiler

Santiago Pastorino (Jan 22 2019 at 16:35, on Zulip):

:clap: :clap: :clap:

Jake Goulding (Jan 22 2019 at 16:41, on Zulip):

me, trolling: "what is a compiler?"

nagisa (Jan 22 2019 at 18:22, on Zulip):

however is /help different from bare stream?

nikomatsakis (Jan 22 2019 at 18:23, on Zulip):

The /help is just part of the stream name

nikomatsakis (Jan 22 2019 at 18:24, on Zulip):

They are otherwise independent

nagisa (Jan 22 2019 at 18:34, on Zulip):

What I meant to ask is what prompted creation of this stream at all

nikomatsakis (Jan 22 2019 at 20:24, on Zulip):

in the steering meeting on 2018.12.14, we decided that this name would help newcomers feel welcome to ask questions

nikomatsakis (Jan 22 2019 at 20:25, on Zulip):

e.g., in and around this comment =)

maksimsco (Feb 15 2019 at 20:21, on Zulip):

Hello
How can I get DefId of a function from std in MIR? Is it appropriate to ask questions like that here?

oli (Feb 15 2019 at 20:25, on Zulip):

@maksimsco This is a good (and appropriate to ask here) question. If the function is a lang item (has a #[lang=foo] attribute), then you can go through tcx.lang_items(), if not, then there's currently no sensible way. What are you trying to achieve?

oli (Feb 15 2019 at 20:26, on Zulip):

There's currently an open PR which may add a way to get arbitrary functions from the libstd for diagnostic purposes: https://github.com/rust-lang/rust/pull/58070#issuecomment-462125065

oli (Feb 15 2019 at 20:26, on Zulip):

nondiagnostic purposes need to make the relevant item a lang item

maksimsco (Feb 15 2019 at 20:40, on Zulip):

@oli Wow, thanks. This is very helpful

maksimsco (Feb 16 2019 at 14:24, on Zulip):

Can someone exaplain a concept in MIR?
I can't understand what rustc::mir::interpret::Scalar is and why it works with Scalar { size: 0, bits: 0 } when constructing tcx.mk_lazy_const to a function?

oli (Feb 16 2019 at 17:24, on Zulip):

@maksimsco a function (not a function pointer) is zero sized. So just like () it doesn't actually have any data. So, the size field is 0, because the number of valid bits in the bits field is zero. You are not allowed to read any of the bits.

oli (Feb 16 2019 at 17:24, on Zulip):

In order to represent such a value in the MIR, we construct a zero sized constant

oli (Feb 16 2019 at 17:25, on Zulip):

similar to how constructing a true literal would give you Scalar { size: 1, bits: 1 } and a false literal would give you Scalar { size: 1, bits: 0 }

maksimsco (Feb 16 2019 at 17:50, on Zulip):

@oli Thank you, very good explanation, got it!

Alexey Melnikov (Feb 18 2019 at 11:24, on Zulip):

Is it possible to use miri as standalone interpreter for independent *.rs files? So, could I run miri hello.rs ?

Alexey Melnikov (Feb 18 2019 at 11:28, on Zulip):

The miri's Github page has a text An experimental interpreter for Rust's mid-level intermediate representation (MIR). It can run binaries. Can miri run binaries?

oli (Feb 18 2019 at 12:03, on Zulip):

Yes, that should in fact work out of the box. If it does not, please open an issue

Alexey Melnikov (Feb 18 2019 at 12:25, on Zulip):

miri simple.rs

warning: unused variable: `y`
 --> simple.rs:3:9
  |
3 |     let y = 3*x + 3;
  |         ^ help: consider prefixing with an underscore: `_y`
  |
  = note: #[warn(unused_variables)] on by default

error[E0080]: constant evaluation error: no mir for `std::rt::lang_start_internal`
   |
   = note: inside call to `std::rt::lang_start::<()>`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0080`.
Alexey Melnikov (Feb 18 2019 at 12:30, on Zulip):

I didn't cargo +nightly miri setup. Should I do this command? What does it mean?

oli (Feb 18 2019 at 12:33, on Zulip):

Yes, you need to do the setup and follow the instructions

oli (Feb 18 2019 at 12:34, on Zulip):

The setup compiles libstd with MIR for every single function in the libstd

oli (Feb 18 2019 at 12:35, on Zulip):

Normally libstd only contains the MIR for functions which are not fully translated to llvm (e.g. generic functions or #[inline] functions)

Alexey Melnikov (Feb 18 2019 at 12:39, on Zulip):

After cargo +nightly miri setup there's the same error.

Alexey Melnikov (Feb 18 2019 at 13:38, on Zulip):

From docs: miri const evaluator. What does it means const? It means that miri evaluate constant (fixed) mir code? Or something else?

oli (Feb 18 2019 at 15:28, on Zulip):

hm, sounds like outdated docs ;)

oli (Feb 18 2019 at 15:28, on Zulip):

is that in the miri-repo?

oli (Feb 18 2019 at 15:28, on Zulip):

or in the rustc docs?

Alexey Melnikov (Feb 18 2019 at 17:14, on Zulip):

An experimental interpreter for Rust's mid-level intermediate representation (MIR). It can run binaries Can miri run binaries? ||| Source: https://github.com/rust-lang/miri/blob/master/README.md , see the first line.

Alexey Melnikov (Feb 18 2019 at 17:19, on Zulip):

Source: https://rust-lang.github.io/rustc-guide/miri.html, please see 26.1 miri const evaluator. What does it means const? It means that miri evaluate constant (fixed) mir code? Or something else?

oli (Feb 18 2019 at 19:16, on Zulip):

ah indeed, that is a misnomer. it's a miri-engine based const evalutor

oli (Feb 18 2019 at 19:16, on Zulip):

not to be confused with miri the tool

Jake Goulding (Feb 19 2019 at 00:09, on Zulip):

Although it's a good idea to start a new Zulip topic for each new... topic...

oli (Feb 19 2019 at 08:22, on Zulip):

If zulip had the ability to mark topics as resolved, that would be much clearer I think

Thomas Mulvaney (Jun 18 2019 at 18:15, on Zulip):

Hi, I've been trying to understand the rust compiler and have noticed a function name which is a bit strange in the hir/map namespace: maybe_body_owned_by_by_hir_id. I suspect the _by_by_ is a typo..?

I could submit a PR but I'm not sure what the etiquette on fixing minor typos such as this is? Open an issue first?

Wesley Wiser (Jun 18 2019 at 18:32, on Zulip):

PRs fixing minor typos are generally well received even without an issue. If fixing the typo requires changing a lot of code, it will be harder to land your PR though.

Thomas Mulvaney (Jun 18 2019 at 18:42, on Zulip):

@Wesley Wiser thanks for the info! I'll open a PR then.

centril (Jun 18 2019 at 21:15, on Zulip):

I think this has already been fixed in a PR

Last update: Nov 11 2019 at 23:00UTC