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 9 pull requests #45233

Merged
merged 24 commits into from
Oct 13, 2017
Merged
Changes from all commits
Commits
Show all changes
24 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
fcee950
let rustdoc print the crate version into docs
QuietMisdreavus Oct 2, 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
1cb9f70
Upgrade some comments to doc comments
oli-obk Oct 10, 2017
ca61ea2
Shorten some test names
petrochenkov Oct 10, 2017
7ea286e
render the rust version into std/compiler/test docs
QuietMisdreavus Oct 9, 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
445bbde
Rollup merge of #44989 - QuietMisdreavus:what-is-your-quest, r=Guilla…
kennytm Oct 12, 2017
4f83c35
Rollup merge of #45005 - leodasvacas:inline-eq-slice-into-eq, r=jseyf…
kennytm Oct 12, 2017
81ea49f
Rollup merge of #45049 - alexcrichton:update-jobserver, r=sfackler
kennytm Oct 12, 2017
ff53dc7
Rollup merge of #45105 - camsteffen:patch-2, r=pnkfelix
kennytm Oct 12, 2017
6944768
Rollup merge of #45121 - johnthagen:pep8-bootstrap, r=alexcrichton
kennytm Oct 12, 2017
7640cda
Rollup merge of #45166 - tinaun:more_unstable_docs, r=steveklabnik
kennytm Oct 12, 2017
db6fdf6
Rollup merge of #45172 - oli-obk:patch-8, r=pnkfelix
kennytm Oct 12, 2017
e1a6795
Rollup merge of #45190 - petrochenkov:shorten, r=alexcrichton
kennytm Oct 12, 2017
19901df
Fix typo in libsyntax/parse/lexer/unicode_chars.rs
kennytm Oct 12, 2017
45e4c19
Rollup merge of #45231 - kennytm:patch-1, r=petrochenkov
kennytm Oct 12, 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.

8 changes: 8 additions & 0 deletions src/bootstrap/bin/rustdoc.rs
Original file line number Diff line number Diff line change
@@ -48,6 +48,14 @@ fn main() {
cmd.arg("-Z").arg("force-unstable-if-unmarked");
}

// Bootstrap's Cargo-command builder sets this variable to the current Rust version; let's pick
// it up so we can make rustdoc print this into the docs
if let Some(version) = env::var_os("RUSTDOC_CRATE_VERSION") {
// This "unstable-options" can be removed when `--crate-version` is stabilized
cmd.arg("-Z").arg("unstable-options")
.arg("--crate-version").arg(version);
}

std::process::exit(match cmd.status() {
Ok(s) => s.code().unwrap_or(1),
Err(e) => panic!("\n\nfailed to run {:?}: {}\n\n", cmd, e),
1 change: 1 addition & 0 deletions src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
@@ -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):
6 changes: 5 additions & 1 deletion src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
@@ -418,7 +418,8 @@ impl<'a> Builder<'a> {
.env("RUSTC_SYSROOT", self.sysroot(compiler))
.env("RUSTC_LIBDIR", self.sysroot_libdir(compiler, self.build.build))
.env("CFG_RELEASE_CHANNEL", &self.build.config.channel)
.env("RUSTDOC_REAL", self.rustdoc(host));
.env("RUSTDOC_REAL", self.rustdoc(host))
.env("RUSTDOC_CRATE_VERSION", self.build.rust_version());
cmd
}

@@ -574,6 +575,9 @@ impl<'a> Builder<'a> {
cargo.env("RUSTC_SAVE_ANALYSIS", "api".to_string());
}

// For `cargo doc` invocations, make rustdoc print the Rust version into the docs
cargo.env("RUSTDOC_CRATE_VERSION", self.build.rust_version());

// Environment variables *required* throughout the build
//
// FIXME: should update code to not require this env var
48 changes: 31 additions & 17 deletions src/bootstrap/configure.py
Original file line number Diff line number Diff line change
@@ -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")
@@ -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('')
@@ -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
@@ -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
@@ -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
@@ -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]
@@ -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':
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
@@ -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
*/
@@ -1590,7 +1580,6 @@ mod traits {
use cmp::Ordering;
use ops;
use slice::{self, SliceIndex};
use str::eq_slice;

/// Implements ordering of strings.
///
@@ -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) }
2 changes: 1 addition & 1 deletion src/librustc/hir/itemlikevisit.rs
Original file line number Diff line number Diff line change
@@ -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.
54 changes: 27 additions & 27 deletions src/librustc/session/mod.rs
Original file line number Diff line number Diff line change
@@ -54,24 +54,24 @@ pub mod config;
pub mod filesearch;
pub mod search_paths;

// Represents the data associated with a compilation
// session for a single crate.
/// Represents the data associated with a compilation
/// session for a single crate.
pub struct Session {
pub target: config::Config,
pub host: Target,
pub opts: config::Options,
pub parse_sess: ParseSess,
// For a library crate, this is always none
/// For a library crate, this is always none
pub entry_fn: RefCell<Option<(NodeId, Span)>>,
pub entry_type: Cell<Option<config::EntryFnType>>,
pub plugin_registrar_fn: Cell<Option<ast::NodeId>>,
pub derive_registrar_fn: Cell<Option<ast::NodeId>>,
pub default_sysroot: Option<PathBuf>,
// The name of the root source file of the crate, in the local file system.
// `None` means that there is no source file.
/// The name of the root source file of the crate, in the local file system.
/// `None` means that there is no source file.
pub local_crate_source_file: Option<String>,
// The directory the compiler has been executed in plus a flag indicating
// if the value stored here has been affected by path remapping.
/// The directory the compiler has been executed in plus a flag indicating
/// if the value stored here has been affected by path remapping.
pub working_dir: (String, bool),
pub lint_store: RefCell<lint::LintStore>,
pub buffered_lints: RefCell<Option<lint::LintBuffer>>,
@@ -83,11 +83,11 @@ pub struct Session {
pub plugin_attributes: RefCell<Vec<(String, AttributeType)>>,
pub crate_types: RefCell<Vec<config::CrateType>>,
pub dependency_formats: RefCell<dependency_format::Dependencies>,
// The crate_disambiguator is constructed out of all the `-C metadata`
// arguments passed to the compiler. Its value together with the crate-name
// forms a unique global identifier for the crate. It is used to allow
// multiple crates with the same name to coexist. See the
// trans::back::symbol_names module for more information.
/// The crate_disambiguator is constructed out of all the `-C metadata`
/// arguments passed to the compiler. Its value together with the crate-name
/// forms a unique global identifier for the crate. It is used to allow
/// multiple crates with the same name to coexist. See the
/// trans::back::symbol_names module for more information.
pub crate_disambiguator: RefCell<Option<Symbol>>,
pub features: RefCell<feature_gate::Features>,

@@ -143,17 +143,17 @@ pub struct Session {
}

pub struct PerfStats {
// The accumulated time needed for computing the SVH of the crate
/// The accumulated time needed for computing the SVH of the crate
pub svh_time: Cell<Duration>,
// The accumulated time spent on computing incr. comp. hashes
/// The accumulated time spent on computing incr. comp. hashes
pub incr_comp_hashes_time: Cell<Duration>,
// The number of incr. comp. hash computations performed
/// The number of incr. comp. hash computations performed
pub incr_comp_hashes_count: Cell<u64>,
// The number of bytes hashed when computing ICH values
/// The number of bytes hashed when computing ICH values
pub incr_comp_bytes_hashed: Cell<u64>,
// The accumulated time spent on computing symbol hashes
/// The accumulated time spent on computing symbol hashes
pub symbol_hash_time: Cell<Duration>,
// The accumulated time spent decoding def path tables from metadata
/// The accumulated time spent decoding def path tables from metadata
pub decode_def_path_tables_time: Cell<Duration>,
}

@@ -804,24 +804,24 @@ pub fn build_session_(sopts: config::Options,
/// Holds data on the current incremental compilation session, if there is one.
#[derive(Debug)]
pub enum IncrCompSession {
// This is the state the session will be in until the incr. comp. dir is
// needed.
/// This is the state the session will be in until the incr. comp. dir is
/// needed.
NotInitialized,
// This is the state during which the session directory is private and can
// be modified.
/// This is the state during which the session directory is private and can
/// be modified.
Active {
session_directory: PathBuf,
lock_file: flock::Lock,
load_dep_graph: bool,
},
// This is the state after the session directory has been finalized. In this
// state, the contents of the directory must not be modified any more.
/// This is the state after the session directory has been finalized. In this
/// state, the contents of the directory must not be modified any more.
Finalized {
session_directory: PathBuf,
},
// This is an error state that is reached when some compilation error has
// occurred. It indicates that the contents of the session directory must
// not be used, since they might be invalid.
/// This is an error state that is reached when some compilation error has
/// occurred. It indicates that the contents of the session directory must
/// not be used, since they might be invalid.
InvalidBecauseOfErrors {
session_directory: PathBuf,
}
2 changes: 2 additions & 0 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
@@ -112,6 +112,7 @@ impl<T: Clean<U>, U> Clean<Vec<U>> for P<[T]> {
#[derive(Clone, Debug)]
pub struct Crate {
pub name: String,
pub version: Option<String>,
pub src: PathBuf,
pub module: Option<Item>,
pub externs: Vec<(CrateNum, ExternalCrate)>,
@@ -183,6 +184,7 @@ impl<'a, 'tcx> Clean<Crate> for visit_ast::RustdocVisitor<'a, 'tcx> {

Crate {
name,
version: None,
src,
module: Some(module),
externs,
14 changes: 14 additions & 0 deletions src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
@@ -256,6 +256,9 @@ pub struct Cache {
// the access levels from crateanalysis.
pub access_levels: Arc<AccessLevels<DefId>>,

/// The version of the crate being documented, if given fron the `--crate-version` flag.
pub crate_version: Option<String>,

// Private fields only used when initially crawling a crate to build a cache

stack: Vec<String>,
@@ -534,6 +537,7 @@ pub fn run(mut krate: clean::Crate,
primitive_locations: FxHashMap(),
stripped_mod: false,
access_levels: krate.access_levels.clone(),
crate_version: krate.version.take(),
orphan_impl_items: Vec::new(),
traits: mem::replace(&mut krate.external_traits, FxHashMap()),
deref_trait_did,
@@ -3433,6 +3437,16 @@ impl<'a> fmt::Display for Sidebar<'a> {
write!(fmt, "{}", it.name.as_ref().unwrap())?;
write!(fmt, "</p>")?;

if it.is_crate() {
if let Some(ref version) = cache().crate_version {
write!(fmt,
"<div class='block version'>\
<p>Version {}</p>\
</div>",
version)?;
}
}

match it.inner {
clean::StructItem(ref s) => sidebar_struct(fmt, it, s)?,
clean::TraitItem(ref t) => sidebar_trait(fmt, it, t)?,
9 changes: 9 additions & 0 deletions src/librustdoc/html/static/rustdoc.css
Original file line number Diff line number Diff line change
@@ -203,6 +203,15 @@ nav.sub {
word-wrap: break-word;
}

.sidebar .version {
font-size: 15px;
text-align: center;
border-bottom: #DDDDDD 1px solid;
overflow-wrap: break-word;
word-wrap: break-word; /* deprecated */
word-break: break-word; /* Chrome, non-standard */
}

.location:empty {
border: none;
}
6 changes: 6 additions & 0 deletions src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
@@ -243,6 +243,9 @@ pub fn opts() -> Vec<RustcOptGroup> {
unstable("display-warnings", |o| {
o.optflag("", "display-warnings", "to print code warnings when testing doc")
}),
unstable("crate-version", |o| {
o.optopt("", "crate-version", "crate version to print into documentation", "VERSION")
}),
]
}

@@ -460,6 +463,7 @@ where R: 'static + Send, F: 'static + Send + FnOnce(Output) -> R {
let triple = matches.opt_str("target");
let maybe_sysroot = matches.opt_str("sysroot").map(PathBuf::from);
let crate_name = matches.opt_str("crate-name");
let crate_version = matches.opt_str("crate-version");
let plugin_path = matches.opt_str("plugin-path");

let cr = PathBuf::from(cratefile);
@@ -484,6 +488,8 @@ where R: 'static + Send, F: 'static + Send + FnOnce(Output) -> R {
krate.name = name
}

krate.version = crate_version;

// Process all of the crate attributes, extracting plugin metadata along
// with the passes which we are supposed to run.
for attr in krate.module.as_ref().unwrap().attrs.lists("doc") {
2 changes: 1 addition & 1 deletion src/libsyntax/parse/lexer/unicode_chars.rs
Original file line number Diff line number Diff line change
@@ -144,7 +144,7 @@ const UNICODE_ARRAY: &'static [(char, &'static str, char)] = &[
('‵', "Reversed Prime", '\''),
('՚', "Armenian Apostrophe", '\''),
('׳', "Hebrew Punctuation Geresh", '\''),
('`', "Greek Accent", '\''),
('`', "Grave Accent", '\''),
('`', "Greek Varia", '\''),
('`', "Fullwidth Grave Accent", '\''),
('´', "Acute Accent", '\''),
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -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");
Original file line number Diff line number Diff line change
@@ -8,13 +8,13 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

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

#![feature(specialization)]

extern crate specialization_cross_crate;
extern crate cross_crate;

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

struct NotClone;

13 changes: 13 additions & 0 deletions src/test/rustdoc/crate-version.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// compile-flags: --crate-version=1.3.37 -Z unstable-options

// @has 'crate_version/index.html' '//div[@class="block version"]/p' 'Version 1.3.37'