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:
parent
5f8e256050
commit
28b699c86a
|
@ -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 },
|
||||
};
|
||||
|
||||
|
|
|
@ -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,
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in New Issue