summary refs log tree commit diff
path: root/src/libsyntax
AgeCommit message (Collapse)AuthorLines
2015-05-11address fallout in libsyntaxtest.Felix S. Klock II-1/+5
2015-05-11Fallout from fixing Issue 25199.Felix S. Klock II-3/+4
There are two interesting kinds of breakage illustrated here: 1. `Box<Trait>` in many contexts is treated as `Box<Trait + 'static>`, due to [RFC 599]. However, in a type like `&'a Box<Trait>`, the `Box<Trait>` type will be expanded to `Box<Trait + 'a>`, again due to [RFC 599]. This, combined with the fix to Issue 25199, leads to a borrowck problem due the combination of this function signature (in src/libstd/net/parser.rs): ```rust fn read_or<T>(&mut self, parsers: &mut [Box<FnMut(&mut Parser) -> Option<T>>]) -> Option<T>; ``` with this call site (again in src/libstd/net/parser.rs): ```rust fn read_ip_addr(&mut self) -> Option<IpAddr> { let ipv4_addr = |p: &mut Parser| p.read_ipv4_addr().map(|v4| IpAddr::V4(v4)); let ipv6_addr = |p: &mut Parser| p.read_ipv6_addr().map(|v6| IpAddr::V6(v6)); self.read_or(&mut [Box::new(ipv4_addr), Box::new(ipv6_addr)]) } ``` yielding borrowck errors like: ``` parser.rs:265:27: 265:69 error: borrowed value does not live long enough parser.rs:265 self.read_or(&mut [Box::new(ipv4_addr), Box::new(ipv6_addr)]) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``` (full log at: https://gist.github.com/pnkfelix/e2e80f1a71580f5d3103 ) The issue here is perhaps subtle: the `parsers` argument is inferred to be taking a slice of boxed objects with the implicit lifetime bound attached to the `self` parameter to `read_or`. Meanwhile, the fix to Issue 25199 (added in a forth-coming commit) is forcing us to assume that each boxed object may have a destructor that could refer to state of that lifetime, and *therefore* that inferred lifetime is required to outlive the boxed object itself. In this case, the relevant boxed object here is not going to make any such references; I believe it is just an artifact of how the expression was built that it is not assigned type: `Box<FnMut(&mut Parser) -> Option<T> + 'static>`. (i.e., mucking with the expression is probably one way to fix this problem). But the other way to fix it, adopted here, is to change the `read_or` method type to force make the (presumably-intended) `'static` bound explicit on the boxed `FnMut` object. (Note: this is still just the *first* example of breakage.) 2. In `macro_rules.rs`, the `TTMacroExpander` trait defines a method with signature: ```rust fn expand<'cx>(&self, cx: &'cx mut ExtCtxt, ...) -> Box<MacResult+'cx>; ``` taking a `&'cx mut ExtCtxt` as an argument and returning a `Box<MacResult'cx>`. The fix to Issue 25199 (added in aforementioned forth-coming commit) assumes that a value of type `Box<MacResult+'cx>` may, in its destructor, refer to a reference of lifetime `'cx`; thus the `'cx` lifetime is forced to outlive the returned value. Meanwhile, within `expand.rs`, the old code was doing: ```rust match expander.expand(fld.cx, ...).make_pat() { ... => immutable borrow of fld.cx ... } ``` The problem is that the `'cx` lifetime, inferred for the `expander.expand` call, has now been extended so that it has to outlive the temporary R-value returned by `expanded.expand`. But call is also reborrowing `fld.cx` *mutably*, which means that this reborrow must end before any immutable borrow of `fld.cx`; but there is one of those within the match body. (Note that the temporary R-values for the input expression to `match` all live as long as the whole `match` expression itself (see Issue #3511 and PR #11585). To address this, I moved the construction of the pat value into its own `let`-statement, so that the `Box<MacResult>` will only live for as long as the initializing expression for the `let`-statement, and thus allow the subsequent immutable borrow within the `match`. [RFC 599]: https://github.com/rust-lang/rfcs/blob/master/text/0599-default-object-bound.md
2015-05-12Squeeze the last bits of `task`s in documentation in favor of `thread`Barosl Lee-9/+9
An automated script was run against the `.rs` and `.md` files, subsituting every occurrence of `task` with `thread`. In the `.rs` files, only the texts in the comment blocks were affected.
2015-04-30Fix #20616York Xiang-2/+41
Conflicts: src/libsyntax/parse/parser.rs
2015-04-23std: Remove deprecated/unstable num functionalityAlex Crichton-13/+20
This commit removes all the old casting/generic traits from `std::num` that are no longer in use by the standard library. This additionally removes the old `strconv` module which has not seen much use in quite a long time. All generic functionality has been supplanted with traits in the `num` crate and the `strconv` module is supplanted with the [rust-strconv crate][rust-strconv]. [rust-strconv]: https://github.com/lifthrasiir/rust-strconv This is a breaking change due to the removal of these deprecated crates, and the alternative crates are listed above. [breaking-change] Conflicts: src/libstd/num/strconv.rs
2015-04-16Auto merge of #24423 - tbelaire:include_bytes, r=alexcrichtonbors-0/+5
This is a little bit tricky, since with include_str!, we know that we are including utf-8 content, so it's safe to store the source as a String in a FileMap. We don't know that for include_bytes!, but I don't think we actually need to track the contents anyways, so I'm passing "". new_filemap does check for the zero length content, and it should be reasonable, howeven I'm not sure if it would be better to pass None instead of Some(Rc::new("")) as the src component of a FileMap. Fixes bug #24348
2015-04-16Auto merge of #23682 - tamird:DRY-is-empty, r=alexcrichtonbors-44/+44
r? @alexcrichton
2015-04-16Auto merge of #24485 - brson:is, r=alexcrichtonbors-2/+0
It was an oversight that this was not done in the great int upheaval. [breaking-change]
2015-04-15Forbid is/us suffixes. Fixes #22496Brian Anderson-2/+0
It was an oversight that this was not done in the great int upheaval. [breaking-change]
2015-04-15Rollup merge of #24438 - nrc:tuple-span, r=sfacklerSteve Klabnik-1/+1
2015-04-15Auto merge of #24436 - fhahn:fix-small-typo, r=steveklabnikbors-1/+1
2015-04-14Negative case of `len()` -> `is_empty()`Tamir Duberstein-30/+30
`s/([^\(\s]+\.)len\(\) [(?:!=)>] 0/!$1is_empty()/g`
2015-04-14Positive case of `len()` -> `is_empty()`Tamir Duberstein-14/+14
`s/(?<!\{ self)(?<=\.)len\(\) == 0/is_empty()/g`
2015-04-15Fix the span for tuple expressionsNick Cameron-1/+1
2015-04-14Remove superfluous `the` from `custom_attribute` feature gate messageFlorian Hahn-1/+1
2015-04-14Test fixes and rebase conflictsAlex Crichton-1/+1
2015-04-14rollup merge of #24391: nrc/visit-visAlex Crichton-23/+30
2015-04-14rollup merge of #24381: erickt/cleanupAlex Crichton-1/+5
Just some minor patches I've been sitting on.
2015-04-14include_bytes! now registers the file includedTheo Belaire-0/+5
This is a little bit tricky, since with include_str!, we know that we are including utf-8 content, so it's safe to store the source as a String in a FileMap. We don't know that for include_bytes!, but I don't think we actually need to track the contents anyways, so I'm passing "". new_filemap does check for the zero length content, and it should be reasonable, howeven I'm not sure if it would be better to pass None instead of Some(Rc::new("")) as the src component of a FileMap. Fixes bug #24348
2015-04-14syntax: Remove derive(Rand)Alex Crichton-178/+0
2015-04-14std: Remove old_io/old_path/rand modulesAlex Crichton-17/+0
This commit entirely removes the old I/O, path, and rand modules. All functionality has been deprecated and unstable for quite some time now!
2015-04-14Auto merge of #24312 - rprichard:destabilize-format-args, r=alexcrichtonbors-19/+25
Fixes #22953.
2015-04-14Auto merge of #24295 - contradictioned:master, r=alexcrichtonbors-1/+7
As i proposed in #24262 (and found acceptance in the IRC channel), added a compiler warning for wrong escaping of curly braces.
2015-04-14Expose visibility for fns in syntax::visitNick Cameron-23/+30
2015-04-13syntax: Publically expose printing where clauses, and add attr_to_stringErick Tryzelaar-1/+5
2015-04-13Added a help span which informs the user about the escaping of curly braces ↵Manuel Hoffmann-1/+7
in a format string if a wrongly escaped one is detected in a string.
2015-04-13Auto merge of #24323 - rprichard:panic-line-type, r=alexcrichtonbors-1/+1
There are syntax extensions that call `std::rt::begin_unwind` passing it a `usize`. I updated the syntax extension to instead pass `u32`, but for bootstrapping reasons, I needed to create a `#[cfg(stage0)]` version of `std::rt::begin_unwind` and therefore also `panic!`.
2015-04-12Use the ecx.call_site() span for generating refs to format_args! internalsRyan Prichard-19/+25
`format_args!` uses `#[allow_internal_unstable]` to access internal functions and structs that are marked unstable. For this to work, the spans on AST nodes referencing unstable internals must be equal (same lo/hi values) to the `format_args!` call site, so that the stability checker can recognize that the AST node was generated by the macro.
2015-04-12Auto merge of #24248 - nrc:macro-span, r=sfacklerbors-9/+11
2015-04-12Auto merge of #24003 - rprichard:span-fixes, r=huonwbors-23/+16
* In `noop_fold_expr`, call `new_span` in these cases: - `ExprMethodCall`'s identifier - `ExprField`'s identifier - `ExprTupField`'s integer Calling `new_span` for `ExprMethodCall`'s identifier is necessary to print an acceptable diagnostic for `write!(&2, "")`. We see this error: ``` <std macros>:2:20: 2:66 error: type `&mut _` does not implement any method in scope named `write_fmt` <std macros>:2 ( & mut * $ dst ) . write_fmt ( format_args ! ( $ ( $ arg ) * ) ) ) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``` With this change, we also see a macro expansion backtrace leading to the `write!(&2, "")` call site. * After fully expanding a macro, we replace the expansion expression's span with the original span. Call `fld.new_span` to add a backtrace to this span. (Note that I'm call `new_span` after `bt.pop()`, so the macro just expanded isn't on the backtrace.) The motivating example for this change is `println!("{}")`. The format string literal is `concat!($fmt, "arg")` and is inside the libstd macro. We need to see the backtrace to find the `println!` call site. * Add a backtrace to the `format_args!` format expression span. r? alexcrichton Addresses #23459
2015-04-12Fix spans for macrosNick Cameron-9/+11
2015-04-12Auto merge of #23011 - nagisa:the-war-of-symbol-and-symbol, r=pnkfelixbors-0/+17
We provide tools to tell what exact symbols to emit for any fn or static, but don’t quite check if that won’t cause any issues later on. Some of the issues include LLVM mangling our names again and our names pointing to wrong locations, us generating dumb foreign call wrappers, linker errors, extern functions resolving to different symbols altogether (`extern {fn fail();} fail();` in some cases calling `fail1()`), etc. Before the commit we had a function called `note_unique_llvm_symbol`, so it is clear somebody was aware of the issue at some point, but the function was barely used, mostly in irrelevant locations. Along with working on it I took liberty to start refactoring trans/base into a few smaller modules. The refactoring is incomplete and I hope I will find some motivation to carry on with it. This is possibly a [breaking-change] because it makes dumbly written code properly invalid. This fixes all those issues about incorrect use of #[no_mangle] being not reported/misreported/ICEd by the compiler. NB. This PR does not attempt to tackle the parallel codegen issue that was mentioned in https://github.com/rust-lang/rust/pull/22811, but I believe it should be very straightforward in a follow up PR by modifying `trans::declare::get_defined_value` to look at all the contexts. cc @alexcrichton @huonw @nrc because you commented on the original RFC issue. EDIT: wow, this became much bigger than I initially intended.
2015-04-11Remove the vestigial ExtCtxt::print_backtrace function.Ryan Prichard-12/+0
It was added in 2011-08-05 and reduced to a no-op ten days later.
2015-04-11Suppress the macro backtrace for `fileline_note` and `fileline_help`.Ryan Prichard-5/+4
2015-04-11Propagate macro backtraces more often, improve formatting diagnosticsRyan Prichard-6/+12
* In noop_fold_expr, call new_span in these cases: - ExprMethodCall's identifier - ExprField's identifier - ExprTupField's integer Calling new_span for ExprMethodCall's identifier is necessary to print an acceptable diagnostic for write!(&2, ""). We see this error: <std macros>:2:20: 2:66 error: type `&mut _` does not implement any method in scope named `write_fmt` <std macros>:2 ( & mut * $ dst ) . write_fmt ( format_args ! ( $ ( $ arg ) * ) ) ) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ With this change, we also see a macro expansion backtrace leading to the write!(&2, "") call site. * After fully expanding a macro, we replace the expansion expression's span with the original span. Call fld.new_span to add a backtrace to this span. (Note that I'm call new_span after bt.pop(), so the macro just expanded isn't on the backtrace.) The motivating example for this change is println!("{}"). The format string literal is concat!($fmt, "arg") and is inside the libstd macro. We need to see the backtrace to find the println! call site. * Add a backtrace to the format_args! format expression span. Addresses #23459
2015-04-11Rollup merge of #24242 - nikomatsakis:escaping-closure-error-message, r=brsonManish Goregaokar-71/+235
Example showing sample inputs, old message, new message: https://gist.github.com/nikomatsakis/11126784ac678b7eb6ba Also adds infrastructure for reporting suggestions \"in situ\" and does some (minor) cleanups to `CodeMap`. r? @brson
2015-04-11Change the rt::unwind line argument type from usize to u32.Ryan Prichard-1/+1
2015-04-11Auto merge of #24155 - chris-chambers:stmt_macros, r=sfacklerbors-45/+87
Statement macros are now treated somewhat like item macros, in that a statement macro can now expand into a series of statements, rather than just a single statement. This allows statement macros to be nested inside other kinds of macros and expand properly, where previously the expansion would only work when no nesting was present. See: - `src/test/run-pass/macro-stmt_macro_in_expr_macro.rs` - `src/test/run-pass/macro-nested_stmt_macro.rs` This changes the interface of the MacResult trait. make_stmt has become make_stmts and now returns a vector, rather than a single item. Plugin writers who were implementing MacResult will have breakage, as well as anyone using MacEager::stmt. See: - `src/libsyntax/ext/base.rs` This also causes a minor difference in behavior to the diagnostics produced by certain malformed macros. See: - `src/test/compile-fail/macro-incomplete-parse.rs`
2015-04-11Moves expand_stmt's bt_pop so that it balances correctly.Christopher Chambers-3/+4
2015-04-10Simplifications to statement macro handling.Christopher Chambers-37/+12
SmallVector::pop no longer worries about converting a Many repr downward to One or Zero. expand_stmt makes use of `if let` for style purposes.
2015-04-10Eliminates a pointless is_empty test.Christopher Chambers-1/+1
2015-04-10Improves semicolon expansion efficiency, corrects bt_pop placement.Christopher Chambers-16/+51
Implements pop() on SmallVector, and uses it to expand the final semicolon in a statement macro expansion more efficiently. Corrects the placement of the call to fld.cx.bt_pop(). It must run unconditionally to reverse the corresponding push.
2015-04-10fix some comments.Felix S. Klock II-6/+7
2015-04-10Incorporate repr-attr into deriving(PartialOrd) to avoid truncation errors.Felix S. Klock II-13/+38
remove out of date fixme.
2015-04-10Re-add a fixme after some investigation into what's going on.Felix S. Klock II-0/+11
2015-04-10Change `derive` expansions to use `discriminant_value` intrinsic.Felix S. Klock II-30/+27
Fix #15523.
2015-04-10Add a new `span_suggestion` infrastructure. This lets you edit a snippetNiko Matsakis-1/+65
of text (perhaps obtained by span_snippet) and then splice that edited form back into the original file in the form of a suggestion.
2015-04-10Modify the codemap code to use more slices and to information aboutNiko Matsakis-40/+133
columns within a line, not just the line numbers. Also try to clarify and use the term `line_index` when 0-based.
2015-04-10Replace the use of the rather randomly named boolean `custom` to meanNiko Matsakis-30/+37
"highlight end" and instead add a variant to `RenderSpan`
2015-04-10Rollup merge of #24225 - nrc:for-span, r=pnkfelixManish Goregaokar-1/+1