diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 17eb2a543..a1d883496 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -116,7 +116,7 @@ jobs: strategy: fail-fast: false matrix: - feature: [capture-io, "cli,doc", "cli,fmt", cli, workspace, languageserver, byte-code] + feature: [capture-io, "cli,doc", "cli,fmt", cli, workspace, languageserver, byte-code, emit] env: RUSTFLAGS: -D warnings steps: diff --git a/crates/rune/src/compile/context.rs b/crates/rune/src/compile/context.rs index 92247e731..2c2eafd4c 100644 --- a/crates/rune/src/compile/context.rs +++ b/crates/rune/src/compile/context.rs @@ -478,7 +478,7 @@ impl Context { } /// Lookup meta by its hash. - #[cfg(any(feature = "cli", feature = "languageserver"))] + #[cfg(any(feature = "cli", feature = "languageserver", feature = "emit"))] pub(crate) fn lookup_meta_by_hash( &self, hash: Hash, @@ -508,7 +508,7 @@ impl Context { } /// Get all associated types for the given hash. - #[cfg(feature = "doc")] + #[cfg(feature = "cli")] pub(crate) fn associated(&self, hash: Hash) -> impl Iterator + '_ { self.associated .get(&hash) @@ -519,7 +519,7 @@ impl Context { } /// Get all traits implemented for the given hash. - #[cfg(feature = "doc")] + #[cfg(feature = "cli")] pub(crate) fn traits(&self, hash: Hash) -> impl Iterator + '_ { self.implemented_traits .get(&hash) @@ -546,7 +546,7 @@ impl Context { } /// Iterate over available crates. - #[cfg(feature = "doc")] + #[cfg(feature = "cli")] pub(crate) fn iter_crates(&self) -> impl Iterator { self.crates.iter().map(|s| s.as_ref()) } diff --git a/crates/rune/src/compile/docs.rs b/crates/rune/src/compile/docs.rs index e85a27fec..a93893f72 100644 --- a/crates/rune/src/compile/docs.rs +++ b/crates/rune/src/compile/docs.rs @@ -32,7 +32,7 @@ impl Docs { } /// Get lines of documentation. - #[cfg(feature = "doc")] + #[cfg(all(feature = "doc", any(feature = "languageserver", feature = "cli")))] pub(crate) fn lines(&self) -> &[String] { &self.docs } diff --git a/crates/rune/src/compile/meta.rs b/crates/rune/src/compile/meta.rs index 30d380c36..e08ca51fe 100644 --- a/crates/rune/src/compile/meta.rs +++ b/crates/rune/src/compile/meta.rs @@ -241,7 +241,7 @@ pub enum Kind { impl Kind { /// Access the underlying signature of the kind, if available. - #[cfg(feature = "doc")] + #[cfg(all(feature = "doc", any(feature = "languageserver", feature = "cli")))] pub(crate) fn as_signature(&self) -> Option<&Signature> { match self { Kind::Struct { constructor, .. } => constructor.as_ref(), @@ -424,7 +424,7 @@ pub(crate) enum DocName { Index(#[try_clone(copy)] usize), } -#[cfg(feature = "doc")] +#[cfg(feature = "cli")] impl DocName { pub(crate) fn is_self(&self) -> bool { match self { diff --git a/crates/rune/src/doc/mod.rs b/crates/rune/src/doc/mod.rs index 6a0463c6b..b1d82d3ef 100644 --- a/crates/rune/src/doc/mod.rs +++ b/crates/rune/src/doc/mod.rs @@ -1,15 +1,24 @@ //! Helper to generate documentation from a context. +#[cfg(feature = "cli")] mod context; +#[cfg(feature = "cli")] use self::context::Context; +#[cfg(feature = "cli")] mod artifacts; +#[cfg(feature = "cli")] pub(crate) use self::artifacts::{Artifacts, TestParams}; +#[cfg(feature = "cli")] mod templating; +#[cfg(feature = "cli")] mod build; +#[cfg(feature = "cli")] pub(crate) use self::build::build; +#[cfg(any(feature = "languageserver", feature = "cli"))] mod visitor; +#[cfg(any(feature = "languageserver", feature = "cli"))] pub(crate) use self::visitor::{Visitor, VisitorData}; diff --git a/crates/rune/src/doc/visitor.rs b/crates/rune/src/doc/visitor.rs index 9b634d305..863234080 100644 --- a/crates/rune/src/doc/visitor.rs +++ b/crates/rune/src/doc/visitor.rs @@ -8,9 +8,12 @@ use crate::item::IntoComponent; use crate::{Hash, Item, ItemBuf}; pub(crate) struct VisitorData { + #[cfg_attr(not(feature = "cli"), allow(dead_code))] pub(crate) item: ItemBuf, + #[cfg_attr(not(feature = "cli"), allow(dead_code))] pub(crate) hash: Hash, pub(crate) kind: Option, + #[cfg_attr(not(feature = "cli"), allow(dead_code))] pub(crate) deprecated: Option, pub(crate) docs: Vec, pub(crate) field_docs: HashMap, Vec>, @@ -71,6 +74,7 @@ impl Visitor { } /// Get meta by item. + #[cfg(feature = "cli")] pub(crate) fn get(&self, item: &Item) -> Option<&VisitorData> { let hash = self.item_to_hash.get(item)?; self.data.get(hash) diff --git a/crates/rune/src/runtime/unit/storage.rs b/crates/rune/src/runtime/unit/storage.rs index 5865d7025..6ea918885 100644 --- a/crates/rune/src/runtime/unit/storage.rs +++ b/crates/rune/src/runtime/unit/storage.rs @@ -197,6 +197,7 @@ cfg_std! { enum EncodeErrorKind { #[cfg(feature = "byte-code")] StorageError { + #[cfg_attr(not(feature = "std"), allow(dead_code))] error: storage::Error, }, AllocError {