Stream: t-compiler

Topic: #55806 promotable and borrow checking


pnkfelix (Nov 09 2018 at 10:51, on Zulip):

ping @Oli

oli (Nov 09 2018 at 10:51, on Zulip):

pong

pnkfelix (Nov 09 2018 at 10:52, on Zulip):

I'm trying to understand the semantics you desire and what you believe to be implemented

pnkfelix (Nov 09 2018 at 10:52, on Zulip):

e.g. "will only work if a function call is promoted in the same crate where the rustc_promotable function is declared."

pnkfelix (Nov 09 2018 at 10:52, on Zulip):

but this: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2015&gist=04f9d23f0b4d0f1fcfe8150c92fb4a43

pnkfelix (Nov 09 2018 at 10:52, on Zulip):

does not compile

oli (Nov 09 2018 at 10:53, on Zulip):

I.... what... I have almost the exact same test in the test suite

oli (Nov 09 2018 at 10:53, on Zulip):

lemme check

pnkfelix (Nov 09 2018 at 10:53, on Zulip):

I was actually looking at some tests that I noted failures in last night while reviewing NLL stuff

oli (Nov 09 2018 at 10:54, on Zulip):

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2015&gist=6db68998a74c8c9975358a4787330601 works

oli (Nov 09 2018 at 10:54, on Zulip):

I gotta run in a moment, I'll be back on mobile in 10 minutes

pnkfelix (Nov 09 2018 at 10:54, on Zulip):

wha tthe heck

pnkfelix (Nov 09 2018 at 10:54, on Zulip):

you made it depend on #[stable] attributes ...?

oli (Nov 09 2018 at 10:54, on Zulip):

stability attributes probably

oli (Nov 09 2018 at 10:55, on Zulip):

idk

oli (Nov 09 2018 at 10:55, on Zulip):

it seems

oli (Nov 09 2018 at 10:55, on Zulip):

oh right

pnkfelix (Nov 09 2018 at 10:55, on Zulip):

hah "rustc_promotable attribute must be paired with either stable or unstable attribute"

pnkfelix (Nov 09 2018 at 10:55, on Zulip):

why didn't I get that message earlier?

oli (Nov 09 2018 at 10:55, on Zulip):

#[rustc_promotable] lives inside the stability struct

oli (Nov 09 2018 at 10:55, on Zulip):

brb

pnkfelix (Nov 09 2018 at 10:56, on Zulip):

okay and you don't get the message without #![feature(staged_api)]

pnkfelix (Nov 09 2018 at 10:56, on Zulip):

Probably would be good to just reject the #[rustc_promotable] attribute if staged_api is off.

oli (Nov 09 2018 at 10:59, on Zulip):

Somewhat hard to do I think, but I'll have a look

oli (Nov 09 2018 at 10:59, on Zulip):

The stability parsing system needs an overhaul imo

oli (Nov 09 2018 at 11:01, on Zulip):

I wonder how many other queries only work if invoked and cached from the crate where their items are defined in

pnkfelix (Nov 09 2018 at 11:17, on Zulip):

Somewhat hard to do I think, but I'll have a look

what, the rejection of #[rustc_promotable] ? really? I would think its just a matter of checking the feature settings if we encounter that attribute?

pnkfelix (Nov 09 2018 at 11:26, on Zulip):

I'm now trying to make a unit test for the cross-crate scenario. But that seems to compile fine (once one uses staged_api and what not...)

pnkfelix (Nov 09 2018 at 11:26, on Zulip):

So I'm still a little confused about whether this applies to all cross-crate scenarios, or if its something particular about libstd ...

oli (Nov 09 2018 at 11:35, on Zulip):

I don't see how libstd could be special that way. Did you try it without the const fn feature gate?

pnkfelix (Nov 09 2018 at 11:35, on Zulip):

oh, no

pnkfelix (Nov 09 2018 at 11:35, on Zulip):

let me see about that.

pnkfelix (Nov 09 2018 at 11:36, on Zulip):

so the const_fn feature gate is expected to loosen the rules here?

pnkfelix (Nov 09 2018 at 11:36, on Zulip):

