Skip to content

Regression: duplicate messages appear in --error-format=json #106571

@dtolnay

Description

@dtolnay
Member
# Cargo.toml

[package]
name = "repro"
version = "0.0.0"
edition = "2021"

[lib]
proc-macro = true
// src/main.rs

repro::repro!();

fn main() {}
// src/lib.rs

use proc_macro::{Delimiter, Group, Ident, Punct, Spacing, Span, TokenStream, TokenTree};

#[proc_macro]
pub fn repro(_input: TokenStream) -> TokenStream {
    TokenStream::from_iter([
        // fn f<T: Sized>() {}
        TokenTree::Ident(Ident::new("fn", Span::call_site())),
        TokenTree::Ident(Ident::new("f", Span::call_site())),
        TokenTree::Punct(Punct::new('<', Spacing::Alone)),
        TokenTree::Ident(Ident::new("T", Span::call_site())),
        TokenTree::Punct(Punct::new(':', Spacing::Alone)),
        TokenTree::Ident(Ident::new("Sized", Span::call_site())),
        TokenTree::Punct(Punct::new('>', Spacing::Alone)),
        TokenTree::Group(Group::new(Delimiter::Parenthesis, TokenStream::new())),
        TokenTree::Group(Group::new(Delimiter::Brace, TokenStream::new())),
        // fn g() { f::<str>() }
        TokenTree::Ident(Ident::new("fn", Span::call_site())),
        TokenTree::Ident(Ident::new("g", Span::call_site())),
        TokenTree::Group(Group::new(Delimiter::Parenthesis, TokenStream::new())),
        TokenTree::Group(Group::new(
            Delimiter::Brace,
            TokenStream::from_iter([
                TokenTree::Ident(Ident::new("f", Span::call_site())),
                TokenTree::Punct(Punct::new(':', Spacing::Joint)),
                TokenTree::Punct(Punct::new(':', Spacing::Alone)),
                TokenTree::Punct(Punct::new('<', Spacing::Alone)),
                TokenTree::Ident(Ident::new("str", Span::call_site())),
                TokenTree::Punct(Punct::new('>', Spacing::Alone)),
                TokenTree::Group(Group::new(Delimiter::Parenthesis, TokenStream::new())),
            ]),
        )),
        // fn h() { f::<str>() }
        TokenTree::Ident(Ident::new("fn", Span::call_site())),
        TokenTree::Ident(Ident::new("h", Span::call_site())),
        TokenTree::Group(Group::new(Delimiter::Parenthesis, TokenStream::new())),
        TokenTree::Group(Group::new(
            Delimiter::Brace,
            TokenStream::from_iter([
                TokenTree::Ident(Ident::new("f", Span::call_site())),
                TokenTree::Punct(Punct::new(':', Spacing::Joint)),
                TokenTree::Punct(Punct::new(':', Spacing::Alone)),
                TokenTree::Punct(Punct::new('<', Spacing::Alone)),
                TokenTree::Ident(Ident::new("str", Span::call_site())),
                TokenTree::Punct(Punct::new('>', Spacing::Alone)),
                TokenTree::Group(Group::new(Delimiter::Parenthesis, TokenStream::new())),
            ]),
        )),
    ])
}
$ cargo clean; cargo +nightly-2023-01-02 check --message-format=json
{"reason":"compiler-artifact","package_id":"repro 0.0.0 (path+file:///git/repro)","manifest_path":"/git/repro/Cargo.toml","target":{"kind":["proc-macro"],"crate_types":["proc-macro"],"name":"repro","src_path":"/git/repro/src/lib.rs","edition":"2021","doc":true,"doctest":true,"test":true},"profile":{"opt_level":"0","debuginfo":2,"debug_assertions":true,"overflow_checks":true,"test":false},"features":[],"filenames":["/git/repro/target/debug/deps/librepro-c697fecae630a328.rmeta"],"executable":null,"fresh":false}
{"reason":"compiler-artifact","package_id":"repro 0.0.0 (path+file:///git/repro)","manifest_path":"/git/repro/Cargo.toml","target":{"kind":["proc-macro"],"crate_types":["proc-macro"],"name":"repro","src_path":"/git/repro/src/lib.rs","edition":"2021","doc":true,"doctest":true,"test":true},"profile":{"opt_level":"0","debuginfo":2,"debug_assertions":true,"overflow_checks":true,"test":false},"features":[],"filenames":["/git/repro/target/debug/deps/librepro-433aa5011bfe20c0.so"],"executable":null,"fresh":false}
{"reason":"compiler-message","package_id":"repro 0.0.0 (path+file:///git/repro)","manifest_path":"/git/repro/Cargo.toml","target":{"kind":["bin"],"crate_types":["bin"],"name":"repro","src_path":"/git/repro/src/main.rs","edition":"2021","doc":true,"doctest":false,"test":true},"message":{"rendered":"error[E0277]: the size for values of type `str` cannot be known at compilation time\n --> src/main.rs:3:1\n  |\n3 | repro::repro!();\n  | ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time\n  |\n  = help: the trait `Sized` is not implemented for `str`\nnote: required by a bound in `f`\n --> src/main.rs:3:1\n  |\n3 | repro::repro!();\n  | ^^^^^^^^^^^^^^^ required by this bound in `f`\n  = note: this error originates in the macro `repro::repro` (in Nightly builds, run with -Z macro-backtrace for more info)\n\n","children":[{"children":[],"code":null,"level":"help","message":"the trait `Sized` is not implemented for `str`","rendered":null,"spans":[]},{"children":[],"code":null,"level":"note","message":"required by a bound in `f`","rendered":null,"spans":[{"byte_end":31,"byte_start":16,"column_end":16,"column_start":1,"expansion":{"def_site_span":{"byte_end":167,"byte_start":119,"column_end":49,"column_start":1,"expansion":null,"file_name":"/git/repro/src/lib.rs","is_primary":false,"label":null,"line_end":6,"line_start":6,"suggested_replacement":null,"suggestion_applicability":null,"text":[{"highlight_end":49,"highlight_start":1,"text":"pub fn repro(_input: TokenStream) -> TokenStream {"}]},"macro_decl_name":"repro::repro!","span":{"byte_end":31,"byte_start":16,"column_end":16,"column_start":1,"expansion":null,"file_name":"src/main.rs","is_primary":false,"label":null,"line_end":3,"line_start":3,"suggested_replacement":null,"suggestion_applicability":null,"text":[{"highlight_end":16,"highlight_start":1,"text":"repro::repro!();"}]}},"file_name":"src/main.rs","is_primary":true,"label":"required by this bound in `f`","line_end":3,"line_start":3,"suggested_replacement":null,"suggestion_applicability":null,"text":[{"highlight_end":16,"highlight_start":1,"text":"repro::repro!();"}]}]}],"code":{"code":"E0277","explanation":"You tried to use a type which doesn't implement some trait in a place which\nexpected that trait.\n\nErroneous code example:\n\n```compile_fail,E0277\n// here we declare the Foo trait with a bar method\ntrait Foo {\n    fn bar(&self);\n}\n\n// we now declare a function which takes an object implementing the Foo trait\nfn some_func<T: Foo>(foo: T) {\n    foo.bar();\n}\n\nfn main() {\n    // we now call the method with the i32 type, which doesn't implement\n    // the Foo trait\n    some_func(5i32); // error: the trait bound `i32 : Foo` is not satisfied\n}\n```\n\nIn order to fix this error, verify that the type you're using does implement\nthe trait. Example:\n\n```\ntrait Foo {\n    fn bar(&self);\n}\n\n// we implement the trait on the i32 type\nimpl Foo for i32 {\n    fn bar(&self) {}\n}\n\nfn some_func<T: Foo>(foo: T) {\n    foo.bar(); // we can now use this method since i32 implements the\n               // Foo trait\n}\n\nfn main() {\n    some_func(5i32); // ok!\n}\n```\n\nOr in a generic context, an erroneous code example would look like:\n\n```compile_fail,E0277\nfn some_func<T>(foo: T) {\n    println!(\"{:?}\", foo); // error: the trait `core::fmt::Debug` is not\n                           //        implemented for the type `T`\n}\n\nfn main() {\n    // We now call the method with the i32 type,\n    // which *does* implement the Debug trait.\n    some_func(5i32);\n}\n```\n\nNote that the error here is in the definition of the generic function. Although\nwe only call it with a parameter that does implement `Debug`, the compiler\nstill rejects the function. It must work with all possible input types. In\norder to make this example compile, we need to restrict the generic type we're\naccepting:\n\n```\nuse std::fmt;\n\n// Restrict the input type to types that implement Debug.\nfn some_func<T: fmt::Debug>(foo: T) {\n    println!(\"{:?}\", foo);\n}\n\nfn main() {\n    // Calling the method is still fine, as i32 implements Debug.\n    some_func(5i32);\n\n    // This would fail to compile now:\n    // struct WithoutDebug;\n    // some_func(WithoutDebug);\n}\n```\n\nRust only looks at the signature of the called function, as such it must\nalready specify all requirements that will be used for every type parameter.\n"},"level":"error","message":"the size for values of type `str` cannot be known at compilation time","spans":[{"byte_end":31,"byte_start":16,"column_end":16,"column_start":1,"expansion":{"def_site_span":{"byte_end":167,"byte_start":119,"column_end":49,"column_start":1,"expansion":null,"file_name":"/git/repro/src/lib.rs","is_primary":false,"label":null,"line_end":6,"line_start":6,"suggested_replacement":null,"suggestion_applicability":null,"text":[{"highlight_end":49,"highlight_start":1,"text":"pub fn repro(_input: TokenStream) -> TokenStream {"}]},"macro_decl_name":"repro::repro!","span":{"byte_end":31,"byte_start":16,"column_end":16,"column_start":1,"expansion":null,"file_name":"src/main.rs","is_primary":false,"label":null,"line_end":3,"line_start":3,"suggested_replacement":null,"suggestion_applicability":null,"text":[{"highlight_end":16,"highlight_start":1,"text":"repro::repro!();"}]}},"file_name":"src/main.rs","is_primary":true,"label":"doesn't have a size known at compile-time","line_end":3,"line_start":3,"suggested_replacement":null,"suggestion_applicability":null,"text":[{"highlight_end":16,"highlight_start":1,"text":"repro::repro!();"}]}]}}
{"reason":"compiler-message","package_id":"repro 0.0.0 (path+file:///git/repro)","manifest_path":"/git/repro/Cargo.toml","target":{"kind":["bin"],"crate_types":["bin"],"name":"repro","src_path":"/git/repro/src/main.rs","edition":"2021","doc":true,"doctest":false,"test":true},"message":{"rendered":"error: aborting due to previous error\n\n","children":[],"code":null,"level":"error","message":"aborting due to previous error","spans":[]}}
{"reason":"compiler-message","package_id":"repro 0.0.0 (path+file:///git/repro)","manifest_path":"/git/repro/Cargo.toml","target":{"kind":["bin"],"crate_types":["bin"],"name":"repro","src_path":"/git/repro/src/main.rs","edition":"2021","doc":true,"doctest":false,"test":true},"message":{"rendered":"For more information about this error, try `rustc --explain E0277`.\n","children":[],"code":null,"level":"failure-note","message":"For more information about this error, try `rustc --explain E0277`.","spans":[]}}
{"reason":"build-finished","success":false}
$ cargo clean; cargo +nightly-2023-01-03 check --message-format=json
{"reason":"compiler-artifact","package_id":"repro 0.0.0 (path+file:///git/repro)","manifest_path":"/git/repro/Cargo.toml","target":{"kind":["proc-macro"],"crate_types":["proc-macro"],"name":"repro","src_path":"/git/repro/src/lib.rs","edition":"2021","doc":true,"doctest":true,"test":true},"profile":{"opt_level":"0","debuginfo":2,"debug_assertions":true,"overflow_checks":true,"test":false},"features":[],"filenames":["/git/repro/target/debug/deps/librepro-c697fecae630a328.rmeta"],"executable":null,"fresh":false}
{"reason":"compiler-artifact","package_id":"repro 0.0.0 (path+file:///git/repro)","manifest_path":"/git/repro/Cargo.toml","target":{"kind":["proc-macro"],"crate_types":["proc-macro"],"name":"repro","src_path":"/git/repro/src/lib.rs","edition":"2021","doc":true,"doctest":true,"test":true},"profile":{"opt_level":"0","debuginfo":2,"debug_assertions":true,"overflow_checks":true,"test":false},"features":[],"filenames":["/git/repro/target/debug/deps/librepro-433aa5011bfe20c0.so"],"executable":null,"fresh":false}
{"reason":"compiler-message","package_id":"repro 0.0.0 (path+file:///git/repro)","manifest_path":"/git/repro/Cargo.toml","target":{"kind":["bin"],"crate_types":["bin"],"name":"repro","src_path":"/git/repro/src/main.rs","edition":"2021","doc":true,"doctest":false,"test":true},"message":{"rendered":"error[E0277]: the size for values of type `str` cannot be known at compilation time\n --> src/main.rs:3:1\n  |\n3 | repro::repro!();\n  | ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time\n  |\n  = help: the trait `Sized` is not implemented for `str`\nnote: required by a bound in `f`\n --> src/main.rs:3:1\n  |\n3 | repro::repro!();\n  | ^^^^^^^^^^^^^^^ required by this bound in `f`\n  = note: this error originates in the macro `repro::repro` (in Nightly builds, run with -Z macro-backtrace for more info)\n\n","children":[{"children":[],"code":null,"level":"help","message":"the trait `Sized` is not implemented for `str`","rendered":null,"spans":[]},{"children":[],"code":null,"level":"note","message":"required by a bound in `f`","rendered":null,"spans":[{"byte_end":31,"byte_start":16,"column_end":16,"column_start":1,"expansion":{"def_site_span":{"byte_end":167,"byte_start":119,"column_end":49,"column_start":1,"expansion":null,"file_name":"/git/repro/src/lib.rs","is_primary":false,"label":null,"line_end":6,"line_start":6,"suggested_replacement":null,"suggestion_applicability":null,"text":[{"highlight_end":49,"highlight_start":1,"text":"pub fn repro(_input: TokenStream) -> TokenStream {"}]},"macro_decl_name":"repro::repro!","span":{"byte_end":31,"byte_start":16,"column_end":16,"column_start":1,"expansion":null,"file_name":"src/main.rs","is_primary":false,"label":null,"line_end":3,"line_start":3,"suggested_replacement":null,"suggestion_applicability":null,"text":[{"highlight_end":16,"highlight_start":1,"text":"repro::repro!();"}]}},"file_name":"src/main.rs","is_primary":true,"label":"required by this bound in `f`","line_end":3,"line_start":3,"suggested_replacement":null,"suggestion_applicability":null,"text":[{"highlight_end":16,"highlight_start":1,"text":"repro::repro!();"}]}]}],"code":{"code":"E0277","explanation":"You tried to use a type which doesn't implement some trait in a place which\nexpected that trait.\n\nErroneous code example:\n\n```compile_fail,E0277\n// here we declare the Foo trait with a bar method\ntrait Foo {\n    fn bar(&self);\n}\n\n// we now declare a function which takes an object implementing the Foo trait\nfn some_func<T: Foo>(foo: T) {\n    foo.bar();\n}\n\nfn main() {\n    // we now call the method with the i32 type, which doesn't implement\n    // the Foo trait\n    some_func(5i32); // error: the trait bound `i32 : Foo` is not satisfied\n}\n```\n\nIn order to fix this error, verify that the type you're using does implement\nthe trait. Example:\n\n```\ntrait Foo {\n    fn bar(&self);\n}\n\n// we implement the trait on the i32 type\nimpl Foo for i32 {\n    fn bar(&self) {}\n}\n\nfn some_func<T: Foo>(foo: T) {\n    foo.bar(); // we can now use this method since i32 implements the\n               // Foo trait\n}\n\nfn main() {\n    some_func(5i32); // ok!\n}\n```\n\nOr in a generic context, an erroneous code example would look like:\n\n```compile_fail,E0277\nfn some_func<T>(foo: T) {\n    println!(\"{:?}\", foo); // error: the trait `core::fmt::Debug` is not\n                           //        implemented for the type `T`\n}\n\nfn main() {\n    // We now call the method with the i32 type,\n    // which *does* implement the Debug trait.\n    some_func(5i32);\n}\n```\n\nNote that the error here is in the definition of the generic function. Although\nwe only call it with a parameter that does implement `Debug`, the compiler\nstill rejects the function. It must work with all possible input types. In\norder to make this example compile, we need to restrict the generic type we're\naccepting:\n\n```\nuse std::fmt;\n\n// Restrict the input type to types that implement Debug.\nfn some_func<T: fmt::Debug>(foo: T) {\n    println!(\"{:?}\", foo);\n}\n\nfn main() {\n    // Calling the method is still fine, as i32 implements Debug.\n    some_func(5i32);\n\n    // This would fail to compile now:\n    // struct WithoutDebug;\n    // some_func(WithoutDebug);\n}\n```\n\nRust only looks at the signature of the called function, as such it must\nalready specify all requirements that will be used for every type parameter.\n"},"level":"error","message":"the size for values of type `str` cannot be known at compilation time","spans":[{"byte_end":31,"byte_start":16,"column_end":16,"column_start":1,"expansion":{"def_site_span":{"byte_end":167,"byte_start":119,"column_end":49,"column_start":1,"expansion":null,"file_name":"/git/repro/src/lib.rs","is_primary":false,"label":null,"line_end":6,"line_start":6,"suggested_replacement":null,"suggestion_applicability":null,"text":[{"highlight_end":49,"highlight_start":1,"text":"pub fn repro(_input: TokenStream) -> TokenStream {"}]},"macro_decl_name":"repro::repro!","span":{"byte_end":31,"byte_start":16,"column_end":16,"column_start":1,"expansion":null,"file_name":"src/main.rs","is_primary":false,"label":null,"line_end":3,"line_start":3,"suggested_replacement":null,"suggestion_applicability":null,"text":[{"highlight_end":16,"highlight_start":1,"text":"repro::repro!();"}]}},"file_name":"src/main.rs","is_primary":true,"label":"doesn't have a size known at compile-time","line_end":3,"line_start":3,"suggested_replacement":null,"suggestion_applicability":null,"text":[{"highlight_end":16,"highlight_start":1,"text":"repro::repro!();"}]}]}}
{"reason":"compiler-message","package_id":"repro 0.0.0 (path+file:///git/repro)","manifest_path":"/git/repro/Cargo.toml","target":{"kind":["bin"],"crate_types":["bin"],"name":"repro","src_path":"/git/repro/src/main.rs","edition":"2021","doc":true,"doctest":false,"test":true},"message":{"rendered":"error[E0277]: the size for values of type `str` cannot be known at compilation time\n --> src/main.rs:3:1\n  |\n3 | repro::repro!();\n  | ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time\n  |\n  = help: the trait `Sized` is not implemented for `str`\nnote: required by a bound in `f`\n --> src/main.rs:3:1\n  |\n3 | repro::repro!();\n  | ^^^^^^^^^^^^^^^ required by this bound in `f`\n  = note: this error originates in the macro `repro::repro` (in Nightly builds, run with -Z macro-backtrace for more info)\n\n","children":[{"children":[],"code":null,"level":"help","message":"the trait `Sized` is not implemented for `str`","rendered":null,"spans":[]},{"children":[],"code":null,"level":"note","message":"required by a bound in `f`","rendered":null,"spans":[{"byte_end":31,"byte_start":16,"column_end":16,"column_start":1,"expansion":{"def_site_span":{"byte_end":167,"byte_start":119,"column_end":49,"column_start":1,"expansion":null,"file_name":"/git/repro/src/lib.rs","is_primary":false,"label":null,"line_end":6,"line_start":6,"suggested_replacement":null,"suggestion_applicability":null,"text":[{"highlight_end":49,"highlight_start":1,"text":"pub fn repro(_input: TokenStream) -> TokenStream {"}]},"macro_decl_name":"repro::repro!","span":{"byte_end":31,"byte_start":16,"column_end":16,"column_start":1,"expansion":null,"file_name":"src/main.rs","is_primary":false,"label":null,"line_end":3,"line_start":3,"suggested_replacement":null,"suggestion_applicability":null,"text":[{"highlight_end":16,"highlight_start":1,"text":"repro::repro!();"}]}},"file_name":"src/main.rs","is_primary":true,"label":"required by this bound in `f`","line_end":3,"line_start":3,"suggested_replacement":null,"suggestion_applicability":null,"text":[{"highlight_end":16,"highlight_start":1,"text":"repro::repro!();"}]}]}],"code":{"code":"E0277","explanation":"You tried to use a type which doesn't implement some trait in a place which\nexpected that trait.\n\nErroneous code example:\n\n```compile_fail,E0277\n// here we declare the Foo trait with a bar method\ntrait Foo {\n    fn bar(&self);\n}\n\n// we now declare a function which takes an object implementing the Foo trait\nfn some_func<T: Foo>(foo: T) {\n    foo.bar();\n}\n\nfn main() {\n    // we now call the method with the i32 type, which doesn't implement\n    // the Foo trait\n    some_func(5i32); // error: the trait bound `i32 : Foo` is not satisfied\n}\n```\n\nIn order to fix this error, verify that the type you're using does implement\nthe trait. Example:\n\n```\ntrait Foo {\n    fn bar(&self);\n}\n\n// we implement the trait on the i32 type\nimpl Foo for i32 {\n    fn bar(&self) {}\n}\n\nfn some_func<T: Foo>(foo: T) {\n    foo.bar(); // we can now use this method since i32 implements the\n               // Foo trait\n}\n\nfn main() {\n    some_func(5i32); // ok!\n}\n```\n\nOr in a generic context, an erroneous code example would look like:\n\n```compile_fail,E0277\nfn some_func<T>(foo: T) {\n    println!(\"{:?}\", foo); // error: the trait `core::fmt::Debug` is not\n                           //        implemented for the type `T`\n}\n\nfn main() {\n    // We now call the method with the i32 type,\n    // which *does* implement the Debug trait.\n    some_func(5i32);\n}\n```\n\nNote that the error here is in the definition of the generic function. Although\nwe only call it with a parameter that does implement `Debug`, the compiler\nstill rejects the function. It must work with all possible input types. In\norder to make this example compile, we need to restrict the generic type we're\naccepting:\n\n```\nuse std::fmt;\n\n// Restrict the input type to types that implement Debug.\nfn some_func<T: fmt::Debug>(foo: T) {\n    println!(\"{:?}\", foo);\n}\n\nfn main() {\n    // Calling the method is still fine, as i32 implements Debug.\n    some_func(5i32);\n\n    // This would fail to compile now:\n    // struct WithoutDebug;\n    // some_func(WithoutDebug);\n}\n```\n\nRust only looks at the signature of the called function, as such it must\nalready specify all requirements that will be used for every type parameter.\n"},"level":"error","message":"the size for values of type `str` cannot be known at compilation time","spans":[{"byte_end":31,"byte_start":16,"column_end":16,"column_start":1,"expansion":{"def_site_span":{"byte_end":167,"byte_start":119,"column_end":49,"column_start":1,"expansion":null,"file_name":"/git/repro/src/lib.rs","is_primary":false,"label":null,"line_end":6,"line_start":6,"suggested_replacement":null,"suggestion_applicability":null,"text":[{"highlight_end":49,"highlight_start":1,"text":"pub fn repro(_input: TokenStream) -> TokenStream {"}]},"macro_decl_name":"repro::repro!","span":{"byte_end":31,"byte_start":16,"column_end":16,"column_start":1,"expansion":null,"file_name":"src/main.rs","is_primary":false,"label":null,"line_end":3,"line_start":3,"suggested_replacement":null,"suggestion_applicability":null,"text":[{"highlight_end":16,"highlight_start":1,"text":"repro::repro!();"}]}},"file_name":"src/main.rs","is_primary":true,"label":"doesn't have a size known at compile-time","line_end":3,"line_start":3,"suggested_replacement":null,"suggestion_applicability":null,"text":[{"highlight_end":16,"highlight_start":1,"text":"repro::repro!();"}]}]}}
{"reason":"compiler-message","package_id":"repro 0.0.0 (path+file:///git/repro)","manifest_path":"/git/repro/Cargo.toml","target":{"kind":["bin"],"crate_types":["bin"],"name":"repro","src_path":"/git/repro/src/main.rs","edition":"2021","doc":true,"doctest":false,"test":true},"message":{"rendered":"error: aborting due to 2 previous errors\n\n","children":[],"code":null,"level":"error","message":"aborting due to 2 previous errors","spans":[]}}
{"reason":"compiler-message","package_id":"repro 0.0.0 (path+file:///git/repro)","manifest_path":"/git/repro/Cargo.toml","target":{"kind":["bin"],"crate_types":["bin"],"name":"repro","src_path":"/git/repro/src/main.rs","edition":"2021","doc":true,"doctest":false,"test":true},"message":{"rendered":"For more information about this error, try `rustc --explain E0277`.\n","children":[],"code":null,"level":"failure-note","message":"For more information about this error, try `rustc --explain E0277`.","spans":[]}}
{"reason":"build-finished","success":false}

