Commit Graph

912 Commits

Author SHA1 Message Date
Tim Chevalier
edc11a9f09 rustc: Suppress derived pattern-match-checking errors
typeck::check::_match wasn't suppressing derived errors properly.
Fixed it.
2013-04-28 18:47:55 -07:00
Daniel Micay
f792baba42 only use #[no_core] in libcore 2013-04-27 21:34:24 -04:00
bors
9f118865a2 auto merge of #6072 : cmr/rust/better_import_error, r=graydon 2013-04-27 14:24:36 -07:00
Corey Richardson
8dd9dc995e add comment 2013-04-26 05:28:43 -04:00
Corey Richardson
b085b51357 Offer a hint on some unresolved imports
I didn't know how to use "use" initially, and an error message like this would
have solved quite a bit of frustration. I think this properly handles cases
where it's not appropriate but I'm not sure.
2013-04-26 04:59:28 -04:00
Corey Richardson
d53e686f4f Rename vec::mod2 to vec::mod_zip 2013-04-25 01:38:44 -04:00
Brendan Zabarauskas
ab8068c9f2 Improve divide-by-zero error messages 2013-04-24 14:20:00 +10:00
Alex Crichton
0c2ab662b7 Fixing some various warnings about unused imports 2013-04-23 19:59:14 -04:00
Alex Crichton
4c08a8d6c3 Removing more unnecessary unsafe blocks throughout 2013-04-23 19:59:13 -04:00
Alex Crichton
c089a17854 Improve the unused unsafe block warning to include unsafe blocks in unsafe functions 2013-04-23 19:40:34 -04:00
bors
88ccee78a8 auto merge of #6022 : catamorphism/rust/warning-police, r=catamorphism 2013-04-23 10:36:50 -07:00
Tim Chevalier
7169907e9f rustc: Remove dead code 2013-04-23 10:17:41 -07:00
Tim Chevalier
aac73b24ae rustc: Comments only: change XXX to FIXME 2013-04-23 10:17:41 -07:00
Tim Chevalier
52d3f5558e core, rustc: Warning police 2013-04-23 10:17:38 -07:00
bors
8cadcc47ee auto merge of #6027 : alexcrichton/rust/more-backticks, r=catamorphism
It seems that the general convention of error messages is to have keywords in backticks, so it's probably a good idea to keep doing that.
2013-04-23 09:48:49 -07:00
bors
0290caa885 auto merge of #6026 : isanbard/rust/ca73fbf72615575f106ee18160580711aca89d85, r=catamorphism
When the number of parameters is 1, then 'parameter' should remain singular.
Otherwise pluralize it.
2013-04-23 02:33:49 -07:00
Alex Crichton
8884c6abdb Use backticks for the unsafe keyword in error messages 2013-04-23 02:06:47 -04:00
Bill Wendling
ca73fbf726 Use correct grammar for error message.
When the number of parameters is 1, then 'parameter' should remain singular.
Otherwise pluralize it.
2013-04-22 22:08:09 -07:00
bors
b8441ca8a6 auto merge of #6007 : pcwalton/rust/use-mod, r=brson
r? @brson
2013-04-22 18:36:50 -07:00
bors
aba93c6b60 auto merge of #5966 : alexcrichton/rust/issue-3083, r=graydon
Closes #3083.

This takes a similar approach to #5797 where a set is present on the `tcx` of used mutable definitions. Everything is by default warned about, and analyses must explicitly add mutable definitions to this set so they're not warned about.

Most of this was pretty straightforward, although there was one caveat that I ran into when implementing it. Apparently when the old modes are used (or maybe `legacy_modes`, I'm not sure) some different code paths are taken to cause spurious warnings to be issued which shouldn't be issued. I'm not really sure how modes even worked, so I was having a lot of trouble tracking this down. I figured that because they're a legacy thing that I'd just de-mode the compiler so that the warnings wouldn't be a problem anymore (or at least for the compiler).

Other than that, the entire compiler compiles without warnings of unused mutable variables. To prevent bad warnings, #5965 should be landed (which in turn is waiting on #5963) before landing this. I figured I'd stick it out for review anyway though.
2013-04-22 15:36:51 -07:00
Patrick Walton
25129ee81c librustc: Remove use mod from the language 2013-04-22 12:32:59 -07:00
Jed Davis
22f751f0f3 Use nullable pointers to represent enums like Option<~T>.
See comments in adt.rs for details.
2013-04-22 08:50:27 -07:00
Jed Davis
70452e5231 Consider nullability for equivalence of monomorphized fns. 2013-04-22 08:49:56 -07:00
Brendan Zabarauskas
01eb5e8ad3 Rename Div operator trait to Quot and Modulo operator trait to Rem 2013-04-22 01:58:53 +10:00
Alex Crichton
c389d0b0dd rustc: remove unused 'mut' variables 2013-04-20 21:03:24 -04:00
Alex Crichton
d1985c9dd0 Implement a lint mode to deal with unused 'mut' variables 2013-04-20 21:02:38 -04:00
bors
0e017ab4e0 auto merge of #5979 : Thiez/rust/no_reinterpret_cast, r=catamorphism
As the name suggests this replaces many instances of cast::reinterpret_cast by cast::transmute. It's essentially the boring part of fixing #5163, the remaining reinterpret_casts should be more tricky to remove (unless I missed a boring case).

r? @catamorphism
2013-04-20 14:24:51 -07:00
bors
f0afe23dce auto merge of #5978 : alexcrichton/rust/issue-5954, r=catamorphism
Closes #5954
2013-04-20 13:33:51 -07:00
Matthijs Hofstra
51a68eb9b1 Replaced many instances of reinterpret_cast with transmute 2013-04-20 22:05:50 +02:00
Alex Crichton
3c2a44b60f Don't warn about unsafe functions which don't need to be unsafe 2013-04-20 15:52:05 -04:00
Huon Wilson
93c0888b6c librustc: implement and use fixed_stack_segment attribute for intrinsics. 2013-04-21 01:40:48 +10:00
Alex Crichton
1e4a439f7f rustc: de-mode + fallout from libsyntax changes 2013-04-19 23:23:23 -04:00
Alex Crichton
be9f4ef65f Fix an ICE when dereferencing types which cannot be dereferenced 2013-04-19 23:21:52 -04:00
bors
8b3c09a103 auto merge of #5962 : pcwalton/rust/shootout, r=pcwalton
r? @brson
2013-04-19 19:24:52 -07:00
Patrick Walton
dcea717208 librustc: Fix botched merge. rs=merge 2013-04-19 15:57:31 -07:00
bors
7d250d3181 auto merge of #5824 : bleibig/rust/debuginfo, r=brson
This adds debugging symbol generation for boxes, bare functions, vectors, and strings, along with a tests for boxes and vectors.

Note that gdb will see them as their actual compiled representation with the refcount, tydesc, etc. fields, so if `b` refers to box, `b->boxed` will refer to its value. Also, since you seem to use the [C struct hack](http://c-faq.com/struct/structhack.html) for dynamic vectors, you won't be able to print out the whole vector at once, only one element at a time by indexing specific elements.
2013-04-19 12:03:49 -07:00
Patrick Walton
f93b3cd5c3 librustc: Remove debug code; xfail-pretty reverse-complement. 2013-04-19 12:00:48 -07:00
Patrick Walton
c995a62d44 librustc: WIP patch for using the return value. 2013-04-19 12:00:08 -07:00
Patrick Walton
0b0ca597bf librustc: Improve inlining behavior. 2013-04-19 11:53:34 -07:00
Patrick Walton
53f54dda60 librustc: Remove def_ids from types. 2013-04-19 11:53:33 -07:00
Patrick Walton
04df19c5ca librustc: Take primitive types out of the type hash table. 2013-04-19 11:53:33 -07:00
Patrick Walton
3ffaaab9e9 librustc: Switch the @s in types with ~ 2013-04-19 11:53:32 -07:00
Patrick Walton
f903ae9e72 librustc: Implement fast-ffi and use it in various places 2013-04-19 11:53:31 -07:00
Patrick Walton
1a36b0f17e librustc: Remove fail_unless! 2013-04-19 11:53:31 -07:00
bors
d3a58f3797 auto merge of #5943 : brson/rust/struct-return, r=graydon
Mac appears to follow the same ABI as MSVC. This fixes one case
but leaves others broken, like windows.
2013-04-18 19:45:48 -07:00
bors
225d74f211 auto merge of #5914 : catamorphism/rust/copy-cops, r=catamorphism 2013-04-18 17:51:51 -07:00
Tim Chevalier
3d43af15d8 rustc: Anti-copy police
In this case, some copies are still necessary to convert from
a mutable to an immutable @-box. It's still an improvement,
I hope.
2013-04-18 17:40:42 -07:00
Tim Chevalier
62847b0f24 rustc: Make some typechecker errors non-fatal 2013-04-18 15:12:27 -07:00
Brian Anderson
8a6d6dd868 rustc: Fix struct returns on x86 mac for 8-byte structs
Mac appears to follow the same ABI as MSVC. This fixes one case
but leaves others broken, like windows.
2013-04-18 14:14:17 -07:00
bors
fdb4ef321e auto merge of #5726 : brson/rust/struct-return, r=brson
r? @nikomatsakis

This doesn't completely fix the x86 ABI for structs, but it does fix some cases. On linux, structs appear to be returned correctly now. On windows, structs are only returned by pointer when they are greater than 8 bytes. That scenario works now.

In the case where the struct is less than 8 bytes our generated code looks peculiar. When returning a pair of u16, C packs both variables into %eax to return them. Our generated code though expects to find one of the pair in %ax and the other in %dx. Similar for u8. I haven't looked into it yet.

There appears to also be struct passing problems on linux, where my `extern-pass-TwoU8s` and `extern-pass-TwoU16s` tests are failing.
2013-04-17 18:45:58 -07:00
Brian Anderson
a5ddc00982 rustc: Use an out pointer to return structs in x86 C ABI. #5347
This Adds a bunch of tests for passing and returning structs
of various sizes to C. It fixes the struct return rules on unix,
and on windows for structs of size > 8 bytes. Struct passing
on unix for structs under a certain size appears to still be broken.
2013-04-17 15:49:19 -07:00
Josh Matthews
97303703ee Allow casting to mutable trait objects. 2013-04-17 00:34:25 +02:00
bors
07e087bf31 auto merge of #5890 : youknowone/rust/const-eval, r=catamorphism
This will help not to meet confusing errors.
In issue #5873, the error was "expected constant expr for vector length: Can't cast str to int".
It was originally "expected constant expr for vector length: Non-constant path in constant expr" (though still invalid error).
This patch make the original error to be printed.
2013-04-16 12:48:56 -07:00
Tim Chevalier
39d45b75cc rustc: Anti-copy police 2013-04-15 19:06:36 -07:00
bors
4beebc427c auto merge of #5797 : alexcrichton/rust/issue-1913, r=catamorphism
Closes #5487, #1913, and #4568

I tracked this by adding all used unsafe blocks/functions to a set on the `tcx` passed around, and then when the lint pass comes around if an unsafe block/function isn't listed in that set, it's unused.

I also removed everything from the compiler that was unused, and up to stage2 is now compiling without any known unused unsafe blocks.

I chose `unused_unsafe` as the name of the lint attribute, but there may be a better name...
2013-04-15 13:00:56 -07:00
Jeong YunWon
9b55d86e74 Prevent eval_const_expr_partial hides prior error in expr_cast arm.
This will help not to meet confusing errors.
In issue #5873, the error was "expected constant expr for vector length: Can't cast str to int".
It was originally "expected constant expr for vector length: Non-constant path in constant expr"
This patch make the original error to be printed.
2013-04-16 04:13:37 +09:00
bors
3809a04bf7 auto merge of #5778 : jld/rust/reflect-abstract-enum, r=graydon
This takes care of one of the last remnants of assumptions about enum layout.  A type visitor is now passed a function to read a value's discriminant, then accesses fields by being passed a byte offset for each one.  The latter may not be fully general, despite the constraints imposed on representations by borrowed pointers, but works for any representations currently planned and is relatively simple.

Closes #5652.
2013-04-15 09:57:55 -07:00
Alex Crichton
72c24e20a9 rustc: remove unnecessary unsafe blocks/methods 2013-04-14 01:15:46 -04:00
Alex Crichton
4bfa3c6663 Add a lint mode for unused unsafe blocks/functions 2013-04-14 01:15:46 -04:00
Jyun-Yan You
4ad8ec351a fix index out of bounds error of x86_64 ABI 2013-04-13 15:04:30 +08:00
bors
76f6606a8c auto merge of #5827 : nikomatsakis/rust/issue-5656-change-meaning-of-borrowed-self, r=pcwalton
See #5656 for details.

r? @pcwalton
2013-04-12 15:14:24 -07:00
bors
63e2724cdb auto merge of #5809 : Aatch/rust/start-attr, r=thestinger
This implements #5158. Currently it takes the command line args and the crate map. Since it doesn't take a `main` function pointer, you can't actually start the runtime easily, but that seems to be a shim to allow the current `rust_start` function to call into main.

However, you can do an end-run round the io library and do this:

```rust
use core::libc::{write, c_int, c_void, size_t, STDOUT_FILENO};

#[start]
fn my_start(_argc:int, _argv: **u8, _crate_map: *u8) -> int {
    do str::as_buf("Hello World!\n") |s,len| {
        unsafe {
            write(STDOUT_FILENO, s as *c_void, len as size_t);
        }
    }
    return 0;
}
```

Which is the most basic "Hello World" you can do in rust without starting up the runtime (though that has quite a lot to do with the fact that `core::io` uses `@` everywhere...)
2013-04-12 02:34:02 -07:00
Niko Matsakis
49de82cdca Issue #5656: Make &self not mean "&'self self"
Fixes #5656.
Fixes #5541.
2013-04-10 17:32:02 -07:00
Erick Tryzelaar
419f6acf0e std: rename {read,emit}_field to {read,emit}_struct_field 2013-04-10 16:08:22 -07:00
Brian Leibig
10d930d51e Prevent debug info generation of zero-span nodes
If a node has a (0, 0) span, it was not in the source, so debug symbols should not be generated for it.
2013-04-10 12:45:54 -04:00
Brian Leibig
cf22d749eb Add debug info for bare_fn type 2013-04-10 12:45:53 -04:00
Brian Leibig
917d5ab34e Add debug info for vectors 2013-04-10 12:45:53 -04:00
Brian Leibig
3c08be9b48 Add debug info for boxes 2013-04-10 12:45:53 -04:00
bors
2c649830be auto merge of #5709 : jbclements/rust/miscellaneous-cleanup, r=jbclements
There's no unifying theme here; I'm just trying to clear a bunch of small commits: removing dead code, adding comments, renaming to an upper-case type, fixing one test case.
2013-04-10 09:43:01 -07:00
John Clements
48e7bda826 path -> Path 2013-04-10 09:15:04 -07:00
bors
ac9dc69bf3 auto merge of #5796 : nikomatsakis/rust/issue-5656-fix-map-iteration, r=nikomatsakis
Revert map.each to something which takes two parameters rather than a tuple.  The current setup iterates over `BaseIter<(&'self K, &'self V)>` where 'self is a lifetime declared *in the `each()` method*.  You can't place such a type in the impl declaration.  The compiler currently allows it, but this will not be legal under #5656 and I'm pretty sure it's not sound now.  It's too bad that maps can't implement `BaseIter` (at least not over a tuple as they do here) but I think it has to be this way for the time being.

r? @thestinger
2013-04-10 08:28:02 -07:00
Niko Matsakis
3322595e89 Reason about nested free variables that appear in a function
signature.  In a nutshell, the idea is to (1) report an error if, for
a region pointer `'a T`, the lifetime `'a` is longer than any
lifetimes that appear in `T` (in other words, if a borrowed pointer
outlives any portion of its contents) and then (2) use this to assume
that in a function like `fn(self: &'a &'b T)`, the relationship `'a <=
'b` holds. This is needed for #5656.  Fixes #5728.
2013-04-10 07:52:46 -07:00
Niko Matsakis
5606fc0c90 Revert map.each to something which takes two parameters
rather than a tuple.  The current setup iterates over
`BaseIter<(&'self K, &'self V)>` where 'self is a lifetime declared
*in the each method*.  You can't place such a type in
the impl declaration.  The compiler currently allows it,
but this will not be legal under #5656 and I'm pretty sure
it's not sound now.
2013-04-10 07:51:48 -07:00
Huon Wilson
cad226025b librustc: implement a #[packed] attribute for structs.
A struct (inc. tuple struct) can be annotated with #[packed], so that there
is no padding between its elements, like GCC's `__attribute__((packed))`.

Closes #1704
2013-04-10 23:39:20 +10:00
bors
6100bb5cba auto merge of #5804 : alexcrichton/rust/issue-3266, r=graydon
This leaves the default lint modes at `warn`, but now the unused variable and dead assignment warnings are configurable on a per-item basis. As described in #3266, this just involved carrying around a couple ids to pass over to `span_lint`. I personally would prefer to keep the `_` prefix as well.

This closes #3266.
2013-04-09 20:36:56 -07:00
James Miller
cd41ee2044 Add #[start] attribute to define a new entry point function 2013-04-10 10:43:46 +12:00
Niko Matsakis
e8cd29ba5e Apply comments from tjc 2013-04-09 12:33:18 -07:00
Alex Crichton
3e67085d7a Allow lint modes to be used on unused variables and dead assignments 2013-04-09 13:48:44 -04:00
Niko Matsakis
9963bd2413 Cleanup substitutions and treatment of generics around traits in a number of ways.
- In a TraitRef, use the self type consistently to refer to the Self type:
  - trait ref in `impl Trait<A,B,C> for S` has a self type of `S`.
  - trait ref in `A:Trait` has the self type `A`
  - trait ref associated with a trait decl has self type `Self`
  - trait ref associated with a supertype has self type `Self`
  - trait ref in an object type `@Trait` has no self type

- Rewrite `each_bound_traits_and_supertraits` to perform
  substitutions as it goes, and thus yield a series of trait refs
  that are always in the same 'namespace' as the type parameter
  bound given as input.  Before, we left this to the caller, but
  this doesn't work because the caller lacks adequare information
  to perform the type substitutions correctly.

- For provided methods, substitute the generics involved in the provided
  method correctly.

- Introduce TypeParameterDef, which tracks the bounds declared on a type
  parameter and brings them together with the def_id and (in the future)
  other information (maybe even the parameter's name!).

- Introduce Subst trait, which helps to cleanup a lot of the
  repetitive code involved with doing type substitution.

- Introduce Repr trait, which makes debug printouts far more convenient.

Fixes #4183.  Needed for #5656.
2013-04-09 08:06:10 -07:00
Jens Nockert
e06b9827ef Fix typo in u16 debug info 2013-04-08 23:59:00 +02:00
Jed Davis
e9a52f5af5 Make intrinsic::Opaque more opaque 2013-04-08 01:03:42 -07:00
Jed Davis
04b2c26f39 Make the enum visit callback generator more readable 2013-04-08 01:03:42 -07:00
Jed Davis
640e8ae4e5 Export adt::trans_get_discr abstractly to the type visitor. 2013-04-08 01:03:42 -07:00
Jed Davis
0ca1885da1 Feed enum field offsets to type vistors. 2013-04-08 01:03:42 -07:00
Niko Matsakis
fd8f56efab Link lifetimes of autoslice'd vectors (Issue #3184)
Fixes #5739.
2013-04-05 06:00:54 -04:00
Niko Matsakis
13801f60b2 rustc: Be careful about calls to fn types that contain nested errors 2013-04-05 05:36:03 -04:00
Niko Matsakis
d7163985b8 Add comment explaining method visibility 2013-04-05 05:36:03 -04:00
Niko Matsakis
2a44a1bd97 Fix various warnings, NOTEs, etc 2013-04-05 05:36:03 -04:00
Niko Matsakis
d28f734412 Refactor so that references to traits are not represented using a type with a
bare function store (which is not in fact a kind of value) but rather
ty::TraitRef.  Removes many uses of fail!() and other telltale signs of
type-semantic mismatch.

cc #4183 (not a fix, but related)
2013-04-05 05:36:02 -04:00
Niko Matsakis
3333b0f117 Add a (currently unused) "transformed self type" pointer into ty::method 2013-04-05 05:36:02 -04:00
Niko Matsakis
0a0525e366 Pass around a pointer to the ty::method rather than the individual bits of info 2013-04-05 05:36:02 -04:00
Niko Matsakis
569596573a Compute a ty::method for methods that appear in impls as well 2013-04-05 05:36:02 -04:00
Niko Matsakis
007abe9352 Rather than storing a list of ty::method per trait, store one ty::method
per method and list of def-ids per trait.
2013-04-05 05:36:02 -04:00
Niko Matsakis
d94830830f Move the replacement of bound regions out from check_arguments and into check_call / method_resolution 2013-04-05 05:36:02 -04:00
Niko Matsakis
1745a2cd08 refactor check_call_inner to have a better name and be readable 2013-04-05 05:36:02 -04:00
ILyoan
fac0d9d89b Decides main name by target 2013-04-04 10:44:48 +09:00
ILyoan
f06404860c Remove a android hack 2013-04-04 10:44:48 +09:00
Daniel Micay
cc148b58ff rename Linear{Map,Set} => Hash{Map,Set} 2013-04-03 10:30:36 -04:00
Daniel Micay
44029a5bbc hashmap: rm linear namespace 2013-04-03 10:30:18 -04:00
Brian Anderson
e3327d3833 Fix warnings 2013-03-31 20:22:47 -07:00