Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 9 pull requests #127896

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
2f305ff
Remove an unnecessary `?`.
nnethercote Jul 16, 2024
48cdfc3
Inline `Parser::parse_item_common_`.
nnethercote Jul 16, 2024
d247489
Reorder `Parser::parse_expr_dot_or_call_with` arguments.
nnethercote Jul 16, 2024
96cc9c9
Inline and remove `Parser::parse_and_disallow_postfix_after_cast`.
nnethercote Jul 16, 2024
96b39f1
Inline and remove `Parser::parse_expr_dot_or_call_with_`.
nnethercote Jul 16, 2024
8cb6bc3
Fix a comment.
nnethercote Jul 16, 2024
9c4f3db
Remove references to `maybe_whole_expr`.
nnethercote Jul 16, 2024
538b31e
Make language around `ToOwned` for `BorrowedFd` more precise
tbu- Jun 28, 2024
2162f3f
Mention how you can go from `BorrowedFd` to `OwnedFd` and back
tbu- Jun 28, 2024
a651050
lift_to_tcx -> lift_to_interner
compiler-errors Jul 16, 2024
8d90f44
tcx -> cx in rustc_type_ir
compiler-errors Jul 16, 2024
0b5ce54
Fix relations
compiler-errors Jul 16, 2024
5483945
rewrite dump-ice-to-disk to rmake
Oneirical Jul 9, 2024
f54fa62
rewrite panic-abort-eh_frame to rmake
Oneirical Jul 9, 2024
a9e1466
Add `llvm_components_contain` to `run-make-support`
Rejyr Jul 15, 2024
a8b6e3f
Migrate `atomic-lock-free` to `rmake`
Rejyr Jul 15, 2024
e38032f
Fix associated item removal suggestion
estebank Jul 9, 2024
8eb5185
Accurate `use` rename suggestion span
estebank Jul 10, 2024
be9d961
More accurate span for type parameter suggestion
estebank Jul 10, 2024
f6c4679
More accurate span for anonymous argument suggestion
estebank Jul 10, 2024
483161d
Rollup merge of #127077 - tbu-:pr_doc_fd_to_owned, r=workingjubilee
tgross35 Jul 18, 2024
c0cd3ca
Rollup merge of #127523 - Oneirical:treasure-test, r=jieyouxu
tgross35 Jul 18, 2024
af30f40
Rollup merge of #127787 - Rejyr:migrate-atomic-lock-free-rmake, r=jie…
tgross35 Jul 18, 2024
caf888c
Rollup merge of #127806 - nnethercote:parser-improvements, r=spastorino
tgross35 Jul 18, 2024
fe9940c
Rollup merge of #127810 - compiler-errors:less-tcx, r=lcnr
tgross35 Jul 18, 2024
9b001ce
Rollup merge of #127878 - estebank:assoc-item-removal, r=fmease
tgross35 Jul 18, 2024
a5fd37e
Rollup merge of #127886 - estebank:as-rename-suggestion, r=compiler-e…
tgross35 Jul 18, 2024
1bdc0fb
Rollup merge of #127888 - estebank:type-param-sugg, r=compiler-errors
tgross35 Jul 18, 2024
6973719
Rollup merge of #127889 - estebank:anon-arg-sugg, r=compiler-errors
tgross35 Jul 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions compiler/rustc_ast/src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -699,8 +699,7 @@ impl Token {
false
}

