diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index d70b2b52aca1b..ece8dedb0aed7 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -35,6 +35,6 @@ And if someone takes issue with something you said or did, resist the urge to be The enforcement policies listed above apply to all official Rust venues; including official IRC channels (#rust, #rust-internals, #rust-tools, #rust-libs, #rustc, #rust-beginners, #rust-docs, #rust-community, #rust-lang, and #cargo); GitHub repositories under rust-lang, rust-lang-nursery, and rust-lang-deprecated; and all forums under rust-lang.org (users.rust-lang.org, internals.rust-lang.org). For other projects adopting the Rust Code of Conduct, please contact the maintainers of those projects for enforcement. If you wish to use this code of conduct for your own project, consider explicitly mentioning your moderation policy or making a copy with your own moderation policy so as to avoid confusion. -*Adapted from the [Node.js Policy on Trolling](http://blog.izs.me/post/30036893703/policy-on-trolling) as well as the [Contributor Covenant v1.3.0](https://www.contributor-covenant.org/version/1/3/0/).* +*Adapted from the [Node.js Policy on Trolling](https://blog.izs.me/2012/08/policy-on-trolling) as well as the [Contributor Covenant v1.3.0](https://www.contributor-covenant.org/version/1/3/0/).* [mod_team]: https://www.rust-lang.org/team.html#Moderation-team diff --git a/config.toml.example b/config.toml.example index f5a348593699f..c68d358b6a67e 100644 --- a/config.toml.example +++ b/config.toml.example @@ -90,6 +90,12 @@ # with clang-cl, so this is special in that it only compiles LLVM with clang-cl #clang-cl = '/path/to/clang-cl.exe' +# Use libc++ when building LLVM instead of libstdc++. This is the default on +# platforms already use libc++ as the default C++ library, but this option +# allows you to use libc++ even on platforms when it's not. You need to ensure +# that your host compiler ships with libc++. +#use-libcxx = true + # ============================================================================= # General build configuration options # ============================================================================= diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 0d2546a0e9ca9..8bc7c5838edda 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -723,6 +723,9 @@ pub fn build_codegen_backend(builder: &Builder, { cargo.env("LLVM_LINK_SHARED", "1"); } + if builder.config.llvm_use_libcxx { + cargo.env("LLVM_USE_LIBCXX", "1"); + } } _ => panic!("unknown backend: {}", backend), } diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index 8655cf0eb3053..9421817ae6d8e 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -82,6 +82,8 @@ pub struct Config { pub lldb_enabled: bool, pub llvm_tools_enabled: bool, + pub llvm_use_libcxx: bool, + // rust codegen options pub rust_optimize: bool, pub rust_codegen_units: Option, @@ -252,6 +254,7 @@ struct Llvm { link_shared: Option, version_suffix: Option, clang_cl: Option, + use_libcxx: Option, } #[derive(Deserialize, Default, Clone)] @@ -513,6 +516,7 @@ impl Config { config.llvm_link_jobs = llvm.link_jobs; config.llvm_version_suffix = llvm.version_suffix.clone(); config.llvm_clang_cl = llvm.clang_cl.clone(); + set(&mut config.llvm_use_libcxx, llvm.use_libcxx); } if let Some(ref rust) = toml.rust { diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py index d13a3dc783436..b0c3c9702498d 100755 --- a/src/bootstrap/configure.py +++ b/src/bootstrap/configure.py @@ -62,6 +62,7 @@ def v(*args): o("lld", "rust.lld", "build lld") o("lldb", "rust.lldb", "build lldb") o("missing-tools", "dist.missing-tools", "allow failures when building tools") +o("use-libcxx", "llvm.use_libcxx", "build LLVM with libc++") # Optimization and debugging options. These may be overridden by the release # channel, etc. diff --git a/src/etc/htmldocck.py b/src/etc/htmldocck.py index ef41e426f2893..e8be2b9b53710 100644 --- a/src/etc/htmldocck.py +++ b/src/etc/htmldocck.py @@ -1,3 +1,6 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + r""" htmldocck.py is a custom checker script for Rustdoc HTML outputs. @@ -98,7 +101,10 @@ """ -from __future__ import print_function +from __future__ import absolute_import, print_function, unicode_literals + +import codecs +import io import sys import os.path import re @@ -110,14 +116,10 @@ from HTMLParser import HTMLParser from xml.etree import cElementTree as ET -# ⇤/⇥ are not in HTML 4 but are in HTML 5 try: - from html.entities import entitydefs + from html.entities import name2codepoint except ImportError: - from htmlentitydefs import entitydefs -entitydefs['larrb'] = u'\u21e4' -entitydefs['rarrb'] = u'\u21e5' -entitydefs['nbsp'] = ' ' + from htmlentitydefs import name2codepoint # "void elements" (no closing tag) from the HTML Standard section 12.1.2 VOID_ELEMENTS = set(['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'keygen', @@ -157,11 +159,11 @@ def handle_data(self, data): self.__builder.data(data) def handle_entityref(self, name): - self.__builder.data(entitydefs[name]) + self.__builder.data(unichr(name2codepoint[name])) def handle_charref(self, name): code = int(name[1:], 16) if name.startswith(('x', 'X')) else int(name, 10) - self.__builder.data(unichr(code).encode('utf-8')) + self.__builder.data(unichr(code)) def close(self): HTMLParser.close(self) @@ -210,11 +212,11 @@ def concat_multi_lines(f): (?<=(?!?) (?P[A-Za-z]+(?:-[A-Za-z]+)*) (?P.*)$ -''', re.X) +''', re.X | re.UNICODE) def get_commands(template): - with open(template, 'rU') as f: + with io.open(template, encoding='utf-8') as f: for lineno, line in concat_multi_lines(f): m = LINE_PATTERN.search(line) if not m: @@ -226,7 +228,10 @@ def get_commands(template): if args and not args[:1].isspace(): print_err(lineno, line, 'Invalid template syntax') continue - args = shlex.split(args) + try: + args = shlex.split(args) + except UnicodeEncodeError: + args = [arg.decode('utf-8') for arg in shlex.split(args.encode('utf-8'))] yield Command(negated=negated, cmd=cmd, args=args, lineno=lineno+1, context=line) @@ -280,7 +285,7 @@ def get_file(self, path): if not(os.path.exists(abspath) and os.path.isfile(abspath)): raise FailedCheck('File does not exist {!r}'.format(path)) - with open(abspath) as f: + with io.open(abspath, encoding='utf-8') as f: data = f.read() self.files[path] = data return data @@ -294,9 +299,9 @@ def get_tree(self, path): if not(os.path.exists(abspath) and os.path.isfile(abspath)): raise FailedCheck('File does not exist {!r}'.format(path)) - with open(abspath) as f: + with io.open(abspath, encoding='utf-8') as f: try: - tree = ET.parse(f, CustomHTMLParser()) + tree = ET.fromstringlist(f.readlines(), CustomHTMLParser()) except Exception as e: raise RuntimeError('Cannot parse an HTML file {!r}: {}'.format(path, e)) self.trees[path] = tree @@ -313,7 +318,7 @@ def check_string(data, pat, regexp): if not pat: return True # special case a presence testing elif regexp: - return re.search(pat, data) is not None + return re.search(pat, data, flags=re.UNICODE) is not None else: data = ' '.join(data.split()) pat = ' '.join(pat.split()) @@ -350,7 +355,7 @@ def check_tree_text(tree, path, pat, regexp): break except Exception as e: print('Failed to get path "{}"'.format(path)) - raise e + raise return ret @@ -359,7 +364,12 @@ def get_tree_count(tree, path): return len(tree.findall(path)) def stderr(*args): - print(*args, file=sys.stderr) + if sys.version_info.major < 3: + file = codecs.getwriter('utf-8')(sys.stderr) + else: + file = sys.stderr + + print(*args, file=file) def print_err(lineno, context, err, message=None): global ERR_COUNT diff --git a/src/libcore/time.rs b/src/libcore/time.rs index b12ee0497d2c2..a751965dffab3 100644 --- a/src/libcore/time.rs +++ b/src/libcore/time.rs @@ -23,6 +23,22 @@ const MILLIS_PER_SEC: u64 = 1_000; const MICROS_PER_SEC: u64 = 1_000_000; const MAX_NANOS_F64: f64 = ((u64::MAX as u128 + 1)*(NANOS_PER_SEC as u128)) as f64; +/// The duration of one second. +#[unstable(feature = "duration_constants", issue = "57391")] +pub const SECOND: Duration = Duration::from_secs(1); + +/// The duration of one millisecond. +#[unstable(feature = "duration_constants", issue = "57391")] +pub const MILLISECOND: Duration = Duration::from_millis(1); + +/// The duration of one microsecond. +#[unstable(feature = "duration_constants", issue = "57391")] +pub const MICROSECOND: Duration = Duration::from_micros(1); + +/// The duration of one nanosecond. +#[unstable(feature = "duration_constants", issue = "57391")] +pub const NANOSECOND: Duration = Duration::from_nanos(1); + /// A `Duration` type to represent a span of time, typically used for system /// timeouts. /// diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 6c377941dad19..f6816d2f4e235 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -2930,9 +2930,6 @@ impl InternIteratorElement for Result { } pub fn provide(providers: &mut ty::query::Providers<'_>) { - // FIXME(#44234): almost all of these queries have no sub-queries and - // therefore no actual inputs, they're just reading tables calculated in - // resolve! Does this work? Unsure! That's what the issue is about. providers.in_scope_traits_map = |tcx, id| tcx.gcx.trait_map.get(&id).cloned(); providers.module_exports = |tcx, id| tcx.gcx.export_map.get(&id).cloned(); providers.crate_name = |tcx, id| { diff --git a/src/librustc_data_structures/sync.rs b/src/librustc_data_structures/sync.rs index d935eb7bdab74..c18a5328dd54e 100644 --- a/src/librustc_data_structures/sync.rs +++ b/src/librustc_data_structures/sync.rs @@ -323,6 +323,7 @@ cfg_if! { } pub fn assert_sync() {} +pub fn assert_send() {} pub fn assert_send_val(_t: &T) {} pub fn assert_send_sync_val(_t: &T) {} diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 0204d041a2420..bfff592a5dd49 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -402,14 +402,15 @@ pub struct CompileController<'a> { /// Allows overriding default rustc query providers, /// after `default_provide` has installed them. - pub provide: Box, + pub provide: Box, /// Same as `provide`, but only for non-local crates, /// applied after `default_provide_extern`. - pub provide_extern: Box, + pub provide_extern: Box, } impl<'a> CompileController<'a> { pub fn basic() -> CompileController<'a> { + sync::assert_send::(); CompileController { after_parse: PhaseController::basic(), after_expand: PhaseController::basic(), @@ -499,7 +500,7 @@ pub struct PhaseController<'a> { // If true then the compiler will try to run the callback even if the phase // ends with an error. Note that this is not always possible. pub run_callback_on_error: bool, - pub callback: Box, + pub callback: Box, } impl<'a> PhaseController<'a> { diff --git a/src/librustc_llvm/build.rs b/src/librustc_llvm/build.rs index 98cf20a7ba7f4..d4a3ae273fcd4 100644 --- a/src/librustc_llvm/build.rs +++ b/src/librustc_llvm/build.rs @@ -236,6 +236,7 @@ fn main() { } let llvm_static_stdcpp = env::var_os("LLVM_STATIC_STDCPP"); + let llvm_use_libcxx = env::var_os("LLVM_USE_LIBCXX"); let stdcppname = if target.contains("openbsd") { // llvm-config on OpenBSD doesn't mention stdlib=libc++ @@ -245,6 +246,8 @@ fn main() { } else if target.contains("netbsd") && llvm_static_stdcpp.is_some() { // NetBSD uses a separate library when relocation is required "stdc++_pic" + } else if llvm_use_libcxx.is_some() { + "c++" } else { "stdc++" }; diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index d42e39f16e663..ccfce672e5f9e 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -248,6 +248,7 @@ #![feature(const_cstr_unchecked)] #![feature(core_intrinsics)] #![feature(dropck_eyepatch)] +#![feature(duration_constants)] #![feature(exact_size_is_empty)] #![feature(external_doc)] #![feature(fixed_size_array)] diff --git a/src/libstd/time.rs b/src/libstd/time.rs index eb67b718dbd3d..3daad7db2deff 100644 --- a/src/libstd/time.rs +++ b/src/libstd/time.rs @@ -21,6 +21,9 @@ use sys_common::FromInner; #[stable(feature = "time", since = "1.3.0")] pub use core::time::Duration; +#[unstable(feature = "duration_constants", issue = "57391")] +pub use core::time::{SECOND, MILLISECOND, MICROSECOND, NANOSECOND}; + /// A measurement of a monotonically nondecreasing clock. /// Opaque and useful only with `Duration`. /// diff --git a/src/test/rustdoc/issue-32374.rs b/src/test/rustdoc/issue-32374.rs index 709cf5be7812d..58876a1aa1162 100644 --- a/src/test/rustdoc/issue-32374.rs +++ b/src/test/rustdoc/issue-32374.rs @@ -10,7 +10,7 @@ // 'Deprecated since 1.0.0: text' // @has - 'test #32374' // @matches issue_32374/struct.T.html '//*[@class="stab unstable"]' \ -// '🔬 This is a nightly-only experimental API. \(test #32374\)$' +// '🔬 This is a nightly-only experimental API. \(test\s#32374\)$' /// Docs #[rustc_deprecated(since = "1.0.0", reason = "text")] #[unstable(feature = "test", issue = "32374")]