Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
8a64cf7
Fix suggestion span error with a line containing non-ASCIIs
sinkuu Feb 25, 2017
53d3c89
Dont bug! on user error
bjorn3 Feb 28, 2017
54a1c8b
Fix indentation in region infer docs
bjorn3 Feb 28, 2017
2a40918
Syntax highlighting in region infer docs
bjorn3 Feb 28, 2017
be49671
Improve a bit more
bjorn3 Feb 28, 2017
90e94d9
Syntax highlight and note about current rust in infer docs
bjorn3 Feb 28, 2017
234753a
Fix missing backtick typo
Nashenas88 Mar 8, 2017
3198904
Disallow subtyping between T and U in T: Unsize<U>.
eddyb Mar 7, 2017
79a7ee8
fix UB in repr(packed) tests
TimNN Mar 8, 2017
edf5dc6
Box docs: no allocation is done for ZSTs.
Mar 9, 2017
74bc7fd
Overhaul coercion to use the lazy InferOk obligations passing.
eddyb Mar 8, 2017
4eeede3
fix emscripten test detection
TimNN Mar 4, 2017
da6e7c8
Distinguish the ways `CStr::from_bytes_with_nul` can fail
tbu- Mar 9, 2017
57c989c
Fix botched member variable rename
shepmaster Mar 4, 2017
3e2390f
Restore creating the channel-rust-$channel-date.txt files
shepmaster Mar 3, 2017
8062cfb
Implement placement-in protocol for and `VecDeque`
Mar 9, 2017
84d1f6a
Do not bother creating StorageLive for TyNever
nagisa Mar 8, 2017
4078b25
Clean up rustdoc css
GuillaumeGomez Mar 9, 2017
cfb41ae
Use subtyping on the target of unsizing coercions.
eddyb Mar 9, 2017
b95b5db
update gdbr tests
TimNN Mar 9, 2017
7f19f1f
fix #40294 obligation cause.body_id is not always a NodeExpr
Mar 9, 2017
889337d
move related tests to type-check ui test directory
Mar 10, 2017
a8cacd3
travis: Attempt to debug sccache failures
alexcrichton Mar 7, 2017
7688222
Don't put Cargo into the rustc workspace
alexcrichton Mar 6, 2017
ac2bc7c
Point to enclosing block/fn on nested unsafe
estebank Jan 20, 2017
a07c9a2
Export attributes in save-analysis data
jonasbb Feb 14, 2017
203d227
Store attributes as strings
jonasbb Feb 23, 2017
db35604
Move remove_docs_from_attrs into lowering step
jonasbb Mar 2, 2017
4ca9c97
Remove ability for plugins to register a MIR pass
nagisa Mar 3, 2017
7b0dd7b
Fix incorrect span label formatting
estebank Mar 6, 2017
5afe784
Expect macro defs in save-analysis and add expn info to spans for att…
Mar 7, 2017
880262a
Update syntax for `pub(restricted)`
petrochenkov Mar 7, 2017
e5d1b9c
save-analysis: cope with lack of method data after a type error
Mar 8, 2017
b959d13
Allow lints to check Bodys directly
oli-obk Mar 7, 2017
993eae1
rustc: Support auto-retry linking on a segfault
alexcrichton Mar 10, 2017
83814fd
OsString::shrink_to_fit.
Mar 10, 2017
384ee48
Clarify docs in `VecDeque::resize`
DirkyJerky Mar 10, 2017
038ec50
emit !align attributes on stores of operand pairs
arielb1 Mar 9, 2017
f846aaf
rustbuild: Build documentation for `proc_macro`
alexcrichton Mar 1, 2017
6de7215
Rollup merge of #39202 - estebank:nested-unsafe, r=jonathandturner
Mar 10, 2017
f2c96dd
Rollup merge of #39820 - jonasbb:export-attributes, r=nrc
Mar 10, 2017
3ec2834
Rollup merge of #40092 - sinkuu:fix_suggestion_index, r=pnkfelix
Mar 10, 2017
6454bd0
Rollup merge of #40146 - bjorn3:few-infer-changes, r=pnkfelix
Mar 10, 2017
66c0345
Rollup merge of #40199 - alexcrichton:doc-proc-macro, r=brson
Mar 10, 2017
3fce5a6
Rollup merge of #40225 - shepmaster:restore-build-date-file, r=alexcr…
Mar 10, 2017
846c037
Rollup merge of #40239 - nagisa:death-to-plugins, r=nikomatsakis
Mar 10, 2017
844d010
Rollup merge of #40259 - TimNN:fix-emscripten-tests, r=alexcrichton
Mar 10, 2017
c50eed5
Rollup merge of #40278 - GuillaumeGomez:css-cleanup, r=frewsxcv
Mar 10, 2017
21c6cf6
Rollup merge of #40287 - estebank:label-overlap, r=nrc
Mar 10, 2017
36e263d
Rollup merge of #40297 - alexcrichton:fix-submodules, r=brson
Mar 10, 2017
66d9eba
Rollup merge of #40311 - nrc:save-proc-macro-attr, r=jseyfried
Mar 10, 2017
a658211
Rollup merge of #40315 - oli-obk:lint_body, r=eddyb
Mar 10, 2017
77da9de
Rollup merge of #40319 - eddyb:it's-"unsize"-not-"unsound", r=nikomat…
Mar 10, 2017
9824687
Rollup merge of #40324 - alexcrichton:sccache-errors, r=aturon
Mar 10, 2017
f82812c
Rollup merge of #40340 - petrochenkov:restricted, r=nikomatsakis
Mar 10, 2017
619f355
Rollup merge of #40344 - nrc:save-container, r=eddyb
Mar 10, 2017
8394360
Rollup merge of #40345 - Nashenas88:patch-1, r=estebank
Mar 10, 2017
f7d8ad1
Rollup merge of #40372 - nagisa:never-drop, r=eddyb
Mar 10, 2017
d5db32c
Rollup merge of #40373 - TimNN:test-ub-packed, r=arielb1
Mar 10, 2017
65738a1
Rollup merge of #40379 - clarcharr:box_docs, r=brson
Mar 10, 2017
50e78eb
Rollup merge of #40385 - arielb1:packed-again, r=eddyb
Mar 10, 2017
befac3c
Rollup merge of #40386 - tbu-:pr_display_frombyteswithnulerror, r=ale…
Mar 10, 2017
7da6516
Rollup merge of #40389 - F001:placementVecDeque, r=nagisa
Mar 10, 2017
811c965
Rollup merge of #40400 - TimNN:gdbr-updates, r=alexcrichton
Mar 10, 2017
8da64f8
Rollup merge of #40404 - cengizIO:master, r=nikomatsakis
Mar 10, 2017
308650a
Rollup merge of #40410 - clarcharr:os_string_shrink_to_fit, r=alexcri…
Mar 10, 2017
428d878
Rollup merge of #40422 - alexcrichton:retry-linker-segfault, r=arielb1
Mar 10, 2017
2645637
Rollup merge of #40423 - DirkyJerky:patch-2, r=BurntSushi
Mar 10, 2017
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
72 changes: 40 additions & 32 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4605,7 +4605,7 @@ impl<'a> Parser<'a> {

let mut attrs = self.parse_outer_attributes()?;
let lo = self.span.lo;
let vis = self.parse_visibility(true)?;
let vis = self.parse_visibility()?;
let defaultness = self.parse_defaultness()?;
let (name, node) = if self.eat_keyword(keywords::Type) {
let name = self.parse_ident()?;
Expand Down Expand Up @@ -4936,7 +4936,7 @@ impl<'a> Parser<'a> {
|p| {
let attrs = p.parse_outer_attributes()?;
let lo = p.span.lo;
let mut vis = p.parse_visibility(false)?;
let mut vis = p.parse_visibility()?;
let ty_is_interpolated =
p.token.is_interpolated() || p.look_ahead(1, |t| t.is_interpolated());
let mut ty = p.parse_ty()?;
Expand Down Expand Up @@ -4993,38 +4993,46 @@ impl<'a> Parser<'a> {
fn parse_struct_decl_field(&mut self) -> PResult<'a, StructField> {
let attrs = self.parse_outer_attributes()?;
let lo = self.span.lo;
let vis = self.parse_visibility(true)?;
let vis = self.parse_visibility()?;
self.parse_single_struct_field(lo, vis, attrs)
}

// If `allow_path` is false, just parse the `pub` in `pub(path)` (but still parse `pub(crate)`)
fn parse_visibility(&mut self, allow_path: bool) -> PResult<'a, Visibility> {
let pub_crate = |this: &mut Self| {
let span = this.prev_span;
this.expect(&token::CloseDelim(token::Paren))?;
Ok(Visibility::Crate(span))
};

// Parse `pub`, `pub(crate)` and `pub(in path)` plus shortcuts
// `pub(self)` for `pub(in self)` and `pub(super)` for `pub(in super)`.
fn parse_visibility(&mut self) -> PResult<'a, Visibility> {
if !self.eat_keyword(keywords::Pub) {
Ok(Visibility::Inherited)
} else if !allow_path {
// Look ahead to avoid eating the `(` in `pub(path)` while still parsing `pub(crate)`
if self.token == token::OpenDelim(token::Paren) &&
self.look_ahead(1, |t| t.is_keyword(keywords::Crate)) {
self.bump(); self.bump();
pub_crate(self)
} else {
Ok(Visibility::Public)
}
} else if !self.eat(&token::OpenDelim(token::Paren)) {
Ok(Visibility::Public)
} else if self.eat_keyword(keywords::Crate) {
pub_crate(self)
} else {
let path = self.parse_path(PathStyle::Mod)?.default_to_global();
self.expect(&token::CloseDelim(token::Paren))?;
Ok(Visibility::Restricted { path: P(path), id: ast::DUMMY_NODE_ID })
}
return Ok(Visibility::Inherited)
}

if self.check(&token::OpenDelim(token::Paren)) {
if self.look_ahead(1, |t| t.is_keyword(keywords::Crate)) {
// `pub(crate)`
self.bump(); // `(`
self.bump(); // `crate`
let vis = Visibility::Crate(self.prev_span);
self.expect(&token::CloseDelim(token::Paren))?; // `)`
return Ok(vis)
} else if self.look_ahead(1, |t| t.is_keyword(keywords::In)) {
// `pub(in path)`
self.bump(); // `(`
self.bump(); // `in`
let path = self.parse_path(PathStyle::Mod)?.default_to_global(); // `path`
let vis = Visibility::Restricted { path: P(path), id: ast::DUMMY_NODE_ID };
self.expect(&token::CloseDelim(token::Paren))?; // `)`
return Ok(vis)
} else if self.look_ahead(2, |t| t == &token::CloseDelim(token::Paren)) &&
self.look_ahead(1, |t| t.is_keyword(keywords::Super) ||
t.is_keyword(keywords::SelfValue)) {
// `pub(self)` or `pub(super)`
self.bump(); // `(`
let path = self.parse_path(PathStyle::Mod)?.default_to_global(); // `super`/`self`
let vis = Visibility::Restricted { path: P(path), id: ast::DUMMY_NODE_ID };
self.expect(&token::CloseDelim(token::Paren))?; // `)`
return Ok(vis)
}
}

Ok(Visibility::Public)
}

/// Parse defaultness: DEFAULT or nothing
Expand Down Expand Up @@ -5499,7 +5507,7 @@ impl<'a> Parser<'a> {

let lo = self.span.lo;

let visibility = self.parse_visibility(true)?;
let visibility = self.parse_visibility()?;

if self.eat_keyword(keywords::Use) {
// USE ITEM
Expand Down Expand Up @@ -5774,7 +5782,7 @@ impl<'a> Parser<'a> {
fn parse_foreign_item(&mut self) -> PResult<'a, Option<ForeignItem>> {
let attrs = self.parse_outer_attributes()?;
let lo = self.span.lo;
let visibility = self.parse_visibility(true)?;
let visibility = self.parse_visibility()?;

if self.check_keyword(keywords::Static) {
// FOREIGN STATIC ITEM
Expand Down
8 changes: 4 additions & 4 deletions src/test/compile-fail-fulldeps/auxiliary/pub_and_stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ mod m {
#[unstable(feature = "unstable_undeclared", issue = "38412")] // SILLY
pub(crate) b_crate: i32,
#[unstable(feature = "unstable_declared", issue = "38412")] // SILLY
pub(m) c_mod: i32,
pub(in m) c_mod: i32,
#[stable(feature = "unit_test", since = "0.0.0")] // SILLY
d_priv: i32
}
Expand All @@ -71,7 +71,7 @@ mod m {
pub i32,

pub(crate) i32,
pub(m) i32,
pub(in m) i32,
i32);

impl Record {
Expand Down Expand Up @@ -124,7 +124,7 @@ mod m {
#[unstable(feature = "unstable_undeclared", issue = "38412")] // SILLY
pub(crate) fn pub_crate(&self) -> i32 { self.d_priv }
#[unstable(feature = "unstable_declared", issue = "38412")] // SILLY
pub(m) fn pub_mod(&self) -> i32 { self.d_priv }
pub(in m) fn pub_mod(&self) -> i32 { self.d_priv }
#[stable(feature = "unit_test", since = "0.0.0")] // SILLY
fn private(&self) -> i32 { self.d_priv }
}
Expand All @@ -138,7 +138,7 @@ mod m {
pub fn stable(&self) -> i32 { self.0 }

pub(crate) fn pub_crate(&self) -> i32 { self.0 }
pub(m) fn pub_mod(&self) -> i32 { self.0 }
pub(in m) fn pub_mod(&self) -> i32 { self.0 }
fn private(&self) -> i32 { self.0 }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ mod foo {
mod bar {
#[derive(Default)]
pub struct S {
pub(foo) x: i32,
pub(in foo) x: i32,
}
impl S {
pub(foo) fn f(&self) -> i32 { 0 }
pub(in foo) fn f(&self) -> i32 { 0 }
}

pub struct S2 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
mod foo {
pub mod bar {
pub struct S {
pub(foo) x: i32,
pub(in foo) x: i32,
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/test/compile-fail/privacy/restricted/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@ fn main() {
}

mod pathological {
pub(bad::path) mod m1 {} //~ ERROR failed to resolve. Maybe a missing `extern crate bad;`?
pub(foo) mod m2 {} //~ ERROR visibilities can only be restricted to ancestor modules
pub(in bad::path) mod m1 {} //~ ERROR failed to resolve. Maybe a missing `extern crate bad;`?
pub(in foo) mod m2 {} //~ ERROR visibilities can only be restricted to ancestor modules
}
7 changes: 1 addition & 6 deletions src/test/compile-fail/privacy/restricted/ty-params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,11 @@
#![feature(pub_restricted)]

macro_rules! m {
($p: path) => (pub($p) struct Z;)
($p: path) => (pub(in $p) struct Z;)
}

struct S<T>(T);
m!{ S<u8> } //~ ERROR type or lifetime parameters in visibility path
//~^ ERROR expected module, found struct `S`

mod foo {
struct S(pub(foo<T>) ()); //~ ERROR type or lifetime parameters in visibility path
//~^ ERROR cannot find type `T` in this scope
}

fn main() {}
10 changes: 5 additions & 5 deletions src/test/compile-fail/resolve-bad-visibility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
enum E {}
trait Tr {}

pub(E) struct S; //~ ERROR expected module, found enum `E`
pub(Tr) struct Z; //~ ERROR expected module, found trait `Tr`
pub(std::vec) struct F; //~ ERROR visibilities can only be restricted to ancestor modules
pub(nonexistent) struct G; //~ ERROR cannot find module `nonexistent` in the crate root
pub(too_soon) struct H; //~ ERROR cannot find module `too_soon` in the crate root
pub(in E) struct S; //~ ERROR expected module, found enum `E`
pub(in Tr) struct Z; //~ ERROR expected module, found trait `Tr`
pub(in std::vec) struct F; //~ ERROR visibilities can only be restricted to ancestor modules
pub(in nonexistent) struct G; //~ ERROR cannot find module `nonexistent` in the crate root
pub(in too_soon) struct H; //~ ERROR cannot find module `too_soon` in the crate root

// Visibilities are resolved eagerly without waiting for modules becoming fully populated.
// Visibilities can only use ancestor modules legally which are always available in time,
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/resolve/auxiliary/privacy-struct-ctor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub mod m {
pub struct S(u8);

pub mod n {
pub(m) struct Z(pub(m::n) u8);
pub(in m) struct Z(pub(in m::n) u8);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/resolve/privacy-struct-ctor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ mod m {
pub struct S(u8);

pub mod n {
pub(m) struct Z(pub(m::n) u8);
pub(in m) struct Z(pub(in m::n) u8);
}

use m::n::Z; // OK, only the type is imported
Expand Down