Before ca07e256f62f772d14c42f41af46f2aeacc54983, LLVM's AArch64FastISel
had a sign (and zero?) extension bug. Until rustc gets its LLVM past
that commit, the way of workaround is to pass an option to LLVM that
forces the disabling of FastISel (which would normally kick in for -O0).
Fixes#21627
This ends up propagating all the way out to the output of dep-info which then
makes Cargo think that files are not existent (it thinks the files have quotes
in their name) when they in fact do.
Don't reallocate when capacity is already equal to length
`Vec::shrink_to_fit()` may be called on vectors that are already the
correct length. Calling out to `reallocate()` in this case is a bad idea
because there is no guarantee that `reallocate()` won't allocate a new
buffer anyway, and based on performance seen in external benchmarks, it
seems likely that it is in fact reallocating a new buffer.
Before:
test string::tests::bench_exact_size_shrink_to_fit ... bench: 45 ns/iter (+/- 2)
After:
test string::tests::bench_exact_size_shrink_to_fit ... bench: 26 ns/iter (+/- 1)
Limiting ourselves to a generic x86 instruction set doesn't seem useful.
Both users running those systems on original i386 hardware might as well
manually specify a target cpu ;-)
Clang uses the same default.
There are some explicit Send/Sync implementations for Window's types
that don't exist in Unix. While the end result will be the same, I
believe it's clearer if we keep the explicit implementations consistent
by making the os-specific types Send/Sync where needed and possible.
This commit addresses tcp. Existing differences below:
src/libstd/sys/unix/tcp.rs
unsafe impl Sync for TcpListener {}
unsafe impl Sync for AcceptorInner {}
src/libstd/sys/windows/tcp.rs
unsafe impl Send for Event {}
unsafe impl Sync for Event {}
unsafe impl Send for TcpListener {}
unsafe impl Sync for TcpListener {}
unsafe impl Send for TcpAcceptor {}
unsafe impl Sync for TcpAcceptor {}
unsafe impl Send for AcceptorInner {}
unsafe impl Sync for AcceptorInner {}
There are some explicit Send/Sync implementations for Window's types
that don't exist in Unix. While the end result will be the same, I
believe it's clearer if we keep the explicit implementations consistent
by making the os-specific types Send/Sync where needed and possible.
This commit addresses pipe
src/libstd/sys/unix/pipe.rs
unsafe impl Send for UnixListener {}
unsafe impl Sync for UnixListener {}
src/libstd/sys/windows/pipe.rs
unsafe impl Send for UnixStream {}
unsafe impl Sync for UnixStream {}
unsafe impl Send for UnixListener {}
unsafe impl Sync for UnixListener {}
unsafe impl Send for UnixAcceptor {}
unsafe impl Sync for UnixAcceptor {}
unsafe impl Send for AcceptorState {}
unsafe impl Sync for AcceptorState {}
I'm beginning to suspect it's impossible to avoid accidentally writing
`#[deriving]` at least once in every program, and it results in
non-intuitive error messages: "Foo doesn't have any method in scope
`clone`" despite there being a `#[deriv...(Clone)]` attribute!
Also, lots of documentation around the internet uses `#[deriving]` so
providing this guidance is very helpful (lots of people ask in #rust
about this error).
the syntax of 'case' is:
`case word in [[(] pattern [| pattern] ...) list ;; ] ... esac`
`list` don't have to issue `break`. `break` is normally used to exit a
`for`, `until` or `while` loop.
As part of #20432, upvar checking is now moved out of regionck to its
own pass and before regionck. But regionck has some type resolution of
its own. Without them, now separated upvar checking may be tripped over
by residue `ty_infer`.
Closes#21306
Two minor improvements that have been on my TODO list for a while:
* Clang uses a size of `-1` for arrays of unknown size and we should do that too as it will tell LLVM to omit the size information in debuginfo.
* There was no LLDB test case for handling the optimized enum representation introduced by @luqmana. This PR finally adds one.
Before:
```
error: invalid operand for inline asm constraint 'i' at line 11
```
Note that 11 is not the line the inline assembly appears in.
After:
```
src/arch/x64/multiboot/bootstrap.rs:203:5: 209:9 error: invalid operand for inline asm constraint 'i'
src/arch/x64/multiboot/bootstrap.rs:203 asm! {
src/arch/x64/multiboot/bootstrap.rs:204 [multiboot => %ecx, mod attsyntax]
src/arch/x64/multiboot/bootstrap.rs:205
src/arch/x64/multiboot/bootstrap.rs:206 ljmp {size_of::<Descriptor>() => %i}, $bootstrap.64
src/arch/x64/multiboot/bootstrap.rs:207 }
src/arch/x64/multiboot/bootstrap.rs:208
...
error: aborting due to previous error
```
when saving .rs files under vim
do not fail to run the syntax checker
error: Unrecognized option: 'parse-only'.
due to this commit
953f294ea3
which removed the deprecated flag --parse-only
E.g. `fn foo() { foo() }`, or, more subtlely
impl Foo for Box<Foo+'static> {
fn bar(&self) {
self.bar();
}
}
The compiler will warn and point out the points where recursion occurs,
if it determines that the function cannot return without calling itself.
Closes#17899.
---
This is highly non-perfect, in particular, my wording above is quite precise, and I have some unresolved questions: This currently will warn about
```rust
fn foo() {
if bar { loop {} }
foo()
}
```
even though `foo` may never be called (i.e. our apparent "unconditional" recursion is actually conditional). I don't know if we should handle this case, and ones like it with `panic!()` instead of `loop` (or anything else that "returns" `!`).
However, strictly speaking, it seems to me that changing the above to not warn will require changing
```rust
fn foo() {
while bar {}
foo()
}
```
to also not warn since it could be that the `while` is an infinite loop and doesn't ever hit the `foo`.
I'm inclined to think we let these cases warn since true edge cases like the first one seem rare, and if they do occur they seem like they would usually be typos in the function call. (I could imagine someone accidentally having code like `fn foo() { assert!(bar()); foo() /* meant to be boo() */ }` which won't warn if the `loop` case is "fixed".)
(Part of the reason this is unresolved is wanting feedback, part of the reason is I couldn't devise a strategy that worked in all cases.)
---
The name `unconditional_self_calls` is kinda clunky; and this reconstructs the CFG for each function that is linted which may or may not be very expensive, I don't know.
This ends up propagating all the way out to the output of dep-info which then
makes Cargo think that files are not existent (it thinks the files have quotes
in their name) when they in fact do.
This commit relaxes the bound on `Result::unwrap` and `Result::unwrap_err` from
the `Display` trait to the `Debug` trait for generating an error message about
the unwrapping operation.
This commit is a breaking change and any breakage should be mitigated by
ensuring that `Debug` is implemented on the relevant type.
[breaking-change]
I'm beginning to suspect it's impossible to avoid accidentally writing
`#[deriving]` at least once in every program, and it results in
non-intuitive error messages: "Foo doesn't have any method in scope
`clone`" despite there being a `#[deriv...(Clone)]` attribute!
Also, lots of documentation around the internet uses `#[deriving]` so
providing this guidance is very helpful (lots of people ask in #rust
about this error).
Fixes#21166.