Stream: t-compiler

Topic: mismatched types in libcore


matthiaskrgr (Jan 24 2020 at 17:34, on Zulip):

Hi, any ideas why ./x.py check works but ./x.py clippy errors while checking libcore:

error[E0308]: mismatched types
   --> src/libcore/macros/mod.rs:418:49
    |
417 | /  macro_rules! write {
418 | |      ($dst:expr, $($arg:tt)*) => ($dst.write_fmt($crate::format_args!($($arg)*)))
    | |                                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | |                                                  |
    | |                                                  expected enum `fmt::rt::v1::Position`, found `usize`
    | |                                                  help: try using a variant of the expected enum: `fmt::rt::v1::Position::At($crate::format_args!($($arg)*))`
    | |                                                  in this macro invocation (#3)
419 | |  }
    | |__- in this expansion of `write!` (#2)
...
792 | /      macro_rules! format_args {
793 | |          ($fmt:expr) => {{ /* compiler built-in */ }};
794 | |          ($fmt:expr, $($args:tt)*) => {{ /* compiler built-in */ }};
795 | |      }
    | |______- in this expansion of `$crate::format_args!` (#3)
    |
   ::: src/libcore/num/bignum.rs:100:1
    |
100 |  / macro_rules! define_bignum {
101 |  |     ($name:ident: type=$ty:ty, n=$n:expr) => {
102 |  |         /// Stack-allocated arbitrary-precision (up to certain limit) integer.
103 |  |         ///
...    |
470 |  |                 write!(f, "{:#x}", self.base[sz - 1])?;
    |  |                 ------------------------------------- in this macro invocation (#2)
...    |
477 |  |     };
478 |  | }
    |  |_- in this expansion of `define_bignum!` (#1)
...
483 |    define_bignum!(Big32x40: type=Digit32, n=40);
    |    --------------------------------------------- in this macro invocation (#1)
simulacrum (Jan 24 2020 at 18:25, on Zulip):

you need to use a beta clippy and pass --cfg=bootstrap

simulacrum (Jan 24 2020 at 18:25, on Zulip):

there was some discussion in Discord I believe

matthiaskrgr (Jan 24 2020 at 23:24, on Zulip):

right, so I can set my default clippy to beta but then the beta-clippy will choke on features that were stabilized on features that were enabled on nightly only
RUSTC_BOOTSTRAP=1 RUSTFLAGS="--cfg=bootstrap" RUST_BACKTRACE=full ./x.py clippy

error[E0658]: use of unstable library feature 'matches_macro'
   --> src/librustc_span/lib.rs:313:9
    |
313 |         matches!(self.ctxt().outer_expn_data().kind, ExpnKind::Macro(MacroKind::Derive, _))
    |         ^^^^^^^
    |
    = note: for more information, see https://github.com/rust-lang/rust/issues/65721
    = help: add `#![feature(matches_macro)]` to the crate attributes to enable
oli (Jan 24 2020 at 23:31, on Zulip):

oh... yea, so it seems like x.py clippy runs with the beta libstd, but it should be using the just-built libstd

oli (Jan 24 2020 at 23:32, on Zulip):

I'm not sure what x.py clippy is doing differntly from x.py check, but it using the downloaded libstd instead of the built libstd would give exactly this kind of problem

simulacrum (Jan 24 2020 at 23:33, on Zulip):

I don't have time to fix x.py clippy I'm afraid nor to really help out much -- even review will be a stretch

simulacrum (Jan 24 2020 at 23:33, on Zulip):

otoh, if it only affects clippy, I'm happy to just merge things in without too close of review

matthiaskrgr (Jan 25 2020 at 09:18, on Zulip):

I tried again with the beta clippy and the bootstrap compiler being the same version now but that didn't help, I still get use of unstable library feature :/

oli (Jan 25 2020 at 09:44, on Zulip):

I don't think you're going to get around fixing x.py to actually give clippy the freshly built libstd

oli (Jan 25 2020 at 09:46, on Zulip):

Although it may be possible to set the sysroot env vars to the correct libstd without touching x.py. check the clippy driver source code for that swash of env vars that allow you to manipulate the sysroot.

matthiaskrgr (Jan 27 2020 at 00:12, on Zulip):

I wonder if something like RUSTFLAGS="--cap-lints warn" RUSTC_WRAPPER="stage2-clippy-driver" ./x.py check could actually work. but it seems I can't simply override the output/target dir mh

simulacrum (Jan 27 2020 at 01:28, on Zulip):

rustc-wrapper is not going to work well with how we do things in rustbuild

simulacrum (Jan 27 2020 at 01:28, on Zulip):

or at least, I suspect it wouldn't

matthiaskrgr (Jan 27 2020 at 10:44, on Zulip):

Hm, I've been using RUSTC_WRAPPER=sccache to successfully bootstrap rustc

simulacrum (Jan 27 2020 at 15:40, on Zulip):

it might work in theory but I think it may fail in unexpected ways (e.g. cache too much)

simulacrum (Jan 27 2020 at 15:40, on Zulip):

since I believe sccache won't know that we're switching compilers under the hood

matthiaskrgr (Jan 31 2020 at 19:40, on Zulip):

looks like the problem was --cfg=bootstrap at last.....

matthiaskrgr (Jan 31 2020 at 19:43, on Zulip):

I found out after accidentally reading https://github.com/rust-lang/rust/pull/68708/files#diff-4d152d5bfb85f6d41ee9a8a7988c1064 , heh

Last update: Feb 25 2020 at 04:15UTC