Skip to content

Rollup of 11 pull requests #103670

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

Closed
wants to merge 33 commits into from
Closed
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
770538e
Add fix suggestions for E0199, E0200, and E0569
nbarrios1337 Oct 20, 2022
641bf08
Don't merge inline doc comments for impl blocks
GuillaumeGomez Oct 25, 2022
a4279a1
Add regression test for inlined doc comment on impl block
GuillaumeGomez Oct 25, 2022
b205a5a
diagnostics: do not suggest static candidates as traits to import
notriddle Oct 25, 2022
8cf9ad6
diagnostics: add test case for issue 102354
notriddle Oct 25, 2022
b1cc95d
Remap early bound lifetimes too
compiler-errors Oct 24, 2022
0185be2
Migrate line numbers CSS to CSS variables
GuillaumeGomez Oct 27, 2022
71e824d
Add tests for source line numbers colors
GuillaumeGomez Oct 26, 2022
f4ac137
add test for issue 36007
Rageking8 Oct 27, 2022
dce44fa
Revert "Make ClosureOutlivesRequirement not rely on an unresolved type"
compiler-errors Oct 27, 2022
4e0c27b
Erase regions from CallArgument, add test + bless
compiler-errors Oct 27, 2022
dd912ad
rustdoc: stop hiding focus outlines on non-rustdoc-toggle details tags
notriddle Oct 27, 2022
4d9114f
Update cargo
weihanglo Oct 27, 2022
c00ff9c
DoIt
BoxyUwU Oct 27, 2022
ca5a6e4
use proper spans
BoxyUwU Oct 27, 2022
b342558
tidy + move logic to fn
BoxyUwU Oct 27, 2022
97423d3
Add tests for static async functions in traits
bryangarza Oct 4, 2022
8a0ebca
Update static AFIT tests based on feedback
bryangarza Oct 4, 2022
11b1439
Update tests based on feedback
bryangarza Oct 7, 2022
9a05081
Add additional tests for static AFIT
bryangarza Oct 7, 2022
0b3b046
Update src/test/ui/async-await/in-trait/async-example.rs
bryangarza Oct 27, 2022
bfdefdb
Update tests based on feedback
bryangarza Oct 27, 2022
9f2b7b4
Rollup merge of #102642 - bryangarza:afit-tests, r=compiler-errors
matthiaskrgr Oct 28, 2022
20188a5
Rollup merge of #103283 - nbarrios1337:unsafe-impl-suggestions, r=cjg…
matthiaskrgr Oct 28, 2022
1073bdc
Rollup merge of #103523 - GuillaumeGomez:inline-doc-comment-impl-bloc…
matthiaskrgr Oct 28, 2022
7121569
Rollup merge of #103550 - notriddle:notriddle/no-suggest-static-candi…
matthiaskrgr Oct 28, 2022
cfa2234
Rollup merge of #103585 - GuillaumeGomez:source-line-css, r=notriddle
matthiaskrgr Oct 28, 2022
e7fdac5
Rollup merge of #103608 - compiler-errors:rpitit-early-lt, r=cjgillot
matthiaskrgr Oct 28, 2022
5bdefdb
Rollup merge of #103609 - BoxyUwU:fix_impl_self_cycle, r=compiler-errors
matthiaskrgr Oct 28, 2022
cdf284d
Rollup merge of #103631 - Rageking8:Add-test-for-issue-36007, r=compi…
matthiaskrgr Oct 28, 2022
774b952
Rollup merge of #103641 - compiler-errors:issue-103624, r=cjgillot
matthiaskrgr Oct 28, 2022
2bb6a49
Rollup merge of #103643 - notriddle:notriddle/summary-focus-visible, …
matthiaskrgr Oct 28, 2022
82e8a9a
Rollup merge of #103645 - weihanglo:update-cargo, r=weihanglo
matthiaskrgr Oct 28, 2022
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
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/constraints/mod.rs
Original file line number Diff line number Diff line change
@@ -92,7 +92,7 @@ pub struct OutlivesConstraint<'tcx> {
pub span: Span,

/// What caused this constraint?
pub category: ConstraintCategory,
pub category: ConstraintCategory<'tcx>,

