These are chat archives for rust-lang/rust

28th
Jun 2018
Michal 'vorner' Vaner
@vorner
Jun 28 2018 07:15

I don't think so, but the implementation should be pretty easy anyway:

impl Ord for Event {
    fn cmp(&self, other: &Self) -> Ordering { self.b.cmp(&other.b) }
}

So any kind of attribute-style explanation of auto-derive, but ignore a would be longer.

Sylwester Rąpała
@xoac
Jun 28 2018 08:55
Why I can't do this?
impl From<SendRequestError> for Error {
    fn from(err: SendRequestError) -> Error {
        Error::SendingError(err)
    }
}

impl From<ExecInstError> for Error {
    fn from(err: ExecInstError) -> Error {
        Error::ExecInstError(ExecInstError)
    }
}
Igor Ranchynskyy
@Awpteamoose
Jun 28 2018 09:05
@xoac Error is a trait, not a struct
afaik you'll have to impl for every type of error you want to convert
Sylwester Rąpała
@xoac
Jun 28 2018 10:29
I think the problem was that SendRequestError impl Fail. After add Fail to my type this works fine
trsh
@trsh
Jun 28 2018 14:53
Im trying to set a flag in .cargo/config, but getting

error[E0602]: unknown lint: WITH_OPENSSL
|
= note: requested on the command line with -D WITH_OPENSSL

error: aborting due to previous error

Any ieas?
Denis Lisov
@tanriol
Jun 28 2018 14:56
@trsh What do you mean by "set a flag"?
trsh
@trsh
Jun 28 2018 14:56
rustflags = ["-DWITH_OPENSSL"]
Denis Lisov
@tanriol
Jun 28 2018 14:56
What compiler do you want it to affect?
trsh
@trsh
Jun 28 2018 14:57
Extrenal C
Denis Lisov
@tanriol
Jun 28 2018 14:58
Then you need to hook into the build script that calls it and/or set the corresponding environment variable(s)...
trsh
@trsh
Jun 28 2018 14:58
U mean here?
cc::Build::new() .file("src/applications/api/externapis/fedex/wsdls/addressvalidation/wrapper.c") .file("src/applications/api/externapis/fedex/wsdls/addressvalidation/soapC.c") .file("src/applications/api/externapis/fedex/wsdls/addressvalidation/soapClient.c") .file("src/applications/api/externapis/fedex/wsdls/addressvalidation/stdsoap2.c") .compile("fedexaddressvalidation.a");
Denis Lisov
@tanriol
Jun 28 2018 14:59
Yes.
.define("WITH_OPENSSL", None)
trsh
@trsh
Jun 28 2018 15:02
why not .flag("-DWITH_OPENSSL") ?
Denis Lisov
@tanriol
Jun 28 2018 15:04
The define method will provide the correct flag with MSVC too, which, I guess, is different from the GCC one :-)
I'd personally also consider define to be more obvious
trsh
@trsh
Jun 28 2018 15:06
@tanriol any exp runing rust in windows?
and MSVC
Denis Lisov
@tanriol
Jun 28 2018 15:07
Not really, I've built a few small helpers a few years ago and that's all.
trsh
@trsh
Jun 28 2018 15:08
Ehh
Compiler complaining about > Cannot open include file: 'openssl/bio.h': No such file or directory
After the flag is set.. howerver I have set up vcpkg
And I can see that studio points to correct includes
Denis Lisov
@tanriol
Jun 28 2018 15:11
And you've installed openssl with vcpkg, haven't you?
trsh
@trsh
Jun 28 2018 15:12
I have yes
The failing call looks like running: "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\bin\\amd64\\cl.exe" "/nologo" "/MD" "/Z7" "/W4" "/DWITH_OPENSSL" "/FoC:\\janis_work\\manu\\backEnd2\\target\\debug\\build\\manu-a824775186703601\\out\\src/applications/api/externapis/fedex/wsdls/addressvalidation\\wrapper.o" "/c" "src/applications/api/externapis/fedex/wsdls/addressvalidation/wrapper.c"
In studio %(AdditionalIncludeDirectories);$(VcpkgRoot)include
On paper it should work
:D
Ingvar Stepanyan
@RReverser
Jun 28 2018 15:16
it looks like it's missing include paths to openssl etc.
trsh
@trsh
Jun 28 2018 15:17
@RReverser but they are set $(VcpkgRoot)include
Ingvar Stepanyan
@RReverser
Jun 28 2018 15:17

