Skip to content

Commit dd481ba

Browse files
committed
Auto merge of #151129 - JonathanBrouwer:rollup-XJJmPLo, r=JonathanBrouwer
Rollup of 12 pull requests Successful merges: - #150585 (Add a context-consistency check before emitting redundant generic-argument suggestions) - #150586 (rustdoc: Fix intra-doc link bugs involving type aliases and associated items) - #150590 (Don't try to recover keyword as non-keyword identifier ) - #150817 (cleanup: remove borrowck handling for inline const patterns) - #150939 (resolve: Relax some asserts in glob overwriting and add tests) - #150966 (rustc_target: Remove unused Arch::PowerPC64LE) - #150971 (Disallow eii in statement position) - #151016 (fix: WASI threading regression by disabling pthread usage) - #151046 (compiler: Make Externally Implementable Item (eii) macros "semiopaque") - #151103 (mir_build: Simplify length-determination and indexing for array/slice patterns) - #151117 (Avoid serde dependency in build_helper when not necessary) - #151127 (Delete `MetaItemOrLitParser::Err`) r? @ghost
2 parents 86a49fd + c57dafe commit dd481ba

Some content is hidden

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

47 files changed

+902
-541
lines changed

compiler/rustc_attr_parsing/src/attributes/cfg.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ pub fn parse_cfg_entry<S: Stage>(
9494
LitKind::Bool(b) => CfgEntry::Bool(b, lit.span),
9595
_ => return Err(cx.expected_identifier(lit.span)),
9696
},
97-
MetaItemOrLitParser::Err(_, err) => return Err(*err),
9897
})
9998
}
10099

compiler/rustc_attr_parsing/src/attributes/doc.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -514,9 +514,6 @@ impl DocParser {
514514
MetaItemOrLitParser::Lit(lit) => {
515515
cx.unexpected_literal(lit.span);
516516
}
517-
MetaItemOrLitParser::Err(..) => {
518-
// already had an error here, move on.
519-
}
520517
}
521518
}
522519
}
@@ -600,9 +597,6 @@ impl DocParser {
600597
MetaItemOrLitParser::Lit(lit) => {
601598
cx.expected_name_value(lit.span, None);
602599
}
603-
MetaItemOrLitParser::Err(..) => {
604-
// already had an error here, move on.
605-
}
606600
}
607601
}
608602
}

compiler/rustc_attr_parsing/src/parser.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use rustc_parse::exp;
1818
use rustc_parse::parser::{ForceCollect, Parser, PathStyle, token_descr};
1919
use rustc_session::errors::{create_lit_error, report_lit_error};
2020
use rustc_session::parse::ParseSess;
21-
use rustc_span::{ErrorGuaranteed, Ident, Span, Symbol, sym};
21+
use rustc_span::{Ident, Span, Symbol, sym};
2222
use thin_vec::ThinVec;
2323

2424
use crate::ShouldEmit;
@@ -192,7 +192,6 @@ impl ArgParser {
192192
pub enum MetaItemOrLitParser {
193193
MetaItemParser(MetaItemParser),
194194
Lit(MetaItemLit),
195-
Err(Span, ErrorGuaranteed),
196195
}
197196

198197
impl MetaItemOrLitParser {
@@ -210,21 +209,20 @@ impl MetaItemOrLitParser {
210209
generic_meta_item_parser.span()
211210
}
212211
MetaItemOrLitParser::Lit(meta_item_lit) => meta_item_lit.span,
213-
MetaItemOrLitParser::Err(span, _) => *span,
214212
}
215213
}
216214

217215
pub fn lit(&self) -> Option<&MetaItemLit> {
218216
match self {
219217
MetaItemOrLitParser::Lit(meta_item_lit) => Some(meta_item_lit),
220-
_ => None,
218+
MetaItemOrLitParser::MetaItemParser(_) => None,
221219
}
222220
}
223221

224222
pub fn meta_item(&self) -> Option<&MetaItemParser> {
225223
match self {
226224
MetaItemOrLitParser::MetaItemParser(parser) => Some(parser),
227-
_ => None,
225+
MetaItemOrLitParser::Lit(_) => None,
228226
}
229227
}
230228
}

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 9 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use rustc_infer::infer::{
1919
BoundRegionConversionTime, InferCtxt, NllRegionVariableOrigin, RegionVariableOrigin,
2020
};
2121
use rustc_infer::traits::PredicateObligations;
22+
use rustc_middle::bug;
2223
use rustc_middle::mir::visit::{NonMutatingUseContext, PlaceContext, Visitor};
2324
use rustc_middle::mir::*;
2425
use rustc_middle::traits::query::NoSolution;
@@ -28,7 +29,6 @@ use rustc_middle::ty::{
2829
self, CanonicalUserTypeAnnotation, CanonicalUserTypeAnnotations, CoroutineArgsExt,
2930
GenericArgsRef, Ty, TyCtxt, TypeVisitableExt, UserArgs, UserTypeAnnotationIndex, fold_regions,
3031
};
31-
use rustc_middle::{bug, span_bug};
3232
use rustc_mir_dataflow::move_paths::MoveData;
3333
use rustc_mir_dataflow::points::DenseLocationMap;
3434
use rustc_span::def_id::CRATE_DEF_ID;
@@ -387,18 +387,10 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
387387
#[instrument(skip(self), level = "debug")]
388388
fn check_user_type_annotations(&mut self) {
389389
debug!(?self.user_type_annotations);
390-
let tcx = self.tcx();
391390
for user_annotation in self.user_type_annotations {
392391
let CanonicalUserTypeAnnotation { span, ref user_ty, inferred_ty } = *user_annotation;
393392
let annotation = self.instantiate_canonical(span, user_ty);
394-
if let ty::UserTypeKind::TypeOf(def, args) = annotation.kind
395-
&& let DefKind::InlineConst = tcx.def_kind(def)
396-
{
397-
assert!(annotation.bounds.is_empty());
398-
self.check_inline_const(inferred_ty, def.expect_local(), args, span);
399-
} else {
400-
self.ascribe_user_type(inferred_ty, annotation, span);
401-
}
393+
self.ascribe_user_type(inferred_ty, annotation, span);
402394
}
403395
}
404396

