diff options
| author | bors <bors@rust-lang.org> | 2019-01-07 17:01:25 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-01-07 17:01:25 +0000 |
| commit | 59e70f27756a57b16a48bd7262e67fda01744701 (patch) | |
| tree | 7f675c297ac8a6f82586cc6f2a1d63b7b0346d64 /src | |
| parent | 21ac19d8fefb023752645fcf2517ce0fad663bf0 (diff) | |
| parent | 6031f1302b66da2e86f331d5202435607c54f256 (diff) | |
| download | rust-59e70f27756a57b16a48bd7262e67fda01744701.tar.gz rust-59e70f27756a57b16a48bd7262e67fda01744701.zip | |
Auto merge of #57405 - pietroalbini:rollup, r=pietroalbini
Rollup of 6 pull requests Successful merges: - #57290 (remove outdated comment) - #57308 (Make CompileController thread-safe) - #57358 (use utf-8 throughout htmldocck) - #57369 (Provide the option to use libc++ even on all platforms) - #57375 (Add duration constants) - #57403 (Make extern ref HTTPS) Failed merges: - #57370 (Support passing cflags/cxxflags/ldflags to LLVM build) r? @ghost
Diffstat (limited to 'src')
| -rw-r--r-- | src/bootstrap/compile.rs | 3 | ||||
| -rw-r--r-- | src/bootstrap/config.rs | 4 | ||||
| -rwxr-xr-x | src/bootstrap/configure.py | 1 | ||||
| -rw-r--r-- | src/etc/htmldocck.py | 46 | ||||
| -rw-r--r-- | src/libcore/time.rs | 16 | ||||
| -rw-r--r-- | src/librustc/ty/context.rs | 3 | ||||
| -rw-r--r-- | src/librustc_data_structures/sync.rs | 1 | ||||
| -rw-r--r-- | src/librustc_driver/driver.rs | 7 | ||||
| -rw-r--r-- | src/librustc_llvm/build.rs | 3 | ||||
| -rw-r--r-- | src/libstd/lib.rs | 1 | ||||
| -rw-r--r-- | src/libstd/time.rs | 3 | ||||
| -rw-r--r-- | src/test/rustdoc/issue-32374.rs | 2 |
12 files changed, 65 insertions, 25 deletions
diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 0d2546a0e9c..8bc7c5838ed 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 8655cf0eb30..9421817ae6d 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<u32>, @@ -252,6 +254,7 @@ struct Llvm { link_shared: Option<bool>, version_suffix: Option<String>, clang_cl: Option<String>, + use_libcxx: Option<bool>, } #[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 d13a3dc7834..b0c3c970249 100755 --- a/src/bootstrap/configure.py +++ b/src/bootstrap/configure.py @@ -62,6 +62,7 @@ o("full-tools", None, "enable all tools") 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 ef41e426f28..e8be2b9b537 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 @@ checks if the given file does not exist, for example. """ -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 @@ except ImportError: 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 @@ class CustomHTMLParser(HTMLParser): 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 @@ LINE_PATTERN = re.compile(r''' (?<=(?<!\S)@)(?P<negated>!?) (?P<cmd>[A-Za-z]+(?:-[A-Za-z]+)*) (?P<args>.*)$ -''', 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 @@ class CachedFiles(object): 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 @@ class CachedFiles(object): 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 b12ee0497d2..a751965dffa 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 6c377941dad..f6816d2f4e2 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -2930,9 +2930,6 @@ impl<T, R, E> InternIteratorElement<T, R> for Result<T, E> { } 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 d935eb7bdab..c18a5328dd5 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<T: ?Sized + Sync>() {} +pub fn assert_send<T: ?Sized + Send>() {} pub fn assert_send_val<T: ?Sized + Send>(_t: &T) {} pub fn assert_send_sync_val<T: ?Sized + Sync + Send>(_t: &T) {} diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 0204d041a24..bfff592a5dd 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<dyn Fn(&mut ty::query::Providers) + 'a>, + pub provide: Box<dyn Fn(&mut ty::query::Providers) + 'a + sync::Send>, /// Same as `provide`, but only for non-local crates, /// applied after `default_provide_extern`. - pub provide_extern: Box<dyn Fn(&mut ty::query::Providers) + 'a>, + pub provide_extern: Box<dyn Fn(&mut ty::query::Providers) + 'a + sync::Send>, } impl<'a> CompileController<'a> { pub fn basic() -> CompileController<'a> { + sync::assert_send::<Self>(); 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<dyn Fn(&mut CompileState) + 'a>, + pub callback: Box<dyn Fn(&mut CompileState) + 'a + sync::Send>, } impl<'a> PhaseController<'a> { diff --git a/src/librustc_llvm/build.rs b/src/librustc_llvm/build.rs index 98cf20a7ba7..d4a3ae273fc 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 d42e39f16e6..ccfce672e5f 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 eb67b718dbd..3daad7db2de 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 709cf5be781..58876a1aa11 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 - '<code>test</code> <a href="http://issue_url/32374">#32374</a>' // @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")] |
