Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 8 pull requests #45207

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
bb74c20
Inline eq_slice into str::eq
leoyvens Oct 3, 2017
47fc913
Update the `jobserver` crate
alexcrichton Oct 5, 2017
e6728ec
fix documentation typo
camsteffen Oct 8, 2017
a263a78
Fix PEP8 style issues in bootstrap code
johnthagen Oct 9, 2017
7735f59
unstable book: OIBIT
tinaun Oct 10, 2017
364148d
unstable book: unboxed_closures
tinaun Oct 10, 2017
d078252
unstable book: fn_traits
tinaun Oct 10, 2017
ca61ea2
Shorten some test names
petrochenkov Oct 10, 2017
db91b00
output compiler message updated
jean-lourenco Oct 8, 2017
d5ef9f9
formatting fixes
tinaun Oct 10, 2017
23a5fb8
Merge branch 'master' into pep8-bootstrap
johnthagen Oct 11, 2017
3cb5294
Fix typo during merge from master
johnthagen Oct 11, 2017
c7aa741
rustc: Handle `#[linkage]` anywhere in a crate
alexcrichton Oct 10, 2017
17cacc8
Rollup merge of #45005 - leodasvacas:inline-eq-slice-into-eq, r=jseyf…
kennytm Oct 11, 2017
d628e44
Rollup merge of #45049 - alexcrichton:update-jobserver, r=sfackler
kennytm Oct 11, 2017
6654979
Rollup merge of #45105 - camsteffen:patch-2, r=pnkfelix
kennytm Oct 11, 2017
79ed52a
Rollup merge of #45121 - johnthagen:pep8-bootstrap, r=alexcrichton
kennytm Oct 11, 2017
9655312
Rollup merge of #45122 - jean-lourenco:master, r=nikomatsakis
kennytm Oct 11, 2017
5d25e1e
Rollup merge of #45166 - tinaun:more_unstable_docs, r=steveklabnik
kennytm Oct 11, 2017
44c0a9a
Rollup merge of #45189 - alexcrichton:thinlto-allocators, r=michaelwo…
kennytm Oct 11, 2017
9defb40
Rollup merge of #45190 - petrochenkov:shorten, r=alexcrichton
kennytm Oct 11, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ def default_build_triple():

return "{}-{}".format(cputype, ostype)


class RustBuild(object):
"""Provide all the methods required to build Rust"""
def __init__(self):
Expand Down
48 changes: 31 additions & 17 deletions src/bootstrap/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,26 @@
sys.path.append(os.path.join(rust_dir, "src", "bootstrap"))
import bootstrap


class Option:
def __init__(self, name, rustbuild, desc, value):
self.name = name
self.rustbuild = rustbuild
self.desc = desc
self.value = value


options = []


def o(*args):
options.append(Option(*args, value=False))


def v(*args):
options.append(Option(*args, value=True))


o("debug", "rust.debug", "debug mode; disables optimization unless `--enable-optimize` given")
o("docs", "build.docs", "build standard library documentation")
o("compiler-docs", "build.compiler-docs", "build compiler documentation")
Expand Down Expand Up @@ -136,13 +141,16 @@ def v(*args):

v("set", None, "set arbitrary key/value pairs in TOML configuration")


def p(msg):
print("configure: " + msg)


def err(msg):
print("configure: error: " + msg)
sys.exit(1)


if '--help' in sys.argv or '-h' in sys.argv:
print('Usage: ./configure [options]')
print('')
Expand Down Expand Up @@ -208,7 +216,7 @@ def err(msg):
continue

found = True
if not option.name in known_args:
if option.name not in known_args:
known_args[option.name] = []
known_args[option.name].append((option, value))
break
Expand All @@ -227,27 +235,30 @@ def err(msg):
# TOML we're going to write out
config = {}


def build():
if 'build' in known_args:
return known_args['build'][0][1]
return bootstrap.default_build_triple()


def set(key, value):
s = "{:20} := {}".format(key, value)
if len(s) < 70:
p(s)
else:
p(s[:70] + " ...")

arr = config
parts = key.split('.')
for i, part in enumerate(parts):
if i == len(parts) - 1:
arr[part] = value
else:
if not part in arr:
arr[part] = {}
arr = arr[part]
s = "{:20} := {}".format(key, value)
if len(s) < 70:
p(s)
else:
p(s[:70] + " ...")

arr = config
parts = key.split('.')
for i, part in enumerate(parts):
if i == len(parts) - 1:
arr[part] = value
else:
if part not in arr:
arr[part] = {}
arr = arr[part]


for key in known_args:
# The `set` option is special and can be passed a bunch of times
Expand Down Expand Up @@ -345,6 +356,7 @@ def set(key, value):
targets[target] = sections['target'][:]
targets[target][0] = targets[target][0].replace("x86_64-unknown-linux-gnu", target)


# Here we walk through the constructed configuration we have from the parsed
# command line arguments. We then apply each piece of configuration by
# basically just doing a `sed` to change the various configuration line to what
Expand All @@ -362,6 +374,7 @@ def to_toml(value):
else:
raise RuntimeError('no toml')


def configure_section(lines, config):
for key in config:
value = config[key]
Expand All @@ -375,9 +388,10 @@ def configure_section(lines, config):
if not found:
raise RuntimeError("failed to find config line for {}".format(key))


for section_key in config:
section_config = config[section_key]
if not section_key in sections:
if section_key not in sections:
raise RuntimeError("config key {} not in sections".format(section_key))

if section_key == 'target':
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# `optin_builtin_traits`

The tracking issue for this feature is [#13231]

[#13231]: https://github.com/rust-lang/rust/issues/13231

----

The `optin_builtin_traits` feature gate allows you to define auto traits.

Auto traits, like [`Send`] or [`Sync`] in the standard library, are marker traits
that are automatically implemented for every type, unless the type, or a type it contains,
has explictly opted out via a negative impl.

[`Send`]: https://doc.rust-lang.org/std/marker/trait.Send.html
[`Sync`]: https://doc.rust-lang.org/std/marker/trait.Sync.html

```rust,ignore
impl !Type for Trait
```

Example:

```rust
#![feature(optin_builtin_traits)]

trait Valid {}

impl Valid for .. {}

struct True;
struct False;

impl !Valid for False {}

struct MaybeValid<T>(T);

fn must_be_valid<T: Valid>(_t: T) { }

fn main() {
// works
must_be_valid( MaybeValid(True) );

// compiler error - trait bound not satisfied
// must_be_valid( MaybeValid(False) );
}
```
25 changes: 25 additions & 0 deletions src/doc/unstable-book/src/language-features/unboxed-closures.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# `unboxed_closures`

The tracking issue for this feature is [#29625]

See Also: [`fn_traits`](library-features/fn-traits.html)

[#29625]: https://github.com/rust-lang/rust/issues/29625

----

The `unboxed_closures` feature allows you to write functions using the `"rust-call"` ABI,
required for implmenting the [`Fn*`] family of traits. `"rust-call"` functions must have
exactly one (non self) argument, a tuple representing the argument list.

[`Fn*`]: https://doc.rust-lang.org/std/ops/trait.Fn.html

```rust
#![feature(unboxed_closures)]

extern "rust-call" fn add_args(args: (u32, u32)) -> u32 {
args.0 + args.1
}

fn main() {}
```
35 changes: 35 additions & 0 deletions src/doc/unstable-book/src/library-features/fn-traits.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# `fn_traits`

The tracking issue for this feature is [#29625]

See Also: [`unboxed_closures`](language-features/unboxed-closures.html)

[#29625]: https://github.com/rust-lang/rust/issues/29625

----

The `fn_traits` feature allows for implementation of the [`Fn*`] traits
for creating custom closure-like types.

[`Fn*`]: https://doc.rust-lang.org/std/ops/trait.Fn.html

```rust
#![feature(unboxed_closures)]
#![feature(fn_traits)]

struct Adder {
a: u32
}

impl FnOnce<(u32, )> for Adder {
type Output = u32;
extern "rust-call" fn call_once(self, b: (u32, )) -> Self::Output {
self.a + b.0
}
}

fn main() {
let adder = Adder { a: 3 };
assert_eq!(adder(2), 5);
}
```
13 changes: 1 addition & 12 deletions src/libcore/str/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1405,16 +1405,6 @@ impl<'a> DoubleEndedIterator for LinesAny<'a> {
#[allow(deprecated)]
impl<'a> FusedIterator for LinesAny<'a> {}

/*
Section: Comparing strings
*/

/// Bytewise slice equality
#[inline]
fn eq_slice(a: &str, b: &str) -> bool {
a.as_bytes() == b.as_bytes()
}

/*
Section: UTF-8 validation
*/
Expand Down Expand Up @@ -1590,7 +1580,6 @@ mod traits {
use cmp::Ordering;
use ops;
use slice::{self, SliceIndex};
use str::eq_slice;

/// Implements ordering of strings.
///
Expand All @@ -1611,7 +1600,7 @@ mod traits {
impl PartialEq for str {
#[inline]
fn eq(&self, other: &str) -> bool {
eq_slice(self, other)
self.as_bytes() == other.as_bytes()
}
#[inline]
fn ne(&self, other: &str) -> bool { !(*self).eq(other) }
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/itemlikevisit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use super::intravisit::Visitor;
/// - Example: Lifetime resolution, which wants to bring lifetimes declared on the
/// impl into scope while visiting the impl-items, and then back out again.
/// - How: Implement `intravisit::Visitor` and override the
/// `visit_nested_map()` methods to return
/// `nested_visit_map()` methods to return
/// `NestedVisitorMap::All`. Walk your crate with
/// `intravisit::walk_crate()` invoked on `tcx.hir.krate()`.
/// - Pro: Visitor methods for any kind of HIR node, not just item-like things.
Expand Down
6 changes: 6 additions & 0 deletions src/librustc/middle/reachable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,12 @@ struct CollectPrivateImplItemsVisitor<'a, 'tcx: 'a> {

impl<'a, 'tcx: 'a> ItemLikeVisitor<'tcx> for CollectPrivateImplItemsVisitor<'a, 'tcx> {
fn visit_item(&mut self, item: &hir::Item) {
// Anything which has custom linkage gets thrown on the worklist no
// matter where it is in the crate.
if attr::contains_name(&item.attrs, "linkage") {
self.worklist.push(item.id);
}

// We need only trait impls here, not inherent impls, and only non-exported ones
if let hir::ItemImpl(.., Some(ref trait_ref), _, ref impl_item_refs) = item.node {
if !self.access_levels.is_reachable(item.id) {
Expand Down
1 change: 1 addition & 0 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2960,6 +2960,7 @@ impl<'a> Parser<'a> {
{ // Foo<Bar<Baz<Qux, ()>>>
err.help(
"use `::<...>` instead of `<...>` if you meant to specify type arguments");
err.help("or use `(...)` if you meant to specify fn arguments");
}
err.emit();
}
Expand Down
3 changes: 2 additions & 1 deletion src/test/parse-fail/require-parens-for-chained-comparison.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ fn main() {

f<X>();
//~^ ERROR: chained comparison operators require parentheses
//~^^ HELP: use `::<...>` instead of `<...>`
//~| HELP: use `::<...>` instead of `<...>`
//~| HELP: or use `(...)`
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// aux-build:specialization_cross_crate_defaults.rs
// aux-build:cross_crate_defaults.rs

#![feature(specialization)]

extern crate specialization_cross_crate_defaults;
extern crate cross_crate_defaults;

use specialization_cross_crate_defaults::*;
use cross_crate_defaults::*;

struct LocalDefault;
struct LocalOverride;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

// Test that specialization works even if only the upstream crate enables it

// aux-build:specialization_cross_crate.rs
// aux-build:cross_crate.rs

extern crate specialization_cross_crate;
extern crate cross_crate;

use specialization_cross_crate::*;
use cross_crate::*;

fn main() {
assert!(0u8.foo() == "generic Clone");
Expand Down
Loading