Commit Graph

38505 Commits

Author SHA1 Message Date
Alex Crichton
5e2b69c1b2 rollup merge of #22162: ogham/patch-1
It returns `false`, not `None`.
2015-02-11 14:02:11 -08:00
Alex Crichton
92e7aebf4b rollup merge of #22161: steveklabnik/close_2741
Given that this is entirely internal, this enhancement isn't going to be needed. And if it is, we'll add it.

Closes #2741.
2015-02-11 14:02:09 -08:00
Alex Crichton
fcf679cb88 rollup merge of #22151: Gankro/macro-bench
r? @alexcrichton
2015-02-11 14:02:08 -08:00
Alex Crichton
18d31cc14b rollup merge of #22150: nagisa/de-perm-frost
Fixes #22124
2015-02-11 14:02:06 -08:00
Alex Crichton
84e5c11785 rollup merge of #22127: alexcrichton/stability-holes
There are a number of holes that the stability lint did not previously cover,
including:

* Types
* Bounds on type parameters on functions and impls
* Where clauses
* Imports
* Patterns (structs and enums)

These holes have all been fixed by overriding the `visit_path` function on the
AST visitor instead of a few specialized cases. This change also necessitated a
few stability changes:

* The `collections::fmt` module is now stable (it was already supposed to be).
* The `thread_local:👿:Key` type is now stable (it was already supposed to
  be).
* The `std::rt::{begin_unwind, begin_unwind_fmt}` functions are now stable.
  These are required via the `panic!` macro.
* The `std::old_io::stdio::{println, println_args}` functions are now stable.
  These are required by the `print!` and `println!` macros.
* The `ops::{FnOnce, FnMut, Fn}` traits are now `#[stable]`. This is required to
  make bounds with these traits stable. Note that manual implementations of
  these traits are still gated by default, this stability only allows bounds
  such as `F: FnOnce()`.

Closes #8962
Closes #16360
Closes #20327
2015-02-11 14:02:04 -08:00
Alex Crichton
c9fdfdb2bb rollup merge of #22048: LeoTestard/impl-patterns-used
The live code analysis only visited the function's body when visiting a
method, and not the FnDecl and the generics, resulting in code to be
incorrectly marked as unused when it only appeared in the generics, the
arguments, or the return type, whereas the same code in non-method
functions was correctly detected as used. Fixes #20343.

Originally I just added a call to `walk_generics` and `walk_fndecl` alongside `walk_block` but then I noticed the `walk_method_helper` function did pretty much the same thing. The only difference is that it also calls `visit_mac`, but since this is not going to happen at this stage, I think it's ok. However let me know if this was not the right thing to do.
2015-02-11 14:02:02 -08:00
Alex Crichton
8b8331ad09 rollup merge of #21881: richo/lint-no-mangle-const
This renames the PrivateNoMangleFns lint to allow both to happen in a
single pass, since they do roughly the same work.

Closes #21856

Open questions:

[ ]: Do the tests actually pass (I'm running make check and running out the door now)
[ ]: Is the name of this lint ok. it seems to mostly be fine with [convention](cc53afbe5d/text/0344-conventions-galore.md (lints))
[ ]: I'm not super thrilled about the warning text

r? @kmcallister (Shamelessly nominating because you were looking at my other ticket)
2015-02-11 14:02:00 -08:00
Alex Crichton
a828e79480 std: Tweak the std::env OsString/String interface
This commit tweaks the interface of the `std::env` module to make it more
ergonomic for common usage:

* `env::var` was renamed to `env::var_os`
* `env::var_string` was renamed to `env::var`
* `env::args` was renamed to `env::args_os`
* `env::args` was re-added as a panicking iterator over string values
* `env::vars` was renamed to `env::vars_os`
* `env::vars` was re-added as a panicking iterator over string values.

This should make common usage (e.g. unicode values everywhere) more ergonomic
as well as "the default". This is also a breaking change due to the differences
of what's yielded from each of these functions, but migration should be fairly
easy as the defaults operate over `String` which is a common type to use.

[breaking-change]
2015-02-11 13:46:35 -08:00
Alex Crichton
bbbb571fee rustc: Fix a number of stability lint holes
There are a number of holes that the stability lint did not previously cover,
including:

* Types
* Bounds on type parameters on functions and impls
* Where clauses
* Imports
* Patterns (structs and enums)

These holes have all been fixed by overriding the `visit_path` function on the
AST visitor instead of a few specialized cases. This change also necessitated a
few stability changes:

* The `collections::fmt` module is now stable (it was already supposed to be).
* The `thread_local:👿:Key` type is now stable (it was already supposed to
  be).
* The `std::rt::{begin_unwind, begin_unwind_fmt}` functions are now stable.
  These are required via the `panic!` macro.
* The `std::old_io::stdio::{println, println_args}` functions are now stable.
  These are required by the `print!` and `println!` macros.
* The `ops::{FnOnce, FnMut, Fn}` traits are now `#[stable]`. This is required to
  make bounds with these traits stable. Note that manual implementations of
  these traits are still gated by default, this stability only allows bounds
  such as `F: FnOnce()`.

Additionally, the compiler now has special logic to ignore its own generated
`__test` module for the `--test` harness in terms of stability.

Closes #8962
Closes #16360
Closes #20327

[breaking-change]
2015-02-11 12:14:59 -08:00
GuillaumeGomez
d4985accb7 Add read and write rights to group and other when creating file 2015-02-11 19:38:57 +01:00
bors
e29f420255 Auto merge of #21972 - pnkfelix:new-dtor-semantics-6, r=nikomatsakis
This is a resurrection and heavy revision/expansion of a PR that pcwalton did to resolve #8861.

The most relevant, user-visible semantic change is this: #[unsafe_destructor] is gone. Instead, if a type expression for some value has a destructor, then any lifetimes referenced within that type expression must strictly outlive the scope of the value.

See discussion on https://github.com/rust-lang/rfcs/pull/769
2015-02-11 17:59:37 +00:00
Simonas Kazlauskas
2f48651111 Revert #22051
This resulted in some very unexpected fallout such as empty llvm-ir, llvm-bc and asm in some cases.
See #22183 for related info.
2015-02-11 19:28:02 +02:00
Edward Wang
2af968eaa6 Eliminate assoc type projection predicate candidate duplicates
When projecting associate types for a trait's default methods, the
trait itself was added to the predicate candidate list twice: one from
parameter environment, the other from trait definition. Then the
duplicates were deemed as code ambiguity and the compiler rejected the
code. Simply checking and dropping the duplicates solves the issue.

Closes #22036
2015-02-12 01:12:57 +08:00
bors
446bc899b2 Auto merge of #22175 - pnkfelix:featuregate-boxpat-rfc469, r=nikomatsakis
Feature gate `box` patterns.

Note that this adds a new feature gate, `box_patterns` specific to e.g. `let box i = ...`, while leaving  `box` expressions (alone) still guarded via the preexisting `box_syntax`.
2015-02-11 15:00:35 +00:00
Felix S. Klock II
cdd8a5ad74 Generalize all error messages with "experimental in alpha release" to
just say "experimental."
2015-02-11 14:13:33 +01:00
Felix S. Klock II
f9a1087f27 Feature-gate the #[unsafe_no_drop_flag] attribute.
See RFC 320, "Non-zeroing dynamic drops."

Fix #22173

[breaking-change]
2015-02-11 13:57:40 +01:00
Felix S. Klock II
2c9d81b2d4 Added lifetime param to Arena.
It (1.) is invariant, (2.) must strictly outlive the arena itself,
(3.) constrains the inputs to the arena so that their borrows must
also strictly outlive the arena itself.

This implies that, for now, one can no longer have cross-references
between data allocated via the same `Arena` (even when the data is not
subject to the Drop Check rule).  Instead one must carry multiple
`Arena` instances, or (more commonly), use one or more `TypedArena`
instances with enums encoding the different variants of allocated
data.
2015-02-11 13:51:21 +01:00
Felix S. Klock II
c1cda0793e compile-fail tests.
Some compile-fail tests illustrated cases to be rejected by dropck,
including ones that check cyclic data cases designed to exposed bugs
if they are actually tricked into running by an unsound analysis.

E.g. these exposed bugs in earlier broken ways of handling `Vec<T>`.

(Note that all the uses of `unsafe_destructor` are just placating the
simple analysis used for that feature, which will eventually go away
once we have put the dropck through its paces.)
2015-02-11 13:51:21 +01:00
Felix S. Klock II
4459a438c2 run-pass tests.
includes regression tests discovered during bootstrapping and tests of
cyclic structure that currently pass and are expected to continue
passing under the dropck rule.

(Note that all the uses of `unsafe_destructor` are just placating the
simple analysis used for that feature, which will eventually go away
once we have put the dropck through its paces.)
2015-02-11 13:51:21 +01:00
Felix S. Klock II
d6c158d262 address nit from niko's review. 2015-02-11 13:51:21 +01:00
Felix S. Klock II
f51176df01 dropck: treat parametric types as safe for dropping.
Handles e.g. `impl<T> Drop for Vec<T>` as parametric: If `T` does not
have any drop code that could read from borrowed data of lifetime `'a`,
then we infer that the drop code for `Vec<T>` also cannot read from
borrowed data of lifetime `'a`, and therefore we do not need to inject
the SafeDestructor constraint for it.

Notably, this enables us to continue storing cyclic structure, without
any `unsafe` code, in `Vec`, without allowing (unsound) destructors on
such cyclic data. (Later commits have tests illustrating these two
cases in run-pass and compile-fail, respectively.)

(This is "Condition (B.)" in Drop-Check rule described in RFC 769.)
2015-02-11 13:51:21 +01:00
Felix S. Klock II
f90c3864b6 Add core::marker::PhantomData.
Port `core::ptr::Unique` to have `PhantomData`. Add `PhantomData` to
`TypedArena` and `Vec` as well.

As a drive-by, switch `ptr::Unique` from a tuple-struct to a struct
with fields.
2015-02-11 13:51:09 +01:00
Sébastien Marie
92b7222254 openbsd don't support TLS 2015-02-11 13:36:44 +01:00
Felix S. Klock II
dbe0828699 generalize error text to not focus on any particular release. 2015-02-11 12:01:57 +01:00
Felix S. Klock II
ff56e376f9 opt into box_patterns in the reference doc that uses them. 2015-02-11 11:47:14 +01:00
Felix S. Klock II
edabfe2912 opt into box_patterns in debuginfo tests. 2015-02-11 11:47:14 +01:00
Felix S. Klock II
23e9d7cbe4 Opt into box_patterns feature gate in all tests that use them. 2015-02-11 11:47:14 +01:00
Felix S. Klock II
e5ec43e217 Opt into new box_patterns feature gate in various crates.
Namely: `collections` (used in `dlist.rs`), `syntax`, `rustc`,
`rustc_typeck`, `rustc_trans`, and `rustdoc`.
2015-02-11 11:47:14 +01:00
Felix S. Klock II
105f70b500 Add box_patterns feature gate.
Switch feature-gate checker from `box_syntax` to `box_patterns` when
visiting a pattern.

(Having to opt into both `box_syntax` and `box_patterns` seemed
unnecessary.)

[breaking-change]
2015-02-11 11:47:05 +01:00
bors
1500df8934 Auto merge of #22169 - gfxmonk:disable-docs, r=steveklabnik
`make docs` fails when (xe)latex is not installed. The output is pretty weird, looks like it's doing some `eval` tricks but something is blank:

    /bin/sh: -output-directory=.: command not found
    /home/tim/dev/rust/rust/mk/docs.mk:220: recipe for target 'doc/reference.pdf' failed

I have neither latex or xelatex installed. It seems like the following snippet is meant for me, but the logic is backwards:

    ifeq ($(CFG_XELATEX),)
        CFG_LATEX := $(CFG_XELATEX)
        XELATEX = 1
      else
        $(info cfg: no xelatex found, disabling LaTeX docs)
        NO_PDF_DOCS = 1
    endif

I verified with:

    $ make doc/reference.pdf CFG_XELATEX=/bin/foo
    cfg: no xelatex found, disabling LaTeX docs
2015-02-11 08:54:30 +00:00
Simonas Kazlauskas
a941fdb98d Fail nicely when copying artefacts fails
Fixes #22124
2015-02-11 10:00:56 +02:00
Felix S. Klock II
e02b6d1748 destructor checker (dropck).
Largely adapted from pcwalton's original branch, with following
notable modifications:

Use `regionck::type_must_outlive` to generate `SafeDestructor`
constraints.  (this plugged some soundness holes in the analysis).

Avoid exponential time blowup on compile-fail/huge-struct.rs by
keeping the breadcrumbs until end of traversal.

Avoid premature return from regionck::visit_expr.

Factored drop-checking code out into dropck module.

Added `SafeDestructor` to enum `SubregionOrigin` (for error reporting).

----

Since this imposes restrictions on the lifetimes used in types with
destructors, this is a (wait for it)

[breaking-change]
2015-02-11 08:50:27 +01:00
Felix S. Klock II
81383bd869 Added DestructionScope variant to CodeExtent, representing the area
immediately surrounding a node that is a terminating_scope
(e.g. statements, looping forms) during which the destructors run (the
destructors for temporaries from the execution of that node, that is).

Introduced DestructionScopeData newtype wrapper around ast::NodeId, to
preserve invariant that FreeRegion and ScopeChain::BlockScope carry
destruction scopes (rather than arbitrary CodeExtents).

Insert DestructionScope and block Remainder into enclosing CodeExtents
hierarchy.

Add more doc for DestructionScope, complete with ASCII art.

Switch to constructing DestructionScope rather than Misc in a number
of places, mostly related to `ty::ReFree` creation, and use
destruction-scopes of node-ids at various calls to
liberate_late_bound_regions.

middle::resolve_lifetime: Map BlockScope to DestructionScope in `fn resolve_free_lifetime`.

Add the InnermostDeclaringBlock and InnermostEnclosingExpr enums that
are my attempt to clarify the region::Context structure, and that
later commmts build upon.

Improve the debug output for `CodeExtent` attached to `ty::Region::ReScope`.

Loosened an assertion in `rustc_trans::trans::cleanup` to account for
`DestructionScope`.  (Perhaps this should just be switched entirely
over to `DestructionScope`, rather than allowing for either `Misc` or
`DestructionScope`.)

----

Even though the DestructionScope is new, this particular commit should
not actually change the semantics of any current code.
2015-02-11 08:50:27 +01:00
Felix S. Klock II
bdb9f3e266 shift bindings to accommodate new lifetime/dtor rules.
(My fix to for-loops (21984) did not deal with similar problems in
if-let expressions, so those binding shifts stay.)
2015-02-11 08:50:27 +01:00
bors
0047f8bbd8 Auto merge of #22163 - bleibig:grammar-updates, r=sanxiyn
Updates to the bison grammar:

* Fixes to range syntax - allow `expr[..]`, and fix precedence to allow `for _ in i.. { }`
* Allow "extern crate" in stmts
* Add qualified path expressions (`<TYPE as TRAIT_REF>::item`)
2015-02-11 06:45:25 +00:00
Tim Cuthbertson
2a367b9330 docs: disable PDF docs when latex _isn't_ present 2015-02-11 17:16:37 +11:00
Keegan McAllister
d4288717c4 Forbid undefined names in macro use / macro reexport
Fixes #21062.
2015-02-10 19:36:31 -08:00
bors
5936278ed6 Auto merge of #22076 - carols10cents:exp2-calling-exp, r=huonw
I was working on adding examples to the documentation in `std::num::Float`. I got to `exp2`, which says "Returns 2 raised to the power of the number, `2^(self)`."

So I tried running this code:

```
use std::num::Float;

#[test]
fn test_exp2() {
    assert_eq!(32.0, 5.0.exp2());
}
```

and it resulted in a failure of `(left: `32`, right: `148.413159`)`. That 148.413159 is the value for e^5, which is `exp()`, not `exp2()`.

Sure enough, `exp2` is calling `exp` and shouldn't be, looks like a copy-paste error. 

I haven't added any tests for this since it's unlikely to break again, but I will happily do so if people think that would be a good idea. The doc examples are coming :)

