Replibyte icon indicating copy to clipboard operation
Replibyte copied to clipboard

Warnings when launching build

Open pascalgrimaud opened this issue 3 years ago • 3 comments
trafficstars

There are a lot of warning when launching cargo build --release Should it be clean or is it intended to keep these variables/functions for futur features?

19:02:43 in projects/qovery/replibyte on  readme-typo-postgresql via 𝗥 v1.59.0 
➜ cargo build --release                    
warning: function is never used: `parse_quoted_ident`
   --> dump-parser/src/postgres/mod.rs:614:4
    |
614 | fn parse_quoted_ident(chars: &mut Peekable<Chars<'_>>, quote_end: char) -> (String, Option<char>) {
    |    ^^^^^^^^^^^^^^^^^^
    |
    = note: `#[warn(dead_code)]` on by default

warning: constant is never used: `LINE_SEPARATOR`
 --> dump-parser/src/utils.rs:7:1
  |
7 | const LINE_SEPARATOR: char = ';';
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: `dump-parser` (lib) generated 2 warnings
warning: unused imports: `stdin`, `stdout`
 --> replibyte/src/destination/postgres.rs:1:15
  |
1 | use std::io::{stdin, stdout, Error, ErrorKind, Write};
  |               ^^^^^  ^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: unused import: `ErrorKind`
 --> replibyte/src/destination/postgres_stdout.rs:1:30
  |
1 | use std::io::{stdout, Error, ErrorKind, Write};
  |                              ^^^^^^^^^

warning: unused imports: `Command`, `Stdio`
 --> replibyte/src/destination/postgres_stdout.rs:2:20
  |
2 | use std::process::{Command, Stdio};
  |                    ^^^^^^^  ^^^^^

warning: unused import: `tokio::io::AsyncWriteExt`
 --> replibyte/src/destination/postgres.rs:3:5
  |
3 | use tokio::io::AsyncWriteExt;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^

warning: unused variable: `host`
   --> replibyte/src/main.rs:176:50
    |
176 | ...                   ConnectionUri::Mysql(host, port, username, password, database) => {
    |                                            ^^^^ help: if this is intentional, prefix it with an underscore: `_host`
    |
    = note: `#[warn(unused_variables)]` on by default

warning: unused variable: `port`
   --> replibyte/src/main.rs:176:56
    |
176 | ...                   ConnectionUri::Mysql(host, port, username, password, database) => {
    |                                                  ^^^^ help: if this is intentional, prefix it with an underscore: `_port`

warning: unused variable: `username`
   --> replibyte/src/main.rs:176:62
    |
176 | ...                   ConnectionUri::Mysql(host, port, username, password, database) => {
    |                                                        ^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_username`

warning: unused variable: `password`
   --> replibyte/src/main.rs:176:72
    |
176 | ...                   ConnectionUri::Mysql(host, port, username, password, database) => {
    |                                                                  ^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_password`

warning: unused variable: `database`
   --> replibyte/src/main.rs:176:82
    |
176 | ...                   ConnectionUri::Mysql(host, port, username, password, database) => {
    |                                                                            ^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_database`

warning: unused variable: `host`
   --> replibyte/src/main.rs:241:42
    |
241 |                     ConnectionUri::Mysql(host, port, username, password, database) => {
    |                                          ^^^^ help: if this is intentional, prefix it with an underscore: `_host`

warning: unused variable: `port`
   --> replibyte/src/main.rs:241:48
    |
241 |                     ConnectionUri::Mysql(host, port, username, password, database) => {
    |                                                ^^^^ help: if this is intentional, prefix it with an underscore: `_port`

warning: unused variable: `username`
   --> replibyte/src/main.rs:241:54
    |
241 |                     ConnectionUri::Mysql(host, port, username, password, database) => {
    |                                                      ^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_username`

warning: unused variable: `password`
   --> replibyte/src/main.rs:241:64
    |
241 |                     ConnectionUri::Mysql(host, port, username, password, database) => {
    |                                                                ^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_password`

warning: unused variable: `database`
   --> replibyte/src/main.rs:241:74
    |
241 |                     ConnectionUri::Mysql(host, port, username, password, database) => {
    |                                                                          ^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_database`

warning: unused variable: `err`
  --> replibyte/src/bridge/s3.rs:61:21
   |
61 |                 Err(err) => s3_config_builder.build(),
   |                     ^^^ help: if this is intentional, prefix it with an underscore: `_err`

warning: unused variable: `original_query`
  --> replibyte/src/tasks/full_backup.rs:91:39
   |
91 |             .read(self.transformers, |original_query, query| {
   |                                       ^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_original_query`

warning: variable does not need to be mutable
  --> replibyte/src/main.rs:78:9
   |
78 |     let mut style_is_progress_bar = false;
   |         ----^^^^^^^^^^^^^^^^^^^^^
   |         |
   |         help: remove this `mut`
   |
   = note: `#[warn(unused_mut)]` on by default

warning: variable does not need to be mutable
   --> replibyte/src/main.rs:185:37
    |
185 | ...                   let mut reader = BufReader::new(dump_file);
    |                           ----^^^^^^
    |                           |
    |                           help: remove this `mut`

warning: variant is never constructed: `FailedToDeleteBucket`
   --> replibyte/src/bridge/s3.rs:187:5
    |
187 |     FailedToDeleteBucket { bucket: &'a str },
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: `#[warn(dead_code)]` on by default

warning: variant is never constructed: `FailedToDeleteObject`
   --> replibyte/src/bridge/s3.rs:192:5
    |
192 |     FailedToDeleteObject { bucket: &'a str, key: &'a str },
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: function is never used: `delete_bucket`
   --> replibyte/src/bridge/s3.rs:279:4
    |
279 | fn delete_bucket<'a>(client: &Client, bucket: &'a str, force: bool) -> Result<(), S3Error<'a>> {
    |    ^^^^^^^^^^^^^

warning: function is never used: `delete_object`
   --> replibyte/src/bridge/s3.rs:371:4
    |
371 | fn delete_object<'a>(client: &Client, bucket: &'a str, key: &'a str) -> Result<(), S3Error<'a>> {
    |    ^^^^^^^^^^^^^

warning: enum is never used: `ConnectorConfig`
  --> replibyte/src/config.rs:20:10
   |
20 | pub enum ConnectorConfig<'a> {
   |          ^^^^^^^^^^^^^^^

warning: associated function is never used: `connector`
  --> replibyte/src/config.rs:26:12
   |
26 |     pub fn connector(&self) -> Result<ConnectorConfig, Error> {
   |            ^^^^^^^^^

warning: variant is never constructed: `Mysql`
   --> replibyte/src/config.rs:183:5
    |
183 |     Mysql(Host, Port, Username, Password, Database),
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: associated function is never used: `new`
  --> replibyte/src/destination/postgres_stdout.rs:12:12
   |
12 |     pub fn new() -> Self {
   |            ^^^

warning: field is never read: `database`
  --> replibyte/src/source/postgres.rs:22:5
   |
22 |     database: &'a str,
   |     ^^^^^^^^^^^^^^^^^

warning: associated function is never used: `new`
  --> replibyte/src/source/postgres_stdin.rs:13:12
   |
13 |     pub fn new() -> Self {
   |            ^^^

warning: associated function is never used: `new`
  --> replibyte/src/transformer/transient.rs:22:12
   |
22 |     pub fn new<S>(database_name: S, table_name: S, column_name: S) -> Self
   |            ^^^

warning: enum is never used: `Transformers`
 --> replibyte/src/transformer/mod.rs:9:10
  |
9 | pub enum Transformers {
  |          ^^^^^^^^^^^^

warning: associated function is never used: `name`
  --> replibyte/src/types.rs:42:12
   |
42 |     pub fn name(&self) -> &str {
   |            ^^^^

warning: associated function is never used: `number_value`
  --> replibyte/src/types.rs:52:12
   |
52 |     pub fn number_value(&self) -> Option<&i128> {
   |            ^^^^^^^^^^^^

warning: associated function is never used: `string_value`
  --> replibyte/src/types.rs:59:12
   |
59 |     pub fn string_value(&self) -> Option<&str> {
   |            ^^^^^^^^^^^^

warning: associated function is never used: `float_number_value`
  --> replibyte/src/types.rs:66:12
   |
66 |     pub fn float_number_value(&self) -> Option<&f64> {
   |            ^^^^^^^^^^^^^^^^^^

warning: associated function is never used: `char_value`
  --> replibyte/src/types.rs:73:12
   |
73 |     pub fn char_value(&self) -> Option<&char> {
   |            ^^^^^^^^^^

warning: `replibyte` (bin "replibyte") generated 35 warnings
    Finished release [optimized] target(s) in 0.09s

pascalgrimaud avatar Mar 24 '22 18:03 pascalgrimaud

This also somewhat bothered me, it does make development with a lot of re-builds a little annoying. A very simple solution would be to add

#![allow(unused)] // TODO remove it when the code is stable

to both /src/main.rs and /dump-parser/src/lib.rs as the 1st line, and all those warnings will be gone.

benny-n avatar Mar 28 '22 10:03 benny-n

I opened this ticket as I'm trying to learn Rust, and would like to contribute :-) So I can clean all these warnings in different pull requests, but I wanted to be sure if it's intended (for future features) or it's just some missing cleaning during development.

I could do some small PRs (one for each warning) and you could accept or decline, depending on the need of variables / functions. What do you think?

pascalgrimaud avatar Mar 28 '22 16:03 pascalgrimaud

@pascalgrimaud It's great that you want to learn Rust and contribute and I'd be happy to help with what I can 🙂 It's just that most of these warnings as you can see are only due to unused variables or structs, which will only be utilized in the future of the crate development. So basically cleaning these warnings just means to keep developing the crate :)

benny-n avatar Mar 28 '22 17:03 benny-n