From 63b17d1b98c87f26e492147057138f421948f24e Mon Sep 17 00:00:00 2001 From: Mark Mansi Date: Wed, 2 Jan 2019 16:10:21 -0600 Subject: [PATCH 1/8] remove outdated comment --- src/librustc/ty/context.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index ea69d466ba6c5..105d31b154cce 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -3040,9 +3040,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| { From 75b2e143f125d7e214b8d3e54b3079caba1cc065 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Thu, 3 Jan 2019 18:14:01 +0100 Subject: [PATCH 2/8] Make CompileController thread-safe --- src/librustc_data_structures/sync.rs | 1 + src/librustc_driver/driver.rs | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) 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 9b232edc11d4a..31e267ef3b668 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -403,14 +403,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(), @@ -500,7 +501,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> { From 7306b87f129197177ffac57139839d18fe93a8f6 Mon Sep 17 00:00:00 2001 From: Petr Hosek Date: Tue, 13 Nov 2018 16:25:51 -0800 Subject: [PATCH 3/8] Provide the option to use libc++ even on all platforms This is the default on platforms which use libc++ as the default C++ library but this option allows using libc++ on others as well. --- config.toml.example | 6 ++++++ src/bootstrap/compile.rs | 3 +++ src/bootstrap/config.rs | 4 ++++ src/bootstrap/configure.py | 1 + src/librustc_llvm/build.rs | 3 +++ 5 files changed, 17 insertions(+) diff --git a/config.toml.example b/config.toml.example index f75e220de47e7..b15f2113c80ef 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 821bd002e95b3..6b6ead351e8a0 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -752,6 +752,9 @@ pub fn build_codegen_backend(builder: &Builder, if builder.config.llvm_link_shared { 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/librustc_llvm/build.rs b/src/librustc_llvm/build.rs index 238e79dfd22e1..4826fef548a88 100644 --- a/src/librustc_llvm/build.rs +++ b/src/librustc_llvm/build.rs @@ -232,6 +232,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++ @@ -241,6 +242,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++" }; From 6fefcee73a5dfee20281396e0f1418ceda81776b Mon Sep 17 00:00:00 2001 From: Andy Russell Date: Sat, 5 Jan 2019 14:17:51 -0500 Subject: [PATCH 4/8] use utf-8 throughout htmldocck This commit improves compatibility with Python 3, which already uses Unicode throughout. It also fixes a subtle incompatibility stemming from the use of `entitydefs`, which contains replacement text _encoded in latin-1_ for HTML entities. When using Python 3, this would cause `0xa0` to be incorrectly added to the element tree. This meant that there was a rustdoc test that would pass under Python 2 but fail under Python 3, due to an incorrect regex match against the non-breaking space character. This commit triggers that failure in both versions, and also fixes it. --- src/etc/htmldocck.py | 46 ++++++++++++++++++++------------- src/test/rustdoc/issue-32374.rs | 2 +- 2 files changed, 29 insertions(+), 19 deletions(-) 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/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")] From 7f7a2e939682ba0fabea62a528cec4fec7148c42 Mon Sep 17 00:00:00 2001 From: Stjepan Glavina Date: Sun, 6 Jan 2019 13:44:55 +0100 Subject: [PATCH 5/8] Add duration constants --- src/libcore/time.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/libcore/time.rs b/src/libcore/time.rs index b12ee0497d2c2..30e0873a4a2ea 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 = "0")] +pub const SECOND: Duration = Duration::from_secs(1); + +/// The duration of one millisecond. +#[unstable(feature = "duration_constants", issue = "0")] +pub const MILLISECOND: Duration = Duration::from_millis(1); + +/// The duration of one microsecond. +#[unstable(feature = "duration_constants", issue = "0")] +pub const MICROSECOND: Duration = Duration::from_micros(1); + +/// The duration of one nanosecond. +#[unstable(feature = "duration_constants", issue = "0")] +pub const NANOSECOND: Duration = Duration::from_nanos(1); + /// A `Duration` type to represent a span of time, typically used for system /// timeouts. /// From 72ec5aa08055fade5122cc306cd9a08c64d4b635 Mon Sep 17 00:00:00 2001 From: Stjepan Glavina Date: Sun, 6 Jan 2019 14:02:42 +0100 Subject: [PATCH 6/8] Re-export constants from core into std --- src/libstd/lib.rs | 1 + src/libstd/time.rs | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 6ded43dfed1f4..13669c1c0e1f5 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 ffe604cd33bd8..d8cdef8b2ab30 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 = "0")] +pub use core::time::{SECOND, MILLISECOND, MICROSECOND, NANOSECOND}; + /// A measurement of a monotonically nondecreasing clock. /// Opaque and useful only with `Duration`. /// From 8c902b66339f54b40d3033c864675929b2c8a65b Mon Sep 17 00:00:00 2001 From: Stjepan Glavina Date: Mon, 7 Jan 2019 11:39:22 +0100 Subject: [PATCH 7/8] Specify the tracking issue --- src/libcore/time.rs | 8 ++++---- src/libstd/time.rs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libcore/time.rs b/src/libcore/time.rs index 30e0873a4a2ea..a751965dffab3 100644 --- a/src/libcore/time.rs +++ b/src/libcore/time.rs @@ -24,19 +24,19 @@ 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 = "0")] +#[unstable(feature = "duration_constants", issue = "57391")] pub const SECOND: Duration = Duration::from_secs(1); /// The duration of one millisecond. -#[unstable(feature = "duration_constants", issue = "0")] +#[unstable(feature = "duration_constants", issue = "57391")] pub const MILLISECOND: Duration = Duration::from_millis(1); /// The duration of one microsecond. -#[unstable(feature = "duration_constants", issue = "0")] +#[unstable(feature = "duration_constants", issue = "57391")] pub const MICROSECOND: Duration = Duration::from_micros(1); /// The duration of one nanosecond. -#[unstable(feature = "duration_constants", issue = "0")] +#[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 diff --git a/src/libstd/time.rs b/src/libstd/time.rs index d8cdef8b2ab30..5d9c726995a34 100644 --- a/src/libstd/time.rs +++ b/src/libstd/time.rs @@ -21,7 +21,7 @@ use sys_common::FromInner; #[stable(feature = "time", since = "1.3.0")] pub use core::time::Duration; -#[unstable(feature = "duration_constants", issue = "0")] +#[unstable(feature = "duration_constants", issue = "57391")] pub use core::time::{SECOND, MILLISECOND, MICROSECOND, NANOSECOND}; /// A measurement of a monotonically nondecreasing clock. From 7316490fcb01beffff6e696f9e061305ca5a93f5 Mon Sep 17 00:00:00 2001 From: Jonathan Claudius Date: Mon, 7 Jan 2019 09:52:32 -0500 Subject: [PATCH 8/8] Make extern ref HTTPS --- CODE_OF_CONDUCT.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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