Added a run-pass test to ensure that processes can be correctly spawned
using non-ASCII arguments, working directory, and environment variables.
It also tests Unicode support of os::env_as_bytes.
An additional assertion was added to the test for make_command_line to
verify it handles Unicode correctly.
Previously, make_command_line iterates over each u8 in the string and
then appends them as chars, so any non-ASCII string will get horribly
mangled by this function. This fix should allow Unicode arguments to
work correctly in native::io::process::spawn.
Changed libnative to use CreateProcessW instead of CreateProcessA. In
addition, the lpEnvironment parameter now uses Unicode.
Added a helper function os::win32::as_mut_utf16_p, which does basically
the same thing as os::win32::as_utf16_p except the pointer is mutable.
Changed StrBuf.shift_byte() that it no longer reallocates the buffer by just calling Vec.shift();
Added warning to shift_char()'s docs about it having to copy the whole buffer, as per the docs for
Vec.shift().
Been meaning to try my hand at something like this for a while, and noticed something similar mentioned as part of #13537. The suggestion on the original ticket is to use `TcpStream::open(&str)` to pass in a host + port string, but seems a little cleaner to pass in host and port separately -- so a signature like `TcpStream::open(&str, u16)`.
Also means we can use std::io::net::addrinfo directly instead of using e.g. liburl to parse the host+port pair from a string.
One outstanding issue in this PR that I'm not entirely sure how to address: in open_timeout, the timeout_ms will apply for every A record we find associated with a hostname -- probably not the intended behavior, but I didn't want to waste my time on elaborate alternatives until the general idea was a-OKed. :)
Anyway, perhaps there are other reasons for us to prefer the original proposed syntax, but thought I'd get some thoughts on this. Maybe there are some solid reasons to prefer using liburl to do this stuff.
Prior to this commit, TcpStream::connect and TcpListener::bind took a
single SocketAddr argument. This worked well enough, but the API felt a
little too "low level" for most simple use cases.
A great example is connecting to rust-lang.org on port 80. Rust users would
need to:
1. resolve the IP address of rust-lang.org using
io::net::addrinfo::get_host_addresses.
2. check for errors
3. if all went well, use the returned IP address and the port number
to construct a SocketAddr
4. pass this SocketAddr to TcpStream::connect.
I'm modifying the type signature of TcpStream::connect and
TcpListener::bind so that the API is a little easier to use.
TcpStream::connect now accepts two arguments: a string describing the
host/IP of the host we wish to connect to, and a u16 representing the
remote port number.
Similarly, TcpListener::bind has been modified to take two arguments:
a string describing the local interface address (e.g. "0.0.0.0" or
"127.0.0.1") and a u16 port number.
Here's how to port your Rust code to use the new TcpStream::connect API:
// old ::connect API
let addr = SocketAddr{ip: Ipv4Addr{127, 0, 0, 1}, port: 8080};
let stream = TcpStream::connect(addr).unwrap()
// new ::connect API (minimal change)
let addr = SocketAddr{ip: Ipv4Addr{127, 0, 0, 1}, port: 8080};
let stream = TcpStream::connect(addr.ip.to_str(), addr.port()).unwrap()
// new ::connect API (more compact)
let stream = TcpStream::connect("127.0.0.1", 8080).unwrap()
// new ::connect API (hostname)
let stream = TcpStream::connect("rust-lang.org", 80)
Similarly, for TcpListener::bind:
// old ::bind API
let addr = SocketAddr{ip: Ipv4Addr{0, 0, 0, 0}, port: 8080};
let mut acceptor = TcpListener::bind(addr).listen();
// new ::bind API (minimal change)
let addr = SocketAddr{ip: Ipv4Addr{0, 0, 0, 0}, port: 8080};
let mut acceptor = TcpListener::bind(addr.ip.to_str(), addr.port()).listen()
// new ::bind API (more compact)
let mut acceptor = TcpListener::bind("0.0.0.0", 8080).listen()
[breaking-change]
Closes#14163 (Fix typos in rustc manpage)
Closes#14161 (Add the patch number to version strings. Closes#13289)
Closes#14156 (rustdoc: Fix hiding implementations of traits)
Closes#14152 (add shebang to scripts that have execute bit set)
Closes#14150 (libcore: remove fails from slice.rs and remove duplicated length checking)
Closes#14147 (Make ProcessOutput Eq, TotalEq, Clone)
Closes#14142 (doc: updates rust manual (loop to continue))
Closes#14141 (doc: Update the linkage documentation)
Closes#14139 (Remove an unnecessary .move_iter().collect())
Closes#14136 (Two minor fixes in parser.rs)
Closes#14130 (Fixed typo in comments of driver.rs)
Closes#14128 (Add `stat` method to `std::io::fs::File` to stat without a Path.)
Closes#14114 (rustdoc: List macros in the sidebar)
Closes#14113 (shootout-nbody improvement)
Closes#14112 (Improved example code in Option)
Closes#14104 (Remove reference to MutexArc)
Closes#14087 (emacs: highlight `macro_name!` in macro invocations using [] delimiters)
The `FileStat` struct contained a `path` field, which was filled by the
`stat` and `lstat` function. Since this field isn't in fact returned by
the operating system (it was copied from the paths passed to the
functions) it was removed, as in the `fstat` case we aren't working with
a `Path`, but directly with a fd.
If your code used the `path` field of `FileStat` you will now have to
manually store the path passed to `stat` along with the returned struct.
[breaking-change]
This addresses #12842 by offering fallback implementations for functions that aren't available.
In this case, as Windows XP simply doesn't support symbolic links at all, the fallbacks simply return an error code indicating that the function hasn't been implemented. This should allow programs written in Rust to run under XP while still offering full support for symbolic links under newer versions of Windows with the same binary, but due to LLVM using stderror_s(), which isn't available in msvcrt.dll in XP, rustc itself will not.
The fallback implementation is as follows:
Calling the function instead calls to a mutable function pointer. This in and of itself would not constitute a performance hit because DLL calls are implemented in a similar manner (see Import Address Table). The function pointer initially points to a thunk which tries to get the address of the associated function and write it back to the function pointer. If it fails to find the function, it instead writes the address to a fallback. As this operation is idempotent, reading and writing the pointer simply needs to be atomic. Subsequent calls to the function should be as fast as any other DLL call, as the pointer will then point directly to either the correct function or a fallback.
The goal of this refactoring is to make the rustc driver code easier to understand and use. Since this is as close to an API as we have, I think it is important that it is nice. On getting stuck in, I found that there wasn't as much to change as I'd hoped to make the stage... functions easier to use by tools (which is a good thing :-) ).
This patch only moves code around - mostly just moving code to different files, but a few extracted method refactorings too. To summarise the changes: I added driver::config which handles everything about configuring the compiler. driver::session now just defines and builds session objects. I moved driver code from librustc/lib.rs to librustc/driver/mod.rs so all the code is one place. I extracted methods to make emulating the compiler without being the compiler a little easier. Within the driver directory, I moved code around to more logically fit in the modules.
Despite implementing the Container trait, StrBuf did not implement the Mutable trait and had no clear method; this request implements the clear method of the Mutable trait for StrBuf.
Testing done: added a test and ran `make check` without any failures.