Commit Graph

4943 Commits

Author SHA1 Message Date
Tom Jakubowski
ec70f2bb6e rustdoc: Add an --extern flag analagous to rustc's
This adds an `--extern` flag to `rustdoc` much like the compiler's to
specify the path where a given crate can be found.
2014-07-21 09:54:29 -07:00
Brian Anderson
97ca98f5cc Address review feedback 2014-07-21 09:54:27 -07:00
Brian Anderson
ec0f1cb709 rustc: Allow the crate linked to as 'std' to be customized
This adds the alt_std_name field to the Session's Options type.
I'm using this in an external tool to control which libraries
a crate links to.
2014-07-21 09:54:27 -07:00
Brian Anderson
c88bf10c37 rustc: Pass optional additional plugins to compile_input
This provides a way for clients of the rustc library to add
their own features to the pipeline.
2014-07-21 09:54:26 -07:00
Brian Anderson
1c3655bed1 rustc: Extract --crate-type parsing to its own function
Helpful for users of rustc as a library.
2014-07-21 09:54:26 -07:00
Brian Anderson
9631bf2e25 rustc: Make monitor public.
It's harder to run rustc correctly without it.
2014-07-21 09:54:26 -07:00
John Clements
1607064cfe repair macro docs
In f1ad425199, I changed the handling
of macros, to prevent macro invocations from occurring in fully expanded
source. Instead, I added a side table. It contained only the
spans of the macros, because this was the only information required
in order to make macro export work.

However, librustdoc was also affected by this change, since it
extracts macro information in a similar way. As a result of the earlier
change, exported macros were no longer documented.

In order to repair this, I've adjusted the side table to contain whole
items, rather than just the spans.
2014-07-21 09:54:07 -07:00
Jakub Wieczorek
4b9bc2e8f2 Implement new mod import sugar
Implements RFC #168.
2014-07-20 12:40:08 +02:00
bors
50481f5503 auto merge of #15784 : dotdash/rust/unreach, r=luqmana
`call_visit_glue` is only ever called from trans_intrinsic, and the
block won't be unreachable there. Also, the comment doesn't make sense
anymore. When the code was introduced in 38fee9526a the function was
also responsible for the cleanup glue, which is no longer the case.

While we're at it, also fixed the debug message to output the right
function name.
2014-07-20 07:51:32 +00:00
bors
56fafe28ee auto merge of #15767 : pcwalton/rust/lifetime-elision, r=nick29581
This implements RFC 39. Omitted lifetimes in return values will now be
inferred to more useful defaults, and an error is reported if a lifetime
in a return type is omitted and one of the two lifetime elision rules
does not specify what it should be.

This primarily breaks two uncommon code patterns. The first is this:

    unsafe fn get_foo_out_of_thin_air() -> &Foo {
        ...
    }

This should be changed to:

    unsafe fn get_foo_out_of_thin_air() -> &'static Foo {
        ...
    }

The second pattern that needs to be changed is this:

    enum MaybeBorrowed<'a> {
        Borrowed(&'a str),
        Owned(String),
    }

    fn foo() -> MaybeBorrowed {
        Owned(format!("hello world"))
    }

Change code like this to:

    enum MaybeBorrowed<'a> {
        Borrowed(&'a str),
        Owned(String),
    }

    fn foo() -> MaybeBorrowed<'static> {
        Owned(format!("hello world"))
    }

Closes #15552.

[breaking-change]

r? @nick29581
2014-07-20 02:46:34 +00:00
bors
8672a235dd auto merge of #15650 : jakub-/rust/patterns-statics, r=pcwalton
This is accomplished by rewriting static expressions into equivalent patterns.
This way, patterns referencing static variables can both participate
in exhaustiveness analysis as well as be compiled down into the appropriate
branch of the decision trees that match expressions are codegened to.

Fixes #6533.
Fixes #13626.
Fixes #13731.
Fixes #14576.
Fixes #15393.
2014-07-19 21:46:37 +00:00
Patrick Walton
6f99a27886 librustc: Implement lifetime elision.
This implements RFC 39. Omitted lifetimes in return values will now be
inferred to more useful defaults, and an error is reported if a lifetime
in a return type is omitted and one of the two lifetime elision rules
does not specify what it should be.

