Skip to content

Improve the "try using a variant of the expected type" hint. - #65562

Merged
bors merged 3 commits into
rust-lang:masterfrom
Patryk27:master
Oct 29, 2019
Merged

Improve the "try using a variant of the expected type" hint.#65562
bors merged 3 commits into
rust-lang:masterfrom
Patryk27:master

Conversation

@Patryk27

@Patryk27Patryk27 commented Oct 18, 2019

Copy link
Copy Markdown
Contributor

Fix#65494.

  • Change type-printing output.
  • Use span_to_snippet when possible.
  • Change the message to try using a variant of the expected enum

@rust-highfive

Copy link
Copy Markdown
Contributor

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @estebank (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 18, 2019
Comment threadsrc/test/ui/qualified/qualified-path-params.stderr Outdated
@estebank

Copy link
Copy Markdown
Contributor

I'm happy with most of it, r=me on those grounds once CI is green. The case I highlighted is correct code, but I liked the readability of the previous version a bit better. It is just a matter of style so it probably doesn't matter.

@estebank

Copy link
Copy Markdown
Contributor

Moving the PR description to this comment, as it otherwise will end up in the merge commit:

Hi,

That's a PR for #65494.

Apart from the type-printing itself, I've also changed the message to try using a variant of the expected enum - this way it seems more logical to me, since the context usually is expected enum %s, found %s. If that's okay, we'd have to update The Book too (ch20-03-graceful-shutdown-and-cleanup.md).

Please let me know what you think,
Thanks.

@rust-highfive

Copy link
Copy Markdown
Contributor

The job x86_64-gnu-llvm-6.0 of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2019-10-18T19:30:44.4770553Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-10-18T19:30:44.4964480Z ##[command]git config gc.auto 0
2019-10-18T19:30:44.5042529Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-10-18T19:30:44.5103106Z ##[command]git config --get-all http.proxy
2019-10-18T19:30:44.5248694Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/65562/merge:refs/remotes/pull/65562/merge
---
2019-10-18T19:36:28.4106959Z Successfully built 1973578ad135
2019-10-18T19:36:28.5236435Z Successfully tagged rust-ci:latest
2019-10-18T19:36:28.5871715Z Built container sha256:1973578ad135133fb298f8d0eabf4954d9524ecf6634e583e4e7456cbb6d6b10
2019-10-18T19:36:28.5890046Z Uploading finished image to https://rust-lang-ci-sccache2.s3.amazonaws.com/docker/590c864a5f2335de0a8287407f9a96030510ec86a676b9b48333a6a037ff1c9ca74007b9ad184866d613750a3d2a1a88c9ad4e657c82d0b1a088ee62c541c4ca
2019-10-18T19:37:27.5213348Z upload failed: - to s3://rust-lang-ci-sccache2/docker/590c864a5f2335de0a8287407f9a96030510ec86a676b9b48333a6a037ff1c9ca74007b9ad184866d613750a3d2a1a88c9ad4e657c82d0b1a088ee62c541c4ca An error occurred (InvalidAccessKeyId) when calling the CreateMultipartUpload operation: The AWS Access Key Id you provided does not exist in our records.
2019-10-18T19:37:28.6114754Z [CI_JOB_NAME=x86_64-gnu-llvm-6.0]
2019-10-18T19:37:28.6147073Z == clock drift check ==
2019-10-18T19:37:28.6157170Z local time: Fri Oct 18 19:37:28 UTC 2019
2019-10-18T19:37:28.7128300Z network time: Fri, 18 Oct 2019 19:37:28 GMT
---
2019-10-18T20:33:33.9377565Z .................................................................................................... 1600/9196
2019-10-18T20:33:38.8774335Z .................................................................................................... 1700/9196
2019-10-18T20:33:51.2130461Z .............................i...............i...................................................... 1800/9196
2019-10-18T20:33:58.3614510Z .................................................................................................... 1900/9196
2019-10-18T20:34:12.1848749Z ...................iiiii............................................................................ 2000/9196
2019-10-18T20:34:22.1707619Z .................................................................................................... 2200/9196
2019-10-18T20:34:24.5348760Z .................................................................................................... 2300/9196
2019-10-18T20:34:29.7947430Z .................................................................................................... 2400/9196
2019-10-18T20:34:51.3298985Z .................................................................................................... 2500/9196
---
2019-10-18T20:37:40.3780002Z ......................i...............i............................................................. 4800/9196
2019-10-18T20:37:51.5918163Z .................................................................................................... 4900/9196
2019-10-18T20:37:57.6008438Z .................................................................................................... 5000/9196
2019-10-18T20:38:07.7048804Z .................................................................................................... 5100/9196
2019-10-18T20:38:13.6485271Z ......................ii.ii......................................................................... 5200/9196
2019-10-18T20:38:23.5693960Z .................................................................................................... 5400/9196
2019-10-18T20:38:33.1651037Z ........................................................................................i........... 5500/9196
2019-10-18T20:38:40.9575082Z .................................................................................................... 5600/9196
2019-10-18T20:38:45.8830916Z .................................................................................................... 5700/9196
2019-10-18T20:38:45.8830916Z .................................................................................................... 5700/9196
2019-10-18T20:38:56.0455093Z .....................................................................................ii...i..ii..... 5800/9196
2019-10-18T20:39:21.5560126Z .................................................................................................... 6000/9196
2019-10-18T20:39:30.7391115Z .................................................................................................... 6100/9196
2019-10-18T20:39:35.9411704Z .................................................................................................... 6200/9196
2019-10-18T20:39:35.9411704Z .................................................................................................... 6200/9196
2019-10-18T20:39:50.3097673Z .......i..ii........................................................................................ 6300/9196
2019-10-18T20:40:08.9052112Z ...................................................................i................................ 6500/9196
2019-10-18T20:40:10.9876625Z .................................................................................................... 6600/9196
2019-10-18T20:40:13.3555929Z .........................................i.......................................................... 6700/9196
2019-10-18T20:40:17.1524660Z .................................................................................................... 6800/9196
---
2019-10-18T20:44:40.7494785Z finished in 5.492
2019-10-18T20:44:40.7680378Z Check compiletest suite=codegen mode=codegen (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-10-18T20:44:40.9488550Z 2019-10-18T20:44:40.9489391Z running 153 tests
2019-10-18T20:44:44.0916020Z i....iii......iii..iiii...i.............................i..i..................i....i...........ii.i. 100/153
2019-10-18T20:44:46.0655048Z i..iiii..............i.........iii.i.........ii......
2019-10-18T20:44:46.0656881Z 2019-10-18T20:44:46.0720561Z finished in 5.298
2019-10-18T20:44:46.0866450Z Check compiletest suite=codegen-units mode=codegen-units (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-10-18T20:44:46.2574366Z ---
2019-10-18T20:44:48.2821454Z finished in 2.197
2019-10-18T20:44:48.2999850Z Check compiletest suite=assembly mode=assembly (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-10-18T20:44:48.4526699Z 2019-10-18T20:44:48.4527098Z running 9 tests
2019-10-18T20:44:48.4528186Z iiiiiiiii
2019-10-18T20:44:48.4528528Z 2019-10-18T20:44:48.4528797Z finished in 0.152
2019-10-18T20:44:48.4715250Z Check compiletest suite=incremental mode=incremental (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-10-18T20:44:49.2235341Z ---
2019-10-18T20:45:06.3220194Z finished in 17.850
2019-10-18T20:45:06.3418827Z Check compiletest suite=debuginfo mode=debuginfo-gdb+lldb (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-10-18T20:45:06.5117758Z 2019-10-18T20:45:06.5117993Z running 123 tests
2019-10-18T20:45:29.8205621Z .iiiii...i.....i..i...i..i.i.i..i.ii..i.i.....i..i....ii..........iiii..........i...ii...i.......ii. 100/123
2019-10-18T20:45:34.3320407Z i.i.i......iii.i.....ii
2019-10-18T20:45:34.3321665Z 2019-10-18T20:45:34.3325324Z finished in 27.990
2019-10-18T20:45:34.3337785Z Uplifting stage1 rustc (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-10-18T20:45:34.3339380Z Copying stage2 rustc from stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
---
2019-10-18T20:52:43.8860987Z 2019-10-18T20:52:43.8863835Z error: pretty-printed source does not match expected source
2019-10-18T20:52:43.8865803Z expected:
2019-10-18T20:52:43.8869680Z ------------------------------------------
2019-10-18T20:52:43.8869741Z #[prelude_import]
2019-10-18T20:52:43.8869780Z use ::std::prelude::v1::*;
2019-10-18T20:52:43.8869817Z #[macro_use]
2019-10-18T20:52:43.8869871Z extern crate std;
2019-10-18T20:52:43.8872339Z // pretty-compare-only
2019-10-18T20:52:43.8872589Z // pretty-mode:hir,typed
2019-10-18T20:52:43.8873453Z // pp-exact:issue-4264.pp
2019-10-18T20:52:43.8873992Z 2019-10-18T20:52:43.8874512Z // #4264 fixed-length vector types
2019-10-18T20:52:43.8874545Z 2019-10-18T20:52:43.8875197Z pub fn foo(_: [i32; (3 as usize)]) ({ } as ())
2019-10-18T20:52:43.8875431Z pub fn bar() ({
2019-10-18T20:52:43.8875431Z pub fn bar() ({
2019-10-18T20:52:43.8875934Z const FOO: usize = ((5 as usize) - (4 as usize) as usize);
2019-10-18T20:52:43.8876142Z let _: [(); (FOO as usize)] = ([(() as ())] as [(); 1]);
2019-10-18T20:52:43.8876181Z 2019-10-18T20:52:43.8876221Z let _: [(); (1 as usize)] = ([(() as ())] as [(); 1]);
2019-10-18T20:52:43.8876301Z let _ =
2019-10-18T20:52:43.8876301Z let _ =
2019-10-18T20:52:43.8876342Z (((&([(1 as i32), (2 as i32), (3 as i32)] as [i32; 3])
2019-10-18T20:52:43.8876385Z as &[i32; 3]) as *const _ as *const [i32; 3]) as
2019-10-18T20:52:43.8876617Z *const [i32; (3 as usize)] as *const [i32; 3]);
2019-10-18T20:52:43.8876709Z 2019-10-18T20:52:43.8876729Z 2019-10-18T20:52:43.8876749Z 2019-10-18T20:52:43.8876791Z 2019-10-18T20:52:43.8876791Z 2019-10-18T20:52:43.8876812Z 2019-10-18T20:52:43.8876832Z 2019-10-18T20:52:43.8876852Z 2019-10-18T20:52:43.8876872Z 2019-10-18T20:52:43.8876928Z ((::alloc::fmt::format as
2019-10-18T20:52:43.8877664Z for<'r> fn(std::fmt::Arguments<'r>) -> std::string::String {std::fmt::format})(((<::core::fmt::Arguments>::new_v1
2019-10-18T20:52:43.8877739Z as
2019-10-18T20:52:43.8878528Z fn(&[&str], &[std::fmt::ArgumentV1<'_>]) -> std::fmt::Arguments<'_> {std::fmt::Arguments::<'_>::new_v1})((&([("test"
2019-10-18T20:52:43.8879873Z &'static str)]
2019-10-18T20:52:43.8879966Z as
2019-10-18T20:52:43.8879966Z as
2019-10-18T20:52:43.8880060Z [&str; 1])
2019-10-18T20:52:43.8880155Z as
2019-10-18T20:52:43.8880392Z &[&str; 1]),
2019-10-18T20:52:43.8880481Z (&(match (()
2019-10-18T20:52:43.8880928Z ())
2019-10-18T20:52:43.8881735Z {
2019-10-18T20:52:43.8881845Z ()
2019-10-18T20:52:43.8882070Z =>
2019-10-18T20:52:43.8882070Z =>
2019-10-18T20:52:43.8882180Z ([]
2019-10-18T20:52:43.8882267Z as
2019-10-18T20:52:43.8883241Z [std::fmt::ArgumentV1<'_>; 0]),
2019-10-18T20:52:43.8883948Z as
2019-10-18T20:52:43.8883948Z as
2019-10-18T20:52:43.8885020Z [std::fmt::ArgumentV1<'_>; 0])
2019-10-18T20:52:43.8885400Z as
2019-10-18T20:52:43.8886179Z &[std::fmt::ArgumentV1<'_>; 0]))
2019-10-18T20:52:43.8886783Z std::fmt::Arguments<'_>))
2019-10-18T20:52:43.8886835Z as std::string::String);
2019-10-18T20:52:43.8886835Z as std::string::String);
2019-10-18T20:52:43.8886891Z } as ())
2019-10-18T20:52:43.8886928Z pub type Foo = [i32; (3 as usize)];
2019-10-18T20:52:43.8886963Z pub struct Bar {
2019-10-18T20:52:43.8887020Z pub x: [i32; (3 as usize)],
2019-10-18T20:52:43.8887053Z }
2019-10-18T20:52:43.8887089Z pub struct TupleBar([i32; (4 as usize)]);
2019-10-18T20:52:43.8887127Z pub enum Baz { BazVariant([i32; (5 as usize)]), }
2019-10-18T20:52:43.8887352Z pub fn id<T>(x: T) -> T ({ (x as T) } as T)
2019-10-18T20:52:43.8887394Z pub fn use_id() ({
2019-10-18T20:52:43.8887430Z let _ =
2019-10-18T20:52:43.8887489Z ((id::<[i32; (3 as usize)]> as
2019-10-18T20:52:43.8887715Z fn([i32; 3]) -> [i32; 3] {id::<[i32; 3]>})(([(1
2019-10-18T20:52:43.8887964Z i32),
2019-10-18T20:52:43.8888008Z (2
2019-10-18T20:52:43.8888051Z as
2019-10-18T20:52:43.8888112Z i32),
2019-10-18T20:52:43.8888112Z i32),
2019-10-18T20:52:43.8888155Z (3
2019-10-18T20:52:43.8888198Z as
2019-10-18T20:52:43.8888260Z i32)]
2019-10-18T20:52:43.8888302Z as
2019-10-18T20:52:43.8888357Z [i32; 3]))
2019-10-18T20:52:43.8888415Z as [i32; 3]);
2019-10-18T20:52:43.8888451Z } as ())
2019-10-18T20:52:43.8888486Z fn main() ({ } as ())
2019-10-18T20:52:43.8889006Z ------------------------------------------
2019-10-18T20:52:43.8889054Z actual:
2019-10-18T20:52:43.8889666Z ------------------------------------------
2019-10-18T20:52:43.8889666Z ------------------------------------------
2019-10-18T20:52:43.8890341Z #[prelude_import]
2019-10-18T20:52:43.8890404Z use ::std::prelude::v1::*;
2019-10-18T20:52:43.8890438Z #[macro_use]
2019-10-18T20:52:43.8890497Z extern crate std;
2019-10-18T20:52:43.8890919Z // pretty-compare-only
2019-10-18T20:52:43.8891865Z // pretty-mode:hir,typed
2019-10-18T20:52:43.8892121Z // pp-exact:issue-4264.pp
2019-10-18T20:52:43.8892500Z 2019-10-18T20:52:43.8893162Z // #4264 fixed-length vector types
2019-10-18T20:52:43.8893211Z 2019-10-18T20:52:43.8893258Z pub fn foo(_: [i32; (3 as usize)]) ({ } as ())
2019-10-18T20:52:43.8893524Z pub fn bar() ({
2019-10-18T20:52:43.8893524Z pub fn bar() ({
2019-10-18T20:52:43.8893892Z const FOO: usize = ((5 as usize) - (4 as usize) as usize);
2019-10-18T20:52:43.8893974Z let _: [(); (FOO as usize)] = ([(() as ())] as [(); 1]);
2019-10-18T20:52:43.8894006Z 2019-10-18T20:52:43.8894053Z let _: [(); (1 as usize)] = ([(() as ())] as [(); 1]);
2019-10-18T20:52:43.8894143Z let _ =
2019-10-18T20:52:43.8894143Z let _ =
2019-10-18T20:52:43.8894192Z (((&([(1 as i32), (2 as i32), (3 as i32)] as [i32; 3])
2019-10-18T20:52:43.8894244Z as &[i32; 3]) as *const _ as *const [i32; 3]) as
2019-10-18T20:52:43.8894313Z *const [i32; (3 as usize)] as *const [i32; 3]);
2019-10-18T20:52:43.8894369Z 2019-10-18T20:52:43.8894395Z 2019-10-18T20:52:43.8894420Z 2019-10-18T20:52:43.8894445Z 2019-10-18T20:52:43.8894445Z 2019-10-18T20:52:43.8894497Z 2019-10-18T20:52:43.8894522Z 2019-10-18T20:52:43.8894554Z 2019-10-18T20:52:43.8894579Z 2019-10-18T20:52:43.8894622Z ((::alloc::fmt::format as
2019-10-18T20:52:43.8895429Z for<'r> fn(std::fmt::Arguments<'r>) -> std::string::String {std::fmt::format})(((::core::fmt::Arguments::new_v1
2019-10-18T20:52:43.8895486Z as
2019-10-18T20:52:43.8896002Z fn(&[&str], &[std::fmt::ArgumentV1<'_>]) -> std::fmt::Arguments<'_> {std::fmt::Arguments::<'_>::new_v1})((&([("test"
2019-10-18T20:52:43.8896429Z &'static str)]
2019-10-18T20:52:43.8896612Z as
2019-10-18T20:52:43.8896612Z as
2019-10-18T20:52:43.8896677Z [&str; 1])
2019-10-18T20:52:43.8896762Z as
2019-10-18T20:52:43.8896832Z &[&str; 1]),
2019-10-18T20:52:43.8896919Z (&(match (()
2019-10-18T20:52:43.8897066Z ())
2019-10-18T20:52:43.8897180Z {
2019-10-18T20:52:43.8897257Z ()
2019-10-18T20:52:43.8897338Z =>
2019-10-18T20:52:43.8897338Z =>
2019-10-18T20:52:43.8897404Z ([]
2019-10-18T20:52:43.8897491Z as
2019-10-18T20:52:43.8897901Z [std::fmt::ArgumentV1<'_>; 0]),
2019-10-18T20:52:43.8898062Z as
2019-10-18T20:52:43.8898062Z as
2019-10-18T20:52:43.8898464Z [std::fmt::ArgumentV1<'_>; 0])
2019-10-18T20:52:43.8898617Z as
2019-10-18T20:52:43.8899031Z &[std::fmt::ArgumentV1<'_>; 0]))
2019-10-18T20:52:43.8899383Z std::fmt::Arguments<'_>))
2019-10-18T20:52:43.8899446Z as std::string::String);
2019-10-18T20:52:43.8899446Z as std::string::String);
2019-10-18T20:52:43.8899483Z } as ())
2019-10-18T20:52:43.8899537Z pub type Foo = [i32; (3 as usize)];
2019-10-18T20:52:43.8899574Z pub struct Bar {
2019-10-18T20:52:43.8899609Z pub x: [i32; (3 as usize)],
2019-10-18T20:52:43.8899660Z }
2019-10-18T20:52:43.8899695Z pub struct TupleBar([i32; (4 as usize)]);
2019-10-18T20:52:43.8899734Z pub enum Baz { BazVariant([i32; (5 as usize)]), }
2019-10-18T20:52:43.8899936Z pub fn id<T>(x: T) -> T ({ (x as T) } as T)
2019-10-18T20:52:43.8899997Z pub fn use_id() ({
2019-10-18T20:52:43.8900032Z let _ =
2019-10-18T20:52:43.8900071Z ((id::<[i32; (3 as usize)]> as
2019-10-18T20:52:43.8900743Z fn([i32; 3]) -> [i32; 3] {id::<[i32; 3]>})(([(1
2019-10-18T20:52:43.8901640Z i32),
2019-10-18T20:52:43.8901790Z (2
2019-10-18T20:52:43.8901845Z as
2019-10-18T20:52:43.8901899Z i32),
2019-10-18T20:52:43.8901899Z i32),
2019-10-18T20:52:43.8901970Z (3
2019-10-18T20:52:43.8902161Z as
2019-10-18T20:52:43.8902229Z i32)]
2019-10-18T20:52:43.8902465Z as
2019-10-18T20:52:43.8902523Z [i32; 3]))
2019-10-18T20:52:43.8902573Z as [i32; 3]);
2019-10-18T20:52:43.8902659Z } as ())
2019-10-18T20:52:43.8902997Z fn main() ({ } as ())
2019-10-18T20:52:43.8903372Z ------------------------------------------
2019-10-18T20:52:43.8903430Z 2019-10-18T20:52:43.8903456Z 2019-10-18T20:52:43.8903456Z 2019-10-18T20:52:43.8922686Z [ERROR compiletest::runtest] fatal error, panic: "pretty-printed source does not match expected source\nexpected:\n------------------------------------------\n#[prelude_import]\nuse ::std::prelude::v1::*;\n#[macro_use]\nextern crate std;\n// pretty-compare-only\n// pretty-mode:hir,typed\n// pp-exact:issue-4264.pp\n\n// #4264 fixed-length vector types\n\npub fn foo(_: [i32; (3 as usize)]) ({ } as ())\n\npub fn bar() ({\n const FOO: usize = ((5 as usize) - (4 as usize) as usize);\n let _: [(); (FOO as usize)] = ([(() as ())] as [(); 1]);\n\n let _: [(); (1 as usize)] = ([(() as ())] as [(); 1]);\n\n let _ =\n (((&([(1 as i32), (2 as i32), (3 as i32)] as [i32; 3])\n as &[i32; 3]) as *const _ as *const [i32; 3]) as\n *const [i32; (3 as usize)] as *const [i32; 3]);\n\n\n\n\n\n\n\n\n\n ((::alloc::fmt::format as\n for<\'r> fn(std::fmt::Arguments<\'r>) -> std::string::String {std::fmt::format})(((<::core::fmt::Arguments>::new_v1\n as\n fn(&[&str], &[std::fmt::ArgumentV1<\'_>]) -> std::fmt::Arguments<\'_> {std::fmt::Arguments::<\'_>::new_v1})((&([(\"test\"\n as\n &\'static str)]\n as\n [&str; 1])\n as\n &[&str; 1]),\n (&(match (()\n as\n ())\n {\n ()\n =>\n ([]\n as\n [std::fmt::ArgumentV1<\'_>; 0]),\n }\n as\n [std::fmt::ArgumentV1<\'_>; 0])\n as\n &[std::fmt::ArgumentV1<\'_>; 0]))\n as\n std::fmt::Arguments<\'_>))\n as std::string::String);\n } as ())\npub type Foo = [i32; (3 as usize)];\npub struct Bar {\n pub x: [i32; (3 as usize)],\n}\npub struct TupleBar([i32; (4 as usize)]);\npub enum Baz { BazVariant([i32; (5 as usize)]), }\npub fn id<T>(x: T) -> T ({ (x as T) } as T)\npub fn use_id() ({\n let _ =\n ((id::<[i32; (3 as usize)]> as\n fn([i32; 3]) -> [i32; 3] {id::<[i32; 3]>})(([(1\n as\n i32),\n (2\n as\n i32),\n (3\n as\n i32)]\n as\n [i32; 3]))\n as [i32; 3]);\n } as ())\nfn main() ({ } as ())\n\n------------------------------------------\nactual:\n------------------------------------------\n#[prelude_import]\nuse ::std::prelude::v1::*;\n#[macro_use]\nextern crate std;\n// pretty-compare-only\n// pretty-mode:hir,typed\n// pp-exact:issue-4264.pp\n\n// #4264 fixed-length vector types\n\npub fn foo(_: [i32; (3 as usize)]) ({ } as ())\n\npub fn bar() ({\n const FOO: usize = ((5 as usize) - (4 as usize) as usize);\n let _: [(); (FOO as usize)] = ([(() as ())] as [(); 1]);\n\n let _: [(); (1 as usize)] = ([(() as ())] as [(); 1]);\n\n let _ =\n (((&([(1 as i32), (2 as i32), (3 as i32)] as [i32; 3])\n as &[i32; 3]) as *const _ as *const [i32; 3]) as\n *const [i32; (3 as usize)] as *const [i32; 3]);\n\n\n\n\n\n\n\n\n\n ((::alloc::fmt::format as\n for<\'r> fn(std::fmt::Arguments<\'r>) -> std::string::String {std::fmt::format})(((::core::fmt::Arguments::new_v1\n as\n fn(&[&str], &[std::fmt::ArgumentV1<\'_>]) -> std::fmt::Arguments<\'_> {std::fmt::Arguments::<\'_>::new_v1})((&([(\"test\"\n as\n &\'static str)]\n as\n [&str; 1])\n as\n &[&str; 1]),\n (&(match (()\n as\n ())\n {\n ()\n =>\n ([]\n as\n [std::fmt::ArgumentV1<\'_>; 0]),\n }\n as\n [std::fmt::ArgumentV1<\'_>; 0])\n as\n &[std::fmt::ArgumentV1<\'_>; 0]))\n as\n std::fmt::Arguments<\'_>))\n as std::string::String);\n } as ())\npub type Foo = [i32; (3 as usize)];\npub struct Bar {\n pub x: [i32; (3 as usize)],\n}\npub struct TupleBar([i32; (4 as usize)]);\npub enum Baz { BazVariant([i32; (5 as usize)]), }\npub fn id<T>(x: T) -> T ({ (x as T) } as T)\npub fn use_id() ({\n let _ =\n ((id::<[i32; (3 as usize)]> as\n fn([i32; 3]) -> [i32; 3] {id::<[i32; 3]>})(([(1\n as\n i32),\n (2\n as\n i32),\n (3\n as\n i32)]\n as\n [i32; 3]))\n as [i32; 3]);\n } as ())\nfn main() ({ } as ())\n\n------------------------------------------\n\n"
2019-10-18T20:52:43.8926517Z thread '[pretty] pretty/issue-4264.rs' panicked at 'fatal error', src/tools/compiletest/src/runtest.rs:2262:9
2019-10-18T20:52:43.8926629Z 2019-10-18T20:52:43.8926650Z 2019-10-18T20:52:43.8926683Z failures:
2019-10-18T20:52:43.8926892Z [pretty] pretty/issue-4264.rs
2019-10-18T20:52:43.8926892Z [pretty] pretty/issue-4264.rs
2019-10-18T20:52:43.8926920Z 2019-10-18T20:52:43.8927204Z test result: FAILED. 54 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out
2019-10-18T20:52:43.8927255Z 2019-10-18T20:52:43.8927483Z thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:537:22
2019-10-18T20:52:43.8927533Z 2019-10-18T20:52:43.8927553Z 2019-10-18T20:52:43.8928811Z command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/pretty" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/pretty" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "pretty" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-6.0/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "6.0.0\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
2019-10-18T20:52:43.8929123Z 2019-10-18T20:52:43.8929164Z 2019-10-18T20:52:43.8929202Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
2019-10-18T20:52:43.8929243Z Build completed unsuccessfully in 1:11:46
2019-10-18T20:52:43.8929243Z Build completed unsuccessfully in 1:11:46
2019-10-18T20:52:43.8959372Z == clock drift check ==
2019-10-18T20:52:43.8971376Z local time: Fri Oct 18 20:52:43 UTC 2019
2019-10-18T20:52:44.1732838Z network time: Fri, 18 Oct 2019 20:52:44 GMT
2019-10-18T20:52:44.1738036Z == end clock drift check ==
2019-10-18T20:52:47.1623602Z 2019-10-18T20:52:47.1788655Z ##[error]Bash exited with code '1'.
2019-10-18T20:52:47.1841308Z ##[section]Starting: Checkout
2019-10-18T20:52:47.1846218Z ==============================================================================
2019-10-18T20:52:47.1846329Z Task : Get sources
2019-10-18T20:52:47.1846392Z Description : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@JohnCSimon

Copy link
Copy Markdown

Ping from triage.
@Patryk27 can you please the changes @estebank has suggested, also the build is failing.
Setting this to waiting on author
Thanks.

@JohnCSimonJohnCSimon added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 26, 2019
@Patryk27

Copy link
Copy Markdown
ContributorAuthor

Hi,

Thanks for the ping - I was actually waiting for response from @estebank or @Centril (the I could try to improve it, so that additional parentheses are added for ... message in discussion above) and I didn't want to be insistent.

I fixed the tests for now, but left the behaviour unchanged - please let me know if that's okay :-)

@bors

bors commented Oct 26, 2019

Copy link
Copy Markdown
Collaborator

☔ The latest upstream changes (presumably #65845) made this pull request unmergeable. Please resolve the merge conflicts.

@estebank

Copy link
Copy Markdown
Contributor

You will have to rebase against latest master :)

@Patryk27

Copy link
Copy Markdown
ContributorAuthor

Yay!

@estebank

Copy link
Copy Markdown
Contributor

@bors r+

@bors

bors commented Oct 27, 2019

Copy link
Copy Markdown
Collaborator

📌 Commit 1c5d0be has been approved by estebank

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 27, 2019
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Oct 28, 2019
Improve the "try using a variant of the expected type" hint.
Fixrust-lang#65494.
- Change type-printing output.
- Use `span_to_snippet` when possible.
- Change the message to `try using a variant of the expected enum`
@JohnTitorJohnTitor mentioned this pull request Oct 28, 2019
@bors

bors commented Oct 28, 2019

Copy link
Copy Markdown
Collaborator

☔ The latest upstream changes (presumably #65421) made this pull request unmergeable. Please resolve the merge conflicts.

@borsbors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Oct 28, 2019
@Patryk27

Copy link
Copy Markdown
ContributorAuthor

Hi,

I've rebased the changes.

@estebank

Copy link
Copy Markdown
Contributor

@bors r+

@bors

bors commented Oct 28, 2019

Copy link
Copy Markdown
Collaborator

📌 Commit 5c023d6 has been approved by estebank

@borsbors removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Oct 28, 2019
@borsbors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Oct 28, 2019
Centril added a commit to Centril/rust that referenced this pull request Oct 29, 2019
Improve the "try using a variant of the expected type" hint.
Fixrust-lang#65494.
- Change type-printing output.
- Use `span_to_snippet` when possible.
- Change the message to `try using a variant of the expected enum`
@CentrilCentril mentioned this pull request Oct 29, 2019
Centril added a commit to Centril/rust that referenced this pull request Oct 29, 2019
Improve the "try using a variant of the expected type" hint.
Fixrust-lang#65494.
- Change type-printing output.
- Use `span_to_snippet` when possible.
- Change the message to `try using a variant of the expected enum`
@CentrilCentril mentioned this pull request Oct 29, 2019
Centril added a commit to Centril/rust that referenced this pull request Oct 29, 2019
Improve the "try using a variant of the expected type" hint.
Fixrust-lang#65494.
- Change type-printing output.
- Use `span_to_snippet` when possible.
- Change the message to `try using a variant of the expected enum`
@CentrilCentril mentioned this pull request Oct 29, 2019
bors added a commit that referenced this pull request Oct 29, 2019
Rollup of 5 pull requests
Successful merges:
- #65294 (Lint ignored `#[inline]` on function prototypes)
- #65318 (Call out the types that are non local on E0117)
- #65531 (Update backtrace to 0.3.40)
- #65562 (Improve the "try using a variant of the expected type" hint.)
- #65809 (Add new EFIAPI ABI)
Failed merges:
r? @ghost
@bors
bors merged commit 5c023d6 into rust-lang:masterOct 29, 2019
@bors

bors commented Oct 29, 2019

Copy link
Copy Markdown
Collaborator

☔ The latest upstream changes (presumably #65919) made this pull request unmergeable. Please resolve the merge conflicts.

@borsbors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Oct 29, 2019
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-authorStatus: This is awaiting some action (such as code changes or more information) from the author.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"try using a variant of the expected type" suggesting a peculiar syntax

6 participants

@Patryk27@rust-highfive@estebank@JohnCSimon@bors@Centril