Skip to content

Commit 65a6e22

Browse files
committed
Auto merge of #104845 - matthiaskrgr:rollup-tckj956, r=matthiaskrgr
Rollup of 11 pull requests Successful merges: - #104514 (Use node_ty_opt to avoid ICE in visit_ty) - #104704 (Allow power10-vector feature in PowerPC) - #104747 (resolve: Don't use constructor def ids in the map for field names) - #104773 (OpaqueCast projections are always overlapping, they can't possibly be disjoint) - #104774 (Document split{_ascii,}_whitespace() for empty strings) - #104780 (make `error_reported` check for delayed bugs) - #104782 (Bump the const eval step limit) - #104792 (rustdoc: simplify `.search-results-title` CSS) - #104796 (lint: do not warn unused parens around higher-ranked function pointers) - #104820 (Remove normalize_projection_type) - #104822 (with_query_mode -> new) Failed merges: - #104716 (move 2 candidates into builtin candidate) - #104841 (Assert that we don't capture escaping bound vars in `Fn` trait selection) r? `@ghost` `@rustbot` modify labels: rollup
2 parents b3bc6bf + 1048a85 commit 65a6e22

File tree

29 files changed

+149
-127
lines changed

29 files changed

+149
-127
lines changed

compiler/rustc_borrowck/src/places_conflict.rs

