Skip to content

Commit

Permalink
Auto merge of rust-lang#59487 - Centril:rollup, r=Centril
Browse files Browse the repository at this point in the history
Rollup of 10 pull requests

Successful merges:

 - rust-lang#58717 (Add FromStr impl for NonZero types)
 - rust-lang#59091 (Combine input and eval_always query types)
 - rust-lang#59216 (Type dependent defs wrappers)
 - rust-lang#59318 (rustc: Update linker flavor inference from filename)
 - rust-lang#59320 (rustc: Allow using `clang` for wasm32 targets)
 - rust-lang#59363 (rust-lang#59361 Moved rustc edition opt to short list)
 - rust-lang#59371 (ffi: rename VaList::copy to VaList::with_copy)
 - rust-lang#59398 (Add a way to track Rustfix UI test coverage)
 - rust-lang#59408 (compiletest: make path normalization smarter)
 - rust-lang#59429 (When moving out of a for loop head, suggest borrowing it in nll mode)

Failed merges:

r? @ghost
  • Loading branch information
bors committed Mar 28, 2019
2 parents 237bf32 + 0f26958 commit 70a497a
Show file tree
Hide file tree
Showing 76 changed files with 714 additions and 443 deletions.
2 changes: 2 additions & 0 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1856,6 +1856,7 @@ mod __test {
doc_tests: DocTests::No,
bless: false,
compare_mode: None,
rustfix_coverage: false,
};

let build = Build::new(config);
Expand Down Expand Up @@ -1897,6 +1898,7 @@ mod __test {
doc_tests: DocTests::No,
bless: false,
compare_mode: None,
rustfix_coverage: false,
};

