1. 13 3月, 2014 1 次提交
  2. 12 3月, 2014 24 次提交
    • B
      auto merge of #12816 : michaelwoerister/rust/limited-debuginfo, r=alexcrichton · 18356675
      bors 提交于
      Fixes #12811 as described in the issue.
      18356675
    • B
      auto merge of #12807 : pnkfelix/rust/fsk-issue5121-fns-with-early-lifetime-params, r=pnkfelix · c2e51353
      bors 提交于
      Fix issue #5121: Add proper support for early/late distinction for lifetime bindings.
      
      There are some little refactoring cleanups as separate commits; the real meat that has the actual fix is in the final commit.
      
      The original author of the work was @nikomatsakis; I have reviewed it, revised it slightly, refactored it into these separate commits, and done some rebasing work.
      c2e51353
    • B
      auto merge of #12839 : alexcrichton/rust/fix-snap, r=huonw · 397abb72
      bors 提交于
      This test is blocking a snapshot. Apparently the snapshot bot doesn't print
      'limited-debuginfo::main()' but rather just 'main()'. Who knew?
      397abb72
    • F
      Add proper support for early/late distinction for lifetime bindings. · 742e4581
      Felix S. Klock II 提交于
      Uses newly added Vec::partition method to simplify resolve_lifetime.
      742e4581
    • F
      Changed lists of lifetimes in ast and ty to use Vec instead of OptVec. · 586b619c
      Felix S. Klock II 提交于
      There is a broader revision (that does this across the board) pending
      in #12675, but that is awaiting the arrival of more data (to decide
      whether to keep OptVec alive by using a non-Vec internally).
      
      For this code, the representation of lifetime lists needs to be the
      same in both ScopeChain and in the ast and ty structures.  So it
      seemed cleanest to just use `vec_ng::Vec`, now that it has a cheaper
      empty representation than the current `vec` code.
      586b619c
    • F
      28ebec51
    • F
    • A
      test: Relax a debuginfo test · 486a25a3
      Alex Crichton 提交于
      This test is blocking a snapshot. Apparently the snapshot bot doesn't print
      'limited-debuginfo::main()' but rather just 'main()'. Who knew?
      486a25a3
    • F
      460ca4f0
    • F
    • B
      auto merge of #12774 : alexcrichton/rust/proc-bounds, r=pcwalton · 8a32ee74
      bors 提交于
      This is needed to make progress on #10296 as the default bounds will no longer
      include Send. I believe that this was the originally intended syntax for procs,
      and it just hasn't been necessary up until now.
      8a32ee74
    • B
      auto merge of #12650 : huonw/rust/librand, r=alexcrichton · 0aa3b888
      bors 提交于
      Move std::rand to a separate rand crate
      
      This functionality is not super-core and so doesn't need to be included
      in std. It's possible that std may need rand (it does a little bit now,
      for io::test) in which case the functionality required could be moved to
      a secret hidden module and reexposed by librand.
      
      Unfortunately, using #[deprecated] here is hard: there's too much to
      mock to make it feasible, since we have to ensure that programs still
      typecheck to reach the linting phase.
      
      Also, deprecates/removes `rand::rng` (this time using `#[deprecated]`), since it's too easy to accidentally use inside a loop, making things very slow (have to read randomness from the OS and seed the RNG each time.)
      0aa3b888
    • A
      syntax: Add support for trait bounds on procs · 7b4ee5cc
      Alex Crichton 提交于
      This is needed to make progress on #10296 as the default bounds will no longer
      include Send. I believe that this was the originally intended syntax for procs,
      and it just hasn't been necessary up until now.
      7b4ee5cc
    • H
      rand: deprecate `rng`. · 689f1972
      Huon Wilson 提交于
      This should be called far less than it is because it does expensive OS
      interactions and seeding of the internal RNG, `task_rng` amortises this
      cost. The main problem is the name is so short and suggestive.
      
      The direct equivalent is `StdRng::new`, which does precisely the same
      thing.
      
      The deprecation will make migrating away from the function easier.
      689f1972
    • H
      Update users for the std::rand -> librand move. · 198caa87
      Huon Wilson 提交于
      198caa87
    • H
      Remove the dependence of std::io::test on rand. · 15e28984
      Huon Wilson 提交于
      This replaces it with a manual "task rng" using XorShift and a crappy
      seeding mechanism. Theoretically good enough for the purposes
      though (unique for tests).
      15e28984
    • H
      std: Move rand to librand. · 6fa4bbee
      Huon Wilson 提交于
      This functionality is not super-core and so doesn't need to be included
      in std. It's possible that std may need rand (it does a little bit now,
      for io::test) in which case the functionality required could be moved to
      a secret hidden module and reexposed by librand.
      
      Unfortunately, using #[deprecated] here is hard: there's too much to
      mock to make it feasible, since we have to ensure that programs still
      typecheck to reach the linting phase.
      6fa4bbee
    • B
      auto merge of #12783 : adrientetar/rust/more-docs, r=alexcrichton · 74bfa710
      bors 提交于
      - remove `node.js` dep., it has no effect as of #12747 (1)
      - switch between LaTeX compilers, some cleanups
      - CSS: fixup the print stylesheet, refactor highlighting code (2)
      
      (1): `prep.js` outputs its own HTML directives, which `pandoc` cannot recognize when converting the document into LaTeX (this is why the PDF docs have never been highlighted as of now).
      
      Note that if we were to add the `.rust` class to snippets, we could probably use pandoc's native highlighting capatibilities i.e. Kate ([here is](http://adrientetar.github.io/rust-tuts/tutorial/tutorial.pdf) an example of that).
      
      (2): the only real highlighting change is for lifetimes which are now brown instead of red, the rest is just refactor of twos shades of red that look the same.
      Also I made numbers highlighting for src in rustdoc a tint more clear so that it is less bothering.
      
      @alexcrichton, @huonw
      
      Closes #9873. Closes #12788.
      74bfa710
    • B
      auto merge of #12780 : zslayton/rust/json-nav, r=alexcrichton · 3bede9fd
      bors 提交于
      This is my first non-docs contribution to Rust, so please let me know what I can fix. I probably should've submitted this to the mailing list first for comments, but it didn't take too long to implement so I figured I'd just give it a shot.
      
      These changes are modeled loosely on the [JsonNode API](http://jackson.codehaus.org/1.7.9/javadoc/org/codehaus/jackson/JsonNode.html) provided by the [Jackson JSON processor](http://jackson.codehaus.org/).
      
      Many common use cases for parsing JSON involve pulling one or more fields out of an object, however deeply nested. At present, this requires writing a pyramid of match statements. The added methods in this PR aim to make this a more painless process.
      
      **Edited to reflect final implementation**
      
      Example JSON:
      ```json
      {
          "successful" : true,
          "status" : 200,
          "error" : null,
          "content" : {
              "vehicles" : [
                  {"make" : "Toyota", "model" : "Camry", "year" : 1997},
                  {"make" : "Honda", "model" : "Accord", "year" : 2003}
              ]
          }
      }
      ```
      
      Accessing "successful":
      ```rust
       let example_json : Json = from_str("...above json...").unwrap();
       let was_successful: Option<bool> = example_json.find(&~"successful").and_then(|j| j.as_boolean());
      ```
      
      Accessing "status":
      ```rust
       let example_json : Json = from_str("...above json...").unwrap();
       let status_code : Option<f64> = example_json.find(&~"status").and_then(|j| j.as_number());
      ```
      
      Accessing "vehicles":
      ```rust
       let example_json : Json = from_str("...above json...").unwrap();
       let vehicle_list: Option<List> = example_json.search(&~"vehicles").and_then(|j| j.as_list());
      ```
      
      Accessing "vehicles" with an explicit path:
      ```rust
       let example_json : Json = from_str("...above json...").unwrap();
       let vehicle_list: Option<List> = example_json.find_path(&[&~"content", &~"vehicles"]).and_then(|j| j.as_list());
      ```
      
      Accessing "error", which might be null or a string:
      ```rust
       let example_json : Json = from_str("...above json...").unwrap();
       let error: Option<Json> = example_json.find(&~"error");
       if error.is_null() { // This would be nicer as a match, I'm just illustrating the boolean test methods
          println!("Error is null, everything's fine.");
       } else if error.is_str(){
          println!("Something went wrong: {}", error.as_string().unwrap());
      }
      ```
      
      Some notes:
      * Macros would help to eliminate some of the repetitiveness of the implementation, but I couldn't use them due to #4621. (**Edit**: There is no longer repetitive impl. Methods were simplified to make them more composable.)
      * Would it be better to name methods after the Json enum type (e.g. `get_string`) or the associated Rust built-in? (e.g. `get_str`)
      * TreeMap requires its keys to be &~str. Because of this, all of the new methods required &~str for their parameters. I'm uncertain what the best approach to fixing this is: neither demanding an owned pointer nor allocating within the methods to appease TreeMap's find() seems desirable. If I were able to take &str, people could put together paths easily with `"foo.bar.baz".split('.').collect();` (**Edit**: Follow on investigation into making TreeMap able to search by Equiv would be worthwhile.)
      * At the moment, the `find_<sometype>` methods all find the first match for the provided key and attempt to return that value if it's of the specified type. This makes sense to me, but it's possible that users would interpret a call to `find_boolean("successful")` as looking for the first "successful" item that was a boolean rather than looking for the first "successful" and returning None if it isn't boolean. (**Edit**: No longer relevant.)
      
      I hope this is helpful. Any feedback is appreciated! 
      3bede9fd
    • M
      debuginfo: Improve commandline option handling for debuginfo (fixes #12811) · 3ea50f0e
      Michael Woerister 提交于
      The `-g` flag does not take an argument anymore while the argument to `--debuginfo` becomes mandatory. This change makes it possible again to run the compiler like this:
      
      `rustc -g ./file.rs`
      
      This did not work before because `./file.rs` was misinterpreted as the argument to `-g`. In order to get limited debuginfo, one now has to use `--debuginfo=1`.
      3ea50f0e
    • B
      auto merge of #12556 : alexcrichton/rust/weak-linkage, r=brson · 9f3ebd8f
      bors 提交于
      It is often convenient to have forms of weak linkage or other various types of
      linkage. Sadly, just using these flavors of linkage are not compatible with
      Rust's typesystem and how it considers some pointers to be non-null.
      
      As a compromise, this commit adds support for weak linkage to external symbols,
      but it requires that this is only placed on extern statics of type `*T`.
      Codegen-wise, we get translations like:
      
      ```rust
          // rust code
          extern {
              #[linkage = "extern_weak"]
              static foo: *i32;
          }
      
          // generated IR
          @foo = extern_weak global i32
          @_some_internal_symbol = internal global *i32 @foo
      ```
      
      All references to the rust value of `foo` then reference `_some_internal_symbol`
      instead of the symbol `_foo` itself. This allows us to guarantee that the
      address of `foo` will never be null while the value may sometimes be null.
      
      An example was implemented in `std::rt::thread` to determine if
      `__pthread_get_minstack()` is available at runtime, and a test is checked in to
      use it for a static value as well. Function pointers a little odd because you
      still need to transmute the pointer value to a function pointer, but it's
      thankfully better than not having this capability at all.
      
      Thanks to @bnoordhuis for the original patch, most of this work is still his!
      9f3ebd8f
    • A
    • A
      doc: auto-generate LaTeX includes · 7ec1eb8a
      Adrien Tétar 提交于
      7ec1eb8a
    • Z
      Added convenience methods and accompanying tests to the Json class. · 9e0cfa23
      zslayton 提交于
      Fixed some styling issues with trailing whitespace.
      
      - Removed redundant functions.
      - Renamed `get` to `find`
      - Renamed `get_path` to `find_path`
      - Renamed `find` to `search`
      - Changed as_object and as_list to return Object and List
        rather than the underlying implementation types
        of TreeMap<~str,Json> and ~[Json]
      - Refactored find_path to use a fold() instead of recursion
      
      Formatting fixes.
      
      Fixed spacing, deleted comment.
      
      Added convenience methods and accompanying tests to the Json class.
      
      Updated tests to expect less pointer indirection.
      9e0cfa23
  3. 11 3月, 2014 11 次提交
    • A
      rustc: Support various flavors of linkages · 699b33d0
      Alex Crichton 提交于
      It is often convenient to have forms of weak linkage or other various types of
      linkage. Sadly, just using these flavors of linkage are not compatible with
      Rust's typesystem and how it considers some pointers to be non-null.
      
      As a compromise, this commit adds support for weak linkage to external symbols,
      but it requires that this is only placed on extern statics of type `*T`.
      Codegen-wise, we get translations like:
      
          // rust code
          extern {
              #[linkage = "extern_weak"]
              static foo: *i32;
          }
      
          // generated IR
          @foo = extern_weak global i32
          @_some_internal_symbol = internal global *i32 @foo
      
      All references to the rust value of `foo` then reference `_some_internal_symbol`
      instead of the symbol `_foo` itself. This allows us to guarantee that the
      address of `foo` will never be null while the value may sometimes be null.
      
      An example was implemented in `std::rt::thread` to determine if
      `__pthread_get_minstack()` is available at runtime, and a test is checked in to
      use it for a static value as well. Function pointers a little odd because you
      still need to transmute the pointer value to a function pointer, but it's
      thankfully better than not having this capability at all.
      699b33d0
    • B
    • G
      fix a bug in shootout-reverse-complement, official tests should pass with it · 7956a11d
      Guillaume Pinot 提交于
      In the "reverse-complement" loop, if there is an odd number of element,
      we forget to complement the element in the middle.  For example, if the
      input is "ggg", the result before the fix is "CgC" instead of "CCC".
      
      This is because of this bug that the official shootout says that the rust
      version is in "Bad Output".  This commit should fix this error.
      7956a11d
    • B
      auto merge of #12617 : sfackler/rust/item-modifier, r=alexcrichton · b3896155
      bors 提交于
      Where ItemDecorator creates new items given a single item, ItemModifier
      alters the tagged item in place. The expansion rules for this are a bit
      weird, but I think are the most reasonable option available.
      
      When an item is expanded, all ItemModifier attributes are stripped from
      it and the item is folded through all ItemModifiers. At that point, the
      process repeats until there are no ItemModifiers in the new item.
      
      cc @huonw
      b3896155
    • S
      Add an ItemModifier syntax extension type · eb4cbd55
      Steven Fackler 提交于
      Where ItemDecorator creates new items given a single item, ItemModifier
      alters the tagged item in place. The expansion rules for this are a bit
      weird, but I think are the most reasonable option available.
      
      When an item is expanded, all ItemModifier attributes are stripped from
      it and the item is folded through all ItemModifiers. At that point, the
      process repeats until there are no ItemModifiers in the new item.
      eb4cbd55
    • B
      auto merge of #12793 : brson/rust/installer, r=alexcrichton · b63cd004
      bors 提交于
      Work towards #9876.
      
      Several minor things here:
        * Fix the `need_ok` function in `configure`
        * Install man pages with non-executable permissions
        * Use the correct directory for man pages when installing (this was a recent regression)
        * Put all distributables in a new `dist/` directory in the build directory (there are soon to be significantly more of these)
      
      Finally, this also creates a new, more precise way to install and uninstall Rust's files, the `install.sh` script, and creates a build target (currently `dist-tar-bins`) that creates a binary tarball containing all the installable files, boilerplate and license docs, and `install.sh`.
      
      This binary tarball is the lowest-common denominator way to install Rust on Unix. We'll use it as the default installer on Linux (OS X will use .pkg).
      
      ## How `install.sh` works
      
      * First, the makefiles (`prepare.mk` and `dist.mk`) put all the stuff that needs to be installed in a new directory in `dist/`.
      * Then it puts `install.sh` in that same directory and a list of all the files to install at `rustlib/manifest`.
      * Then the directory can be packaged and distributed.
      * When `install.sh` runs it does some sanity checking then copies everything in the manifest to the install prefix, then copies the manifest as well.
      * When `install.sh` runs again in the future it first looks for the existing manifest at the install prefix, and if it exists deletes everything in it. This is how the core distribution is upgraded - cargo is responsible for the rest.
      * `install.sh --uninstall` will uninstall Rust
      
      ## Future work:
      
        * Modify `install.sh` to accept `--man-dir` etc
        * Rewrite `install.mk` to delegate to `install.sh`
        * Investigate how `install.sh` does or doesn't work with .pkg on Mac
        * Modify `dist.mk` to create `.pkg` files for all hosts
        * Possibly use [makeself](http://www.megastep.org/makeself/) to create self-extracting installers
        * Modify dist-snap bots run on mac as well, uploading binary tarballs and .pkg files for the four combos of linux, mac, x86, and x86_64.
        * Adjust build system to be able to augment versions with '-nightly'
        * Adjust build system to name dist artifacts without version numbers e.g. `rust-nightly-...pkg`. This is so we don't leave a huge trail of old nightly binaries on S3 - they just get overwritten.
        * Create new dist-nightly builder
        * Give the build master a new cron job to push to dist-nightly every night
        * Add docs to distributables
        * Update README.md to reflect the new reality
        * Modernize the website to promote new installers
      
      b63cd004
    • B
    • B
      auto merge of #12652 : rcxdude/rust/hexfloatext, r=alexcrichton · dd3e9d74
      bors 提交于
      Closes #1433. Implemented after suggestion by @cmr in #12323
      
      This is slightly less flexible than the implementation in #12323 (binary and octal floats aren't supported, nor are underscores in the literal), but is cleaner in that it doesn't modify the core grammar, or require odd syntax for the number itself. The missing features could be added back with relatively little effort (the main awkwardness is parsing the string. Is there a good approach for this in the stdlib currently?)
      dd3e9d74
    • D
      Implement hexadecimal floating point literals via a syntax extension · a38e1487
      Douglas Young 提交于
      closes #1433
      a38e1487
    • B
      auto merge of #12733 : edwardw/rust/rw-liveness, r=nikomatsakis · cad7d24a
      bors 提交于
      - Repurposes `MoveData.assignee_ids` to mean only `=` but not `+=`, so
        that borrowck effectively classifies all expressions into assignees,
        uses or both.
      - Removes two `span_err` in liveness analysis, which are now borrowck's
        responsibilities.
          
      Closes #12527.
      cad7d24a
    • B
      auto merge of #12670 : dmski/rust/master, r=nick29581 · d75a6ab5
      bors 提交于
      CodeMap.span_to_* perform a lookup of a BytePos(sp.hi), which lands into the next filemap if the last byte of range denoted by Span is also the last byte of the filemap, which results in ICEs or incorrect error reports.
      
              Example:
                  ````
      
                  pub fn main() {
                      let mut num = 3;
                      let refe = &mut num;
                      *refe = 5;
                      println!("{}", num);
                  }````
      
      (note the empty line in the beginning and the absence of newline at the end)
      
      The above would have caused ICE when trying to report where "refe" borrow ends.
      The above without an empty line in the beginning would have reported borrow end to be the first line.
      
      Most probably, this is also responsible for (at least some occurrences of) issue #8256.
      
      The issue is fixed by always adding a newline at the end of non-empty filemaps in case there isn't a new line there already.
      d75a6ab5
  4. 10 3月, 2014 4 次提交
    • D
      syntax: fixed ICEs and incorrect line nums when reporting Spans at the end of the file. · 43a8f7b3
      Dmitry Promsky 提交于
      CodeMap.span_to_* perform a lookup of a BytePos(sp.hi), which lands into the next filemap if the last byte of range denoted by Span is also the last byte of the filemap, which results in ICEs or incorrect error reports.
      
          Example:
              ````
      
              pub fn main() {
                  let mut num = 3;
                  let refe = &mut num;
                  *refe = 5;
                  println!("{}", num);
              }````
      
      (note the empty line in the beginning and the absence of newline at the end)
      
      The above would have caused ICE when trying to report where "refe" borrow ends.
      The above without an empty line in the beginning would have reported borrow end to be the first line.
      
      Most probably, this is also responsible for (at least some occurrences of) issue #8256.
      
      The issue is fixed by always adding a newline at the end of non-empty filemaps in case there isn't a new line there already.
      43a8f7b3
    • B
      install.sh: untabify · 95238090
      Brian Anderson 提交于
      95238090
    • B
      install.sh: Improve error handling · 1f7de380
      Brian Anderson 提交于
      1f7de380
    • B
      mk: Put all distribution artifacts in dist/ · 364d4ad1
      Brian Anderson 提交于
      Also, add license docs to installers
      364d4ad1