This primarily breaks two uncommon code patterns. The first is this:

    unsafe fn get_foo_out_of_thin_air() -> &Foo {
        ...
    }

This should be changed to:

    unsafe fn get_foo_out_of_thin_air() -> &'static Foo {
        ...
    }

The second pattern that needs to be changed is this:

    enum MaybeBorrowed<'a> {
        Borrowed(&'a str),
        Owned(String),
    }

    fn foo() -> MaybeBorrowed {
        Owned(format!("hello world"))
    }

Change code like this to:

    enum MaybeBorrowed<'a> {
        Borrowed(&'a str),
        Owned(String),
    }

    fn foo() -> MaybeBorrowed<'static> {
        Owned(format!("hello world"))
    }

Closes #15552.

[breaking-change]
2014-07-19 13:10:58 -07:00
bors
e0a6e2b414 auto merge of #15765 : luqmana/rust/iec, r=pcwalton
Fixes #15400.
2014-07-19 12:26:39 +00:00
bors
f05a2c97b8 auto merge of #15754 : jakub-/rust/diagnostics, r=alexcrichton 2014-07-19 08:51:34 +00:00
bors
44a71dee37 auto merge of #15686 : alexcrichton/rust/same-crate-name, r=kballard
The first is to require that `#[crate_name]` and `--crate-name` always match (if both are specified). The second is to fix parallel compilation in cargo by mixing in `-C extra-filename` into the temporary outputs of the compiler.
2014-07-19 03:11:34 +00:00
Alex Crichton
82fb85a152 rustc: Mix extra-filename in temp outputs
When invoking the compiler in parallel, the intermediate output of the object
files and bytecode can stomp over one another if two crates with the same name
are being compiled.

The output file is already being disambiguated with `-C extra-filename`, so this
commit alters the naming of the temporary files to also mix in the extra
filename to ensure that file names don't clash.
2014-07-18 18:09:08 -07:00
Jakub Wieczorek
fba1194841 Add support for patterns referencing non-trivial statics
This is accomplished by rewriting static expressions into equivalent patterns.
This way, patterns referencing static variables can both participate
in exhaustiveness analysis as well as be compiled down into the appropriate
branch of the decision trees that match expressions are codegened to.

Fixes #6533.
Fixes #13626.
Fixes #13731.
Fixes #14576.
Fixes #15393.
2014-07-19 01:09:22 +02:00
Björn Steinbrink
d368ffdb26 Remove the unneeded final parameter from call_visit_glue
call_visit_glue() is only ever called with None as its last argument, so
we can remove it as well.
2014-07-18 21:56:36 +02:00
Luqman Aden
ad27e2625a librustc: Set enum discriminant only after field translation. 2014-07-18 11:58:45 -07:00
Luqman Aden
27748b09d8 librustc: Only emit constructor functions as necessary. 2014-07-18 11:58:45 -07:00
Luqman Aden
06bf73a646 librustc: Emit tuple struct constructor at callsite instead of via a call to a function. 2014-07-18 11:46:03 -07:00
Luqman Aden
cb404dd4fb librustc: Emit enum variant constructor at callsite instead of via a call to a function. 2014-07-18 11:46:03 -07:00
bors
7502b4cd6b auto merge of #15742 : pnkfelix/rust/fsk-fix-15019, r=pcwalton
Removed `index_to_bitset` field and `_frozen` methods.

Drive-by: Added some missing docs on the `each_bit` method.

Drive-by: Put in a regular pattern: when calling `compute_id_range`, ensure `words_per_id > 0` by either asserting it or checking and returning early.  (The prior code did the latter in a few cases where necessary, but debugging is much aided by the asserts.)

Fix #15019.
2014-07-18 18:26:34 +00:00
Jakub Wieczorek
5274e997ab Assign more diagnostic codes 2014-07-18 20:13:19 +02:00
Björn Steinbrink
33a4dd824f Remove outdated unreachable check from call_visit_glue
`call_visit_glue` is only ever called from trans_intrinsic, and the
block won't be unreachable there. Also, the comment doesn't make sense
anymore. When the code was introduced in 38fee9526a the function was
also responsible for the cleanup glue, which is no longer the case.

