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

Do not complain about unconstrained params when Self is Ty Error #64108

Merged
merged 4 commits into from
Sep 9, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
18 changes: 8 additions & 10 deletions src/librustc_typeck/constrained_generic_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ impl From<ty::ParamConst> for Parameter {
}

/// Returns the set of parameters constrained by the impl header.
pub fn parameters_for_impl<'tcx>(impl_self_ty: Ty<'tcx>,
impl_trait_ref: Option<ty::TraitRef<'tcx>>)
-> FxHashSet<Parameter>
{
pub fn parameters_for_impl<'tcx>(
impl_self_ty: Ty<'tcx>,
impl_trait_ref: Option<ty::TraitRef<'tcx>>,
) -> FxHashSet<Parameter> {
let vec = match impl_trait_ref {
Some(tr) => parameters_for(&tr, false),
None => parameters_for(&impl_self_ty, false),
Expand All @@ -36,12 +36,10 @@ pub fn parameters_for_impl<'tcx>(impl_self_ty: Ty<'tcx>,
/// uniquely determined by `t` (see RFC 447). If it is true, return the list
/// of parameters whose values are needed in order to constrain `ty` - these
/// differ, with the latter being a superset, in the presence of projections.
pub fn parameters_for<'tcx, T>(t: &T,
include_nonconstraining: bool)
-> Vec<Parameter>
where T: TypeFoldable<'tcx>
{

pub fn parameters_for<'tcx, T: TypeFoldable<'tcx>>(
estebank marked this conversation as resolved.
Show resolved Hide resolved
t: &T,
estebank marked this conversation as resolved.
Show resolved Hide resolved
include_nonconstraining: bool,
) -> Vec<Parameter> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spurious rustfmt?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My guess is manual drive-by fixing... but who cares. ;)

let mut collector = ParameterCollector {
parameters: vec![],
include_nonconstraining,
Expand Down
4 changes: 4 additions & 0 deletions src/librustc_typeck/impl_wf_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ fn enforce_impl_params_are_constrained(
) {
// Every lifetime used in an associated type must be constrained.
let impl_self_ty = tcx.type_of(impl_def_id);
if impl_self_ty.sty == ty::Error {
estebank marked this conversation as resolved.
Show resolved Hide resolved
// Don't complain about unconstrained type params when self ty doesn't exist. (#36836)
return;
estebank marked this conversation as resolved.
Show resolved Hide resolved
}
let impl_generics = tcx.generics_of(impl_def_id);
let impl_predicates = tcx.predicates_of(impl_def_id);
let impl_trait_ref = tcx.impl_trait_ref(impl_def_id);
Expand Down
5 changes: 5 additions & 0 deletions src/test/ui/issues/issue-36836.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
trait Foo {}
estebank marked this conversation as resolved.
Show resolved Hide resolved

impl<T> Foo for Bar<T> {} //~ ERROR cannot find type `Bar` in this scope

fn main() {}
9 changes: 9 additions & 0 deletions src/test/ui/issues/issue-36836.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
error[E0412]: cannot find type `Bar` in this scope
--> $DIR/issue-36836.rs:3:17
|
LL | impl<T> Foo for Bar<T> {}
| ^^^ not found in this scope

error: aborting due to previous error

For more information about this error, try `rustc --explain E0412`.