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

Prefer accessible paths in 'use' suggestions #72623

Merged
merged 1 commit into from
Jun 22, 2020

Commits on Jun 21, 2020

  1. Prefer accessible paths in 'use' suggestions

    This fixes an issue with the following sample:
    
        mod foo {
    	mod inaccessible {
    	    pub struct X;
    	}
    	pub mod avail {
    	    pub struct X;
    	}
        }
    
        fn main() { X; }
    
    Instead of suggesting both `use crate::foo::inaccessible::X;` and `use
    crate::foo::avail::X;`, it should only suggest the latter.
    
    It is done by trimming the list of suggestions from inaccessible paths
    if accessible paths are present.
    
    Visibility is checked with `is_accessible_from` now instead of being
    hard-coded.
    
    -
    
    Some tests fixes are trivial, and others require a bit more explaining,
    here are my comments:
    
    src/test/ui/issues/issue-35675.stderr: Only needs to make the enum
    public to have the suggestion make sense.
    
    src/test/ui/issues/issue-42944.stderr: Importing the tuple struct won't
    help because its constructor is not visible, so the attempted
    constructor does not work. In that case, it's better not to suggest it.
    The case where the constructor is public is covered in `issue-26545.rs`.
    da-x committed Jun 21, 2020
    Configuration menu
    Copy the full SHA
    fea5ab1 View commit details
    Browse the repository at this point in the history