While we're at it, also fixed the debug message to output the right
function name.
2014-07-18 18:16:18 +02:00
Patrick Walton
02adaca4dc librustc: Implement unboxed closures with mutable receivers 2014-07-18 09:01:37 -07:00
Alex Crichton
50868db351 rustc: #[crate_name] and --crate-name must match
Part of the original discussions around the `--crate-name` flag brought up that
mass confusion can arise when the flag specifies a different name than is
contained in the crate.

The current primary use case of the `--crate-name` flag is through cargo and
not requiring a `#[crate_name]` attribute, but if the `#[crate_name]` attribute
is specified it will likely go awry when the two names deviate from one another.
This commit requires that if both are provided they both match to prevent this
confusion.
2014-07-18 08:47:23 -07:00
bors
5ddc7b4a25 auto merge of #15737 : huonw/rust/lint-level-here, r=pnkfelix
This allows lint traversals to emit more information (when a lint is
non-allow), or avoid doing expensive computations (when a lint is
allow).
2014-07-18 13:31:22 +00:00
bors
4418664177 auto merge of #15733 : sanxiyn/rust/use-from-type, r=alexcrichton
Importing from types was disallowed in #6462. Flag was set for paths whether it is a module or a type. Type flag was set when impl was seen. The problem is, for cross-crate situations, when reexport is involved, it is possible that impl is seen too late because metadata is loaded lazily.

Fix #15664.
2014-07-18 11:51:20 +00:00
Felix S. Klock II
8f50428432 Removed the _frozen methods from dataflow API.
Calls to methods like `each_bit_on_entry_frozen` and
`each_gen_bit_frozen` now go to the `each_bit_on_entry` and
`each_gen_bit` methods.
2014-07-18 13:48:53 +02:00
Felix S. Klock II
fc4f6eda96 Removed index_to_bitset from the dataflow context.
Part of addressing 15019.
2014-07-18 13:48:06 +02:00
bors
8067d03679 auto merge of #15726 : aturon/rust/macro-stability, r=alexcrichton
This small patch causes the stability lint to bail out when traversing
any AST produced via a macro expansion. Ultimately, we would like to
lint the contents of the macro at the place where the macro is defined,
but regardless we should not be linting it at the use site.

Closes #15703
2014-07-18 06:11:24 +00:00
bors
8a308b167f auto merge of #15725 : aochagavia/rust/vec, r=alexcrichton
* Deprecated `to_owned` in favor of `to_vec`
* Deprecated `into_owned` in favor of `into_vec`

[breaking-change]
2014-07-18 03:46:23 +00:00
bors
f50e4ee559 auto merge of #15719 : michaelwoerister/rust/global_var_null_span_fix, r=alexcrichton
This should fix issue #15541. It would be good to have an test case for this would also be nice but I haven't had the time to write one. The change is very small though and it doesn't break anything in the existing test suite, so I guess we can add it without test for now.
2014-07-18 00:01:22 +00:00
Patrick Walton
de70d76373 librustc: Remove cross-borrowing of Box<T> to &T from the language,
except where trait objects are involved.

Part of issue #15349, though I'm leaving it open for trait objects.
Cross borrowing for trait objects remains because it is needed until we
have DST.

This will break code like:

    fn foo(x: &int) { ... }

    let a = box 3i;
    foo(a);

Change this code to:

    fn foo(x: &int) { ... }

    let a = box 3i;
    foo(&*a);

[breaking-change]
2014-07-17 14:05:36 -07:00
Adolfo Ochagavía
8107ef77f0 Rename functions in the CloneableVector trait
* Deprecated `to_owned` in favor of `to_vec`
* Deprecated `into_owned` in favor of `into_vec`

[breaking-change]
2014-07-17 16:35:48 +02:00
bors
dd348b3ab0 auto merge of #15698 : Zoxc/rust/code-model, r=alexcrichton
The default code model is usually unsuitable for kernels,
so we add an option to specify which model we want.

Testing for this would be fragile and very architecture specific and is better left to LLVM.
2014-07-17 12:11:19 +00:00
Huon Wilson
46a3314943 lint: add method to get level of a specific lint.
This allows lint traversals to emit more information (when a lint is
non-allow), or avoid doing expensive computations (when a lint is
allow).
2014-07-17 20:07:43 +10:00
Seo Sanghyeon
99bd9265d9 Disallow importing from types when reexport is involved 2014-07-17 13:50:54 +09:00
Patrick Walton
357d5cd96c librustc: Implement the fully-expanded, UFCS form of explicit self.
This makes two changes to region inference: (1) it allows region
inference to relate early-bound regions; and (2) it allows regions to be
related before variance runs. The former is needed because there is no
relation between the two regions before region substitution happens,
while the latter is needed because type collection has to run before
variance. We assume that, before variance is inferred, that lifetimes
are invariant. This is a conservative overapproximation.

This relates to #13885. This does not remove `~self` from the language
yet, however.

[breaking-change]
2014-07-16 20:01:52 -07:00
bors
d3adccda4e auto merge of #15696 : Zoxc/rust/redzone, r=alexcrichton
Disabling the redzone is required in x86-64's kernel mode to avoid interrupts trashing the stack.

I'm not sure if decl_fn is the right place to tag all functions with noredzone. It might have interactions with external functions when linking with bitcode built without -C no-redzone although I see no reason to do that.

I'm not sure how to write a test inspecting the bitcode output for noredzone attributes on all functions either.
2014-07-16 21:46:21 +00:00
Aaron Turon
81b69d1538 stability lint: ignore code from macro expansion
This small patch causes the stability lint to bail out when traversing
any AST produced via a macro expansion. Ultimately, we would like to
lint the contents of the macro at the place where the macro is defined,
but regardless we should not be linting it at the use site.

Closes #15703
2014-07-16 13:53:06 -07:00
John Kåre Alsaker
036b9e8e3e Add an option to disable the use of the redzone
Disabling the redzone is required in x86-64's kernel mode to avoid interrupts trashing the stack.
2014-07-16 13:35:50 +02:00
bors
efbbb51ec0 auto merge of #15691 : jbclements/rust/method-field-cleanup, r=alexcrichton
This patch applies the excellent suggestion of @pnkfelix to group the helper methods for method field access into a Trait, making the code much more readable, and much more similar to the way it was before.
2014-07-16 10:26:16 +00:00
Michael Woerister
731f44de45 debuginfo: Don't crash when encountering global variable with unknown source span. 2014-07-16 11:32:54 +02:00
bors
6c35d513ce auto merge of #15656 : nick29581/rust/index-bck, r=pnkfelix
Closes #15525

The important bit of this are the changes from line 445 in mem_categorization.rs. Most of the other changes are about adding an Implicit PointerKind, and this is only necessary for getting a decent error message :-s An alternative would have been to add an implciti/explicit flag to cat_deref, which could be mostly ignored and so would mean much fewer changes. However, the implicit state would only be valid if the PointerKind was BorrowedPtr, so it felt like it ought to be another kind of PointerKind. I still don't know which is the better design.
2014-07-16 04:31:12 +00:00
Ben Gamari
d2c38aa6eb middle::typeck::collect: Add debug output for lifetimes 2014-07-15 19:34:42 -04:00
Ben Gamari
6867d91d20 middle::kind: Don't crash when checking safety of Drop
To verify that a type can satisfy Send
`check_struct_safe_for_destructor` attempts to construct a new `ty::t`
an empty substitution list.

Previously the function would verify that the function has no type
parameters before attempting this. Unfortunately this check would not
catch functions with only regions parameters. In this case, the type
would eventually find its way to the substition engine which would
attempt to perform a substitution on the region parameters. As the
constructed substitution list is empty, this would fail, leading to a
compiler crash.

We fix this by verifying that types have both no type and region
parameters.
2014-07-15 19:34:42 -04:00
Ben Gamari
c6c1a22c56 middle::subst: Better handling of parameter lookup failure 2014-07-15 19:34:41 -04:00
Ben Gamari
741bb1a57e typeck::check::_match: Better error handling
Previously this was an Option::unwrap() which failed for me.
Unfortunately I've since inadvertently worked around the bug and have
been unable to reproduce it. With this patch hopefully the next person
to encounter this will be in a slightly better position to debug it.
2014-07-15 19:34:41 -04:00