1. 12 2月, 2015 11 次提交
    • A
      rollup merge of #22167: kmcallister/undef-macro · 7362bd57
      Alex Crichton 提交于
      Fixes #21062.
      7362bd57
    • A
      rollup merge of #22164: huonw/alloc-- · 48767165
      Alex Crichton 提交于
      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.
      
      Thanks to @mahkoh for pointing it out.
      
      r? @steveklabnik
      48767165
    • A
      rollup merge of #22162: ogham/patch-1 · 5e2b69c1
      Alex Crichton 提交于
      It returns `false`, not `None`.
      5e2b69c1
    • A
      rollup merge of #22161: steveklabnik/close_2741 · 92e7aebf
      Alex Crichton 提交于
      Given that this is entirely internal, this enhancement isn't going to be needed. And if it is, we'll add it.
      
      Closes #2741.
      92e7aebf
    • A
      rollup merge of #22151: Gankro/macro-bench · fcf679cb
      Alex Crichton 提交于
      r? @alexcrichton
      fcf679cb
    • A
      rollup merge of #22150: nagisa/de-perm-frost · 18d31cc1
      Alex Crichton 提交于
      Fixes #22124
      18d31cc1
    • A
      rollup merge of #22127: alexcrichton/stability-holes · 84e5c117
      Alex Crichton 提交于
      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::imp::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
      84e5c117
    • A
      rollup merge of #22048: LeoTestard/impl-patterns-used · c9fdfdb2
      Alex Crichton 提交于
      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.
      c9fdfdb2
    • A
      rollup merge of #21881: richo/lint-no-mangle-const · 8b8331ad
      Alex Crichton 提交于
      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](https://github.com/rust-lang/rfcs/blob/cc53afbe5dea41e1f7d1c3dce71e013abe025211/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)
      8b8331ad
    • A
      rustc: Fix a number of stability lint holes · bbbb571f
      Alex Crichton 提交于
      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::imp::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]
      bbbb571f
    • B
      Auto merge of #21972 - pnkfelix:new-dtor-semantics-6, r=nikomatsakis · e29f4202
      bors 提交于
      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
      e29f4202
  2. 11 2月, 2015 29 次提交
    • B
      Auto merge of #22175 - pnkfelix:featuregate-boxpat-rfc469, r=nikomatsakis · 446bc899
      bors 提交于
      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`.
      446bc899
    • F
      Generalize all error messages with "experimental in alpha release" to · cdd8a5ad
      Felix S. Klock II 提交于
      just say "experimental."
      cdd8a5ad
    • F
      Added lifetime param to Arena. · 2c9d81b2
      Felix S. Klock II 提交于
      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.
      2c9d81b2
    • F
      compile-fail tests. · c1cda079
      Felix S. Klock II 提交于
      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.)
      c1cda079
    • F
      run-pass tests. · 4459a438
      Felix S. Klock II 提交于
      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.)
      4459a438
    • F
      address nit from niko's review. · d6c158d2
      Felix S. Klock II 提交于
      d6c158d2
    • F
      dropck: treat parametric types as safe for dropping. · f51176df
      Felix S. Klock II 提交于
      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.)
      f51176df
    • F
      Add core::marker::PhantomData. · f90c3864
      Felix S. Klock II 提交于
      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.
      f90c3864
    • F
      dbe08286
    • F
      ff56e376
    • F
      opt into box_patterns in debuginfo tests. · edabfe29
      Felix S. Klock II 提交于
      edabfe29
    • F
    • F
      Opt into new `box_patterns` feature gate in various crates. · e5ec43e2
      Felix S. Klock II 提交于
      Namely: `collections` (used in `dlist.rs`), `syntax`, `rustc`,
      `rustc_typeck`, `rustc_trans`, and `rustdoc`.
      e5ec43e2
    • F
      Add `box_patterns` feature gate. · 105f70b5
      Felix S. Klock II 提交于
      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]
      105f70b5
    • B
      Auto merge of #22169 - gfxmonk:disable-docs, r=steveklabnik · 1500df89
      bors 提交于
      `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
      1500df89
    • S
      Fail nicely when copying artefacts fails · a941fdb9
      Simonas Kazlauskas 提交于
      Fixes #22124
      a941fdb9
    • F
      destructor checker (dropck). · e02b6d17
      Felix S. Klock II 提交于
      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]
      e02b6d17
    • F
      Added DestructionScope variant to CodeExtent, representing the area · 81383bd8
      Felix S. Klock II 提交于
      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.
      81383bd8
    • F
      shift bindings to accommodate new lifetime/dtor rules. · bdb9f3e2
      Felix S. Klock II 提交于
      (My fix to for-loops (21984) did not deal with similar problems in
      if-let expressions, so those binding shifts stay.)
      bdb9f3e2
    • B
      Auto merge of #22163 - bleibig:grammar-updates, r=sanxiyn · 0047f8bb
      bors 提交于
      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`)
      0047f8bb
    • T
      docs: disable PDF docs when latex _isn't_ present · 2a367b93
      Tim Cuthbertson 提交于
      2a367b93
    • K
      Forbid undefined names in macro use / macro reexport · d4288717
      Keegan McAllister 提交于
      Fixes #21062.
      d4288717
    • B
      Auto merge of #22076 - carols10cents:exp2-calling-exp, r=huonw · 5936278e
      bors 提交于
      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.
      5936278e
    • H
      Tweak wording of copy_nonoverlapping_memory to remove misleading 'allocated'. · d8d37618
      Huon Wilson 提交于
      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.
      d8d37618
    • B
      3bca5f23
    • B
      03cc48c3
    • B
      Bison grammar: add qualified path expressions · 41d6513b
      Brian Leibig 提交于
      41d6513b
    • B
      Bison grammar: refactor index expressions to use ordinary expressions as... · ad6bb17a
      Brian Leibig 提交于
      Bison grammar: refactor index expressions to use ordinary expressions as indexes, remove index_expr and expr_norange
      ad6bb17a
    • B
      Auto merge of #22160 - dotdash:extern_rust, r=brson · 2067dd2a
      bors 提交于
      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
      2067dd2a