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 15 pull requests #90159

Closed
wants to merge 40 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
82348ef
nice_region_error: Include lifetime placeholders in error output
notriddle Oct 1, 2021
729ff2d
Give better error for `macro_rules name`
aDotInTheVoid Sep 25, 2021
1bb399c
Ensure that pushing empty path works as before
seanyoung Oct 8, 2021
bd1a1e4
Don't mark for loop head span with desugaring
camsteffen Oct 14, 2021
a697aa6
Use more lowered spans in for loop
camsteffen Oct 15, 2021
ffdd5a0
Fix clippy with for loop span change
camsteffen Oct 14, 2021
4333091
Update E0637 description to mention `&` w/o an explicit lifetime name
JohnTitor Oct 15, 2021
d2470e7
rustc_ast: Turn `MutVisitor::token_visiting_enabled` into a constant
petrochenkov Oct 17, 2021
7581bae
Fix const qualification when executed after promotion
tmiasko Oct 19, 2021
c97cf7f
Reject closures in patterns
tmiasko Oct 18, 2021
21d02bf
Add a regression test for issue-83479
JohnTitor Oct 20, 2021
396a4f4
Increase `ROOT_ENTRY_LIMIT` to 1331
JohnTitor Oct 20, 2021
fe060bf
Change `Duration::from_secs_*` underflow error
mbartlett21 Oct 16, 2021
6469fba
Trait objects
BoxyUwU Oct 20, 2021
a81e489
Return pos impl trait
BoxyUwU Oct 20, 2021
83a1834
Wfness
BoxyUwU Oct 20, 2021
8f23779
Inference
BoxyUwU Oct 20, 2021
7a8bd2d
add fixme
BoxyUwU Oct 20, 2021
c75d8cb
Ordering
BoxyUwU Oct 20, 2021
e7a9e82
*dust dust*
BoxyUwU Oct 20, 2021
74c6636
Verify that only NeedsNonConstDrop expects promoteds
tmiasko Oct 21, 2021
ab44e46
Add test for issue #78561
samlich Oct 20, 2021
d50832b
triagebot: Treat `I-*nominated` like `I-nominated`
joshtriplett Oct 21, 2021
04c1ec5
Clarify undefined behaviour for binary heap, btree and hashset
Wilfred Jul 28, 2021
0dba9d0
Stabilize feature saturating_div for rust 1.58
kellerkindt Oct 21, 2021
121411d
Rollup merge of #87537 - Wilfred:improve-min-heap-docs, r=Mark-Simula…
JohnTitor Oct 22, 2021
0c7b513
Rollup merge of #88624 - kellerkindt:master, r=JohnTitor
JohnTitor Oct 22, 2021
1585730
Rollup merge of #89257 - aDotInTheVoid:macro-error-2, r=estebank
JohnTitor Oct 22, 2021
0cc8b39
Rollup merge of #89416 - notriddle:notriddle/do-not-elide-lifetimes-i…
JohnTitor Oct 22, 2021
0d70763
Rollup merge of #89665 - seanyoung:push-empty, r=m-ou-se
JohnTitor Oct 22, 2021
01f7352
Rollup merge of #89895 - camsteffen:for-loop-head-span, r=davidtwco
JohnTitor Oct 22, 2021
8c210e0
Rollup merge of #89922 - JohnTitor:update-e0637, r=jackh726
JohnTitor Oct 22, 2021
5256761
Rollup merge of #89944 - mbartlett21:patch-2, r=Mark-Simulacrum
JohnTitor Oct 22, 2021
05e0281
Rollup merge of #89991 - petrochenkov:visitok2, r=jackh726
JohnTitor Oct 22, 2021
a93e7e0
Rollup merge of #90028 - tmiasko:structural-match-closure, r=spastorino
JohnTitor Oct 22, 2021
efdb8e5
Rollup merge of #90069 - tmiasko:promoted-const-qualif, r=oli-obk
JohnTitor Oct 22, 2021
7bcc6be
Rollup merge of #90078 - JohnTitor:test-83479, r=Mark-Simulacrum
JohnTitor Oct 22, 2021
61e4e3b
Rollup merge of #90114 - BoxyUwU:cg_defaults_tests, r=lcnr
JohnTitor Oct 22, 2021
c24e75a
Rollup merge of #90115 - samlich:test-issue-78561, r=oli-obk
JohnTitor Oct 22, 2021
1fbce5c
Rollup merge of #90129 - joshtriplett:triagebot-nominated, r=Mark-Sim…
JohnTitor Oct 22, 2021
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
Next Next commit
nice_region_error: Include lifetime placeholders in error output
As you can see in src/test/ui/traits/self-without-lifetime-constraint.stderr
you can get very confusing type names if you don't have this.

Fixes #87763
  • Loading branch information
