Skip to content

Extend E0623 for named conflicts #43882

Closed

Description

@gaurikholkar-zz

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

cc @nikomatsakis @estebank @GuillaumeGomez @arielb1

Activity

  1. gaurikholkar-zz commented on Aug 15, 2017

    @gaurikholkar-zz
    Author

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

  2. gaurikholkar-zz commented on Aug 16, 2017

    @gaurikholkar-zz
    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] }
    
  3. gaurikholkar-zz commented on Aug 16, 2017

    @gaurikholkar-zz
    Author

    @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.

  4. GuillaumeGomez commented on Aug 16, 2017

    @GuillaumeGomez
    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.

  5. gaurikholkar-zz commented on Aug 17, 2017

    @gaurikholkar-zz
    Author

    @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
    
  6. added
    A-diagnosticsArea: Messages for errors, warnings, and lints
    C-enhancementCategory: An issue proposing an enhancement or a PR with one.
    on Aug 20, 2017
  7. changed the title [-]Extend E0623 for named conflicts[/-] [+]Extend E0623 for named conflicts WIP[/+] on Sep 5, 2017
  8. added a commit that references this issue on Sep 10, 2017
  9. gaurikholkar-zz commented on Sep 14, 2017

    @gaurikholkar-zz
    Author

    In the process of doing it for structs now
    #44549

  10. gaurikholkar-zz commented on Sep 29, 2017

    @gaurikholkar-zz
    Author
    • Structs
    • Function and Trait Items
    • Free fns, trait definitions and impls
      cc @nikomatsakis you can add the other cases
  11. estebank commented on Nov 9, 2017

    @estebank
    Contributor

    @gaurikholkar, are there outstanding tasks for this issue?

  12. gaurikholkar-zz commented on Nov 10, 2017

    @gaurikholkar-zz
    Author

    Nope. @estebank updated the title.

  13. changed the title [-]Extend E0623 for named conflicts WIP[/-] [+]Extend E0623 for named conflicts[/+] on Nov 10, 2017
  14. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Jun 11, 2020
  15. BGR360 commented on Dec 29, 2021

    @BGR360
    Contributor

    Sooo, can this be closed?

  16. GuillaumeGomez commented on Dec 29, 2021

    @GuillaumeGomez
    Member

    I guess so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions