Commit Graph

549 Commits

Author SHA1 Message Date
Niko Matsakis
8bd8466e81 Refactor how we handle overflow so that it is a fatal error that aborts
compilation: this removes all the ungainly code that special cases
overflow so that we can ensure it propagates.
2015-03-23 18:05:20 -04:00
Manish Goregaokar
d8baa010ab Rollup merge of #23570 - dotdash:issue23550, r=eddyb
Boolean values and small aggregates have a different type in args/allocas than
in SSA values but the intrinsics for volatile and atomic ops were
missing the necessary casts to handle that.

Fixes #23550
2015-03-23 04:54:26 +05:30
bors
b0aad7dd4f Auto merge of #23361 - petrochenkov:refdst, r=jakub-
After this patch code like `let ref a = *"abcdef"` doesn't cause ICE anymore.
Required for #23121

There are still places in rustc_trans where pointers are always assumed to be thin. In particular, #19064 is not resolved by this patch.
2015-03-22 15:52:30 +00:00
Björn Steinbrink
d4ca1cffce Fix volatile / atomic ops on bools and small aggregates
Boolean values and small aggregates have a different type in
args/allocas than in SSA values but the intrinsics for volatile and
atomic ops were missing the necessary casts to handle that.

Fixes #23550
2015-03-21 10:46:52 +01:00
Joseph Crail
857035ade7 Fix spelling errors in comments.
I corrected misspelled comments in several crates.
2015-03-19 00:48:08 -04:00
bors
46f649c479 Auto merge of #22838 - petrochenkov:bytelit, r=alexcrichton
This patch changes the type of byte string literals from `&[u8]` to `&[u8; N]`.
It also implements some necessary traits (`IntoBytes`, `Seek`, `Read`, `BufRead`) for fixed-size arrays (also related to #21725) and adds test for #17233, which seems to be resolved.

Fixes #18465
[breaking-change]
2015-03-18 08:27:22 +00:00
Vadim Petrochenkov
dccd17d23e Remove the newly introduced trait impls for fixed-size arrays and use &b"..."[..] instead. 2015-03-18 09:16:08 +03:00
bors
f9a7bc58f8 Auto merge of #23290 - nrc:pub_priv_mod, r=nikomatsakis
Closes #22261

r? @nikomatsakis 

(+ a new test coming soon...)
2015-03-18 05:55:19 +00:00
Nick Cameron
46aa621452 Fix private module loophole in the 'private type in public item' check 2015-03-18 16:47:24 +13:00
bors
c10918905f Auto merge of #23452 - nikomatsakis:unsafety-subtyping, r=nrc
Safe fns are no longer subtypes of unsafe fns, but you can coerce from one to the other.

This is a [breaking-change] in that impl fns must now be declared `unsafe` if the trait is declared `unsafe`. In some rare cases, the subtyping change may also direct affect you, but no such cases were encountered in practice.

Fixes #23449.

r? @nrc
2015-03-18 03:22:12 +00:00
bors
1ae32decb8 Auto merge of #23438 - nikomatsakis:issue-23435-default-methods-with-where-clauses, r=nrc
Fixes #23435
2015-03-18 00:51:03 +00:00
Vadim Petrochenkov
d2cccd07bc Fix byte string literal patterns in match 2015-03-18 00:40:59 +03:00
Vadim Petrochenkov
1e9bef916f Fixed-size byte string literals (RFC 339) 2015-03-18 00:40:59 +03:00
Niko Matsakis
0947f4076d Move unsafety out of the subtyping relation and into coercion. 2015-03-17 17:29:07 -04:00
Eduard Burtescu
e256b7f049 Replace TyDesc and its uses with trait vtables and a type_name intrinsic. 2015-03-17 21:00:23 +02:00
Eduard Burtescu
3e98ab560a rustc_trans: use the drop glue of T instead of Box<T> in Trait's vtable, be it &Trait or Box<Trait>. 2015-03-17 21:00:21 +02:00
bors
c64d671671 Auto merge of #23423 - nikomatsakis:issue-18737-trait-subtyping, r=nrc
This upcast coercion currently never requires vtable changes. It should be generalized. 

This is a [breaking-change] -- if you have an impl on an object type like `impl SomeTrait`, then this will no longer be applicable to object types like `SomeTrait+Send`. In the standard library, this primarily affected `Any`, and this PR adds impls for `Any+Send` as to keep the API the same in practice. An alternate workaround is to use UFCS form or standalone fns. For more details, see <https://github.com/rust-lang/rust/issues/18737#issuecomment-78450798>.

r? @nrc
2015-03-17 13:29:48 +00:00
Niko Matsakis
5f5ed62298 Remove subtyping for object types and replace with an *upcast* coercion.
This upcast coercion currently preserves the vtable for the object, but
eventually it can be used to create a derived vtable. The upcast
coercion is not introduced into method dispatch; see comment on #18737
for information about why. Fixes #18737.
2015-03-17 08:34:25 -04:00
Niko Matsakis
bd2096c497 Only test predicates if this is a default method, as a simple optimization. 2015-03-17 07:36:42 -04:00
Niko Matsakis
99a508bc17 Check that predicates hold before emitting an entry for the vtable.
Fixes #23435.
2015-03-17 06:24:11 -04:00
Manish Goregaokar
fad4c380e8 Rollup merge of #23385 - tamird:cleanup-whitespace, r=alexcrichton
r? @alexcrichton

Conflicts:
	src/test/run-pass/test-fn-signature-verification-for-explicit-return-type.rs
2015-03-17 15:21:22 +05:30
Manish Goregaokar
0b463b075e Rollup merge of #23329 - jbcrail:rm-syntax-highlight, r=sanxiyn
As suggested by @steveklabnik in #23254, I removed the redundant Rust syntax highlighting from the documentation.
2015-03-17 15:20:27 +05:30
Niko Matsakis
88b65c9e2b Refactor the emit_vtable_methods code to be a bit cleaner in its use of
iterators.
2015-03-17 05:18:01 -04:00
Tobias Bucher
1b894c65de Improve error handling in libflate
This removes the error case of the compression functions, the only errors that
can occur are incorrect parameters or an out-of-memory condition, both of which
are handled with panics in Rust.

Also introduces an extensible `Error` type instead of returning an `Option`.
2015-03-16 19:15:20 +01:00
Vadim Petrochenkov
a5eefdef3c Fix binding unsized expressions to ref patterns 2015-03-15 19:16:04 +03:00
Tamir Duberstein
d51047ded0 Strip all leading/trailing newlines 2015-03-15 09:08:21 -07:00
Björn Steinbrink
9eed8ea644 Fix broken codegen for [expr; n] where "expr" diverges 2015-03-14 14:23:43 +01:00
Björn Steinbrink
3a8f989dbb Always evaluate the expression in [expr; n]
In case that there is a destination for the array, like in
"let x = [expr; n]", we currently don't evaluate the given expression if
n is zero. That's inconsistent with all other cases, including "[expr;
0]" without a destination.

Fixes #23354
2015-03-14 14:19:29 +01:00
Joseph Crail
fcf3f3209a Remove explicit syntax highlight from docs. 2015-03-13 19:25:18 -04:00
Manish Goregaokar
d0f98fcc7f Rollup merge of #23322 - dotdash:jemalloc_attrs, r=brson
When this attribute is applied to a function, its return value gets the
noalias attribute, which is how you tell LLVM that the function returns
a \"new\" pointer that doesn't alias anything accessible to the caller,
i.e. it acts like a memory allocator.

Plain malloc doesn't need this attribute because LLVM already knows
about malloc and adds the attribute itself.
2015-03-13 18:11:51 +05:30
Björn Steinbrink
0942803f50 Add an "allocator" attribute to mark functions as allocators
When this attribute is applied to a function, its return value gets the
noalias attribute, which is how you tell LLVM that the function returns
a "new" pointer that doesn't alias anything accessible to the caller,
i.e. it acts like a memory allocator.

Plain malloc doesn't need this attribute because LLVM already knows
about malloc and adds the attribute itself.
2015-03-13 03:19:30 +01:00
bors
c9b03c24ec Auto merge of #23265 - eddyb:meth-ast-refactor, r=nikomatsakis
The end result is that common fields (id, name, attributes, etc.) are stored in now-structures `ImplItem` and `TraitItem`.
The signature of a method is no longer duplicated between methods with a body (default/impl) and those without, they now share `MethodSig`.

This is also a [breaking-change] because of minor bugfixes and changes to syntax extensions:
* `pub fn` methods in a trait no longer parse - remove the `pub`, it has no meaning anymore
* `MacResult::make_methods` is now `make_impl_items` and the return type has changed accordingly
* `quote_method` is gone, because `P<ast::Method>` doesn't exist and it couldn't represent a full method anyways - could be replaced by `quote_impl_item`/`quote_trait_item` in the future, but I do hope we realize how silly that combinatorial macro expansion is and settle on a single `quote` macro + some type hints - or just no types at all (only token-trees)

r? @nikomatsakis This is necessary (hopefully also sufficient) for associated constants.
2015-03-12 20:13:23 +00:00
Björn Steinbrink
de67c3a5bb Fix LLVM assertion when out-of-bounds indexing in a constant
Fixes #23291
2015-03-12 00:38:22 +01:00
Eduard Burtescu
9da918548d syntax: move MethMac to MacImplItem and combine {Provided,Required}Method into MethodTraitItem. 2015-03-11 23:39:16 +02:00
Eduard Burtescu
ce10fa8d12 syntax: rename TypeMethod to MethodSig and use it in MethDecl. 2015-03-11 23:39:16 +02:00
Eduard Burtescu
f98b176314 syntax: gather common fields of impl & trait items into their respective types. 2015-03-11 23:39:16 +02:00
Eduard Burtescu
98491827b9 syntax: move indirection around {Trait,Impl}Item, from within. 2015-03-11 23:39:15 +02:00
Manish Goregaokar
a49b6f8bd3 Rollup merge of #23201 - pnkfelix:fsk-struct-ooe-23112, r=nikomatsakis
For FRU, eval field exprs (into scratch temps) before base expr

Fix #23112.
2015-03-10 14:59:07 +05:30
Felix S. Klock II
3dbf969103 For FRU, evaluate field expressions (into scratch temps) before base expression.
Fix #23112.
2015-03-09 14:50:36 +01:00
Manish Goregaokar
d77fc9fefc Rollup merge of #23074 - michaelwoerister:constants-debug-locs, r=alexcrichton
With this PR in-place constants are handled correctly with respect to debug location assignment.
The PR also adds an (unrelated) test case for debug locations in `extern \"C\"` functions.

Fixes #22432
2015-03-06 09:01:23 +05:30
Manish Goregaokar
efb487b503 Rollup merge of #22980 - alexcrichton:debug-assertions, r=pnkfelix
This commit is an implementation of [RFC 563][rfc] which adds a new
`cfg(debug_assertions)` directive which is specially recognized and calculated
by the compiler. The flag is turned off at any optimization level greater than 1
and may also be explicitly controlled through the `-C debug-assertions`
flag.

[rfc]: https://github.com/rust-lang/rfcs/pull/563

The `debug_assert!` and `debug_assert_eq!` macros now respect this instead of
the `ndebug` variable and `ndebug` no longer holds any meaning to the standard
library.

Code which was previously relying on `not(ndebug)` to gate expensive code should
be updated to rely on `debug_assertions` instead.

Closes #22492
[breaking-change]
2015-03-06 08:58:30 +05:30
Alex Crichton
d5d834551c rustc: Add a debug_assertions #[cfg] directive
This commit is an implementation of [RFC 563][rfc] which adds a new
`cfg(debug_assertions)` directive which is specially recognized and calculated
by the compiler. The flag is turned off at any optimization level greater than 1
and may also be explicitly controlled through the `-C debug-assertions`
flag.

[rfc]: https://github.com/rust-lang/rfcs/pull/563

The `debug_assert!` and `debug_assert_eq!` macros now respect this instead of
the `ndebug` variable and `ndebug` no longer holds any meaning to the standard
library.

Code which was previously relying on `not(ndebug)` to gate expensive code should
be updated to rely on `debug_assertions` instead.

Closes #22492
[breaking-change]
2015-03-05 14:51:38 -08:00
bors
b0746ff19b Auto merge of #23031 - Manishearth:rollup, r=Manishearth 2015-03-05 21:03:10 +00:00
bors
f0c74f85f3 Auto merge of #23026 - nikomatsakis:issue-20220-supertrait, r=nikomatsakis
The main gist of this PR is commit 1077efb which removes the list of supertraits from the `TraitDef` and pulls them into a separate table, which is accessed via `lookup_super_predicates`. This is analogous to `lookup_predicates`, which gets the complete where clause. This allows us to create the `TraitDef`, which contains the list generics and so forth, without fully knowing the list of supertraits. This in turn allows the *supertrait listing* to contain references to associated types like `<Self as Foo>::Item`, which were previously impossible because conversion required having the `TraitDef` for `Foo`.

We do not yet support `Self::Item` in a supertrait listing. This doesn't work because to convert that, it attempts to expand out the full set of supertraits, which are in the process of being created. This could potentially be worked out by having the expansion of supertraits proceed in a lazy fashion, but we'd have to define shadowing rules for associated types which we don't currently have.

Along the way (in 9de9ec5) I also removed the restriction against duplicate bounds and generalized the code so that it can handle having the same supertrait multiple times with different arguments, e.g. `Foo : Bar<i32> + Bar<u32>`. This restriction was serving no particular purpose, since the same trait could be extended multiple times indirectly, and in the era of multidispatch it is actively harmful.

This is technically a [breaking-change] because it affects the definition of a super-trait. Anything in a where clause that looks like `where Self : Foo` is now considered a supertrait. Because cycles are disallowed in supertraits, that could lead to some errors. This has not been observed in any existing code.

r? @nrc
2015-03-05 17:52:21 +00:00
Michael Woerister
e316c662f8 debuginfo: Add debuginfo::with_source_location_override() function...
... and use it to fix a debug-location issue with constants.
2015-03-05 15:00:25 +01:00
Niko Matsakis
9b332ff2c7 Address nits by @nrc. 2015-03-05 05:46:12 -05:00
Manish Goregaokar
145b83e633 Rollup merge of #22994 - eddyb:unsuffix-ints-good, r=alexcrichton
Automatic has-same-types testing methodology can be found in #22501.
Because most of them don't work with `--pretty=typed`, compile-fail tests were manually audited.

r? @aturon
2015-03-05 12:38:33 +05:30
Eduard Burtescu
e64670888a Remove integer suffixes where the types in compiled code are identical. 2015-03-05 12:38:33 +05:30
Manish Goregaokar
c8c4d85b50 Rollup merge of #22764 - ivanradanov:fileline_help, r=huonw
When warnings and errors occur, the associated help message should not print the same code snippet.
https://github.com/rust-lang/rust/issues/21938
2015-03-05 12:38:32 +05:30
Alex Crichton
95d904625b std: Deprecate std::old_io::fs
This commit deprecates the majority of std::old_io::fs in favor of std::fs and
its new functionality. Some functions remain non-deprecated but are now behind a
feature gate called `old_fs`. These functions will be deprecated once
suitable replacements have been implemented.

The compiler has been migrated to new `std::fs` and `std::path` APIs where
appropriate as part of this change.
2015-03-04 15:59:30 -08:00