diff --git a/.gitmodules b/.gitmodules index 003e50d0788e4..b2b580d08bc28 100644 --- a/.gitmodules +++ b/.gitmodules @@ -31,9 +31,9 @@ [submodule "src/stdarch"] path = src/stdarch url = https://github.com/rust-lang/stdarch.git -[submodule "src/doc/rustc-guide"] - path = src/doc/rustc-guide - url = https://github.com/rust-lang/rustc-guide.git +[submodule "src/doc/rustc-dev-guide"] + path = src/doc/rustc-dev-guide + url = https://github.com/rust-lang/rustc-dev-guide.git [submodule "src/doc/edition-guide"] path = src/doc/edition-guide url = https://github.com/rust-lang/edition-guide.git diff --git a/rustfmt.toml b/rustfmt.toml index 8f4c901fb9740..9b2c08200362e 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -20,7 +20,7 @@ ignore = [ "src/doc/nomicon", "src/doc/reference", "src/doc/rust-by-example", - "src/doc/rustc-guide", + "src/doc/rustc-dev-guide", "src/llvm-project", "src/stdarch", "src/tools/cargo", diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index 1b9e9a889483c..f041555c93224 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -1493,7 +1493,7 @@ impl Step for RustcGuide { const ONLY_HOSTS: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - run.path("src/doc/rustc-guide") + run.path("src/doc/rustc-dev-guide") } fn make_run(run: RunConfig<'_>) { @@ -1501,14 +1501,14 @@ impl Step for RustcGuide { } fn run(self, builder: &Builder<'_>) { - let src = builder.src.join("src/doc/rustc-guide"); + let src = builder.src.join("src/doc/rustc-dev-guide"); let mut rustbook_cmd = builder.tool_cmd(Tool::Rustbook); let toolstate = if try_run(builder, rustbook_cmd.arg("linkcheck").arg(&src)) { ToolState::TestPass } else { ToolState::TestFail }; - builder.save_toolstate("rustc-guide", toolstate); + builder.save_toolstate("rustc-dev-guide", toolstate); } } diff --git a/src/bootstrap/toolstate.rs b/src/bootstrap/toolstate.rs index 7cffc47293070..31ff01d5be6a5 100644 --- a/src/bootstrap/toolstate.rs +++ b/src/bootstrap/toolstate.rs @@ -89,7 +89,7 @@ static STABLE_TOOLS: &[(&str, &str)] = &[ static NIGHTLY_TOOLS: &[(&str, &str)] = &[ ("miri", "src/tools/miri"), ("embedded-book", "src/doc/embedded-book"), - ("rustc-guide", "src/doc/rustc-guide"), + ("rustc-dev-guide", "src/doc/rustc-dev-guide"), ]; fn print_error(tool: &str, submodule: &str) { diff --git a/src/ci/docker/x86_64-gnu-tools/checktools.sh b/src/ci/docker/x86_64-gnu-tools/checktools.sh index e57fe2271398f..72325c7b94830 100755 --- a/src/ci/docker/x86_64-gnu-tools/checktools.sh +++ b/src/ci/docker/x86_64-gnu-tools/checktools.sh @@ -14,7 +14,7 @@ python2.7 "$X_PY" test --no-fail-fast \ src/doc/rust-by-example \ src/doc/embedded-book \ src/doc/edition-guide \ - src/doc/rustc-guide \ + src/doc/rustc-dev-guide \ src/tools/clippy \ src/tools/rls \ src/tools/rustfmt \ diff --git a/src/doc/rustc-dev-guide b/src/doc/rustc-dev-guide new file mode 160000 index 0000000000000..66be765404efb --- /dev/null +++ b/src/doc/rustc-dev-guide @@ -0,0 +1 @@ +Subproject commit 66be765404efb82c6bc2735473cbd3472f777dc0 diff --git a/src/doc/rustc-guide b/src/doc/rustc-guide deleted file mode 160000 index 5bd60bc51efae..0000000000000 --- a/src/doc/rustc-guide +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 5bd60bc51efaec04e69e2e18b59678e2af066433 diff --git a/src/librustc_infer/infer/canonical/query_response.rs b/src/librustc_infer/infer/canonical/query_response.rs index 77f1c6bf28109..966bd99787729 100644 --- a/src/librustc_infer/infer/canonical/query_response.rs +++ b/src/librustc_infer/infer/canonical/query_response.rs @@ -12,14 +12,15 @@ use crate::infer::canonical::{ Canonical, CanonicalVarValues, CanonicalizedQueryResponse, Certainty, OriginalQueryValues, QueryOutlivesConstraint, QueryRegionConstraints, QueryResponse, }; +use crate::infer::nll_relate::{NormalizationStrategy, TypeRelating, TypeRelatingDelegate}; use crate::infer::region_constraints::{Constraint, RegionConstraintData}; -use crate::infer::InferCtxtBuilder; -use crate::infer::{InferCtxt, InferOk, InferResult}; +use crate::infer::{InferCtxt, InferCtxtBuilder, InferOk, InferResult, NLLRegionVariableOrigin}; use crate::traits::query::{Fallible, NoSolution}; -use crate::traits::TraitEngine; +use crate::traits::{DomainGoal, TraitEngine}; use crate::traits::{Obligation, ObligationCause, PredicateObligation}; use rustc::arena::ArenaAllocatable; use rustc::ty::fold::TypeFoldable; +use rustc::ty::relate::TypeRelation; use rustc::ty::subst::{GenericArg, GenericArgKind}; use rustc::ty::{self, BoundVar, Ty, TyCtxt}; use rustc_data_structures::captures::Captures; @@ -304,13 +305,31 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> { } (GenericArgKind::Type(v1), GenericArgKind::Type(v2)) => { - let ok = self.at(cause, param_env).eq(v1, v2)?; - obligations.extend(ok.into_obligations()); + TypeRelating::new( + self, + QueryTypeRelatingDelegate { + infcx: self, + param_env, + cause, + obligations: &mut obligations, + }, + ty::Variance::Invariant, + ) + .relate(&v1, &v2)?; } (GenericArgKind::Const(v1), GenericArgKind::Const(v2)) => { - let ok = self.at(cause, param_env).eq(v1, v2)?; - obligations.extend(ok.into_obligations()); + TypeRelating::new( + self, + QueryTypeRelatingDelegate { + infcx: self, + param_env, + cause, + obligations: &mut obligations, + }, + ty::Variance::Invariant, + ) + .relate(&v1, &v2)?; } _ => { @@ -656,3 +675,55 @@ pub fn make_query_region_constraints<'tcx>( QueryRegionConstraints { outlives, member_constraints: member_constraints.clone() } } + +struct QueryTypeRelatingDelegate<'a, 'tcx> { + infcx: &'a InferCtxt<'a, 'tcx>, + obligations: &'a mut Vec>, + param_env: ty::ParamEnv<'tcx>, + cause: &'a ObligationCause<'tcx>, +} + +impl<'tcx> TypeRelatingDelegate<'tcx> for QueryTypeRelatingDelegate<'_, 'tcx> { + fn create_next_universe(&mut self) -> ty::UniverseIndex { + self.infcx.create_next_universe() + } + + fn next_existential_region_var(&mut self, from_forall: bool) -> ty::Region<'tcx> { + let origin = NLLRegionVariableOrigin::Existential { from_forall }; + self.infcx.next_nll_region_var(origin) + } + + fn next_placeholder_region(&mut self, placeholder: ty::PlaceholderRegion) -> ty::Region<'tcx> { + self.infcx.tcx.mk_region(ty::RePlaceholder(placeholder)) + } + + fn generalize_existential(&mut self, universe: ty::UniverseIndex) -> ty::Region<'tcx> { + self.infcx.next_nll_region_var_in_universe( + NLLRegionVariableOrigin::Existential { from_forall: false }, + universe, + ) + } + + fn push_outlives(&mut self, sup: ty::Region<'tcx>, sub: ty::Region<'tcx>) { + self.obligations.push(Obligation { + cause: self.cause.clone(), + param_env: self.param_env, + predicate: ty::Predicate::RegionOutlives(ty::Binder::dummy(ty::OutlivesPredicate( + sup, sub, + ))), + recursion_depth: 0, + }); + } + + fn push_domain_goal(&mut self, _: DomainGoal<'tcx>) { + bug!("should never be invoked with eager normalization") + } + + fn normalization() -> NormalizationStrategy { + NormalizationStrategy::Eager + } + + fn forbid_inference_vars() -> bool { + true + } +} diff --git a/src/test/ui/nll/user-annotations/type-annotation-with-hrtb.rs b/src/test/ui/nll/user-annotations/type-annotation-with-hrtb.rs new file mode 100644 index 0000000000000..1f7c060386bd0 --- /dev/null +++ b/src/test/ui/nll/user-annotations/type-annotation-with-hrtb.rs @@ -0,0 +1,33 @@ +// Regression test for issue #69490 + +// check-pass + +pub trait Trait { + const S: &'static str; +} + +impl Trait<()> for T +where + T: for<'a> Trait<&'a ()>, +{ + // Use of `T::S` here caused an ICE + const S: &'static str = T::S; +} + +// Some similar cases that didn't ICE: + +impl<'a, T> Trait<()> for (T,) +where + T: Trait<&'a ()>, +{ + const S: &'static str = T::S; +} + +impl Trait<()> for [T; 1] +where + T: Trait fn(&'a ())>, +{ + const S: &'static str = T::S; +} + +fn main() {} diff --git a/src/tools/publish_toolstate.py b/src/tools/publish_toolstate.py index 5fbb986286ade..25e684ff43d77 100755 --- a/src/tools/publish_toolstate.py +++ b/src/tools/publish_toolstate.py @@ -41,7 +41,7 @@ 'ryankurte', 'thejpster', 'therealprof', }, 'edition-guide': {'ehuss', 'Centril', 'steveklabnik'}, - 'rustc-guide': {'mark-i-m', 'spastorino', 'amanjeev', 'JohnTitor'}, + 'rustc-dev-guide': {'mark-i-m', 'spastorino', 'amanjeev', 'JohnTitor'}, } REPOS = { @@ -55,7 +55,7 @@ 'rust-by-example': 'https://github.com/rust-lang/rust-by-example', 'embedded-book': 'https://github.com/rust-embedded/book', 'edition-guide': 'https://github.com/rust-lang/edition-guide', - 'rustc-guide': 'https://github.com/rust-lang/rustc-guide', + 'rustc-dev-guide': 'https://github.com/rust-lang/rustc-dev-guide', } @@ -204,7 +204,7 @@ def update_latest( old = status[os] new = s.get(tool, old) status[os] = new - maintainers = ' '.join('@'+name for name in MAINTAINERS[tool]) + maintainers = ' '.join('@'+name for name in MAINTAINERS.get(tool, ())) # comparing the strings, but they are ordered appropriately: # "test-pass" > "test-fail" > "build-fail" if new > old: