}
PathResult::Failed(span, msg, true) => {
let (mut self_path, mut self_result) = (module_path.clone(), None);
- if !self_path.is_empty() &&
- !token::Ident(self_path[0].node).is_path_segment_keyword() &&
- !(self_path.len() > 1 &&
- token::Ident(self_path[1].node).is_path_segment_keyword())
- {
+ let is_special = |ident| token::Ident(ident).is_path_segment_keyword() &&
+ ident.name != keywords::CrateRoot.name();
+ if !self_path.is_empty() && !is_special(self_path[0].node) &&
+ !(self_path.len() > 1 && is_special(self_path[1].node)) {
self_path[0].node.name = keywords::SelfValue.name();
self_result = Some(self.resolve_path(&self_path, None, false, span));
}
if names.is_empty() {
import_directive_subclass_to_string(subclass)
} else {
- // FIXME: Remove this entire logic after #48116 is fixed.
- //
- // Note that this code looks a little wonky, it's currently here to
- // hopefully help debug #48116, but otherwise isn't intended to
- // cause any problems.
- let x = format!(
- "{}::{}",
- names_to_string(names),
- import_directive_subclass_to_string(subclass),
- );
- if names.is_empty() || x.starts_with("::") {
- span_bug!(
- span,
- "invalid name `{}` at {:?}; global = {}, names = {:?}, subclass = {:?}",
- x,
- span,
- global,
- names,
- subclass
- );
- }
- return x
+ format!("{}::{}",
+ names_to_string(names),
+ import_directive_subclass_to_string(subclass))
}
}
}
})?)
}
+fn check_item_well_formed<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) {
+ wfcheck::check_item_well_formed(tcx, def_id);
+}
+
+fn check_trait_item_well_formed<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) {
+ wfcheck::check_trait_item(tcx, def_id);
+}
+
+fn check_impl_item_well_formed<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) {
+ wfcheck::check_impl_item(tcx, def_id);
+}
+
pub fn provide(providers: &mut Providers) {
*providers = Providers {
typeck_item_bodies,
has_typeck_tables,
adt_destructor,
used_trait_imports,
+ check_item_well_formed,
+ check_trait_item_well_formed,
+ check_impl_item_well_formed,
..*providers
};
}
if sugg_unit {
let sugg_span = sess.codemap().end_point(expr_sp);
// remove closing `)` from the span
- let sugg_span = sugg_span.with_hi(sugg_span.lo());
+ let sugg_span = sugg_span.shrink_to_lo();
err.span_suggestion(
sugg_span,
"expected the unit value `()`; create it with empty parentheses",
let origin = self.misc(call_span);
let ures = self.at(&origin, self.param_env).sup(ret_ty, formal_ret);
- // FIXME(#15760) can't use try! here, FromError doesn't default
+ // FIXME(#27336) can't use ? here, Try::from_error doesn't default
// to identity so the resulting type is not constrained.
match ures {
Ok(ok) => {
// we can. We don't care if some things turn
// out unconstrained or ambiguous, as we're
// just trying to get hints here.
- let result = self.save_and_restore_in_snapshot_flag(|_| {
+ self.save_and_restore_in_snapshot_flag(|_| {
let mut fulfill = FulfillmentContext::new();
- let ok = ok; // FIXME(#30046)
for obligation in ok.obligations {
fulfill.register_predicate_obligation(self, obligation);
}
fulfill.select_where_possible(self)
- });
-
- match result {
- Ok(()) => { }
- Err(_) => return Err(()),
- }
+ }).map_err(|_| ())?;
}
Err(_) => return Err(()),
}
debug!("parse_str_lit: given {}", escape_default(lit));
let mut res = String::with_capacity(lit.len());
- // FIXME #8372: This could be a for-loop if it didn't borrow the iterator
let error = |i| format!("lexer should have rejected {} at {}", lit, i);
/// Eat everything up to a non-whitespace
pub fn byte_str_lit(lit: &str) -> Lrc<Vec<u8>> {
let mut res = Vec::with_capacity(lit.len());
- // FIXME #8372: This could be a for-loop if it didn't borrow the iterator
let error = |i| format!("lexer should have rejected {} at {}", lit, i);
/// Eat everything up to a non-whitespace
id: ast::DUMMY_NODE_ID,
node: ast::ExprKind::Path(None, ast::Path {
span: sp(0, 6),
- segments: vec![ast::PathSegment::crate_root(sp(0, 2)),
+ segments: vec![ast::PathSegment::crate_root(sp(0, 0)),
str2seg("a", 2, 3),
str2seg("b", 5, 6)]
}),
span_diagnostic: &errors::Handler,
features: &Features) -> ast::Crate {
// Check for #[reexport_test_harness_main = "some_name"] which
- // creates a `use some_name = __test::main;`. This needs to be
+ // creates a `use __test::main as some_name;`. This needs to be
// unconditional, so that the attribute is still marked as used in
// non-test builds.
let reexport_test_harness_main =
cx.ext_cx.path(DUMMY_SP, vec![super_, r]))
}).chain(tested_submods.into_iter().map(|(r, sym)| {
let path = cx.ext_cx.path(DUMMY_SP, vec![super_, r, sym]);
- cx.ext_cx.item_use_simple_(DUMMY_SP, dummy_spanned(ast::VisibilityKind::Public), r, path)
+ cx.ext_cx.item_use_simple_(DUMMY_SP, dummy_spanned(ast::VisibilityKind::Public),
+ Some(r), path)
})).collect();
let reexport_mod = ast::Mod {
(ast::ItemKind::Use(P(ast::UseTree {
span: DUMMY_SP,
prefix: path_node(vec![id_test]),
- kind: ast::UseTreeKind::Simple(id_test),
+ kind: ast::UseTreeKind::Simple(None),
})),
ast::VisibilityKind::Public, keywords::Invalid.ident())
} else {
tokens: None,
})).pop().unwrap();
let reexport = cx.reexport_test_harness_main.map(|s| {
- // building `use <ident> = __test::main`
- let reexport_ident = Ident::with_empty_ctxt(s);
+ // building `use __test::main as <ident>;`
+ let rename = Ident::with_empty_ctxt(s);
let use_path = ast::UseTree {
span: DUMMY_SP,
prefix: path_node(vec![mod_ident, Ident::from_str("main")]),
- kind: ast::UseTreeKind::Simple(reexport_ident),
+ kind: ast::UseTreeKind::Simple(Some(rename)),
};
expander.fold_item(P(ast::Item {
}
fn path_name_i(idents: &[Ident]) -> String {
- // FIXME: Bad copies (#2543 -- same for everything else that says "bad")
- idents.iter().map(|i| i.to_string()).collect::<Vec<String>>().join("::")
+ let mut path_name = "".to_string();
+ let mut idents_iter = idents.iter().peekable();
+ while let Some(ident) = idents_iter.next() {
+ path_name.push_str(&ident.name.as_str());
+ if let Some(_) = idents_iter.peek() {
+ path_name.push_str("::")
+ }
+ }
+ path_name
}
fn mk_tests(cx: &TestCtxt) -> P<ast::Item> {
// gensym information.
let span = ignored_span(cx, test.span);
- let path = test.path.clone();
let ecx = &cx.ext_cx;
let self_id = ecx.ident_of("self");
let test_id = ecx.ident_of("test");
// creates $name: $expr
let field = |name, expr| ecx.field_imm(span, ecx.ident_of(name), expr);
- debug!("encoding {}", path_name_i(&path[..]));
-
// path to the #[test] function: "foo::bar::baz"
- let path_string = path_name_i(&path[..]);
+ let path_string = path_name_i(&test.path[..]);
+
+ debug!("encoding {}", path_string);
+
let name_expr = ecx.expr_str(span, Symbol::intern(&path_string));
// self::test::StaticTestName($name_expr)
diag.bug("expected to find top-level re-export name, but found None");
}
};
- visible_path.extend(path);
+ visible_path.extend_from_slice(&test.path[..]);
// Rather than directly give the test function to the test
// harness, we create a wrapper like one of the following: