Commit Graph

30767 Commits

Author SHA1 Message Date
Kevin Butler
11b093425d liburl: Simplify encoding/decoding using iterators. 2014-07-04 01:30:45 +01:00
Kevin Butler
ed47c479d7 liburl: remove redundant fields in Url.
url.path - Now a Path instead of a String.

To fix old code:
url.path => url.path.path
url.query => url.path.query
url.fragment => url.path.fragment

Not much point having the Path struct if it's not going to be used.

[breaking-change]
2014-07-04 01:28:20 +01:00
Kevin Butler
a9e82e145e liburl: rename and move path_from_str to Path::parse_str.
url::path_from_str => url::Path::parse_str

The FromStr trait still works, but its confusing to have a path_from_str
free function that retuns a Result, while the regular from_str style
functions return an Option, hence the rename to indicate a Result.

[breaking-change]
2014-07-04 01:26:48 +01:00
Kevin Butler
2194fd7569 liburl: rename and move from_str to Url::parse_str.
url::from_str => url::Url::parse_str

The FromStr trait still works, but its confusing to have a from_str
free function that retuns a Result, while the regular from_str
returns an Option, hence the rename.

[breaking-change]
2014-07-04 01:22:32 +01:00
Jakub Wieczorek
c2c27faa35 Fix #12285
Unit-like struct patterns are irrefutable, no need for a branch.
2014-07-04 00:29:47 +02:00
Huon Wilson
fb258f22de doc: reduce spacing of table of contents.
A margin for the top level list was leaking into nested ones.
2014-07-04 08:17:20 +10:00
bors
5d5c20647f auto merge of #15377 : alexcrichton/rust/rollup, r=alexcrichton
Closes #15276 (Guide: if)
Closes #15280 (std::os - Add join_paths, make setenv non-utf8 capable)
Closes #15314 (Guide: functions)
Closes #15327 (Simplify PatIdent to contain an Ident rather than a Path)
Closes #15340 (Guide: add mutable binding section)
Closes #15342 (Fix ICE with nested macro_rules!-style macros)
Closes #15350 (Remove duplicated slash in install script path)
Closes #15351 (correct a few spelling mistakes in the tutorial)
Closes #15352 (librustc: Have the kind checker check sub-bounds in trait casts.)
Closes #15359 (Fix spelling errors.)
Closes #15361 (Rename set_broadast() to set_broadcast().)
Closes #15366 (Simplify creating a parser from a token tree)
Closes #15367 (Add examples for StrVector methods)
Closes #15372 (Vec::grow should use reserve_additional, Vec::reserve should check against capacity)
Closes #15373 (Fix minor issues in the documentation of libtime.)
2014-07-03 21:46:47 +00:00
bors
dd812ccbb5 auto merge of #15076 : luqmana/rust/naim, r=pcwalton
```Rust
struct With {
    x: int,
    f: NoCopy
}

#[no_mangle]
fn bar() {
    let mine = With { x: 3, f: NoCopy };
    match mine {
        c => {
            foo(c);
        }
    }
}

#[no_mangle]
fn foo(_: With) {}
```

Before:
```LLVM
define internal void @bar() unnamed_addr #1 {
entry-block:
  %mine = alloca %"struct.With<[]>"
  %__llmatch = alloca %"struct.With<[]>"*
  %c = alloca %"struct.With<[]>"
  %0 = getelementptr inbounds %"struct.With<[]>"* %mine, i32 0, i32 0
  store i64 3, i64* %0
  %1 = getelementptr inbounds %"struct.With<[]>"* %mine, i32 0, i32 1
  store %"struct.With<[]>"* %mine, %"struct.With<[]>"** %__llmatch
  br label %case_body

case_body:                                        ; preds = %entry-block
  %2 = load %"struct.With<[]>"** %__llmatch
  %3 = bitcast %"struct.With<[]>"* %2 to i8*
  %4 = bitcast %"struct.With<[]>"* %c to i8*
  call void @llvm.memcpy.p0i8.p0i8.i64(i8* %4, i8* %3, i64 8, i32 8, i1 false)
  %5 = load %"struct.With<[]>"* %c
  call void @foo(%"struct.With<[]>" %5)
  br label %join

join:                                             ; preds = %case_body
  ret void
}
```