In studio %(AdditionalIncludeDirectories);$(VcpkgRoot)include

What do you mean by "in studio"?

If you just set them in project properties, they won't take effect if you compile manually via cl.exe (which is what build script invokes)
trsh
@trsh
Jun 28 2018 15:18
Its global includes
Ingvar Stepanyan
@RReverser
Jun 28 2018 15:18
you need to explicitly use .include in build script for that
trsh
@trsh
Jun 28 2018 15:19
@RReverser are you sure. Microsoft.cpp.win32.user settings are not global, even from command line?
Ingvar Stepanyan
@RReverser
Jun 28 2018 15:20
Well you didn't say where you are setting them, but if it's in project settings then yeah, they are just saves as part of sln file
trsh
@trsh
Jun 28 2018 15:20
No not on project..
I can open any project and it's there
Ingvar Stepanyan
@RReverser
Jun 28 2018 15:21
Oh ok
But either way
trsh
@trsh
Jun 28 2018 15:21
vcpkg set's it
Ingvar Stepanyan
@RReverser
Jun 28 2018 15:21
Microsoft.cpp.win32.user is also used just by MSBuild
which you don't use here
trsh
@trsh
Jun 28 2018 15:22
Seems so
Ingvar Stepanyan
@RReverser
Jun 28 2018 15:22
that can be reconfirmed by looking at cl.exe call
what MSBuild would do is still pass these directories explicitly
byt you bypass it, so need to do that yourself
Denis Lisov
@tanriol
Jun 28 2018 15:22
Have you seen the vcpkg crate?
trsh
@trsh
Jun 28 2018 15:25
next fun begins error LNK2019: unresolved external symbol sk_num referenced in function tcp_connect
Ingvar Stepanyan
@RReverser
Jun 28 2018 15:26
(FWIW another thing you could do is just to invoke MSBuild yourself and then just tell Rust to link to the final artifact)
trsh
@trsh
Jun 28 2018 15:29
@tanriol not really
trsh
@trsh
Jun 28 2018 15:37
C:\vcpkg\installed\x86-windows\include\openssl/ssl.h(837): error C2143: syntax error: missing ')' before 'constant'
Great :D
trsh
@trsh
Jun 28 2018 15:54
fck
(headbang)
Eugene Tolmachev
@et1975
Jun 28 2018 15:55
I'm confused by cargo.lock content... it seems to have multiple versions of the same dependency listed. How does it decide which one to actually use (and do it consistently and repeatably)?
Eugene Tolmachev
@et1975
Jun 28 2018 16:03
actually I guess I don't understand something even more fundamental: if my lib depends on A and B@0.1.0, and A depends on B@0.2.0, what happens? I see a compiler error, suggesting that "Perhaps two different versions of crate B are being used?". Perhaps, I was under impression that cargo would resolve to one specific version of B for the entire build. Am I wrong?
trsh
@trsh
Jun 28 2018 16:11
Dont understand how add libs https://docs.rs/cc/1.0.3/cc/struct.Build.html
Includes is clear, but..
Ingvar Stepanyan
@RReverser
Jun 28 2018 16:56
@et1975 It can include several copies of dependencies when deduplication is not possible (e.g. due to conflicting semvers).
trsh
@trsh
Jun 28 2018 16:58
@RReverser any ideas on my question?
Ingvar Stepanyan
@RReverser
Jun 28 2018 16:58
what do you mean by add libs?
trsh
@trsh
Jun 28 2018 17:02
ssl.lib
@RReverser or xxx.lib, whatever
Ingvar Stepanyan
@RReverser
Jun 28 2018 17:03
sorry I don't understand your question
add where?
trsh
@trsh
Jun 28 2018 17:03
@RReverser "cl /EHsc /GA /MT simple.cpp User32.lib"
Lats part
Includes clear, flags clear, defines clear - this not
Ingvar Stepanyan
@RReverser
Jun 28 2018 17:04
just add as a file?
Eugene Tolmachev
@et1975
Jun 28 2018 17:05
@RReverser thx, any links to read up on that?
trsh
@trsh
Jun 28 2018 17:05
@RReverser nooo
Ingvar Stepanyan
@RReverser
Jun 28 2018 17:05
@et1975 not sure tbh, just seen various issues / discussions around
Mathieu Besançon
@matbesancon
Jun 28 2018 17:18
question I couldn't find documentation on: why does the find method need a mutable self reference? It does not fit what I understand the method to do
Ingvar Stepanyan
@RReverser
Jun 28 2018 17:19
Which find?
std::str::find doesn't
trsh
@trsh
Jun 28 2018 17:20
Or how to I define "LIBPATH "
Ehh
sorry, had forgotten. It seems to mutate the iterator
Ingvar Stepanyan
@RReverser
Jun 28 2018 17:31
ah well yeah
Dmitriy
@dpogretskiy
Jun 28 2018 17:39
in general you always mutate the iterator by getting next()
you can have as much of iterators for single slice/vec/whatever as you want, cause they are generally cheap
Mathieu Besançon
@matbesancon
Jun 28 2018 18:06
oh ok I understand, it mutates the iterator, not the structure, got it thanks!
Dmitriy
@dpogretskiy
Jun 28 2018 18:10
iter_mut provides mutable references and can mutate whatever the underlying structure is, tho
Mathieu Besançon
@matbesancon
Jun 28 2018 18:16
yup that I had used before, I just got tricked by the iterator <-> underlying collection link
trsh
@trsh
Jun 28 2018 18:32
So if my c code requires some .lib s, how do i link them?
sitty
@sitty
Jun 28 2018 20:11
Has anyone tired installing cargo-tree on Windows WSL?
can someone tell me what the next steps are in deprecating std::env::home_dir?
Fredrik Portström
@portstrom
Jun 28 2018 20:25
Is there a way to set a limit for how much memory can be allocated? It would be helpful when testing programs that have bugs causing them to allocate infinite amounts of memory.
James McCoy
@jamessan
Jun 28 2018 20:27
On unixy systems, you can change your shell's ulimit
Fredrik Portström
@portstrom
Jun 28 2018 20:29
That's what I normally do, but it only supports limiting virtual memory, which includes memory mapped files. The program I was testing today is supposed to open a 2 GB memory mapped file, but not supposed to allocate a 2 GB Vec.
Sylwester Rąpała
@xoac
Jun 28 2018 20:39
How would you skip 0xFF bytes from reader? I have reader.read(&mut buf). But I would like to skip every 0xFF bytes at begin. buf is type [u8; 100]
Denis Lisov
@tanriol
Jun 28 2018 20:41
@trsh Have you tried looking at vcpkg? According to its docs, it should take care of linking to libraries, no?
trsh
@trsh
Jun 28 2018 20:49
Seems like when run from command line, like rust does, the linking done by vcpkg doesnt work
Maybe i need that crate you pasted
Sylwester Rąpała
@xoac
Jun 28 2018 21:01
Is there a way to see underlying buffer of BufReader?
Denis Lisov
@tanriol
Jun 28 2018 21:14
@trsh Yes, the vcpkg crate not only finds the include paths, but also emits the metadata required for linking.
Sylwester Rąpała
@xoac
Jun 28 2018 22:19
Is there a way to autospecific feature nightly when build with cargo +nightly build?
Denis Lisov
@tanriol
Jun 28 2018 22:47
What do you mean?