mirror of
https://github.com/enso-org/enso.git
synced 2024-11-23 08:08:34 +03:00
bump toolchain, fix clear issues
This commit is contained in:
parent
9fcba50e0f
commit
054d071d80
@ -50,18 +50,18 @@ impl ScalaGenerator {
|
||||
/// Generates a block of Scala code.
|
||||
fn block(&mut self, ident:&Ident, lines:&[syn::Item]) {
|
||||
write!(self.code, "\n{:i$}object " , "", i=self.indent);
|
||||
self.typ_name(&ident);
|
||||
self.typ_name(ident);
|
||||
writeln!(self.code, " {{");
|
||||
self.indent += 2;
|
||||
if self.extends.contains_key(&ident) {
|
||||
if self.extends.contains_key(ident) {
|
||||
write!(self.code, "{:i$}sealed trait ", "", i=self.indent);
|
||||
self.typ_name(&ident);
|
||||
self.extends(&ident);
|
||||
self.typ_name(ident);
|
||||
self.extends(ident);
|
||||
}
|
||||
|
||||
for item in lines {
|
||||
match item {
|
||||
syn::Item::Enum (val) => self.adt(&val),
|
||||
syn::Item::Enum (val) => self.adt(val),
|
||||
syn::Item::Type (val) => {
|
||||
write!(self.code, "\n{:i$}type ", "", i=self.indent);
|
||||
self.typ_name(&val.ident);
|
||||
@ -101,7 +101,7 @@ impl ScalaGenerator {
|
||||
for (i, field) in fields.named.iter().enumerate() {
|
||||
if i != 0 { write!(self.code, ", "); }
|
||||
if let Some(ident) = &field.ident {
|
||||
self.var_name(&ident);
|
||||
self.var_name(ident);
|
||||
}
|
||||
write!(self.code, ": ");
|
||||
self.typ(&field.ty);
|
||||
@ -170,7 +170,7 @@ impl ScalaGenerator {
|
||||
///
|
||||
/// `foo` => `extends Foo`
|
||||
fn extends(&mut self, ident:&Ident) {
|
||||
if let Some(name) = self.extends.get(&ident).cloned() {
|
||||
if let Some(name) = self.extends.get(ident).cloned() {
|
||||
write!(self.code, " extends ");
|
||||
self.typ_name(&name);
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
use ast::generation::ScalaGenerator;
|
||||
|
||||
use clap;
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
|
||||
|
@ -66,7 +66,7 @@ impl Dfa {
|
||||
impl Dfa {
|
||||
/// Simulate the DFA transition with the provided input symbol.
|
||||
pub fn next_state(&self, current_state:State, symbol:&Symbol) -> State {
|
||||
let ix = self.alphabet.index_of_symbol(&symbol);
|
||||
let ix = self.alphabet.index_of_symbol(symbol);
|
||||
self.links.safe_index(current_state.id(),ix).unwrap_or_default()
|
||||
}
|
||||
|
||||
|
@ -353,16 +353,16 @@ pub mod tests {
|
||||
}
|
||||
|
||||
pub fn has_transition(&self, trigger:RangeInclusive<Symbol>, target:State) -> bool {
|
||||
self.states.iter().any(|r| r.links().iter().find(|transition | {
|
||||
self.states.iter().any(|r| r.links().iter().any(|transition | {
|
||||
(transition.symbols == trigger) && transition.target == target
|
||||
}).is_some())
|
||||
}))
|
||||
}
|
||||
|
||||
pub fn has_epsilon(&self, from:State, to:State) -> bool {
|
||||
self.states.iter().enumerate().fold(false,|l,(ix,r)| {
|
||||
let state_has = ix == from.id() && r.epsilon_links().iter().find(|ident| {
|
||||
**ident == to
|
||||
}).is_some();
|
||||
let state_has = ix == from.id() && r.epsilon_links().iter().any(|ident| {
|
||||
*ident == to
|
||||
});
|
||||
l || state_has
|
||||
})
|
||||
}
|
||||
|
@ -129,9 +129,7 @@ impl Pattern {
|
||||
|
||||
/// This pattern doesn't trigger on any code contained in `codes`.
|
||||
pub fn none_of_codes(codes:&[u64],names:&[String]) -> Self {
|
||||
if codes.len() != names.len() {
|
||||
panic!("`codes` and `names`must have the same length.");
|
||||
}
|
||||
assert_eq!(codes.len(), names.len(), "`codes` and `names`must have the same length.");
|
||||
let mut codes = Vec::from(codes);
|
||||
codes.sort_unstable();
|
||||
codes.dedup();
|
||||
|
@ -28,7 +28,7 @@ fn bench_config() -> Criterion {
|
||||
fn gen_tree(width:usize, depth:usize) -> HashMapTree<usize,usize> {
|
||||
let mut tree = HashMapTree::<usize,usize>::default();
|
||||
let paths = (0..width).permutations(depth);
|
||||
paths.into_iter().for_each(|p| tree.set(p.clone(),1));
|
||||
paths.into_iter().for_each(|p| tree.set(p,1));
|
||||
tree
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ impl<T:Clone+Eq+Hash+Ord> DependencyGraph<T> {
|
||||
let mut keys_iter = keys.iter();
|
||||
let mut opt_key = keys_iter.next();
|
||||
while let Some(key) = opt_key {
|
||||
match next_to_keep.as_ref().map(|t| t.cmp(&key)) {
|
||||
match next_to_keep.as_ref().map(|t| t.cmp(key)) {
|
||||
Some(std::cmp::Ordering::Less) => {
|
||||
next_to_keep = keep.next()
|
||||
},
|
||||
@ -111,13 +111,13 @@ impl<T:Clone+Eq+Hash+Ord> DependencyGraph<T> {
|
||||
opt_key = keys_iter.next();
|
||||
}
|
||||
_ => {
|
||||
if let Some(node) = self.nodes.get_mut(&key) {
|
||||
if let Some(node) = self.nodes.get_mut(key) {
|
||||
let node = mem::take(node);
|
||||
for key2 in node.ins {
|
||||
self.nodes.get_mut(&key2).for_each(|t| t.out.remove_item(&key))
|
||||
self.nodes.get_mut(&key2).for_each(|t| t.out.remove_item(key))
|
||||
}
|
||||
for key2 in node.out {
|
||||
self.nodes.get_mut(&key2).for_each(|t| t.ins.remove_item(&key))
|
||||
self.nodes.get_mut(&key2).for_each(|t| t.ins.remove_item(key))
|
||||
}
|
||||
}
|
||||
opt_key = keys_iter.next();
|
||||
|
@ -312,7 +312,7 @@ pub fn branch_body<S:BuildHasher>
|
||||
}
|
||||
} else {
|
||||
let target_state_has_no_rule = match rule_name_for_state {
|
||||
Some(_) => if !dfa_has_rule_name_for(&data, dfa, target_state) {
|
||||
Some(_) => if !dfa_has_rule_name_for(data, dfa, target_state) {
|
||||
dfa.sources[target_state.id()] = (*sources).clone();
|
||||
has_overlaps.insert(target_state.id(),true);
|
||||
true
|
||||
|
@ -192,7 +192,7 @@ impl AutomatonData {
|
||||
|
||||
/// Get a reference to the states for this automaton.
|
||||
pub fn states(&self) -> &Vec<state::Data> {
|
||||
&self.automaton.states()
|
||||
self.automaton.states()
|
||||
}
|
||||
|
||||
/// Get a reference to the state names for this automaton.
|
||||
|
@ -4,6 +4,8 @@
|
||||
//! allows for increased clarity in the testing.
|
||||
|
||||
#![allow(missing_docs)]
|
||||
#![allow(clippy::blacklisted_name)] // `foo` is fine here.
|
||||
#![allow(clippy::new_without_default)] // No need for boilerplate in throwaway test code.
|
||||
|
||||
use enso_flexer::*;
|
||||
|
||||
|
@ -282,7 +282,7 @@ pub mod literal {
|
||||
|
||||
/// Get the first character of the lexeme, if it exists.
|
||||
pub fn char(literal:&'static str) -> Option<char> {
|
||||
literal.chars().nth(0)
|
||||
literal.chars().next()
|
||||
}
|
||||
|
||||
/// Get the first character of the lexeme, assuming that it exists.
|
||||
|
@ -390,30 +390,17 @@ impl TextStyle {
|
||||
|
||||
/// Check if the text literal is a line literal.
|
||||
pub fn is_line_literal(self) -> bool {
|
||||
match self {
|
||||
TextStyle::RawLine => true,
|
||||
TextStyle::FormatLine => true,
|
||||
TextStyle::UnclosedLine => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(self, TextStyle::RawLine | TextStyle::FormatLine | TextStyle::UnclosedLine)
|
||||
}
|
||||
|
||||
/// Check if the text literal is an inline block literal.
|
||||
pub fn is_inline_block_literal(self) -> bool {
|
||||
match self {
|
||||
TextStyle::FormatInlineBlock => true,
|
||||
TextStyle::RawInlineBlock => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(self, TextStyle::FormatInlineBlock | TextStyle::RawInlineBlock)
|
||||
}
|
||||
|
||||
/// Check if the text literal is a block literal.
|
||||
pub fn is_block_literal(self) -> bool {
|
||||
match self {
|
||||
TextStyle::FormatBlock => true,
|
||||
TextStyle::RawBlock => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(self, TextStyle::FormatBlock | TextStyle::RawBlock)
|
||||
}
|
||||
}
|
||||
|
||||
@ -761,9 +748,14 @@ impl Stream {
|
||||
pub fn tokens_len(&self) -> usize {
|
||||
self.tokens.iter().map(|token|token.length + token.offset).sum()
|
||||
}
|
||||
}
|
||||
|
||||
/// Get a consuming iterator over the token stream.
|
||||
pub fn into_iter(self) -> std::vec::IntoIter<Token> {
|
||||
/// Get a consuming iterator over the token stream.
|
||||
impl std::iter::IntoIterator for Stream {
|
||||
type Item = Token;
|
||||
type IntoIter = std::vec::IntoIter<Self::Item>;
|
||||
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
self.tokens.into_iter()
|
||||
}
|
||||
}
|
||||
@ -791,8 +783,8 @@ impl From<Vec<Token>> for Stream {
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<Vec<Token>> for Stream {
|
||||
fn into(self) -> Vec<Token> {
|
||||
self.tokens
|
||||
impl From<Stream> for Vec<Token> {
|
||||
fn from(stream: Stream) -> Self {
|
||||
stream.tokens
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@
|
||||
//! benchmarking the Enso lexer.
|
||||
|
||||
use criterion::{black_box, Criterion, Throughput};
|
||||
use lexer;
|
||||
use std::time::Duration;
|
||||
|
||||
|
||||
|
@ -16,9 +16,9 @@ fn generate_engine() -> std::io::Result<()> {
|
||||
let output_path = "src/generated/engine.rs";
|
||||
let definition_error = format!("The lexer definition should exist at {}.",definition_path);
|
||||
let output_error = format!("Cannot open output file at {}.",output_path);
|
||||
let mut lexer_def = File::open(definition_path).expect(definition_error.as_str());
|
||||
let mut lexer_def = File::open(definition_path).expect(&definition_error);
|
||||
let mut contents = String::new();
|
||||
let mut file = File::create(output_path).expect(output_error.as_str());
|
||||
let mut file = File::create(output_path).expect(&output_error);
|
||||
let lexer = EnsoLexer::define();
|
||||
let engine = lexer.specialize().unwrap();
|
||||
lexer_def.read_to_string(&mut contents).expect("Unable to read lexer definition.");
|
||||
|
@ -5,7 +5,6 @@
|
||||
use enso_flexer::*;
|
||||
use lexer_definition::library::*;
|
||||
|
||||
use lexer;
|
||||
use lexer_definition::library::token::Token;
|
||||
|
||||
|
||||
|
@ -213,7 +213,7 @@ pub fn gather_all_types(node:&syn::Type) -> Vec<&syn::TypePath> {
|
||||
|
||||
/// All text representations of `TypePath`s in the given's `Type` subtree.
|
||||
pub fn gather_all_type_reprs(node:&syn::Type) -> Vec<String> {
|
||||
gather_all_types(node).iter().map(|t| repr(t)).collect()
|
||||
gather_all_types(node).iter().map(repr).collect()
|
||||
}
|
||||
|
||||
|
||||
|
@ -165,7 +165,7 @@ impl<Src,Tgt,Path> OptLens<Src,Tgt,Path> {
|
||||
impl<Src,Tgt,Path> Lens<Src,Tgt,Path> {
|
||||
pub fn resolve(self, t: &Src) -> &NestedField<Src, Path>
|
||||
where Path: Resolver<Src> {
|
||||
<Path as Resolver<Src>>::resolve(&t)
|
||||
<Path as Resolver<Src>>::resolve(t)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -89,9 +89,7 @@ impl<T> NonEmptyVec<T> {
|
||||
/// vec.push(11);
|
||||
/// ```
|
||||
pub fn with_capacity(first:T, capacity:usize) -> NonEmptyVec<T> {
|
||||
if capacity == 0 {
|
||||
panic!("Capacity must be greater than zero for a NonEmptyVec.");
|
||||
}
|
||||
assert_ne!(capacity, 0, "Capacity must be greater than zero for a NonEmptyVec.");
|
||||
let mut elems = Vec::with_capacity(capacity);
|
||||
elems.push(first);
|
||||
NonEmptyVec{elems}
|
||||
@ -198,7 +196,7 @@ impl<T> NonEmptyVec<T> {
|
||||
/// assert_eq!(*vec.first(), 0);
|
||||
/// ```
|
||||
pub fn first(&self) -> &T {
|
||||
&self.elems.first().expect("The NonEmptyVec always has an item in it.")
|
||||
self.elems.first().expect("The NonEmptyVec always has an item in it.")
|
||||
}
|
||||
|
||||
/// Obtain a mutable reference to the head of the `NonEmptyVec`.
|
||||
@ -309,4 +307,4 @@ impl<T:Default> Default for NonEmptyVec<T> {
|
||||
fn default() -> Self {
|
||||
Self::singleton(default())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -394,7 +394,7 @@ pub trait WeakRef : CloneRef {
|
||||
impl<T:?Sized> StrongRef for Rc<T> {
|
||||
type WeakRef = Weak<T>;
|
||||
fn downgrade(&self) -> Self::WeakRef {
|
||||
Rc::downgrade(&self)
|
||||
Rc::downgrade(self)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#![feature(generators)]
|
||||
#![feature(min_type_alias_impl_trait)]
|
||||
#![feature(type_alias_impl_trait)]
|
||||
|
||||
use enso_shapely::*;
|
||||
|
||||
|
@ -16,11 +16,11 @@ use enso_prelude::*;
|
||||
#[derive(Clone,CloneRef)] enum EnumEmpty {}
|
||||
|
||||
#[derive(Clone,CloneRef)] enum Enum {
|
||||
VariantUnit,
|
||||
VariantNamedEmpty {},
|
||||
VariantNamed {named0:Rc<i32>,named1:Rc<String>},
|
||||
VariantUnnamedEmpty(),
|
||||
VariantUnnamed(Rc<i32>,Rc<String>),
|
||||
Unit,
|
||||
NamedEmpty {},
|
||||
Named {named0:Rc<i32>,named1:Rc<String>},
|
||||
UnnamedEmpty(),
|
||||
Unnamed(Rc<i32>,Rc<String>),
|
||||
}
|
||||
|
||||
#[derive(CloneRef,Derivative)]
|
||||
@ -42,7 +42,7 @@ struct StructBoundGeneric<T:Display>(Rc<T>);
|
||||
#[derive(CloneRef,Derivative)]
|
||||
#[derivative(Clone(bound=""))]
|
||||
// Note: CloneRef "knows" about `Display` bound.
|
||||
struct StructGenericLifetime<'t>(Rc<&'t String>);
|
||||
struct StructGenericLifetime<'t>(PhantomData<&'t String>);
|
||||
|
||||
#[derive(CloneRef,Derivative)]
|
||||
#[derivative(Clone(bound=""))]
|
||||
|
@ -147,9 +147,7 @@ pub fn clone_ref_bounds(attr:&Attribute) -> Option<Vec<WherePredicate>> {
|
||||
Meta::List(ml) => ml.nested,
|
||||
_ => panic!("Attribute contents does not conform to meta item."),
|
||||
};
|
||||
if list.len() > 1 {
|
||||
panic!("Only a single entry within `{}` attribute is allowed.",CLONE_REF_ATTR);
|
||||
}
|
||||
assert!(list.len() <= 1,"Only a single entry within `{}` attribute is allowed.",CLONE_REF_ATTR);
|
||||
let bound_value = match list.first() {
|
||||
Some(NestedMeta::Meta(Meta::NameValue(name_val))) => {
|
||||
if is_custom_bound(name_val) {
|
||||
|
@ -91,7 +91,7 @@ impl<'t> DependentValue<'t> {
|
||||
match self.ty {
|
||||
syn::Type::Tuple(tuple) => self.yield_tuple_value(tuple, is_mut),
|
||||
syn::Type::Path(path) => {
|
||||
if type_matches(&self.ty, &self.target_param) {
|
||||
if type_matches(self.ty, self.target_param) {
|
||||
self.yield_direct_value(is_mut)
|
||||
} else {
|
||||
self.yield_dependent_ty_path_value(path,is_mut)
|
||||
|
1
rust-toolchain
Normal file
1
rust-toolchain
Normal file
@ -0,0 +1 @@
|
||||
nightly-2021-10-29
|
Loading…
Reference in New Issue
Block a user