Skip to content

Commit 1fc607b

Browse files
committed
Auto merge of #152399 - matthiaskrgr:rollup-uDIDnAN, r=matthiaskrgr
Rollup of 12 pull requests Successful merges: - #152388 (`rust-analyzer` subtree update) - #151613 (Align `ArrayWindows` trait impls with `Windows`) - #152134 (Set crt_static_allow_dylibs to true for Emscripten target) - #152166 (cleanup some more things in `proc_macro::bridge`) - #152236 (compiletest: `-Zunstable-options` for json targets) - #152287 (Fix an ICE in the vtable iteration for a trait reference in const eval when a supertrait not implemented) - #142957 (std: introduce path normalize methods at top of `std::path`) - #145504 (Add some conversion trait impls) - #152131 (Port rustc_no_implicit_bounds attribute to parser.) - #152315 (fix: rhs_span to rhs_span_new) - #152327 (Check stalled coroutine obligations eagerly) - #152377 (Rename the query system's `JobOwner` to `ActiveJobGuard`, and include `key_hash`)
2 parents 71dc761 + 2f16df1 commit 1fc607b

File tree

118 files changed

+1866
-939
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+1866
-939
lines changed

compiler/rustc_attr_parsing/src/attributes/crate_level.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,3 +283,12 @@ impl<S: Stage> NoArgsAttributeParser<S> for RustcPreserveUbChecksParser {
283283
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Crate)]);
284284
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcPreserveUbChecks;
285285
}
286+
287+
pub(crate) struct RustcNoImplicitBoundsParser;
288+
289+
impl<S: Stage> NoArgsAttributeParser<S> for RustcNoImplicitBoundsParser {
290+
const PATH: &[Symbol] = &[sym::rustc_no_implicit_bounds];
291+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
292+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Crate)]);
293+
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcNoImplicitBounds;
294+
}

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ attribute_parsers!(
282282
Single<WithoutArgs<RustcMainParser>>,
283283
Single<WithoutArgs<RustcNeverReturnsNullPointerParser>>,
284284
Single<WithoutArgs<RustcNoImplicitAutorefsParser>>,
285+
Single<WithoutArgs<RustcNoImplicitBoundsParser>>,
285286
Single<WithoutArgs<RustcNonConstTraitMethodParser>>,
286287
Single<WithoutArgs<RustcNounwindParser>>,
287288
Single<WithoutArgs<RustcOffloadKernelParser>>,

compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1695,7 +1695,7 @@ fn suggest_ampmut<'tcx>(
16951695
&& let Either::Left(rhs_stmt_new) = body.stmt_at(*assign)
16961696
&& let StatementKind::Assign(box (_, rvalue_new)) = &rhs_stmt_new.kind
16971697
&& let rhs_span_new = rhs_stmt_new.source_info.span
1698-
&& let Ok(rhs_str_new) = tcx.sess.source_map().span_to_snippet(rhs_span)
1698+
&& let Ok(rhs_str_new) = tcx.sess.source_map().span_to_snippet(rhs_span_new)
16991699
{
17001700
(rvalue, rhs_span, rhs_str) = (rvalue_new, rhs_span_new, rhs_str_new);
17011701
}

compiler/rustc_borrowck/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ fn mir_borrowck(
121121
let (input_body, _) = tcx.mir_promoted(def);
122122
debug!("run query mir_borrowck: {}", tcx.def_path_str(def));
123123

124+
// We should eagerly check stalled coroutine obligations from HIR typeck.
125+
// Not doing so leads to silent normalization failures later, which will
126+
// fail to register opaque types in the next solver.
127+
tcx.check_coroutine_obligations(def)?;
128+
124129
let input_body: &Body<'_> = &input_body.borrow();
125130
if let Some(guar) = input_body.tainted_by_errors {
126131
debug!("Skipping borrowck because of tainted body");

compiler/rustc_hir/src/attrs/data_structures.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,6 +1177,9 @@ pub enum AttributeKind {
11771177
/// Represents `#[rustc_no_implicit_autorefs]`
11781178
RustcNoImplicitAutorefs,
11791179

1180+
/// Represents `#[rustc_no_implicit_bounds]`
1181+
RustcNoImplicitBounds,
1182+
11801183
/// Represents `#[rustc_non_const_trait_method]`.
11811184
RustcNonConstTraitMethod,
11821185

compiler/rustc_hir/src/attrs/encode_cross_crate.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ impl AttributeKind {
137137
RustcMustImplementOneOf { .. } => No,
138138
RustcNeverReturnsNullPointer => Yes,
139139
RustcNoImplicitAutorefs => Yes,
140+
RustcNoImplicitBounds => No,
140141
RustcNonConstTraitMethod => No, // should be reported via other queries like `constness`
141142
RustcNounwind => No,
142143
RustcObjcClass { .. } => No,

compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@ use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
44
use rustc_errors::codes::*;
55
use rustc_errors::struct_span_code_err;
66
use rustc_hir as hir;
7-
use rustc_hir::PolyTraitRef;
7+
use rustc_hir::attrs::AttributeKind;
88
use rustc_hir::def::{DefKind, Res};
99
use rustc_hir::def_id::{CRATE_DEF_ID, DefId};
10+
use rustc_hir::{PolyTraitRef, find_attr};
1011
use rustc_middle::bug;
1112
use rustc_middle::ty::{
1213
self as ty, IsSuggestable, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitableExt,
1314
TypeVisitor, Upcast,
1415
};
15-
use rustc_span::{ErrorGuaranteed, Ident, Span, kw, sym};
16+
use rustc_span::{ErrorGuaranteed, Ident, Span, kw};
1617
use rustc_trait_selection::traits;
1718
use smallvec::SmallVec;
1819
use tracing::{debug, instrument};
@@ -170,7 +171,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
170171
let tcx = self.tcx();
171172

172173
// Skip adding any default bounds if `#![rustc_no_implicit_bounds]`
173-
if tcx.has_attr(CRATE_DEF_ID, sym::rustc_no_implicit_bounds) {
174+
if find_attr!(tcx.get_all_attrs(CRATE_DEF_ID), AttributeKind::RustcNoImplicitBounds) {
174175
return;
175176
}
176177

@@ -284,7 +285,8 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
284285
context: ImpliedBoundsContext<'tcx>,
285286
) -> bool {
286287
let collected = collect_bounds(hir_bounds, context, trait_def_id);
287-
!self.tcx().has_attr(CRATE_DEF_ID, sym::rustc_no_implicit_bounds) && !collected.any()
288+
!find_attr!(self.tcx().get_all_attrs(CRATE_DEF_ID), AttributeKind::RustcNoImplicitBounds)
289+
&& !collected.any()
288290
}
289291

290292
fn reject_duplicate_relaxed_bounds(&self, relaxed_bounds: SmallVec<[&PolyTraitRef<'_>; 1]>) {

compiler/rustc_interface/src/passes.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,18 +1116,14 @@ fn run_required_analyses(tcx: TyCtxt<'_>) {
11161116
{
11171117
tcx.ensure_ok().mir_drops_elaborated_and_const_checked(def_id);
11181118
}
1119-
if tcx.is_coroutine(def_id.to_def_id()) {
1120-
tcx.ensure_ok().mir_coroutine_witnesses(def_id);
1121-
let _ = tcx.ensure_ok().check_coroutine_obligations(
1122-
tcx.typeck_root_def_id(def_id.to_def_id()).expect_local(),
1119+
if tcx.is_coroutine(def_id.to_def_id())
1120+
&& (!tcx.is_async_drop_in_place_coroutine(def_id.to_def_id()))
1121+
{
1122+
// Eagerly check the unsubstituted layout for cycles.
1123+
tcx.ensure_ok().layout_of(
1124+
ty::TypingEnv::post_analysis(tcx, def_id.to_def_id())
1125+
.as_query_input(tcx.type_of(def_id).instantiate_identity()),
11231126
);
1124-
if !tcx.is_async_drop_in_place_coroutine(def_id.to_def_id()) {
1125-
// Eagerly check the unsubstituted layout for cycles.
1126-
tcx.ensure_ok().layout_of(
1127-
ty::TypingEnv::post_analysis(tcx, def_id.to_def_id())
1128-
.as_query_input(tcx.type_of(def_id).instantiate_identity()),
1129-
);
1130-
}
11311127
}
11321128
});
11331129
});

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ pub struct ImplicitCtxt<'a, 'tcx> {
1616
/// The current `TyCtxt`.
1717
pub tcx: TyCtxt<'tcx>,
1818

19-
/// The current query job, if any. This is updated by `JobOwner::start` in
20-
/// `ty::query::plumbing` when executing a query.
19+
/// The current query job, if any.
2120
pub query: Option<QueryJobId>,
2221

2322
/// Used to prevent queries from calling too deeply.

compiler/rustc_passes/src/check_attr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
330330
| AttributeKind::RustcMir(_)
331331
| AttributeKind::RustcNeverReturnsNullPointer
332332
| AttributeKind::RustcNoImplicitAutorefs
333+
| AttributeKind::RustcNoImplicitBounds
333334
| AttributeKind::RustcNonConstTraitMethod
334335
| AttributeKind::RustcNounwind
335336
| AttributeKind::RustcObjcClass { .. }
@@ -413,7 +414,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
413414
// crate-level attrs, are checked below
414415
| sym::feature
415416
| sym::register_tool
416-
| sym::rustc_no_implicit_bounds
417417
| sym::test_runner,
418418
..
419419
] => {}

0 commit comments

Comments
 (0)