8000 Add a note to duplicate diagnostics · rust-lang/rust@5453a9f · GitHub
[go: up one dir, main page]

Skip to content

Commit 5453a9f

Browse files
committed
Add a note to duplicate diagnostics
1 parent 2ffeb46 commit 5453a9f

File tree

166 files changed

+460
-203
lines changed
  • must_not_suspend
  • rfc-2383-lint-reason
  • lub-glb
  • macros
  • nll
  • object-safety
  • parser
  • pattern
  • privacy
  • proc-macro
  • recursion_limit
  • regions
  • repr
  • rfcs
  • rust-2018
  • sanitize
  • suggestions
  • tool-attributes
  • traits
  • tuple/tuple-struct-fields
  • type-alias-enum-variants
  • typeck
  • unknown-unstable-lints
  • use
  • Some content is hidden

    Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

    166 files changed

    +460
    -203
    lines changed

    compiler/rustc_errors/src/lib.rs

    Lines changed: 8 additions & 3 deletions
    Original file line numberDiff line numberDiff line change
    @@ -1376,16 +1376,16 @@ impl HandlerInner {
    13761376
    self.emitted_diagnostic_codes.insert(code.clone());
    13771377
    }
    13781378

    1379-
    let already_emitted = |this: &mut Self| {
    1379+
    let already_emitted = {
    13801380
    let mut hasher = StableHasher::new();
    13811381
    diagnostic.hash(&mut hasher);
    13821382
    let diagnostic_hash = hasher.finish();
    1383-
    !this.emitted_diagnostics.insert(diagnostic_hash)
    1383+
    !self.emitted_diagnostics.insert(diagnostic_hash)
    13841384
    };
    13851385

    13861386
    // Only emit the diagnostic if we've been asked to deduplicate or
    13871387
    // haven't already emitted an equivalent diagnostic.
    1388-
    if !(self.flags.deduplicate_diagnostics && already_emitted(self)) {
    1388+
    if !(self.flags.deduplicate_diagnostics && already_emitted) {
    13891389
    debug!(?diagnostic);
    13901390
    debug!(?self.emitted_diagnostics);
    13911391
    let already_emitted_sub = |sub: &mut SubDiagnostic| {
    @@ -1401,6 +1401,11 @@ impl HandlerInner {
    14011401
    };
    14021402

    14031403
    diagnostic.children.extract_if(already_emitted_sub).for_each(|_| {});
    1404+
    if already_emitted {
    1405+
    diagnostic.note(
    1406+
    "duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`",
    1407+
    );
    1408+
    }
    14041409

    14051410
    self.emitter.emit_diagnostic(diagnostic);
    14061411
    if diagnostic.is_error() {

    tests/rustdoc-ui/custom_code_classes_in_docs-warning3.stderr

    Lines changed: 2 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -28,6 +28,8 @@ LL | |
    2828
    LL | | /// main;
    2929
    LL | | /// ```
    3030
    | |_______^
    31+
    |
    32+
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
    3133

    3234
    error: aborting due to 2 previous errors
    3335

    tests/rustdoc-ui/intra-doc/broken-link-in-unused-doc-string.stderr

    Lines changed: 1 addition & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -22,6 +22,7 @@ LL | /// [1]
    2222
    | ^ no item named `1` in scope
    2323
    |
    2424
    = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
    25+
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
    2526

    2627
    warning: 3 warnings emitted
    2728

    tests/rustdoc-ui/issues/issue-105742.stderr

    Lines changed: 16 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -169,6 +169,7 @@ note: associated type defined here, with 1 lifetime parameter: `'a`
    169169
    |
    170170
    LL | type Item<'a, T>;
    171171
    | ^^^^ --
    172+
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
    172173
    help: add missing lifetime argument
    173174
    |
    174175
    LL | <Self as SVec>::Item<'a>,
    @@ -185,6 +186,7 @@ note: associated type defined here, with 1 generic parameter: `T`
    185186
    |
    186187
    LL | type Item<'a, T>;
    187188
    | ^^^^ -
    189+
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
    188190
    help: add missing generic argument
    189191
    |
    190192
    LL | <Self as SVec>::Item<T>,
    @@ -201,6 +203,7 @@ note: associated type defined here, with 1 lifetime parameter: `'a`
    201203
    |
    202204
    LL | type Item<'a, T>;
    203205
    | ^^^^ --
    206+
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
    204207
    help: add missing lifetime argument
    205208
    |
    206209
    LL | Output = <Index<<Self as SVec>::Item<'a>,
    @@ -217,6 +220,7 @@ note: associated type defined here, with 1 generic parameter: `T`
    217220
    |
    218221
    LL | type Item<'a, T>;
    219222
    | ^^^^ -
    223+
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
    220224
    help: add missing generic argument
    221225
    |
    222226
    LL | Output = <Index<<Self as SVec>::Item<T>,
    @@ -233,6 +237,7 @@ note: associated type defined here, with 1 lifetime parameter: `'a`
    233237
    |
    234238
    LL | type Item<'a, T>;
    235239
    | ^^^^ --
    240+
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
    236241
    help: add missing lifetime argument
    237242
    |
    238243
    LL | Output = <Self as SVec>::Item<'a>> as SVec>::Item,
    @@ -249,6 +254,7 @@ note: associated type defined here, with 1 generic parameter: `T`
    249254
    |
    250255
    LL | type Item<'a, T>;
    251256
    | ^^^^ -
    257+
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
    252258
    help: add missing generic argument
    253259
    |
    254260
    LL | Output = <Self as SVec>::Item<T>> as SVec>::Item,
    @@ -265,6 +271,7 @@ note: associated type defined here, with 1 lifetime parameter: `'a`
    265271
    |
    266272
    LL | type Item<'a, T>;
    267273
    | ^^^^ --
    274+
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
    268275
    help: add missing lifetime argument
    269276
    |
    270277
    LL | Output = <Self as SVec>::Item> as SVec>::Item<'a>,
    @@ -281,6 +288,7 @@ note: associated type defined here, with 1 generic parameter: `T`
    281288
    |
    282289
    LL | type Item<'a, T>;
    283290
    | ^^^^ -
    291+
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
    284292
    help: add missing generic argument
    285293
    |
    286294
    LL | Output = <Self as SVec>::Item> as SVec>::Item<T>,
    @@ -327,6 +335,7 @@ note: associated type defined here, with 1 lifetime parameter: `'a`
    327335
    |
    328336
    LL | type Item<'a, T>;
    329337
    | ^^^^ --
    338+
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
    330339
    help: add missing lifetime argument
    331340
    |
    332341
    LL | <Self as SVec>::Item<'a>,
    @@ -343,6 +352,7 @@ note: associated type defined here, with 1 generic parameter: `T`
    343352
    |
    344353
    LL | type Item<'a, T>;
    345354
    | ^^^^ -
    355+
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
    346356
    help: add missing generic argument
    347357
    |
    348358
    LL | <Self as SVec>::Item<T>,
    @@ -359,6 +369,7 @@ note: associated type defined here, with 1 lifetime parameter: `'a`
    359369
    |
    360370
    LL | type Item<'a, T>;
    361371
    | ^^^^ --
    372+
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
    362373
    help: add missing lifetime argument
    363374
    |
    364375
    LL | Output = <Index<<Self as SVec>::Item<'a>,
    @@ -375,6 +386,7 @@ note: associated type defined here, with 1 generic parameter: `T`
    375386
    |
    376387
    LL | type Item<'a, T>;
    377388
    | ^^^^ -
    389+
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
    378390
    help: add missing generic argument
    379391
    |
    380392
    LL | Output = <Index<<Self as SVec>::Item<T>,
    @@ -391,6 +403,7 @@ note: associated type defined here, with 1 lifetime parameter: `'a`
    391403
    |
    392404
    LL | type Item<'a, T>;
    393405
    | ^^^^ --
    406+
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
    394407
    help: add missing lifetime argument
    395408
    |
    396409
    LL | Output = <Self as SVec>::Item<'a>> as SVec>::Item,
    @@ -407,6 +420,7 @@ note: associated type defined here, with 1 generic parameter: `T`
    407420
    |
    408421
    LL | type Item<'a, T>;
    409422
    | ^^^^ -
    423+
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
    410424
    help: add missing generic argument
    411425
    |
    412426
    LL | Output = <Self as SVec>::Item<T>> as SVec>::Item,
    @@ -423,6 +437,7 @@ note: associated type defined here, with 1 lifetime parameter: `'a`
    423437
    |
    424438
    LL | type Item<'a, T>;
    425439
    | ^^^^ --
    440+
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
    426441
    help: add missing lifetime argument
    427442
    |
    428443
    LL | Output = <Self as SVec>::Item> as SVec>::Item<'a>,
    @@ -439,6 +454,7 @@ note: associated type defined here, with 1 generic parameter: `T`
    439454
    |
    440455
    LL | type Item<'a, T>;
    441456
    | ^^^^ -
    457+
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
    442458
    help: add missing generic argument
    443459
    |
    444460
    LL | Output = <Self as SVec>::Item> as SVec>::Item<T>,
    Lines changed: 1 addition & 6 deletions
    Original file line numberDiff line numberDiff line change
    @@ -1,12 +1,7 @@
    1+
    // compile-flags: -Zdeduplicate-diagnostics=yes
    12
    #![deny(unknown_lints)]
    23
    //~^ NOTE defined here
    34
    #![allow(rustdoc::missing_doc_code_examples)]
    45
    //~^ ERROR unknown lint
    5-
    //~| ERROR unknown lint
    6-
    //~| ERROR unknown lint
    76
    //~| NOTE lint is unstable
    8-
    //~| NOTE lint is unstable
    9-
    //~| NOTE lint is unstable
    10-
    //~| NOTE see issue
    11-
    //~| NOTE see issue
    127
    //~| NOTE see issue
    Lines changed: 3 additions & 23 deletions
    Original file line numberDiff line numberDiff line change
    @@ -1,5 +1,5 @@
    11
    error: unknown lint: `rustdoc::missing_doc_code_examples`
    2-
    --> $DIR/feature-gate-rustdoc_missing_doc_code_examples.rs:3:1
    2+
    --> $DIR/feature-gate-rustdoc_missing_doc_code_examples.rs:4:1
    33
    |
    44
    LL | #![allow(rustdoc::missing_doc_code_examples)]
    55
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    @@ -8,30 +8,10 @@ LL | #![allow(rustdoc::missing_doc_code_examples)]
    88
    = note: see issue #101730 <https://github.com/rust-lang/rust/issues/101730> for more information
    99
    = help: add `#![feature(rustdoc_missing_doc_code_examples)]` to the crate attributes to enable
    1010
    note: the lint level is defined here
    11-
    --> $DIR/feature-gate-rustdoc_missing_doc_code_examples.rs:1:9
    11+
    --> $DIR/feature-gate-rustdoc_missing_doc_code_examples.rs:2:9
    1212
    |
    1313
    LL | #![deny(unknown_lints)]
    1414
    | ^^^^^^^^^^^^^
    1515

    16-
    error: unknown lint: `rustdoc::missing_doc_code_examples`
    17-
    --> $DIR/feature-gate-rustdoc_missing_doc_code_examples.rs:3:1
    18-
    |
    19-
    LL | #![allow(rustdoc::missing_doc_code_examples)]
    20-
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    21-
    |
    22-
    = note: the `rustdoc::missing_doc_code_examples` lint is unstable
    23-
    = note: see issue #101730 <https://github.com/rust-lang/rust/issues/101730> for more information
    24-
    = help: add `#![feature(rustdoc_missing_doc_code_examples)]` to the crate attributes to enable
    25-
    26-
    error: unknown lint: `rustdoc::missing_doc_code_examples`
    27-
    --> $DIR/feature-gate-rustdoc_missing_doc_code_examples.rs:3:1
    28-
    |
    29-
    LL | #![allow(rustdoc::missing_doc_code_examples)]
    30-
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    31-
    |
    32-
    = note: the `rustdoc::missing_doc_code_examples` lint is unstable
    33-
    = note: see issue #101730 <https://github.com/rust-lang/rust/issues/101730> for more information
    34-
    = help: add `#![feature(rustdoc_missing_doc_code_examples)]` to the crate attributes to enable
    35-
    36-
    error: aborting due to 3 previous errors
    16+
    error: aborting due to previous error
    3717

    tests/rustdoc-ui/unescaped_backticks.stderr

    Lines changed: 3 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -302,6 +302,7 @@ LL | | /// level changes.
    302302
    = help: if you meant to use a literal backtick, escape it
    303303
    change: or `None` if it isn't.
    304304
    to this: or `None\` if it isn't.
    305+
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
    305306

    306307
    error: unescaped backtick
    307308
    --> $DIR/unescaped_backticks.rs:323:5
    @@ -321,6 +322,7 @@ LL | | /// level changes.
    321322
    = help: if you meant to use a literal backtick, escape it
    322323
    change: `on_event` should be called.
    323324
    to this: `on_event\` should be called.
    325+
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
    324326

    325327
    error: unescaped backtick
    326328
    --> $DIR/unescaped_backticks.rs:323:5
    @@ -340,6 +342,7 @@ LL | | /// level changes.
    340342
    = help: if you meant to use a literal backtick, escape it
    341343
    change: [`rebuild_interest_cache`][rebuild] is called after the value of the max
    342344
    to this: [`rebuild_interest_cache\`][rebuild] is called after the value of the max
    345+
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
    343346

    344347
    error: unescaped backtick
    345348
    --> $DIR/unescaped_backticks.rs:349:56

    tests/ui-fulldeps/plugin/lint-plugin-forbid-attrs.stderr

    Lines changed: 2 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -27,6 +27,8 @@ LL | #![forbid(test_lint)]
    2727
    ...
    2828
    LL | #[allow(test_lint)]
    2929
    | ^^^^^^^^^ overruled by previous forbid
    30+
    |
    31+
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
    3032

    3133
    warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675
    3234
    --> $DIR/lint-plugin-forbid-attrs.rs:5:1

    tests/ui-fulldeps/plugin/lint-plugin-forbid-cmdline.stderr

    Lines changed: 1 addition & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -21,6 +21,7 @@ LL | #[allow(test_lint)]
    2121
    | ^^^^^^^^^ overruled by previous forbid
    2222
    |
    2323
    = note: `forbid` lint level was set on command line
    24+
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
    2425

    2526
    warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675
    2627
    --> $DIR/lint-plugin-forbid-cmdline.rs:6:1

    tests/ui-fulldeps/plugin/lint-tool-cmdline-allow.stderr

    Lines changed: 2 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -8,6 +8,7 @@ warning: lint name `test_lint` is deprecated and may not have an effect in the f
    88
    |
    99
    = help: change it to clippy::test_lint
    1010
    = note: requested on the command line with `-A test_lint`
    11+
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
    1112

    1213
    warning: item is named 'lintme'
    1314
    --> $DIR/lint-tool-cmdline-allow.rs:9:1
    @@ -29,6 +30,7 @@ warning: lint name `test_lint` is deprecated and may not have an effect in the f
    2930
    |
    3031
    = help: change it to clippy::test_lint
    3132
    = note: requested on the command line with `-A test_lint`
    33+
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
    3234

    3335
    warning: 5 warnings emitted
    3436

    0 commit comments

    Comments
     (0)
    0