notriddle committed Oct 1, 2021
commit 82348ef1e660592d7ca0aea20b7a8e5615a074aa
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ use rustc_hir as hir;
use rustc_hir::def::Res;
use rustc_hir::def_id::DefId;
use rustc_hir::intravisit::Visitor;
use rustc_middle::ty::error::ExpectedFound;
use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_middle::ty::print::RegionHighlightMode;
use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable, TypeVisitor};

use rustc_span::{MultiSpan, Span, Symbol};

use std::ops::ControlFlow;

impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
/// Print the error message for lifetime errors when the `impl` doesn't conform to the `trait`.
pub(super) fn try_report_impl_not_conforming_to_trait(&self) -> Option<ErrorReported> {
Expand Down Expand Up @@ -67,6 +70,47 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
.tcx()
.sess
.struct_span_err(sp, "`impl` item signature doesn't match `trait` item signature");

// Mark all unnamed regions in the type with a number.
// This diagnostic is called in response to lifetime errors, so be informative.
struct HighlightBuilder<'tcx> {
highlight: RegionHighlightMode,
tcx: TyCtxt<'tcx>,
counter: usize,
}

impl HighlightBuilder<'tcx> {
fn build(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> RegionHighlightMode {
let mut builder =
HighlightBuilder { highlight: RegionHighlightMode::default(), counter: 1, tcx };
builder.visit_ty(ty);
builder.highlight
}
}

impl<'tcx> ty::fold::TypeVisitor<'tcx> for HighlightBuilder<'tcx> {
fn tcx_for_anon_const_substs(&self) -> Option<TyCtxt<'tcx>> {
Some(self.tcx)
}

fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<Self::BreakTy> {
if !r.has_name() && self.counter <= 3 {
self.highlight.highlighting_region(r, self.counter);
self.counter += 1;
}
r.super_visit_with(self)
}
}

let expected_highlight = HighlightBuilder::build(self.tcx(), expected);
let expected = self
.infcx
.extract_inference_diagnostics_data(expected.into(), Some(expected_highlight))
.name;
let found_highlight = HighlightBuilder::build(self.tcx(), found);
let found =
self.infcx.extract_inference_diagnostics_data(found.into(), Some(found_highlight)).name;

err.span_label(sp, &format!("found `{}`", found));
err.span_label(trait_sp, &format!("expected `{}`", expected));

Expand Down Expand Up @@ -94,15 +138,8 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
);
}

if let Some((expected, found)) =
self.infcx.expected_found_str_ty(ExpectedFound { expected, found })
{
// Highlighted the differences when showing the "expected/found" note.
err.note_expected_found(&"", expected, &"", found);
} else {
// This fallback shouldn't be necessary, but let's keep it in just in case.
err.note(&format!("expected `{}`\n found `{}`", expected, found));
}
err.note(&format!("expected `{}`\n found `{}`", expected, found));

err.span_help(
type_param_span,
"the lifetime requirements from the `impl` do not correspond to the requirements in \
Expand Down
8 changes: 4 additions & 4 deletions src/test/ui/in-band-lifetimes/mismatched_trait_impl-2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ error: `impl` item signature doesn't match `trait` item signature
--> $DIR/mismatched_trait_impl-2.rs:8:5
|
LL | fn deref(&self) -> &dyn Trait {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&Struct) -> &dyn Trait`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 Struct) -> &'1 (dyn Trait + '1)`
|
::: $SRC_DIR/core/src/ops/deref.rs:LL:COL
|
LL | fn deref(&self) -> &Self::Target;
| --------------------------------- expected `fn(&Struct) -> &(dyn Trait + 'static)`
| --------------------------------- expected `fn(&'1 Struct) -> &'1 (dyn Trait + 'static)`
|
= note: expected `fn(&Struct) -> &(dyn Trait + 'static)`
found `fn(&Struct) -> &dyn Trait`
= note: expected `fn(&'1 Struct) -> &'1 (dyn Trait + 'static)`
found `fn(&'1 Struct) -> &'1 (dyn Trait + '1)`
= help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
= help: verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output

Expand Down
8 changes: 4 additions & 4 deletions src/test/ui/in-band-lifetimes/mismatched_trait_impl.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ error: `impl` item signature doesn't match `trait` item signature
--> $DIR/mismatched_trait_impl.rs:9:5
|
LL | fn foo(&self, x: &'a u32, y: &u32) -> &'a u32;
| ---------------------------------------------- expected `fn(&i32, &'a u32, &u32) -> &'a u32`
| ---------------------------------------------- expected `fn(&'1 i32, &'a u32, &'2 u32) -> &'a u32`
...
LL | fn foo(&self, x: &u32, y: &'a u32) -> &'a u32 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&i32, &u32, &u32) -> &u32`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 i32, &'2 u32, &'3 u32) -> &'3 u32`
|
= note: expected `fn(&i32, &'a u32, &u32) -> &'a u32`
found `fn(&i32, &u32, &u32) -> &u32`
= note: expected `fn(&'1 i32, &'a u32, &'2 u32) -> &'a u32`
found `fn(&'1 i32, &'2 u32, &'3 u32) -> &'3 u32`
= help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
= help: verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ error: `impl` item signature doesn't match `trait` item signature
--> $DIR/lifetime-mismatch-between-trait-and-impl.rs:6:5
|
LL | fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32;
| ------------------------------------------- expected `fn(&i32, &'a i32) -> &'a i32`
| ------------------------------------------- expected `fn(&'1 i32, &'a i32) -> &'a i32`
...
LL | fn foo<'a>(x: &'a i32, y: &'a i32) -> &'a i32 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&i32, &i32) -> &i32`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 i32, &'1 i32) -> &'1 i32`
|
= note: expected `fn(&i32, &'a i32) -> &'a i32`
found `fn(&i32, &i32) -> &i32`
= note: expected `fn(&'1 i32, &'a i32) -> &'a i32`
found `fn(&'1 i32, &'1 i32) -> &'1 i32`
= help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
= help: verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ error: `impl` item signature doesn't match `trait` item signature
--> $DIR/issue-75361-mismatched-impl.rs:18:3
|
LL | fn adjacent_edges(&self) -> Box<dyn MyTrait<Item = &Self::EdgeType>>;
| --------------------------------------------------------------------- expected `fn(&T) -> Box<(dyn MyTrait<Item = &T> + 'static)>`
| --------------------------------------------------------------------- expected `fn(&'1 T) -> Box<(dyn MyTrait<Item = &'1 T> + 'static)>`
...
LL | fn adjacent_edges(&self) -> Box<dyn MyTrait<Item = &Self::EdgeType> + '_> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&T) -> Box<dyn MyTrait<Item = &T>>`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 T) -> Box<(dyn MyTrait<Item = &'1 T> + '1)>`
|
= note: expected `fn(&T) -> Box<(dyn MyTrait<Item = &T> + 'static)>`
found `fn(&T) -> Box<dyn MyTrait<Item = &T>>`
= note: expected `fn(&'1 T) -> Box<(dyn MyTrait<Item = &'1 T> + 'static)>`
found `fn(&'1 T) -> Box<(dyn MyTrait<Item = &'1 T> + '1)>`
help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
--> $DIR/issue-75361-mismatched-impl.rs:12:55
|
Expand Down
8 changes: 4 additions & 4 deletions src/test/ui/traits/param-without-lifetime-constraint.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ error: `impl` item signature doesn't match `trait` item signature
--> $DIR/param-without-lifetime-constraint.rs:14:5
|
LL | fn get_relation(&self) -> To;
| ----------------------------- expected `fn(&Article) -> &ProofReader`
| ----------------------------- expected `fn(&'1 Article) -> &'2 ProofReader`
...
LL | fn get_relation(&self) -> &ProofReader {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&Article) -> &ProofReader`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 Article) -> &'1 ProofReader`
|
= note: expected `fn(&Article) -> &ProofReader`
found `fn(&Article) -> &ProofReader`
= note: expected `fn(&'1 Article) -> &'2 ProofReader`
found `fn(&'1 Article) -> &'1 ProofReader`
help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
--> $DIR/param-without-lifetime-constraint.rs:10:31
|
Expand Down
8 changes: 4 additions & 4 deletions src/test/ui/traits/self-without-lifetime-constraint.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ error: `impl` item signature doesn't match `trait` item signature
--> $DIR/self-without-lifetime-constraint.rs:45:5
|
LL | fn column_result(value: ValueRef<'_>) -> FromSqlResult<Self, &Self>;
| -------------------------------------------------------------------- expected `fn(ValueRef<'_>) -> Result<(&str, &&str), FromSqlError>`
| -------------------------------------------------------------------- expected `fn(ValueRef<'1>) -> Result<(&'2 str, &'1 &'2 str), FromSqlError>`
...
LL | fn column_result(value: ValueRef<'_>) -> FromSqlResult<&str, &&str> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(ValueRef<'_>) -> Result<(&str, &&str), FromSqlError>`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(ValueRef<'1>) -> Result<(&'1 str, &'1 &'1 str), FromSqlError>`
|
= note: expected `fn(ValueRef<'_>) -> Result<(&str, &&str), _>`
found `fn(ValueRef<'_>) -> Result<(&str, &&str), _>`
= note: expected `fn(ValueRef<'1>) -> Result<(&'2 str, &'1 &'2 str), FromSqlError>`
found `fn(ValueRef<'1>) -> Result<(&'1 str, &'1 &'1 str), FromSqlError>`
help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
--> $DIR/self-without-lifetime-constraint.rs:41:60
|
Expand Down