Look up macro names as well when suggesting replacements for function resolve errors

fixes #5780
This commit is contained in:
Manish Goregaokar
2015-11-21 15:07:50 +05:30
parent ef5ee7d895
commit 99925fb562
6 changed files with 76 additions and 30 deletions

View File

@@ -27,7 +27,7 @@ use util::small_vector::SmallVector;
use ext::mtwt;
use fold::Folder;
use std::collections::HashMap;
use std::collections::{HashMap, HashSet};
use std::rc::Rc;
use std::default::Default;
@@ -856,7 +856,10 @@ pub fn get_exprs_from_tts(cx: &mut ExtCtxt,
///
/// This environment maps Names to SyntaxExtensions.
pub struct SyntaxEnv {
chain: Vec<MapChainFrame> ,
chain: Vec<MapChainFrame>,
/// All bang-style macro/extension names
/// encountered so far; to be used for diagnostics in resolve
pub names: HashSet<Name>,
}
// impl question: how to implement it? Initially, the
@@ -876,7 +879,7 @@ struct MapChainFrame {
impl SyntaxEnv {
fn new() -> SyntaxEnv {
let mut map = SyntaxEnv { chain: Vec::new() };
let mut map = SyntaxEnv { chain: Vec::new() , names: HashSet::new()};
map.push_frame();
map
}
@@ -913,6 +916,9 @@ impl SyntaxEnv {
}
pub fn insert(&mut self, k: Name, v: SyntaxExtension) {
if let NormalTT(..) = v {
self.names.insert(k);
}
self.find_escape_frame().map.insert(k, Rc::new(v));
}