Skip to content

Rollup of 8 pull requests #74724

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

Merged
merged 28 commits into from
Jul 24, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
6813c1c
revise RwLock, which is derived from the wasm implementation
stlankes Jun 3, 2020
3acc3ef
minor changes to pass the format check
stlankes Jun 3, 2020
beb1b1f
reorder crates to pass the format check
stlankes Jun 4, 2020
f9c6091
remove some compiler warnings
stlankes Jun 26, 2020
6925ebd
use latest version of hermit-abi
stlankes Jul 6, 2020
711a680
Optimize away BitAnd and BitOr when possible
xldenis Jul 18, 2020
c276334
add RegionName::span
SNCPlay42 Jul 21, 2020
51af5af
extract RegionNameHighlight
SNCPlay42 Jul 22, 2020
601518e
change returns to RegionNameHighlight
SNCPlay42 Jul 22, 2020
723ea90
rename functions
SNCPlay42 Jul 22, 2020
b56f5b9
clean up give_name_if_anonymous_region_appears_in_arguments
SNCPlay42 Jul 22, 2020
a7450b7
decouple highlight_if_we_cannot_match_hir_ty
SNCPlay42 Jul 22, 2020
ebb4aba
move highlight_if_we_can_match_hir_ty call
SNCPlay42 Jul 22, 2020
8a776ee
rename arguments to highlight_if_we_can_match_hir_ty
SNCPlay42 Jul 22, 2020
ef74e50
Rearrange the pipeline of `pow` to gain efficiency
Neutron3529 Jul 15, 2020
e46219c
Downgrade glibc to 2.11.1 for ppc, ppc64 and s390x
Jul 22, 2020
5a5846f
delay_span_bug instead of silent ignore
Mark-Simulacrum Jul 23, 2020
bae1e03
fixed error reporting for mismatched traits
ayrtonm Jul 23, 2020
b75ed4f
added a test case for reporting mismatched traits
ayrtonm Jul 24, 2020
b56ea88
Add a system for creating diffs across multiple mir optimizations.
oli-obk Jul 24, 2020
dfedb84
Rollup merge of #72954 - hermitcore:rwlock, r=dtolnay
Manishearth Jul 24, 2020
3226d72
Rollup merge of #74367 - Neutron3529:patch-1, r=nagisa
Manishearth Jul 24, 2020
e59effe
Rollup merge of #74491 - xldenis:constant-binop-opt, r=oli-obk
Manishearth Jul 24, 2020
a4024ba
Rollup merge of #74639 - msirringhaus:master, r=cuviper
Manishearth Jul 24, 2020
ceaef73
Rollup merge of #74661 - SNCPlay42:lifetime-names-refactor, r=estebank
Manishearth Jul 24, 2020
db83a21
Rollup merge of #74692 - Mark-Simulacrum:delay-bug, r=pnkfelix
Manishearth Jul 24, 2020
7f24c7d
Rollup merge of #74698 - ayrtonm:handle-traitref-mismatch, r=estebank
Manishearth Jul 24, 2020
5d1d94e
Rollup merge of #74715 - oli-obk:mir_pass_diff, r=wesleywiser
Manishearth Jul 24, 2020
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
Prev Previous commit
Next Next commit
extract RegionNameHighlight
  • Loading branch information
SNCPlay42 committed Jul 22, 2020
commit 51af5af6fde92f6a15314310e756b3b2d19f22fa
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ impl OutlivesSuggestionBuilder {
// Don't give suggestions for upvars, closure return types, or other unnamable
// regions.
RegionNameSource::SynthesizedFreeEnvRegion(..)
| RegionNameSource::CannotMatchHirTy(..)
| RegionNameSource::MatchedHirTy(..)
| RegionNameSource::MatchedAdtAndSegment(..)
| RegionNameSource::AnonRegionFromArgument(..)
| RegionNameSource::AnonRegionFromUpvar(..)
| RegionNameSource::AnonRegionFromOutput(..)
| RegionNameSource::AnonRegionFromYieldTy(..)
Expand Down
59 changes: 39 additions & 20 deletions src/librustc_mir/borrow_check/diagnostics/region_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,8 @@ crate enum RegionNameSource {
Static,
/// The free region corresponding to the environment of a closure.
SynthesizedFreeEnvRegion(Span, String),
/// The region name corresponds to a region where the type annotation is completely missing
/// from the code, e.g. in a closure arguments `|x| { ... }`, where `x` is a reference.
CannotMatchHirTy(Span, String),
/// The region name corresponds a reference that was found by traversing the type in the HIR.
MatchedHirTy(Span),
/// A region name from the generics list of a struct/enum/union.
MatchedAdtAndSegment(Span),
/// The region corresponding to an argument.
AnonRegionFromArgument(RegionNameHighlight),
/// The region corresponding to a closure upvar.
AnonRegionFromUpvar(Span, String),
/// The region corresponding to the return type of a closure.
Expand All @@ -51,16 +46,27 @@ crate enum RegionNameSource {
AnonRegionFromAsyncFn(Span),
}

/// Describes what to highlight to explain to the user that we're giving an anonymous region a
/// synthesized name, and how to highlight it.
#[derive(Debug, Clone)]
crate enum RegionNameHighlight {
/// The anonymous region corresponds to a reference that was found by traversing the type in the HIR.
MatchedHirTy(Span),
/// The anonymous region corresponds to a `'_` in the generics list of a struct/enum/union.
MatchedAdtAndSegment(Span),
/// The anonymous region corresponds to a region where the type annotation is completely missing
/// from the code, e.g. in a closure arguments `|x| { ... }`, where `x` is a reference.
CannotMatchHirTy(Span, String),
}

impl RegionName {
crate fn was_named(&self) -> bool {
match self.source {
RegionNameSource::NamedEarlyBoundRegion(..)
| RegionNameSource::NamedFreeRegion(..)
| RegionNameSource::Static => true,
RegionNameSource::SynthesizedFreeEnvRegion(..)
| RegionNameSource::CannotMatchHirTy(..)
| RegionNameSource::MatchedHirTy(..)
| RegionNameSource::MatchedAdtAndSegment(..)
| RegionNameSource::AnonRegionFromArgument(..)
| RegionNameSource::AnonRegionFromUpvar(..)
| RegionNameSource::AnonRegionFromOutput(..)
| RegionNameSource::AnonRegionFromYieldTy(..)
Expand All @@ -74,13 +80,15 @@ impl RegionName {
RegionNameSource::NamedEarlyBoundRegion(span)
| RegionNameSource::NamedFreeRegion(span)
| RegionNameSource::SynthesizedFreeEnvRegion(span, _)
| RegionNameSource::CannotMatchHirTy(span, _)
| RegionNameSource::MatchedHirTy(span)
| RegionNameSource::MatchedAdtAndSegment(span)
| RegionNameSource::AnonRegionFromUpvar(span, _)
| RegionNameSource::AnonRegionFromOutput(span, _, _)
| RegionNameSource::AnonRegionFromYieldTy(span, _)
| RegionNameSource::AnonRegionFromAsyncFn(span) => Some(span),
RegionNameSource::AnonRegionFromArgument(ref highlight) => match *highlight {
RegionNameHighlight::MatchedHirTy(span)
| RegionNameHighlight::MatchedAdtAndSegment(span)
| RegionNameHighlight::CannotMatchHirTy(span, _) => Some(span),
},
}
}

Expand All @@ -97,17 +105,22 @@ impl RegionName {
);
diag.note(&note);
}
RegionNameSource::CannotMatchHirTy(span, type_name) => {
RegionNameSource::AnonRegionFromArgument(RegionNameHighlight::CannotMatchHirTy(
span,
type_name,
)) => {
diag.span_label(*span, format!("has type `{}`", type_name));
}
RegionNameSource::MatchedHirTy(span)
RegionNameSource::AnonRegionFromArgument(RegionNameHighlight::MatchedHirTy(span))
| RegionNameSource::AnonRegionFromAsyncFn(span) => {
diag.span_label(
*span,
format!("let's call the lifetime of this reference `{}`", self),
);
}
RegionNameSource::MatchedAdtAndSegment(span) => {
RegionNameSource::AnonRegionFromArgument(
RegionNameHighlight::MatchedAdtAndSegment(span),
) => {
diag.span_label(*span, format!("let's call this `{}`", self));
}
RegionNameSource::AnonRegionFromUpvar(span, upvar_name) => {
Expand Down Expand Up @@ -393,7 +406,9 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
// it so the next value will be used next and return the region name that would
// have been used.
name: self.synthesize_region_name(),
source: RegionNameSource::CannotMatchHirTy(span, type_name),
source: RegionNameSource::AnonRegionFromArgument(
RegionNameHighlight::CannotMatchHirTy(span, type_name),
),
})
} else {
None
Expand Down Expand Up @@ -453,7 +468,9 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {

return Some(RegionName {
name: region_name,
source: RegionNameSource::MatchedHirTy(ampersand_span),
source: RegionNameSource::AnonRegionFromArgument(
RegionNameHighlight::MatchedHirTy(ampersand_span),
),
});
}

Expand Down Expand Up @@ -534,10 +551,12 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
| hir::LifetimeName::Static
| hir::LifetimeName::Underscore => {
let region_name = self.synthesize_region_name();
let ampersand_span = lifetime.span;
let lifetime_span = lifetime.span;
Some(RegionName {
name: region_name,
source: RegionNameSource::MatchedAdtAndSegment(ampersand_span),
source: RegionNameSource::AnonRegionFromArgument(
RegionNameHighlight::MatchedAdtAndSegment(lifetime_span),
),
})
}

Expand Down