After:
```LLVM
define internal void @bar() unnamed_addr #1 {
entry-block:
  %mine = alloca %"struct.With<[]>"
  %c = alloca %"struct.With<[]>"*
  %0 = getelementptr inbounds %"struct.With<[]>"* %mine, i32 0, i32 0
  store i64 3, i64* %0
  %1 = getelementptr inbounds %"struct.With<[]>"* %mine, i32 0, i32 1
  store %"struct.With<[]>"* %mine, %"struct.With<[]>"** %c
  br label %case_body

case_body:                                        ; preds = %entry-block
  %2 = load %"struct.With<[]>"** %c
  %3 = load %"struct.With<[]>"* %2
  call void @foo(%"struct.With<[]>" %3)
  br label %join

join:                                             ; preds = %case_body
  ret void
}
```

r? @pcwalton
2014-07-03 19:56:47 +00:00
Alex Crichton
9bd6479912 Test fixes from the rollup 2014-07-03 12:54:52 -07:00
OGINO Masanori
0c5b627232 Fix minor issues in the documentation of libtime.
- When the timezone is UTC, the "zone" field of the RFC 822 format is
  "GMT" (or "UT"), not "UTC."

- Although the name of `rfc3999` refers to RFC 3999, the documentation
  of it refers only to ISO 8601. This commit adds a description of the
  relation between ISO 8601 and RFC 3999.

Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
2014-07-03 12:54:52 -07:00
Erick Tryzelaar
451b7495b0 collections: Fix conditional when reserving extra vec space 2014-07-03 12:54:52 -07:00
Erick Tryzelaar
e7adb8434a collections: grow should use the overflow-checked reserve_additional 2014-07-03 12:54:52 -07:00
Jason Thompson
7db691e010 Add examples for StrVector methods
- examples for connect and concat
- also fixed extra word in existing docs
2014-07-03 12:54:52 -07:00
Piotr Jawniak
2f355b79dd Simplify creating a parser from a token tree
Closes #15306
2014-07-03 12:54:52 -07:00
Joseph Crail
4a6fcc51a0 Rename set_broadast() to set_broadcast(). 2014-07-03 12:54:51 -07:00
Joseph Crail
e3fa23bcb6 Fix spelling errors. 2014-07-03 12:54:51 -07:00
Patrick Walton
8297edd549 librustc: Have the kind checker check sub-bounds in trait casts.
This can break code that looked like:

    struct S<T> {
        val: T,
    }
    trait Gettable<T> {
        ...
    }
    impl<T: Copy> Gettable<T> for S<T> {
        ...
    }
    let t: Box<S<String>> = box S {
        val: "one".to_string(),
    };
    let a = t as Box<Gettable<String>>;
    //                        ^ note no `Copy` bound

Change this code to:

    impl<T> Gettable<T> for S<T> {
    //   ^ remove `Copy` bound
        ...
    }

Closes #14061.

[breaking-change]
2014-07-03 12:54:51 -07:00
Nathan Froyd
704f11d3d8 correct a few spelling mistakes in the tutorial 2014-07-03 12:54:51 -07:00
Ruud van Asseldonk
5d36005066 remove duplicated slash in install script path 2014-07-03 12:54:51 -07:00
Kevin Ballard
b81905eedb Fix ICE with nested macro_rules!-style macros
Fixes #10536.
2014-07-03 12:54:51 -07:00
Steve Klabnik
9868b65b15 Guide: add mutable binding section
Fixes #15334.
2014-07-03 12:54:51 -07:00
John Clements
e38cb972dc Simplify PatIdent to contain an Ident rather than a Path
Rationale: for what appear to be historical reasons only, the PatIdent contains
a Path rather than an Ident.  This means that there are many places in the code
where an ident is artificially promoted to a path, and---much more problematically---
a bunch of elements from a path are simply thrown away, which seems like an invitation
to some really nasty bugs.

This commit replaces the Path in a PatIdent with a SpannedIdent, which just contains an ident
and a span.
2014-07-03 12:54:51 -07:00
Paolo Falabella
cff79ab563 Rationals that have a 1 denom should print like ints 2014-07-03 12:54:51 -07:00
Steve Klabnik
faf5d926ec Guide: functions
Just a few words about functions and defining them.
2014-07-03 10:55:19 -07:00
Aaron Turon
8877b81f2c Add os::join_paths, make setenv non-utf8 capable
This commit changes `os` in three ways:

* It adds a `join_paths` function that is the converse to `split_paths`,
  easing manipulation of the `PATH` environment variable according to
  platform conventions.

* **Breaking change**: It changes `split_paths` to no longer drop empty paths, since they are
  meaningful to some shells (where they are synonymous with the current
  working directory).

* It changes `setenv` to take a `BytesContainer` rather than a `&str`
  value, since environment variables may have non-utf8 values on some
  platforms. Since `&str` is a `BytesContainer`, this is *not* a
  breaking change.

Along the way, it also refactors the `split_paths` function so that
`cfg` switches are applied internally (and the function header is given
only once). This fixes a bug: the doc comment had an example for only
one platform.

[breaking-change]
2014-07-03 10:55:14 -07:00
Steve Klabnik
748b9477f8 Guide: if 2014-07-03 10:55:10 -07:00
bors
eda75bcf42 auto merge of #15370 : alexcrichton/rust/fix-cargo, r=pnkfelix
This was causing lots of ICEs in cargo. I sadly wasn't ever able to reduce the
test case down, but I presume that's because it has to do with node id
collisions which are pretty difficult to turn up...
2014-07-03 16:56:51 +00:00
Alex Crichton
497ecd0458 rustc: Fix a call to with_path in trans_unboxing_shim
This was causing lots of ICEs in cargo. I sadly wasn't ever able to reduce the
test case down, but I presume that's because it has to do with node id
collisions which are pretty difficult to turn up...
2014-07-03 08:20:04 -07:00
OGINO Masanori
4530f8b2ef Rename ctime to asctime and add *proper* ctime.
In C, `ctime(t)` is equivalent to `asctime(localtime(t))`, so the result
should depend on the local timezone. Current `ctime` is compatible with
`asctime` in C, not `ctime`.

This commit renames `ctime` to `asctime` and adds `ctime` which converts
the time to the local timezone before formatting it.

This commit also fixes the documentation of them. Current documentation
of `ctime` says it returns "a string of the current time." However, it
actually returns a string of the time represented as `self`, not the
time when it is called.

Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
2014-07-04 00:18:30 +09:00
bors
0aa23ed18a auto merge of #15338 : pfalabella/rust/rational-impl-2, r=alexcrichton
Tried squashing commits for https://github.com/rust-lang/rust/pull/15329, failed spectacularly.
This is a fresh PR for the same change.

@alexcrichton?
2014-07-03 14:21:35 +00:00
bors
524f469943 auto merge of #15331 : Derecho/rust/master, r=alexcrichton
One of the examples in the docs on adding documentation to rust code has an error that will cause the function to run endlessly rather than return the desired result, should someone actually implement this for some reason. While the error does not hinder the explanation of documenting code, it does look better if it is corrected.
2014-07-03 12:36:36 +00:00
bors
550cc045e2 auto merge of #15199 : michaelwoerister/rust/cross-crate-stability, r=luqmana
So far, type names generated for debuginfo where a bit sketchy. It was not clearly defined when a name should be fully qualified and when not, if region parameters should be shown or not, and other things like that.
This commit makes the debuginfo module responsible for creating type names instead of using `ppaux::ty_to_str()` and brings type names (as they show up in the DWARF information) in line with GCC and Clang:

* The name of the type being described is unqualified. It's path is defined by its position in the namespace hierarchy.
* Type arguments are always fully qualified, no matter if they would actually be in scope at the type definition location.

Care is also taken to make type names consistent across crate boundaries. That is, the code now tries make the type name the same, regardless if the type is in the local crate or reconstructed from metadata. Otherwise LLVM will complain about violating the one-definition-rule when using link-time-optimization.

This commit also removes all source location information from type descriptions because these cannot be reconstructed for types instantiated from metadata. Again, with LTO enabled, this can lead to two versions of the debuginfo type description, one with and one without source location information, which then triggers the LLVM ODR assertion.
Fortunately, source location information about types is rarely used, so this has little impact. Once source location information is preserved in metadata (#1972) it can also be re-enabled for type descriptions.

`RUSTFLAGS=-g make check` no works again for me locally, including the LTO test cases (note that I've taken care of #15156 by reverting the change in LLVM that @luqmana identified as the culprit for that issue).
2014-07-03 10:46:39 +00:00
bors
e26d0a7a36 auto merge of #15078 : jakub-/rust/pattern-matching-refactor-vol-2, r=pnkfelix
I believe there's more commonality to be found there but maybe small steps are better. I'm also in the process of documenting what I can, I will see if I can add it to this PR.

It also seems to me that ideally some of this stuff (especially the pattern sanity check) could live as a separate compiler-agnostic module but I understand this may not be the right time (if not the worst) to start the process of modularising rustc.
2014-07-03 08:56:36 +00:00
Jakub Wieczorek
6b6edf4702 Improve code reuse between trans/_match.rs and check_match.rs
The specialization logic for patterns is really the same in both
exhaustiveness/reachability checking and codegen.
2014-07-03 09:17:47 +02:00
bors
00f9ff2b41 auto merge of #15324 : sneves/rust/master, r=alexcrichton
The current implementation of `rotate_left` and `rotate_right` are incorrect when the rotation amount is 0, or a multiple of the input's bitsize. When `n = 0`, the expression

    (self >> n) | (self << ($BITS - n))

results in a shift left by `$BITS` bits, which is undefined behavior (see https://github.com/rust-lang/rust/issues/10183), and currently results in a hardcoded `-1` value, instead of the original input value. Reducing `($BITS - n)` modulo `$BITS`, simplified to `(-n % $BITS)`, fixes this problem.
2014-07-03 06:11:38 +00:00
bors
e6c54a12c4 auto merge of #15087 : iliekturtles/rust/13810-make-install-mingw32, r=brson
Short-term fix per @brson's comment: https://github.com/rust-lang/rust/issues/13810#issuecomment-43562843. Tested on Win7 x64 and Linux.

One possible issue is that `install.sh` doesn't have a `need_cmd` definition like `configure` does. Should this be ported over as well?

Platform-detection code from `configure` copied over to `install.sh` in
order to special case the lib dir being `bin` on Windows instead of
`lib`.

Short-term fix for #13810.
2014-07-03 03:41:39 +00:00
Luqman Aden
77f72d36ec Build rustc with /LARGEADDRESSAWARE on windows. 2014-07-02 20:22:35 -07:00
Luqman Aden
df88646828 librustc: Don't schedule redundant cleanups. 2014-07-02 20:22:34 -07:00
Luqman Aden
bedc41b257 librustc: Use different alloca slot for non-move bindings. 2014-07-02 20:22:34 -07:00
Luqman Aden
94a56a3758 librustc: Don't create extra alloca slot for by value bindings in match. 2014-07-02 20:22:33 -07:00
Alex Crichton
c4ac124edd Merge remote-tracking branch 'origin/master' into 0.11.0-release
Conflicts:
	RELEASES.txt
2014-07-02 18:48:23 -07:00
bors
67776ba3da auto merge of #15325 : pcwalton/rust/trait-impl-bound-mismatch, r=pnkfelix
with the corresponding trait parameter bounds.

This is a version of the patch in PR #12611 by Florian Hahn, modified to
address Niko's feedback.

It does not address the issue of duplicate type parameter bounds, nor
does it address the issue of implementation-defined methods that contain
*fewer* bounds than the trait, because Niko's review indicates that this
should not be necessary (and indeed I believe it is not). A test has
been added to ensure that this works.

This will break code like:

    trait Foo {
        fn bar<T:Baz>();
    }

    impl Foo for Boo {
        fn bar<T:Baz + Quux>() { ... }
        //             ^~~~ ERROR
    }

This will be rejected because the implementation requires *more* bounds
than the trait. It can be fixed by either adding the missing bound to
the trait:

    trait Foo {
        fn bar<T:Baz + Quux>();
        //             ^~~~
    }

    impl Foo for Boo {
        fn bar<T:Baz + Quux>() { ... }  // OK
    }

Or by removing the bound from the impl:

    trait Foo {
        fn bar<T:Baz>();
    }

    impl Foo for Boo {
        fn bar<T:Baz>() { ... }  // OK
        //       ^ remove Quux
    }

This patch imports the relevant tests from #2687, as well as the test
case in #5886, which is fixed as well by this patch.

Closes #2687.
Closes #5886.

[breaking-change]

r? @pnkfelix
2014-07-03 01:06:38 +00:00
Mike Boutin
ccd7aaf17a install: Correct libdir for Windows installs.
Platform-detection code from `configure` copied over to `install.sh`
in order to special case the lib dir being `bin` on Windows instead
of `lib`.

Short-term fix for #13810.
2014-07-02 20:03:10 -04:00
bors
c8ae065182 auto merge of #15323 : alexcrichton/rust/no-travis-wait, r=huonw
It's looking like we're still timing out all over the place with travis_wait
because the entire `make -j4 rustc-stage1` command is taking too long. Instead,
achieve roughly the same idea by just having `-Z time-passes` printing
information. We shouldn't have a pass that takes longer than 10 minutes in
isolation.
2014-07-02 23:16:40 +00:00
Samuel Neves
c0248c0839 Fix rotate_{left, right} for multiple of bitsize rotation amounts
Add additional rotation tests
2014-07-02 23:45:27 +01:00
Patrick Walton
c3ae64a5cf librustc: Take the parameter space into account when combining type
parameters.

This can break code that mistakenly used type parameters in place of
`Self`. For example, this will break:

    trait Foo {
        fn bar<X>(u: X) -> Self {
            u
        }
    }

Change this code to not contain a type error. For example:

    trait Foo {
        fn bar<X>(_: X) -> Self {
            self
        }
    }

Closes #15172.

[breaking-change]
2014-07-02 15:40:09 -07:00
Andrew Poelstra
8ef0165a56 collections::bitv: clean up and unit test BitvSet::is_subset 2014-07-02 15:31:08 -07:00
mdinger
4afe31030e Fix broken link by adding comma 2014-07-02 17:48:10 -04:00
bors
3035d8dfb1 auto merge of #15313 : pcwalton/rust/overloaded-call-expr-use, r=alexcrichton
with overloaded calls.

This enforces the mutability and borrow restrictions around overloaded
calls.

[breaking-change]

Closes #12223.

r? @alexcrichton
2014-07-02 21:26:40 +00:00
Andrew Poelstra
78b674152e collections::bitv: change constructors for Bitv and BitvSet
`Bitv::new` has been renamed `Bitv::with_capacity`. The new function
`Bitv::new` now creates a `Bitv` with no elements.

The new function `BitvSet::with_capacity` creates a `BitvSet` with
a specified capacity.
2014-07-02 12:36:02 -07:00