+4-10
Original file line numberDiff line numberDiff line change
@@ -320,16 +320,10 @@ fn place_projection_conflict<'tcx>(
320320
debug!("place_element_conflict: DISJOINT-OR-EQ-DEREF");
321321
Overlap::EqualOrDisjoint
322322
}
323-
(ProjectionElem::OpaqueCast(v1), ProjectionElem::OpaqueCast(v2)) => {
324-
if v1 == v2 {
325-
// same type - recur.
326-
debug!("place_element_conflict: DISJOINT-OR-EQ-OPAQUE");
327-
Overlap::EqualOrDisjoint
328-
} else {
329-
// Different types. Disjoint!
330-
debug!("place_element_conflict: DISJOINT-OPAQUE");
331-
Overlap::Disjoint
332-
}
323+
(ProjectionElem::OpaqueCast(_), ProjectionElem::OpaqueCast(_)) => {
324+
// casts to other types may always conflict irrespective of the type being cast to.
325+
debug!("place_element_conflict: DISJOINT-OR-EQ-OPAQUE");
326+
Overlap::EqualOrDisjoint
333327
}
334328
(ProjectionElem::Field(f1, _), ProjectionElem::Field(f2, _)) => {
335329
if f1 == f2 {

compiler/rustc_codegen_ssa/src/target_features.rs

+1
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ const HEXAGON_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
215215
const POWERPC_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
216216
// tidy-alphabetical-start
217217
("altivec", Some(sym::powerpc_target_feature)),
218+
("power10-vector", Some(sym::powerpc_target_feature)),
218219
("power8-altivec", Some(sym::powerpc_target_feature)),
219220
("power8-vector", Some(sym::powerpc_target_feature)),
220221
("power9-altivec", Some(sym::powerpc_target_feature)),

compiler/rustc_errors/src/lib.rs

+18-3
Original file line numberDiff line numberDiff line change
@@ -1044,13 +1044,24 @@ impl Handler {
10441044
}
10451045
pub fn has_errors_or_lint_errors(&self) -> Option<ErrorGuaranteed> {
10461046
if self.inner.borrow().has_errors_or_lint_errors() {
1047-
Some(ErrorGuaranteed(()))
1047+
Some(ErrorGuaranteed::unchecked_claim_error_was_emitted())
1048+
} else {
1049+
None
1050+
}
1051+
}
1052+
pub fn has_errors_or_delayed_span_bugs(&self) -> Option<ErrorGuaranteed> {
1053+
if self.inner.borrow().has_errors_or_delayed_span_bugs() {
1054+
Some(ErrorGuaranteed::unchecked_claim_error_was_emitted())
10481055
} else {
10491056
None
10501057
}
10511058
}
1052-
pub fn has_errors_or_delayed_span_bugs(&self) -> bool {
1053-
self.inner.borrow().has_errors_or_delayed_span_bugs()
1059+
pub fn is_compilation_going_to_fail(&self) -> Option<ErrorGuaranteed> {
1060+
if self.inner.borrow().is_compilation_going_to_fail() {
1061+
Some(ErrorGuaranteed::unchecked_claim_error_was_emitted())
1062+
} else {
1063+
None
1064+
}
10541065
}
10551066

10561067
pub fn print_error_count(&self, registry: &Registry) {
@@ -1484,6 +1495,10 @@ impl HandlerInner {
14841495
self.err_count() > 0 || self.lint_err_count > 0 || self.warn_count > 0
14851496
}
14861497

1498+
fn is_compilation_going_to_fail(&self) -> bool {
1499+
self.has_errors() || self.lint_err_count > 0 || !self.delayed_span_bugs.is_empty()
1500+
}
1501+
14871502
fn abort_if_errors(&mut self) {
14881503
self.emit_stashed_diagnostics();
14891504

compiler/rustc_hir_typeck/src/writeback.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -361,9 +361,12 @@ impl<'cx, 'tcx> Visitor<'tcx> for WritebackCx<'cx, 'tcx> {
361361

362362
fn visit_ty(&mut self, hir_ty: &'tcx hir::Ty<'tcx>) {
363363
intravisit::walk_ty(self, hir_ty);
364-
let ty = self.fcx.node_ty(hir_ty.hir_id);
365-
let ty = self.resolve(ty, &hir_ty.span);
366-
self.write_ty_to_typeck_results(hir_ty.hir_id, ty);
364+
// If there are type checking errors, Type privacy pass will stop,
365+
// so we may not get the type from hid_id, see #104513
366+
if let Some(ty) = self.fcx.node_ty_opt(hir_ty.hir_id) {
367+
let ty = self.resolve(ty, &hir_ty.span);
368+
self.write_ty_to_typeck_results(hir_ty.hir_id, ty);
369+
}
367370
}
368371

369372
fn visit_infer(&mut self, inf: &'tcx hir::InferArg) {

compiler/rustc_incremental/src/persist/fs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ pub fn finalize_session_directory(sess: &Session, svh: Svh) {
322322

323323
let incr_comp_session_dir: PathBuf = sess.incr_comp_session_dir().clone();
324324

325-
if sess.has_errors_or_delayed_span_bugs() {
325+
if let Some(_) = sess.has_errors_or_delayed_span_bugs() {
326326
// If there have been any errors during compilation, we don't want to
327327
// publish this session directory. Rather, we'll just delete it.
328328

compiler/rustc_incremental/src/persist/save.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub fn save_dep_graph(tcx: TyCtxt<'_>) {
2828
return;
2929
}
3030
// This is going to be deleted in finalize_session_directory, so let's not create it
31-
if sess.has_errors_or_delayed_span_bugs() {
31+
if let Some(_) = sess.has_errors_or_delayed_span_bugs() {
3232
return;
3333
}
3434

@@ -89,7 +89,7 @@ pub fn save_work_product_index(
8989
return;
9090
}
9191
// This is going to be deleted in finalize_session_directory, so let's not create it
92-
if sess.has_errors_or_delayed_span_bugs() {
92+
if let Some(_) = sess.has_errors_or_delayed_span_bugs() {
9393
return;
9494
}
9595

compiler/rustc_infer/src/traits/engine.rs

-8
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,6 @@ use super::FulfillmentError;
88
use super::{ObligationCause, PredicateObligation};
99

1010
pub trait TraitEngine<'tcx>: 'tcx {
11-
fn normalize_projection_type(
12-
&mut self,
13-
infcx: &InferCtxt<'tcx>,
14-
param_env: ty::ParamEnv<'tcx>,
15-
projection_ty: ty::ProjectionTy<'tcx>,
16-
cause: ObligationCause<'tcx>,
17-
) -> Ty<'tcx>;
18-
1911
/// Requires that `ty` must implement the trait with `def_id` in
2012
/// the given environment. This trait must not have any type
2113
/// parameters (except for `Self`).

compiler/rustc_lint/src/unused.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1015,6 +1015,7 @@ impl EarlyLintPass for UnusedParens {
10151015
if let ast::TyKind::Paren(r) = &ty.kind {
10161016
match &r.kind {
10171017
ast::TyKind::TraitObject(..) => {}
1018+
ast::TyKind::BareFn(b) if b.generic_params.len() > 0 => {}
10181019
ast::TyKind::ImplTrait(_, bounds) if bounds.len() > 1 => {}
10191020
ast::TyKind::Array(_, len) => {
10201021
self.check_unused_delims_expr(

compiler/rustc_middle/src/middle/limits.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub fn provide(providers: &mut ty::query::Providers) {
3838
tcx.hir().krate_attrs(),
3939
tcx.sess,
4040
sym::const_eval_limit,
41-
1_000_000,
41+
2_000_000,
4242
),
4343
}
4444
}

compiler/rustc_middle/src/ty/visit.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,10 @@ pub trait TypeVisitable<'tcx>: fmt::Debug + Clone {
9797
}
9898
fn error_reported(&self) -> Result<(), ErrorGuaranteed> {
9999
if self.references_error() {
100-
if let Some(reported) = ty::tls::with(|tcx| tcx.sess.has_errors()) {
100+
if let Some(reported) = ty::tls::with(|tcx| tcx.sess.is_compilation_going_to_fail()) {
101101
Err(reported)
102102
} else {
103-
bug!("expect tcx.sess.has_errors return true");
103+
bug!("expect tcx.sess.is_compilation_going_to_fail return `Some`");
104104
}
105105
} else {
106106
Ok(())

compiler/rustc_query_system/src/dep_graph/graph.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ impl<K: DepKind> DepGraph<K> {
667667
None => {}
668668
}
669669

670-
if !qcx.dep_context().sess().has_errors_or_delayed_span_bugs() {
670+
if let None = qcx.dep_context().sess().has_errors_or_delayed_span_bugs() {
671671
panic!("try_mark_previous_green() - Forcing the DepNode should have set its color")
672672
}
673673

compiler/rustc_resolve/src/build_reduced_graph.rs

+10-18
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use rustc_middle::metadata::ModChild;
3030
use rustc_middle::ty::{self, DefIdTree};
3131
use rustc_session::cstore::CrateStore;
3232
use rustc_span::hygiene::{ExpnId, LocalExpnId, MacroKind};
33-
use rustc_span::source_map::{respan, Spanned};
33+
use rustc_span::source_map::respan;
3434
use rustc_span::symbol::{kw, sym, Ident, Symbol};
3535
use rustc_span::Span;
3636

@@ -329,10 +329,12 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
329329
.iter()
330330
.map(|field| respan(field.span, field.ident.map_or(kw::Empty, |ident| ident.name)))
331331
.collect();
332-
self.insert_field_names(def_id, field_names);
332+
self.r.field_names.insert(def_id, field_names);
333333
}
334334

335-
fn insert_field_names(&mut self, def_id: DefId, field_names: Vec<Spanned<Symbol>>) {
335+
fn insert_field_names_extern(&mut self, def_id: DefId) {
336+
let field_names =
337+
self.r.cstore().struct_field_names_untracked(def_id, self.r.session).collect();
336338
self.r.field_names.insert(def_id, field_names);
337339
}
338340

@@ -995,8 +997,6 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
995997
let cstore = self.r.cstore();
996998
match res {
997999
Res::Def(DefKind::Struct, def_id) => {
998-
let field_names =
999-
cstore.struct_field_names_untracked(def_id, self.r.session).collect();
10001000
if let Some((ctor_kind, ctor_def_id)) = cstore.ctor_untracked(def_id) {
10011001
let ctor_res = Res::Def(DefKind::Ctor(CtorOf::Struct, ctor_kind), ctor_def_id);
10021002
let ctor_vis = cstore.visibility_untracked(ctor_def_id);
@@ -1006,13 +1006,9 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
10061006
.struct_constructors
10071007
.insert(def_id, (ctor_res, ctor_vis, field_visibilities));
10081008
}
1009-
self.insert_field_names(def_id, field_names);
1010-
}
1011-
Res::Def(DefKind::Union, def_id) => {
1012-
let field_names =
1013-
cstore.struct_field_names_untracked(def_id, self.r.session).collect();
1014-
self.insert_field_names(def_id, field_names);
1009+
self.insert_field_names_extern(def_id)
10151010
}
1011+
Res::Def(DefKind::Union, def_id) => self.insert_field_names_extern(def_id),
10161012
Res::Def(DefKind::AssocFn, def_id) => {
10171013
if cstore.fn_has_self_parameter_untracked(def_id, self.r.session) {
10181014
self.r.has_self.insert(def_id);
@@ -1514,20 +1510,16 @@ impl<'a, 'b> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b> {
15141510
};
15151511

15161512
// Define a constructor name in the value namespace.
1517-
let fields_id = if let Some((ctor_kind, ctor_node_id)) = CtorKind::from_ast(&variant.data) {
1513+
if let Some((ctor_kind, ctor_node_id)) = CtorKind::from_ast(&variant.data) {
15181514
let ctor_def_id = self.r.local_def_id(ctor_node_id);
15191515
let ctor_res =
15201516
Res::Def(DefKind::Ctor(CtorOf::Variant, ctor_kind), ctor_def_id.to_def_id());
15211517
self.r.define(parent, ident, ValueNS, (ctor_res, ctor_vis, variant.span, expn_id));
15221518
self.r.visibilities.insert(ctor_def_id, ctor_vis);
1523-
ctor_def_id
1524-
} else {
1525-
def_id
1526-
};
1519+
}
15271520

15281521
// Record field names for error reporting.
1529-
// FIXME: Always use non-ctor id as the key.
1530-
self.insert_field_names_local(fields_id.to_def_id(), &variant.data);
1522+
self.insert_field_names_local(def_id.to_def_id(), &variant.data);
15311523

15321524
visit::walk_variant(self, variant);
15331525
}

compiler/rustc_resolve/src/late/diagnostics.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use rustc_hir::def::Namespace::{self, *};
2121
use rustc_hir::def::{self, CtorKind, CtorOf, DefKind};
2222
use rustc_hir::def_id::{DefId, CRATE_DEF_ID, LOCAL_CRATE};
2323
use rustc_hir::PrimTy;
24+
use rustc_middle::ty::DefIdTree;
2425
use rustc_session::lint;
2526
use rustc_session::parse::feature_err;
2627
use rustc_session::Session;
@@ -1462,7 +1463,8 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
14621463
_ => return false,
14631464
}
14641465
}
1465-
(Res::Def(DefKind::Ctor(_, CtorKind::Fn), def_id), _) if ns == ValueNS => {
1466+
(Res::Def(DefKind::Ctor(_, CtorKind::Fn), ctor_def_id), _) if ns == ValueNS => {
1467+
let def_id = self.r.parent(ctor_def_id);
14661468
if let Some(span) = self.def_span(def_id) {
14671469
err.span_label(span, &format!("`{}` defined here", path_str));
14681470
}
@@ -1953,7 +1955,8 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
19531955
));
19541956
}
19551957
} else {
1956-
let needs_placeholder = |def_id: DefId, kind: CtorKind| {
1958+
let needs_placeholder = |ctor_def_id: DefId, kind: CtorKind| {
1959+
let def_id = self.r.parent(ctor_def_id);
19571960
let has_no_fields = self.r.field_names.get(&def_id).map_or(false, |f| f.is_empty());
19581961
match kind {
19591962
CtorKind::Const => false,

compiler/rustc_session/src/session.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -538,9 +538,12 @@ impl Session {
538538
pub fn has_errors(&self) -> Option<ErrorGuaranteed> {
539539
self.diagnostic().has_errors()
540540
}
541-
pub fn has_errors_or_delayed_span_bugs(&self) -> bool {
541+
pub fn has_errors_or_delayed_span_bugs(&self) -> Option<ErrorGuaranteed> {
542542
self.diagnostic().has_errors_or_delayed_span_bugs()
543543
}
544+
pub fn is_compilation_going_to_fail(&self) -> Option<ErrorGuaranteed> {
545+
self.diagnostic().is_compilation_going_to_fail()
546+
}
544547
pub fn abort_if_errors(&self) {
545548
self.diagnostic().abort_if_errors();
546549
}

compiler/rustc_trait_selection/src/autoderef.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::errors::AutoDerefReachedRecursionLimit;
2+
use crate::infer::InferCtxtExt as _;
23
use crate::traits::query::evaluate_obligation::InferCtxtExt;
34
use crate::traits::{self, TraitEngine, TraitEngineExt};
45
use rustc_hir as hir;
@@ -137,16 +138,14 @@ impl<'a, 'tcx> Autoderef<'a, 'tcx> {
137138
return None;
138139
}
139140

140-
let mut fulfillcx = <dyn TraitEngine<'tcx>>::new_in_snapshot(tcx);
141-
let normalized_ty = fulfillcx.normalize_projection_type(
142-
&self.infcx,
143-
self.param_env,
144-
ty::ProjectionTy {
145-
item_def_id: tcx.lang_items().deref_target()?,
146-
substs: trait_ref.substs,
147-
},
141+
let normalized_ty = self.infcx.partially_normalize_associated_types_in(
148142
cause,
143+
self.param_env,
144+
tcx.mk_projection(tcx.lang_items().deref_target()?, trait_ref.substs),
149145
);
146+
let mut fulfillcx = <dyn TraitEngine<'tcx>>::new_in_snapshot(tcx);
147+
let normalized_ty =
148+
normalized_ty.into_value_registering_obligations(self.infcx, &mut *fulfillcx);
150149
let errors = fulfillcx.select_where_possible(&self.infcx);
151150
if !errors.is_empty() {
152151
// This shouldn't happen, except for evaluate/fulfill mismatches,

compiler/rustc_trait_selection/src/traits/chalk_fulfill.rs

+3-13
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ use crate::infer::canonical::OriginalQueryValues;
44
use crate::infer::InferCtxt;
55
use crate::traits::query::NoSolution;
66
use crate::traits::{
7-
ChalkEnvironmentAndGoal, FulfillmentError, FulfillmentErrorCode, ObligationCause,
8-
PredicateObligation, SelectionError, TraitEngine,
7+
ChalkEnvironmentAndGoal, FulfillmentError, FulfillmentErrorCode, PredicateObligation,
8+
SelectionError, TraitEngine,
99
};
1010
use rustc_data_structures::fx::{FxHashMap, FxIndexSet};
11-
use rustc_middle::ty::{self, Ty, TypeVisitable};
11+
use rustc_middle::ty::{self, TypeVisitable};
1212

1313
pub struct FulfillmentContext<'tcx> {
1414
obligations: FxIndexSet<PredicateObligation<'tcx>>,
@@ -33,16 +33,6 @@ impl FulfillmentContext<'_> {
3333
}
3434

3535
impl<'tcx> TraitEngine<'tcx> for FulfillmentContext<'tcx> {
36-
fn normalize_projection_type(
37-
&mut self,
38-
infcx: &InferCtxt<'tcx>,
39-
_param_env: ty::ParamEnv<'tcx>,
40-
projection_ty: ty::ProjectionTy<'tcx>,
41-
_cause: ObligationCause<'tcx>,
42-
) -> Ty<'tcx> {
43-
infcx.tcx.mk_ty(ty::Projection(projection_ty))
44-
}
45-
4636
fn register_predicate_obligation(
4737
&mut self,
4838
infcx: &InferCtxt<'tcx>,

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

+1-4
Original file line numberDiff line numberDiff line change
@@ -2112,10 +2112,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
21122112
};
21132113

21142114
let obligation = obligation.with(self.tcx, trait_ref.to_poly_trait_predicate());
2115-
let mut selcx = SelectionContext::with_query_mode(
2116-
&self,
2117-
crate::traits::TraitQueryMode::Standard,
2118-
);
2115+
let mut selcx = SelectionContext::new(&self);
21192116
match selcx.select_from_obligation(&obligation) {
21202117
Ok(None) => {
21212118
let impls = ambiguity::recompute_applicable_impls(self.infcx, &obligation);

0 commit comments

Comments
 (0)