still seems to compile

pnkfelix (Nov 09 2018 at 11:36, on Zulip):

let me show you my current test

pnkfelix (Nov 09 2018 at 11:38, on Zulip):

issue_55806_lib.rs:

#![stable(feature = "unit_test", since="1.0.0")]
#![feature(staged_api, rustc_attrs)]
#![crate_type="lib"]

#[stable(feature = "unit_test", since="1.0.0")]
#[rustc_promotable]
pub const fn bar() -> u8 { 10 }

issue-55806-xc.rs:

extern crate issue_55806_lib;

use issue_55806_lib::bar;

fn main() {
    let _x: &'static _ = &bar();
}
pnkfelix (Nov 09 2018 at 11:38, on Zulip):

Then this command ./build/x86_64-unknown-linux-gnu/stage1/bin/rustc ../../issue_55806_lib.rs && ./build/x86_64-unknown-linux-gnu/stage1/bin/rustc ../../issue-55806-xc.rs --extern issue_55806_lib=./libissue_55806_lib.rlib runs without any error.

pnkfelix (Nov 09 2018 at 11:40, on Zulip):

let me try attaching it to the impl of a type, to see if that makes a difference...

oli (Nov 09 2018 at 11:41, on Zulip):

These tests look correct to me

pnkfelix (Nov 09 2018 at 11:41, on Zulip):

as in, you'd expect them to fail into the same bug category, right?

oli (Nov 09 2018 at 11:42, on Zulip):

Yes

pnkfelix (Nov 09 2018 at 11:42, on Zulip):

I don't know much about how query results are cached. Maybe its something goofy interaction there

oli (Nov 09 2018 at 11:43, on Zulip):

I'm debugging this right now, not sure yet whether the promoted info gets lost or all stab info

oli (Nov 09 2018 at 11:43, on Zulip):

Are we purging stab info for stable items?

pnkfelix (Nov 09 2018 at 11:43, on Zulip):

I dunno

pnkfelix (Nov 09 2018 at 11:44, on Zulip):

Shall I re-assign this bug to you in any case? Do you expect to have much time to debug it today?

oli (Nov 09 2018 at 11:44, on Zulip):

Yes

oli (Nov 09 2018 at 11:44, on Zulip):

In an hour or two

pnkfelix (Nov 09 2018 at 11:44, on Zulip):

(i expect to be going on paternity leave on Tuesday, and will be gone for ~2 weeks, so I'm trying to take care of as much stuff as I can today)

oli (Nov 09 2018 at 11:45, on Zulip):

Don't hesitate to assign things to me to get them off your plate

pnkfelix (Nov 09 2018 at 12:32, on Zulip):

(its mostly boring stuff. I hope!)

oli (Nov 09 2018 at 15:01, on Zulip):

oh no... I don't think the stability attributes are good for being used here. They are inherited down to child items. So a const fn declared inside a rustc_promotable const fn will also be promotable

oli (Nov 09 2018 at 15:02, on Zulip):

this is independent of the issue at hand, but it seems moderately dangerous that we can attach #[rustc_promotable] to modules and everything inside will be promotable

oli (Nov 09 2018 at 15:58, on Zulip):

fun fact: only the inherent methods on builtin ints exhibit this behavior

oli (Nov 09 2018 at 15:58, on Zulip):

all other promotable const fns work

oli (Nov 09 2018 at 16:32, on Zulip):

Ok, so I have circled this in. it gets weird now: when the value is put into the stab_map, it correctly has promotable = true. When I read this stability from another crate, it has all other values the same (like feature = "rustc" and since = "1.0.0"), except promotable` is now false.

oli (Nov 09 2018 at 16:34, on Zulip):

and it's not even related to cross crate

oli (Nov 09 2018 at 16:47, on Zulip):

and... it's only for the unsigned builtin types

oli (Nov 09 2018 at 16:48, on Zulip):

E-too-many-macros

oli (Nov 09 2018 at 16:59, on Zulip):

https://github.com/rust-lang/rust/pull/55828 fixes it with two lines -.-

Last update: Nov 20 2019 at 01:10UTC