Refactor package imports

Closed Sylvain Henry requested to merge hsyl20/ghc:hsyl20/pkgqual into master

The way we handle package imports was quite fragile as identified in fb7c3117:

In doing this I tripped across the specialness of "this" in
PackageImports.  The magic constant (fsLit "this") is scattered across
the compiler and ought to be put in one place.  But where?

We're now doing it properly in the renamer. Commit message:

Use an (Raw)PkgQual datatype instead of `Maybe FastString` to represent
package imports. Factorize the code that renames RawPkgQual into PkgQual
in function `rnPkgQual`. Renaming consists in checking if the FastString
is the magic "this" keyword, the home-unit unit-id or something else.

The first commit is a refactoring that makes the use of lookupPackageName simpler.

(found while trying to understand how imports are handled to fix #20218 (closed))

Merge request reports