Commit Graph

66 Commits

Author SHA1 Message Date
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
Huon Wilson
28f0782260 librustc: use new [ty, .. len] syntax for fixed vector errors. 2013-04-06 13:27:27 +11: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
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
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
Niko Matsakis
6965fe4bce Add AbiSet and integrate it into the AST.
I believe this patch incorporates all expected syntax changes from extern
function reform (#3678). You can now write things like:

    extern "<abi>" fn foo(s: S) -> T { ... }
    extern "<abi>" mod { ... }
    extern "<abi>" fn(S) -> T

The ABI for foreign functions is taken from this syntax (rather than from an
annotation).  We support the full ABI specification I described on the mailing
list.  The correct ABI is chosen based on the target architecture.

Calls by pointer to C functions are not yet supported, and the Rust type of
crust fns is still *u8.
2013-03-29 18:36:20 -07:00
Alex Crichton
be57d745d2 Removing unused imports 2013-03-28 23:56:46 -04:00
Alex Crichton
dbe1354321 Move ast_map::map to LinearMap 2013-03-26 19:21:05 -04:00
Alex Crichton
6f812fef1b rustc: Remove uses of oldmap::HashMap 2013-03-26 19:21:04 -04:00
bors
b8899138f8 auto merge of #5466 : Kimundi/rust/view-slice-rename, r=bstrie
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()`
2013-03-21 07:06:54 -07:00
bors
0b4f2687ce auto merge of #5470 : sanxiyn/rust/remove-oldmap-2, r=sanxiyn
Referencing #4986.
2013-03-21 06:15:58 -07:00
Marvin Löbel
9d9a209e9a back-renamed slice_DBG_BRWD, slice_V_DBG_BRWD -> slice, slice_DBG_UNIQ -> slice_unique 2013-03-21 14:05:57 +01:00
Seo Sanghyeon
64d923f7dd Move the function to time passes to util 2013-03-21 18:50:02 +09:00
Marvin Löbel
a7d296f24c renamed str::view -> slice_DBG_BRWD
renamed str::slice -> slice_DBG_UNIQ
changed vec slice method -> to_owned()
renamed vec view method  -> slice_V_DBG_BRWD
2013-03-21 01:50:32 +01:00
Niko Matsakis
00f97b9fb0 Refactor the self-info so that the def-id is carried in ty_self()
and the fn_ctxt doesn't need any self_info field at all.

Step towards fixing `fn(&self)` (cc #4846) to have a distinct
lifetime.
2013-03-20 06:14:53 -04:00
Alex Crichton
3fac7cce8f rustc: Remove some bad copies throughout 2013-03-20 01:28:32 -04:00
Patrick Walton
c4db4faefa libsyntax: Stop parsing old lifetimes, except for the ones on data type declarations. 2013-03-18 17:21:15 -07:00
Patrick Walton
24a0de4e7f librustc: Separate out trait storage from evec/estr storage 2013-03-13 20:07:08 -07:00
Patrick Walton
d18f785457 librustc: Replace all uses of fn() with &fn(). rs=defun 2013-03-11 09:35:58 -07:00
Patrick Walton
4e3dbfe052 librustc: Remove structural record types from the compiler 2013-03-07 22:32:54 -08:00
Alex Crichton
dfb5c10dea Remove unused imports throughout src/ 2013-03-04 12:27:01 -05:00
Patrick Walton
97fd421319 librustc: Remove fn@, fn~, and fn& from librustc. rs=defun 2013-03-02 16:49:31 -08:00
Erick Tryzelaar
d2c4b6492d Merge remote-tracking branch 'remotes/origin/incoming' into incoming 2013-02-28 07:25:49 -08:00
Ben Striegel
43d43adf6b Turn old drop blocks into Drop traits 2013-02-27 19:14:19 -05:00
Erick Tryzelaar
7d0ec86c4a Merge remote-tracking branch 'remotes/origin/incoming' into incoming 2013-02-27 11:03:21 -08:00
Erick Tryzelaar
f14409c528 libsyntax: progress on making syntax::visit vecs_implicitly_copyable-free 2013-02-25 07:49:34 -08:00
oncemoreification
c4ef822dc7 Fix slice printing 2013-02-23 21:46:36 -08:00
oncemoreification
4ffff6697b Fix vector syntax in error messages 2013-02-22 02:19:41 -08:00
Erick Tryzelaar
68746cd4fb librustc: change driver::session::Session::str_of to return @~str 2013-02-19 10:11:05 -08:00
Luqman Aden
99b3c07b4e librustc: Get rid of move. 2013-02-15 02:49:55 -08:00
Niko Matsakis
a32498d846 Make ~fn non-copyable, make &fn copyable, split barefn/closure types,
correct handling of moves for struct-record update.

Part of #3678.  Fixes #2828, #3904, #4719.
2013-02-07 05:53:30 -08:00
Patrick Walton
801f3225b2 oldmap: use &K instead of K in find and get
This reverts commit a4250a96fd.

This is not the cause of the nonexhaustive-match failure.
2013-02-05 19:41:45 -08:00
Graydon Hoare
a4250a96fd Revert "oldmap: use &K instead of K in find and get"
This reverts commit 8e643525d4.
2013-02-05 14:30:53 -08:00
Daniel Micay
8e643525d4 oldmap: use &K instead of K in find and get 2013-02-03 23:30:56 -05:00
Daniel Micay
319eeb1c79 rename map -> oldmap and mark it as deprecated
LinearMap is quite a bit faster, and is fully owned/sendable without
requiring copies. The older std::map also doesn't use explicit self and
relies on mutable fields.
2013-02-03 15:55:10 -05:00
Niko Matsakis
0682ad0eb9 Finalize moves-based-on-type implementation.
Changes:

- Refactor move mode computation
- Removes move mode arguments, unary move, capture clauses
  (though they still parse for backwards compatibility)
- Simplify how moves are handled in trans
- Fix a number of illegal copies that cropped up
- Workaround for bug involving def-ids in params
  (see details below)

Future work (I'll open bugs for these...):

- Improve error messages for moves that are due
  to bindings
- Add support for moving owned content like a.b.c
  to borrow check, test in trans (but I think it'll
  "just work")
- Proper fix for def-ids in params

Def ids in params:

Move captures into a map instead of recomputing.

This is a workaround for a larger bug having to do with the def-ids associated
with ty_params, which are not always properly preserved when inlining.  I am
not sure of my preferred fix for the larger bug yet.  This current fix removes
the only code in trans that I know of which relies on ty_param def-ids, but
feels fragile.
2013-01-31 12:09:00 -08:00
Patrick Walton
2ea2628ca9 librustc: De-export back, lib, and util. rs=deexporting 2013-01-29 15:48:50 -08:00
Patrick Walton
eb4d39e1fe libstd: Remove "dual impls" from the language and enforce coherence rules. r=brson
"Dual impls" are impls that are both type implementations and trait
implementations. They can lead to ambiguity and so this patch removes them
from the language.

This also enforces coherence rules. Without this patch, records can implement
traits not defined in the current crate. This patch fixes this, and updates
all of rustc to adhere to the new enforcement. Most of this patch is fixing
rustc to obey the coherence rules, which involves converting a bunch of records
to structs.
2013-01-29 10:42:45 -08:00
Niko Matsakis
d4fd30c6ac Link the lifetimes of regions resulting from borrows of the
contents of other borrowed pointers to the lifetimes of the
borrowed value.  Fixes #3148.

r=catamorphism
2013-01-28 10:00:23 -08:00
ILyoan
ce85837557 remove unnecessary code 2013-01-24 19:03:49 +09:00
Tim Chevalier
9d672671e2 Make borrowck's notion of scopes consistent with trans's notion of scopes
This eliminates an ICE in trans where the scope for a particular
borrow was a statement ID, but the code in trans that does cleanups
wasn't finding the block with that scope. As per #3860

preserve looks at a node ID to see if it's for a statement -- if it
is, it uses the enclosing scope instead when updating the map that
trans looks at later.

I added a comment noting that this is not the best fix (since it may
cause boxes to be frozen for longer than necessary) and referring
to #3511.

r=nmatsakis
2013-01-22 15:59:45 -08:00
Tim Chevalier
01f26249bb rustc: Print out region errors involving a function scope properly 2013-01-20 19:51:33 -08:00
Tim Chevalier
96b4f43675 Handle region errors where the actual scope is a statement
Prevents a case of "unknown scope, this is a bug".

I judged this too small to review. Closes #4500
2013-01-19 17:06:36 -08:00
Graydon Hoare
84825ee310 librustc: Make the default sigil for block lambdas & instead of @. 2013-01-15 17:57:45 -08:00
Niko Matsakis
2b92962aa2 A collection of refactorings that I found it hard/tiresome to divide:
- Make `extern fn()` assignable to any closure type, rather than
  a subtype.
- Remove unused int_ty_set and float_ty_set
- Refactor variable unification and make it more DRY
- Do fn sub/lub/glb on the level of fn_sig
- Rename infer::to_str::ToStr to infer::to_str::InferStr
- Capitalize names of various types
- Correct hashing of FnMeta
- Convert various records-of-fns into structs-of-fns.  This is both
  eliminating use of deprecated features and more forwards compatible
  with fn reform.

r=pcwalton
2013-01-09 14:59:07 -08:00
Patrick Walton
2db3abddcd librustc: Make unqualified identifier searches terminate at the nearest module scope. r=tjc 2013-01-08 22:02:35 -08:00
Patrick Walton
44ab00ee37 Revert "librustc: Make unqualified identifier searches terminate at the nearest module scope. r=tjc"
This reverts commit a8d37af247.
2013-01-08 19:29:16 -08:00
Patrick Walton
a8d37af247 librustc: Make unqualified identifier searches terminate at the nearest module scope. r=tjc 2013-01-08 19:27:57 -08:00
Niko Matsakis
c3a74d87bd Implement GLB algorithm. (Issue #2263)
r=brson
2013-01-08 15:41:53 -08:00