(host: x86_64-unknown-linux-gnu)

Notice that the first "compiler-message" (3rd JSON object) in the nightly-2023-01-02 output appears twice (3rd and 4th JSON object) in the nightly-2023-01-03 output. The duplicate lines are exactly identical.

If CARGO_INCREMENTAL=0 is set, the duplication does not occur.

The regression bisects to #84762. @cjgillot @petrochenkov

I am reporting this here instead of rust-lang/cargo because the description of that PR makes it sound like it was intended to be an internal refactor only with no user-facing consequence.

Activity

added
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
A-incr-compArea: Incremental compilation
C-bugCategory: This is a bug.
on Jan 7, 2023
added
I-prioritizeIssue: Indicates that prioritization has been requested for this issue.
on Jan 7, 2023
self-assigned this
on Jan 7, 2023
cjgillot

cjgillot commented on Jan 8, 2023

@cjgillot
Contributor

rustc is right to emit two diagnostics: one for f and one for g.

fn f<T: Sized>() {}
fn g() { f::<str>() }
fn h() { f::<str>() }

I agree that having different behaviours for incremental vs non-incremental is buggy.
I'm not sure if we should investigate the duplication or the de-duplication here.

apiraino

apiraino commented on Jan 25, 2023

@apiraino
Contributor

WG-prioritization assigning priority (Zulip discussion).

@rustbot label -I-prioritize +P-medium

added and removed
I-prioritizeIssue: Indicates that prioritization has been requested for this issue.
on Jan 25, 2023
added this to the 1.68.0 milestone on Feb 14, 2023
added
regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.
and removed on May 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-incr-compArea: Incremental compilationC-bugCategory: This is a bug.P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

Type

No type

Projects

No projects

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @cjgillot@dtolnay@Mark-Simulacrum@apiraino@rustbot

      Issue actions

        Regression: duplicate messages appear in --error-format=json · Issue #106571 · rust-lang/rust