about summary refs log tree commit diff
path: root/src/libsyntax
AgeCommit message (Collapse)AuthorLines
2015-12-18Auto merge of #29973 - petrochenkov:privinpub, r=nikomatsakisbors-4/+1
Some notes: This patch enforces the rules from [RFC 136](https://github.com/rust-lang/rfcs/blob/master/text/0136-no-privates-in-public.md) and makes "private in public" a module-level concept and not crate-level. Only `pub` annotations are used by the new algorithm, crate-level exported node set produced by `EmbargoVisitor` is not used. The error messages are tweaked accordingly and don't use the word "exported" to avoid confusing people (https://github.com/rust-lang/rust/issues/29668). The old algorithm tried to be extra smart with impls, but it mostly led to unpredictable behavior and bugs like https://github.com/rust-lang/rust/issues/28325. The new algorithm tries to be as simple as possible - an impl is considered public iff its type is public and its trait is public (if presents). A type or trait is considered public if all its components are public, [complications](https://internals.rust-lang.org/t/limits-of-type-inference-smartness/2919) with private types leaking to other crates/modules through trait impls and type inference are deliberately ignored so far. The new algorithm is not recursive and uses the nice new facility `Crate::visit_all_items`! Obsolete pre-1.0 feature `visible_private_types` is removed. This is a [breaking-change]. The two main vectors of breakage are type aliases (https://github.com/rust-lang/rust/issues/28450) and impls (https://github.com/rust-lang/rust/issues/28325). I need some statistics from a crater run (cc @alexcrichton) to decide on the breakage mitigation strategy. UPDATE: All the new errors are reported as warnings controlled by a lint `private_in_public` and lint group `future_incompatible`, but the intent is to make them hard errors eventually. Closes https://github.com/rust-lang/rust/issues/28325 Closes https://github.com/rust-lang/rust/issues/28450 Closes https://github.com/rust-lang/rust/issues/29524 Closes https://github.com/rust-lang/rust/issues/29627 Closes https://github.com/rust-lang/rust/issues/29668 Closes https://github.com/rust-lang/rust/issues/30055 r? @nikomatsakis
2015-12-18Rollup merge of #30420 - petrochenkov:owned2, r=nrcManish Goregaokar-177/+144
Part of https://github.com/rust-lang/rust/pull/30095 not causing mysterious segfaults. r? @nrc
2015-12-18Rollup merge of #30384 - nrc:diagnostics, r=@nikomatsakisManish Goregaokar-560/+703
Should make it possible to add JSON or HTML errors. Also tidies up a lot.
2015-12-18Rewrite VisiblePrivateTypesVisitorVadim Petrochenkov-4/+1
2015-12-18Deprecate name `OwnedSlice` and don't use itVadim Petrochenkov-62/+54
2015-12-18libsyntax: Merge OwnedSlice into ptr::PVadim Petrochenkov-115/+90
2015-12-17Remove unused importsJeffrey Seyfried-10/+10
2015-12-17test errorsNick Cameron-86/+111
2015-12-17A little more refactoring inside emitter.rsNick Cameron-45/+35
2015-12-17Add the files I fogot about earlierNick Cameron-0/+1027
d'oh
2015-12-17Move a bunch of stuff from Session to syntax::errorsNick Cameron-1/+1
The intention here is that Session is a very thin wrapper over the error handling infra.
2015-12-17move error handling from libsyntax/diagnostics.rs to libsyntax/errors/*Nick Cameron-987/+88
Also split out emitters into their own module.
2015-12-16Rollup merge of #30388 - DanielJCampbell:macro-ident-spans, r=nrcManish Goregaokar-8/+12
r? @nrc
2015-12-16Auto merge of #30300 - sanxiyn:syntax-ext, r=nikomatsakisbors-5257/+20
This reduces iteration time (`make rustc-stage1`) for moved syntax extensions from 11 minutes to 3 minutes on my machine. Because of the signature change, this is a [breaking-change] for people directly calling `expand_crate`. I think it is rare: from GitHub search, only case I found is [glassful](https://github.com/kmcallister/glassful).
2015-12-16Auto merge of #30206 - petrochenkov:newdepr, r=brsonbors-10/+88
Closes https://github.com/rust-lang/rust/issues/29935 The attributes `deprecated` and `rustc_deprecated` are completely independent in this implementation and it leads to some noticeable code duplication. Representing `deprecated` as ``` Stability { level: Stable { since: "" }, feature: "", depr: Some(Deprecation), } ``` or, contrariwise, splitting rustc_deprecation from stability makes most of the duplication go away. I can do this refactoring, but before doing it I must be sure, that further divergence of `deprecated` and `rustc_deprecated` is certainly not a goal. cc @llogiq
2015-12-15Fix expansion testsSeo Sanghyeon-4/+13
2015-12-15Move built-in syntax extensions to a separate crateSeo Sanghyeon-5253/+7
2015-12-15Generated code spans now point to callsite parameters (where applicable)Daniel Campbell-8/+12
2015-12-14[breaking-change] move ast_util functions to methodsfaineance-178/+178
2015-12-14Auto merge of #29735 - Amanieu:asm_indirect_constraint, r=pnkfelixbors-13/+32
This PR reverts #29543 and instead implements proper support for "=*m" and "+*m" indirect output operands. This provides a framework on top of which support for plain memory operands ("m", "=m" and "+m") can be implemented. This also fixes the liveness analysis pass not handling read/write operands correctly.
2015-12-13remove deprecated APIs missed in #30182Tamir Duberstein-14/+0
2015-12-12Address the review commentsVadim Petrochenkov-1/+1
2015-12-12Implement `#[deprecated]` attribute (RFC 1270)Vadim Petrochenkov-10/+88
2015-12-08Auto merge of #29995 - DanielJCampbell:Expanded-Span-Printing, r=nrcbors-0/+204
r? @nrc
2015-12-08Added pretty-printing for span expansion chains through span_to_expanded_string.Daniel Campbell-0/+204
2015-12-05std: Stabilize APIs for the 1.6 releaseAlex Crichton-13/+8
This commit is the standard API stabilization commit for the 1.6 release cycle. The list of issues and APIs below have all been through their cycle-long FCP and the libs team decisions are listed below Stabilized APIs * `Read::read_exact` * `ErrorKind::UnexpectedEof` (renamed from `UnexpectedEOF`) * libcore -- this was a bit of a nuanced stabilization, the crate itself is now marked as `#[stable]` and the methods appearing via traits for primitives like `char` and `str` are now also marked as stable. Note that the extension traits themeselves are marked as unstable as they're imported via the prelude. The `try!` macro was also moved from the standard library into libcore to have the same interface. Otherwise the functions all have copied stability from the standard library now. * The `#![no_std]` attribute * `fs::DirBuilder` * `fs::DirBuilder::new` * `fs::DirBuilder::recursive` * `fs::DirBuilder::create` * `os::unix::fs::DirBuilderExt` * `os::unix::fs::DirBuilderExt::mode` * `vec::Drain` * `vec::Vec::drain` * `string::Drain` * `string::String::drain` * `vec_deque::Drain` * `vec_deque::VecDeque::drain` * `collections::hash_map::Drain` * `collections::hash_map::HashMap::drain` * `collections::hash_set::Drain` * `collections::hash_set::HashSet::drain` * `collections::binary_heap::Drain` * `collections::binary_heap::BinaryHeap::drain` * `Vec::extend_from_slice` (renamed from `push_all`) * `Mutex::get_mut` * `Mutex::into_inner` * `RwLock::get_mut` * `RwLock::into_inner` * `Iterator::min_by_key` (renamed from `min_by`) * `Iterator::max_by_key` (renamed from `max_by`) Deprecated APIs * `ErrorKind::UnexpectedEOF` (renamed to `UnexpectedEof`) * `OsString::from_bytes` * `OsStr::to_cstring` * `OsStr::to_bytes` * `fs::walk_dir` and `fs::WalkDir` * `path::Components::peek` * `slice::bytes::MutableByteVector` * `slice::bytes::copy_memory` * `Vec::push_all` (renamed to `extend_from_slice`) * `Duration::span` * `IpAddr` * `SocketAddr::ip` * `Read::tee` * `io::Tee` * `Write::broadcast` * `io::Broadcast` * `Iterator::min_by` (renamed to `min_by_key`) * `Iterator::max_by` (renamed to `max_by_key`) * `net::lookup_addr` New APIs (still unstable) * `<[T]>::sort_by_key` (added to mirror `min_by_key`) Closes #27585 Closes #27704 Closes #27707 Closes #27710 Closes #27711 Closes #27727 Closes #27740 Closes #27744 Closes #27799 Closes #27801 cc #27801 (doesn't close as `Chars` is still unstable) Closes #28968
2015-12-05Use a struct instead of a tuple for inline asm output operandsAmanieu d'Antras-11/+29
2015-12-05Add proper support for indirect output constraints in inline asmAmanieu d'Antras-8/+9
2015-12-04Auto merge of #29850 - Kimundi:attributes_that_make_a_statement, r=pnkfelixbors-421/+1234
See https://github.com/rust-lang/rfcs/pull/16 and https://github.com/rust-lang/rust/issues/15701 - Added syntax support for attributes on expressions and all syntax nodes in statement position. - Extended `#[cfg]` folder to allow removal of statements, and of expressions in optional positions like expression lists and trailing block expressions. - Extended lint checker to recognize lint levels on expressions and locals. - As per RFC, attributes are not yet accepted on `if` expressions. Examples: ```rust let x = y; { ... } assert_eq!((1, #[cfg(unset)] 2, 3), (1, 3)); let FOO = 0; ``` Implementation wise, there are a few rough corners and open questions: - The parser work ended up a bit ugly. - The pretty printer change was based mostly on guessing. - Similar to the `if` case, there are some places in the grammar where a new `Expr` node starts, but where it seemed weird to accept attributes and hence the parser doesn't. This includes: - const expressions in patterns - in the middle of an postfix operator chain (that is, after `.`, before indexing, before calls) - on range expressions, since `#[attr] x .. y` parses as `(#[attr] x) .. y`, which is inconsistent with `#[attr] .. y` which would parse as `#[attr] (.. y)` - Attributes are added as additional `Option<Box<Vec<Attribute>>>` fields in expressions and locals. - Memory impact has not been measured yet. - A cfg-away trailing expression in a block does not currently promote the previous `StmtExpr` in a block to a new trailing expr. That is to say, this won't work: ```rust let x = { #[cfg(foo)] Foo { data: x } #[cfg(not(foo))] Foo { data: y } }; ``` - One-element tuples can have their inner expression removed to become Unit, but just Parenthesis can't. Eg, `(#[cfg(unset)] x,) == ()` but `(#[cfg(unset)] x) == error`. This seemed reasonable to me since tuples and unit are type constructors, but could probably be argued either way. - Attributes on macro nodes are currently unconditionally dropped during macro expansion, which seemed fine since macro disappear at that point? - Attributes on `ast::ExprParens` will be prepend-ed to the inner expression in the hir folder. - The work on pretty printer tests for this did trigger, but not fix errors regarding macros: - expression `foo![]` prints as `foo!()` - expression `foo!{}` prints as `foo!()` - statement `foo![];` prints as `foo!();` - statement `foo!{};` prints as `foo!();` - statement `foo!{}` triggers a `None` unwrap ICE.
2015-12-03libterm: bring across changes from termBryce Van Dyk-8/+8
This brings across changes made to the term library to libterm. This includes removing instances or unwrap, fixing format string handling, and removing a TODO. This fix does not bring all changes across, as term now relies on cargo deps that cannot be brought into the rust build at this stage, but has attempted as best to cross port changes not relying on this. This notably limits extra functionality since implemented int he Terminal trait in Term. This is in partly in response to rust issue #29992.
2015-12-01Auto merge of #25570 - oli-obk:const_indexing, r=nikomatsakisbors-0/+6
This PR allows the constant evaluation of index operations on constant arrays and repeat expressions. This allows index expressions to appear in the expression path of the length expression of a repeat expression or an array type. An example is ```rust const ARR: [usize; 5] = [1, 2, 3, 4, 5]; const ARR2: [usize; ARR[1]] = [42, 99]; ``` In most other locations llvm's const evaluator figures it out already. This is not specific to index expressions and could be remedied in the future.
2015-11-30Improved comments around dropped attributes in the macro expanderMarvin Löbel-2/+2
2015-11-30Simplyfied map_thin_attrs()Marvin Löbel-19/+3
2015-11-29Auto merge of #30075 - kyeah:mac-span, r=sanxiynbors-5/+9
Fixes #28424 (item macros), #30067 (impl item macros), and pattern macros.
2015-11-28Use last_span for macro spansKevin Yeh-3/+4
2015-11-27Auto merge of #30064 - fhartwig:macro-suggestions, r=sanxiynbors-0/+88
Fixes #13677 This does the same sort of suggestion for misspelt macros that we already do for misspelt identifiers. Example. Compiling this program: ```rust macro_rules! foo { ($e:expr) => ( $e ) } fn main() { fob!("hello!"); } ``` gives the following error message: ``` /Users/mcp/temp/test.rs:7:5: 7:8 error: macro undefined: 'fob!' /Users/mcp/temp/test.rs:7 fob!("hello!"); ^~~ /Users/mcp/temp/test.rs:7:5: 7:8 help: did you mean `foo`? /Users/mcp/temp/test.rs:7 fob!("hello!"); ``` I had to move the levenshtein distance function into libsyntax for this. Maybe this should live somewhere else (some utility crate?), but I couldn't find a crate to put it in that is imported by libsyntax and the other rustc crates.
2015-11-27Introduce max_suggestion_distance function to avoid duplicating the heuristicFlorian Hartwig-4/+10
2015-11-26Added stmt_expr_attribute feature gateMarvin Löbel-63/+291
2015-11-26Some TLC for the MoveMap traitMarvin Löbel-56/+120
2015-11-26Fixed macro expander not folding attributes (though I'm not sure if that is ↵Marvin Löbel-16/+18
actually neccessary)
2015-11-26Moved and refactored ThinAttributesMarvin Löbel-130/+132
2015-11-26Add syntax support for attributes on expressions and all syntaxMarvin Löbel-312/+845
nodes in statement position. Extended #[cfg] folder to allow removal of statements, and of expressions in optional positions like expression lists and trailing block expressions. Extended lint checker to recognize lint levels on expressions and locals.
2015-11-26Fix spans for macrosKevin Yeh-3/+6
2015-11-26Add '!' to macro name suggestion, use fileline_help instead of span_helpFlorian Hartwig-1/+1
2015-11-26Auto merge of #30015 - petrochenkov:staged, r=brsonbors-3/+4
Closes https://github.com/rust-lang/rust/issues/30008 `#[stable]`, `#[unstable]` and `#[rustc_deprecated]` are now guarded by `#[feature(staged_api)]` r? @brson
2015-11-26Add suggestion of similar macro names to `macro undefined` error messageFlorian Hartwig-0/+82
2015-11-25Fix "Cannot fill in a NT" ICEJonas Schievink-12/+23
2015-11-25Remove all uses of `#[staged_api]`Vadim Petrochenkov-1/+1
2015-11-25Remove `#[staged_api]`Vadim Petrochenkov-2/+3
2015-11-25Auto merge of #30011 - jonas-schievink:macro-context, r=nrcbors-10/+10
Fixes #22425 Also fixes #30007, since it's just a change from `true` to `false`.