Merge unused imported constructors and unused imported type with unused imported value

This was somewhat weirdly done, with a boolean 'imported' set on the
  formers; but an explicit new warning for values. I don't see the point
  of distinguishing them so I just merged them all into a single
  warning.

  I have however preserved the 'UnusedType' and 'UnusedConstructor'
  warnings since they were ALSO used for unused private constructors or
  types.
This commit is contained in:
KtorZ 2023-10-22 00:27:30 +02:00
parent 5f8e256050
commit 28b699c86a
No known key found for this signature in database
GPG Key ID: 33173CB6F77F4277
2 changed files with 10 additions and 25 deletions

View File

@ -355,33 +355,20 @@ impl<'a> Environment<'a> {
fn handle_unused(&mut self, unused: HashMap<String, (EntityKind, Span, bool)>) {
for (name, (kind, location, _)) in unused.into_iter().filter(|(_, (_, _, used))| !used) {
let warning = match kind {
EntityKind::ImportedType | EntityKind::ImportedTypeAndConstructor => {
Warning::UnusedType {
name,
imported: true,
location,
EntityKind::ImportedType
| EntityKind::ImportedTypeAndConstructor
| EntityKind::ImportedConstructor
| EntityKind::ImportedValue => {
Warning::UnusedImportedValueOrType { name, location }
}
}
EntityKind::ImportedConstructor => Warning::UnusedConstructor {
name,
imported: true,
location,
},
EntityKind::PrivateConstant => {
Warning::UnusedPrivateModuleConstant { name, location }
}
EntityKind::PrivateTypeConstructor(_) => Warning::UnusedConstructor {
name,
imported: false,
location,
},
EntityKind::PrivateTypeConstructor(_) => {
Warning::UnusedConstructor { name, location }
}
EntityKind::PrivateFunction => Warning::UnusedPrivateFunction { name, location },
EntityKind::PrivateType => Warning::UnusedType {
name,
imported: false,
location,
},
EntityKind::ImportedValue => Warning::UnusedImportedValue { name, location },
EntityKind::PrivateType => Warning::UnusedType { name, location },
EntityKind::Variable => Warning::UnusedVariable { name, location },
};

View File

@ -1437,7 +1437,6 @@ pub enum Warning {
UnusedConstructor {
#[label]
location: Span,
imported: bool,
name: String,
},
@ -1463,7 +1462,7 @@ pub enum Warning {
"No big deal, but you might want to remove it to get rid of that warning."
))]
#[diagnostic(code("unused:import::value"))]
UnusedImportedValue {
UnusedImportedValueOrType {
#[label]
location: Span,
name: String,
@ -1509,7 +1508,6 @@ pub enum Warning {
UnusedType {
#[label]
location: Span,
imported: bool,
name: String,
},