about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-01-10 02:09:41 +0000
committerbors <bors@rust-lang.org>2020-01-10 02:09:41 +0000
commit2d8d559bbecf6272eb41f8a800e319238aa9d621 (patch)
treec714e372e75f080c46ed07608912aa7df4211f9b /src/libsyntax
parent72b2bd55edbb1e63a930c5ddd08b25e4f9044786 (diff)
parent6f3f1c537b18f95bd4ea42700a1776334b165984 (diff)
downloadrust-2d8d559bbecf6272eb41f8a800e319238aa9d621.tar.gz
rust-2d8d559bbecf6272eb41f8a800e319238aa9d621.zip
Auto merge of #68078 - Centril:rollup-qvq052k, r=Centril
Rollup of 6 pull requests

Successful merges:

 - #66463 (Point at opaque and closure type definitions in type errors)
 - #67501 (Reduce special treatment for zsts)
 - #67820 (Parse the syntax described in RFC 2632)
 - #67922 (rustc_ast_lowering: misc cleanup & rustc dep reductions)
 - #68071 (Extend support of `_` in type parameters)
 - #68073 (expect `fn` after `const unsafe` / `const extern`)

Failed merges:

r? @ghost
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/ast.rs20
-rw-r--r--src/libsyntax/feature_gate/check.rs2
-rw-r--r--src/libsyntax/mut_visit.rs3
3 files changed, 21 insertions, 4 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs
index 47070261385..1d3bb7d8768 100644
--- a/src/libsyntax/ast.rs
+++ b/src/libsyntax/ast.rs
@@ -1033,7 +1033,7 @@ impl Expr {
     pub fn to_bound(&self) -> Option<GenericBound> {
         match &self.kind {
             ExprKind::Path(None, path) => Some(GenericBound::Trait(
-                PolyTraitRef::new(Vec::new(), path.clone(), self.span),
+                PolyTraitRef::new(Vec::new(), path.clone(), None, self.span),
                 TraitBoundModifier::None,
             )),
             _ => None,
@@ -2376,6 +2376,15 @@ pub enum AttrKind {
 pub struct TraitRef {
     pub path: Path,
     pub ref_id: NodeId,
+
+    /// The `const` modifier, if any, that appears before this trait.
+    ///
+    /// |                | `constness`                 |
+    /// |----------------|-----------------------------|
+    /// | `Trait`        | `None`                      |
+    /// | `const Trait`  | `Some(Constness::Const)`    |
+    /// | `?const Trait` | `Some(Constness::NotConst)` |
+    pub constness: Option<Constness>,
 }
 
 #[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
@@ -2390,10 +2399,15 @@ pub struct PolyTraitRef {
 }
 
 impl PolyTraitRef {
-    pub fn new(generic_params: Vec<GenericParam>, path: Path, span: Span) -> Self {
+    pub fn new(
+        generic_params: Vec<GenericParam>,
+        path: Path,
+        constness: Option<Constness>,
+        span: Span,
+    ) -> Self {
         PolyTraitRef {
             bound_generic_params: generic_params,
-            trait_ref: TraitRef { path, ref_id: DUMMY_NODE_ID },
+            trait_ref: TraitRef { path, constness, ref_id: DUMMY_NODE_ID },
             span,
         }
     }
diff --git a/src/libsyntax/feature_gate/check.rs b/src/libsyntax/feature_gate/check.rs
index 26545bfa61b..52eb20d320f 100644
--- a/src/libsyntax/feature_gate/check.rs
+++ b/src/libsyntax/feature_gate/check.rs
@@ -909,6 +909,8 @@ pub fn check_crate(
     gate_all!(or_patterns, "or-patterns syntax is experimental");
     gate_all!(const_extern_fn, "`const extern fn` definitions are unstable");
     gate_all!(raw_ref_op, "raw address of syntax is experimental");
+    gate_all!(const_trait_bound_opt_out, "`?const` on trait bounds is experimental");
+    gate_all!(const_trait_impl, "const trait impls are experimental");
 
     // All uses of `gate_all!` below this point were added in #65742,
     // and subsequently disabled (with the non-early gating readded).
diff --git a/src/libsyntax/mut_visit.rs b/src/libsyntax/mut_visit.rs
index 1413f1566d0..264ba25cede 100644
--- a/src/libsyntax/mut_visit.rs
+++ b/src/libsyntax/mut_visit.rs
@@ -838,7 +838,8 @@ pub fn noop_visit_variant_data<T: MutVisitor>(vdata: &mut VariantData, vis: &mut
     }
 }
 
-pub fn noop_visit_trait_ref<T: MutVisitor>(TraitRef { path, ref_id }: &mut TraitRef, vis: &mut T) {
+pub fn noop_visit_trait_ref<T: MutVisitor>(tr: &mut TraitRef, vis: &mut T) {
+    let TraitRef { path, ref_id, constness: _ } = tr;
     vis.visit_path(path);
     vis.visit_id(ref_id);
 }