Skip to content

Commit 934ae77

Browse files
committed
Auto merge of #70848 - Mark-Simulacrum:beta-next, r=Mark-Simulacrum
[beta] backports * Use TypeRelating for instantiating query responses #69591 * Move rustc-guide submodule to rustc-dev-guide #69898
2 parents 4331852 + 225ad8d commit 934ae77

File tree

10 files changed

+124
-20
lines changed

10 files changed

+124
-20
lines changed

.gitmodules

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131
[submodule "src/stdarch"]
3232
path = src/stdarch
3333
url = https://github.com/rust-lang/stdarch.git
34-
[submodule "src/doc/rustc-guide"]
35-
path = src/doc/rustc-guide
36-
url = https://github.com/rust-lang/rustc-guide.git
34+
[submodule "src/doc/rustc-dev-guide"]
35+
path = src/doc/rustc-dev-guide
36+
url = https://github.com/rust-lang/rustc-dev-guide.git
3737
[submodule "src/doc/edition-guide"]
3838
path = src/doc/edition-guide
3939
url = https://github.com/rust-lang/edition-guide.git

rustfmt.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ ignore = [
2020
"src/doc/nomicon",
2121
"src/doc/reference",
2222
"src/doc/rust-by-example",
23-
"src/doc/rustc-guide",
23+
"src/doc/rustc-dev-guide",
2424
"src/llvm-project",
2525
"src/stdarch",
2626
"src/tools/cargo",

src/bootstrap/test.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1493,22 +1493,22 @@ impl Step for RustcGuide {
14931493
const ONLY_HOSTS: bool = true;
14941494

14951495
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1496-
run.path("src/doc/rustc-guide")
1496+
run.path("src/doc/rustc-dev-guide")
14971497
}
14981498

14991499
fn make_run(run: RunConfig<'_>) {
15001500
run.builder.ensure(RustcGuide);
15011501
}
15021502

15031503
fn run(self, builder: &Builder<'_>) {
1504-
let src = builder.src.join("src/doc/rustc-guide");
1504+
let src = builder.src.join("src/doc/rustc-dev-guide");
15051505
let mut rustbook_cmd = builder.tool_cmd(Tool::Rustbook);
15061506
let toolstate = if try_run(builder, rustbook_cmd.arg("linkcheck").arg(&src)) {
15071507
ToolState::TestPass
15081508
} else {
15091509
ToolState::TestFail
15101510
};
1511-
builder.save_toolstate("rustc-guide", toolstate);
1511+
builder.save_toolstate("rustc-dev-guide", toolstate);
15121512
}
15131513
}
15141514

