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 11 pull requests #77864

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
db0438b
Mark `repr128` as `incomplete_features`
varkor Oct 3, 2020
536674f
cleanup WithOptConstParam queries
lcnr Oct 4, 2020
8160bfa
query_name_of_opt_const_arg -> query_name_opt_const_arg
lcnr Oct 5, 2020
ce45b4f
Remove unused class rule
GuillaumeGomez Oct 8, 2020
8d2c622
Implement `AsRawFd` for `StdinLock` etc. on WASI.
sunfishcode Oct 8, 2020
d5b7143
Fix intra-docs link
aDotInTheVoid Oct 10, 2020
0a2a68e
Use range instead of tuple of ints
bugadani Oct 10, 2020
83c790f
Make some functions private that don't need to be public
jyn514 Oct 11, 2020
e533bb7
Don't duplicate char::is_ascii_digit
LingMan Sep 23, 2020
a56b0e9
Simplify using is_ascii_alphabetic and is_ascii_alphanumeric
LingMan Sep 23, 2020
d7494af
Mostly print statements to see where things are
winnsterx Oct 6, 2020
5d44402
update url in bootstrap README
12101111 Oct 12, 2020
9f1048d
Add word-wrap rule for short descriptions
GuillaumeGomez Oct 8, 2020
cabedfe
Remove `mark-i-m` from rustc-dev-guide maintainers
JohnTitor Oct 12, 2020
27a00dc
Rollup merge of #77488 - varkor:repr128-incomplete_features, r=jonas-…
JohnTitor Oct 12, 2020
9ec5ab9
Rollup merge of #77550 - lcnr:ty-dep-path-ct-cleanup, r=ecstatic-morse
JohnTitor Oct 12, 2020
f412007
Rollup merge of #77699 - GuillaumeGomez:word-wrap, r=XAMPPRocky
JohnTitor Oct 12, 2020
195e787
Rollup merge of #77724 - sunfishcode:stdinlock-asrawfd, r=alexcrichton
JohnTitor Oct 12, 2020
6ff6fc1
Rollup merge of #77746 - winnayx:issue-77572-fix, r=jyn514
JohnTitor Oct 12, 2020
fd3c5ce
Rollup merge of #77784 - aDotInTheVoid:ffi-sealed_trait-intra-docs, r…
JohnTitor Oct 12, 2020
2c9ff19
Rollup merge of #77811 - jyn514:private, r=GuillaumeGomez
JohnTitor Oct 12, 2020
161784f
Rollup merge of #77818 - bugadani:range, r=oli-obk
JohnTitor Oct 12, 2020
40bf827
Rollup merge of #77831 - LingMan:use_std, r=jonas-schievink
JohnTitor Oct 12, 2020
3fd9c82
Rollup merge of #77852 - 12101111:fix-bootstrap-doc, r=jonas-schievink
JohnTitor Oct 12, 2020
a35a130
Rollup merge of #77863 - JohnTitor:remove-mark-i-m, r=pietroalbini
JohnTitor Oct 12, 2020
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
33 changes: 10 additions & 23 deletions compiler/rustc_builtin_macros/src/format_foreign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ pub mod printf {
if let Start = state {
match c {
'1'..='9' => {
let end = at_next_cp_while(next, is_digit);
let end = at_next_cp_while(next, char::is_ascii_digit);
match end.next_cp() {
// Yes, this *is* the parameter.
Some(('$', end2)) => {
Expand Down Expand Up @@ -427,7 +427,7 @@ pub mod printf {
move_to!(next);
}
'1'..='9' => {
let end = at_next_cp_while(next, is_digit);
let end = at_next_cp_while(next, char::is_ascii_digit);
state = Prec;
width = Some(Num::from_str(at.slice_between(end).unwrap(), None));
move_to!(end);
Expand All @@ -441,7 +441,7 @@ pub mod printf {
}

if let WidthArg = state {
let end = at_next_cp_while(at, is_digit);
let end = at_next_cp_while(at, char::is_ascii_digit);
match end.next_cp() {
Some(('$', end2)) => {
state = Prec;
Expand Down Expand Up @@ -473,7 +473,7 @@ pub mod printf {
if let PrecInner = state {
match c {
'*' => {
let end = at_next_cp_while(next, is_digit);
let end = at_next_cp_while(next, char::is_ascii_digit);
match end.next_cp() {
Some(('$', end2)) => {
state = Length;
Expand All @@ -488,7 +488,7 @@ pub mod printf {
}
}
'0'..='9' => {
let end = at_next_cp_while(next, is_digit);
let end = at_next_cp_while(next, char::is_ascii_digit);
state = Length;
precision = Some(Num::from_str(at.slice_between(end).unwrap(), None));
move_to!(end);
Expand Down Expand Up @@ -563,12 +563,12 @@ pub mod printf {

fn at_next_cp_while<F>(mut cur: Cur<'_>, mut pred: F) -> Cur<'_>
where
F: FnMut(char) -> bool,
F: FnMut(&char) -> bool,
{
loop {
match cur.next_cp() {
Some((c, next)) => {
if pred(c) {
if pred(&c) {
cur = next;
} else {
return cur;
Expand All @@ -579,14 +579,7 @@ pub mod printf {
}
}

fn is_digit(c: char) -> bool {
match c {
'0'..='9' => true,
_ => false,
}
}

fn is_flag(c: char) -> bool {
fn is_flag(c: &char) -> bool {
match c {
'0' | '-' | '+' | ' ' | '#' | '\'' => true,
_ => false,
Expand Down Expand Up @@ -723,17 +716,11 @@ pub mod shell {
}

fn is_ident_head(c: char) -> bool {
match c {
'a'..='z' | 'A'..='Z' | '_' => true,
_ => false,
}
c.is_ascii_alphabetic() || c == '_'
}

fn is_ident_tail(c: char) -> bool {
match c {
'0'..='9' => true,
c => is_ident_head(c),
}
c.is_ascii_alphanumeric() || c == '_'
}

#[cfg(test)]
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_feature/src/active.rs
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,7 @@ pub const INCOMPLETE_FEATURES: &[Symbol] = &[
sym::const_trait_bound_opt_out,
sym::lazy_normalization_consts,
sym::specialization,
sym::repr128,
];

/// Some features are not allowed to be used together at the same time, if
Expand Down
36 changes: 34 additions & 2 deletions compiler/rustc_middle/src/mir/query.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
//! Values computed by queries that use MIR.

use crate::mir::{Body, Promoted};
use crate::mir::{abstract_const, Body, Promoted};
use crate::ty::{self, Ty, TyCtxt};
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::sync::Lrc;
use rustc_errors::ErrorReported;
use rustc_hir as hir;
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_index::bit_set::BitMatrix;
Expand Down Expand Up @@ -407,7 +408,12 @@ pub struct CoverageInfo {
pub num_expressions: u32,
}

/// Shims which make dealing with `WithOptConstParam` easier.
///
/// For more information on why this is needed, consider looking
/// at the docs for `WithOptConstParam` itself.
impl<'tcx> TyCtxt<'tcx> {
#[inline]
pub fn mir_borrowck_opt_const_arg(
self,
def: ty::WithOptConstParam<LocalDefId>,
Expand All @@ -419,6 +425,7 @@ impl<'tcx> TyCtxt<'tcx> {
}
}

#[inline]
pub fn mir_const_qualif_opt_const_arg(
self,
def: ty::WithOptConstParam<LocalDefId>,
Expand All @@ -430,7 +437,8 @@ impl<'tcx> TyCtxt<'tcx> {
}
}

pub fn promoted_mir_of_opt_const_arg(
#[inline]
pub fn promoted_mir_opt_const_arg(
self,
def: ty::WithOptConstParam<DefId>,
) -> &'tcx IndexVec<Promoted, Body<'tcx>> {
Expand All @@ -440,4 +448,28 @@ impl<'tcx> TyCtxt<'tcx> {
self.promoted_mir(def.did)
}
}

#[inline]
pub fn optimized_mir_opt_const_arg(
self,
def: ty::WithOptConstParam<DefId>,
) -> &'tcx Body<'tcx> {
if let Some((did, param_did)) = def.as_const_arg() {
self.optimized_mir_of_const_arg((did, param_did))
} else {
self.optimized_mir(def.did)
}
}

#[inline]
pub fn mir_abstract_const_opt_const_arg(
self,
def: ty::WithOptConstParam<DefId>,
) -> Result<Option<&'tcx [abstract_const::Node<'tcx>]>, ErrorReported> {
if let Some((did, param_did)) = def.as_const_arg() {
self.mir_abstract_const_of_const_arg((did, param_did))
} else {
self.mir_abstract_const(def.did)
}
}
}
8 changes: 1 addition & 7 deletions compiler/rustc_middle/src/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2953,13 +2953,7 @@ impl<'tcx> TyCtxt<'tcx> {
/// Returns the possibly-auto-generated MIR of a `(DefId, Subst)` pair.
pub fn instance_mir(self, instance: ty::InstanceDef<'tcx>) -> &'tcx Body<'tcx> {
match instance {
ty::InstanceDef::Item(def) => {
if let Some((did, param_did)) = def.as_const_arg() {
self.optimized_mir_of_const_arg((did, param_did))
} else {
self.optimized_mir(def.did)
}
}
ty::InstanceDef::Item(def) => self.optimized_mir_opt_const_arg(def),
ty::InstanceDef::VtableShim(..)
| ty::InstanceDef::ReifyShim(..)
| ty::InstanceDef::Intrinsic(..)
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir/src/const_eval/eval_queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ pub fn eval_to_allocation_raw_provider<'tcx>(
// deny-by-default lint
_ => {
if let Some(p) = cid.promoted {
let span = tcx.promoted_mir_of_opt_const_arg(def.to_global())[p].span;
let span = tcx.promoted_mir_opt_const_arg(def.to_global())[p].span;
if let err_inval!(ReferencedConstant) = err.error {
Err(err.report_as_error(
tcx.at(span),
Expand Down
8 changes: 2 additions & 6 deletions compiler/rustc_mir/src/interpret/eval_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -477,16 +477,12 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
}
trace!("load mir(instance={:?}, promoted={:?})", instance, promoted);
if let Some(promoted) = promoted {
return Ok(&self.tcx.promoted_mir_of_opt_const_arg(def)[promoted]);
return Ok(&self.tcx.promoted_mir_opt_const_arg(def)[promoted]);
}
match instance {
ty::InstanceDef::Item(def) => {
if self.tcx.is_mir_available(def.did) {
if let Some((did, param_did)) = def.as_const_arg() {
Ok(self.tcx.optimized_mir_of_const_arg((did, param_did)))
} else {
Ok(self.tcx.optimized_mir(def.did))
}
Ok(self.tcx.optimized_mir_opt_const_arg(def))
} else {
throw_unsup!(NoMirFor(def.did))
}
Expand Down
18 changes: 9 additions & 9 deletions compiler/rustc_mir/src/monomorphize/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ use rustc_session::config::EntryFnType;
use rustc_span::source_map::{dummy_spanned, respan, Span, Spanned, DUMMY_SP};
use smallvec::SmallVec;
use std::iter;
use std::ops::Range;
use std::path::PathBuf;

#[derive(PartialEq)]
Expand All @@ -210,9 +211,8 @@ pub enum MonoItemCollectionMode {
pub struct InliningMap<'tcx> {
// Maps a source mono item to the range of mono items
// accessed by it.
// The two numbers in the tuple are the start (inclusive) and
// end index (exclusive) within the `targets` vecs.
index: FxHashMap<MonoItem<'tcx>, (usize, usize)>,
// The range selects elements within the `targets` vecs.
index: FxHashMap<MonoItem<'tcx>, Range<usize>>,
targets: Vec<MonoItem<'tcx>>,

// Contains one bit per mono item in the `targets` field. That bit
Expand Down Expand Up @@ -245,7 +245,7 @@ impl<'tcx> InliningMap<'tcx> {
}

let end_index = self.targets.len();
assert!(self.index.insert(source, (start_index, end_index)).is_none());
assert!(self.index.insert(source, start_index..end_index).is_none());
}

// Internally iterate over all items referenced by `source` which will be
Expand All @@ -254,9 +254,9 @@ impl<'tcx> InliningMap<'tcx> {
where
F: FnMut(MonoItem<'tcx>),
{
if let Some(&(start_index, end_index)) = self.index.get(&source) {
for (i, candidate) in self.targets[start_index..end_index].iter().enumerate() {
if self.inlines.contains(start_index + i) {
if let Some(range) = self.index.get(&source) {
for (i, candidate) in self.targets[range.clone()].iter().enumerate() {
if self.inlines.contains(range.start + i) {
f(*candidate);
}
}
Expand All @@ -268,8 +268,8 @@ impl<'tcx> InliningMap<'tcx> {
where
F: FnMut(MonoItem<'tcx>, &[MonoItem<'tcx>]),
{
for (&accessor, &(start_index, end_index)) in &self.index {
f(accessor, &self.targets[start_index..end_index])
for (&accessor, range) in &self.index {
f(accessor, &self.targets[range.clone()])
}
}
}
Expand Down
6 changes: 1 addition & 5 deletions compiler/rustc_mir/src/transform/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,11 +287,7 @@ fn mir_promoted(
// this point, before we steal the mir-const result.
// Also this means promotion can rely on all const checks having been done.
let _ = tcx.mir_const_qualif_opt_const_arg(def);
let _ = if let Some(param_did) = def.const_param_did {
tcx.mir_abstract_const_of_const_arg((def.did, param_did))
} else {
tcx.mir_abstract_const(def.did.to_def_id())
};
let _ = tcx.mir_abstract_const_opt_const_arg(def.to_global());
let mut body = tcx.mir_const(def).steal();

let mut required_consts = Vec::new();
Expand Down
14 changes: 2 additions & 12 deletions compiler/rustc_trait_selection/src/traits/const_evaluatable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,7 @@ pub fn is_const_evaluatable<'cx, 'tcx>(
if concrete.is_ok() && substs.has_param_types_or_consts() {
match infcx.tcx.def_kind(def.did) {
DefKind::AnonConst => {
let mir_body = if let Some(def) = def.as_const_arg() {
infcx.tcx.optimized_mir_of_const_arg(def)
} else {
infcx.tcx.optimized_mir(def.did)
};
let mir_body = infcx.tcx.optimized_mir_opt_const_arg(def);

if mir_body.is_polymorphic {
future_compat_lint();
Expand Down Expand Up @@ -212,13 +208,7 @@ impl AbstractConst<'tcx> {
def: ty::WithOptConstParam<DefId>,
substs: SubstsRef<'tcx>,
) -> Result<Option<AbstractConst<'tcx>>, ErrorReported> {
let inner = match (def.did.as_local(), def.const_param_did) {
(Some(did), Some(param_did)) => {
tcx.mir_abstract_const_of_const_arg((did, param_did))?
}
_ => tcx.mir_abstract_const(def.did)?,
};

let inner = tcx.mir_abstract_const_opt_const_arg(def)?;
Ok(inner.map(|inner| AbstractConst { inner, substs }))
}

Expand Down
2 changes: 1 addition & 1 deletion library/core/src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ impl<'a, 'f: 'a> DerefMut for VaList<'a, 'f> {
// within a private module. Once RFC 2145 has been implemented look into
// improving this.
mod sealed_trait {
/// Trait which permits the allowed types to be used with [VaList::arg].
/// Trait which permits the allowed types to be used with [super::VaListImpl::arg].
#[unstable(
feature = "c_variadic",
reason = "the `c_variadic` feature has not been properly tested on \
Expand Down
18 changes: 18 additions & 0 deletions library/std/src/sys/wasi/ext/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,21 @@ impl AsRawFd for io::Stderr {
sys::stdio::Stderr.as_raw_fd()
}
}

impl<'a> AsRawFd for io::StdinLock<'a> {
fn as_raw_fd(&self) -> RawFd {
sys::stdio::Stdin.as_raw_fd()
}
}

impl<'a> AsRawFd for io::StdoutLock<'a> {
fn as_raw_fd(&self) -> RawFd {
sys::stdio::Stdout.as_raw_fd()
}
}

impl<'a> AsRawFd for io::StderrLock<'a> {
fn as_raw_fd(&self) -> RawFd {
sys::stdio::Stderr.as_raw_fd()
}
}
6 changes: 3 additions & 3 deletions src/bootstrap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ handled naturally. `./configure` should almost never be used for local
installations, and is primarily useful for CI. Prefer to customize behavior
using `config.toml`.

Finally, rustbuild makes use of the [gcc-rs crate] which has [its own
Finally, rustbuild makes use of the [cc-rs crate] which has [its own
method][env-vars] of configuring C compilers and C flags via environment
variables.

[gcc-rs crate]: https://github.com/alexcrichton/gcc-rs
[env-vars]: https://github.com/alexcrichton/gcc-rs#external-configuration-via-environment-variables
[cc-rs crate]: https://github.com/alexcrichton/cc-rs
[env-vars]: https://github.com/alexcrichton/cc-rs#external-configuration-via-environment-variables

## Build stages

Expand Down
8 changes: 4 additions & 4 deletions src/bootstrap/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@

use std::env;

use bootstrap::{Build, Config, Subcommand};
use bootstrap::{Build, Config, Subcommand, VERSION};

fn main() {
let args = env::args().skip(1).collect::<Vec<_>>();
let config = Config::parse(&args);

let changelog_suggestion = check_version(&config);
// check_version warnings are not printed during setup
let changelog_suggestion =
if matches!(config.cmd, Subcommand::Setup {..}) { None } else { check_version(&config) };

// NOTE: Since `./configure` generates a `config.toml`, distro maintainers will see the
// changelog warning, not the `x.py setup` message.
Expand All @@ -40,8 +42,6 @@ fn main() {
}

fn check_version(config: &Config) -> Option<String> {
const VERSION: usize = 2;

let mut msg = String::new();

let suggestion = if let Some(seen) = config.changelog_seen {
Expand Down
2 changes: 2 additions & 0 deletions src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ const LLVM_TOOLS: &[&str] = &[
"llvm-ar", // used for creating and modifying archive files
];

pub const VERSION: usize = 2;

/// A structure representing a Rust compiler.
///
/// Each compiler has a `stage` that it is associated with and a `host` that
Expand Down
Loading