Skip to content

Rollup of 11 pull requests #66483

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 44 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
75ab3a8
Stabilize rustdoc theme options
GuillaumeGomez Oct 1, 2018
272799f
Add documentation for stabilized flags
GuillaumeGomez May 23, 2019
ca64df5
Warn instead of failing for themes
GuillaumeGomez May 23, 2019
10e6ca6
Apply review comments
GuillaumeGomez May 24, 2019
8df4ce2
add test for rustdoc's --themes flag
QuietMisdreavus May 24, 2019
2aa57e9
Prevent invalid html characters in themes name
GuillaumeGomez Jun 30, 2019
5b2862c
Add sentence to tell other options are ignored when running check-theme
GuillaumeGomez Jun 30, 2019
2f535a4
Rename theme-checker option to check-theme
GuillaumeGomez Jun 30, 2019
29494a8
Fix typos
GuillaumeGomez Jul 26, 2019
b65a369
Improve documentation, add checks for themes option arguments, make s…
GuillaumeGomez Aug 21, 2019
c45a553
rename check-theme option into check-themes
GuillaumeGomez Sep 14, 2019
747dcaf
remove unstable docs
GuillaumeGomez Sep 14, 2019
94b21eb
Rename rustdoc options --themes and --check-themes to --theme and --c…
GuillaumeGomez Sep 22, 2019
c614cad
Apply review comments
GuillaumeGomez Oct 10, 2019
82a7b32
remove -Z option from rustdoc theme checker tool
GuillaumeGomez Oct 12, 2019
1ebb9ec
improve error messages and documentation
GuillaumeGomez Oct 17, 2019
6fc18a9
Centralize panic macro documentation
czipperz Jun 4, 2019
91aadf0
find_deprecation: deprecation attr may be ill-formed meta.
Centril Nov 13, 2019
e85f40c
add missing 'static lifetime in docs
mulimoen Nov 16, 2019
52d7246
miri panic_unwind: fix hack for SEH platforms
RalfJung Nov 16, 2019
e8ff465
avoid linking errors
RalfJung Nov 16, 2019
bd63c59
Use "field is never read" instead of "field is never used"
Nov 16, 2019
8575743
rustc_plugin: Remove `Registry::register_attribute`
petrochenkov Nov 12, 2019
266f547
ast: Keep `extern` qualifiers in functions more precisely
petrochenkov Nov 9, 2019
00bc449
ast: Keep string literals in ABIs precisely
petrochenkov Nov 9, 2019
b85a3da
parse: Support parsing optional literals
petrochenkov Nov 10, 2019
a699f17
parse: Use string literal parsing in the `asm` macro
petrochenkov Nov 10, 2019
8c7530a
Improve documentation of `Vec::split_off(...)`
mqudsi Oct 23, 2019
a36c3f6
Revise the text of `vec::split_off()` per review in #65739
mqudsi Nov 16, 2019
3407c49
Clarify transmute_copy documentation example
ALSchwalm Nov 16, 2019
11580ce
Address review comments
petrochenkov Nov 16, 2019
28aec1b
Add some more tests
petrochenkov Nov 16, 2019
cfe94b4
Add test for issue 63116
Alexendoo Nov 16, 2019
8195038
Rollup merge of #54733 - GuillaumeGomez:stabilize-rustdoc-theme, r=Dy…
Centril Nov 17, 2019
f188904
Rollup merge of #65739 - mqudsi:vec_split_off_docs, r=dtolnay
Centril Nov 17, 2019
b25e706
Rollup merge of #66271 - petrochenkov:abism, r=Centril
Centril Nov 17, 2019
fd55f5c
Rollup merge of #66344 - petrochenkov:noregattr, r=matthewjasper
Centril Nov 17, 2019
d7b2b87
Rollup merge of #66381 - Centril:66340, r=petrochenkov
Centril Nov 17, 2019
5aa6e46
Rollup merge of #66395 - jplatte:centralize-panic-docs, r=Dylan-DPC
Centril Nov 17, 2019
6268e5b
Rollup merge of #66465 - mulimoen:fix_lifetime_elision_not_shown, r=r…
Centril Nov 17, 2019
99a4b98
Rollup merge of #66466 - RalfJung:seh, r=oli-obk
Centril Nov 17, 2019
c269580
Rollup merge of #66469 - CosineP:fix/field-lint, r=petrochenkov
Centril Nov 17, 2019
d14a893
Rollup merge of #66471 - Alexendoo:test-issue-63116, r=Centril
Centril Nov 17, 2019
9885dd3
Rollup merge of #66477 - ALSchwalm:clarify-transmute-copy, r=Centril
Centril Nov 17, 2019
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
parse: Support parsing optional literals
Revert weird renaming of the former `LitError::report`
  • Loading branch information
petrochenkov committed Nov 16, 2019
commit b85a3da421abad7d1936ec6e57e43c7b0ff10bd3
31 changes: 19 additions & 12 deletions src/librustc_parse/parser/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -778,13 +778,12 @@ impl<'a> Parser<'a> {

macro_rules! parse_lit {
() => {
match self.parse_lit() {
Ok(literal) => {
match self.parse_opt_lit() {
Some(literal) => {
hi = self.prev_span;
ex = ExprKind::Lit(literal);
}
Err(mut err) => {
err.cancel();
None => {
return Err(self.expected_expression_found());
}
}
Expand Down Expand Up @@ -1074,11 +1073,20 @@ impl<'a> Parser<'a> {
self.maybe_recover_from_bad_qpath(expr, true)
}

/// Matches `lit = true | false | token_lit`.
pub(super) fn parse_lit(&mut self) -> PResult<'a, Lit> {
self.parse_opt_lit().ok_or_else(|| {
let msg = format!("unexpected token: {}", self.this_token_descr());
self.span_fatal(self.token.span, &msg)
})
}

/// Matches `lit = true | false | token_lit`.
/// Returns `None` if the next token is not a literal.
pub(super) fn parse_opt_lit(&mut self) -> Option<Lit> {
let mut recovered = None;
if self.token == token::Dot {
// Attempt to recover `.4` as `0.4`.
// Attempt to recover `.4` as `0.4`. We don't currently have any syntax where
// dot would follow an optional literal, so we do this unconditionally.
recovered = self.look_ahead(1, |next_token| {
if let token::Literal(token::Lit { kind: token::Integer, symbol, suffix })
= next_token.kind {
Expand Down Expand Up @@ -1107,11 +1115,10 @@ impl<'a> Parser<'a> {
match Lit::from_token(token) {
Ok(lit) => {
self.bump();
Ok(lit)
Some(lit)
}
Err(LitError::NotLiteral) => {
let msg = format!("unexpected token: {}", self.this_token_descr());
Err(self.span_fatal(token.span, &msg))
None
}
Err(err) => {
let span = token.span;
Expand All @@ -1120,18 +1127,18 @@ impl<'a> Parser<'a> {
_ => unreachable!(),
};
self.bump();
self.error_literal_from_token(err, lit, span);
self.report_lit_error(err, lit, span);
// Pack possible quotes and prefixes from the original literal into
// the error literal's symbol so they can be pretty-printed faithfully.
let suffixless_lit = token::Lit::new(lit.kind, lit.symbol, None);
let symbol = Symbol::intern(&suffixless_lit.to_string());
let lit = token::Lit::new(token::Err, symbol, lit.suffix);
Lit::from_lit_token(lit, span).map_err(|_| unreachable!())
Some(Lit::from_lit_token(lit, span).unwrap_or_else(|_| unreachable!()))
}
}
}

fn error_literal_from_token(&self, err: LitError, lit: token::Lit, span: Span) {
fn report_lit_error(&self, err: LitError, lit: token::Lit, span: Span) {
// Checks if `s` looks like i32 or u1234 etc.
fn looks_like_width_suffix(first_chars: &[char], s: &str) -> bool {
s.len() > 1
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_parse/parser/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl<'a> Parser<'a> {
return Ok(Some(self.parse_item_extern_crate(lo, vis, attrs)?));
}

let abi = self.parse_opt_abi()?;
let abi = self.parse_opt_abi();

if self.eat_keyword(kw::Fn) {
// EXTERN FUNCTION ITEM
Expand Down
15 changes: 7 additions & 8 deletions src/librustc_parse/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1214,21 +1214,20 @@ impl<'a> Parser<'a> {
/// Parses `extern string_literal?`.
fn parse_extern(&mut self) -> PResult<'a, Extern> {
Ok(if self.eat_keyword(kw::Extern) {
Extern::from_abi(self.parse_opt_abi()?)
Extern::from_abi(self.parse_opt_abi())
} else {
Extern::None
})
}

/// Parses a string literal as an ABI spec.
fn parse_opt_abi(&mut self) -> PResult<'a, Option<StrLit>> {
if self.token.can_begin_literal_or_bool() {
let ast::Lit { token: token::Lit { symbol, suffix, .. }, span, kind }
= self.parse_lit()?;
fn parse_opt_abi(&mut self) -> Option<StrLit> {
if let Some(ast::Lit { token: token::Lit { symbol, suffix, .. }, span, kind })
= self.parse_opt_lit() {
match kind {
ast::LitKind::Str(symbol_unescaped, style) => return Ok(Some(StrLit {
ast::LitKind::Str(symbol_unescaped, style) => return Some(StrLit {
style, symbol, suffix, span, symbol_unescaped,
})),
}),
ast::LitKind::Err(_) => {}
_ => {
self.struct_span_err(span, "non-string ABI literal")
Expand All @@ -1242,7 +1241,7 @@ impl<'a> Parser<'a> {
}
}
}
Ok(None)
None
}

/// We are parsing `async fn`. If we are on Rust 2015, emit an error.
Expand Down