Skip to content

Fix issue #8763 #10475

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

Merged
merged 1 commit into from
Nov 24, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
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
11 changes: 9 additions & 2 deletions src/librustc/middle/typeck/astconv.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
Expand Down Expand Up @@ -60,10 +60,11 @@ use middle::typeck::lookup_def_tcx;

use std::vec;
use syntax::abi::AbiSet;
use syntax::{ast, ast_util};
use syntax::{ast, ast_map, ast_util};
use syntax::codemap::Span;
use syntax::opt_vec::OptVec;
use syntax::opt_vec;
use syntax::parse::token;
use syntax::print::pprust::{lifetime_to_str, path_to_str};

pub trait AstConv {
Expand Down Expand Up @@ -518,6 +519,12 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:RegionScope>(
let did = ast_util::local_def(id);
ty::mk_self(tcx, did)
}
ast::DefMod(id) => {
tcx.sess.span_fatal(ast_ty.span,
format!("found module name used as a type: {}",
ast_map::node_id_to_str(tcx.items, id.node,
token::get_ident_interner())));
}
_ => {
tcx.sess.span_fatal(ast_ty.span,
format!("found value name used as a type: {:?}", a_def));
Expand Down
21 changes: 21 additions & 0 deletions src/test/compile-fail/trait-impl-for-module.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

mod a {
}

trait A {
}

impl A for a { //~ERROR found module name used as a type
}

fn main() {
}
6 changes: 3 additions & 3 deletions src/test/compile-fail/trait-or-new-type-instead.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
Expand All @@ -8,8 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// error-pattern: found value name used as a type
impl<T> Option<T> {
// FIXME(#8767) bad error message; Option is not a module
impl<T> Option<T> { //~ERROR found module name used as a type
pub fn foo(&self) { }
}

Expand Down