Stream: t-compiler/wg-nll

Topic: issue-50716


Vytautas Astrauskas (May 28 2018 at 13:54, on Zulip):

@nikomatsakis

I have attempted to fix the issue by adding the following lines:

let trait_ref = ty::TraitRef {
    def_id: tcx.lang_items().sized_trait().unwrap(),
    substs: tcx.mk_substs_trait(place_ty, &[]),
};
self.prove_trait_ref(trait_ref, location);

However, if I try to compile with:

./x.py build --stage 1 --keep-stage 0 -i

I get an ICE:

   Compiling syntax_ext v0.0.0 (file:///home/data/rustfest-paris/rust/src/libsyntax_ext)
error: internal compiler error: broken MIR in NodeId(702427) (""): errors selecting obligation: [FulfillmentError(Obligation(predicate=Binder(TraitPredicate(<[T] as std::marker::Sized>)),depth=1),Unimplemented)]
   --> librustc/ty/mod.rs:591:1
    |
591 | pub struct Slice<T>([T]);
    | ^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

error: Could not compile `rustc`.

Caused by:
  process didn't exit successfully: `/home/data/rustfest-paris/rust/build/bootstrap/debug/rustc

Do you have any idea why it fails while compiling stage 1?

Vytautas Astrauskas (May 28 2018 at 13:54, on Zulip):

Also, is my change at least to the right direction?

nikomatsakis (May 28 2018 at 13:55, on Zulip):

nope :) I mean, it looks like in that case we .. have some value of type [T]... seems ... unexpected to me but maybe I'm forgetting a corner case

nikomatsakis (May 28 2018 at 13:55, on Zulip):

Also, is my change at least to the right direction?

yes, it looks roughly right

nikomatsakis (May 28 2018 at 13:56, on Zulip):

it might be helpful to do -Zdump-mir=all and look for the last file to be dumped

nikomatsakis (May 28 2018 at 13:56, on Zulip):

and/or -Zdump-mir=nll

nikomatsakis (May 28 2018 at 13:56, on Zulip):

these will dump files into a directory mir_dump or dump_mir, something like that

Vytautas Astrauskas (May 28 2018 at 14:00, on Zulip):

If I understand correctly, the code that fails is generated by a procedural macro.

nikomatsakis (May 28 2018 at 14:02, on Zulip):

If I understand correctly, the code that fails is generated by a procedural macro.

sounds plausible, do you have the MIR?

nikomatsakis (May 28 2018 at 14:02, on Zulip):

I had kind of hoped to look at the MIR

Vytautas Astrauskas (May 28 2018 at 14:02, on Zulip):

Compiling…

Fabian Zaiser (May 28 2018 at 14:50, on Zulip):

@nikomatsakis I got his fix to compile and for the example in the issue it outputs this now

error: free region `'a` does not outlive free region `'static`
  --> test.rs:13:13
   |
13 |     let x = *s; // requires 'a: 'static
   |             ^^

error: aborting due to previous error

Which is good, I think?

Vytautas Astrauskas (May 28 2018 at 15:13, on Zulip):

Still fails on my machine. I suspect that my environment is corrupted. I have scheduled a build on my server. I will open a pull request if it succeeds.

nikomatsakis (May 28 2018 at 15:21, on Zulip):

curious

pnkfelix (May 28 2018 at 15:26, on Zulip):

@Vytautas Astrauskas this is with a clean build (nothing in the build/ directory at the outset, and you've removed --keep-stage 0 as well?

pnkfelix (May 28 2018 at 15:27, on Zulip):

(got a face-to-face reponse; the answer is "no, neither of those things were done yet")

Vytautas Astrauskas (May 28 2018 at 19:16, on Zulip):

The build has succeeded on my server (including ./x.py test). I have rebased and opened a pull request: https://github.com/rust-lang/rust/pull/51139

nikomatsakis (Jun 25 2018 at 22:08, on Zulip):

@Vytautas Astrauskas I left a comment about how to fix this issue, let me know what you think

Vytautas Astrauskas (Jun 26 2018 at 09:07, on Zulip):

Thanks! Looking into it.

nikomatsakis (Jun 26 2018 at 10:52, on Zulip):

I proposed the hacky but simple fix :)

Vytautas Astrauskas (Jun 26 2018 at 12:02, on Zulip):

I am working on it. :relaxed:

Vytautas Astrauskas (Jun 26 2018 at 12:10, on Zulip):

By the way, if I understood it correctly, this code

struct Qey<Q: ?Sized>(Q);

is sound just because the constructor is never called (with an argument of an unknown size), am I right?

nikomatsakis (Jun 26 2018 at 12:12, on Zulip):

yes -- basically we prevent constructing an unsized value in the first place

Vytautas Astrauskas (Jun 26 2018 at 12:44, on Zulip):

Ok. Thanks!

Vytautas Astrauskas (Jun 27 2018 at 12:36, on Zulip):

Can anyone advise me where I should put a test file so that when the Rust compiler test suite is run, it would be checked that the program compiles with no errors with both AST and MIR borrow checkers?

nikomatsakis (Jun 27 2018 at 12:48, on Zulip):

if you make a ui test, it will work, because we also do a second run with compare-mode=nll

but if you want to be explicit, you can add something like this to the test:

// revisions: ast mir
#![cfg_attr(mir, feature(nll))]
nikomatsakis (Jun 27 2018 at 12:49, on Zulip):

revisions are explained in the rustc guide

Vytautas Astrauskas (Jun 27 2018 at 12:49, on Zulip):

Thanks!

Vytautas Astrauskas (Jun 27 2018 at 12:49, on Zulip):

I will try.

Vytautas Astrauskas (Jun 27 2018 at 16:23, on Zulip):

@nikomatsakis I have updated the pull request. Please let me know what you think. It passes all tests on my machine. One thing that is strange to me is why the reported spans in some tests changed.

nikomatsakis (Jun 27 2018 at 17:04, on Zulip):

ok

Last update: Nov 21 2019 at 13:10UTC