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

Extend E0623 for named conflicts #43882

Closed
gaurikholkar-zz opened this issue Aug 15, 2017 · 11 comments
Closed

Extend E0623 for named conflicts #43882

gaurikholkar-zz opened this issue Aug 15, 2017 · 11 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@gaurikholkar-zz
Copy link

Adding changes for rl::Region::EarlyBound and rl::Region::LateBound for references.
Still looking for good examples

cc @nikomatsakis @estebank @GuillaumeGomez @arielb1

@gaurikholkar-zz
Copy link
Author

gaurikholkar-zz commented Aug 15, 2017

Here's the code I pushed into a local branch.
I need help with examples for both the cases.

@gaurikholkar-zz
Copy link
Author

Status:The check for if debruijn_index.depth == 1 && self.infcx.tcx.hir.local_def_id(id) == def_id fails for LateBound

fn foo<'a,'b>(x: &mut Vec<&'a u8>, y: &'b u8) {
    x.push(y);
}

Logs are

DEBUG:rustc::infer::error_reporting: report_region_errors: error = ConcreteFailure(Reborrow(src/test/ui/lifetime-errors/ex3-both-anon-regions.rs:12:12: 12:13), ReFree(DefId { krate: CrateNum(0), node: DefIndex(3) => ex3_both_anon_regions/8cd878b::foo[0] }, BrNamed(CrateNum(0):DefIndex(2147483657), 'a(86))), ReFree(DefId { krate: CrateNum(0), node: DefIndex(3) => ex3_both_anon_regions/8cd878b::foo[0] }, BrNamed(CrateNum(0):DefIndex(2147483658), 'b(88))))
DEBUG:rustc::infer::error_reporting::named_anon_conflict: try_report_named_anon_conflict
DEBUG:rustc::infer::error_reporting::named_anon_conflict: 1.1
DEBUG:rustc::infer::error_reporting::util: arg=Arg { pat: pat(16: y), id: NodeId(15) }
DEBUG:rustc::infer::error_reporting::anon_anon_conflict: try_report_anon_anon_conflict
DEBUG:rustc::infer::error_reporting::anon_anon_conflict: LateBound depth = 1 self.infcx.tcx.hir.local_def_id(id) =DefId { krate: CrateNum(0), node: DefIndex(2147483658) => ex3_both_anon_regions/8cd878b::foo[0]::'b[0] }
                        def_id=DefId { krate: CrateNum(0), node: DefIndex(2147483658) => ex3_both_anon_regions/8cd878b::foo[0]::'b[0] }
DEBUG:rustc::infer::error_reporting::anon_anon_conflict: LateBound depth = 1 self.infcx.tcx.hir.local_def_id(id) =DefId { krate: CrateNum(0), node: DefIndex(2147483658) => ex3_both_anon_regions/8cd878b::foo[0]::'b[0] }
                        def_id=DefId { krate: CrateNum(0), node: DefIndex(2147483657) => ex3_both_anon_regions/8cd878b::foo[0]::'a[0] }

@gaurikholkar-zz
Copy link
Author

gaurikholkar-zz commented Aug 16, 2017

@nikomatsakis
for EarlyBound

fn foo<'a,'b>(x: &mut Vec<&'a u8>, y: &'b u8) where &'a (): Sized, &'b u32: Sized {
        x.push(y);
}

I've confirmed with @arielb1 that this is the correct example for the case but it doesn't seem to trigger the EarlyBound case in the code.

@GuillaumeGomez
Copy link
Member

Could you add in which case this code will improve the current rustc output please? (Put a code with the current output and then the improved one.) It'll help us to understand what you want to do.

@gaurikholkar-zz
Copy link
Author

gaurikholkar-zz commented Aug 17, 2017

@GuillaumeGomez here is the example

fn foo<'a, 'b>(x: &mut Vec<&'a u8>, y: &'b u8) {
    x.push(y);
}

Current output

error[E0312]: lifetime of reference outlives lifetime of borrowed content...
 --> src/main.rs:2:12
  |
2 |     x.push(y);
  |            ^
  |
note: ...the reference is valid for the lifetime 'a as defined on the function body at 1:1...
 --> src/main.rs:1:1
  |
1 | / fn foo<'a, 'b>(x: &mut Vec<&'a u8>, y: &'b u8) {
2 | |     x.push(y);
3 | | }
  | |_^
note: ...but the borrowed content is only valid for the lifetime 'b as defined on the function body at 1:1
 --> src/main.rs:1:1
  |
1 | / fn foo<'a, 'b>(x: &mut Vec<&'a u8>, y: &'b u8) {
2 | |     x.push(y);
3 | | }
  | |_^

New output

error[E0623]: lifetime mismatch
  --> $DIR/ex3-both-anon-regions.rs:12:12
   |
11 | fn foo<'a, 'b>(x: &mut Vec<&'a u8>, y: &'b u8) {
   |                            ------      ------ these two types are declared with different lifetimes...
12 |     x.push(y);
   |            ^ ...but data from `y` flows into `x` here
error: aborting due to previous error

@Mark-Simulacrum Mark-Simulacrum added A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. labels Aug 20, 2017
@gaurikholkar-zz gaurikholkar-zz changed the title Extend E0623 for named conflicts Extend E0623 for named conflicts WIP Sep 5, 2017
bors added a commit that referenced this issue Sep 10, 2017
Extend E0623 for LateBound and EarlyBound Regions

This is a fix for #43882
```
fn foo<'a,'b>(x: &mut Vec<&'a u8>, y: &'b u8) {
    x.push(y);
}
```
now gives

```
error[E0623]: lifetime mismatch
  --> $DIR/ex3-both-anon-regions-latebound-regions.rs:12:12
   |
11 | fn foo<'a,'b>(x: &mut Vec<&'a u8>, y: &'b u8) {
   |                           ------      ------ these two types are declared with different lifetimes...
12 |     x.push(y);
   |            ^ ...but data from `y` flows into `x` here
```
cc @nikomatsakis @arielb1

Please ignore the second commit. It will be merged in a separate PR.
@gaurikholkar-zz
Copy link
Author

In the process of doing it for structs now
#44549

@gaurikholkar-zz
Copy link
Author

gaurikholkar-zz commented Sep 29, 2017

  • Structs
  • Function and Trait Items
  • Free fns, trait definitions and impls
    cc @nikomatsakis you can add the other cases

@estebank
Copy link
Contributor

estebank commented Nov 9, 2017

@gaurikholkar, are there outstanding tasks for this issue?

@gaurikholkar-zz
Copy link
Author

Nope. @estebank updated the title.

@gaurikholkar-zz gaurikholkar-zz changed the title Extend E0623 for named conflicts WIP Extend E0623 for named conflicts Nov 10, 2017
@crlf0710 crlf0710 added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jun 11, 2020
@BGR360
Copy link
Contributor

BGR360 commented Dec 29, 2021

Sooo, can this be closed?

@GuillaumeGomez
Copy link
Member

I guess so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants