Skip to content

Commit 70a497a

Browse files
committed
Auto merge of #59487 - Centril:rollup, r=Centril
Rollup of 10 pull requests Successful merges: - #58717 (Add FromStr impl for NonZero types) - #59091 (Combine input and eval_always query types) - #59216 (Type dependent defs wrappers) - #59318 (rustc: Update linker flavor inference from filename) - #59320 (rustc: Allow using `clang` for wasm32 targets) - #59363 (#59361 Moved rustc edition opt to short list) - #59371 (ffi: rename VaList::copy to VaList::with_copy) - #59398 (Add a way to track Rustfix UI test coverage) - #59408 (compiletest: make path normalization smarter) - #59429 (When moving out of a for loop head, suggest borrowing it in nll mode) Failed merges: r? @ghost
2 parents 237bf32 + 0f26958 commit 70a497a

File tree

76 files changed

+714
-443
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+714
-443
lines changed

src/bootstrap/builder.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1856,6 +1856,7 @@ mod __test {
18561856
doc_tests: DocTests::No,
18571857
bless: false,
18581858
compare_mode: None,
1859+
rustfix_coverage: false,
18591860
};
18601861

18611862
let build = Build::new(config);
@@ -1897,6 +1898,7 @@ mod __test {
18971898
doc_tests: DocTests::No,
18981899
bless: false,
18991900
compare_mode: None,
1901+
rustfix_coverage: false,
19001902
};
19011903

19021904
let build = Build::new(config);

src/bootstrap/flags.rs

+15
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ pub enum Subcommand {
5656
rustc_args: Vec<String>,
5757
fail_fast: bool,
5858
doc_tests: DocTests,
59+
rustfix_coverage: bool,
5960
},
6061
Bench {
6162
paths: Vec<PathBuf>,
@@ -188,6 +189,12 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`"
188189
"mode describing what file the actual ui output will be compared to",
189190
"COMPARE MODE",
190191
);
192+
opts.optflag(
193+
"",
194+
"rustfix-coverage",
195+
"enable this to generate a Rustfix coverage file, which is saved in \
196+
`/<build_base>/rustfix_missing_coverage.txt`",
197+
);
191198
}
192199
"bench" => {
193200
opts.optmulti("", "test-args", "extra arguments", "ARGS");
@@ -363,6 +370,7 @@ Arguments:
363370
test_args: matches.opt_strs("test-args"),
364371
rustc_args: matches.opt_strs("rustc-args"),
365372
fail_fast: !matches.opt_present("no-fail-fast"),
373+
rustfix_coverage: matches.opt_present("rustfix-coverage"),
366374
doc_tests: if matches.opt_present("doc") {
367375
DocTests::Only
368376
} else if matches.opt_present("no-doc") {
@@ -467,6 +475,13 @@ impl Subcommand {
467475
}
468476
}
469477

478+
pub fn rustfix_coverage(&self) -> bool {
479+
match *self {
480+
Subcommand::Test { rustfix_coverage, .. } => rustfix_coverage,
481+
_ => false,
482+
}
483+
}
484+
470485
pub fn compare_mode(&self) -> Option<&str> {
471486
match *self {
472487
Subcommand::Test {

src/bootstrap/test.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1284,6 +1284,10 @@ impl Step for Compiletest {
12841284
cmd.arg("--android-cross-path").arg("");
12851285
}
12861286

1287+
if builder.config.cmd.rustfix_coverage() {
1288+
cmd.arg("--rustfix-coverage");
1289+
}
1290+
12871291
builder.ci_env.force_coloring_in_ci(&mut cmd);
12881292

12891293
let _folder = builder.fold_output(|| format!("test_{}", suite));

src/libcore/ffi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ impl<'a> VaList<'a> {
190190
reason = "the `c_variadic` feature has not been properly tested on \
191191
all supported platforms",
192192
issue = "44930")]
193-
pub unsafe fn copy<F, R>(&self, f: F) -> R
193+
pub unsafe fn with_copy<F, R>(&self, f: F) -> R
194194
where F: for<'copy> FnOnce(VaList<'copy>) -> R {
195195
#[cfg(any(all(not(target_arch = "aarch64"), not(target_arch = "powerpc"),
196196
not(target_arch = "x86_64")),

src/libcore/num/mod.rs

+24
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,24 @@ nonzero_integers! {
112112
#[stable(feature = "signed_nonzero", since = "1.34.0")] NonZeroIsize(isize);
113113
}
114114

115+
macro_rules! from_str_radix_nzint_impl {
116+
($($t:ty)*) => {$(
117+
#[stable(feature = "nonzero_parse", since = "1.35.0")]
118+
impl FromStr for $t {
119+
type Err = ParseIntError;
120+
fn from_str(src: &str) -> Result<Self, Self::Err> {
121+
Self::new(from_str_radix(src, 10)?)
122+
.ok_or(ParseIntError {
123+
kind: IntErrorKind::Zero
124+
})
125+
}
126+
}
127+
)*}
128+
}
129+
130+
from_str_radix_nzint_impl! { NonZeroU8 NonZeroU16 NonZeroU32 NonZeroU64 NonZeroU128 NonZeroUsize
131+
NonZeroI8 NonZeroI16 NonZeroI32 NonZeroI64 NonZeroI128 NonZeroIsize }
132+
115133
/// Provides intentionally-wrapped arithmetic on `T`.
116134
///
117135
/// Operations like `+` on `u32` values is intended to never overflow,
@@ -4768,6 +4786,11 @@ pub enum IntErrorKind {
47684786
Overflow,
47694787
/// Integer is too small to store in target integer type.
47704788
Underflow,
4789+
/// Value was Zero
4790+
///
4791+
/// This variant will be emitted when the parsing string has a value of zero, which
4792+
/// would be illegal for non-zero types.
4793+
Zero,
47714794
}
47724795

47734796
impl ParseIntError {
@@ -4790,6 +4813,7 @@ impl ParseIntError {
47904813
IntErrorKind::InvalidDigit => "invalid digit found in string",
47914814
IntErrorKind::Overflow => "number too large to fit in target type",
47924815
IntErrorKind::Underflow => "number too small to fit in target type",
4816+
IntErrorKind::Zero => "number would be zero for non-zero type",
47934817
}
47944818
}
47954819
}

src/libcore/tests/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#![feature(slice_internals)]
3232
#![feature(slice_partition_dedup)]
3333
#![feature(copy_within)]
34+
#![feature(int_error_matching)]
3435

3536
extern crate core;
3637
extern crate test;

src/libcore/tests/nonzero.rs

+23-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
use core::num::{NonZeroU32, NonZeroI32};
2-
use core::option::Option;
3-
use core::option::Option::{Some, None};
1+
use core::num::{IntErrorKind, NonZeroI32, NonZeroI8, NonZeroU32, NonZeroU8};
2+
use core::option::Option::{self, None, Some};
43
use std::mem::size_of;
54

65
#[test]
@@ -126,3 +125,24 @@ fn test_from_signed_nonzero() {
126125
let num: i32 = nz.into();
127126
assert_eq!(num, 1i32);
128127
}
128+
129+
#[test]
130+
fn test_from_str() {
131+
assert_eq!("123".parse::<NonZeroU8>(), Ok(NonZeroU8::new(123).unwrap()));
132+
assert_eq!(
133+
"0".parse::<NonZeroU8>().err().map(|e| e.kind().clone()),
134+
Some(IntErrorKind::Zero)
135+
);
136+
assert_eq!(
137+
"-1".parse::<NonZeroU8>().err().map(|e| e.kind().clone()),
138+
Some(IntErrorKind::InvalidDigit)
139+
);
140+
assert_eq!(
141+
"-129".parse::<NonZeroI8>().err().map(|e| e.kind().clone()),
142+
Some(IntErrorKind::Underflow)
143+
);
144+
assert_eq!(
145+
"257".parse::<NonZeroU8>().err().map(|e| e.kind().clone()),
146+
Some(IntErrorKind::Overflow)
147+
);
148+
}

src/librustc/dep_graph/dep_node.rs

+30-48
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,6 @@ macro_rules! is_anon_attr {
8585
($attr:ident) => (false);
8686
}
8787

88-
macro_rules! is_input_attr {
89-
(input) => (true);
90-
($attr:ident) => (false);
91-
}
92-
9388
macro_rules! is_eval_always_attr {
9489
(eval_always) => (true);
9590
($attr:ident) => (false);
@@ -99,10 +94,6 @@ macro_rules! contains_anon_attr {
9994
($($attr:ident),*) => ({$(is_anon_attr!($attr) | )* false});
10095
}
10196

102-
macro_rules! contains_input_attr {
103-
($($attr:ident),*) => ({$(is_input_attr!($attr) | )* false});
104-
}
105-
10697
macro_rules! contains_eval_always_attr {
10798
($($attr:ident),*) => ({$(is_eval_always_attr!($attr) | )* false});
10899
}
@@ -151,7 +142,7 @@ macro_rules! define_dep_nodes {
151142
}
152143
}
153144

154-
// FIXME: Make `is_anon`, `is_input`, `is_eval_always` and `has_params` properties
145+
// FIXME: Make `is_anon`, `is_eval_always` and `has_params` properties
155146
// of queries
156147
#[inline(always)]
157148
pub fn is_anon(&self) -> bool {
@@ -162,15 +153,6 @@ macro_rules! define_dep_nodes {
162153
}
163154
}
164155

165-
#[inline(always)]
166-
pub fn is_input(&self) -> bool {
167-
match *self {
168-
$(
169-
DepKind :: $variant => { contains_input_attr!($($attr),*) }
170-
)*
171-
}
172-
}
173-
174156
#[inline(always)]
175157
pub fn is_eval_always(&self) -> bool {
176158
match *self {
@@ -438,17 +420,17 @@ rustc_dep_node_append!([define_dep_nodes!][ <'tcx>
438420
// suitable wrapper, you can use `tcx.dep_graph.ignore()` to gain
439421
// access to the krate, but you must remember to add suitable
440422
// edges yourself for the individual items that you read.
441-
[input] Krate,
423+
[eval_always] Krate,
442424

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

447429
// Represents the HIR node with the given node-id
448-
[input] Hir(DefId),
430+
[eval_always] Hir(DefId),
449431

450432
// Represents metadata from an extern crate.
451-
[input] CrateMetadata(CrateNum),
433+
[eval_always] CrateMetadata(CrateNum),
452434

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

483465
[] Reachability,
484-
[eval_always] CrateVariances,
466+
[] CrateVariances,
485467

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

537-
[input] AllLocalTraitImpls,
519+
[eval_always] AllLocalTraitImpls,
538520

539521
[anon] TraitSelect,
540522

@@ -546,7 +528,7 @@ rustc_dep_node_append!([define_dep_nodes!][ <'tcx>
546528
// to make type debuginfo to be source location independent. Declaring
547529
// DefSpan an input makes sure that changes to these are always detected
548530
// regardless of HIR hashing.
549-
[input] DefSpan(DefId),
531+
[eval_always] DefSpan(DefId),
550532
[] LookupStability(DefId),
551533
[] LookupDeprecationEntry(DefId),
552534
[] ConstIsRvaluePromotableToStatic(DefId),
@@ -564,10 +546,10 @@ rustc_dep_node_append!([define_dep_nodes!][ <'tcx>
564546
[] IsCompilerBuiltins(CrateNum),
565547
[] HasGlobalAllocator(CrateNum),
566548
[] HasPanicHandler(CrateNum),
567-
[input] ExternCrate(DefId),
549+
[eval_always] ExternCrate(DefId),
568550
[] Specializes { impl1: DefId, impl2: DefId },
569-
[input] InScopeTraits(DefIndex),
570-
[input] ModuleExports(DefId),
551+
[eval_always] InScopeTraits(DefIndex),
552+
[eval_always] ModuleExports(DefId),
571553
[] IsSanitizerRuntime(CrateNum),
572554
[] IsProfilerRuntime(CrateNum),
573555
[] GetPanicStrategy(CrateNum),
@@ -580,10 +562,10 @@ rustc_dep_node_append!([define_dep_nodes!][ <'tcx>
580562
[] EntryFn(CrateNum),
581563
[] PluginRegistrarFn(CrateNum),
582564
[] ProcMacroDeclsStatic(CrateNum),
583-
[input] CrateDisambiguator(CrateNum),
584-
[input] CrateHash(CrateNum),
585-
[input] OriginalCrateName(CrateNum),
586-
[input] ExtraFileName(CrateNum),
565+
[eval_always] CrateDisambiguator(CrateNum),
566+
[eval_always] CrateHash(CrateNum),
567+
[eval_always] OriginalCrateName(CrateNum),
568+
[eval_always] ExtraFileName(CrateNum),
587569

588570
[] ImplementationsOfTrait { krate: CrateNum, trait_id: DefId },
589571
[] AllTraitImplementations(CrateNum),
@@ -592,16 +574,16 @@ rustc_dep_node_append!([define_dep_nodes!][ <'tcx>
592574
[] IsDllimportForeignItem(DefId),
593575
[] IsStaticallyIncludedForeignItem(DefId),
594576
[] NativeLibraryKind(DefId),
595-
[input] LinkArgs,
577+
[eval_always] LinkArgs,
596578

597579
[] ResolveLifetimes(CrateNum),
598580
[] NamedRegion(DefIndex),
599581
[] IsLateBound(DefIndex),
600582
[] ObjectLifetimeDefaults(DefIndex),
601583

602584
[] Visibility(DefId),
603-
[input] DepKind(CrateNum),
604-
[input] CrateName(CrateNum),
585+
[eval_always] DepKind(CrateNum),
586+
[eval_always] CrateName(CrateNum),
605587
[] ItemChildren(DefId),
606588
[] ExternModStmtCnum(DefId),
607589
[eval_always] GetLibFeatures,
@@ -610,24 +592,24 @@ rustc_dep_node_append!([define_dep_nodes!][ <'tcx>
610592
[] DefinedLangItems(CrateNum),
611593
[] MissingLangItems(CrateNum),
612594
[] VisibleParentMap,
613-
[input] MissingExternCrateItem(CrateNum),
614-
[input] UsedCrateSource(CrateNum),
615-
[input] PostorderCnums,
616-
617-
[input] Freevars(DefId),
618-
[input] MaybeUnusedTraitImport(DefId),
619-
[input] MaybeUnusedExternCrates,
620-
[input] NamesImportedByGlobUse(DefId),
595+
[eval_always] MissingExternCrateItem(CrateNum),
596+
[eval_always] UsedCrateSource(CrateNum),
597+
[eval_always] PostorderCnums,
598+
599+
[eval_always] Freevars(DefId),
600+
[eval_always] MaybeUnusedTraitImport(DefId),
601+
[eval_always] MaybeUnusedExternCrates,
602+
[eval_always] NamesImportedByGlobUse(DefId),
621603
[eval_always] StabilityIndex,
622604
[eval_always] AllTraits,
623-
[input] AllCrateNums,
605+
[eval_always] AllCrateNums,
624606
[] ExportedSymbols(CrateNum),
625607
[eval_always] CollectAndPartitionMonoItems,
626608
[] IsCodegenedItem(DefId),
627609
[] CodegenUnit(InternedString),
628610
[] BackendOptimizationLevel(CrateNum),
629611
[] CompileCodegenUnit(InternedString),
630-
[input] OutputFilenames,
612+
[eval_always] OutputFilenames,
631613
[] NormalizeProjectionTy(CanonicalProjectionGoal<'tcx>),
632614
[] NormalizeTyAfterErasingRegions(ParamEnvAnd<'tcx, Ty<'tcx>>),
633615
[] ImpliedOutlivesBounds(CanonicalTyGoal<'tcx>),
@@ -646,11 +628,11 @@ rustc_dep_node_append!([define_dep_nodes!][ <'tcx>
646628
[] SubstituteNormalizeAndTestPredicates { key: (DefId, SubstsRef<'tcx>) },
647629
[] MethodAutoderefSteps(CanonicalTyGoal<'tcx>),
648630

649-
[input] TargetFeaturesWhitelist,
631+
[eval_always] TargetFeaturesWhitelist,
650632

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

653-
[input] Features,
635+
[eval_always] Features,
654636

655637
[] ForeignModules(CrateNum),
656638

0 commit comments

Comments
 (0)