let build = Build::new(config);
Expand Down
15 changes: 15 additions & 0 deletions src/bootstrap/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ pub enum Subcommand {
rustc_args: Vec<String>,
fail_fast: bool,
doc_tests: DocTests,
rustfix_coverage: bool,
},
Bench {
paths: Vec<PathBuf>,
Expand Down Expand Up @@ -188,6 +189,12 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`"
"mode describing what file the actual ui output will be compared to",
"COMPARE MODE",
);
opts.optflag(
"",
"rustfix-coverage",
"enable this to generate a Rustfix coverage file, which is saved in \
`/<build_base>/rustfix_missing_coverage.txt`",
);
}
"bench" => {
opts.optmulti("", "test-args", "extra arguments", "ARGS");
Expand Down Expand Up @@ -363,6 +370,7 @@ Arguments:
test_args: matches.opt_strs("test-args"),
rustc_args: matches.opt_strs("rustc-args"),
fail_fast: !matches.opt_present("no-fail-fast"),
rustfix_coverage: matches.opt_present("rustfix-coverage"),
doc_tests: if matches.opt_present("doc") {
DocTests::Only
} else if matches.opt_present("no-doc") {
Expand Down Expand Up @@ -467,6 +475,13 @@ impl Subcommand {
}
}

pub fn rustfix_coverage(&self) -> bool {
match *self {
Subcommand::Test { rustfix_coverage, .. } => rustfix_coverage,
_ => false,
}
}

pub fn compare_mode(&self) -> Option<&str> {
match *self {
Subcommand::Test {
Expand Down
4 changes: 4 additions & 0 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1284,6 +1284,10 @@ impl Step for Compiletest {
cmd.arg("--android-cross-path").arg("");
}

if builder.config.cmd.rustfix_coverage() {
cmd.arg("--rustfix-coverage");
}

builder.ci_env.force_coloring_in_ci(&mut cmd);

let _folder = builder.fold_output(|| format!("test_{}", suite));
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ impl<'a> VaList<'a> {
reason = "the `c_variadic` feature has not been properly tested on \
all supported platforms",
issue = "44930")]
pub unsafe fn copy<F, R>(&self, f: F) -> R
pub unsafe fn with_copy<F, R>(&self, f: F) -> R
where F: for<'copy> FnOnce(VaList<'copy>) -> R {
#[cfg(any(all(not(target_arch = "aarch64"), not(target_arch = "powerpc"),
not(target_arch = "x86_64")),
Expand Down
24 changes: 24 additions & 0 deletions src/libcore/num/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,24 @@ nonzero_integers! {
#[stable(feature = "signed_nonzero", since = "1.34.0")] NonZeroIsize(isize);
}

macro_rules! from_str_radix_nzint_impl {
($($t:ty)*) => {$(
#[stable(feature = "nonzero_parse", since = "1.35.0")]
impl FromStr for $t {
type Err = ParseIntError;
fn from_str(src: &str) -> Result<Self, Self::Err> {
Self::new(from_str_radix(src, 10)?)
.ok_or(ParseIntError {
kind: IntErrorKind::Zero
})
}
}
)*}
}

from_str_radix_nzint_impl! { NonZeroU8 NonZeroU16 NonZeroU32 NonZeroU64 NonZeroU128 NonZeroUsize
NonZeroI8 NonZeroI16 NonZeroI32 NonZeroI64 NonZeroI128 NonZeroIsize }

/// Provides intentionally-wrapped arithmetic on `T`.
///
/// Operations like `+` on `u32` values is intended to never overflow,
Expand Down Expand Up @@ -4768,6 +4786,11 @@ pub enum IntErrorKind {
Overflow,
/// Integer is too small to store in target integer type.
Underflow,
/// Value was Zero
///
/// This variant will be emitted when the parsing string has a value of zero, which
/// would be illegal for non-zero types.
Zero,
}

impl ParseIntError {
Expand All @@ -4790,6 +4813,7 @@ impl ParseIntError {
IntErrorKind::InvalidDigit => "invalid digit found in string",
IntErrorKind::Overflow => "number too large to fit in target type",
IntErrorKind::Underflow => "number too small to fit in target type",
IntErrorKind::Zero => "number would be zero for non-zero type",
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/libcore/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#![feature(slice_internals)]
#![feature(slice_partition_dedup)]
#![feature(copy_within)]
#![feature(int_error_matching)]

extern crate core;
extern crate test;
Expand Down
26 changes: 23 additions & 3 deletions src/libcore/tests/nonzero.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use core::num::{NonZeroU32, NonZeroI32};
use core::option::Option;
use core::option::Option::{Some, None};
use core::num::{IntErrorKind, NonZeroI32, NonZeroI8, NonZeroU32, NonZeroU8};
use core::option::Option::{self, None, Some};
use std::mem::size_of;

#[test]
Expand Down Expand Up @@ -126,3 +125,24 @@ fn test_from_signed_nonzero() {
let num: i32 = nz.into();
assert_eq!(num, 1i32);
}

#[test]
fn test_from_str() {
assert_eq!("123".parse::<NonZeroU8>(), Ok(NonZeroU8::new(123).unwrap()));
assert_eq!(
"0".parse::<NonZeroU8>().err().map(|e| e.kind().clone()),
Some(IntErrorKind::Zero)
);
assert_eq!(
"-1".parse::<NonZeroU8>().err().map(|e| e.kind().clone()),
Some(IntErrorKind::InvalidDigit)
);
assert_eq!(
"-129".parse::<NonZeroI8>().err().map(|e| e.kind().clone()),
Some(IntErrorKind::Underflow)
);
assert_eq!(
"257".parse::<NonZeroU8>().err().map(|e| e.kind().clone()),
Some(IntErrorKind::Overflow)
);
}
78 changes: 30 additions & 48 deletions src/librustc/dep_graph/dep_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,6 @@ macro_rules! is_anon_attr {
($attr:ident) => (false);
}

macro_rules! is_input_attr {
(input) => (true);
($attr:ident) => (false);
}

macro_rules! is_eval_always_attr {
(eval_always) => (true);
($attr:ident) => (false);
Expand All @@ -99,10 +94,6 @@ macro_rules! contains_anon_attr {
($($attr:ident),*) => ({$(is_anon_attr!($attr) | )* false});
}

macro_rules! contains_input_attr {
($($attr:ident),*) => ({$(is_input_attr!($attr) | )* false});
}

macro_rules! contains_eval_always_attr {
($($attr:ident),*) => ({$(is_eval_always_attr!($attr) | )* false});
}
Expand Down Expand Up @@ -151,7 +142,7 @@ macro_rules! define_dep_nodes {
}
}

// FIXME: Make `is_anon`, `is_input`, `is_eval_always` and `has_params` properties
// FIXME: Make `is_anon`, `is_eval_always` and `has_params` properties
// of queries
#[inline(always)]
pub fn is_anon(&self) -> bool {
Expand All @@ -162,15 +153,6 @@ macro_rules! define_dep_nodes {
}
}

#[inline(always)]
pub fn is_input(&self) -> bool {
match *self {
$(
DepKind :: $variant => { contains_input_attr!($($attr),*) }
)*
}
}

#[inline(always)]
pub fn is_eval_always(&self) -> bool {
match *self {
Expand Down Expand Up @@ -438,17 +420,17 @@ rustc_dep_node_append!([define_dep_nodes!][ <'tcx>
// suitable wrapper, you can use `tcx.dep_graph.ignore()` to gain
// access to the krate, but you must remember to add suitable
// edges yourself for the individual items that you read.
[input] Krate,
[eval_always] Krate,

// Represents the body of a function or method. The def-id is that of the
// function/method.
[input] HirBody(DefId),
[eval_always] HirBody(DefId),

// Represents the HIR node with the given node-id
[input] Hir(DefId),
[eval_always] Hir(DefId),

// Represents metadata from an extern crate.
[input] CrateMetadata(CrateNum),
[eval_always] CrateMetadata(CrateNum),

// Represents different phases in the compiler.
[] RegionScopeTree(DefId),
Expand Down Expand Up @@ -481,7 +463,7 @@ rustc_dep_node_append!([define_dep_nodes!][ <'tcx>
[] CollectModItemTypes(DefId),

[] Reachability,
[eval_always] CrateVariances,
[] CrateVariances,

// Nodes representing bits of computed IR in the tcx. Each shared
// table in the tcx (or elsewhere) maps to one of these
Expand Down Expand Up @@ -534,7 +516,7 @@ rustc_dep_node_append!([define_dep_nodes!][ <'tcx>
// The set of impls for a given trait.
[] TraitImpls(DefId),

[input] AllLocalTraitImpls,
[eval_always] AllLocalTraitImpls,

[anon] TraitSelect,

Expand All @@ -546,7 +528,7 @@ rustc_dep_node_append!([define_dep_nodes!][ <'tcx>
// to make type debuginfo to be source location independent. Declaring
// DefSpan an input makes sure that changes to these are always detected
// regardless of HIR hashing.
[input] DefSpan(DefId),
[eval_always] DefSpan(DefId),
[] LookupStability(DefId),
[] LookupDeprecationEntry(DefId),
[] ConstIsRvaluePromotableToStatic(DefId),
Expand All @@ -564,10 +546,10 @@ rustc_dep_node_append!([define_dep_nodes!][ <'tcx>
[] IsCompilerBuiltins(CrateNum),
[] HasGlobalAllocator(CrateNum),
[] HasPanicHandler(CrateNum),
[input] ExternCrate(DefId),
[eval_always] ExternCrate(DefId),
[] Specializes { impl1: DefId, impl2: DefId },
[input] InScopeTraits(DefIndex),
[input] ModuleExports(DefId),
[eval_always] InScopeTraits(DefIndex),
[eval_always] ModuleExports(DefId),
[] IsSanitizerRuntime(CrateNum),
[] IsProfilerRuntime(CrateNum),
[] GetPanicStrategy(CrateNum),
Expand All @@ -580,10 +562,10 @@ rustc_dep_node_append!([define_dep_nodes!][ <'tcx>
[] EntryFn(CrateNum),
[] PluginRegistrarFn(CrateNum),
[] ProcMacroDeclsStatic(CrateNum),
[input] CrateDisambiguator(CrateNum),
[input] CrateHash(CrateNum),
[input] OriginalCrateName(CrateNum),
[input] ExtraFileName(CrateNum),
[eval_always] CrateDisambiguator(CrateNum),
[eval_always] CrateHash(CrateNum),
[eval_always] OriginalCrateName(CrateNum),
[eval_always] ExtraFileName(CrateNum),

[] ImplementationsOfTrait { krate: CrateNum, trait_id: DefId },
[] AllTraitImplementations(CrateNum),
Expand All @@ -592,16 +574,16 @@ rustc_dep_node_append!([define_dep_nodes!][ <'tcx>
[] IsDllimportForeignItem(DefId),
[] IsStaticallyIncludedForeignItem(DefId),
[] NativeLibraryKind(DefId),
[input] LinkArgs,
[eval_always] LinkArgs,

[] ResolveLifetimes(CrateNum),
[] NamedRegion(DefIndex),
[] IsLateBound(DefIndex),
[] ObjectLifetimeDefaults(DefIndex),

[] Visibility(DefId),
[input] DepKind(CrateNum),
[input] CrateName(CrateNum),
[eval_always] DepKind(CrateNum),
[eval_always] CrateName(CrateNum),
[] ItemChildren(DefId),
[] ExternModStmtCnum(DefId),
[eval_always] GetLibFeatures,
Expand All @@ -610,24 +592,24 @@ rustc_dep_node_append!([define_dep_nodes!][ <'tcx>
[] DefinedLangItems(CrateNum),
[] MissingLangItems(CrateNum),
[] VisibleParentMap,
[input] MissingExternCrateItem(CrateNum),
[input] UsedCrateSource(CrateNum),
[input] PostorderCnums,

[input] Freevars(DefId),
[input] MaybeUnusedTraitImport(DefId),
[input] MaybeUnusedExternCrates,
[input] NamesImportedByGlobUse(DefId),
[eval_always] MissingExternCrateItem(CrateNum),
[eval_always] UsedCrateSource(CrateNum),
[eval_always] PostorderCnums,

[eval_always] Freevars(DefId),
[eval_always] MaybeUnusedTraitImport(DefId),
[eval_always] MaybeUnusedExternCrates,
[eval_always] NamesImportedByGlobUse(DefId),
[eval_always] StabilityIndex,
[eval_always] AllTraits,
[input] AllCrateNums,
[eval_always] AllCrateNums,
[] ExportedSymbols(CrateNum),
[eval_always] CollectAndPartitionMonoItems,
[] IsCodegenedItem(DefId),
[] CodegenUnit(InternedString),
[] BackendOptimizationLevel(CrateNum),
[] CompileCodegenUnit(InternedString),
[input] OutputFilenames,
[eval_always] OutputFilenames,
[] NormalizeProjectionTy(CanonicalProjectionGoal<'tcx>),
[] NormalizeTyAfterErasingRegions(ParamEnvAnd<'tcx, Ty<'tcx>>),
[] ImpliedOutlivesBounds(CanonicalTyGoal<'tcx>),
Expand All @@ -646,11 +628,11 @@ rustc_dep_node_append!([define_dep_nodes!][ <'tcx>
[] SubstituteNormalizeAndTestPredicates { key: (DefId, SubstsRef<'tcx>) },
[] MethodAutoderefSteps(CanonicalTyGoal<'tcx>),

[input] TargetFeaturesWhitelist,
[eval_always] TargetFeaturesWhitelist,

[] InstanceDefSizeEstimate { instance_def: InstanceDef<'tcx> },

[input] Features,
[eval_always] Features,

[] ForeignModules(CrateNum),

Expand Down

0 comments on commit 70a497a

Please sign in to comment.