Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
bd10ef7
rustc_typeck/check/closure: rustfmt
nikomatsakis Feb 10, 2018
cc05561
detect wrong number of args when type-checking a closure
nikomatsakis Feb 12, 2018
3118cbe
Allow two-phase borrows of &mut self in ops
sapphire-arches Feb 14, 2018
75f72c0
Make nested impl Trait a hard error
cramertj Feb 8, 2018
70e1f4f
Disallow projections from impl Trait types
cramertj Feb 9, 2018
f1fbf79
Amend nested impl Trait error message
cramertj Feb 14, 2018
dbacf0c
Test err on impl Trait projection within dyn Trait
cramertj Feb 14, 2018
20dcc72
inform type annotations
csmoe Feb 14, 2018
d4b8475
incr.comp.: Store DepNode colors in a dense array instead of a hashmap.
michaelwoerister Feb 13, 2018
9e9c55f
Update E0657 stderr to match changed test
cramertj Feb 14, 2018
7062955
Fix arguments specified by lxl in two-phase-bin-ops test
sapphire-arches Feb 15, 2018
f787bdd
Turn features() into a query.
michaelwoerister Feb 14, 2018
c0517a3
incr.comp.: Add regression test for detecting feature gate changes.
michaelwoerister Feb 14, 2018
d691c46
Fix procedural_mbe_matching test case after libsyntax change.
michaelwoerister Feb 15, 2018
1f0e1a0
Convert compile-fail/lint-ctypes.rs to ui test
Feb 14, 2018
7ac5e96
[improper_ctypes] Use a 'help:' line for possible fixes
Feb 11, 2018
ae92dfa
[improper_ctypes] Stop complaining about repr(usize) and repr(isize) …
Feb 11, 2018
9b5f47e
[improper_ctypes] Overhaul primary label
Feb 12, 2018
22a1716
[improper_ctypes] Suggest repr(transparent) for structs
Feb 14, 2018
9d493c8
[improper_ctypes] Point at definition of non-FFI-safe type if possible
Feb 14, 2018
051ea5c
[improper_ctypes] Don't suggest raw pointers when encountering trait …
Feb 14, 2018
0be2dc8
fix stderr
csmoe Feb 17, 2018
2cf683e
Merge branch 'master' into inform_type_annotations
csmoe Feb 17, 2018
01a70c6
Add a closing parenthesis to the span of Visibility::Crate
topecongiro Jan 27, 2018
0bddba9
Add a span field to Visibility::Restricted
topecongiro Jan 27, 2018
d6bdf29
Change ast::Visibility to Spanned type
topecongiro Jan 29, 2018
b5099a7
Replace dummy spans with empty spans
topecongiro Feb 4, 2018
291c51b
Fix up tests and typos
topecongiro Feb 14, 2018
8e9fa57
Revert unintentional submodule updates
topecongiro Feb 17, 2018
472dcdb
Fix broken documentation link.
frewsxcv Feb 18, 2018
4370a58
fix tyvar_behind_raw_pointer error code
csmoe Feb 18, 2018
6818551
bump pulldown
Manishearth Feb 18, 2018
f60aeec
Include shortcut links in markdown_links
Manishearth Feb 18, 2018
1d0ae9f
Generate shortcut links
Manishearth Feb 18, 2018
a04c124
Add test
Manishearth Feb 18, 2018
5fdc10c
Filter out non-macros in resolve_macro
Manishearth Feb 18, 2018
894707a
Rollup merge of #48084 - cramertj:impl-trait-errors, r=nikomatsakis
Manishearth Feb 20, 2018
fa17dac
Rollup merge of #48123 - nikomatsakis:issue-47244-expected-num-args, …
Manishearth Feb 20, 2018
7d3251c
Rollup merge of #48197 - bobtwinkles:two_phase_borrow_on_ops, r=nikom…
Manishearth Feb 20, 2018
e9f5e2b
Rollup merge of #48206 - michaelwoerister:colors-array, r=nikomatsakis
Manishearth Feb 20, 2018
852f7f1
Rollup merge of #48208 - michaelwoerister:track-features, r=petrochenkov
Manishearth Feb 20, 2018
0527a9a
Rollup merge of #48221 - rkruppe:improve-ctypes-lint, r=estebank
Manishearth Feb 20, 2018
f8b640c
Rollup merge of #48335 - Manishearth:shortcut-links, r=QuietMisdreavus
Manishearth Feb 20, 2018
df186aa
Rollup merge of #48198 - csmoe:inform_type_annotations, r=estebank
Manishearth Feb 20, 2018
587c42f
Rollup merge of #48314 - frewsxcv:frewsxcv-broken-link, r=GuillaumeGomez
Manishearth Feb 20, 2018
bbea863
Rollup merge of #47799 - topecongiro:fix-span-of-visibility, r=petroc…
Manishearth Feb 20, 2018
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
Prev Previous commit
Next Next commit
Change ast::Visibility to Spanned type
  • Loading branch information
