Merge pull request #167499 from K900/bindgen-fixes

rust: bindgen fixes
This commit is contained in:
Artturi 2022-04-09 14:31:24 +03:00 committed by GitHub
commit 26b32f1b24
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 23 deletions

View file

@ -0,0 +1,13 @@
--- a/src/tools/rustfmt/src/ignore_path.rs
+++ b/src/tools/rustfmt/src/ignore_path.rs
@@ -37,9 +37,9 @@
#[nightly_only_test]
#[test]
fn test_ignore_path_set() {
- use std::path::{Path, PathBuf};
use crate::config::{Config, FileName};
use crate::ignore_path::IgnorePathSet;
+ use std::path::{Path, PathBuf};
let config =
Config::from_toml(r#"ignore = ["foo.rs", "bar_dir/*"]"#, Path::new("")).unwrap();

View file

@ -1,7 +1,7 @@
{ lib, stdenv, rustPlatform, Security }:
{ lib, stdenv, rustPlatform, Security, asNightly ? false }:
rustPlatform.buildRustPackage rec {
pname = "rustfmt";
pname = "rustfmt" + lib.optionalString asNightly "-nightly";
inherit (rustPlatform.rust.rustc) version src;
# the rust source tarball already has all the dependencies vendored, no need to fetch them again
@ -19,7 +19,10 @@ rustPlatform.buildRustPackage rec {
# As of rustc 1.45.0, these env vars are required to build rustfmt (due to
# https://github.com/rust-lang/rust/pull/72001)
CFG_RELEASE = rustPlatform.rust.rustc.version;
CFG_RELEASE_CHANNEL = "stable";
CFG_RELEASE_CHANNEL = if asNightly then "nightly" else "stable";
# FIXME: seems fixed upstream, remove after the next update
patches = [ ./rustfmt-fix-self-tests.patch ];
meta = with lib; {
description = "A tool for formatting Rust code according to style guidelines";

View file

@ -1,9 +1,11 @@
{ lib, fetchFromGitHub, rustPlatform, clang, rustfmt, writeTextFile
{ lib, fetchFromGitHub, rustPlatform, clang, rustfmt
, runtimeShell
, bash
}:
rustPlatform.buildRustPackage rec {
let
# bindgen hardcodes rustfmt outputs that use nightly features
rustfmt-nightly = rustfmt.override { asNightly = true; };
in rustPlatform.buildRustPackage rec {
pname = "rust-bindgen-unwrapped";
version = "0.59.2";
@ -25,23 +27,10 @@ rustPlatform.buildRustPackage rec {
'';
doCheck = true;
checkInputs =
let fakeRustup = writeTextFile {
name = "fake-rustup";
executable = true;
destination = "/bin/rustup";
text = ''
#!${runtimeShell}
shift
shift
exec "$@"
'';
};
in [
rustfmt
fakeRustup # the test suite insists in calling `rustup run nightly rustfmt`
clang
];
checkInputs = [ clang ];
RUSTFMT = "${rustfmt-nightly}/bin/rustfmt";
preCheck = ''
# for the ci folder, notably
patchShebangs .