- Most functions that used to return `~[~str]` for a list of substrings got turned into iterators over `&str` slices
- Some cleanup of apis, docs and code layout
and from typeck, which is verboten. We are supposed to write inference results
into the FnCtxt and then these get copied over in writeback. Add assertions
that no inference by-products are added to this table.
Fixes#3888Fixes#4036Fixes#4492
Kills some warnings, and implements str::each_char_reverse so that it actually iterates. The test case wasn't detecting a failure, since the loop body was never executed.
`let v = [24, ..1000];` now more or less emits the same IR as:
```Rust
let mut i = 0;
while i < 1000 {
v[i] = 24;
i += 1;
}
```
LLVM will still turn it into a memset if possible with optimization on.
The reasoning for doing it this way is that it's much easier to transition method-by-method to the `Map` API than trying to do the migration all at once.
I found an issue unrelated to my changes in one of the run-fail tests - if it uses `LinearMap`, it still fails but exits with 0. I xfailed it for now and opened [an issue](https://github.com/mozilla/rust/issues/5512), because it's not caused by these changes.
r? @nikomatsakis The typechecker previously passed around a boolean return flag to
indicate whether it saw something with type _|_ (that is, something
it knows at compile-time will definitely diverge) and also had some
manual checks for the `ty_err` pseudo-type that represents a previous
type error. This was because the typing rules implemented by the
typechecker didn't properly propagate _|_ and ty_err. I fixed it.
This also required changing expected error messages in a few tests,
as now we're printing out fewer derived errors -- in fact, at this
point we should print out no derived errors, so report any that
you see (ones that include "[type error]") as bugs.
A slice now always refers to something that returns an borrowed pointer, views don't exist anymore. If you want to have an explictit copy of a slice, use `to_owned()`
The typechecker previously passed around a boolean return flag to
indicate whether it saw something with type _|_ (that is, something
it knows at compile-time will definitely diverge) and also had some
manual checks for the `ty_err` pseudo-type that represents a previous
type error. This was because the typing rules implemented by the
typechecker didn't properly propagate _|_ and ty_err. I fixed it.
This also required changing expected error messages in a few tests,
as now we're printing out fewer derived errors -- in fact, at this
point we should print out no derived errors, so report any that
you see (ones that include "[type error]") as bugs.
Removes a lot of instances of `/*bad*/ copy` throughout libsyntax/librustc. On the plus side, this shaves about 2s off of the runtime when compiling `librustc` with optimizations.
Ideally I would have run a profiler to figure out which copies are the most critical to remove, but in reality there was a liberal amount of `git grep`s along with some spot checking and removing the easy ones.
For bootstrapping purposes, this commit does not remove all uses of
the keyword "pure" -- doing so would cause the compiler to no longer
bootstrap due to some syntax extensions ("deriving" in particular).
Instead, it makes the compiler ignore "pure". Post-snapshot, we can
remove "pure" from the language.
There are quite a few (~100) borrow check errors that were essentially
all the result of mutable fields or partial borrows of `@mut`. Per
discussions with Niko I think we want to allow partial borrows of
`@mut` but detect obvious footguns. We should also improve the error
message when `@mut` is erroneously reborrowed.
This is done in two steps:
First, we make foreign functions not consider modes at all. This is because previously ++ mode was the only way to pass structs to foreign functions and so forth. We also add a lint mode warning if you use `&&` mode in a foreign function, since the semantics of that change (it used to pass a pointer to the C function, now it doesn't).
Then, we remove by value and make it equivalent to `+` mode. At the same time, we stop parsing `-` mode and convert all uses of it to `+` mode (it was already being parsed to `+` mode anyhow).
This obsoletes pull request #5298.
r? @brson
adjusting a few foreign functions that were declared with by-ref
mode. This also allows us to remove by-val mode in the near future.
With copy mode, though, we have to be careful because Rust will implicitly pass
somethings by pointer but this may not be the C ABI rules. For example, rust
will pass a struct Foo as a Foo*. So I added some code into the adapters to
fix this (though the C ABI rules may put the pointer back, oh well).
This patch also includes a lint mode for the use of by-ref mode
in foreign functions as the semantics of this have changed.
Continuing #5140
For the sake of getting this merged I've disabled debuginfo tests on mac (where running gdb needs root). Please feel free to follow up with further improvements.
r? @graydon
This removes `log` from the language. Because we can't quite implement it as a syntax extension (probably need globals at the least) it simply renames the keyword to `__log` and hides it behind macros.
After this the only way to log is with `debug!`, `info!`, etc. I figure that if there is demand for `log!` we can add it back later.
I am not sure that we ever agreed on this course of action, though I *think* there is consensus that `log` shouldn't be a statement.
These changes make const translation use adjustments (autodereference, autoreference, bare-fn-to-closure), like normal code does, replacing some ad-hoc logic that wasn't always right.
As a convenient side-effect, explicit dereference (both of pointers and of newtypes) is also supported in const expressions.
There is also a “bonus fix” for a bug in the pretty-printer exposed by one of the added tests.
Struct and enum representations have some complicatedness that's no longer needed. Now that everything's in one place and has access to anything we'd want to know about the type, flatten some of that out. Slight changes to representations in some cases.
The only thing we really lose is that C-like enums with one variant and a
non-zero discriminant now take up space, but I do not think this is a
common usage. As previously noted, that was mostly there for
transitional compatibility with the pre-adt.rs codebase.
Out goes the extra layer of struct wrapping; the destructedness flag is
added to the end of the struct. This means that, if the struct
previously had alignment padding at the end, the flag will live there
instead of increasing the struct size.
Changes the ad-hoc closure adjustment into using adjustment info instead
of being separately driven from types, and likewise for autoderef.
Also takes care of autoref (the cases we should be seeing in consts,
at least, since we can't be doing method calls which would need the
ref-to-vec mode), which didn't quite work right previously.
However, "dereference" of a newtype isn't handled yet....
Also converts const cast-from-enum, because it used the same routine to
get the discriminant as what's renovated to construct the enums.
Also fixes ICE on struct-like variants as consts, and provides a slightly
less bad ICE for functional-update-like struct expressions in consts.
Note that in the ByValue case (which can't happen? yet?) we're still
effectively bitcasting, I think. So this change adds a way to assert
that that's safe.
Note also, for future reference, that LLVM's instcombine pass will turn
a bitcast into a GEP(0, 0, ...) if possible.
This change remains separate from the addition of adt.rs, even though
it's necessary for compatibility with pre-trans::adt representation,
to serve as an example of a change to the representation logic.
Later changes on this branch adapt the rest of rustc::middle::trans
to use this module instead of scattered hard-coded knowledge of
representations; a few of them also have improvements or cleanup for
adt.rs (and many added comments) that weren't drastic enough to justify
changing history to move them into this commit.
Work towards #4846.
- Institute new region defaults where all omitted regions get a fresh lifetime.
- Require explicit region names except in functions.
- Fix a bug in region parameterization inference. I've been putting this off because it will not be important when we remove RP inference in favor of explicit declarations, but then it was blocking this patch.
r? @pcwalton
Before:
````
test.rs:3:21: 3:30 error: expected constant integer for repeat count but found variable
test.rs:3 let a = ~[0, ..n]; //~ ERROR expected constant integer for repeat count but found variable
^~~~~~~~~
````
After:
````
test.rs:3:27: 3:28 error: expected constant integer for repeat count but found variable
test.rs:3 let a = ~[0, ..n]; //~ ERROR expected constant integer for repeat count but found variable
^
````
Before:
````
test.rs:3:21: 3:30 error: expected constant integer for repeat count but found variable
test.rs:3 let a = ~[0, ..n]; //~ ERROR expected constant integer for repeat count but found variable
^~~~~~~~~
````
After:
````
test.rs:3:27: 3:28 error: expected constant integer for repeat count but found variable
test.rs:3 let a = ~[0, ..n]; //~ ERROR expected constant integer for repeat count but found variable
^
````
The basic idea is that we add a new kind of adjustment, AutoAddEnv, that pads
an extern fn into a closure by adding the extra NULL word. Then there are a few
misc changes in trans to get the LLVM types to match up.
Fixes#4808.
This removes all but 6 uses of `drop {}` from the entire codebase. Removing any of the remaining uses causes various non-trivial bugs; I'll start reporting them once this gets merged.
Major changes are:
- replace ~[ty_param] with Generics structure, which includes
both OptVec<TyParam> and OptVec<Lifetime>;
- the use of syntax::opt_vec to avoid allocation for empty lists;
cc #4846
r? @graydon
Major changes are:
- replace ~[ty_param] with Generics structure, which includes
both OptVec<TyParam> and OptVec<Lifetime>;
- the use of syntax::opt_vec to avoid allocation for empty lists;
cc #4846
r?
#3406
Pretty straightforward. I'm using opaque pointers instead trying to get trans and core to agree on the types of the main function and crate map. One oddity is that this required changing the order of the `-lrustrt` argument to the linker in order to resolve `upcall_new_stack`. Linkers are mysterious.
r?
After this patch, macros declared in a module, function, or block can only be used inside of that module, function or block, with the exception of modules declared with the #[macro_escape] attribute; these modules allow macros to escape, and can be used as a limited macro export mechanism.
This pull request also includes miscellaneous comments, lots of new test cases, a few renamings, and a few as-yet-unused data definitions for hygiene.
Address #2281
```
-> % cat foo.rs
fn foo() -> int {
let bar = 10;
bad
}
```
```
-> % rustc foo.rs
foo.rs:4:4: 4:7 error: unresolved name: `bad`. Did you mean: `bar`?
foo.rs:4 bad
^~~
error: aborting due to previous error
```