/// Variance diagnostic information
pub variance_info: VarianceDiagInfo<'tcx>,
10 changes: 5 additions & 5 deletions compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
Original file line number Diff line number Diff line change
@@ -983,7 +983,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
err: &mut Diagnostic,
location: Location,
issued_borrow: &BorrowData<'tcx>,
explanation: BorrowExplanation,
explanation: BorrowExplanation<'tcx>,
) {
let used_in_call = matches!(
explanation,
@@ -1333,7 +1333,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
borrow: &BorrowData<'tcx>,
drop_span: Span,
borrow_spans: UseSpans<'tcx>,
explanation: BorrowExplanation,
explanation: BorrowExplanation<'tcx>,
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
debug!(
"report_local_value_does_not_live_long_enough(\
@@ -1539,7 +1539,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
drop_span: Span,
borrow_spans: UseSpans<'tcx>,
proper_span: Span,
explanation: BorrowExplanation,
explanation: BorrowExplanation<'tcx>,
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
if let BorrowExplanation::MustBeValidFor { category, span, from_closure: false, .. } =
explanation
@@ -1653,7 +1653,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
borrow: &BorrowData<'tcx>,
borrow_span: Span,
return_span: Span,
category: ConstraintCategory,
category: ConstraintCategory<'tcx>,
opt_place_desc: Option<&String>,
) -> Option<DiagnosticBuilder<'cx, ErrorGuaranteed>> {
let return_kind = match category {
@@ -1748,7 +1748,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
use_span: UseSpans<'tcx>,
var_span: Span,
fr_name: &RegionName,
category: ConstraintCategory,
category: ConstraintCategory<'tcx>,
constraint_span: Span,
captured_var: &str,
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
12 changes: 6 additions & 6 deletions compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ use crate::{
use super::{find_use, RegionName, UseSpans};

#[derive(Debug)]
pub(crate) enum BorrowExplanation {
pub(crate) enum BorrowExplanation<'tcx> {
UsedLater(LaterUseKind, Span, Option<Span>),
UsedLaterInLoop(LaterUseKind, Span, Option<Span>),
UsedLaterWhenDropped {
@@ -30,7 +30,7 @@ pub(crate) enum BorrowExplanation {
should_note_order: bool,
},
MustBeValidFor {
category: ConstraintCategory,
category: ConstraintCategory<'tcx>,
from_closure: bool,
span: Span,
region_name: RegionName,
@@ -49,7 +49,7 @@ pub(crate) enum LaterUseKind {
Other,
}

impl<'tcx> BorrowExplanation {
impl<'tcx> BorrowExplanation<'tcx> {
pub(crate) fn is_explained(&self) -> bool {
!matches!(self, BorrowExplanation::Unexplained)
}
@@ -284,7 +284,7 @@ impl<'tcx> BorrowExplanation {
fn add_lifetime_bound_suggestion_to_diagnostic(
&self,
err: &mut Diagnostic,
category: &ConstraintCategory,
category: &ConstraintCategory<'tcx>,
span: Span,
region_name: &RegionName,
) {
@@ -316,7 +316,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
&self,
borrow_region: RegionVid,
outlived_region: RegionVid,
) -> (ConstraintCategory, bool, Span, Option<RegionName>, Vec<ExtraConstraintInfo>) {
) -> (ConstraintCategory<'tcx>, bool, Span, Option<RegionName>, Vec<ExtraConstraintInfo>) {
let (blame_constraint, extra_info) = self.regioncx.best_blame_constraint(
borrow_region,
NllRegionVariableOrigin::FreeRegion,
@@ -348,7 +348,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
location: Location,
borrow: &BorrowData<'tcx>,
kind_place: Option<(WriteKind, Place<'tcx>)>,
) -> BorrowExplanation {
) -> BorrowExplanation<'tcx> {
let regioncx = &self.regioncx;
let body: &Body<'_> = &self.body;
let tcx = self.infcx.tcx;
Original file line number Diff line number Diff line change
@@ -161,7 +161,7 @@ impl OutlivesSuggestionBuilder {
pub(crate) fn intermediate_suggestion(
&mut self,
mbcx: &MirBorrowckCtxt<'_, '_>,
errci: &ErrorConstraintInfo,
errci: &ErrorConstraintInfo<'_>,
diag: &mut Diagnostic,
) {
// Emit an intermediate note.
24 changes: 9 additions & 15 deletions compiler/rustc_borrowck/src/diagnostics/region_errors.rs
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@
#![deny(rustc::diagnostic_outside_of_impl)]
//! Error reporting machinery for lifetime errors.

use either::Either;
use rustc_data_structures::fx::FxHashSet;
use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed, MultiSpan};
use rustc_hir::def_id::DefId;
@@ -17,7 +16,7 @@ use rustc_infer::infer::{
NllRegionVariableOrigin, RelateParamBound,
};
use rustc_middle::hir::place::PlaceBase;
use rustc_middle::mir::{ConstraintCategory, ReturnConstraint, TerminatorKind};
use rustc_middle::mir::{ConstraintCategory, ReturnConstraint};
use rustc_middle::ty::subst::InternalSubsts;
use rustc_middle::ty::Region;
use rustc_middle::ty::TypeVisitor;
@@ -40,7 +39,7 @@ use crate::{
MirBorrowckCtxt,
};

impl ConstraintDescription for ConstraintCategory {
impl<'tcx> ConstraintDescription for ConstraintCategory<'tcx> {
fn description(&self) -> &'static str {
// Must end with a space. Allows for empty names to be provided.
match self {
@@ -116,15 +115,15 @@ pub(crate) enum RegionErrorKind<'tcx> {

/// Information about the various region constraints involved in a borrow checker error.
#[derive(Clone, Debug)]
pub struct ErrorConstraintInfo {
pub struct ErrorConstraintInfo<'tcx> {
// fr: outlived_fr
pub(super) fr: RegionVid,
pub(super) fr_is_local: bool,
pub(super) outlived_fr: RegionVid,
pub(super) outlived_fr_is_local: bool,

// Category and span for best blame constraint
pub(super) category: ConstraintCategory,
pub(super) category: ConstraintCategory<'tcx>,
pub(super) span: Span,
}

@@ -499,7 +498,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
/// ```
fn report_fnmut_error(
&self,
errci: &ErrorConstraintInfo,
errci: &ErrorConstraintInfo<'tcx>,
kind: ReturnConstraint,
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
let ErrorConstraintInfo { outlived_fr, span, .. } = errci;
@@ -572,7 +571,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
#[instrument(level = "debug", skip(self))]
fn report_escaping_data_error(
&self,
errci: &ErrorConstraintInfo,
errci: &ErrorConstraintInfo<'tcx>,
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
let ErrorConstraintInfo { span, category, .. } = errci;

@@ -676,7 +675,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
/// ```
fn report_general_error(
&self,
errci: &ErrorConstraintInfo,
errci: &ErrorConstraintInfo<'tcx>,
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
let ErrorConstraintInfo {
fr,
@@ -789,20 +788,15 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
diag: &mut Diagnostic,
f: Region<'tcx>,
o: Region<'tcx>,
category: &ConstraintCategory,
category: &ConstraintCategory<'tcx>,
) {
if !o.is_static() {
return;
}

let tcx = self.infcx.tcx;

let instance =
if let ConstraintCategory::CallArgument(location) = category
&& let Either::Right(term) = self.body.stmt_at(*location)
&& let TerminatorKind::Call { func, .. } = &term.kind
{
let func_ty = func.ty(self.body, tcx);
let instance = if let ConstraintCategory::CallArgument(Some(func_ty)) = category {
let (fn_did, substs) = match func_ty.kind() {
ty::FnDef(fn_did, substs) => (fn_did, substs),
_ => return,
10 changes: 5 additions & 5 deletions compiler/rustc_borrowck/src/region_infer/mod.rs
Original file line number Diff line number Diff line change
@@ -91,7 +91,7 @@ pub struct RegionInferenceContext<'tcx> {

/// Map closure bounds to a `Span` that should be used for error reporting.
closure_bounds_mapping:
FxHashMap<Location, FxHashMap<(RegionVid, RegionVid), (ConstraintCategory, Span)>>,
FxHashMap<Location, FxHashMap<(RegionVid, RegionVid), (ConstraintCategory<'tcx>, Span)>>,

/// Map universe indexes to information on why we created it.
universe_causes: FxHashMap<ty::UniverseIndex, UniverseInfo<'tcx>>,
@@ -267,7 +267,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
member_constraints_in: MemberConstraintSet<'tcx, RegionVid>,
closure_bounds_mapping: FxHashMap<
Location,
FxHashMap<(RegionVid, RegionVid), (ConstraintCategory, Span)>,
FxHashMap<(RegionVid, RegionVid), (ConstraintCategory<'tcx>, Span)>,
>,
universe_causes: FxHashMap<ty::UniverseIndex, UniverseInfo<'tcx>>,
type_tests: Vec<TypeTest<'tcx>>,
@@ -1807,7 +1807,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
pub(crate) fn retrieve_closure_constraint_info(
&self,
constraint: OutlivesConstraint<'tcx>,
) -> Option<(ConstraintCategory, Span)> {
) -> Option<(ConstraintCategory<'tcx>, Span)> {
match constraint.locations {
Locations::All(_) => None,
Locations::Single(loc) => {
@@ -1822,7 +1822,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
fr1: RegionVid,
fr1_origin: NllRegionVariableOrigin,
fr2: RegionVid,
) -> (ConstraintCategory, ObligationCause<'tcx>) {
) -> (ConstraintCategory<'tcx>, ObligationCause<'tcx>) {
let BlameConstraint { category, cause, .. } = self
.best_blame_constraint(fr1, fr1_origin, |r| self.provides_universal_region(r, fr1, fr2))
.0;
@@ -2362,7 +2362,7 @@ impl<'tcx> ClosureRegionRequirementsExt<'tcx> for ClosureRegionRequirements<'tcx

#[derive(Clone, Debug)]
pub struct BlameConstraint<'tcx> {
pub category: ConstraintCategory,
pub category: ConstraintCategory<'tcx>,
pub from_closure: bool,
pub cause: ObligationCause<'tcx>,
pub variance_info: ty::VarianceDiagInfo<'tcx>,
10 changes: 5 additions & 5 deletions compiler/rustc_borrowck/src/type_check/canonical.rs
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
pub(super) fn fully_perform_op<R: fmt::Debug, Op>(
&mut self,
locations: Locations,
category: ConstraintCategory,
category: ConstraintCategory<'tcx>,
op: Op,
) -> Fallible<R>
where
@@ -85,7 +85,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
&mut self,
trait_ref: ty::TraitRef<'tcx>,
locations: Locations,
category: ConstraintCategory,
category: ConstraintCategory<'tcx>,
) {
self.prove_predicate(
ty::Binder::dummy(ty::PredicateKind::Trait(ty::TraitPredicate {
@@ -124,7 +124,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
&mut self,
predicates: impl IntoIterator<Item = impl ToPredicate<'tcx>>,
locations: Locations,
category: ConstraintCategory,
category: ConstraintCategory<'tcx>,
) {
for predicate in predicates {
let predicate = predicate.to_predicate(self.tcx());
@@ -139,7 +139,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
&mut self,
predicate: ty::Predicate<'tcx>,
locations: Locations,
category: ConstraintCategory,
category: ConstraintCategory<'tcx>,
) {
let param_env = self.param_env;
self.fully_perform_op(
@@ -164,7 +164,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
&mut self,
value: T,
location: impl NormalizeLocation,
category: ConstraintCategory,
category: ConstraintCategory<'tcx>,
) -> T
where
T: type_op::normalize::Normalizable<'tcx> + fmt::Display + Copy + 'tcx,
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@ pub(crate) struct ConstraintConversion<'a, 'tcx> {
param_env: ty::ParamEnv<'tcx>,
locations: Locations,
span: Span,
category: ConstraintCategory,
category: ConstraintCategory<'tcx>,
constraints: &'a mut MirTypeckRegionConstraints<'tcx>,
}

@@ -50,7 +50,7 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
param_env: ty::ParamEnv<'tcx>,
locations: Locations,
span: Span,
category: ConstraintCategory,
category: ConstraintCategory<'tcx>,
constraints: &'a mut MirTypeckRegionConstraints<'tcx>,
) -> Self {
Self {
@@ -175,7 +175,7 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
&mut self,
sup: ty::RegionVid,
sub: ty::RegionVid,
category: ConstraintCategory,
category: ConstraintCategory<'tcx>,
) {
let category = match self.category {
ConstraintCategory::Boring | ConstraintCategory::BoringNoLocation => category,
@@ -203,7 +203,7 @@ impl<'a, 'b, 'tcx> TypeOutlivesDelegate<'tcx> for &'a mut ConstraintConversion<'
_origin: SubregionOrigin<'tcx>,
a: ty::Region<'tcx>,
b: ty::Region<'tcx>,
constraint_category: ConstraintCategory,
constraint_category: ConstraintCategory<'tcx>,
) {
let b = self.to_region_vid(b);
let a = self.to_region_vid(a);
Loading