Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions lib.nix
Original file line number Diff line number Diff line change
Expand Up @@ -191,15 +191,21 @@ rec
pushd $out/$member > /dev/null
mkdir -p src

# Avoid accidentally pulling `std` for no-std crates.
echo '#![no_std]' >src/lib.rs

# pretend there's a `build.rs`, otherwise cargo doesn't build
# the `[build-dependencies]`. Custom locations of build scripts
# aren't an issue because we strip the `build` field in
# `fixupCargoToml`; so cargo always thinks there's a build
# script which is `./build.rs`.
echo 'fn main() {}' > build.rs
# We also add documentation to avoid rustc complaining about
# missing documentation: https://github.com/nix-community/naersk/issues/377
echo '//! stub crate' > build.rs
echo '/// stub main function' >> build.rs
echo 'fn main() {}' >> build.rs

# Avoid accidentally pulling `std` for no-std crates.
echo '//! stub lib' >src/lib.rs
echo '#![no_std]' >>src/lib.rs

popd > /dev/null
done

Expand Down
1 change: 1 addition & 0 deletions test/fast/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
git-dep-dup = pkgs.callPackage ./git-dep-dup { inherit naersk; };
git-single-repository-with-multiple-crates = pkgs.callPackage ./git-single-repository-with-multiple-crates { inherit naersk; };
git-symlink = pkgs.callPackage ./git-symlink { inherit naersk; };
stub-lints = pkgs.callPackage ./stub-lints { inherit naersk; };
openssl = pkgs.callPackage ./openssl { inherit naersk; };
post-install-hook = pkgs.callPackage ./post-install-hook { inherit naersk; };
readme = pkgs.callPackage ./readme { inherit naersk; };
Expand Down
13 changes: 13 additions & 0 deletions test/fast/stub-lints/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{ naersk, ... }:

naersk.buildPackage {
src = ./fixtures;
doCheck = true;

# we instruct cargo to error out if the 'missing-docs' lint is triggered. At the time of writing
# (30-01-2026) this is the only documentation lint that rustc looks for:
#
# > Note that, except for missing_docs, these lints are only available when running rustdoc, not rustc.
# > [https://doc.rust-lang.org/rustdoc/lints.html#lints]
CARGO_BUILD_RUSTFLAGS = "-D missing-docs"; # error out if 'missing-docs' is triggered
}
7 changes: 7 additions & 0 deletions test/fast/stub-lints/fixtures/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions test/fast/stub-lints/fixtures/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Tests that the stub/dummy "build.rs" does not fail on rustc lints
# https://github.com/nix-community/naersk/issues/377

[package]
name = "stub-lints"
version = "0.1.0"
authors = ["nicolas <nicolas@nmattia.com>"]
edition = "2018"

[dependencies]
6 changes: 6 additions & 0 deletions test/fast/stub-lints/fixtures/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//! Hello world!

/// Says hello
fn main() {
println!("Hello, world!");
}