@@ -560,36 +552,6 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
560552
self.constraints.liveness_constraints.add_location(region, location);
561553
}
562554
}
563-
564-
fn check_inline_const(
565-
&mut self,
566-
inferred_ty: Ty<'tcx>,
567-
def_id: LocalDefId,
568-
args: UserArgs<'tcx>,
569-
span: Span,
570-
) {
571-
assert!(args.user_self_ty.is_none());
572-
let tcx = self.tcx();
573-
let const_ty = tcx.type_of(def_id).instantiate(tcx, args.args);
574-
if let Err(terr) =
575-
self.eq_types(const_ty, inferred_ty, Locations::All(span), ConstraintCategory::Boring)
576-
{
577-
span_bug!(
578-
span,
579-
"bad inline const pattern: ({:?} = {:?}) {:?}",
580-
const_ty,
581-
inferred_ty,
582-
terr
583-
);
584-
}
585-
let args = self.infcx.resolve_vars_if_possible(args.args);
586-
let predicates = self.prove_closure_bounds(tcx, def_id, args, Locations::All(span));
587-
self.normalize_and_prove_instantiated_predicates(
588-
def_id.to_def_id(),
589-
predicates,
590-
Locations::All(span),
591-
);
592-
}
593555
}
594556

595557
impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
@@ -1731,12 +1693,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
17311693
let def_id = uv.def;
17321694
if tcx.def_kind(def_id) == DefKind::InlineConst {
17331695
let def_id = def_id.expect_local();
1734-
let predicates = self.prove_closure_bounds(
1735-
tcx,
1736-
def_id,
1737-
uv.args,
1738-
location.to_locations(),
1739-
);
1696+
let predicates = self.prove_closure_bounds(tcx, def_id, uv.args, location);
17401697
self.normalize_and_prove_instantiated_predicates(
17411698
def_id.to_def_id(),
17421699
predicates,
@@ -2519,15 +2476,9 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
25192476
// clauses on the struct.
25202477
AggregateKind::Closure(def_id, args)
25212478
| AggregateKind::CoroutineClosure(def_id, args)
2522-
| AggregateKind::Coroutine(def_id, args) => (
2523-
def_id,
2524-
self.prove_closure_bounds(
2525-
tcx,
2526-
def_id.expect_local(),
2527-
args,
2528-
location.to_locations(),
2529-
),
2530-
),
2479+
| AggregateKind::Coroutine(def_id, args) => {
2480+
(def_id, self.prove_closure_bounds(tcx, def_id.expect_local(), args, location))
2481+
}
25312482

25322483
AggregateKind::Array(_) | AggregateKind::Tuple | AggregateKind::RawPtr(..) => {
25332484
(CRATE_DEF_ID.to_def_id(), ty::InstantiatedPredicates::empty())
@@ -2546,12 +2497,12 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
25462497
tcx: TyCtxt<'tcx>,
25472498
def_id: LocalDefId,
25482499
args: GenericArgsRef<'tcx>,
2549-
locations: Locations,
2500+
location: Location,
25502501
) -> ty::InstantiatedPredicates<'tcx> {
25512502
let root_def_id = self.root_cx.root_def_id();
25522503
// We will have to handle propagated closure requirements for this closure,
25532504
// but need to defer this until the nested body has been fully borrow checked.
2554-
self.deferred_closure_requirements.push((def_id, args, locations));
2505+
self.deferred_closure_requirements.push((def_id, args, location.to_locations()));
25552506

25562507
// Equate closure args to regions inherited from `root_def_id`. Fixes #98589.
25572508
let typeck_root_args = ty::GenericArgs::identity_for_item(tcx, root_def_id);
@@ -2575,7 +2526,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
25752526
if let Err(_) = self.eq_args(
25762527
typeck_root_args,
25772528
parent_args,
2578-
locations,
2529+
location.to_locations(),
25792530
ConstraintCategory::BoringNoLocation,
25802531
) {
25812532
span_mirbug!(

compiler/rustc_builtin_macros/messages.ftl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ builtin_macros_eii_only_once = `#[{$name}]` can only be specified once
161161
162162
builtin_macros_eii_shared_macro_expected_function = `#[{$name}]` is only valid on functions
163163
builtin_macros_eii_shared_macro_expected_max_one_argument = `#[{$name}]` expected no arguments or a single argument: `#[{$name}(default)]`
164+
builtin_macros_eii_shared_macro_in_statement_position = `#[{$name}]` can only be used on functions inside a module
165+
.label = `#[{$name}]` is used on this item, which is part of another item's local scope
164166
165167
builtin_macros_env_not_defined = environment variable `{$var}` not defined at compile time
166168
.cargo = Cargo sets build script variables at run time. Use `std::env::var({$var_expr})` instead

0 commit comments

Comments
 (0)