Skip to content

Commit 9b8dbd5

Browse files
committed
Auto merge of rust-lang#107870 - matthiaskrgr:rollup-3z1q4rm, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - rust-lang#107043 (Support `true` and `false` as boolean flag params) - rust-lang#107831 (Query refactoring) - rust-lang#107841 (Handled snap curl issue inside Rust) - rust-lang#107852 (rustdoc: remove unused fn parameter `tab`) - rust-lang#107861 (Sync release notes for 1.67.1) - rust-lang#107863 (Allow multiple candidates with same response in new solver) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents a697573 + 9300617 commit 9b8dbd5

File tree

26 files changed

+112
-120
lines changed

26 files changed

+112
-120
lines changed

Cargo.lock

+1
Original file line numberDiff line numberDiff line change
@@ -4773,6 +4773,7 @@ checksum = "8ba09476327c4b70ccefb6180f046ef588c26a24cf5d269a9feba316eb4f029f"
47734773
name = "rustc_trait_selection"
47744774
version = "0.0.0"
47754775
dependencies = [
4776+
"itertools",
47764777
"rustc_ast",
47774778
"rustc_attr",
47784779
"rustc_data_structures",

RELEASES.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
Version 1.67.1 (2023-02-09)
2+
===========================
3+
4+
- [Fix interoperability with thin archives.](https://github.com/rust-lang/rust/pull/107360)
5+
- [Fix an internal error in the compiler build process.](https://github.com/rust-lang/rust/pull/105624)
6+
- [Downgrade `clippy::uninlined_format_args` to pedantic.](https://github.com/rust-lang/rust-clippy/pull/10265)
7+
18
Version 1.67.0 (2023-01-26)
29
==========================
310

compiler/rustc_const_eval/src/const_eval/eval_queries.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ fn eval_body_using_ecx<'mir, 'tcx>(
5454

5555
trace!(
5656
"eval_body_using_ecx: pushing stack frame for global: {}{}",
57-
with_no_trimmed_paths!(ty::tls::with(|tcx| tcx.def_path_str(cid.instance.def_id()))),
57+
with_no_trimmed_paths!(ecx.tcx.def_path_str(cid.instance.def_id())),
5858
cid.promoted.map_or_else(String::new, |p| format!("::promoted[{:?}]", p))
5959
);
6060

compiler/rustc_infer/src/infer/canonical/canonicalizer.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,10 @@ impl CanonicalizeMode for CanonicalizeQueryResponse {
203203
// rust-lang/rust#57464: `impl Trait` can leak local
204204
// scopes (in manner violating typeck). Therefore, use
205205
// `delay_span_bug` to allow type error over an ICE.
206-
ty::tls::with(|tcx| {
207-
tcx.sess.delay_span_bug(
208-
rustc_span::DUMMY_SP,
209-
&format!("unexpected region in query response: `{:?}`", r),
210-
);
211-
});
206+
canonicalizer.tcx.sess.delay_span_bug(
207+
rustc_span::DUMMY_SP,
208+
&format!("unexpected region in query response: `{:?}`", r),
209+
);
212210
r
213211
}
214212
}

compiler/rustc_interface/src/callbacks.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ fn track_diagnostic(diagnostic: &mut Diagnostic, f: &mut dyn FnMut(&mut Diagnost
3838

3939
// Diagnostics are tracked, we can ignore the dependency.
4040
let icx = tls::ImplicitCtxt { task_deps: TaskDepsRef::Ignore, ..icx.clone() };
41-
return tls::enter_context(&icx, move |_| (*f)(diagnostic));
41+
return tls::enter_context(&icx, move || (*f)(diagnostic));
4242
}
4343

4444
// In any other case, invoke diagnostics anyway.

compiler/rustc_interface/src/passes.rs

+5-21
Original file line numberDiff line numberDiff line change
@@ -738,30 +738,16 @@ pub static DEFAULT_EXTERN_QUERY_PROVIDERS: LazyLock<ExternProviders> = LazyLock:
738738
extern_providers
739739
});
740740

741-
pub struct QueryContext<'tcx> {
742-
gcx: &'tcx GlobalCtxt<'tcx>,
743-
}
744-
745-
impl<'tcx> QueryContext<'tcx> {
746-
pub fn enter<F, R>(&mut self, f: F) -> R
747-
where
748-
F: FnOnce(TyCtxt<'tcx>) -> R,
749-
{
750-
let icx = ty::tls::ImplicitCtxt::new(self.gcx);
751-
ty::tls::enter_context(&icx, |_| f(icx.tcx))
752-
}
753-
}
754-
755741
pub fn create_global_ctxt<'tcx>(
756742
compiler: &'tcx Compiler,
757743
lint_store: Lrc<LintStore>,
758744
dep_graph: DepGraph,
759745
untracked: Untracked,
760746
queries: &'tcx OnceCell<TcxQueries<'tcx>>,
761-
global_ctxt: &'tcx OnceCell<GlobalCtxt<'tcx>>,
747+
gcx_cell: &'tcx OnceCell<GlobalCtxt<'tcx>>,
762748
arena: &'tcx WorkerLocal<Arena<'tcx>>,
763749
hir_arena: &'tcx WorkerLocal<rustc_hir::Arena<'tcx>>,
764-
) -> QueryContext<'tcx> {
750+
) -> &'tcx GlobalCtxt<'tcx> {
765751
// We're constructing the HIR here; we don't care what we will
766752
// read, since we haven't even constructed the *input* to
767753
// incr. comp. yet.
@@ -785,8 +771,8 @@ pub fn create_global_ctxt<'tcx>(
785771
TcxQueries::new(local_providers, extern_providers, query_result_on_disk_cache)
786772
});
787773

788-
let gcx = sess.time("setup_global_ctxt", || {
789-
global_ctxt.get_or_init(move || {
774+
sess.time("setup_global_ctxt", || {
775+
gcx_cell.get_or_init(move || {
790776
TyCtxt::create_global_ctxt(
791777
sess,
792778
lint_store,
@@ -799,9 +785,7 @@ pub fn create_global_ctxt<'tcx>(
799785
rustc_query_impl::query_callbacks(arena),
800786
)
801787
})
802-
});
803-
804-
QueryContext { gcx }
788+
})
805789
}
806790

807791
/// Runs the resolution, type-checking, region checking and other

compiler/rustc_interface/src/queries.rs

+14-13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::errors::{FailedWritingFile, RustcErrorFatal, RustcErrorUnexpectedAnnotation};
22
use crate::interface::{Compiler, Result};
3-
use crate::passes::{self, BoxedResolver, QueryContext};
3+
use crate::passes::{self, BoxedResolver};
44

55
use rustc_ast as ast;
66
use rustc_codegen_ssa::traits::CodegenBackend;
@@ -64,7 +64,7 @@ impl<'a, T> std::ops::DerefMut for QueryResult<'a, T> {
6464
}
6565
}
6666

67-
impl<'a, 'tcx> QueryResult<'a, QueryContext<'tcx>> {
67+
impl<'a, 'tcx> QueryResult<'a, &'tcx GlobalCtxt<'tcx>> {
6868
pub fn enter<T>(&mut self, f: impl FnOnce(TyCtxt<'tcx>) -> T) -> T {
6969
(*self.0).get_mut().enter(f)
7070
}
@@ -78,7 +78,7 @@ impl<T> Default for Query<T> {
7878

7979
pub struct Queries<'tcx> {
8080
compiler: &'tcx Compiler,
81-
gcx: OnceCell<GlobalCtxt<'tcx>>,
81+
gcx_cell: OnceCell<GlobalCtxt<'tcx>>,
8282
queries: OnceCell<TcxQueries<'tcx>>,
8383

8484
arena: WorkerLocal<Arena<'tcx>>,
@@ -90,15 +90,16 @@ pub struct Queries<'tcx> {
9090
register_plugins: Query<(ast::Crate, Lrc<LintStore>)>,
9191
expansion: Query<(Lrc<ast::Crate>, Rc<RefCell<BoxedResolver>>, Lrc<LintStore>)>,
9292
dep_graph: Query<DepGraph>,
93-
global_ctxt: Query<QueryContext<'tcx>>,
93+
// This just points to what's in `gcx_cell`.
94+
gcx: Query<&'tcx GlobalCtxt<'tcx>>,
9495
ongoing_codegen: Query<Box<dyn Any>>,
9596
}
9697

9798
impl<'tcx> Queries<'tcx> {
9899
pub fn new(compiler: &'tcx Compiler) -> Queries<'tcx> {
99100
Queries {
100101
compiler,
101-
gcx: OnceCell::new(),
102+
gcx_cell: OnceCell::new(),
102103
queries: OnceCell::new(),
103104
arena: WorkerLocal::new(|_| Arena::default()),
104105
hir_arena: WorkerLocal::new(|_| rustc_hir::Arena::default()),
@@ -108,7 +109,7 @@ impl<'tcx> Queries<'tcx> {
108109
register_plugins: Default::default(),
109110
expansion: Default::default(),
110111
dep_graph: Default::default(),
111-
global_ctxt: Default::default(),
112+
gcx: Default::default(),
112113
ongoing_codegen: Default::default(),
113114
}
114115
}
@@ -207,8 +208,8 @@ impl<'tcx> Queries<'tcx> {
207208
})
208209
}
209210

210-
pub fn global_ctxt(&'tcx self) -> Result<QueryResult<'_, QueryContext<'tcx>>> {
211-
self.global_ctxt.compute(|| {
211+
pub fn global_ctxt(&'tcx self) -> Result<QueryResult<'_, &'tcx GlobalCtxt<'tcx>>> {
212+
self.gcx.compute(|| {
212213
let crate_name = *self.crate_name()?.borrow();
213214
let (krate, resolver, lint_store) = self.expansion()?.steal();
214215

@@ -218,18 +219,18 @@ impl<'tcx> Queries<'tcx> {
218219
ast_lowering: untracked_resolver_for_lowering,
219220
} = BoxedResolver::to_resolver_outputs(resolver);
220221

221-
let mut qcx = passes::create_global_ctxt(
222+
let gcx = passes::create_global_ctxt(
222223
self.compiler,
223224
lint_store,
224225
self.dep_graph()?.steal(),
225226
untracked,
226227
&self.queries,
227-
&self.gcx,
228+
&self.gcx_cell,
228229
&self.arena,
229230
&self.hir_arena,
230231
);
231232

232-
qcx.enter(|tcx| {
233+
gcx.enter(|tcx| {
233234
let feed = tcx.feed_unit_query();
234235
feed.resolver_for_lowering(
235236
tcx.arena.alloc(Steal::new((untracked_resolver_for_lowering, krate))),
@@ -239,7 +240,7 @@ impl<'tcx> Queries<'tcx> {
239240
let feed = tcx.feed_local_crate();
240241
feed.crate_name(crate_name);
241242
});
242-
Ok(qcx)
243+
Ok(gcx)
243244
})
244245
}
245246

@@ -387,7 +388,7 @@ impl Compiler {
387388

388389
// NOTE: intentionally does not compute the global context if it hasn't been built yet,
389390
// since that likely means there was a parse error.
390-
if let Some(Ok(gcx)) = &mut *queries.global_ctxt.result.borrow_mut() {
391+
if let Some(Ok(gcx)) = &mut *queries.gcx.result.borrow_mut() {
391392
let gcx = gcx.get_mut();
392393
// We assume that no queries are run past here. If there are new queries
393394
// after this point, they'll show up as "<unknown>" in self-profiling data.

compiler/rustc_middle/src/dep_graph/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl rustc_query_system::dep_graph::DepKind for DepKind {
5555
ty::tls::with_context(|icx| {
5656
let icx = ty::tls::ImplicitCtxt { task_deps, ..icx.clone() };
5757

58-
ty::tls::enter_context(&icx, |_| op())
58+
ty::tls::enter_context(&icx, op)
5959
})
6060
}
6161

compiler/rustc_middle/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#![feature(get_mut_unchecked)]
3535
#![feature(if_let_guard)]
3636
#![feature(iter_from_generator)]
37+
#![feature(local_key_cell_methods)]
3738
#![feature(negative_impls)]
3839
#![feature(never_type)]
3940
#![feature(extern_types)]

compiler/rustc_middle/src/ty/context.rs

+12
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,18 @@ pub struct GlobalCtxt<'tcx> {
468468
pub(crate) alloc_map: Lock<interpret::AllocMap<'tcx>>,
469469
}
470470

471+
impl<'tcx> GlobalCtxt<'tcx> {
472+
/// Installs `self` in a `TyCtxt` and `ImplicitCtxt` for the duration of
473+
/// `f`.
474+
pub fn enter<'a: 'tcx, F, R>(&'a self, f: F) -> R
475+
where
476+
F: FnOnce(TyCtxt<'tcx>) -> R,
477+
{
478+
let icx = tls::ImplicitCtxt::new(self);
479+
tls::enter_context(&icx, || f(icx.tcx))
480+
}
481+
}
482+
471483
impl<'tcx> TyCtxt<'tcx> {
472484
/// Expects a body and returns its codegen attributes.
473485
///

compiler/rustc_middle/src/ty/context/tls.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,8 @@ mod tlv {
8989
/// This is used to set the pointer to the new `ImplicitCtxt`.
9090
#[inline]
9191
pub(super) fn with_tlv<F: FnOnce() -> R, R>(value: *const (), f: F) -> R {
92-
let old = get_tlv();
93-
let _reset = rustc_data_structures::OnDrop(move || TLV.with(|tlv| tlv.set(old)));
94-
TLV.with(|tlv| tlv.set(value));
92+
let old = TLV.replace(value);
93+
let _reset = rustc_data_structures::OnDrop(move || TLV.set(old));
9594
f()
9695
}
9796
}
@@ -110,9 +109,9 @@ unsafe fn downcast<'a, 'tcx>(context: *const ()) -> &'a ImplicitCtxt<'a, 'tcx> {
110109
#[inline]
111110
pub fn enter_context<'a, 'tcx, F, R>(context: &ImplicitCtxt<'a, 'tcx>, f: F) -> R
112111
where
113-
F: FnOnce(&ImplicitCtxt<'a, 'tcx>) -> R,
112+
F: FnOnce() -> R,
114113
{
115-
tlv::with_tlv(erase(context), || f(&context))
114+
tlv::with_tlv(erase(context), f)
116115
}
117116

118117
/// Allows access to the current `ImplicitCtxt` in a closure if one is available.

compiler/rustc_query_impl/src/plumbing.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ impl QueryContext for QueryCtxt<'_> {
124124
};
125125

126126
// Use the `ImplicitCtxt` while we execute the query.
127-
tls::enter_context(&new_icx, |_| {
127+
tls::enter_context(&new_icx, || {
128128
rustc_data_structures::stack::ensure_sufficient_stack(compute)
129129
})
130130
})

compiler/rustc_session/src/options.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ fn build_options<O: Default>(
349349
#[allow(non_upper_case_globals)]
350350
mod desc {
351351
pub const parse_no_flag: &str = "no value";
352-
pub const parse_bool: &str = "one of: `y`, `yes`, `on`, `n`, `no`, or `off`";
352+
pub const parse_bool: &str = "one of: `y`, `yes`, `on`, `true`, `n`, `no`, `off` or `false`";
353353
pub const parse_opt_bool: &str = parse_bool;
354354
pub const parse_string: &str = "a string";
355355
pub const parse_opt_string: &str = parse_string;
@@ -433,11 +433,11 @@ mod parse {
433433
/// Use this for any boolean option that has a static default.
434434
pub(crate) fn parse_bool(slot: &mut bool, v: Option<&str>) -> bool {
435435
match v {
436-
Some("y") | Some("yes") | Some("on") | None => {
436+
Some("y") | Some("yes") | Some("on") | Some("true") | None => {
437437
*slot = true;
438438
true
439439
}
440-
Some("n") | Some("no") | Some("off") => {
440+
Some("n") | Some("no") | Some("off") | Some("false") => {
441441
*slot = false;
442442
true
443443
}
@@ -450,11 +450,11 @@ mod parse {
450450
/// other factors, such as other options, or target options.)
451451
pub(crate) fn parse_opt_bool(slot: &mut Option<bool>, v: Option<&str>) -> bool {
452452
match v {
453-
Some("y") | Some("yes") | Some("on") | None => {
453+
Some("y") | Some("yes") | Some("on") | Some("true") | None => {
454454
*slot = Some(true);
455455
true
456456
}
457-
Some("n") | Some("no") | Some("off") => {
457+
Some("n") | Some("no") | Some("off") | Some("false") => {
458458
*slot = Some(false);
459459
true
460460
}

compiler/rustc_trait_selection/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ rustc_span = { path = "../rustc_span" }
2424
rustc_target = { path = "../rustc_target" }
2525
rustc_transmute = { path = "../rustc_transmute", features = ["rustc"] }
2626
smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
27+
itertools = "0.10.1"

compiler/rustc_trait_selection/src/solve/assembly.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use super::infcx_ext::InferCtxtExt;
44
#[cfg(doc)]
55
use super::trait_goals::structural_traits::*;
66
use super::{CanonicalResponse, Certainty, EvalCtxt, Goal, MaybeCause, QueryResult};
7+
use itertools::Itertools;
78
use rustc_hir::def_id::DefId;
89
use rustc_infer::traits::query::NoSolution;
910
use rustc_infer::traits::util::elaborate_predicates;
@@ -489,9 +490,9 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
489490
i += 1;
490491
}
491492

492-
// If there are *STILL* multiple candidates, give up
493-
// and report ambiguity.
494-
if candidates.len() > 1 {
493+
// If there are *STILL* multiple candidates that have *different* response
494+
// results, give up and report ambiguity.
495+
if candidates.len() > 1 && !candidates.iter().map(|cand| cand.result).all_equal() {
495496
let certainty = if candidates.iter().all(|x| {
496497
matches!(x.result.value.certainty, Certainty::Maybe(MaybeCause::Overflow))
497498
}) {
@@ -503,6 +504,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
503504
}
504505
}
505506

507+
// FIXME: What if there are >1 candidates left with the same response, and one is a reservation impl?
506508
Ok(self.discard_reservation_impl(candidates.pop().unwrap()).result)
507509
}
508510

compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ impl<'tcx, 'a> GeneratorData<'tcx, 'a> {
9898
// obligation
9999
fn get_from_await_ty<F>(
100100
&self,
101+
tcx: TyCtxt<'tcx>,
101102
visitor: AwaitsVisitor,
102103
hir: map::Map<'tcx>,
103104
ty_matches: F,
@@ -134,9 +135,7 @@ impl<'tcx, 'a> GeneratorData<'tcx, 'a> {
134135
.unwrap_or_else(|| {
135136
bug!(
136137
"node_type: no type for node {}",
137-
ty::tls::with(|tcx| tcx
138-
.hir()
139-
.node_to_string(await_expr.hir_id))
138+
tcx.hir().node_to_string(await_expr.hir_id)
140139
)
141140
})
142141
},
@@ -2351,7 +2350,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
23512350

23522351
let mut interior_or_upvar_span = None;
23532352

2354-
let from_awaited_ty = generator_data.get_from_await_ty(visitor, hir, ty_matches);
2353+
let from_awaited_ty = generator_data.get_from_await_ty(self.tcx, visitor, hir, ty_matches);
23552354
debug!(?from_awaited_ty);
23562355

23572356
// The generator interior types share the same binders

src/bootstrap/download.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,10 @@ impl Config {
229229
"--retry",
230230
"3",
231231
"-Sf",
232-
"-o",
233232
]);
234-
curl.arg(tempfile);
235233
curl.arg(url);
234+
let f = File::create(tempfile).unwrap();
235+
curl.stdout(Stdio::from(f));
236236
if !self.check_run(&mut curl) {
237237
if self.build.contains("windows-msvc") {
238238
println!("Fallback to PowerShell");

0 commit comments

Comments
 (0)