I tried this code:
[package]
name = "repro"
version = "0.1.0"
edition = "2018"
[dependencies]
quote = "=1.0.3"
use quote::quote;
pub fn repro() {
let many = [1, 2, 3];
let _together = quote! {
#(#many),*
};
}
I think this is a basic and common usage of the quote crate.
I expected to see no warnings:
% RUSTFLAGS=-Dwarnings cargo +nightly-2020-04-04 build
Finished dev [unoptimized + debuginfo] target(s) in 0.01s
% RUSTFLAGS=-Dwarnings cargo +nightly-2020-04-04 doc
Documenting repro v0.1.0 (/private/tmp/repro)
Finished dev [unoptimized + debuginfo] target(s) in 0.82s
Instead, warnings are generated (and my CI build fails due to the deny):
% RUSTFLAGS=-Dwarnings cargo +nightly-2020-04-04 build
Finished dev [unoptimized + debuginfo] target(s) in 0.01s
% RUSTFLAGS=-Dwarnings cargo +nightly-2020-04-04 doc
Documenting repro v0.1.0 (/private/tmp/repro)
warning: unnecessary braces around block return value
|
= note: `#[warn(unused_braces)]` on by default
Finished dev [unoptimized + debuginfo] target(s) in 0.82s
Note that the warning only appears when running rustdoc.
rustc +nightly-2020-04-04 --version --verbose:
rustc 1.44.0-nightly (74bd074ee 2020-04-03)
binary: rustc
commit-hash: 74bd074eefcf4915c73d1ab91bc90859664729e6
commit-date: 2020-04-03
host: x86_64-apple-darwin
release: 1.44.0-nightly
LLVM version: 9.0
/cc @lcnr
Note that the warning only appears when running rustdoc.
Hang on, could this be because of the transformation rustdoc uses (AFAIK) that replaces fn bodies with loop {}?
Simplified repro source, both inner blocks are necessary for some reason:
pub fn repro() {
{
{
use std;
}
}
}
@Nemo157 My guess it's because {{}} is basically {()} - the outer block has the inner block as its final expression. Curious that this is rustdoc-specific.
I just hit a similar error message in rustc (not rustdoc). Unused braces lint with no span or other information. I don't have a reproducer currently, since it's from a big crate and I don't have much to go by.
I'm getting unnescessary braces around block return value from check/clippy
warning: unnecessary braces around block return value
--> src/models/user.rs:137:63
|
137 | fn ticket(&self, context : &SharedContext) -> Option<Ticket> { self.get_ticket(context) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove these braces
Is this related or should I create a new issue?
Using Nightly 1.44.0 2020-04-16
@grantperry is this inside a macro?
@lcnr yes it is. Sounds like it's something you already know about?
If you are using a proc macro using quote then this should be the same issue afaict
I tried to fix this by checking if the surrounding expression comes from an expansion, but this didn't actually fix this. :thinking: @matklad do you have an idea/can this be fixed in quote?
My approach stilled warned for the following, which seems to be the same issue afaict.
I don't think I am familiar with the code in question @lcnr
Sorry, mb :sweat: meant @dtolnay as he is the owner of quote.
Labeling regression-from-stable-to-nightly. I would consider accepting a workaround in quote if somebody who is not me sends a PR and it is a very simple fix, but really this needs to be fixed in rustdoc / rustc.
Let鈥檚 try to find the cause of the regression
@rustbot ping cleanup
Error: Only Rust team members can ping teams.
Please let @rust-lang/release know if you're having trouble with this bot.
@rustbot ping cleanup
Hey Cleanup Crew ICE-breakers! This bug has been identified as a good
"Cleanup ICE-breaking candidate". In case it's useful, here are some
[instructions] for tackling these sorts of bugs. Maybe take a look?
Thanks! <3
cc @AminArria @chrissimpkins @contrun @DutchGhost @elshize @ethanboxx @h-michael @HallerPatrick @hdhoang @hellow554 @imtsuki @jakevossen5 @kanru @KarlK90 @LeSeulArtichaut @MAdrianMattocks @matheus-consoli @mental32 @nmccarty @Noah-Kennedy @pard68 @PeytonT @pierreN @Redblueflame @RobbieClarken @RobertoSnap @robjtede @SarthakSingh31 @senden9 @shekohex @sinato @spastorino @turboladen @woshilapin @yerke
searched nightlies: from nightly-2020-03-29 to nightly-2020-04-05
regressed nightly: nightly-2020-04-02
searched commits: from https://github.com/rust-lang/rust/commit/a5b09d35473615e7142f5570f5c5fad0caf68bd2 to https://github.com/rust-lang/rust/commit/76b11980ad416c3ad6143504c2277757ecacf9b5
regressed commit: https://github.com/rust-lang/rust/commit/58dd1ce8383aaebcad9b6027b89a316fd868b35c
I guess the PR would be #70081
I'm sorry, that was my bad for not including that information in the original comment. We already knew the cause of the regression (found in #70717), and the author of the regression is already aware (@lcnr) of the issue, but not yet a fix.
Assigning P-medium as discussed as part of the Prioritization Working Group process and removing I-prioritize.