diff options
| author | bors <bors@rust-lang.org> | 2018-12-06 12:41:30 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-12-06 12:41:30 +0000 |
| commit | 367e783e6f66a4dba32decdc68a262953d2f3f1b (patch) | |
| tree | cda4764d303feb6c62218550fb619c73a2eebdc8 /src/libsyntax | |
| parent | 128a1fa4e1f85e04f522653bb9bee83ed6523440 (diff) | |
| parent | cd1ee5edbd080659f1ff353dd828bdf9749cf11d (diff) | |
| download | rust-367e783e6f66a4dba32decdc68a262953d2f3f1b.tar.gz rust-367e783e6f66a4dba32decdc68a262953d2f3f1b.zip | |
Auto merge of #56557 - pietroalbini:rollup, r=pietroalbini
Rollup of 11 pull requests Successful merges: - #56315 (Rustdoc inline macro reexport) - #56332 ([rustdoc] Specific crate search) - #56362 (Stabilise exhaustive integer patterns) - #56426 (libsyntax_pos: A few tweaks) - #56441 (rustbuild: Fix issues with compiler docs) - #56446 (pass the parameter environment to `traits::find_associated_item`) - #56500 (cleanup: remove static lifetimes from consts) - #56525 (Avoid extra copy and syscall in std::env::current_exe) - #56528 (Remove unused dependency (rustc_lint -> rustc_mir)) - #56548 (Optimized string FromIterator + Extend impls) - #56553 (Don't print the profiling summary to stdout when -Zprofile-json is set) Failed merges: r? @ghost
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast.rs | 23 | ||||
| -rw-r--r-- | src/libsyntax/ext/build.rs | 18 | ||||
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/tt/quoted.rs | 1 | ||||
| -rw-r--r-- | src/libsyntax/feature_gate.rs | 41 | ||||
| -rw-r--r-- | src/libsyntax/parse/attr.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/parse/lexer/unicode_chars.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 10 | ||||
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/std_inject.rs | 2 |
10 files changed, 47 insertions, 60 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 227017a9073..87225711871 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -73,7 +73,7 @@ impl fmt::Debug for Lifetime { pub struct Path { pub span: Span, /// The segments in the path: the things separated by `::`. - /// Global paths begin with `keywords::CrateRoot`. + /// Global paths begin with `keywords::PathRoot`. pub segments: Vec<PathSegment>, } @@ -105,19 +105,8 @@ impl Path { } } - // Make a "crate root" segment for this path unless it already has it - // or starts with something like `self`/`super`/`$crate`/etc. - pub fn make_root(&self) -> Option<PathSegment> { - if let Some(ident) = self.segments.get(0).map(|seg| seg.ident) { - if ident.is_path_segment_keyword() { - return None; - } - } - Some(PathSegment::crate_root(self.span.shrink_to_lo())) - } - pub fn is_global(&self) -> bool { - !self.segments.is_empty() && self.segments[0].ident.name == keywords::CrateRoot.name() + !self.segments.is_empty() && self.segments[0].ident.name == keywords::PathRoot.name() } } @@ -144,8 +133,8 @@ impl PathSegment { pub fn from_ident(ident: Ident) -> Self { PathSegment { ident, id: DUMMY_NODE_ID, args: None } } - pub fn crate_root(span: Span) -> Self { - PathSegment::from_ident(Ident::new(keywords::CrateRoot.name(), span)) + pub fn path_root(span: Span) -> Self { + PathSegment::from_ident(Ident::new(keywords::PathRoot.name(), span)) } } @@ -1688,7 +1677,7 @@ pub type ExplicitSelf = Spanned<SelfKind>; impl Arg { pub fn to_self(&self) -> Option<ExplicitSelf> { if let PatKind::Ident(BindingMode::ByValue(mutbl), ident, _) = self.pat.node { - if ident.name == keywords::SelfValue.name() { + if ident.name == keywords::SelfLower.name() { return match self.ty.node { TyKind::ImplicitSelf => Some(respan(self.pat.span, SelfKind::Value(mutbl))), TyKind::Rptr(lt, MutTy { ref ty, mutbl }) if ty.node.is_implicit_self() => { @@ -1706,7 +1695,7 @@ impl Arg { pub fn is_self(&self) -> bool { if let PatKind::Ident(_, ident, _) = self.pat.node { - ident.name == keywords::SelfValue.name() + ident.name == keywords::SelfLower.name() } else { false } diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index cacec867cf1..5770f6bb8a2 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -318,9 +318,13 @@ impl<'a> AstBuilder for ExtCtxt<'a> { args: Vec<ast::GenericArg>, bindings: Vec<ast::TypeBinding> ) -> ast::Path { + assert!(!idents.is_empty()); + let add_root = global && !idents[0].is_path_segment_keyword(); + let mut segments = Vec::with_capacity(idents.len() + add_root as usize); + if add_root { + segments.push(ast::PathSegment::path_root(span)); + } let last_ident = idents.pop().unwrap(); - let mut segments: Vec<ast::PathSegment> = vec![]; - segments.extend(idents.into_iter().map(|ident| { ast::PathSegment::from_ident(ident.with_span_pos(span)) })); @@ -334,13 +338,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { id: ast::DUMMY_NODE_ID, args, }); - let mut path = ast::Path { span, segments }; - if global { - if let Some(seg) = path.make_root() { - path.segments.insert(0, seg); - } - } - path + ast::Path { span, segments } } /// Constructs a qualified path. @@ -625,7 +623,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { self.expr_path(self.path_ident(span, id)) } fn expr_self(&self, span: Span) -> P<ast::Expr> { - self.expr_ident(span, keywords::SelfValue.ident()) + self.expr_ident(span, keywords::SelfLower.ident()) } fn expr_binary(&self, sp: Span, op: ast::BinOpKind, diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 68a96293891..67f3dc1bb52 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -204,7 +204,7 @@ fn macro_bang_format(path: &ast::Path) -> ExpnFormat { path_str.push_str("::"); } - if segment.ident.name != keywords::CrateRoot.name() && + if segment.ident.name != keywords::PathRoot.name() && segment.ident.name != keywords::DollarCrate.name() { path_str.push_str(&segment.ident.as_str()) diff --git a/src/libsyntax/ext/tt/quoted.rs b/src/libsyntax/ext/tt/quoted.rs index edc431be369..a7415e845ca 100644 --- a/src/libsyntax/ext/tt/quoted.rs +++ b/src/libsyntax/ext/tt/quoted.rs @@ -444,7 +444,6 @@ where macro_node_id, ), Edition::Edition2018 => parse_sep_and_kleene_op_2018(input, span, sess, features, attrs), - _ => unimplemented!(), } } diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index bfdc75378d5..5e0176df311 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -53,8 +53,7 @@ macro_rules! declare_features { /// Represents active features that are currently being implemented or /// currently being considered for addition/removal. const ACTIVE_FEATURES: - &'static [(&'static str, &'static str, Option<u32>, - Option<Edition>, fn(&mut Features, Span))] = + &[(&str, &str, Option<u32>, Option<Edition>, fn(&mut Features, Span))] = &[$((stringify!($feature), $ver, $issue, $edition, set!($feature))),+]; /// A set of features to be used by later passes. @@ -439,8 +438,8 @@ declare_features! ( // 'a: { break 'a; } (active, label_break_value, "1.28.0", Some(48594), None), - // Integer match exhaustiveness checking - (active, exhaustive_integer_patterns, "1.30.0", Some(50907), None), + // Exhaustive pattern matching on `usize` and `isize`. + (active, precise_pointer_size_matching, "1.32.0", Some(56354), None), // #[doc(keyword = "...")] (active, doc_keyword, "1.28.0", Some(51315), None), @@ -686,6 +685,8 @@ declare_features! ( (accepted, extern_crate_item_prelude, "1.31.0", Some(55599), None), // Allows use of the :literal macro fragment specifier (RFC 1576) (accepted, macro_literal_matcher, "1.31.0", Some(35625), None), + // Integer match exhaustiveness checking (RFC 2591) + (accepted, exhaustive_integer_patterns, "1.32.0", Some(50907), None), // Use `?` as the Kleene "at most one" operator (accepted, macro_at_most_once_rep, "1.32.0", Some(48075), None), // `Self` struct constructor (RFC 2302) @@ -772,7 +773,7 @@ pub fn is_builtin_attr(attr: &ast::Attribute) -> bool { } // Attributes that have a special meaning to rustc or rustdoc -pub const BUILTIN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeGate)] = &[ +pub const BUILTIN_ATTRIBUTES: &[(&str, AttributeType, AttributeGate)] = &[ // Normal attributes ("warn", Normal, Ungated), @@ -1386,48 +1387,48 @@ fn leveled_feature_err<'a>(sess: &'a ParseSess, feature: &str, span: Span, issue } -const EXPLAIN_BOX_SYNTAX: &'static str = +const EXPLAIN_BOX_SYNTAX: &str = "box expression syntax is experimental; you can call `Box::new` instead."; -pub const EXPLAIN_STMT_ATTR_SYNTAX: &'static str = +pub const EXPLAIN_STMT_ATTR_SYNTAX: &str = "attributes on expressions are experimental."; -pub const EXPLAIN_ASM: &'static str = +pub const EXPLAIN_ASM: &str = "inline assembly is not stable enough for use and is subject to change"; -pub const EXPLAIN_GLOBAL_ASM: &'static str = +pub const EXPLAIN_GLOBAL_ASM: &str = "`global_asm!` is not stable enough for use and is subject to change"; -pub const EXPLAIN_CUSTOM_TEST_FRAMEWORKS: &'static str = +pub const EXPLAIN_CUSTOM_TEST_FRAMEWORKS: &str = "custom test frameworks are an unstable feature"; -pub const EXPLAIN_LOG_SYNTAX: &'static str = +pub const EXPLAIN_LOG_SYNTAX: &str = "`log_syntax!` is not stable enough for use and is subject to change"; -pub const EXPLAIN_CONCAT_IDENTS: &'static str = +pub const EXPLAIN_CONCAT_IDENTS: &str = "`concat_idents` is not stable enough for use and is subject to change"; -pub const EXPLAIN_FORMAT_ARGS_NL: &'static str = +pub const EXPLAIN_FORMAT_ARGS_NL: &str = "`format_args_nl` is only for internal language use and is subject to change"; -pub const EXPLAIN_TRACE_MACROS: &'static str = +pub const EXPLAIN_TRACE_MACROS: &str = "`trace_macros` is not stable enough for use and is subject to change"; -pub const EXPLAIN_ALLOW_INTERNAL_UNSTABLE: &'static str = +pub const EXPLAIN_ALLOW_INTERNAL_UNSTABLE: &str = "allow_internal_unstable side-steps feature gating and stability checks"; -pub const EXPLAIN_ALLOW_INTERNAL_UNSAFE: &'static str = +pub const EXPLAIN_ALLOW_INTERNAL_UNSAFE: &str = "allow_internal_unsafe side-steps the unsafe_code lint"; -pub const EXPLAIN_CUSTOM_DERIVE: &'static str = +pub const EXPLAIN_CUSTOM_DERIVE: &str = "`#[derive]` for custom traits is deprecated and will be removed in the future."; -pub const EXPLAIN_DEPR_CUSTOM_DERIVE: &'static str = +pub const EXPLAIN_DEPR_CUSTOM_DERIVE: &str = "`#[derive]` for custom traits is deprecated and will be removed in the future. \ Prefer using procedural macro custom derive."; -pub const EXPLAIN_DERIVE_UNDERSCORE: &'static str = +pub const EXPLAIN_DERIVE_UNDERSCORE: &str = "attributes of the form `#[derive_*]` are reserved for the compiler"; -pub const EXPLAIN_UNSIZED_TUPLE_COERCION: &'static str = +pub const EXPLAIN_UNSIZED_TUPLE_COERCION: &str = "unsized tuple coercion is not stable enough for use and is subject to change"; struct PostExpansionVisitor<'a> { diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs index a240604bfe0..4ff6048e821 100644 --- a/src/libsyntax/parse/attr.rs +++ b/src/libsyntax/parse/attr.rs @@ -22,8 +22,8 @@ enum InnerAttributeParsePolicy<'a> { NotPermitted { reason: &'a str }, } -const DEFAULT_UNEXPECTED_INNER_ATTR_ERR_MSG: &'static str = "an inner attribute is not \ - permitted in this context"; +const DEFAULT_UNEXPECTED_INNER_ATTR_ERR_MSG: &str = "an inner attribute is not \ + permitted in this context"; impl<'a> Parser<'a> { /// Parse attributes that appear before an item diff --git a/src/libsyntax/parse/lexer/unicode_chars.rs b/src/libsyntax/parse/lexer/unicode_chars.rs index 03bf1b5a4e1..8a620c8067d 100644 --- a/src/libsyntax/parse/lexer/unicode_chars.rs +++ b/src/libsyntax/parse/lexer/unicode_chars.rs @@ -306,7 +306,7 @@ const UNICODE_ARRAY: &[(char, &str, char)] = &[ ('>', "Fullwidth Greater-Than Sign", '>'), ]; -const ASCII_ARRAY: &'static [(char, &'static str)] = &[ +const ASCII_ARRAY: &[(char, &str)] = &[ (' ', "Space"), ('_', "Underscore"), ('-', "Minus/Hyphen"), diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 1cd5006f330..8165c0e44c4 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -2082,7 +2082,7 @@ impl<'a> Parser<'a> { let mut segments = Vec::new(); let mod_sep_ctxt = self.span.ctxt(); if self.eat(&token::ModSep) { - segments.push(PathSegment::crate_root(lo.shrink_to_lo().with_ctxt(mod_sep_ctxt))); + segments.push(PathSegment::path_root(lo.shrink_to_lo().with_ctxt(mod_sep_ctxt))); } self.parse_path_segments(&mut segments, style, enable_warning)?; @@ -5508,7 +5508,7 @@ impl<'a> Parser<'a> { _ => unreachable!() }; let isolated_self = |this: &mut Self, n| { - this.look_ahead(n, |t| t.is_keyword(keywords::SelfValue)) && + this.look_ahead(n, |t| t.is_keyword(keywords::SelfLower)) && this.look_ahead(n + 1, |t| t != &token::ModSep) }; @@ -6330,7 +6330,7 @@ impl<'a> Parser<'a> { 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)) + t.is_keyword(keywords::SelfLower)) { // `pub(self)` or `pub(super)` self.bump(); // `(` @@ -6782,7 +6782,7 @@ impl<'a> Parser<'a> { let error_msg = "crate name using dashes are not valid in `extern crate` statements"; let suggestion_msg = "if the original crate name uses dashes you need to use underscores \ in the code"; - let mut ident = if self.token.is_keyword(keywords::SelfValue) { + let mut ident = if self.token.is_keyword(keywords::SelfLower) { self.parse_path_segment_ident() } else { self.parse_ident() @@ -7685,7 +7685,7 @@ impl<'a> Parser<'a> { let mod_sep_ctxt = self.span.ctxt(); if self.eat(&token::ModSep) { prefix.segments.push( - PathSegment::crate_root(lo.shrink_to_lo().with_ctxt(mod_sep_ctxt)) + PathSegment::path_root(lo.shrink_to_lo().with_ctxt(mod_sep_ctxt)) ); } diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index a9f08fdd411..e50f28897dd 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -724,7 +724,7 @@ pub trait PrintState<'a> { if i > 0 { self.writer().word("::")? } - if segment.ident.name != keywords::CrateRoot.name() && + if segment.ident.name != keywords::PathRoot.name() && segment.ident.name != keywords::DollarCrate.name() { self.writer().word(segment.ident.as_str().get())?; @@ -2463,7 +2463,7 @@ impl<'a> State<'a> { colons_before_params: bool) -> io::Result<()> { - if segment.ident.name != keywords::CrateRoot.name() && + if segment.ident.name != keywords::PathRoot.name() && segment.ident.name != keywords::DollarCrate.name() { self.print_ident(segment.ident)?; if let Some(ref args) = segment.args { diff --git a/src/libsyntax/std_inject.rs b/src/libsyntax/std_inject.rs index 1210f331b28..5c994558ab0 100644 --- a/src/libsyntax/std_inject.rs +++ b/src/libsyntax/std_inject.rs @@ -112,7 +112,7 @@ pub fn maybe_inject_crates_ref( vis: respan(span.shrink_to_lo(), ast::VisibilityKind::Inherited), node: ast::ItemKind::Use(P(ast::UseTree { prefix: ast::Path { - segments: iter::once(keywords::CrateRoot.ident()) + segments: iter::once(keywords::PathRoot.ident()) .chain( [name, "prelude", "v1"].iter().cloned() .map(ast::Ident::from_str) |
