mirror of
https://github.com/rust-lang/cargo.git
synced 2026-05-06 08:36:38 -04:00
refactor(compile): Be consistent in unused_externs type
This commit is contained in:
@@ -9,6 +9,7 @@ use crate::core::compiler::locking::LockKey;
|
||||
use crate::core::compiler::timings::SectionTiming;
|
||||
use crate::util::Queue;
|
||||
use crate::util::context::WarningHandling;
|
||||
use crate::util::interning::InternedString;
|
||||
use crate::{CargoResult, core::compiler::locking::LockManager};
|
||||
|
||||
use super::{Artifact, DiagDedupe, Job, JobId, Message};
|
||||
@@ -224,7 +225,7 @@ impl<'a, 'gctx> JobState<'a, 'gctx> {
|
||||
///
|
||||
/// This is useful for checking unused dependencies.
|
||||
/// Should only be called once, as the compiler only emits it once per compilation.
|
||||
pub fn unused_externs(&self, unused_externs: Vec<String>) {
|
||||
pub fn unused_externs(&self, unused_externs: Vec<InternedString>) {
|
||||
self.messages
|
||||
.push(Message::UnusedExterns(self.id, unused_externs));
|
||||
}
|
||||
|
||||
@@ -149,6 +149,7 @@ use crate::util::CargoResult;
|
||||
use crate::util::context::WarningHandling;
|
||||
use crate::util::diagnostic_server::{self, DiagnosticPrinter};
|
||||
use crate::util::errors::AlreadyPrintedError;
|
||||
use crate::util::interning::InternedString;
|
||||
use crate::util::machine_message::{self, Message as _};
|
||||
use crate::util::{self, internal};
|
||||
use crate::util::{DependencyQueue, GlobalContext, Progress, ProgressStyle, Queue};
|
||||
@@ -387,7 +388,7 @@ enum Message {
|
||||
Finish(JobId, Artifact, CargoResult<()>),
|
||||
FutureIncompatReport(JobId, Vec<FutureBreakageItem>),
|
||||
SectionTiming(JobId, SectionTiming),
|
||||
UnusedExterns(JobId, Vec<String>),
|
||||
UnusedExterns(JobId, Vec<InternedString>),
|
||||
}
|
||||
|
||||
impl<'gctx> JobQueue<'gctx> {
|
||||
|
||||
@@ -2399,7 +2399,7 @@ fn on_stderr_line_inner(
|
||||
|
||||
#[derive(serde::Deserialize)]
|
||||
struct UnusedExterns {
|
||||
unused_extern_names: Vec<String>,
|
||||
unused_extern_names: Vec<InternedString>,
|
||||
}
|
||||
if let Ok(uext) = serde_json::from_str::<UnusedExterns>(compiler_message.get()) {
|
||||
trace!(
|
||||
|
||||
@@ -111,7 +111,11 @@ impl UnusedDepState {
|
||||
Self { states }
|
||||
}
|
||||
|
||||
pub fn record_unused_externs_for_unit(&mut self, unit: &Unit, unused_externs: Vec<String>) {
|
||||
pub fn record_unused_externs_for_unit(
|
||||
&mut self,
|
||||
unit: &Unit,
|
||||
unused_externs: Vec<InternedString>,
|
||||
) {
|
||||
let pkg_id = unit.pkg.package_id();
|
||||
let dep_kind = dep_kind_of(unit);
|
||||
trace!(
|
||||
@@ -129,7 +133,7 @@ impl UnusedDepState {
|
||||
.unused_externs
|
||||
.entry(unit.clone())
|
||||
.or_default()
|
||||
.extend(unused_externs.into_iter().map(|s| InternedString::new(&s)));
|
||||
.extend(unused_externs);
|
||||
}
|
||||
|
||||
#[instrument(skip_all)]
|
||||
|
||||
Reference in New Issue
Block a user