topecongiro committed Feb 17, 2018
commit d6bdf296a42caec8711adc075782e0b8c920aa1f
10 changes: 5 additions & 5 deletions src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3362,10 +3362,10 @@ impl<'a> LoweringContext<'a> {
v: &Visibility,
explicit_owner: Option<NodeId>)
-> hir::Visibility {
match *v {
Visibility::Public => hir::Public,
Visibility::Crate(..) => hir::Visibility::Crate,
Visibility::Restricted { ref path, id, .. } => {
match v.node {
VisibilityKind::Public => hir::Public,
VisibilityKind::Crate(..) => hir::Visibility::Crate,
VisibilityKind::Restricted { ref path, id, .. } => {
hir::Visibility::Restricted {
path: P(self.lower_path(id, path, ParamMode::Explicit, true)),
id: if let Some(owner) = explicit_owner {
Expand All @@ -3375,7 +3375,7 @@ impl<'a> LoweringContext<'a> {
}
}
}
Visibility::Inherited => hir::Inherited,
VisibilityKind::Inherited => hir::Inherited,
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/librustc_allocator/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use rustc_errors;
use syntax::abi::Abi;
use syntax::ast::{Crate, Attribute, LitKind, StrStyle, ExprKind};
use syntax::ast::{Unsafety, Constness, Generics, Mutability, Ty, Mac, Arg};
use syntax::ast::{self, Ident, Item, ItemKind, TyKind, Visibility, Expr};
use syntax::ast::{self, Ident, Item, ItemKind, TyKind, VisibilityKind, Expr};
use syntax::attr;
use syntax::codemap::dummy_spanned;
use syntax::codemap::{ExpnInfo, NameAndSpan, MacroAttribute};
Expand Down Expand Up @@ -97,7 +97,7 @@ impl<'a> Folder for ExpandAllocatorDirectives<'a> {
]);
let mut items = vec![
f.cx.item_extern_crate(f.span, f.alloc),
f.cx.item_use_simple(f.span, Visibility::Inherited, super_path),
f.cx.item_use_simple(f.span, dummy_spanned(VisibilityKind::Inherited), super_path),
];
for method in ALLOCATOR_METHODS {
items.push(f.allocator_fn(method));
Expand Down
3 changes: 2 additions & 1 deletion src/librustc_metadata/cstore_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ use std::rc::Rc;

use syntax::ast;
use syntax::attr;
use syntax::codemap;
use syntax::ext::base::SyntaxExtension;
use syntax::parse::filemap_to_stream;
use syntax::symbol::Symbol;
Expand Down Expand Up @@ -496,7 +497,7 @@ impl CrateStore for cstore::CStore {
tokens: body.into(),
legacy: def.legacy,
}),
vis: ast::Visibility::Inherited,
vis: codemap::dummy_spanned(ast::VisibilityKind::Inherited),
tokens: None,
})
}
Expand Down
29 changes: 14 additions & 15 deletions src/librustc_passes/ast_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ impl<'a> AstValidator<'a> {
}
}

