Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected closing delimiter from wayland-protocols build script #344

Closed
Michael-F-Bryan opened this issue Aug 28, 2020 · 2 comments
Closed

Comments

@Michael-F-Bryan
Copy link

I've run into a weird issue where the wayland-protocols build script will generate some invalid Rust code. It forgot to add a \n at the end of a doc-comment, so the next block of code doesn't have an opening {.

Annoyingly, I couldn't reproduce this by creating a bare crate that just pulls in wayland-protocols. Instead, I had to add winit which depends on wayland-protocols v0.23.6.

This was found on an Arch Linux machine with the wayland 1.18.0-2 package installed.

Steps to reproduce:

# Compiler versions
$ rustc --version --verbose
rustc 1.48.0-nightly (397b390cc 2020-08-27)
binary: rustc
commit-hash: 397b390cc76ba1d98f80b2a24a371f708dcc9169
commit-date: 2020-08-27
host: x86_64-unknown-linux-gnu
release: 1.48.0-nightly
LLVM version: 11.0
$ cargo --version --verbose
cargo 1.47.0-nightly (51b66125b 2020-08-19)
release: 1.47.0
commit-hash: 51b66125ba97d2906f461b3f4e0408f206299bb6
commit-date: 2020-08-19

# Generate a simple repo with some boilerplate
$ cargo generate --git https://github.com/Michael-F-Bryan/github-template --branch gitlab --name gfx3d
$ cd gfx3d

# Add winit as a dependency
$ cargo add winit
    Updating 'https://github.com/rust-lang/crates.io-index' index
      Adding winit v0.22.2 to dependencies

# Let's have a look around
$ cat Cargo.toml
[package]
name = "gfx3d"
version = "0.1.0"
authors = ["Michael-F-Bryan <michaelfbryan@gmail.com>"]
license = "MIT OR Apache-2.0"
edition = "2018"
[dependencies]
winit = "0.22.2"
$ cat src/lib.rs
#[test]
fn it_works() {
    assert_eq!(2 + 2, 4);
}

$ cargo build
    Updating crates.io index
   Compiling libc v0.2.76
   Compiling cfg-if v0.1.10
   Compiling proc-macro2 v0.4.30
   Compiling autocfg v1.0.1
   Compiling unicode-xid v0.1.0
   Compiling xml-rs v0.8.3
   Compiling bitflags v1.2.1
   Compiling libloading v0.6.3
   Compiling log v0.4.11
   Compiling nix v0.14.1
   Compiling byteorder v1.3.4
   Compiling void v1.0.2
   Compiling slab v0.4.2
   Compiling lazy_static v1.4.0
   Compiling lazycell v1.3.0
   Compiling downcast-rs v1.2.0
   Compiling same-file v1.0.6
   Compiling maybe-uninit v2.0.0
   Compiling pkg-config v0.3.18
   Compiling smallvec v1.4.2
   Compiling scopeguard v1.1.0
   Compiling xdg v2.2.0
   Compiling percent-encoding v2.1.0
   Compiling instant v0.1.6
   Compiling walkdir v2.3.1
   Compiling lock_api v0.3.4
   Compiling num-traits v0.2.12
   Compiling dlib v0.4.2
   Compiling wayland-sys v0.23.6
   Compiling stb_truetype v0.3.1
   Compiling x11-dl v2.18.5
   Compiling quote v0.6.13
   Compiling net2 v0.2.34
   Compiling iovec v0.1.4
   Compiling parking_lot_core v0.7.2
   Compiling memmap v0.7.0
   Compiling raw-window-handle v0.3.3
   Compiling wayland-scanner v0.23.6
   Compiling mio v0.6.22
   Compiling parking_lot v0.10.2
   Compiling approx v0.3.2
   Compiling ordered-float v1.1.0
   Compiling line_drawing v0.7.0
   Compiling rusttype v0.8.3
   Compiling rusttype v0.7.9
   Compiling andrew v0.2.1
   Compiling mio-extras v2.0.6
   Compiling wayland-client v0.23.6
   Compiling wayland-protocols v0.23.6
   Compiling calloop v0.4.4
   Compiling wayland-commons v0.23.6
error: unexpected closing delimiter: `}`
   --> /home/michael/Documents/gfx3d/target/debug/build/wayland-protocols-8add1996975fb452/out/fullscreen-shell-v1_client_api.rs:632:1
    |
624 |         wl_interface {
    |                      - this opening brace...
...
631 |         };
    |         - ...matches this closing brace
632 | }
    | ^

error: aborting due to previous error

error: could not compile `wayland-protocols`.

To learn more, run the command again with --verbose.

This may be related to #291 and rust-windowing/winit#1562.

I've also attached the files generated by the build script, the compiler's verbose output, and a zip with the contents of my repro.

generated.zip
verbose-output.txt
gfx3d.zip

@kchibisov
Copy link
Member

Duplicate of #291

nothing we can do, since rustfmt bug.

@Michael-F-Bryan
Copy link
Author

Ignore me. I didn't read the linked issues properly... A comment mentions it's a rustfmt thing:

This is a rustfmt bug: rust-lang/rustfmt#3988

Disable normalize_doc_attributes = true from veloren's .rustfmt.toml and it'll disapear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants