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 5 pull requests #99127

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
38 changes: 33 additions & 5 deletions compiler/rustc_borrowck/src/region_infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
/// The idea then is to lower the `T: 'X` constraint into multiple
/// bounds -- e.g., if `'X` is the union of two free lifetimes,
/// `'1` and `'2`, then we would create `T: '1` and `T: '2`.
#[instrument(level = "debug", skip(self, infcx, propagated_outlives_requirements))]
fn try_promote_type_test(
&self,
infcx: &InferCtxt<'_, 'tcx>,
Expand All @@ -934,11 +935,41 @@ impl<'tcx> RegionInferenceContext<'tcx> {
return false;
};

debug!("subject = {:?}", subject);

let r_scc = self.constraint_sccs.scc(*lower_bound);

debug!(
"lower_bound = {:?} r_scc={:?} universe={:?}",
lower_bound, r_scc, self.scc_universes[r_scc]
);

// If the type test requires that `T: 'a` where `'a` is a
// placeholder from another universe, that effectively requires
// `T: 'static`, so we have to propagate that requirement.
//
// It doesn't matter *what* universe because the promoted `T` will
// always be in the root universe.
if let Some(p) = self.scc_values.placeholders_contained_in(r_scc).next() {
debug!("encountered placeholder in higher universe: {:?}, requiring 'static", p);
let static_r = self.universal_regions.fr_static;
propagated_outlives_requirements.push(ClosureOutlivesRequirement {
subject,
outlived_free_region: static_r,
blame_span: locations.span(body),
category: ConstraintCategory::Boring,
});

// we can return here -- the code below might push add'l constraints
// but they would all be weaker than this one.
return true;
}

// For each region outlived by lower_bound find a non-local,
// universal region (it may be the same region) and add it to
// `ClosureOutlivesRequirement`.
let r_scc = self.constraint_sccs.scc(*lower_bound);
for ur in self.scc_values.universal_regions_outlived_by(r_scc) {
debug!("universal_region_outlived_by ur={:?}", ur);
// Check whether we can already prove that the "subject" outlives `ur`.
// If so, we don't have to propagate this requirement to our caller.
//
Expand All @@ -963,8 +994,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
continue;
}

debug!("try_promote_type_test: ur={:?}", ur);

let non_local_ub = self.universal_region_relations.non_local_upper_bounds(ur);
debug!("try_promote_type_test: non_local_ub={:?}", non_local_ub);

Expand Down Expand Up @@ -1001,15 +1030,14 @@ impl<'tcx> RegionInferenceContext<'tcx> {
/// will use it's *external name*, which will be a `RegionKind`
/// variant that can be used in query responses such as
/// `ReEarlyBound`.
#[instrument(level = "debug", skip(self, infcx))]
fn try_promote_type_test_subject(
&self,
infcx: &InferCtxt<'_, 'tcx>,
ty: Ty<'tcx>,
) -> Option<ClosureOutlivesSubject<'tcx>> {
let tcx = infcx.tcx;

debug!("try_promote_type_test_subject(ty = {:?})", ty);

let ty = tcx.fold_regions(ty, |r, _depth| {
let region_vid = self.to_region_vid(r);

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_trait_selection/src/traits/coherence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::traits::{
self, FulfillmentContext, Normalized, Obligation, ObligationCause, PredicateObligation,
PredicateObligations, SelectionContext,
};
//use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::fx::FxIndexSet;
use rustc_errors::Diagnostic;
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
use rustc_infer::infer::{InferCtxt, TyCtxtInferExt};
Expand Down Expand Up @@ -44,7 +44,7 @@ pub enum Conflict {

pub struct OverlapResult<'tcx> {
pub impl_header: ty::ImplHeader<'tcx>,
pub intercrate_ambiguity_causes: Vec<IntercrateAmbiguityCause>,
pub intercrate_ambiguity_causes: FxIndexSet<IntercrateAmbiguityCause>,

/// `true` if the overlap might've been permitted before the shift
/// to universes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
IntercrateAmbiguityCause::DownstreamCrate { trait_desc, self_desc }
};
debug!(?cause, "evaluate_stack: pushing cause");
self.intercrate_ambiguity_causes.as_mut().unwrap().push(cause);
self.intercrate_ambiguity_causes.as_mut().unwrap().insert(cause);
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions compiler/rustc_trait_selection/src/traits/select/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use crate::traits::error_reporting::InferCtxtExt;
use crate::traits::project::ProjectAndUnifyResult;
use crate::traits::project::ProjectionCacheKeyExt;
use crate::traits::ProjectionCacheKey;
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet};
use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_errors::{Diagnostic, ErrorGuaranteed};
use rustc_hir as hir;
Expand Down Expand Up @@ -52,7 +52,7 @@ pub use rustc_middle::traits::select::*;
mod candidate_assembly;
mod confirmation;

#[derive(Clone, Debug)]
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
pub enum IntercrateAmbiguityCause {
DownstreamCrate { trait_desc: String, self_desc: Option<String> },
UpstreamCrateUpdate { trait_desc: String, self_desc: Option<String> },
Expand Down Expand Up @@ -128,7 +128,7 @@ pub struct SelectionContext<'cx, 'tcx> {
/// We don't do his until we detect a coherence error because it can
/// lead to false overflow results (#47139) and because always
/// computing it may negatively impact performance.
intercrate_ambiguity_causes: Option<Vec<IntercrateAmbiguityCause>>,
intercrate_ambiguity_causes: Option<FxIndexSet<IntercrateAmbiguityCause>>,

/// The mode that trait queries run in, which informs our error handling
/// policy. In essence, canonicalized queries need their errors propagated
Expand Down Expand Up @@ -254,14 +254,14 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
pub fn enable_tracking_intercrate_ambiguity_causes(&mut self) {
assert!(self.intercrate);
assert!(self.intercrate_ambiguity_causes.is_none());
self.intercrate_ambiguity_causes = Some(vec![]);
self.intercrate_ambiguity_causes = Some(FxIndexSet::default());
debug!("selcx: enable_tracking_intercrate_ambiguity_causes");
}

/// Gets the intercrate ambiguity causes collected since tracking
/// was enabled and disables tracking at the same time. If
/// tracking is not enabled, just returns an empty vector.
pub fn take_intercrate_ambiguity_causes(&mut self) -> Vec<IntercrateAmbiguityCause> {
pub fn take_intercrate_ambiguity_causes(&mut self) -> FxIndexSet<IntercrateAmbiguityCause> {
assert!(self.intercrate);
self.intercrate_ambiguity_causes.take().unwrap_or_default()
}
Expand Down Expand Up @@ -960,7 +960,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
});

debug!(?cause, "evaluate_stack: pushing cause");
self.intercrate_ambiguity_causes.as_mut().unwrap().push(cause);
self.intercrate_ambiguity_causes.as_mut().unwrap().insert(cause);
}
}
}
Expand Down Expand Up @@ -1252,7 +1252,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
reservation impl ambiguity on {:?}",
def_id
);
intercrate_ambiguity_clauses.push(
intercrate_ambiguity_clauses.insert(
IntercrateAmbiguityCause::ReservationImpl {
message: value.to_string(),
},
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_trait_selection/src/traits/specialize/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use specialization_graph::GraphExt;
use crate::infer::{InferCtxt, InferOk, TyCtxtInferExt};
use crate::traits::select::IntercrateAmbiguityCause;
use crate::traits::{self, coherence, FutureCompatOverlapErrorKind, ObligationCause, TraitEngine};
use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::fx::{FxHashSet, FxIndexSet};
use rustc_errors::{struct_span_err, EmissionGuarantee, LintDiagnosticBuilder};
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_middle::ty::subst::{InternalSubsts, Subst, SubstsRef};
Expand All @@ -33,7 +33,7 @@ pub struct OverlapError {
pub with_impl: DefId,
pub trait_desc: String,
pub self_desc: Option<String>,
pub intercrate_ambiguity_causes: Vec<IntercrateAmbiguityCause>,
pub intercrate_ambiguity_causes: FxIndexSet<IntercrateAmbiguityCause>,
pub involves_placeholder: bool,
}

Expand Down
2 changes: 1 addition & 1 deletion library/core/src/sync/atomic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -991,7 +991,7 @@ impl<T> AtomicPtr<T> {
/// use std::sync::atomic::AtomicPtr;
///
/// let ptr = &mut 5;
/// let atomic_ptr = AtomicPtr::new(ptr);
/// let atomic_ptr = AtomicPtr::new(ptr);
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
Expand Down
22 changes: 11 additions & 11 deletions src/librustdoc/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,17 @@ impl Options {
return Err(0);
}

let z_flags = matches.opt_strs("Z");
if z_flags.iter().any(|x| *x == "help") {
print_flag_list("-Z", config::DB_OPTIONS);
return Err(0);
}
let c_flags = matches.opt_strs("C");
if c_flags.iter().any(|x| *x == "help") {
print_flag_list("-C", config::CG_OPTIONS);
return Err(0);
}

let color = config::parse_color(matches);
let config::JsonConfig { json_rendered, json_unused_externs, .. } =
config::parse_json(matches);
Expand All @@ -343,17 +354,6 @@ impl Options {
// check for deprecated options
check_deprecated_options(matches, &diag);

let z_flags = matches.opt_strs("Z");
if z_flags.iter().any(|x| *x == "help") {
print_flag_list("-Z", config::DB_OPTIONS);
return Err(0);
}
let c_flags = matches.opt_strs("C");
if c_flags.iter().any(|x| *x == "help") {
print_flag_list("-C", config::CG_OPTIONS);
return Err(0);
}

if matches.opt_strs("passes") == ["list"] {
println!("Available passes for running rustdoc:");
for pass in passes::PASSES {
Expand Down
4 changes: 1 addition & 3 deletions src/librustdoc/html/static/css/themes/dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,6 @@ a {
color: #D2991D;
}

a.test-arrow {
color: #dedede;
}
body.source .example-wrap pre.rust a {
background: #333;
}
Expand Down Expand Up @@ -255,6 +252,7 @@ pre.rust .question-mark {
}

a.test-arrow {
color: #dedede;
background-color: rgba(78, 139, 202, 0.2);
}

Expand Down
6 changes: 2 additions & 4 deletions src/librustdoc/html/static/css/themes/light.css
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,6 @@ a {
color: #3873AD;
}

a.test-arrow {
color: #f5f5f5;
}
body.source .example-wrap pre.rust a {
background: #eee;
}
Expand Down Expand Up @@ -239,7 +236,8 @@ pre.rust .question-mark {
}

a.test-arrow {
background-color: rgb(78, 139, 202, 0.2);
color: #f5f5f5;
background-color: rgba(78, 139, 202, 0.2);
}

a.test-arrow:hover{
Expand Down
6 changes: 6 additions & 0 deletions src/test/rustdoc-ui/c-help.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// check-pass
// compile-flags: -Chelp
// check-stdout
// regex-error-pattern: -C\s+incremental

pub struct Foo;
51 changes: 51 additions & 0 deletions src/test/rustdoc-ui/c-help.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
-C ar=val -- this option is deprecated and does nothing
-C code-model=val -- choose the code model to use (`rustc --print code-models` for details)
-C codegen-units=val -- divide crate into N units to optimize in parallel
-C control-flow-guard=val -- use Windows Control Flow Guard (default: no)
-C debug-assertions=val -- explicitly enable the `cfg(debug_assertions)` directive
-C debuginfo=val -- debug info emission level (0 = no debug info, 1 = line tables only, 2 = full debug info with variable and type information; default: 0)
-C default-linker-libraries=val -- allow the linker to link its default libraries (default: no)
-C embed-bitcode=val -- emit bitcode in rlibs (default: yes)
-C extra-filename=val -- extra data to put in each output filename
-C force-frame-pointers=val -- force use of the frame pointers
-C force-unwind-tables=val -- force use of unwind tables
-C incremental=val -- enable incremental compilation
-C inline-threshold=val -- set the threshold for inlining a function
-C instrument-coverage=val -- instrument the generated code to support LLVM source-based code coverage reports (note, the compiler build config must include `profiler = true`); implies `-C symbol-mangling-version=v0`. Optional values are:
`=all` (implicit value)
`=except-unused-generics`
`=except-unused-functions`
`=off` (default)
-C link-arg=val -- a single extra argument to append to the linker invocation (can be used several times)
-C link-args=val -- extra arguments to append to the linker invocation (space separated)
-C link-dead-code=val -- keep dead code at link time (useful for code coverage) (default: no)
-C link-self-contained=val -- control whether to link Rust provided C objects/libraries or rely
on C toolchain installed in the system
-C linker=val -- system linker to link outputs with
-C linker-flavor=val -- linker flavor
-C linker-plugin-lto=val -- generate build artifacts that are compatible with linker-based LTO
-C llvm-args=val -- a list of arguments to pass to LLVM (space separated)
-C lto=val -- perform LLVM link-time optimizations
-C metadata=val -- metadata to mangle symbol names with
-C no-prepopulate-passes=val -- give an empty list of passes to the pass manager
-C no-redzone=val -- disable the use of the redzone
-C no-stack-check=val -- this option is deprecated and does nothing
-C no-vectorize-loops=val -- disable loop vectorization optimization passes
-C no-vectorize-slp=val -- disable LLVM's SLP vectorization pass
-C opt-level=val -- optimization level (0-3, s, or z; default: 0)
-C overflow-checks=val -- use overflow checks for integer arithmetic
-C panic=val -- panic strategy to compile crate with
-C passes=val -- a list of extra LLVM passes to run (space separated)
-C prefer-dynamic=val -- prefer dynamic linking to static linking (default: no)
-C profile-generate=val -- compile the program with profiling instrumentation
-C profile-use=val -- use the given `.profdata` file for profile-guided optimization
-C relocation-model=val -- control generation of position-independent code (PIC) (`rustc --print relocation-models` for details)
-C remark=val -- print remarks for these optimization passes (space separated, or "all")
-C rpath=val -- set rpath values in libs/exes (default: no)
-C save-temps=val -- save all temporary output files during compilation (default: no)
-C soft-float=val -- use soft float ABI (*eabihf targets only) (default: no)
-C split-debuginfo=val -- how to handle split-debuginfo, a platform-specific option
-C strip=val -- tell the linker which information to strip (`none` (default), `debuginfo` or `symbols`)
-C symbol-mangling-version=val -- which mangling version to use for symbol names ('legacy' (default) or 'v0')
-C target-cpu=val -- select target processor (`rustc --print target-cpus` for details)
-C target-feature=val -- target specific attributes. (`rustc --print target-features` for details). This feature is unsafe.
6 changes: 6 additions & 0 deletions src/test/rustdoc-ui/z-help.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// check-pass
// compile-flags: -Zhelp
// check-stdout
// regex-error-pattern: -Z\s+self-profile

pub struct Foo;
Loading