Skip to content

Commit

Permalink
Auto merge of rust-lang#133322 - compiler-errors:rollup-pcn90qt, r=co…
Browse files Browse the repository at this point in the history
…mpiler-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
  • Loading branch information
bors committed Nov 22, 2024
2 parents 5d3c6ee + db9f07a commit 929f899
Show file tree
Hide file tree
Showing 64 changed files with 639 additions and 385 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_abi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ impl AddAssign for Size {
#[cfg(feature = "nightly")]
impl Step for Size {
#[inline]
fn steps_between(start: &Self, end: &Self) -> Option<usize> {
fn steps_between(start: &Self, end: &Self) -> (usize, Option<usize>) {
u64::steps_between(&start.bytes(), &end.bytes())
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_index_macros/src/newtype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ impl Parse for Newtype {
#gate_rustc_only
impl ::std::iter::Step for #name {
#[inline]
fn steps_between(start: &Self, end: &Self) -> Option<usize> {
fn steps_between(start: &Self, end: &Self) -> (usize, Option<usize>) {
<usize as ::std::iter::Step>::steps_between(
&Self::index(*start),
&Self::index(*end),
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_resolve/src/late.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3940,12 +3940,12 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
}
Res::SelfCtor(_) => {
// We resolve `Self` in pattern position as an ident sometimes during recovery,
// so delay a bug instead of ICEing. (Note: is this no longer true? We now ICE. If
// this triggers, please convert to a delayed bug and add a test.)
self.r.dcx().span_bug(
// so delay a bug instead of ICEing.
self.r.dcx().span_delayed_bug(
ident.span,
"unexpected `SelfCtor` in pattern, expected identifier"
);
None
}
_ => span_bug!(
ident.span,
Expand Down
48 changes: 29 additions & 19 deletions compiler/rustc_session/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ fn build_options<O: Default>(

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

/// This is for boolean options that don't take a value and start with
/// `no-`. This style of option is deprecated.
pub(crate) fn parse_no_flag(slot: &mut bool, v: Option<&str>) -> bool {
/// This is for boolean options that don't take a value, and are true simply
/// by existing on the command-line.
///
/// This style of option is deprecated, and is mainly used by old options
/// beginning with `no-`.
pub(crate) fn parse_no_value(slot: &mut bool, v: Option<&str>) -> bool {
match v {
None => {
*slot = true;
true
}
// Trying to specify a value is always forbidden.
Some(_) => false,
}
}
Expand Down Expand Up @@ -1609,16 +1613,16 @@ options! {
"perform LLVM link-time optimizations"),
metadata: Vec<String> = (Vec::new(), parse_list, [TRACKED],
"metadata to mangle symbol names with"),
no_prepopulate_passes: bool = (false, parse_no_flag, [TRACKED],
no_prepopulate_passes: bool = (false, parse_no_value, [TRACKED],
"give an empty list of passes to the pass manager"),
no_redzone: Option<bool> = (None, parse_opt_bool, [TRACKED],
"disable the use of the redzone"),
#[rustc_lint_opt_deny_field_access("documented to do nothing")]
no_stack_check: bool = (false, parse_no_flag, [UNTRACKED],
no_stack_check: bool = (false, parse_no_value, [UNTRACKED],
"this option is deprecated and does nothing"),
no_vectorize_loops: bool = (false, parse_no_flag, [TRACKED],
no_vectorize_loops: bool = (false, parse_no_value, [TRACKED],
"disable loop vectorization optimization passes"),
no_vectorize_slp: bool = (false, parse_no_flag, [TRACKED],
no_vectorize_slp: bool = (false, parse_no_value, [TRACKED],
"disable LLVM's SLP vectorization pass"),
opt_level: String = ("0".to_string(), parse_string, [TRACKED],
"optimization level (0-3, s, or z; default: 0)"),
Expand Down Expand Up @@ -1915,25 +1919,25 @@ options! {
"dump facts from NLL analysis into side files (default: no)"),
nll_facts_dir: String = ("nll-facts".to_string(), parse_string, [UNTRACKED],
"the directory the NLL facts are dumped into (default: `nll-facts`)"),
no_analysis: bool = (false, parse_no_flag, [UNTRACKED],
no_analysis: bool = (false, parse_no_value, [UNTRACKED],
"parse and expand the source, but run no analysis"),
no_codegen: bool = (false, parse_no_flag, [TRACKED_NO_CRATE_HASH],
no_codegen: bool = (false, parse_no_value, [TRACKED_NO_CRATE_HASH],
"run all passes except codegen; no output"),
no_generate_arange_section: bool = (false, parse_no_flag, [TRACKED],
no_generate_arange_section: bool = (false, parse_no_value, [TRACKED],
"omit DWARF address ranges that give faster lookups"),
no_implied_bounds_compat: bool = (false, parse_bool, [TRACKED],
"disable the compatibility version of the `implied_bounds_ty` query"),
no_jump_tables: bool = (false, parse_no_flag, [TRACKED],
no_jump_tables: bool = (false, parse_no_value, [TRACKED],
"disable the jump tables and lookup tables that can be generated from a switch case lowering"),
no_leak_check: bool = (false, parse_no_flag, [UNTRACKED],
no_leak_check: bool = (false, parse_no_value, [UNTRACKED],
"disable the 'leak check' for subtyping; unsound, but useful for tests"),
no_link: bool = (false, parse_no_flag, [TRACKED],
no_link: bool = (false, parse_no_value, [TRACKED],
"compile without linking"),
no_parallel_backend: bool = (false, parse_no_flag, [UNTRACKED],
no_parallel_backend: bool = (false, parse_no_value, [UNTRACKED],
"run LLVM in non-parallel mode (while keeping codegen-units and ThinLTO)"),
no_profiler_runtime: bool = (false, parse_no_flag, [TRACKED],
no_profiler_runtime: bool = (false, parse_no_value, [TRACKED],
"prevent automatic injection of the profiler_builtins crate"),
no_trait_vptr: bool = (false, parse_no_flag, [TRACKED],
no_trait_vptr: bool = (false, parse_no_value, [TRACKED],
"disable generation of trait vptr in vtable for upcasting"),
no_unique_section_names: bool = (false, parse_bool, [TRACKED],
"do not use unique names for text and data sections when -Z function-sections is used"),
Expand Down Expand Up @@ -1991,7 +1995,7 @@ options! {
proc_macro_execution_strategy: ProcMacroExecutionStrategy = (ProcMacroExecutionStrategy::SameThread,
parse_proc_macro_execution_strategy, [UNTRACKED],
"how to run proc-macro code (default: same-thread)"),
profile_closures: bool = (false, parse_no_flag, [UNTRACKED],
profile_closures: bool = (false, parse_no_value, [UNTRACKED],
"profile size of closures"),
profile_sample_use: Option<PathBuf> = (None, parse_opt_pathbuf, [TRACKED],
"use the given `.prof` file for sampled profile-guided optimization (also known as AutoFDO)"),
Expand Down Expand Up @@ -2165,8 +2169,14 @@ written to standard error output)"),
"enable unsound and buggy MIR optimizations (default: no)"),
/// This name is kind of confusing: Most unstable options enable something themselves, while
/// this just allows "normal" options to be feature-gated.
///
/// The main check for `-Zunstable-options` takes place separately from the
/// usual parsing of `-Z` options (see [`crate::config::nightly_options`]),
/// so this boolean value is mostly used for enabling unstable _values_ of
/// stable options. That separate check doesn't handle boolean values, so
/// to avoid an inconsistent state we also forbid them here.
#[rustc_lint_opt_deny_field_access("use `Session::unstable_options` instead of this field")]
unstable_options: bool = (false, parse_bool, [UNTRACKED],
unstable_options: bool = (false, parse_no_value, [UNTRACKED],
"adds unstable command line options to rustc interface (default: no)"),
use_ctors_section: Option<bool> = (None, parse_opt_bool, [TRACKED],
"use legacy .ctors section for initializers rather than .init_array"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
} else if tcx.is_lang_item(def_id, LangItem::Sized) {
// Sized is never implementable by end-users, it is
// always automatically computed.

// FIXME: Consider moving this check to the top level as it
// may also be useful for predicates other than `Sized`
// Error type cannot possibly implement `Sized` (fixes #123154)
if let Err(e) = obligation.predicate.skip_binder().self_ty().error_reported() {
return Err(SelectionError::Overflow(e.into()));
}

let sized_conditions = self.sized_conditions(obligation);
self.assemble_builtin_bound_candidates(sized_conditions, &mut candidates);
} else if tcx.is_lang_item(def_id, LangItem::Unsize) {
Expand Down Expand Up @@ -230,13 +222,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
) -> Result<(), SelectionError<'tcx>> {
debug!(?stack.obligation);

// An error type will unify with anything. So, avoid
// matching an error type with `ParamCandidate`.
// This helps us avoid spurious errors like issue #121941.
if stack.obligation.predicate.references_error() {
return Ok(());
}

let bounds = stack
.obligation
.param_env
Expand Down Expand Up @@ -563,19 +548,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
obligation: &PolyTraitObligation<'tcx>,
candidates: &mut SelectionCandidateSet<'tcx>,
) {
// Essentially any user-written impl will match with an error type,
// so creating `ImplCandidates` isn't useful. However, we might
// end up finding a candidate elsewhere (e.g. a `BuiltinCandidate` for `Sized`)
// This helps us avoid overflow: see issue #72839
// Since compilation is already guaranteed to fail, this is just
// to try to show the 'nicest' possible errors to the user.
// We don't check for errors in the `ParamEnv` - in practice,
// it seems to cause us to be overly aggressive in deciding
// to give up searching for candidates, leading to spurious errors.
if obligation.predicate.references_error() {
return;
}

let drcx = DeepRejectCtxt::relate_rigid_infer(self.tcx());
let obligation_args = obligation.predicate.skip_binder().trait_ref.args;
self.tcx().for_each_relevant_impl(
Expand Down
4 changes: 0 additions & 4 deletions compiler/rustc_trait_selection/src/traits/select/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2487,10 +2487,6 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
let impl_args = self.infcx.fresh_args_for_item(obligation.cause.span, impl_def_id);

let trait_ref = impl_trait_header.trait_ref.instantiate(self.tcx(), impl_args);
if trait_ref.references_error() {
return Err(());
}

debug!(?impl_trait_header);

let Normalized { value: impl_trait_ref, obligations: mut nested_obligations } =
Expand Down
6 changes: 1 addition & 5 deletions compiler/rustc_ty_utils/src/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ use rustc_index::bit_set::BitSet;
use rustc_middle::bug;
use rustc_middle::query::Providers;
use rustc_middle::ty::{
self, EarlyBinder, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitableExt,
TypeVisitor, Upcast,
self, EarlyBinder, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitor, Upcast,
};
use rustc_span::DUMMY_SP;
use rustc_span::def_id::{CRATE_DEF_ID, DefId, LocalDefId};
Expand Down Expand Up @@ -95,9 +94,6 @@ fn adt_sized_constraint<'tcx>(
let tail_ty = tcx.type_of(tail_def.did).instantiate_identity();

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

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

0 comments on commit 929f899

Please sign in to comment.