pub use GenericArgs::*;
pub use UnsafeSource::*;
-pub use syntax_pos::symbol::{Ident, Symbol as Name};
+pub use rustc_span::symbol::{Ident, Symbol as Name};
use crate::ptr::P;
-use crate::source_map::{dummy_spanned, respan, Spanned};
use crate::token::{self, DelimToken};
use crate::tokenstream::{DelimSpan, TokenStream, TokenTree};
-use syntax_pos::symbol::{kw, sym, Symbol};
-use syntax_pos::{Span, DUMMY_SP};
-
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::sync::Lrc;
use rustc_data_structures::thin_vec::ThinVec;
use rustc_index::vec::Idx;
use rustc_macros::HashStable_Generic;
use rustc_serialize::{self, Decoder, Encoder};
+use rustc_span::source_map::{dummy_spanned, respan, Spanned};
+use rustc_span::symbol::{kw, sym, Symbol};
+use rustc_span::{Span, DUMMY_SP};
use std::fmt;
use std::iter;
Lit(P<Expr>),
/// A range pattern (e.g., `1...2`, `1..=2` or `1..2`).
- Range(P<Expr>, P<Expr>, Spanned<RangeEnd>),
+ Range(Option<P<Expr>>, Option<P<Expr>>, Spanned<RangeEnd>),
/// A slice pattern `[a, b, c]`.
Slice(Vec<P<Pat>>),
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,
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)]
}
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,
}
}