Skip to content

Commit 7a4cf71

Browse files
committed
Auto merge of rust-lang#133322 - compiler-errors:rollup-pcn90qt, r=compiler-errors
Rollup of 9 pull requests Successful merges: - rust-lang#129238 (Stabilize `Ipv6Addr::is_unique_local` and `Ipv6Addr::is_unicast_link_local`) - rust-lang#130867 (distinguish overflow and unimplemented in Step::steps_between) - rust-lang#131505 (use `confstr(_CS_DARWIN_USER_TEMP_DIR, ...)` as a `TMPDIR` fallback on Darwin) - rust-lang#132090 (Stop being so bail-y in candidate assembly) - rust-lang#133159 (Don't allow `-Zunstable-options` to take a value ) - rust-lang#133215 (Fix missing submodule in `./x vendor`) - rust-lang#133286 (Re-delay a resolve `bug` related to `Self`-ctor in patterns) - rust-lang#133301 (Add code example for `wrapping_neg` method for signed integers) - rust-lang#133313 (Use arc4random of libc for RTEMS target) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 5d3c6ee + db9f07a commit 7a4cf71

File tree

64 files changed

+639
-385
lines changed

Some content is hidden

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

64 files changed

+639
-385
lines changed

compiler/rustc_abi/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ impl AddAssign for Size {
638638
#[cfg(feature = "nightly")]
639639
impl Step for Size {
640640
#[inline]
641-
fn steps_between(start: &Self, end: &Self) -> Option<usize> {
641+
fn steps_between(start: &Self, end: &Self) -> (usize, Option<usize>) {
642642
u64::steps_between(&start.bytes(), &end.bytes())
643643
}
644644

compiler/rustc_index_macros/src/newtype.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ impl Parse for Newtype {
122122
#gate_rustc_only
123123
impl ::std::iter::Step for #name {
124124
#[inline]
125-
fn steps_between(start: &Self, end: &Self) -> Option<usize> {
125+
fn steps_between(start: &Self, end: &Self) -> (usize, Option<usize>) {
126126
<usize as ::std::iter::Step>::steps_between(
127127
&Self::index(*start),
128128
&Self::index(*end),

compiler/rustc_resolve/src/late.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -3940,12 +3940,12 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
39403940
}
39413941
Res::SelfCtor(_) => {
39423942
// We resolve `Self` in pattern position as an ident sometimes during recovery,
3943-
// so delay a bug instead of ICEing. (Note: is this no longer true? We now ICE. If
3944-
// this triggers, please convert to a delayed bug and add a test.)
3945-
self.r.dcx().span_bug(
3943+
// so delay a bug instead of ICEing.
3944+
self.r.dcx().span_delayed_bug(
39463945
ident.span,
39473946
"unexpected `SelfCtor` in pattern, expected identifier"
39483947
);
3948+
None
39493949
}
39503950
_ => span_bug!(
39513951
ident.span,

compiler/rustc_session/src/options.rs

+29-19
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ fn build_options<O: Default>(
358358

359359
#[allow(non_upper_case_globals)]
360360
mod desc {
361-
pub(crate) const parse_no_flag: &str = "no value";
361+
pub(crate) const parse_no_value: &str = "no value";
362362
pub(crate) const parse_bool: &str =
363363
"one of: `y`, `yes`, `on`, `true`, `n`, `no`, `off` or `false`";
364364
pub(crate) const parse_opt_bool: &str = parse_bool;
@@ -462,14 +462,18 @@ pub mod parse {
462462
pub(crate) use super::*;
463463
pub(crate) const MAX_THREADS_CAP: usize = 256;
464464

465-
/// This is for boolean options that don't take a value and start with
466-
/// `no-`. This style of option is deprecated.
467-
pub(crate) fn parse_no_flag(slot: &mut bool, v: Option<&str>) -> bool {
465+
/// This is for boolean options that don't take a value, and are true simply
466+
/// by existing on the command-line.
467+
///
468+
/// This style of option is deprecated, and is mainly used by old options
469+
/// beginning with `no-`.
470+
pub(crate) fn parse_no_value(slot: &mut bool, v: Option<&str>) -> bool {
468471
match v {
469472
None => {
470473
*slot = true;
471474
true
472475
}
476+
// Trying to specify a value is always forbidden.
473477
Some(_) => false,
474478
}
475479
}
@@ -1609,16 +1613,16 @@ options! {
16091613
"perform LLVM link-time optimizations"),
16101614
metadata: Vec<String> = (Vec::new(), parse_list, [TRACKED],
16111615
"metadata to mangle symbol names with"),
1612-
no_prepopulate_passes: bool = (false, parse_no_flag, [TRACKED],
1616+
no_prepopulate_passes: bool = (false, parse_no_value, [TRACKED],
16131617
"give an empty list of passes to the pass manager"),
16141618
no_redzone: Option<bool> = (None, parse_opt_bool, [TRACKED],
16151619
"disable the use of the redzone"),
16161620
#[rustc_lint_opt_deny_field_access("documented to do nothing")]
1617-
no_stack_check: bool = (false, parse_no_flag, [UNTRACKED],
1621+
no_stack_check: bool = (false, parse_no_value, [UNTRACKED],
16181622
"this option is deprecated and does nothing"),
1619-
no_vectorize_loops: bool = (false, parse_no_flag, [TRACKED],
1623+
no_vectorize_loops: bool = (false, parse_no_value, [TRACKED],
16201624
"disable loop vectorization optimization passes"),
1621-
no_vectorize_slp: bool = (false, parse_no_flag, [TRACKED],
1625+
no_vectorize_slp: bool = (false, parse_no_value, [TRACKED],
16221626
"disable LLVM's SLP vectorization pass"),
16231627
opt_level: String = ("0".to_string(), parse_string, [TRACKED],
16241628
"optimization level (0-3, s, or z; default: 0)"),
@@ -1915,25 +1919,25 @@ options! {
19151919
"dump facts from NLL analysis into side files (default: no)"),
19161920
nll_facts_dir: String = ("nll-facts".to_string(), parse_string, [UNTRACKED],
19171921
"the directory the NLL facts are dumped into (default: `nll-facts`)"),
1918-
no_analysis: bool = (false, parse_no_flag, [UNTRACKED],
1922+
no_analysis: bool = (false, parse_no_value, [UNTRACKED],
19191923
"parse and expand the source, but run no analysis"),
1920-
no_codegen: bool = (false, parse_no_flag, [TRACKED_NO_CRATE_HASH],
1924+
no_codegen: bool = (false, parse_no_value, [TRACKED_NO_CRATE_HASH],
19211925
"run all passes except codegen; no output"),
1922-
no_generate_arange_section: bool = (false, parse_no_flag, [TRACKED],
1926+
no_generate_arange_section: bool = (false, parse_no_value, [TRACKED],
19231927
"omit DWARF address ranges that give faster lookups"),
19241928
no_implied_bounds_compat: bool = (false, parse_bool, [TRACKED],
19251929
"disable the compatibility version of the `implied_bounds_ty` query"),
1926-
no_jump_tables: bool = (false, parse_no_flag, [TRACKED],
1930+
no_jump_tables: bool = (false, parse_no_value, [TRACKED],
19271931
"disable the jump tables and lookup tables that can be generated from a switch case lowering"),
1928-
no_leak_check: bool = (false, parse_no_flag, [UNTRACKED],
1932+
no_leak_check: bool = (false, parse_no_value, [UNTRACKED],
19291933
"disable the 'leak check' for subtyping; unsound, but useful for tests"),
1930-
no_link: bool = (false, parse_no_flag, [TRACKED],
1934+
no_link: bool = (false, parse_no_value, [TRACKED],
19311935
"compile without linking"),
1932-
no_parallel_backend: bool = (false, parse_no_flag, [UNTRACKED],
1936+
no_parallel_backend: bool = (false, parse_no_value, [UNTRACKED],
19331937
"run LLVM in non-parallel mode (while keeping codegen-units and ThinLTO)"),
1934-
no_profiler_runtime: bool = (false, parse_no_flag, [TRACKED],
1938+
no_profiler_runtime: bool = (false, parse_no_value, [TRACKED],
19351939
"prevent automatic injection of the profiler_builtins crate"),
1936-
no_trait_vptr: bool = (false, parse_no_flag, [TRACKED],
1940+
no_trait_vptr: bool = (false, parse_no_value, [TRACKED],
19371941
"disable generation of trait vptr in vtable for upcasting"),
19381942
no_unique_section_names: bool = (false, parse_bool, [TRACKED],
19391943
"do not use unique names for text and data sections when -Z function-sections is used"),
@@ -1991,7 +1995,7 @@ options! {
19911995
proc_macro_execution_strategy: ProcMacroExecutionStrategy = (ProcMacroExecutionStrategy::SameThread,
19921996
parse_proc_macro_execution_strategy, [UNTRACKED],
19931997
"how to run proc-macro code (default: same-thread)"),
1994-
profile_closures: bool = (false, parse_no_flag, [UNTRACKED],
1998+
profile_closures: bool = (false, parse_no_value, [UNTRACKED],
19951999
"profile size of closures"),
19962000
profile_sample_use: Option<PathBuf> = (None, parse_opt_pathbuf, [TRACKED],
19972001
"use the given `.prof` file for sampled profile-guided optimization (also known as AutoFDO)"),
@@ -2165,8 +2169,14 @@ written to standard error output)"),
21652169
"enable unsound and buggy MIR optimizations (default: no)"),
21662170
/// This name is kind of confusing: Most unstable options enable something themselves, while
21672171
/// this just allows "normal" options to be feature-gated.
2172+
///
2173+
/// The main check for `-Zunstable-options` takes place separately from the
2174+
/// usual parsing of `-Z` options (see [`crate::config::nightly_options`]),
2175+
/// so this boolean value is mostly used for enabling unstable _values_ of
2176+
/// stable options. That separate check doesn't handle boolean values, so
2177+
/// to avoid an inconsistent state we also forbid them here.
21682178
#[rustc_lint_opt_deny_field_access("use `Session::unstable_options` instead of this field")]
2169-
unstable_options: bool = (false, parse_bool, [UNTRACKED],
2179+
unstable_options: bool = (false, parse_no_value, [UNTRACKED],
21702180
"adds unstable command line options to rustc interface (default: no)"),
21712181
use_ctors_section: Option<bool> = (None, parse_opt_bool, [TRACKED],
21722182
"use legacy .ctors section for initializers rather than .init_array"),

compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs

-28
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
9191
} else if tcx.is_lang_item(def_id, LangItem::Sized) {
9292
// Sized is never implementable by end-users, it is
9393
// always automatically computed.
94-
95-
// FIXME: Consider moving this check to the top level as it
96-
// may also be useful for predicates other than `Sized`
97-
// Error type cannot possibly implement `Sized` (fixes #123154)
98-
if let Err(e) = obligation.predicate.skip_binder().self_ty().error_reported() {
99-
return Err(SelectionError::Overflow(e.into()));
100-
}
101-
10294
let sized_conditions = self.sized_conditions(obligation);
10395
self.assemble_builtin_bound_candidates(sized_conditions, &mut candidates);
10496
} else if tcx.is_lang_item(def_id, LangItem::Unsize) {
@@ -230,13 +222,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
230222
) -> Result<(), SelectionError<'tcx>> {
231223
debug!(?stack.obligation);
232224

233-
// An error type will unify with anything. So, avoid
234-
// matching an error type with `ParamCandidate`.
235-
// This helps us avoid spurious errors like issue #121941.
236-
if stack.obligation.predicate.references_error() {
237-
return Ok(());
238-
}
239-
240225
let bounds = stack
241226
.obligation
242227
.param_env
@@ -563,19 +548,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
563548
obligation: &PolyTraitObligation<'tcx>,
564549
candidates: &mut SelectionCandidateSet<'tcx>,
565550
) {
566-
// Essentially any user-written impl will match with an error type,
567-
// so creating `ImplCandidates` isn't useful. However, we might
568-
// end up finding a candidate elsewhere (e.g. a `BuiltinCandidate` for `Sized`)
569-
// This helps us avoid overflow: see issue #72839
570-
// Since compilation is already guaranteed to fail, this is just
571-
// to try to show the 'nicest' possible errors to the user.
572-
// We don't check for errors in the `ParamEnv` - in practice,
573-
// it seems to cause us to be overly aggressive in deciding
574-
// to give up searching for candidates, leading to spurious errors.
575-
if obligation.predicate.references_error() {
576-
return;
577-
}
578-
579551
let drcx = DeepRejectCtxt::relate_rigid_infer(self.tcx());
580552
let obligation_args = obligation.predicate.skip_binder().trait_ref.args;
581553
self.tcx().for_each_relevant_impl(

compiler/rustc_trait_selection/src/traits/select/mod.rs

-4
Original file line numberDiff line numberDiff line change
@@ -2487,10 +2487,6 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
24872487
let impl_args = self.infcx.fresh_args_for_item(obligation.cause.span, impl_def_id);
24882488

24892489
let trait_ref = impl_trait_header.trait_ref.instantiate(self.tcx(), impl_args);
2490-
if trait_ref.references_error() {
2491-
return Err(());
2492-
}
2493-
24942490
debug!(?impl_trait_header);
24952491

24962492
let Normalized { value: impl_trait_ref, obligations: mut nested_obligations } =

compiler/rustc_ty_utils/src/ty.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ use rustc_index::bit_set::BitSet;
66
use rustc_middle::bug;
77
use rustc_middle::query::Providers;
88
use rustc_middle::ty::{
9-
self, EarlyBinder, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitableExt,
10-
TypeVisitor, Upcast,
9+
self, EarlyBinder, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitor, Upcast,
1110
};
1211
use rustc_span::DUMMY_SP;
1312
use rustc_span::def_id::{CRATE_DEF_ID, DefId, LocalDefId};
@@ -95,9 +94,6 @@ fn adt_sized_constraint<'tcx>(
9594
let tail_ty = tcx.type_of(tail_def.did).instantiate_identity();
9695

9796
let constraint_ty = sized_constraint_for_ty(tcx, tail_ty)?;
98-
if let Err(guar) = constraint_ty.error_reported() {
99-
return Some(ty::EarlyBinder::bind(Ty::new_error(tcx, guar)));
100-
}
10197

10298
// perf hack: if there is a `constraint_ty: Sized` bound, then we know
10399
// that the type is sized and do not need to check it on the impl.

0 commit comments

Comments
 (0)