rust-lang / rust-lang/rust-clippy

Error applying suggestions (range underflow)

Open
#15,787 19 comments 0 reactions 1 assignee View on GitHub

@re-masashi is already working on this.

Since Oct 10, 2025.

C-bug good first issue
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

Description

Summary

Running

"cargo" "clippy" "--workspace" "--all-targets" "--all-features" "--fix" "--" "-D" "warnings"

(running without --fix doesn't seem to cause the issue)

generated me the following output (which suggested I open a bug report):

   Compiling ring v0.17.14
   Compiling vector-config-common v0.1.0 (/Users/thomas.schneider/src/vector-alt/lib/vector-config-common)
   Compiling vector-core v0.1.0 (/Users/thomas.schneider/src/vector-alt/lib/vector-core)
   Compiling opentelemetry-proto v0.1.0 (/Users/thomas.schneider/src/vector-alt/lib/opentelemetry-proto)
   Compiling prometheus-parser v0.1.0 (/Users/thomas.schneider/src/vector-alt/lib/prometheus-parser)
   Compiling dnstap-parser v0.1.0 (/Users/thomas.schneider/src/vector-alt/lib/dnstap-parser)
    Checking tracing-limit v0.1.0 (/Users/thomas.schneider/src/vector-alt/lib/tracing-limit)
   Compiling loki-logproto v0.1.0 (/Users/thomas.schneider/src/vector-alt/lib/loki-logproto)
    Checking rdkafka-sys v4.8.0+2.3.0
   Compiling vector v0.51.0 (/Users/thomas.schneider/src/vector-alt)
    Checking sqlx v0.8.6
    Checking console-subscriber v0.4.1
    Checking postgres-openssl v0.5.1
    Checking hyper-openssl v0.9.2
    Checking async-graphql-warp v7.0.17
    Checking fakedata v0.1.0 (/Users/thomas.schneider/src/vector-alt/lib/fakedata)
    Checking portpicker v1.0.0 (/Users/thomas.schneider/src/vector-alt/lib/portpicker)
    Checking rdkafka v0.37.0
    Checking wiremock v0.6.5
    Checking tower-test v0.4.0
    Checking k8s-test-framework v0.1.0 (/Users/thomas.schneider/src/vector-alt/lib/k8s-test-framework)
   Compiling vector-config-macros v0.1.0 (/Users/thomas.schneider/src/vector-alt/lib/vector-config-macros)
   Compiling vector-vrl-web-playground v0.1.0 (/Users/thomas.schneider/src/vector-alt/lib/vector-vrl/web-playground)
   Compiling rustls v0.23.23
   Compiling rustls v0.21.12
   Compiling rustls v0.22.4
    Checking rustls-webpki v0.102.8
    Checking sct v0.7.1
    Checking rustls-webpki v0.101.7
    Checking hickory-proto v0.25.2
    Checking tokio-rustls v0.24.1
    Checking tokio-rustls v0.25.0
    Checking tokio-tungstenite v0.20.1
    Checking hyper-rustls v0.24.2
    Checking mongodb v2.8.2
    Checking tokio-rustls v0.26.2
    Checking tonic v0.11.0
    Checking rumqttc v0.24.0
    Checking reqwest v0.11.26
    Checking hyper-rustls v0.27.5
    Checking aws-smithy-http-client v1.1.1
    Checking reqwest v0.12.9
    Checking aws-smithy-runtime v1.9.1
    Checking dnsmsg-parser v0.1.0 (/Users/thomas.schneider/src/vector-alt/lib/dnsmsg-parser)
    Checking vector-api-client v0.1.2 (/Users/thomas.schneider/src/vector-alt/lib/vector-api-client)
    Checking oauth2 v4.4.2
    Checking reqwest-middleware v0.4.2
    Checking azure_core v0.21.0
    Checking typespec_client_core v0.4.0
    Checking openidconnect v3.5.0
    Checking reqwest-retry v0.7.0
    Checking aws-runtime v1.5.10
    Checking vrl v0.27.0 (https://github.com/vectordotdev/vrl.git?branch=main#77add137)
    Checking azure_core v0.25.0
    Checking greptime-proto v0.1.0 (https://github.com/GreptimeTeam/greptime-proto.git?tag=v0.9.0#396206c2)
    Checking azure_storage v0.21.0
    Checking aws-sdk-sts v1.73.0
    Checking aws-sdk-sso v1.64.0
    Checking aws-sdk-ssooidc v1.65.0
    Checking azure_svc_blobstorage v0.21.0
    Checking pulsar v6.3.1
    Checking azure_identity v0.25.0
    Checking aws-sdk-secretsmanager v1.76.0
    Checking aws-sdk-s3 v1.82.0
    Checking aws-config v1.6.1
    Checking aws-sdk-firehose v1.71.0
    Checking greptimedb-ingester v0.1.0 (https://github.com/GreptimeTeam/greptimedb-ingester-rust?rev=f7243393808640f5123b0d5b7b798da591a4df6e#f7243393)
    Checking aws-sdk-kms v1.75.0
    Checking aws-sdk-cloudwatch v1.70.0
    Checking aws-sdk-elasticsearch v1.67.0
    Checking aws-sdk-cloudwatchlogs v1.76.0
    Checking aws-sdk-kinesis v1.66.0
    Checking azure_storage_blobs v0.21.0
    Checking aws-sdk-sns v1.73.0
    Checking aws-sdk-sqs v1.64.0
    Checking opendal v0.54.0
    Checking goauth v0.16.0
    Checking databend-client v0.28.2
    Checking bollard v0.19.2
    Checking async-nats v0.42.0
    Checking k8s-e2e-tests v0.1.0 (/Users/thomas.schneider/src/vector-alt/lib/k8s-e2e-tests)
    Checking vdev v0.1.0 (/Users/thomas.schneider/src/vector-alt/vdev)
    Checking vector-config v0.1.0 (/Users/thomas.schneider/src/vector-alt/lib/vector-config)
    Checking enrichment v0.1.0 (/Users/thomas.schneider/src/vector-alt/lib/enrichment)
    Checking vector-vrl-functions v0.1.0 (/Users/thomas.schneider/src/vector-alt/lib/vector-vrl/functions)
    Checking vector-common v0.1.0 (/Users/thomas.schneider/src/vector-alt/lib/vector-common)
    Checking vector-lookup v0.1.0 (/Users/thomas.schneider/src/vector-alt/lib/vector-lookup)
    Checking docs-renderer v0.1.0 (/Users/thomas.schneider/src/vector-alt/lib/docs-renderer)
    Checking vector-vrl-cli v0.1.0 (/Users/thomas.schneider/src/vector-alt/lib/vector-vrl/cli)
    Checking vector-buffers v0.1.0 (/Users/thomas.schneider/src/vector-alt/lib/vector-buffers)
    Checking file-source-common v0.1.0 (/Users/thomas.schneider/src/vector-alt/lib/file-source-common)
       Fixed lib/file-source-common/src/buffer.rs (1 fix)
    Checking file-source v0.1.0 (/Users/thomas.schneider/src/vector-alt/lib/file-source)
       Fixed lib/vector-buffers/src/variants/disk_v2/common.rs (1 fix)
       Fixed lib/vector-core/src/event/estimated_json_encoded_size_of.rs (2 fixes)
       Fixed lib/vector-core/src/event/test/common.rs (3 fixes)
       Fixed lib/vector-core/src/event/array.rs (1 fix)
    Checking codecs v0.1.0 (/Users/thomas.schneider/src/vector-alt/lib/codecs)
    Checking vector-tap v0.1.0 (/Users/thomas.schneider/src/vector-alt/lib/vector-tap)
    Checking vector-stream v0.1.0 (/Users/thomas.schneider/src/vector-alt/lib/vector-stream)
       Fixed lib/file-source/src/file_server.rs (1 fix)
       Fixed lib/codecs/src/decoding/framing/chunked_gelf.rs (1 fix)
    Checking vector-lib v0.1.0 (/Users/thomas.schneider/src/vector-alt/lib/vector-lib)
    Checking vector-vrl-tests v0.1.0 (/Users/thomas.schneider/src/vector-alt/lib/vector-vrl/tests)
warning: error applying suggestions to `src/sinks/util/service/health.rs`

The full error message was:

> invalid range 8069..22222351, original data is only 10493 byte long

This likely indicates a bug in either rustc or cargo itself,
and we would appreciate a bug report! You're likely to see
a number of compiler warnings after this message which cargo
attempted to fix but failed. If you could open an issue at
https://github.com/rust-lang/rust-clippy/issues
quoting the full output of this command we'd be very appreciative!
Note that you may be able to make some more progress in the near-term
fixing code with the `--broken-code` flag

       Fixed src/sinks/util/service/health.rs (0 fixes)
       Fixed src/transforms/lua/v1/mod.rs (1 fix)
       Fixed src/sources/host_metrics/filesystem.rs (1 fix)
       Fixed src/sources/host_metrics/disk.rs (1 fix)
       Fixed src/transforms/lua/v2/mod.rs (1 fix)
       Fixed src/transforms/sample/transform.rs (1 fix)
warning: struct `NewRelicStatusModel` is never constructed
  --> src/sinks/new_relic/healthcheck.rs:10:8
   |
10 | struct NewRelicStatusModel {
   |        ^^^^^^^^^^^^^^^^^^^
   |
note: the lint level is defined here
  --> src/lib.rs:7:9
   |
 7 | #![deny(warnings)]
   |         ^^^^^^^^
   = note: `#[warn(dead_code)]` implied by `#[warn(warnings)]`

warning: struct `NewRelicStatusPage` is never constructed
  --> src/sinks/new_relic/healthcheck.rs:16:8
   |
16 | struct NewRelicStatusPage {
   |        ^^^^^^^^^^^^^^^^^^

warning: struct `NewRelicStatusComponent` is never constructed
  --> src/sinks/new_relic/healthcheck.rs:23:8
   |
23 | struct NewRelicStatusComponent {
   |        ^^^^^^^^^^^^^^^^^^^^^^^

warning: useless conversion to the same type: `<F as futures_util::TryFuture>::Error`
  --> src/sinks/util/service/health.rs:238:69
   |
56 | |
   | |_^help: consider removing
...
238|           let output = ready!(this.inner.poll(cx)).map_err(Into::into);
   |  _____________________________________________________________________^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion
   = note: `#[warn(clippy::useless_conversion)]` implied by `#[warn(warnings)]`

warning: `vector` (lib test) generated 4 warnings (run `cargo clippy --fix --lib -p vector --tests` to apply 1 suggestion)
warning: error applying suggestions to `src/sinks/util/service/health.rs`

The full error message was:

> invalid range 8069..19848720, original data is only 10493 byte long

This likely indicates a bug in either rustc or cargo itself,
and we would appreciate a bug report! You're likely to see
a number of compiler warnings after this message which cargo
attempted to fix but failed. If you could open an issue at
https://github.com/rust-lang/rust-clippy/issues
quoting the full output of this command we'd be very appreciative!
Note that you may be able to make some more progress in the near-term
fixing code with the `--broken-code` flag

       Fixed src/sinks/util/service/health.rs (0 fixes)
warning: `vector` (lib) generated 4 warnings (4 duplicates)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 2m 50s
Reproducer
git clone https://github.com/vectordotdev/vector.git && cd vector

git reset --hard bd6a8f51d6c16106de76de3330d27415f53940ad

Add the following to rust-1.90.patch

From 355c4bc4eec20c9563320a4905e6b7456885f3a9 Mon Sep 17 00:00:00 2001
From: Thomas <thomas.schneider@datadoghq.com>
Date: Mon, 29 Sep 2025 16:02:27 -0400
Subject: [PATCH] Rust 1.90

---
 rust-toolchain.toml | 2 +-
 vdev/src/app.rs     | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/rust-toolchain.toml b/rust-toolchain.toml
index b6981e639..29b051764 100644
--- a/rust-toolchain.toml
+++ b/rust-toolchain.toml
@@ -1,3 +1,3 @@
 [toolchain]
-channel = "1.89"
+channel = "1.90"
 profile = "default"
diff --git a/vdev/src/app.rs b/vdev/src/app.rs
index 49e595b58..d49f7d5bf 100644
--- a/vdev/src/app.rs
+++ b/vdev/src/app.rs
@@ -27,7 +27,7 @@ const DEFAULT_SHELL: &str = "/bin/sh";
 // Extract the shell from the environment variable `$SHELL` and substitute the above default value
 // if it isn't set.
 pub static SHELL: LazyLock<OsString> =
-    LazyLock::new(|| (env::var_os("SHELL").unwrap_or_else(|| DEFAULT_SHELL.into())));
+    LazyLock::new(|| env::var_os("SHELL").unwrap_or_else(|| DEFAULT_SHELL.into()));
 
 static VERBOSITY: OnceLock<LevelFilter> = OnceLock::new();
 static CONFIG: OnceLock<Config> = OnceLock::new();
-- 
2.51.0

Then run

git am rust-1.90.patch && rm rust-1.90.patch

rustup toolchain install

"cargo" "clippy" "--workspace" "--all-targets" "--all-features" "--fix" "--" "-D" "warnings"
Version
rustc 1.90.0 (1159e78c4 2025-09-14)
binary: rustc
commit-hash: 1159e78c4747b02ef996e55082b704c09b970588
commit-date: 2025-09-14
host: aarch64-apple-darwin
release: 1.90.0
LLVM version: 20.1.8
Additional Labels

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.