fn invalid_visibility(&self, vis: &Visibility, span: Span, note: Option<&str>) {
if vis != &Visibility::Inherited {
fn invalid_visibility(&self, vis: &Visibility, note: Option<&str>) {
if vis.node != VisibilityKind::Inherited {
let mut err = struct_span_err!(self.session,
span,
vis.span,
E0449,
"unnecessary visibility qualifier");
if vis == &Visibility::Public {
err.span_label(span, "`pub` not needed here");
if vis.node == VisibilityKind::Public {
err.span_label(vis.span, "`pub` not needed here");
}
if let Some(note) = note {
err.note(note);
Expand Down Expand Up @@ -216,7 +216,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
fn visit_item(&mut self, item: &'a Item) {
match item.node {
ItemKind::Impl(unsafety, polarity, _, _, Some(..), ref ty, ref impl_items) => {
self.invalid_visibility(&item.vis, item.span, None);
self.invalid_visibility(&item.vis, None);
if ty.node == TyKind::Err {
self.err_handler()
.struct_span_err(item.span, "`impl Trait for .. {}` is an obsolete syntax")
Expand All @@ -226,15 +226,14 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
span_err!(self.session, item.span, E0198, "negative impls cannot be unsafe");
}
for impl_item in impl_items {
self.invalid_visibility(&impl_item.vis, impl_item.span, None);
self.invalid_visibility(&impl_item.vis, None);
if let ImplItemKind::Method(ref sig, _) = impl_item.node {
self.check_trait_fn_not_const(sig.constness);
}
}
}
ItemKind::Impl(unsafety, polarity, defaultness, _, None, _, _) => {
self.invalid_visibility(&item.vis,
item.span,
Some("place qualifiers on individual impl items instead"));
if unsafety == Unsafety::Unsafe {
span_err!(self.session, item.span, E0197, "inherent impls cannot be unsafe");
Expand All @@ -247,16 +246,16 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
}
}
ItemKind::ForeignMod(..) => {
self.invalid_visibility(&item.vis,
item.span,
Some("place qualifiers on individual foreign items \
instead"));
self.invalid_visibility(
&item.vis,
Some("place qualifiers on individual foreign items instead"),
);
}
ItemKind::Enum(ref def, _) => {
for variant in &def.variants {
self.invalid_non_exhaustive_attribute(variant);
for field in variant.node.data.fields() {
self.invalid_visibility(&field.vis, field.span, None);
self.invalid_visibility(&field.vis, None);
}
}
}
Expand Down Expand Up @@ -359,8 +358,8 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
}

fn visit_vis(&mut self, vis: &'a Visibility) {
match *vis {
Visibility::Restricted { ref path, .. } => {
match vis.node {
VisibilityKind::Restricted { ref path, .. } => {
path.segments.iter().find(|segment| segment.parameters.is_some()).map(|segment| {
self.err_handler().span_err(segment.parameters.as_ref().unwrap().span(),
"generic arguments in visibility path");
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_resolve/check_unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl<'a, 'b> Visitor<'a> for UnusedImportCheckVisitor<'a, 'b> {
// because this means that they were generated in some fashion by the
// compiler and we don't need to consider them.
if let ast::ItemKind::Use(..) = item.node {
if item.vis == ast::Visibility::Public || item.span.source_equal(&DUMMY_SP) {
if item.vis.node == ast::VisibilityKind::Public || item.span.source_equal(&DUMMY_SP) {
return;
}
}
Expand Down
12 changes: 7 additions & 5 deletions src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3796,13 +3796,15 @@ impl<'a> Resolver<'a> {
}

fn resolve_visibility(&mut self, vis: &ast::Visibility) -> ty::Visibility {
match *vis {
ast::Visibility::Public => ty::Visibility::Public,
ast::Visibility::Crate(..) => ty::Visibility::Restricted(DefId::local(CRATE_DEF_INDEX)),
ast::Visibility::Inherited => {
match vis.node {
ast::VisibilityKind::Public => ty::Visibility::Public,
ast::VisibilityKind::Crate(..) => {
ty::Visibility::Restricted(DefId::local(CRATE_DEF_INDEX))
}
ast::VisibilityKind::Inherited => {
ty::Visibility::Restricted(self.current_module.normal_ancestor_id)
}
ast::Visibility::Restricted { ref path, id, .. } => {
ast::VisibilityKind::Restricted { ref path, id, .. } => {
let def = self.smart_resolve_path(id, None, path,
PathSource::Visibility).base_def();
if def == Def::Err {
Expand Down
36 changes: 16 additions & 20 deletions src/librustc_save_analysis/dump_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ use syntax::print::pprust::{
ty_to_string
};
use syntax::ptr::P;
use syntax::codemap::{Spanned, DUMMY_SP};
use syntax::codemap::{Spanned, DUMMY_SP, dummy_spanned};
use syntax_pos::*;

use {escape, generated_code, lower_attributes, PathCollector, SaveContext};
Expand All @@ -65,12 +65,19 @@ macro_rules! down_cast_data {
}

macro_rules! access_from {
($save_ctxt:expr, $vis:expr, $id:expr) => {
Access {
public: $vis.node == ast::VisibilityKind::Public,
reachable: $save_ctxt.analysis.access_levels.is_reachable($id),
}
};

($save_ctxt:expr, $item:expr) => {
Access {
public: $item.vis == ast::Visibility::Public,
public: $item.vis.node == ast::VisibilityKind::Public,
reachable: $save_ctxt.analysis.access_levels.is_reachable($item.id),
}
}
};
}

pub struct DumpVisitor<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> {
Expand Down Expand Up @@ -405,12 +412,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {

method_data.value = sig_str;
method_data.sig = sig::method_signature(id, name, generics, sig, &self.save_ctxt);
self.dumper.dump_def(
&Access {
public: vis == ast::Visibility::Public,
reachable: self.save_ctxt.analysis.access_levels.is_reachable(id),
},
method_data);
self.dumper.dump_def(&access_from!(self.save_ctxt, vis, id), method_data);
}

// walk arg and return types
Expand Down Expand Up @@ -543,10 +545,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
let span = self.span_from_span(sub_span.expect("No span found for variable"));

self.dumper.dump_def(
&Access {
public: vis == ast::Visibility::Public,
reachable: self.save_ctxt.analysis.access_levels.is_reachable(id),
},
&access_from!(self.save_ctxt, vis, id),
Def {
kind: DefKind::Const,
id: ::id_from_node_id(id, &self.save_ctxt),
Expand Down Expand Up @@ -597,7 +596,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
.iter()
.enumerate()
.filter_map(|(i, f)| {
if include_priv_fields || f.vis == ast::Visibility::Public {
if include_priv_fields || f.vis.node == ast::VisibilityKind::Public {
f.ident
.map(|i| i.to_string())
.or_else(|| Some(i.to_string()))
Expand Down Expand Up @@ -1144,7 +1143,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
&ty,
expr.as_ref().map(|e| &**e),
trait_id,
ast::Visibility::Public,
dummy_spanned(ast::VisibilityKind::Public),
&trait_item.attrs,
);
}
Expand All @@ -1155,7 +1154,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
trait_item.id,
trait_item.ident,
&trait_item.generics,
ast::Visibility::Public,
dummy_spanned(ast::VisibilityKind::Public),
trait_item.span,
);
}
Expand Down Expand Up @@ -1259,10 +1258,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {

// The access is calculated using the current tree ID, but with the root tree's visibility
// (since nested trees don't have their own visibility).
let access = Access {
public: root_item.vis == ast::Visibility::Public,
reachable: self.save_ctxt.analysis.access_levels.is_reachable(id),
};
let access = access_from!(self.save_ctxt, root_item.vis, id);

// The parent def id of a given use tree is always the enclosing item.
let parent = self.save_ctxt.tcx.hir.opt_local_def_id(id)
Expand Down
8 changes: 5 additions & 3 deletions src/libsyntax/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1937,11 +1937,13 @@ pub enum CrateSugar {
JustCrate,
}

pub type Visibility = Spanned<VisibilityKind>;

#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
pub enum Visibility {
pub enum VisibilityKind {
Public,
Crate(Span, CrateSugar),
Restricted { path: P<Path>, id: NodeId, span: Span },
Crate(CrateSugar),
Restricted { path: P<Path>, id: NodeId },
Inherited,
}

Expand Down
3 changes: 2 additions & 1 deletion src/libsyntax/diagnostics/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use std::env;

use ast;
use ast::{Ident, Name};
use codemap;
use syntax_pos::Span;
use ext::base::{ExtCtxt, MacEager, MacResult};
use ext::build::AstBuilder;
Expand Down Expand Up @@ -234,7 +235,7 @@ pub fn expand_build_diagnostic_array<'cx>(ecx: &'cx mut ExtCtxt,
ty,
expr,
),
vis: ast::Visibility::Public,
vis: codemap::dummy_spanned(ast::VisibilityKind::Public),
span,
tokens: None,
})
Expand Down
4 changes: 2 additions & 2 deletions src/libsyntax/ext/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -987,7 +987,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
attrs,
id: ast::DUMMY_NODE_ID,
node,
vis: ast::Visibility::Inherited,
vis: dummy_spanned(ast::VisibilityKind::Inherited),
span,
tokens: None,
})
Expand Down Expand Up @@ -1033,7 +1033,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
span: ty.span,
ty,
ident: None,
vis: ast::Visibility::Inherited,
vis: dummy_spanned(ast::VisibilityKind::Inherited),
attrs: Vec::new(),
id: ast::DUMMY_NODE_ID,
}
Expand Down
9 changes: 6 additions & 3 deletions src/libsyntax/ext/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use ast::{self, Block, Ident, NodeId, PatKind, Path};
use ast::{MacStmtStyle, StmtKind, ItemKind};
use attr::{self, HasAttrs};
use codemap::{ExpnInfo, NameAndSpan, MacroBang, MacroAttribute, dummy_spanned};
use codemap::{ExpnInfo, NameAndSpan, MacroBang, MacroAttribute, dummy_spanned, respan};
use config::{is_test_or_bench, StripUnconfigured};
use errors::FatalError;
use ext::base::*;
Expand Down Expand Up @@ -238,7 +238,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
node: ast::ItemKind::Mod(krate.module),
ident: keywords::Invalid.ident(),
id: ast::DUMMY_NODE_ID,
vis: ast::Visibility::Public,
vis: dummy_spanned(ast::VisibilityKind::Public),
tokens: None,
})));

Expand Down Expand Up @@ -1022,7 +1022,10 @@ impl<'a, 'b> Folder for InvocationCollector<'a, 'b> {
// Ensure that test functions are accessible from the test harness.
ast::ItemKind::Fn(..) if self.cx.ecfg.should_test => {
if item.attrs.iter().any(|attr| is_test_or_bench(attr)) {
item = item.map(|mut item| { item.vis = ast::Visibility::Public; item });
item = item.map(|mut item| {
item.vis = respan(item.vis.span, ast::VisibilityKind::Public);
item
});
}
noop_fold_item(item, self)
}
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/ext/placeholders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub fn placeholder(kind: ExpansionKind, id: ast::NodeId) -> Expansion {
let ident = keywords::Invalid.ident();
let attrs = Vec::new();
let generics = ast::Generics::default();
let vis = ast::Visibility::Inherited;
let vis = dummy_spanned(ast::VisibilityKind::Inherited);
let span = DUMMY_SP;
let expr_placeholder = || P(ast::Expr {
id, span,
Expand Down
8 changes: 7 additions & 1 deletion src/libsyntax/ext/quote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// except according to those terms.

use ast::{self, Arg, Arm, Block, Expr, Item, Pat, Stmt, Ty};
use codemap::dummy_spanned;
use syntax_pos::Span;
use ext::base::ExtCtxt;
use ext::base;
Expand Down Expand Up @@ -855,7 +856,12 @@ fn expand_wrapper(cx: &ExtCtxt,
let mut stmts = imports.iter().map(|path| {
// make item: `use ...;`
let path = path.iter().map(|s| s.to_string()).collect();
cx.stmt_item(sp, cx.item_use_glob(sp, ast::Visibility::Inherited, ids_ext(path)))
let use_item = cx.item_use_glob(
sp,
dummy_spanned(ast::VisibilityKind::Inherited),
ids_ext(path),
);
cx.stmt_item(sp, use_item)
}).chain(Some(stmt_let_ext_cx)).collect::<Vec<_>>();
stmts.push(cx.stmt_expr(expr));

Expand Down
4 changes: 2 additions & 2 deletions src/libsyntax/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1816,8 +1816,8 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
}

fn visit_vis(&mut self, vis: &'a ast::Visibility) {
if let ast::Visibility::Crate(span, ast::CrateSugar::JustCrate) = *vis {
gate_feature_post!(&self, crate_visibility_modifier, span,
if let ast::VisibilityKind::Crate(ast::CrateSugar::JustCrate) = vis.node {
gate_feature_post!(&self, crate_visibility_modifier, vis.span,
"`crate` visibility modifier is experimental");
}
visit::walk_vis(self, vis);
Expand Down
Loading