profile
viewpoint
Josh Stone cuviper Red Hat Portland, OR https://blog.cuviper.com AKA jistone

bluss/indexmap 449

A hash table with consistent order and fast iteration; access items by key or sequence index

bluss/either 144

The enum Either with variants Left and Right is a general purpose sum type with two cases.

agrover/froyo 59

A flexible and redundant long-term storage system for Linux, using DM and XFS

cuviper/autocfg 21

Automatic cfg for Rust compiler features

cuviper/alloc_geiger 5

A Rust allocator which makes sound when active, like a Geiger counter.

cuviper/cm-kernel 5

CyanogenMod Linux Kernel for the HTC Incredible

cuviper/android_device_htc_inc 2

WIP repo for CM Inc. Beware, this is where I break stuff...

cuviper/addr2line 0

A cross-platform `addr2line` clone written in Rust, using `gimli`

cuviper/alga 0

Abstract algebra for Rust.

push eventrust-lang/llvm-project

B YI

commit sha 9f65ad057357b307180955831968f79e74090a90

fix unsilenceable warnings on GCC 9 (#41) See issue https://github.com/rust-lang/rust/issues/69078 for details --- [cmake] Disable GCC 9's -Winit-list-lifetime warning in ArrayRef Summary: This is a new warning which fires when one stores a reference to the initializer_list contents in a way which may outlive the initializer_list which it came from. In llvm this warning is triggered whenever someone uses the initializer_list ArrayRef constructor. This is indeed a dangerous thing to do (I myself was bitten by that at least once), but it is not more dangerous than calling other ArrayRef constructors with temporary objects -- something which we are used to and have accepted as a tradeoff for ArrayRef's efficiency. Currently, this warnings generates so much output that it completely obscures any actionable warnings, so this patch disables it. Reviewers: rnk, aaron.ballman Subscribers: mgorny, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D70122 (cherry picked from commit 6c2151bf4c829958891e65a4cc396daa6d308eb0) Co-authored-by: Pavel Labath <pavel@labath.sk>

view details

push time in 15 minutes

PR merged rust-lang/llvm-project

fix unsilenceable warnings on GCC 9

See issue https://github.com/rust-lang/rust/issues/69078 for details

+10 -0

3 comments

1 changed file

contrun

pr closed time in 15 minutes

pull request commentrust-lang/llvm-project

fix unsilenceable warnings on GCC 9

Thanks!

contrun

comment created time in 15 minutes

issue commentrust-lang/rust

Instantiate fewer copies of a closure inside a generic function

It seems to me that "does this type parameter appear" would have to see through to the associated type I::Item, and not count that as an appearance of I itself.

How would this work, replace I::Item with a generic parameter?

Something like that, yes. I'm sure it is harder request for the compiler, but this issue was cited as a possible solution to replace #62429 -- in a lot of those cases, the whole point was to be generic on the Item type rather than the broader iterator.

Your Item = impl ... trick is neat for my specific example, but I don't think that will always apply. Those real cases on Iterators are dealing with parameters of Self (like Map<I, F>) and then doing something in a closure with I::Item or Self::Item. We also can't change the API of those methods to add new type parameters, whether explicit or impl ....

You might also want to consider iter.map(Into::into).map(move |y| x * y).

Sure, but that was already an artificial example, just trying to show the scope of generics.

Actually, there is probably a trick we can use: we can have the same generics as if I was unused, but then add a <I as Item>::Item == X bound to the ParamEnv for every X we monomorphize on. That way the compiler doesn't have to invent generics, and IMO that's also the way I would want to handle monomorphizing only based on the size/align of a type but nothing else. (we'd have bounds in the ParamEnv describing those properties)

I don't know enough of these details, but it sounds plausible to me! :)

dtolnay

comment created time in 2 hours

issue commentrust-lang/rust

Instantiate fewer copies of a closure inside a generic function

in fact, I think all you need is to implement TypeVisitor::visit_ty and put MIR through it, accumulating a bitset of "does this type parameter appear", at least on the analysis side.

Would this see through associated types?

The question of type sizes came up again in the users forum, akin to #62429. I gave this example of how things can go bad, and how to manually fix it:

fn multiply<I>(iter: I, x: f64) -> impl Iterator<Item = f64>
where
    I: Iterator,
    I::Item: Into<f64>,
{
    iter.map(move |item| x * item.into())
}

fn multiply2<I>(iter: I, x: f64) -> impl Iterator<Item = f64>
where
    I: Iterator,
    I::Item: Into<f64>,
{
    fn mul<T: Into<f64>>(x: f64) -> impl Fn(T) -> f64 {
        move |item| x * item.into()
    }
    iter.map(mul(x))
}

fn iter() -> impl Iterator<Item = i32> {
    (0..10).map(|i| i * 42)
}

pub fn foo() {
    let _ = multiply(iter(), 2.0);
    let _ = multiply2(iter(), 2.0);
}

This creates expanded types like this:

; playground::foo
; Function Attrs: nonlazybind uwtable
define void @_ZN10playground3foo17hbce2de427f35bc00E() unnamed_addr #1 !dbg !161 {
start:
  %_3 = alloca %"core::iter::adapters::Map<core::iter::adapters::Map<core::ops::range::Range<i32>, iter::{{closure}}>, multiply2::mul::{{closure}}<i32>>", align 8
  %_1 = alloca %"core::iter::adapters::Map<core::iter::adapters::Map<core::ops::range::Range<i32>, iter::{{closure}}>, multiply::{{closure}}<core::iter::adapters::Map<core::ops::range::Range<i32>, iter::{{closure}}>>>", align 8
...

It would be nice if multiply::{{closure}} could automatically be reduced like I did manually for multiply2::mul::{{closure}}. It seems to me that "does this type parameter appear" would have to see through to the associated type I::Item, and not count that as an appearance of I itself.

dtolnay

comment created time in 3 hours

Pull request review commentdtolnay/thiserror

Support no_std

 readme = "README.md" travis-ci = { repository = "dtolnay/thiserror" }  [dependencies]-thiserror-impl = { version = "=1.0.11", path = "impl" }+thiserror-impl = { version = "=1.0.11", path = "impl", default-features = false }  [dev-dependencies] anyhow = "1.0" ref-cast = "1.0" rustversion = "1.0" trybuild = { version = "1.0.19", features = ["diff"] } +[features]+default = ["std"]

Note, this is technically a breaking change if anyone was already using thiserror with default-features = false, as they will now have reduced functionality.

I got burned by this when I added no_std to num crates -- https://github.com/rust-num/num/issues/297. I've seen a lot of crates brush that off though, whether deliberate or not.

IcyDefiance

comment created time in 4 hours

pull request commentrust-lang/llvm-project

fix unsilenceable warnings on GCC 9

Please use git cherry-pick -x ... so we have the connection to upstream LLVM, including authorship. You can then amend the commit message to add Rust-special details if you like.

contrun

comment created time in 16 hours

pull request commentrust-lang/cargo

Ignore the host in rustc.verbose_version for metadata

If the goal is, "same artifacts for different host compilers", wouldn't different filenames defeat that?

The filename would be based on the target triple, regardless of host. The filenames of transient host pieces (build deps) would be different according to host compiler, but the end target files should be the same, and those are what we would ship. Right?

cuviper

comment created time in 18 hours

Pull request review commentrust-num/num-rational

WIP: add more formatting traits

 impl<T: Clone + Integer + Signed> Signed for Ratio<T> { }  // String conversions-impl<T> fmt::Display for Ratio<T>-where-    T: fmt::Display + Eq + One,-{-    /// Renders as `numer/denom`. If denom=1, renders as numer.-    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {-        if self.denom.is_one() {-            write!(f, "{}", self.numer)-        } else {-            write!(f, "{}/{}", self.numer, self.denom)+macro_rules! impl_formatting {+    ($fmt_trait:ident, $prefix:expr, $fmt_str:expr, $fmt_alt:expr) => {+        impl<T: $fmt_trait + PartialEq + One> $fmt_trait for Ratio<T> {

In your first few commits, you had non_negative checking for the sign placement, which seems to be gone now. That's what I'm referring to for better handling of negative values. I'm still unsure how I feel about that binary formatting...

I think it's ok to lose f32 support, just test Exp on newer toolchains where supported for integers.

maxbla

comment created time in 19 hours

Pull request review commentrust-num/num-rational

WIP: add more formatting traits

 mod test {         assert!(!_NEG1_2.is_integer());     } +    #[cfg(not(feature = "std"))]+    use core::fmt;+    #[cfg(not(feature = "std"))]+    use fmt::Write;+    #[cfg(not(feature = "std"))]+    const TESTER_BUF_SIZE: usize = 32;+    #[cfg(not(feature = "std"))]+    #[derive(Debug)]+    struct NoStdTester {+        cursor: usize,+        buf: [u8; TESTER_BUF_SIZE],+    }++    #[cfg(not(feature = "std"))]+    impl NoStdTester {+        fn new() -> NoStdTester {+            NoStdTester {+                buf: [0; TESTER_BUF_SIZE],+                cursor: 0,+            }+        }++        fn clear(&mut self) {+            self.cursor = 0;+        }+    }++    #[cfg(not(feature = "std"))]+    impl Write for NoStdTester {+        fn write_str(&mut self, s: &str) -> fmt::Result {+            for byte in s.bytes() {+                self.buf[self.cursor] = byte;+                self.cursor += 1;+                if self.cursor >= self.buf.len() {+                    return Err(fmt::Error {});+                }+            }+            Ok(())+        }+    }++    #[cfg(not(feature = "std"))]+    impl PartialEq<str> for NoStdTester {+        fn eq(&self, other: &str) -> bool {+            let other = other.as_bytes();+            for index in 0..self.cursor {+                if self.buf.get(index) != other.get(index) {+                    return false;+                }+            }+            true+        }+    }++    #[test]+    #[cfg(not(feature = "std"))]+    fn test_show() {+        let err_msg = "Formatted output too long";+        let mut tester = NoStdTester::new();+        write!(tester, "{:o}", _8).expect(err_msg);+        assert_eq!(tester, *"10");+        tester.clear();+    }+     #[test]     #[cfg(feature = "std")]     fn test_show() {-        use std::string::ToString;-        assert_eq!(format!("{}", _2), "2".to_string());-        assert_eq!(format!("{}", _1_2), "1/2".to_string());-        assert_eq!(format!("{}", _0), "0".to_string());-        assert_eq!(format!("{}", Ratio::from_integer(-2)), "-2".to_string());+        // Test:+        // :b :o :x, :X, :?+        // alternate or not (#)+        // positive and negative+        // padding+        // does not test precision (i.e. truncation)+        assert_eq!(&format!("{}", _2), "2");+        assert_eq!(&format!("{}", _1_2), "1/2");+        assert_eq!(&format!("{}", -_1_2), "-1/2"); // test negatives+        assert_eq!(&format!("{}", _0), "0");+        assert_eq!(&format!("{}", -_2), "-2");+        assert_eq!(&format!("{:b}", _2), "10");+        assert_eq!(&format!("{:b}", _1_2), "1/10");+        assert_eq!(&format!("{:b}", _0), "0");+        assert_eq!(&format!("{:#b}", _1_2), "0b1/0b10");+        assert_eq!(&format!("{:010b}", _1_2), "0000001/10");+        assert_eq!(&format!("{:#010b}", _1_2), "0b001/0b10");+        let half_i8: Ratio<i8> = Ratio::new(1_i8, 2_i8);+        assert_eq!(&format!("{:b}", -half_i8), "11111111/10");+        assert_eq!(&format!("{:#b}", -half_i8), "0b11111111/0b10");++        assert_eq!(&format!("{:o}", _8), "10");+        assert_eq!(&format!("{:o}", _1_8), "1/10");+        assert_eq!(&format!("{:o}", _0), "0");+        assert_eq!(&format!("{:#o}", _1_8), "0o1/0o10");+        assert_eq!(&format!("{:010o}", _1_8), "0000001/10");+        assert_eq!(&format!("{:#010o}", _1_8), "0o001/0o10");+        assert_eq!(&format!("{:o}", -half_i8), "377/2");+        assert_eq!(&format!("{:#o}", -half_i8), "0o377/0o2");++        assert_eq!(&format!("{:x}", _16), "10");+        assert_eq!(&format!("{:x}", _15), "f");+        assert_eq!(&format!("{:x}", _1_16), "1/10");+        assert_eq!(&format!("{:x}", _1_15), "1/f");+        assert_eq!(&format!("{:x}", _0), "0");+        assert_eq!(&format!("{:#x}", _1_16), "0x1/0x10");+        assert_eq!(&format!("{:010x}", _1_16), "0000001/10");+        assert_eq!(&format!("{:#010x}", _1_16), "0x001/0x10");+        assert_eq!(&format!("{:x}", -half_i8), "ff/2");+        assert_eq!(&format!("{:#x}", -half_i8), "0xff/0x2");++        assert_eq!(&format!("{:X}", _16), "10");+        assert_eq!(&format!("{:X}", _15), "F");+        assert_eq!(&format!("{:X}", _1_16), "1/10");+        assert_eq!(&format!("{:X}", _1_15), "1/F");+        assert_eq!(&format!("{:X}", _0), "0");+        assert_eq!(&format!("{:#X}", _1_16), "0x1/0x10");+        assert_eq!(&format!("{:010X}", _1_16), "0000001/10");+        assert_eq!(&format!("{:#010X}", _1_16), "0x001/0x10");+        assert_eq!(&format!("{:X}", -half_i8), "FF/2");+        assert_eq!(&format!("{:#X}", -half_i8), "0xFF/0x2");++        let _one_tehth_1_f = Ratio {

I found rust-lang/rust#66721, congrats!

We could add back a build script and use autocfg to probe for available support, giving you a cfg flag to guard the test case. It will only work on nightlies for now, but that will trickle down.

maxbla

comment created time in 19 hours

Pull request review commentrust-num/num-rational

WIP: add more formatting traits

 mod test {         assert!(!_NEG1_2.is_integer());     } +    #[cfg(not(feature = "std"))]+    use core::fmt;+    #[cfg(not(feature = "std"))]+    use fmt::Write;

The bigint feature is now a no-std form, which requires Rust 1.36 for the alloc crate. Use bigint-std here to turn on full num-bigint/std in the dependency.

maxbla

comment created time in 19 hours

pull request commentrust-lang/cargo

Ignore the host in rustc.verbose_version for metadata

@alexcrichton if the host triple is still in the metadata for build scripts, proc-macros, etc., then that will also affect the target metadata when dependencies are hashed in.

Any thoughts on separating the metadata and extra-filename? Basically, unit.kind.short_name() would only need to go into the file name, leaving metadata "pure".

cuviper

comment created time in 19 hours

PR opened rust-num/num-bigint

impl PartialEq and PartialOrd with primitives

This rebases and extends #105 (cc @hansihe). As noted before, it may hurt type inference where callers use comparison operators that relied on only one possible impl before. We're on the way to 0.3 though, so even a relatively minor break like that is perfectly allowable.

+473 -103

0 comment

9 changed files

pr created time in 20 hours

create barnchcuviper/num-bigint

branch : primitive-cmp

created branch time in 20 hours

pull request commentKoka/gettext-rs

Upgrade to locale_config 0.3

CI seems to have timed out building gettext -- is that normal?

cuviper

comment created time in 20 hours

issue commentrust-lang/rust

Memory unsafety problem in safe Rust

1.37.0 seems safe to me (no combination of options I tried produces a segfault).

That's using LLVM 8, so the blamed SCEV change shouldn't exist at all.

dfyz

comment created time in 21 hours

pull request commentrust-lang/rust

Cherry-pick the LLVM fix for #69225

r? @nikic

cuviper

comment created time in 21 hours

PR opened rust-lang/rust

Cherry-pick the LLVM fix for #69225

An additional reproducer was provided in #69225 -- the new testcase here -- which still crashes even after #69241 reverted #67174. Now this pull request updates LLVM with the cherry-picked reversion of its own. This is also going to stable in #69444.

I have not tried to reapply #67241 yet -- cc @kraai @shahn

+34 -1

0 comment

2 changed files

pr created time in 21 hours

create barnchcuviper/rust

branch : llvm-scev-no-wrap

created branch time in 21 hours

issue commentrust-lang/rust

Memory unsafety problem in safe Rust

FWIW, for me the new reproducer works as expected (index out of bounds) on stable 1.38.0 and earlier, but segfaults on 1.39.0 and later. There's not a whole lot of difference in LLVM between 1.38 and 1.39 (https://github.com/rust-lang/llvm-project/compare/71fe7ec06b85f612fc0e4eb4134c7a7d0f23fac5...8adf9bdccfefb8d03f0e8db3b012fb41da1580a4), but it could be any sort of Rust-generated difference along the way too.

dfyz

comment created time in a day

PR closed rust-lang/llvm-project

Revert "[SCEV] add no wrap flag for SCEVAddExpr."

This reverts r366419 because the analysis performed is within the context of the loop and it's only valid to add wrapping flags to "global" expressions if they're always correct.

llvm-svn: 373184 (cherry picked from commit 58e8c793d0e43150a6452e971a32d7407a8a7401)


This is backported for Rust's LLVM 9 per https://github.com/rust-lang/rust/issues/69225#issuecomment-588888172 (same as #39, but targeting the LLVM branch used by Rust 1.41)

+8 -8

3 comments

5 changed files

cuviper

pr closed time in a day

pull request commentrust-lang/llvm-project

Revert "[SCEV] add no wrap flag for SCEVAddExpr."

OK, I pushed rustc/9.0-2019-09-19-rust-1.41

cuviper

comment created time in a day

create barnchrust-lang/llvm-project

branch : rustc/9.0-2019-09-19-rust-1.41

created branch time in a day

pull request commentrust-lang/llvm-project

Revert "[SCEV] add no wrap flag for SCEVAddExpr."

Hmm, it looks like stable 1.41 actually shipped with 2cb41005ed5c4747b10d2bf01d8779d3bb4ae32d, so there are a few other changes on top of that too.

https://github.com/rust-lang/llvm-project/compare/2cb41005ed5c4747b10d2bf01d8779d3bb4ae32d...cuviper:rust-revert-r366419-1.41?expand=1

If we want to be more focused for 1.41 backports, I can push a new LLVM branch.

cuviper

comment created time in a day

PR opened rust-lang/llvm-project

Revert "[SCEV] add no wrap flag for SCEVAddExpr."

This reverts r366419 because the analysis performed is within the context of the loop and it's only valid to add wrapping flags to "global" expressions if they're always correct.

llvm-svn: 373184 (cherry picked from commit 58e8c793d0e43150a6452e971a32d7407a8a7401)


This is backported for Rust's LLVM 9 per https://github.com/rust-lang/rust/issues/69225#issuecomment-588888172 (same as #39, but targeting the LLVM branch used by Rust 1.41)

+8 -8

0 comment

5 changed files

pr created time in a day

create barnchcuviper/llvm-project

branch : rust-revert-r366419-1.41

created branch time in a day

create barnchcuviper/llvm-project

branch : rust-revert-r366419

created branch time in a day

pull request commentrust-lang/llvm-project

Revert "[SCEV] add no wrap flag for SCEVAddExpr."

cc @comex @nikic

cuviper

comment created time in a day

PR opened rust-lang/llvm-project

Revert "[SCEV] add no wrap flag for SCEVAddExpr."

This reverts r366419 because the analysis performed is within the context of the loop and it's only valid to add wrapping flags to "global" expressions if they're always correct.

llvm-svn: 373184 (cherry picked from commit 58e8c793d0e43150a6452e971a32d7407a8a7401)


This is backported for Rust's LLVM 9 per https://github.com/rust-lang/rust/issues/69225#issuecomment-588888172

+8 -8

0 comment

5 changed files

pr created time in a day

Pull request review commentrayon-rs/rayon

add step by parallel iterator.

+use super::plumbing::*;+use super::*;+use std::iter;+use std::usize;++/// `StepBy` is an iterator that skip `n` element between each yield. where `n` is the given step+/// This struct is created by the [`step_by()`] method on [`IndexedParallelIterator`]+///+/// [`step_by()`]: trait.IndexedParallelIterator.html#method.step_by+/// [`IndexedParallelIterator`]: trait.IndexedParallelIterator.html+#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]+#[derive(Debug, Clone)]+pub struct StepBy<I: IndexedParallelIterator> {+    base: I,+    step: usize,+}++impl<I> StepBy<I>+    where+        I: IndexedParallelIterator,+{+    /// Create a new `StepBy` iterator.+    pub(super) fn new(base: I, step: usize) -> Self {+        StepBy { base, step }+    }+}++impl<I> ParallelIterator for StepBy<I>+    where+        I: IndexedParallelIterator,+{+    type Item = I::Item;++    fn drive_unindexed<C>(self, consumer: C) -> C::Result+        where+            C: UnindexedConsumer<Self::Item>, {+        bridge(self, consumer)+    }+}++impl<I> IndexedParallelIterator for StepBy<I>+    where+        I: IndexedParallelIterator,+{+    fn drive<C: Consumer<Self::Item>>(self, consumer: C) -> C::Result {+        bridge(self, consumer)+    }++    fn len(&self) -> usize {+        if (self.base.len() % self.step) == 0 {+            self.base.len() / self.step+        }+        else {+            //the addition is needed because the first element is always yielded+            (self.base.len() / self.step) + 1+        }+    }++    fn with_producer<CB>(self, callback: CB) -> CB::Output+        where+            CB: ProducerCallback<Self::Item>,+    {+        return self.base.with_producer(Callback {callback, step: self.step});++        struct Callback<CB> {+            callback: CB,+            step: usize,+        }++        impl<T, CB> ProducerCallback<T> for Callback<CB>+            where+                CB: ProducerCallback<T>,+        {+            type Output = CB::Output;+            fn callback<P>(self, base: P) -> CB::Output+                where+                    P: Producer<Item = T>,+            {+                let producer = StepByProducer { base, step: self.step };+                self.callback.callback(producer)+            }+        }+    }+}++/// ////////////////////////////////////////////////////////////////////////+/// Producer implementation++struct StepByProducer<P> {+    base: P,+    step: usize,+}++impl<P> Producer for StepByProducer<P>+    where+        P: Producer,+{+    type Item = P::Item;+    type IntoIter = iter::StepBy<P::IntoIter>;++    fn into_iter(self) -> Self::IntoIter {+        self.base.into_iter().step_by(self.step)+    }++    fn split_at(self, index: usize) -> (Self, Self) {+        let (left, right) = self.base.split_at(index * self.step);+        (+            StepByProducer {+                base: left,+                step: self.step,+            },+            StepByProducer {+                base: right,+                step: self.step,+            },+        )+    }+}

This should also define min_len and max_len -- again the same math as src/iter/chunks.rs.

FlyingCanoe

comment created time in a day

Pull request review commentrayon-rs/rayon

add step by parallel iterator.

+use super::plumbing::*;+use super::*;+use std::iter;+use std::usize;++/// `StepBy` is an iterator that skip `n` element between each yield. where `n` is the given step+/// This struct is created by the [`step_by()`] method on [`IndexedParallelIterator`]+///+/// [`step_by()`]: trait.IndexedParallelIterator.html#method.step_by+/// [`IndexedParallelIterator`]: trait.IndexedParallelIterator.html+#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]+#[derive(Debug, Clone)]+pub struct StepBy<I: IndexedParallelIterator> {+    base: I,+    step: usize,+}++impl<I> StepBy<I>+    where+        I: IndexedParallelIterator,+{+    /// Create a new `StepBy` iterator.+    pub(super) fn new(base: I, step: usize) -> Self {+        StepBy { base, step }+    }+}++impl<I> ParallelIterator for StepBy<I>+    where+        I: IndexedParallelIterator,+{+    type Item = I::Item;++    fn drive_unindexed<C>(self, consumer: C) -> C::Result+        where+            C: UnindexedConsumer<Self::Item>, {+        bridge(self, consumer)+    }+}

This should also define opt_len -- just return Some(self.len()).

FlyingCanoe

comment created time in a day

Pull request review commentrayon-rs/rayon

add step by parallel iterator.

+use super::plumbing::*;+use super::*;+use std::iter;+use std::usize;++/// `StepBy` is an iterator that skip `n` element between each yield. where `n` is the given step+/// This struct is created by the [`step_by()`] method on [`IndexedParallelIterator`]+///+/// [`step_by()`]: trait.IndexedParallelIterator.html#method.step_by+/// [`IndexedParallelIterator`]: trait.IndexedParallelIterator.html+#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]+#[derive(Debug, Clone)]+pub struct StepBy<I: IndexedParallelIterator> {+    base: I,+    step: usize,+}++impl<I> StepBy<I>+    where+        I: IndexedParallelIterator,+{+    /// Create a new `StepBy` iterator.+    pub(super) fn new(base: I, step: usize) -> Self {+        StepBy { base, step }+    }+}++impl<I> ParallelIterator for StepBy<I>+    where+        I: IndexedParallelIterator,+{+    type Item = I::Item;++    fn drive_unindexed<C>(self, consumer: C) -> C::Result+        where+            C: UnindexedConsumer<Self::Item>, {+        bridge(self, consumer)+    }+}++impl<I> IndexedParallelIterator for StepBy<I>+    where+        I: IndexedParallelIterator,+{+    fn drive<C: Consumer<Self::Item>>(self, consumer: C) -> C::Result {+        bridge(self, consumer)+    }++    fn len(&self) -> usize {+        if (self.base.len() % self.step) == 0 {+            self.base.len() / self.step+        }+        else {+            //the addition is needed because the first element is always yielded+            (self.base.len() / self.step) + 1+        }+    }

We have a helper crate::math::div_round_up that should work here. It's used in the chunk iterators that need a similar computation.

FlyingCanoe

comment created time in a day

issue commentrayon-rs/rayon

Implement step_by

I don't think we should bump the MSRV for this feature. We can either implement our own version of the StepBy iterator, or add a build script which detects support to set a cfg (so it wouldn't be available at all earlier). Use autocfg if you go for a build script, where you can probe an expression like (0..10).step_by(2).rev().

hherman1

comment created time in a day

pull request commentrust-num/num-traits

Removed repeated words

Heh, gotta love a copy-pasted typo. Thanks!

bors r+

vallentin

comment created time in 4 days

issue commentlibgit2/libgit2

1.0 planning / next few releases

OK, thanks, good to know libssh won't be out of the question for the future.

ethomson

comment created time in 4 days

PR opened bluss/odds

Upgrade quickcheck and rawpointer
+2 -2

0 comment

1 changed file

pr created time in 5 days

create barnchcuviper/odds

branch : quickcheck-rawpointer

created branch time in 5 days

fork cuviper/odds

Odds and ends — collection miscellania. Extra functionality for slices, strings and other things

https://docs.rs/odds/

fork in 5 days

PR opened Koka/gettext-rs

Upgrade to locale_config 0.3

No code changes required.

+1 -1

0 comment

1 changed file

pr created time in 5 days

create barnchcuviper/gettext-rs

branch : locale_config-0.3

created branch time in 5 days

fork cuviper/gettext-rs

GNU Gettext FFI binding for Rust

fork in 5 days

PR opened rust-lang/rustup

Let docs pass through with custom toolchains

Following #2116, custom toolchains started to fail rustup doc, since they can't list components to check if rust-docs is installed.

error: toolchain 'system' does not support components
error: caused by: invalid toolchain name: 'system'

Now custom toolchains just skip that component check, and it's up to the user to have installed the documentation in their own way.

+24 -11

0 comment

2 changed files

pr created time in 5 days

create barnchcuviper/rustup.rs

branch : docs-custom

created branch time in 5 days

issue commentrust-num/num-traits

Why does the Float trait not inherit FloatConst?

FWIW, it should be easy to define your own combined trait for convenience, like:

use num_traits::{Float, FloatConst};
trait MyFloat: Float + FloatConst {}
impl<T: Float + FloatConst> MyFloat for T {}
stijnfrishert

comment created time in 5 days

issue closedrust-num/num-traits

Why does the Float trait not inherit FloatConst?

Makes sense to me that every Float should be able to provide values such as π by default.

(Once again, pretty new to Rust, so if this doesn't make any sense I'd love to learn why not too)

closed time in 5 days

stijnfrishert

issue commentrust-num/num-traits

Why does the Float trait not inherit FloatConst?

History. The Float trait existed before FloatConst, and it would be a breaking change to add new constraints now.

We could do that with a bump to the semantic version, but I've been loath to consider that since these traits are often in the public API of other crates. That would make it a breaking change for those crates to adopt new num-traits, so the ecosystem upgrade would be painful.

stijnfrishert

comment created time in 5 days

pull request commentrust-num/num-traits

Add the full circle constant τ (TAU)

It was published in num-traits 0.2.11, and num 0.2.1 also requires that.

m-ou-se

comment created time in 5 days

pull request commentcrossbeam-rs/crossbeam

Patch release for all crossbeam crates.

uh-oh, seems like a real bug... https://travis-ci.org/crossbeam-rs/crossbeam/jobs/651567571#L538

I was just looking at Fedora failed builds in that same test, on the current crossbeam-channel 0.4.0. In other words, I think this isn't new, at least.

$ for (( i=1 ;; i+=1 )); do echo "*** test $i ***"; cargo test --test ready fairness || break; done

This loops until failure -- usually I make it 20-30 times successfully. It seems to fails even more frequently with --release, so maybe the test just needs more allowance?

jonhoo

comment created time in 5 days

pull request commentJelteF/derive_more

Fix the include glob for tests/

FWIW, you can check what is included before publishing with cargo package --list.

cuviper

comment created time in 5 days

issue commentJelteF/derive_more

Some test files are not distributed on crates.io

"test/**/*.rs" should be tests/, plural -- #117.

silwol

comment created time in 5 days

PR opened JelteF/derive_more

Fix the include glob for tests/
+1 -1

0 comment

1 changed file

pr created time in 5 days

create barnchcuviper/derive_more

branch : include-tests

created branch time in 5 days

fork cuviper/derive_more

Some more derive(Trait) options

fork in 5 days

created tagcuviper/ssh-rs

tag0.1.0

A common library for linking libssh to rust programs.

created time in 5 days

created tagcuviper/ssh-rs

tag0.1.1

A common library for linking libssh to rust programs.

created time in 5 days

push eventcuviper/ssh-rs

Josh Stone

commit sha d9efadd0a5b303fe36ddf97c562f3e98cbb9e5f9

Release 0.1.1

view details

push time in 6 days

push eventcuviper/ssh-rs

Eugene Oden

commit sha 1ae15f286f3de12d7b5ce90e2d9724e3e544b0d1

Some bindings for public key verification, password authentication, and toggling blocking mode

view details

Josh Stone

commit sha 75cbe855ac7b477892b518d44c8e763cb6e5bebb

Merge pull request #4 from eugeneoden/pub_keys_known_hosts_passwd_auth_blocking Some bindings for public key verification, password authentication, and toggling blocking mode

view details

push time in 6 days

pull request commentRazrFalcon/cargo-bloat

Update dependencies

Would you mind switching memmap to memmap2?

Sure, done.

cuviper

comment created time in 6 days

push eventcuviper/cargo-bloat

Josh Stone

commit sha ba62863db968a11029aea10e42981c895dce1222

replace memmap 0.7 with memmap2 0.1

view details

push time in 6 days

issue commentRazrFalcon/pico-args

`cargo test --release` fails

I can simply hide them behind #[cfg(debug_assertions)]

I think that would better reflect your expected behavior, at least.

cuviper

comment created time in 6 days

PR opened RazrFalcon/cargo-bloat

Update dependencies
  • upgrade multimap 0.5 -> 0.8
  • upgrade pico-args 0.2 -> 0.3
  • remove time 0.1
    • std::time::Instant does the same job
+24 -42

0 comment

3 changed files

pr created time in 6 days

create barnchcuviper/cargo-bloat

branch : update-deps

created branch time in 6 days

fork cuviper/cargo-bloat

Find out what takes most of the space in your executable.

fork in 6 days

issue openedRazrFalcon/pico-args

`cargo test --release` fails

While cargo test passes for me, cargo test --release fails a few tests.

failures:

---- invalid_flag_02 stdout ----
note: test did not panic as expected
---- invalid_flag_03 stdout ----
note: test did not panic as expected
---- invalid_flag_04 stdout ----
note: test did not panic as expected

failures:
    invalid_flag_02
    invalid_flag_03
    invalid_flag_04

I think this is because the From impls use debug_assert, which does nothing in release builds. Oddly, invalid_flag_01 still passed, but using cargo test -- --nocapture I can see that it's hitting different asserts in debug/release builds, so it still satisfies #[should_panic].

Note: we test release builds in Fedora so our full rpm build+check all uses the same thing.

created time in 6 days

Pull request review commentrust-num/num-rational

WIP: add more formatting traits

 impl<T: Clone + Integer + Signed> Signed for Ratio<T> { }  // String conversions-impl<T> fmt::Display for Ratio<T>-where-    T: fmt::Display + Eq + One,-{-    /// Renders as `numer/denom`. If denom=1, renders as numer.-    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {-        if self.denom.is_one() {-            write!(f, "{}", self.numer)-        } else {-            write!(f, "{}/{}", self.numer, self.denom)+macro_rules! impl_formatting {+    ($fmt_trait:ident, $prefix:expr, $fmt_str:expr, $fmt_alt:expr) => {+        impl<T: $fmt_trait + PartialEq + One> $fmt_trait for Ratio<T> {

That would let you restore better handling for negative values too, right?

maxbla

comment created time in 6 days

Pull request review commentrust-num/num-rational

WIP: add more formatting traits

 mod test {         assert!(!_NEG1_2.is_integer());     } +    #[cfg(not(feature = "std"))]+    use core::fmt;+    #[cfg(not(feature = "std"))]+    use fmt::Write;+    #[cfg(not(feature = "std"))]+    const TESTER_BUF_SIZE: usize = 32;+    #[cfg(not(feature = "std"))]+    #[derive(Debug)]+    struct NoStdTester {+        cursor: usize,+        buf: [u8; TESTER_BUF_SIZE],+    }++    #[cfg(not(feature = "std"))]+    impl NoStdTester {+        fn new() -> NoStdTester {+            NoStdTester {+                buf: [0; TESTER_BUF_SIZE],+                cursor: 0,+            }+        }++        fn clear(&mut self) {+            self.cursor = 0;+        }+    }++    #[cfg(not(feature = "std"))]+    impl Write for NoStdTester {+        fn write_str(&mut self, s: &str) -> fmt::Result {+            for byte in s.bytes() {+                self.buf[self.cursor] = byte;+                self.cursor += 1;+                if self.cursor >= self.buf.len() {+                    return Err(fmt::Error {});+                }+            }+            Ok(())+        }+    }++    #[cfg(not(feature = "std"))]+    impl PartialEq<str> for NoStdTester {+        fn eq(&self, other: &str) -> bool {+            let other = other.as_bytes();+            for index in 0..self.cursor {+                if self.buf.get(index) != other.get(index) {+                    return false;+                }+            }+            true+        }+    }++    #[test]+    #[cfg(not(feature = "std"))]+    fn test_show() {+        let err_msg = "Formatted output too long";+        let mut tester = NoStdTester::new();+        write!(tester, "{:o}", _8).expect(err_msg);+        assert_eq!(tester, *"10");

Can you please add an alt test, as well as non-integral values?

maxbla

comment created time in 6 days

Pull request review commentrust-num/num-rational

WIP: add more formatting traits

 impl<T: Clone + Integer + Signed> Signed for Ratio<T> { }  // String conversions-impl<T> fmt::Display for Ratio<T>-where-    T: fmt::Display + Eq + One,-{-    /// Renders as `numer/denom`. If denom=1, renders as numer.-    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {-        if self.denom.is_one() {-            write!(f, "{}", self.numer)-        } else {-            write!(f, "{}/{}", self.numer, self.denom)+macro_rules! impl_formatting {+    ($fmt_trait:ident, $prefix:expr, $fmt_str:expr, $fmt_alt:expr) => {+        impl<T: $fmt_trait + PartialEq + One> $fmt_trait for Ratio<T> {

I think I'd prefer to have the formatting traits require T: Clone + Integer, like most of the API. Even if we don't need it now, it's a slight bit of future-proofing to have those constraints available.

maxbla

comment created time in 6 days

Pull request review commentrust-num/num-rational

WIP: add more formatting traits

 mod test {         assert!(!_NEG1_2.is_integer());     } +    #[cfg(not(feature = "std"))]+    use core::fmt;+    #[cfg(not(feature = "std"))]+    use fmt::Write;+    #[cfg(not(feature = "std"))]+    const TESTER_BUF_SIZE: usize = 32;+    #[cfg(not(feature = "std"))]+    #[derive(Debug)]+    struct NoStdTester {+        cursor: usize,+        buf: [u8; TESTER_BUF_SIZE],+    }++    #[cfg(not(feature = "std"))]+    impl NoStdTester {+        fn new() -> NoStdTester {+            NoStdTester {+                buf: [0; TESTER_BUF_SIZE],+                cursor: 0,+            }+        }++        fn clear(&mut self) {+            self.cursor = 0;+        }+    }++    #[cfg(not(feature = "std"))]+    impl Write for NoStdTester {+        fn write_str(&mut self, s: &str) -> fmt::Result {+            for byte in s.bytes() {+                self.buf[self.cursor] = byte;+                self.cursor += 1;+                if self.cursor >= self.buf.len() {+                    return Err(fmt::Error {});+                }+            }+            Ok(())+        }+    }++    #[cfg(not(feature = "std"))]+    impl PartialEq<str> for NoStdTester {+        fn eq(&self, other: &str) -> bool {+            let other = other.as_bytes();+            for index in 0..self.cursor {+                if self.buf.get(index) != other.get(index) {+                    return false;+                }+            }+            true+        }+    }++    #[test]+    #[cfg(not(feature = "std"))]+    fn test_show() {+        let err_msg = "Formatted output too long";+        let mut tester = NoStdTester::new();+        write!(tester, "{:o}", _8).expect(err_msg);+        assert_eq!(tester, *"10");+        tester.clear();+    }+     #[test]     #[cfg(feature = "std")]     fn test_show() {-        use std::string::ToString;-        assert_eq!(format!("{}", _2), "2".to_string());-        assert_eq!(format!("{}", _1_2), "1/2".to_string());-        assert_eq!(format!("{}", _0), "0".to_string());-        assert_eq!(format!("{}", Ratio::from_integer(-2)), "-2".to_string());+        // Test:+        // :b :o :x, :X, :?+        // alternate or not (#)+        // positive and negative+        // padding+        // does not test precision (i.e. truncation)+        assert_eq!(&format!("{}", _2), "2");+        assert_eq!(&format!("{}", _1_2), "1/2");+        assert_eq!(&format!("{}", -_1_2), "-1/2"); // test negatives+        assert_eq!(&format!("{}", _0), "0");+        assert_eq!(&format!("{}", -_2), "-2");+        assert_eq!(&format!("{:b}", _2), "10");+        assert_eq!(&format!("{:b}", _1_2), "1/10");+        assert_eq!(&format!("{:b}", _0), "0");+        assert_eq!(&format!("{:#b}", _1_2), "0b1/0b10");+        assert_eq!(&format!("{:010b}", _1_2), "0000001/10");+        assert_eq!(&format!("{:#010b}", _1_2), "0b001/0b10");+        let half_i8: Ratio<i8> = Ratio::new(1_i8, 2_i8);+        assert_eq!(&format!("{:b}", -half_i8), "11111111/10");+        assert_eq!(&format!("{:#b}", -half_i8), "0b11111111/0b10");++        assert_eq!(&format!("{:o}", _8), "10");+        assert_eq!(&format!("{:o}", _1_8), "1/10");+        assert_eq!(&format!("{:o}", _0), "0");+        assert_eq!(&format!("{:#o}", _1_8), "0o1/0o10");+        assert_eq!(&format!("{:010o}", _1_8), "0000001/10");+        assert_eq!(&format!("{:#010o}", _1_8), "0o001/0o10");+        assert_eq!(&format!("{:o}", -half_i8), "377/2");+        assert_eq!(&format!("{:#o}", -half_i8), "0o377/0o2");++        assert_eq!(&format!("{:x}", _16), "10");+        assert_eq!(&format!("{:x}", _15), "f");+        assert_eq!(&format!("{:x}", _1_16), "1/10");+        assert_eq!(&format!("{:x}", _1_15), "1/f");+        assert_eq!(&format!("{:x}", _0), "0");+        assert_eq!(&format!("{:#x}", _1_16), "0x1/0x10");+        assert_eq!(&format!("{:010x}", _1_16), "0000001/10");+        assert_eq!(&format!("{:#010x}", _1_16), "0x001/0x10");+        assert_eq!(&format!("{:x}", -half_i8), "ff/2");+        assert_eq!(&format!("{:#x}", -half_i8), "0xff/0x2");++        assert_eq!(&format!("{:X}", _16), "10");+        assert_eq!(&format!("{:X}", _15), "F");+        assert_eq!(&format!("{:X}", _1_16), "1/10");+        assert_eq!(&format!("{:X}", _1_15), "1/F");+        assert_eq!(&format!("{:X}", _0), "0");+        assert_eq!(&format!("{:#X}", _1_16), "0x1/0x10");+        assert_eq!(&format!("{:010X}", _1_16), "0000001/10");+        assert_eq!(&format!("{:#010X}", _1_16), "0x001/0x10");+        assert_eq!(&format!("{:X}", -half_i8), "FF/2");+        assert_eq!(&format!("{:#X}", -half_i8), "0xFF/0x2");++        let _one_tehth_1_f = Ratio {

Nit:

        let _one_tenth_1_f = Ratio {

However, it's pretty weird to be testing Ratio<f32> at all -- do you have a specific motivation for that?

maxbla

comment created time in 6 days

pull request commentcuviper/autocfg

Use TESTS_TARGET_DIR envvar to override tests target dir

Looks good, thanks!

bors r+

silwol

comment created time in 6 days

PR closed cuviper/autocfg

test method exists base on signature

I'm not sure whether or not we can use the type parameter to dump as function signature.

pub fn probe_method<SIG>(&self, name: &str) -> bool {
    self.probe(format!("pub static PROBE: {} = {};", some_magic!(SIG), name))
        .unwrap_or(false)
}

seems std::intrinsics::type_name is not stable.

+65 -9

1 comment

2 changed files

flier

pr closed time in 6 days

pull request commentcuviper/autocfg

test method exists base on signature

#19 added support for probing general expressions, so I think this isn't needed anymore. Please let me know if that doesn't work for you!

flier

comment created time in 6 days

issue commentlibgit2/libgit2

1.0 planning / next few releases

Would it be possible to abstract the ssh backend before 1.0, so libssh2 isn't baked into libgit2's API? AFAICS the only exposure is in the callbacks in include/git2/credential.h. Even if libssh support isn't done in time for 1.0, perhaps the API can at least be ready for alternates. (issue #5225, WIP pull request #5253)

ethomson

comment created time in 6 days

Pull request review commentlibgit2/libgit2

[WIP] libssh backend

+/*+ * Copyright (C) the libgit2 contributors. All rights reserved.+ *+ * This file is part of libgit2, distributed under the GNU GPL v2 with+ * a Linking Exception. For full terms see the included COPYING file.+ */++#include "common.h"+#include "../transports/ssh.h"+#include "git2/sys/cred.h"++#if defined(GIT_SSH) && defined(GIT_LIBSSH2)++void git__ssh_error(git_ssh_session *s, const char *errmsg)+{+	char *ssherr;+	libssh2_session_last_error(s->session, &ssherr, NULL, 0);++	git_error_set(GIT_ERROR_SSH, "%s: %s", errmsg, ssherr);+}++void git_ssh__session_free(git_ssh_session *s)+{+	if (!s)+		return;++	libssh2_session_free(s->session);+	git__free(s);+}++int git_ssh__session_create(+	git_ssh_session **out_session,+	git_stream *io)+{+	int rc = 0;+	git_ssh_session *s;+	git_socket_stream *socket = GIT_CONTAINER_OF(io, git_socket_stream, parent);++	assert(out_session);++	s = git__calloc(1, sizeof(*s));+	if (!s) {+		git_error_set_oom();+		return -1;+	}++	s->session = git_ssh_session_new();+	if (!s->session) {+		git_error_set(GIT_ERROR_NET, "failed to initialize SSH session");+		goto cleanup;+	}++	do {+		rc = libssh2_session_handshake(s->session, socket->s);+	} while (LIBSSH2_ERROR_EAGAIN == rc || LIBSSH2_ERROR_TIMEOUT == rc);++	if (rc != GIT_SSH_ERROR_NONE) {+		git__ssh_error(s, "failed to start SSH session");+		goto cleanup;+	}++	libssh2_session_set_blocking(s->session, 1);++	*out_session = s;++	return 0;++cleanup:+	git_ssh__session_free(s);++	return -1;+}++git_ssh_channel *git_ssh_channel_open(git_ssh_session *s)+{+	git_ssh_channel *channel;++	channel = git__calloc(1, sizeof(*channel));+	if (!channel) {+		git_error_set_oom();+		return NULL;+	}++	channel->channel = libssh2_channel_open_session(s->session);++	if (channel->channel)+		libssh2_channel_set_blocking(channel->channel, 1);++	return channel;+}++int git_ssh_channel_read(char *buffer, size_t size, int is_stderr, git_ssh_channel *c)+{+	if (is_stderr)+		return libssh2_channel_read_stderr(c->channel, buffer, size);+	return libssh2_channel_read(c->channel, buffer, size);+}++int git_ssh_channel_write(git_ssh_channel *c, const char *buffer, size_t size)+{+	return libssh2_channel_write(c->channel, buffer, size);+}++int git_ssh_channel_exec(git_ssh_channel *c, const char *request)+{+	return libssh2_channel_exec(c->channel, request);+}++int git_ssh_session_server_hostkey(git_ssh_session *s, git_cert_hostkey *cert)+{+	const char *key;++	key = libssh2_hostkey_hash(s->session, LIBSSH2_HOSTKEY_HASH_SHA1);+	if (key != NULL) {+		cert->type |= GIT_CERT_SSH_SHA1;+		memcpy(&cert->hash_sha1, key, 20);+	}++	key = libssh2_hostkey_hash(s->session, LIBSSH2_HOSTKEY_HASH_MD5);+	if (key != NULL) {+		cert->type |= GIT_CERT_SSH_MD5;+		memcpy(&cert->hash_md5, key, 16);+	}++	if (cert->type == 0) {+		git_error_set(GIT_ERROR_SSH, "unable to get the host key");+		return -1;+	}++	return 0;+}++#define SSH_AUTH_PUBLICKEY "publickey"+#define SSH_AUTH_PASSWORD "password"+#define SSH_AUTH_KEYBOARD_INTERACTIVE "keyboard-interactive"++int git__ssh_list_auth_methods(int *out, git_ssh_session *s, const char *username)+{+	const char *list, *ptr;++	*out = 0;++	list = libssh2_userauth_list(s->session, username, strlen(username));++	/* either error, or the remote accepts NONE auth, which is bizarre, let's punt */+	if (list == NULL && !libssh2_userauth_authenticated(s->session)) {+		git__ssh_error(s, "Failed to retrieve list of SSH authentication methods");+		return -1;+	}++	ptr = list;+	while (ptr) {+		if (*ptr == ',')+			ptr++;++		if (!git__prefixcmp(ptr, SSH_AUTH_PUBLICKEY)) {+			*out |= GIT_CREDTYPE_SSH_KEY;+			*out |= GIT_CREDTYPE_SSH_CUSTOM;+#ifdef GIT_SSH_MEMORY_CREDENTIALS+			*out |= GIT_CREDTYPE_SSH_MEMORY;+#endif+			ptr += strlen(SSH_AUTH_PUBLICKEY);+			continue;+		}++		if (!git__prefixcmp(ptr, SSH_AUTH_PASSWORD)) {+			*out |= GIT_CREDTYPE_USERPASS_PLAINTEXT;+			ptr += strlen(SSH_AUTH_PASSWORD);+			continue;+		}++		if (!git__prefixcmp(ptr, SSH_AUTH_KEYBOARD_INTERACTIVE)) {+			*out |= GIT_CREDTYPE_SSH_INTERACTIVE;+			ptr += strlen(SSH_AUTH_KEYBOARD_INTERACTIVE);+			continue;+		}++		/* Skipt it if we don't know it */+		ptr = strchr(ptr, ',');+	}++	return 0;+}++int git__ssh_agent_auth(git_ssh_session *s, git_cred_ssh_key *c)+{+	int rc = GIT_SSH_ERROR_NONE;++	struct libssh2_agent_publickey *curr, *prev = NULL;++	LIBSSH2_AGENT *agent = libssh2_agent_init(s->session);++	if (agent == NULL)+		return -1;++	rc = libssh2_agent_connect(agent);++	if (rc != LIBSSH2_ERROR_NONE)+		goto shutdown;++	rc = libssh2_agent_list_identities(agent);++	if (rc != LIBSSH2_ERROR_NONE)+		goto shutdown;++	while (1) {+		rc = libssh2_agent_get_identity(agent, &curr, prev);++		if (rc < 0)+			goto shutdown;++		/* rc is set to 1 whenever the ssh agent ran out of keys to check.+		 * Set the error code to authentication failure rather than erroring+		 * out with an untranslatable error code.+		 */+		if (rc == 1) {+			rc = LIBSSH2_ERROR_AUTHENTICATION_FAILED;+			goto shutdown;+		}++		rc = libssh2_agent_userauth(agent, c->username, curr);++		if (rc == 0)+			break;++		prev = curr;+	}++shutdown:++	if (rc != LIBSSH2_ERROR_NONE)+		git__ssh_error(s, "error authenticating");++	libssh2_agent_disconnect(agent);+	libssh2_agent_free(agent);++	return rc;+}++struct git_ssh__sign_payload+{+	git_cred_sign_cb sign_cb;+	void *user_payload;+};++static inline LIBSSH2_USERAUTH_PUBLICKEY_SIGN_FUNC(git_ssh__sign_cb)+{+	struct git_ssh__sign_payload *payload = *abstract;++	return payload->sign_cb((git_ssh_session *)session,+							sig, sig_len,+							data, data_len, payload->user_payload);+}++struct git_ssh__kbdint_payload+{+	LIBSSH2_SESSION *session;+	git_cred_ssh_interactive_cb kbdint_cb;+	void *user_payload;+};++static inline LIBSSH2_USERAUTH_KBDINT_RESPONSE_FUNC(git_ssh__kbdint_cb)+{+	struct git_ssh__kbdint_payload *payload = *abstract;++	GIT_UNUSED(prompts);+	GIT_UNUSED(responses);++	return payload->kbdint_cb((git_ssh_session *)payload->session,+							  name, name_len,+							  instruction, instruction_len,+							  num_prompts, NULL, NULL,+							  payload->user_payload);+}++int _git_ssh_authenticate_session(git_ssh_session *s, git_cred *cred)+{+	int rc;++	do {+		git_error_clear();+		switch (cred->credtype) {+			case GIT_CREDTYPE_USERPASS_PLAINTEXT: {+				git_cred_userpass_plaintext *c = (git_cred_userpass_plaintext *)cred;+				rc = libssh2_userauth_password(s->session, c->username, c->password);+				break;+			}+			case GIT_CREDTYPE_SSH_KEY: {+				git_cred_ssh_key *c = (git_cred_ssh_key *)cred;++				if (c->privatekey) {+					rc = libssh2_userauth_publickey_fromfile(+						s->session, c->username, c->publickey,+						c->privatekey, c->passphrase);+				} else+					rc = git__ssh_agent_auth(s, c);++				break;+			}+			case GIT_CREDTYPE_SSH_CUSTOM: {+				git_cred_ssh_custom *c = (git_cred_ssh_custom *)cred;+				struct git_ssh__sign_payload payload = { c->sign_callback, &c->payload };++				rc = libssh2_userauth_publickey(+					s->session, c->username, (const unsigned char *)c->publickey,+					c->publickey_len, git_ssh__sign_cb, (void **)&payload);+				break;+			}+			case GIT_CREDTYPE_SSH_INTERACTIVE: {+				git_cred_ssh_interactive *c = (git_cred_ssh_interactive *)cred;+				void **abstract = libssh2_session_abstract(s->session);+				struct git_ssh__kbdint_payload payload;+				payload.kbdint_cb = c->prompt_callback;+				payload.session = s->session;+				payload.user_payload = c->payload;++				/* ideally, we should be able to set this by calling+				 * libssh2_session_init_ex() instead of libssh2_session_init().+				 * libssh2's API is inconsistent here i.e. libssh2_userauth_publickey()+				 * allows you to pass the `abstract` as part of the call, whereas+				 * libssh2_userauth_keyboard_interactive() does not!+				 *+				 * The only way to set the `abstract` pointer is by calling+				 * libssh2_session_abstract(), which will replace the existing+				 * pointer as is done below. This is safe for now (at time of writing),+				 * but may not be valid in future.+				 */+				*abstract = &payload;++				rc = libssh2_userauth_keyboard_interactive(+					s->session, c->username, git_ssh__kbdint_cb);++				*abstract = old_abstract;

I see you added old_abstract in commit 98c9f6a6, but its declaration got lost in the following commit 749f3440.

tiennou

comment created time in 6 days

Pull request review commentlibgit2/libgit2

[WIP] libssh backend

 #define INCLUDE_transports_ssh_h__  #include "common.h"+#include "../streams/socket.h"  int git_transport_ssh_global_init(void); +#ifdef GIT_SSH++#ifdef GIT_LIBSSH2++#include <libssh2.h>++#define GIT_SSH_ERROR_NONE LIBSSH2_ERROR_NONE++struct git_ssh_session {+	LIBSSH2_SESSION *session;+};++#define git_ssh_session_new() libssh2_session_init()+#define git_ssh_session_disconnect(s, msg) \+	libssh2_session_disconnect(s->session, msg);++struct git_ssh_channel {+	LIBSSH2_CHANNEL *channel;+};++#define git_ssh_channel_close(c) libssh2_channel_close(c->channel)+#define git_ssh_channel_free(c) libssh2_channel_free(c->channel)
#define git_ssh_channel_free(c) libssh2_channel_free(c)
tiennou

comment created time in 6 days

Pull request review commentlibgit2/libgit2

[WIP] libssh backend

 #define INCLUDE_transports_ssh_h__  #include "common.h"+#include "../streams/socket.h"  int git_transport_ssh_global_init(void); +#ifdef GIT_SSH++#ifdef GIT_LIBSSH2++#include <libssh2.h>++#define GIT_SSH_ERROR_NONE LIBSSH2_ERROR_NONE++struct git_ssh_session {+	LIBSSH2_SESSION *session;+};++#define git_ssh_session_new() libssh2_session_init()+#define git_ssh_session_disconnect(s, msg) \+	libssh2_session_disconnect(s->session, msg);++struct git_ssh_channel {+	LIBSSH2_CHANNEL *channel;+};++#define git_ssh_channel_close(c) libssh2_channel_close(c->channel)
#define git_ssh_channel_close(c) libssh2_channel_close(c)
tiennou

comment created time in 6 days

Pull request review commentlibgit2/libgit2

[WIP] libssh backend

 OPTION(TAGS				"Generate tags"						OFF) OPTION(PROFILE				"Generate profiling information"			OFF) OPTION(ENABLE_TRACE			"Enables tracing support"				OFF) OPTION(LIBGIT2_FILENAME			"Name of the produced binary"				OFF)-OPTION(USE_SSH				"Link with libssh2 to enable SSH support"		 ON)+OPTION(USE_SSH				"Enable SSH support. Can be set to a specific backend (libssh2)" ON)

I think this needs to be SET to properly cache the backend value, like:

   SET(USE_SSH				"ON" CACHE STRING "Enable SSH support. Can be set to a specific backend (libssh2)")
tiennou

comment created time in 6 days

Pull request review commentrust-num/num-rational

WIP: add more formatting traits

 mod test {         assert!(!_NEG1_2.is_integer());     } +    #[cfg(not(feature = "std"))]+    use core::fmt;+    #[cfg(not(feature = "std"))]+    use fmt::Write;

This needs to be use core::fmt::Write; for Rust 1.31 compatibility.

Or combine the two, use core::fmt::{self, Write};

maxbla

comment created time in 6 days

issue commentlibgit2/libgit2

libssh2 deprecated in Redhat 7 removed in 8.

Hi @tiennou, I'm very sorry that I disappeared on this -- where does it stand? I see your PR #5253, but no maintainer has reviewed it, and it seems like there are some API questions that would be good to resolve before libgit2 1.0...

If there's any part that I can still help with, please let me know.

toddr

comment created time in 6 days

issue commentopenshift-s2i/s2i-rust

Is this maintained anymore?

At least for RHEL 7 and 8, the official containers are more current, and still s2i-enabled:

  • https://access.redhat.com/containers/#/registry.access.redhat.com/devtools/rust-toolset-rhel7
  • https://access.redhat.com/containers/#/registry.access.redhat.com/rhel8/rust-toolset

Neither are up to 1.40+ yet, but updates are in the release pipeline...

WillNilges

comment created time in 6 days

issue openedFrommi/miniz_oxide

0.2.4 broke the C API on 32-bit unix

On Fedora, we found that 0.2.4 broke for i686 and armv7hl, such as this build.

error[E0308]: mismatched types
   --> src/lib.rs:252:79
    |
252 |                 as_c_return_code(mz_compress2_oxide(&mut stream_oxide, level, dest_len))
    |                                                                               ^^^^^^^^ expected `u64`, found `u32`
    |
    = note: expected mutable reference `&mut u64`
               found mutable reference `&mut u32`
error[E0308]: mismatched types
   --> src/lib.rs:291:74
    |
291 |                 as_c_return_code(mz_uncompress2_oxide(&mut stream_oxide, dest_len))
    |                                                                          ^^^^^^^^ expected `u64`, found `u32`
    |
    = note: expected mutable reference `&mut u64`
               found mutable reference `&mut u32`
error[E0308]: mismatched types
   --> src/c_export.rs:150:23
    |
150 |             total_in: self.total_in,
    |                       ^^^^^^^^^^^^^ expected `u32`, found `u64`
error[E0308]: mismatched types
   --> src/c_export.rs:160:24
    |
160 |             total_out: self.total_out,
    |                        ^^^^^^^^^^^^^^ expected `u32`, found `u64`
error[E0308]: mismatched types
   --> src/c_export.rs:211:23
    |
211 |             total_in: stream.total_in,
    |                       ^^^^^^^^^^^^^^^ expected `u64`, found `u32`
error[E0308]: mismatched types
   --> src/c_export.rs:213:24
    |
213 |             total_out: stream.total_out,
    |                        ^^^^^^^^^^^^^^^^ expected `u64`, found `u32`
error: aborting due to 6 previous errors
For more information about this error, try `rustc --explain E0308`.
error: could not compile `miniz_oxide_c_api`.

I bisected the regression to commit 918aa73285e3. For the mz_uncompress2_oxide errors, that parameter changed from &mut c_ulong to &mut u64. StreamOxide's total_in and total_out also changed from c_ulong to u64. Those are the same type on LP64 targets (most 64-bit Unix), but not on 32-bit targets, nor 64-bit Windows (LLP64).

See also #54.

created time in 6 days

issue commentrust-lang/rust-clippy

Lint on deny(warnings), deny(deprecated), and similar

FWIW, @llogiq also shared a rust-unofficial/patterns page about this: https://github.com/rust-unofficial/patterns/blob/master/anti_patterns/deny-warnings.md

This certainly doesn't qualify as a future incompatibility lint in rustc. Rustc is already permitted to make changes to existing lints that cause breakages, the stability policy for lints is basically "do not radically change their meaning". You have this hazard even without the blanket deny, as long as you have any deny.

True, but deprecated and blanket warnings are even less stable than most, as they will inherently increase in scope over time.

Crater can indeed do that, by passing cap-lints=warn to the experiment. The release team does that for beta runs.

Aha, and the test failure in https://github.com/reem/rust-mac/issues/15 did show up in https://github.com/rust-lang/rust/issues/66244#issuecomment-552903470, but AFAICS nobody triaged that one.

Still, as noted on reddit, it's not always desirable for Crater to cap lints, because some problems may depend on the behavior of default-denied lints.

cuviper

comment created time in 6 days

issue openedrust-lang/rust-clippy

Lint on deny(warnings), deny(deprecated), and similar

Denying all warnings, or even just deprecation warnings, is a forward compatibility hazard, and can also have unintended effects like masking Crater failures. I posted about this on /r/rust, and /u/Luroalive asked me to file an issue to add a clippy lint. It may actually be worth a first-class rustc lint in the future-incompatible group, but we can consider it here first.

GitHub suggested the related issue #287 that was closed, but perhaps it's worth another look with this new context. cc @llogiq @Manishearth

created time in 7 days

pull request commentrust-lang/rust

syntax: Support modern attribute syntax in the `meta` matcher

We just discovered that this change broke mac -- https://github.com/reem/rust-mac/issues/15 -- but the crate was masked from the crater run due to existing errors from deny(warnings).

petrochenkov

comment created time in 7 days

issue commentreem/rust-mac

One of tests is broken

I believe this is a consequence of a change to meta parsing that became stable in Rust 1.40. https://github.com/rust-lang/rust/pull/63674/

https://github.com/reem/rust-mac/blob/66afc663b68a65633ea165c742b5a9c6734581c2/src/cfg.rs#L56-L59

So the whole test { ... } now gets consumed by the $cfg:meta matcher, and then the macro thinks it's missing the $t:block.

There was a crater run for that Rust change which showed 0 regressions. However, the mac crate was masked because of existing errors from deny(warnings):

[INFO] [stderr]     Checking mac v0.1.1 (/opt/rustwide/workdir)
[INFO] [stderr] error: `...` range patterns are deprecated
[INFO] [stderr]   --> src/matches.rs:42:41
[INFO] [stderr]    |
[INFO] [stderr] 42 |         matches!(bar.as_bytes()[1], b'0'... b'9')
[INFO] [stderr]    |                                         ^^^ help: use `..=` for an inclusive range
[INFO] [stderr]    |
[INFO] [stderr] note: lint level defined here
[INFO] [stderr]   --> src/lib.rs:1:24
[INFO] [stderr]    |
[INFO] [stderr] 1  | #![cfg_attr(test, deny(warnings))]
[INFO] [stderr]    |                        ^^^^^^^^
[INFO] [stderr]    = note: `#[deny(ellipsis_inclusive_range_patterns)]` implied by `#[deny(warnings)]`
[INFO] [stderr] 
[INFO] [stderr] error: aborting due to previous error
[INFO] [stderr] 
[INFO] [stderr] error: Could not compile `mac`.

I'll note this upstream for posterity, but I'm sure it's too late to fix this.

If you care to change syntax, maybe you can use a separator like $cfg:meta => $t:block.

ignatenkobrain

comment created time in 7 days

issue commentrust-num/num-complex

Arithmetic operations with reference semantics

In my example, I use Complex<Ratio<BigInt>>.

Note, Ratio also implements reference ops by cloning, which means that changing Complex alone wouldn't really help you.

I started looking at this for 0.3 (#70), but I'm skeptical. It requires a lot of code duplication on our part to directly implement each op with/without clones, and the additional T: NumRef + ... requirements end up propagating widely. The latter will affect all generic users too, sadly.

cohomology

comment created time in 8 days

pull request commentrust-num/num-bigint

Remove an unnecessary `BigInt::one()` in `div_mod_floor`

bors r+

cuviper

comment created time in 8 days

create barnchcuviper/num-bigint

branch : div_mod_floor-one

created branch time in 8 days

pull request commentrust-num/num-rational

WIP: add more formatting traits

I would like to include this in 0.3 (#65), and notably this means we can make the breaking change you had earlier on Display. Can you rebase this, and perhaps make that change, so I can give it another review?

maxbla

comment created time in 8 days

create barnchcuviper/rust

branch : llvm-flags

created branch time in 8 days

pull request commentrust-lang/rust

configure: set LLVM flags with a value

r? @Mark-Simulacrum

cuviper

comment created time in 8 days

PR opened rust-lang/rust

configure: set LLVM flags with a value

Rather than a boolean --enable-cflags etc., these options should reflect that they are for LLVM, and that they need a value. You would now use ./configure --llvm-cflags="...".

+3 -3

0 comment

1 changed file

pr created time in 8 days

PR opened rust-lang/cargo

Link the licenses into crates/cargo-platform

The licenses should be included in the package published on crates.io

+2 -0

0 comment

2 changed files

pr created time in 11 days

create barnchcuviper/cargo

branch : cargo-platform-licenses

created branch time in 11 days

pull request commentrust-lang/cargo

Ignore the host in rustc.verbose_version for metadata

I'm wondering now if I could get away with just building these noarch subpackages on one of the builders, so there's no difference to worry about.

FWIW, I brought this up on Fedora devel, and while there's some concern, it seems there are other packages doing something similar already.

Still, it feels like there should still be a way to resolve these host/target differences vs caching. What if we split the difference between -C metadata and -C extra-filename so only the latter includes any triple? So the internal metadata hash would include all of the target-independent information -- which is important for dependency metadata too so stuff like proc-macros don't infect host info into the target. Then the extra-filename can be generated from that and add just the target triple, or the host triple if there's no --target.

cuviper

comment created time in 12 days

issue commentrayon-rs/rayon

Documentation error: Incorrect link for iterators README

Hmm, that is awkward. It is available on docs.rs under the source browser, but that doesn't render any markdown. https://docs.rs/crate/rayon/1.3.0/source/src/iter/plumbing/README.md

The plumbing module mentions the same README, pointing to the repo's master branch.

Maybe we should convert at least some of those details into the doctext of plumbing/mod.rs so it's directly available.

captnfab

comment created time in 13 days

issue closedrayon-rs/rayon

Question about behavior of spawn and thread-pool.

I have a couple of somewhat independent structs that I would like each to be able to spawn work on the same thread-pool.

I did not see an API to clone or get an handle to a thread-pool that one would have configured with a builder, but I read that rayon::spawn will spawn work "on the global or static threadpool".

However, looking at https://github.com/rayon-rs/rayon/blob/7ffaf3463be2339cb5bad86dc87b602ed067fc7c/rayon-core/src/registry.rs#L268

It appears to me that if the global thead-pool hasn't been set yet, rayon::spawn could actually result in setting a new thread-pool as the global one?

So let's say that in a given process, I first build a thread pool, and then I want to use rayon::spawn, is that going to actually build a new thread-pool or use the one that was configured before?

Do I need to use build_global to get this behavior?

Or would it be best to simply pass the ThreadPool around using (A)Rc?

closed time in 13 days

gterzian
more