I scanned through the other functions in these files for similar sorts of errors and didn't notice any.
2015-02-11 03:15:00 +00:00
Steve Klabnik
005a2506a6 Move rustc docs to the book
This is super black magic internals at the moment, but having it
somewhere semi-public seems good. The current versions weren't being
rendered, and they'll be useful for some people.

Fixes #21281
2015-02-10 22:02:53 -05:00
Huon Wilson
d8d3761899 Tweak wording of copy_nonoverlapping_memory to remove misleading 'allocated'.
It doesn't have to be a literal memory allocation (ala malloc), e.g. it
can be in static memory, so saying "allocated" is mildly misleading.
2015-02-11 13:58:11 +11:00
Brian Leibig
3bca5f23aa Bison grammar: fix precedence with ranges followed by blocks 2015-02-10 17:59:02 -08:00
Brian Leibig
03cc48c38d Bison grammar: refactor items to allow "extern crate" in stmts 2015-02-10 17:59:01 -08:00
Brian Leibig
41d6513b8f Bison grammar: add qualified path expressions 2015-02-10 17:59:01 -08:00
Brian Leibig
ad6bb17acf Bison grammar: refactor index expressions to use ordinary expressions as indexes, remove index_expr and expr_norange 2015-02-10 17:59:01 -08:00
bors
2067dd2a86 Auto merge of #22160 - dotdash:extern_rust, r=brson
As the function comment already says, the types generated in the
foreign_signture function don't necessarily match the types used for a
corresponding rust function. Therefore we can't just use these types to
guide the translation of the wrapper function that bridges between the
external ABI and the rust ABI. Instead, we can query LLVM about the
types used in the rust function and use those to generate an appropriate
wrapper.

Fixes #21454
2015-02-11 01:04:54 +00:00
Ben S
c324a8ace0 Documentation fix for PathBuf#pop
It returns `false`, not `none`.
2015-02-11 00:45:43 +00:00
Steve Klabnik
07f1d3d5d9 Remove FIXME in librbml
Given that this is entirely internal, this enhancement isn't going to be needed. And if it is, we'll add it.

Closes #2741.
2015-02-10 19:39:25 -05:00
Alfie John
bffbcb5729 Deprecating i/u suffixes in libcoretest 2015-02-10 22:56:31 +00:00
Björn Steinbrink
61db6923e2 Fix ICE when compiling "extern" rust functions
As the function comment already says, the types generated in the
foreign_signture function don't necessarily match the types used for a
corresponding rust function. Therefore we can't just use these types to
guide the translation of the wrapper function that bridges between the
external ABI and the rust ABI. Instead, we can query LLVM about the
types used in the rust function and use those to generate an appropriate
wrapper.

Fixes #21454
2015-02-10 23:43:38 +01:00
bors
a954663db6 Auto merge of #22089 - dotdash:llvm_20150207, r=alexcrichton
Fixes #21996
2015-02-10 22:08:30 +00:00