/// Would `maybe_whole_expr` in `parser.rs` return `Ok(..)`?
/// That is, is this a pre-parsed expression dropped into the token stream
/// Is this a pre-parsed expression dropped into the token stream
/// (which happens while parsing the result of macro expansion)?
pub fn is_whole_expr(&self) -> bool {
if let Interpolated(nt) = &self.kind
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_borrowck/src/type_check/relate_tys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ impl<'me, 'bccx, 'tcx> NllTypeRelating<'me, 'bccx, 'tcx> {
}

impl<'bccx, 'tcx> TypeRelation<TyCtxt<'tcx>> for NllTypeRelating<'_, 'bccx, 'tcx> {
fn tcx(&self) -> TyCtxt<'tcx> {
fn cx(&self) -> TyCtxt<'tcx> {
self.type_checker.infcx.tcx
}

Expand Down Expand Up @@ -370,7 +370,7 @@ impl<'bccx, 'tcx> TypeRelation<TyCtxt<'tcx>> for NllTypeRelating<'_, 'bccx, 'tcx
// shouldn't ever fail. Instead, it unconditionally emits an
// alias-relate goal.
assert!(!self.type_checker.infcx.next_trait_solver());
self.tcx().dcx().span_delayed_bug(
self.cx().dcx().span_delayed_bug(
self.span(),
"failure to relate an opaque to itself should result in an error later on",
);
Expand Down Expand Up @@ -540,7 +540,7 @@ impl<'bccx, 'tcx> PredicateEmittingRelation<InferCtxt<'tcx>> for NllTypeRelating
&mut self,
obligations: impl IntoIterator<Item: ty::Upcast<TyCtxt<'tcx>, ty::Predicate<'tcx>>>,
) {
let tcx = self.tcx();
let tcx = self.cx();
let param_env = self.param_env();
self.register_goals(
obligations.into_iter().map(|to_pred| Goal::new(tcx, param_env, to_pred)),
Expand All @@ -559,7 +559,7 @@ impl<'bccx, 'tcx> PredicateEmittingRelation<InferCtxt<'tcx>> for NllTypeRelating
.into_iter()
.map(|goal| {
Obligation::new(
self.tcx(),
self.cx(),
ObligationCause::dummy_with_span(self.span()),
goal.param_env,
goal.predicate,
Expand Down
22 changes: 11 additions & 11 deletions compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1257,14 +1257,12 @@ pub fn prohibit_assoc_item_constraint(
};

// Now emit the suggestion
if let Ok(suggestion) = tcx.sess.source_map().span_to_snippet(removal_span) {
e.span_suggestion_verbose(
removal_span,
format!("consider removing this associated item {}", constraint.kind.descr()),
suggestion,
Applicability::MaybeIncorrect,
);
}
e.span_suggestion_verbose(
removal_span,
format!("consider removing this associated item {}", constraint.kind.descr()),
"",
Applicability::MaybeIncorrect,
);
};

// Suggest replacing the associated item binding with a generic argument.
Expand Down Expand Up @@ -1340,11 +1338,13 @@ pub fn prohibit_assoc_item_constraint(
format!("<{lifetimes}{type_with_constraints}>"),
)
};
let suggestions =
vec![param_decl, (constraint.span, format!("{}", matching_param.name))];
let suggestions = vec![
param_decl,
(constraint.span.with_lo(constraint.ident.span.hi()), String::new()),
];

err.multipart_suggestion_verbose(
format!("declare the type parameter right after the `impl` keyword"),
"declare the type parameter right after the `impl` keyword",
suggestions,
Applicability::MaybeIncorrect,
);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_infer/src/error_reporting/infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1930,7 +1930,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
struct SameTypeModuloInfer<'a, 'tcx>(&'a InferCtxt<'tcx>);

impl<'tcx> TypeRelation<TyCtxt<'tcx>> for SameTypeModuloInfer<'_, 'tcx> {
fn tcx(&self) -> TyCtxt<'tcx> {
fn cx(&self) -> TyCtxt<'tcx> {
self.0.tcx
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_infer/src/infer/outlives/test_type_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for MatchAgainstHigherRankedOutlives<'tcx>
"MatchAgainstHigherRankedOutlives"
}

fn tcx(&self) -> TyCtxt<'tcx> {
fn cx(&self) -> TyCtxt<'tcx> {
self.tcx
}

Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_infer/src/infer/relate/generalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ impl<'tcx> Generalizer<'_, 'tcx> {

let is_nested_alias = mem::replace(&mut self.in_alias, true);
let result = match self.relate(alias, alias) {
Ok(alias) => Ok(alias.to_ty(self.tcx())),
Ok(alias) => Ok(alias.to_ty(self.cx())),
Err(e) => {
if is_nested_alias {
return Err(e);
Expand All @@ -397,7 +397,7 @@ impl<'tcx> Generalizer<'_, 'tcx> {
}

impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Generalizer<'_, 'tcx> {
fn tcx(&self) -> TyCtxt<'tcx> {
fn cx(&self) -> TyCtxt<'tcx> {
self.infcx.tcx
}

Expand All @@ -417,7 +417,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Generalizer<'_, 'tcx> {
// (e.g., #41849).
relate::relate_args_invariantly(self, a_arg, b_arg)
} else {
let tcx = self.tcx();
let tcx = self.cx();
let opt_variances = tcx.variances_of(item_def_id);
relate::relate_args_with_variances(
self,
Expand Down Expand Up @@ -525,7 +525,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Generalizer<'_, 'tcx> {
}

debug!("replacing original vid={:?} with new={:?}", vid, new_var_id);
Ok(Ty::new_var(self.tcx(), new_var_id))
Ok(Ty::new_var(self.cx(), new_var_id))
}
}
}
Expand Down Expand Up @@ -654,7 +654,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Generalizer<'_, 'tcx> {
{
variable_table.union(vid, new_var_id);
}
Ok(ty::Const::new_var(self.tcx(), new_var_id))
Ok(ty::Const::new_var(self.cx(), new_var_id))
}
}
}
Expand All @@ -672,7 +672,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Generalizer<'_, 'tcx> {
args,
args,
)?;
Ok(ty::Const::new_unevaluated(self.tcx(), ty::UnevaluatedConst { def, args }))
Ok(ty::Const::new_unevaluated(self.cx(), ty::UnevaluatedConst { def, args }))
}
ty::ConstKind::Placeholder(placeholder) => {
if self.for_universe.can_name(placeholder.universe) {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_infer/src/infer/relate/glb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Glb<'_, '_, 'tcx> {
"Glb"
}

fn tcx(&self) -> TyCtxt<'tcx> {
fn cx(&self) -> TyCtxt<'tcx> {
self.fields.tcx()
}

Expand Down Expand Up @@ -61,7 +61,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Glb<'_, '_, 'tcx> {
let origin = SubregionOrigin::Subtype(Box::new(self.fields.trace.clone()));
// GLB(&'static u8, &'a u8) == &RegionLUB('static, 'a) u8 == &'static u8
Ok(self.fields.infcx.inner.borrow_mut().unwrap_region_constraints().lub_regions(
self.tcx(),
self.cx(),
origin,
a,
b,
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_infer/src/infer/relate/lub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Lub<'_, '_, 'tcx> {
"Lub"
}

fn tcx(&self) -> TyCtxt<'tcx> {
fn cx(&self) -> TyCtxt<'tcx> {
self.fields.tcx()
}

Expand Down Expand Up @@ -61,7 +61,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Lub<'_, '_, 'tcx> {
let origin = SubregionOrigin::Subtype(Box::new(self.fields.trace.clone()));
// LUB(&'static u8, &'a u8) == &RegionGLB('static, 'a) u8 == &'a u8
Ok(self.fields.infcx.inner.borrow_mut().unwrap_region_constraints().glb_regions(
self.tcx(),
self.cx(),
origin,
a,
b,
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_infer/src/infer/relate/type_relating.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for TypeRelating<'_, '_, 'tcx> {
"TypeRelating"
}

fn tcx(&self) -> TyCtxt<'tcx> {
fn cx(&self) -> TyCtxt<'tcx> {
self.fields.infcx.tcx
}

Expand All @@ -48,7 +48,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for TypeRelating<'_, '_, 'tcx> {
// (e.g., #41849).
relate_args_invariantly(self, a_arg, b_arg)
} else {
let tcx = self.tcx();
let tcx = self.cx();
let opt_variances = tcx.variances_of(item_def_id);
relate_args_with_variances(self, item_def_id, opt_variances, a_arg, b_arg, false)
}
Expand Down Expand Up @@ -88,7 +88,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for TypeRelating<'_, '_, 'tcx> {
// can't make progress on `A <: B` if both A and B are
// type variables, so record an obligation.
self.fields.goals.push(Goal::new(
self.tcx(),
self.cx(),
self.fields.param_env,
ty::Binder::dummy(ty::PredicateKind::Subtype(ty::SubtypePredicate {
a_is_expected: true,
Expand All @@ -101,7 +101,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for TypeRelating<'_, '_, 'tcx> {
// can't make progress on `B <: A` if both A and B are
// type variables, so record an obligation.
self.fields.goals.push(Goal::new(
self.tcx(),
self.cx(),
self.fields.param_env,
ty::Binder::dummy(ty::PredicateKind::Subtype(ty::SubtypePredicate {
a_is_expected: false,
Expand Down Expand Up @@ -134,7 +134,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for TypeRelating<'_, '_, 'tcx> {

(&ty::Error(e), _) | (_, &ty::Error(e)) => {
infcx.set_tainted_by_errors(e);
return Ok(Ty::new_error(self.tcx(), e));
return Ok(Ty::new_error(self.cx(), e));
}

(
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_macros/src/lift.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub fn lift_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStre
quote! {
type Lifted = #lifted;

fn lift_to_tcx(self, __tcx: ::rustc_middle::ty::TyCtxt<'__lifted>) -> Option<#lifted> {
fn lift_to_interner(self, __tcx: ::rustc_middle::ty::TyCtxt<'__lifted>) -> Option<#lifted> {
Some(match self { #body })
}
},
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ macro_rules! TrivialLiftImpls {
$(
impl<'tcx> $crate::ty::Lift<$crate::ty::TyCtxt<'tcx>> for $ty {
type Lifted = Self;
fn lift_to_tcx(self, _: $crate::ty::TyCtxt<'tcx>) -> Option<Self> {
fn lift_to_interner(self, _: $crate::ty::TyCtxt<'tcx>) -> Option<Self> {
Some(self)
}
}
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_middle/src/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1484,7 +1484,7 @@ impl<'tcx> TyCtxt<'tcx> {
}

pub fn lift<T: Lift<TyCtxt<'tcx>>>(self, value: T) -> Option<T::Lifted> {
value.lift_to_tcx(self)
value.lift_to_interner(self)
}

/// Creates a type context. To use the context call `fn enter` which
Expand Down Expand Up @@ -2087,7 +2087,7 @@ macro_rules! nop_lift {
($set:ident; $ty:ty => $lifted:ty) => {
impl<'a, 'tcx> Lift<TyCtxt<'tcx>> for $ty {
type Lifted = $lifted;
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
fn lift_to_interner(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
// Assert that the set has the right type.
// Given an argument that has an interned type, the return type has the type of
// the corresponding interner set. This won't actually return anything, we're
Expand Down Expand Up @@ -2122,7 +2122,7 @@ macro_rules! nop_list_lift {
($set:ident; $ty:ty => $lifted:ty) => {
impl<'a, 'tcx> Lift<TyCtxt<'tcx>> for &'a List<$ty> {
type Lifted = &'tcx List<$lifted>;
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
fn lift_to_interner(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
// Assert that the set has the right type.
if false {
let _x: &InternedSet<'tcx, List<$lifted>> = &tcx.interners.$set;
Expand Down Expand Up @@ -2160,7 +2160,7 @@ macro_rules! nop_slice_lift {
($ty:ty => $lifted:ty) => {
impl<'a, 'tcx> Lift<TyCtxt<'tcx>> for &'a [$ty] {
type Lifted = &'tcx [$lifted];
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
fn lift_to_interner(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
if self.is_empty() {
return Some(&[]);
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/generic_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ impl<'tcx> GenericArg<'tcx> {
impl<'a, 'tcx> Lift<TyCtxt<'tcx>> for GenericArg<'a> {
type Lifted = GenericArg<'tcx>;

fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
fn lift_to_interner(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
match self.unpack() {
GenericArgKind::Lifetime(lt) => tcx.lift(lt).map(|lt| lt.into()),
GenericArgKind::Type(ty) => tcx.lift(ty).map(|ty| ty.into()),
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_middle/src/ty/relate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ impl<'tcx> Relate<TyCtxt<'tcx>> for ty::Pattern<'tcx> {
if inc_a != inc_b {
todo!()
}
Ok(relation.tcx().mk_pat(ty::PatternKind::Range { start, end, include_end: inc_a }))
Ok(relation.cx().mk_pat(ty::PatternKind::Range { start, end, include_end: inc_a }))
}
}
}
Expand All @@ -81,7 +81,7 @@ impl<'tcx> Relate<TyCtxt<'tcx>> for &'tcx ty::List<ty::PolyExistentialPredicate<
a: Self,
b: Self,
) -> RelateResult<'tcx, Self> {
let tcx = relation.tcx();
let tcx = relation.cx();

// FIXME: this is wasteful, but want to do a perf run to see how slow it is.
// We need to perform this deduplication as we sometimes generate duplicate projections
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_middle/src/ty/structural_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ TrivialTypeTraversalAndLiftImpls! {

impl<'tcx, T: Lift<TyCtxt<'tcx>>> Lift<TyCtxt<'tcx>> for Option<T> {
type Lifted = Option<T::Lifted>;
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
fn lift_to_interner(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
Some(match self {
Some(x) => Some(tcx.lift(x)?),
None => None,
Expand All @@ -293,7 +293,7 @@ impl<'tcx, T: Lift<TyCtxt<'tcx>>> Lift<TyCtxt<'tcx>> for Option<T> {

impl<'a, 'tcx> Lift<TyCtxt<'tcx>> for Term<'a> {
type Lifted = ty::Term<'tcx>;
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
fn lift_to_interner(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
match self.unpack() {
TermKind::Ty(ty) => tcx.lift(ty).map(Into::into),
TermKind::Const(c) => tcx.lift(c).map(Into::into),
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_parse/src/parser/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2240,11 +2240,11 @@ impl<'a> Parser<'a> {
}
_ => {
// Otherwise, try to get a type and emit a suggestion.
if let Some(ty) = pat.to_ty() {
if let Some(_) = pat.to_ty() {
err.span_suggestion_verbose(
pat.span,
pat.span.shrink_to_lo(),
"explicitly ignore the parameter name",
format!("_: {}", pprust::ty_to_string(&ty)),
"_: ".to_string(),
Applicability::MachineApplicable,
);
err.note(rfc_note);
Expand All @@ -2256,7 +2256,7 @@ impl<'a> Parser<'a> {

// `fn foo(a, b) {}`, `fn foo(a<x>, b<y>) {}` or `fn foo(usize, usize) {}`
if first_param {
err.span_suggestion(
err.span_suggestion_verbose(
self_span,
"if this is a `self` type, give it a parameter name",
self_sugg,
Expand All @@ -2266,14 +2266,14 @@ impl<'a> Parser<'a> {
// Avoid suggesting that `fn foo(HashMap<u32>)` is fixed with a change to
// `fn foo(HashMap: TypeName<u32>)`.
if self.token != token::Lt {
err.span_suggestion(
err.span_suggestion_verbose(
param_span,
"if this is a parameter name, give it a type",
param_sugg,
Applicability::HasPlaceholders,
);
}
err.span_suggestion(
err.span_suggestion_verbose(
type_span,
"if this is a type, explicitly ignore the parameter name",
type_sugg,
Expand Down
Loading
Loading