src/bootstrap/toolstate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ static STABLE_TOOLS: &[(&str, &str)] = &[
8989
static NIGHTLY_TOOLS: &[(&str, &str)] = &[
9090
("miri", "src/tools/miri"),
9191
("embedded-book", "src/doc/embedded-book"),
92-
("rustc-guide", "src/doc/rustc-guide"),
92+
("rustc-dev-guide", "src/doc/rustc-dev-guide"),
9393
];
9494

9595
fn print_error(tool: &str, submodule: &str) {

src/ci/docker/x86_64-gnu-tools/checktools.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ python2.7 "$X_PY" test --no-fail-fast \
1414
src/doc/rust-by-example \
1515
src/doc/embedded-book \
1616
src/doc/edition-guide \
17-
src/doc/rustc-guide \
17+
src/doc/rustc-dev-guide \
1818
src/tools/clippy \
1919
src/tools/rls \
2020
src/tools/rustfmt \

src/doc/rustc-dev-guide

Submodule rustc-dev-guide added at 66be765

src/doc/rustc-guide

-1
This file was deleted.

src/librustc_infer/infer/canonical/query_response.rs

+78-7
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ use crate::infer::canonical::{
1212
Canonical, CanonicalVarValues, CanonicalizedQueryResponse, Certainty, OriginalQueryValues,
1313
QueryOutlivesConstraint, QueryRegionConstraints, QueryResponse,
1414
};
15+
use crate::infer::nll_relate::{NormalizationStrategy, TypeRelating, TypeRelatingDelegate};
1516
use crate::infer::region_constraints::{Constraint, RegionConstraintData};
16-
use crate::infer::InferCtxtBuilder;
17-
use crate::infer::{InferCtxt, InferOk, InferResult};
17+
use crate::infer::{InferCtxt, InferCtxtBuilder, InferOk, InferResult, NLLRegionVariableOrigin};
1818
use crate::traits::query::{Fallible, NoSolution};
19-
use crate::traits::TraitEngine;
19+
use crate::traits::{DomainGoal, TraitEngine};
2020
use crate::traits::{Obligation, ObligationCause, PredicateObligation};
2121
use rustc::arena::ArenaAllocatable;
2222
use rustc::ty::fold::TypeFoldable;
23+
use rustc::ty::relate::TypeRelation;
2324
use rustc::ty::subst::{GenericArg, GenericArgKind};
2425
use rustc::ty::{self, BoundVar, Ty, TyCtxt};
2526
use rustc_data_structures::captures::Captures;
@@ -304,13 +305,31 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
304305
}
305306

306307
(GenericArgKind::Type(v1), GenericArgKind::Type(v2)) => {
307-
let ok = self.at(cause, param_env).eq(v1, v2)?;
308-
obligations.extend(ok.into_obligations());
308+
TypeRelating::new(
309+
self,
310+
QueryTypeRelatingDelegate {
311+
infcx: self,
312+
param_env,
313+
cause,
314+
obligations: &mut obligations,
315+
},
316+
ty::Variance::Invariant,
317+
)
318+
.relate(&v1, &v2)?;
309319
}
310320

311321
(GenericArgKind::Const(v1), GenericArgKind::Const(v2)) => {
312-
let ok = self.at(cause, param_env).eq(v1, v2)?;
313-
obligations.extend(ok.into_obligations());
322+
TypeRelating::new(
323+
self,
324+
QueryTypeRelatingDelegate {
325+
infcx: self,
326+
param_env,
327+
cause,
328+
obligations: &mut obligations,
329+
},
330+
ty::Variance::Invariant,
331+
)
332+
.relate(&v1, &v2)?;
314333
}
315334

316335
_ => {
@@ -656,3 +675,55 @@ pub fn make_query_region_constraints<'tcx>(
656675

657676
QueryRegionConstraints { outlives, member_constraints: member_constraints.clone() }
658677
}
678+
679+
struct QueryTypeRelatingDelegate<'a, 'tcx> {
680+
infcx: &'a InferCtxt<'a, 'tcx>,
681+
obligations: &'a mut Vec<PredicateObligation<'tcx>>,
682+
param_env: ty::ParamEnv<'tcx>,
683+
cause: &'a ObligationCause<'tcx>,
684+
}
685+
686+
impl<'tcx> TypeRelatingDelegate<'tcx> for QueryTypeRelatingDelegate<'_, 'tcx> {
687+
fn create_next_universe(&mut self) -> ty::UniverseIndex {
688+
self.infcx.create_next_universe()
689+
}
690+
691+
fn next_existential_region_var(&mut self, from_forall: bool) -> ty::Region<'tcx> {
692+
let origin = NLLRegionVariableOrigin::Existential { from_forall };
693+
self.infcx.next_nll_region_var(origin)
694+
}
695+
696+
fn next_placeholder_region(&mut self, placeholder: ty::PlaceholderRegion) -> ty::Region<'tcx> {
697+
self.infcx.tcx.mk_region(ty::RePlaceholder(placeholder))
698+
}
699+
700+
fn generalize_existential(&mut self, universe: ty::UniverseIndex) -> ty::Region<'tcx> {
701+
self.infcx.next_nll_region_var_in_universe(
702+
NLLRegionVariableOrigin::Existential { from_forall: false },
703+
universe,
704+
)
705+
}
706+
707+
fn push_outlives(&mut self, sup: ty::Region<'tcx>, sub: ty::Region<'tcx>) {
708+
self.obligations.push(Obligation {
709+
cause: self.cause.clone(),
710+
param_env: self.param_env,
711+
predicate: ty::Predicate::RegionOutlives(ty::Binder::dummy(ty::OutlivesPredicate(
712+
sup, sub,
713+
))),
714+
recursion_depth: 0,
715+
});
716+
}
717+
718+
fn push_domain_goal(&mut self, _: DomainGoal<'tcx>) {
719+
bug!("should never be invoked with eager normalization")
720+
}
721+
722+
fn normalization() -> NormalizationStrategy {
723+
NormalizationStrategy::Eager
724+
}
725+
726+
fn forbid_inference_vars() -> bool {
727+
true
728+
}
729+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Regression test for issue #69490
2+
3+
// check-pass
4+
5+
pub trait Trait<T> {
6+
const S: &'static str;
7+
}
8+
9+
impl<T> Trait<()> for T
10+
where
11+
T: for<'a> Trait<&'a ()>,
12+
{
13+
// Use of `T::S` here caused an ICE
14+
const S: &'static str = T::S;
15+
}
16+
17+
// Some similar cases that didn't ICE:
18+
19+
impl<'a, T> Trait<()> for (T,)
20+
where
21+
T: Trait<&'a ()>,
22+
{
23+
const S: &'static str = T::S;
24+
}
25+
26+
impl<T> Trait<()> for [T; 1]
27+
where
28+
T: Trait<for<'a> fn(&'a ())>,
29+
{
30+
const S: &'static str = T::S;
31+
}
32+
33+
fn main() {}

src/tools/publish_toolstate.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
'ryankurte', 'thejpster', 'therealprof',
4242
},
4343
'edition-guide': {'ehuss', 'Centril', 'steveklabnik'},
44-
'rustc-guide': {'mark-i-m', 'spastorino', 'amanjeev', 'JohnTitor'},
44+
'rustc-dev-guide': {'mark-i-m', 'spastorino', 'amanjeev', 'JohnTitor'},
4545
}
4646

4747
REPOS = {
@@ -55,7 +55,7 @@
5555
'rust-by-example': 'https://github.com/rust-lang/rust-by-example',
5656
'embedded-book': 'https://github.com/rust-embedded/book',
5757
'edition-guide': 'https://github.com/rust-lang/edition-guide',
58-
'rustc-guide': 'https://github.com/rust-lang/rustc-guide',
58+
'rustc-dev-guide': 'https://github.com/rust-lang/rustc-dev-guide',
5959
}
6060

6161

@@ -204,7 +204,7 @@ def update_latest(
204204
old = status[os]
205205
new = s.get(tool, old)
206206
status[os] = new
207-
maintainers = ' '.join('@'+name for name in MAINTAINERS[tool])
207+
maintainers = ' '.join('@'+name for name in MAINTAINERS.get(tool, ()))
208208
# comparing the strings, but they are ordered appropriately:
209209
# "test-pass" > "test-fail" > "build-fail"
210210
if new > old:

0 commit comments

Comments
 (0)