Merge pull request #2528 from topecongiro/rfc/trait-impl-where

Implement RFC style for trait
This commit is contained in:
Nick Cameron 2018-03-12 16:25:12 +13:00 committed by GitHub
commit 047a52087e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 224 additions and 172 deletions

View File

@ -1698,7 +1698,8 @@ fn rewrite_match_body(
); );
match (orig_body, next_line_body) { match (orig_body, next_line_body) {
(Some(ref orig_str), Some(ref next_line_str)) (Some(ref orig_str), Some(ref next_line_str))
if forbid_same_line || prefer_next_line(orig_str, next_line_str) => if forbid_same_line
|| prefer_next_line(orig_str, next_line_str, RhsTactics::Default) =>
{ {
combine_next_line_body(next_line_str) combine_next_line_body(next_line_str)
} }
@ -2514,6 +2515,15 @@ fn rewrite_assignment(
rewrite_assign_rhs(context, lhs_str, rhs, shape) rewrite_assign_rhs(context, lhs_str, rhs, shape)
} }
/// Controls where to put the rhs.
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum RhsTactics {
/// Use heuristics.
Default,
/// Put the rhs on the next line if it uses multiple line.
ForceNextLine,
}
// The left hand side must contain everything up to, and including, the // The left hand side must contain everything up to, and including, the
// assignment operator. // assignment operator.
pub fn rewrite_assign_rhs<S: Into<String>, R: Rewrite>( pub fn rewrite_assign_rhs<S: Into<String>, R: Rewrite>(
@ -2521,6 +2531,16 @@ pub fn rewrite_assign_rhs<S: Into<String>, R: Rewrite>(
lhs: S, lhs: S,
ex: &R, ex: &R,
shape: Shape, shape: Shape,
) -> Option<String> {
rewrite_assign_rhs_with(context, lhs, ex, shape, RhsTactics::Default)
}
pub fn rewrite_assign_rhs_with<S: Into<String>, R: Rewrite>(
context: &RewriteContext,
lhs: S,
ex: &R,
shape: Shape,
rhs_tactics: RhsTactics,
) -> Option<String> { ) -> Option<String> {
let lhs = lhs.into(); let lhs = lhs.into();
let last_line_width = last_line_width(&lhs) let last_line_width = last_line_width(&lhs)
@ -2536,15 +2556,22 @@ pub fn rewrite_assign_rhs<S: Into<String>, R: Rewrite>(
offset: shape.offset + last_line_width + 1, offset: shape.offset + last_line_width + 1,
..shape ..shape
}); });
let rhs = choose_rhs(context, ex, orig_shape, ex.rewrite(context, orig_shape))?; let rhs = choose_rhs(
context,
ex,
orig_shape,
ex.rewrite(context, orig_shape),
rhs_tactics,
)?;
Some(lhs + &rhs) Some(lhs + &rhs)
} }
pub fn choose_rhs<R: Rewrite>( fn choose_rhs<R: Rewrite>(
context: &RewriteContext, context: &RewriteContext,
expr: &R, expr: &R,
shape: Shape, shape: Shape,
orig_rhs: Option<String>, orig_rhs: Option<String>,
rhs_tactics: RhsTactics,
) -> Option<String> { ) -> Option<String> {
match orig_rhs { match orig_rhs {
Some(ref new_str) if !new_str.contains('\n') && new_str.len() <= shape.width => { Some(ref new_str) if !new_str.contains('\n') && new_str.len() <= shape.width => {
@ -2566,7 +2593,9 @@ pub fn choose_rhs<R: Rewrite>(
{ {
Some(format!(" {}", orig_rhs)) Some(format!(" {}", orig_rhs))
} }
(Some(ref orig_rhs), Some(ref new_rhs)) if prefer_next_line(orig_rhs, new_rhs) => { (Some(ref orig_rhs), Some(ref new_rhs))
if prefer_next_line(orig_rhs, new_rhs, rhs_tactics) =>
{
Some(format!("{}{}", new_indent_str, new_rhs)) Some(format!("{}{}", new_indent_str, new_rhs))
} }
(None, Some(ref new_rhs)) => Some(format!("{}{}", new_indent_str, new_rhs)), (None, Some(ref new_rhs)) => Some(format!("{}{}", new_indent_str, new_rhs)),
@ -2577,8 +2606,9 @@ pub fn choose_rhs<R: Rewrite>(
} }
} }
fn prefer_next_line(orig_rhs: &str, next_line_rhs: &str) -> bool { fn prefer_next_line(orig_rhs: &str, next_line_rhs: &str, rhs_tactics: RhsTactics) -> bool {
!next_line_rhs.contains('\n') || count_newlines(orig_rhs) > count_newlines(next_line_rhs) + 1 rhs_tactics == RhsTactics::ForceNextLine || !next_line_rhs.contains('\n')
|| count_newlines(orig_rhs) > count_newlines(next_line_rhs) + 1
} }
fn rewrite_expr_addrof( fn rewrite_expr_addrof(

View File

@ -23,13 +23,14 @@ use codemap::{LineRangeUtils, SpanUtils};
use comment::{combine_strs_with_missing_comments, contains_comment, recover_comment_removed, use comment::{combine_strs_with_missing_comments, contains_comment, recover_comment_removed,
recover_missing_comment_in_span, rewrite_missing_comment, FindUncommented}; recover_missing_comment_in_span, rewrite_missing_comment, FindUncommented};
use config::{BraceStyle, Config, Density, IndentStyle}; use config::{BraceStyle, Config, Density, IndentStyle};
use expr::{format_expr, is_empty_block, is_simple_block_stmt, rewrite_assign_rhs, ExprType}; use expr::{format_expr, is_empty_block, is_simple_block_stmt, rewrite_assign_rhs,
rewrite_assign_rhs_with, ExprType, RhsTactics};
use lists::{definitive_tactic, itemize_list, write_list, ListFormatting, ListItem, Separator}; use lists::{definitive_tactic, itemize_list, write_list, ListFormatting, ListItem, Separator};
use rewrite::{Rewrite, RewriteContext}; use rewrite::{Rewrite, RewriteContext};
use overflow; use overflow;
use shape::{Indent, Shape}; use shape::{Indent, Shape};
use spanned::Spanned; use spanned::Spanned;
use types::join_bounds; use types::TraitTyParamBounds;
use utils::{colon_spaces, contains_skip, first_line_width, format_abi, format_constness, use utils::{colon_spaces, contains_skip, first_line_width, format_abi, format_constness,
format_defaultness, format_mutability, format_unsafety, format_visibility, format_defaultness, format_mutability, format_unsafety, format_visibility,
is_attributes_extendable, last_line_contains_single_line_comment, is_attributes_extendable, last_line_contains_single_line_comment,
@ -919,60 +920,55 @@ pub fn format_trait(context: &RewriteContext, item: &ast::Item, offset: Indent)
return None; return None;
} }
} }
let trait_bound_str = rewrite_trait_bounds( if !type_param_bounds.is_empty() {
context, result = rewrite_assign_rhs_with(
type_param_bounds, context,
Shape::indented(offset, context.config), result + ":",
)?; &TraitTyParamBounds::new(type_param_bounds),
// If the trait, generics, and trait bound cannot fit on the same line, shape,
// put the trait bounds on an indented new line RhsTactics::ForceNextLine,
if offset.width() + last_line_width(&result) + trait_bound_str.len() )?;
> context.config.comment_width()
{
let trait_indent = offset.block_only().block_indent(context.config);
result.push_str(&trait_indent.to_string_with_newline(context.config));
} }
result.push_str(&trait_bound_str);
let where_density = // Rewrite where clause.
if context.config.indent_style() == IndentStyle::Block && result.is_empty() { if !generics.where_clause.predicates.is_empty() {
let where_density = if context.config.indent_style() == IndentStyle::Block {
Density::Compressed Density::Compressed
} else { } else {
Density::Tall Density::Tall
}; };
let where_budget = context.budget(last_line_width(&result)); let where_budget = context.budget(last_line_width(&result));
let pos_before_where = if type_param_bounds.is_empty() { let pos_before_where = if type_param_bounds.is_empty() {
generics.where_clause.span.lo() generics.where_clause.span.lo()
} else {
type_param_bounds[type_param_bounds.len() - 1].span().hi()
};
let option = WhereClauseOption::snuggled(&generics_str);
let where_clause_str = rewrite_where_clause(
context,
&generics.where_clause,
context.config.brace_style(),
Shape::legacy(where_budget, offset.block_only()),
where_density,
"{",
None,
pos_before_where,
option,
false,
)?;
// If the where clause cannot fit on the same line,
// put the where clause on a new line
if !where_clause_str.contains('\n')
&& last_line_width(&result) + where_clause_str.len() + offset.width()
> context.config.comment_width()
{
let width = offset.block_indent + context.config.tab_spaces() - 1;
let where_indent = Indent::new(0, width);
result.push_str(&where_indent.to_string_with_newline(context.config));
}
result.push_str(&where_clause_str);
} else { } else {
type_param_bounds[type_param_bounds.len() - 1].span().hi()
};
let option = WhereClauseOption::snuggled(&generics_str);
let where_clause_str = rewrite_where_clause(
context,
&generics.where_clause,
context.config.brace_style(),
Shape::legacy(where_budget, offset.block_only()),
where_density,
"{",
None,
pos_before_where,
option,
false,
)?;
// If the where clause cannot fit on the same line,
// put the where clause on a new line
if !where_clause_str.contains('\n')
&& last_line_width(&result) + where_clause_str.len() + offset.width()
> context.config.comment_width()
{
let width = offset.block_indent + context.config.tab_spaces() - 1;
let where_indent = Indent::new(0, width);
result.push_str(&where_indent.to_string_with_newline(context.config));
}
result.push_str(&where_clause_str);
if generics.where_clause.predicates.is_empty() {
let item_snippet = context.snippet(item.span); let item_snippet = context.snippet(item.span);
if let Some(lo) = item_snippet.chars().position(|c| c == '/') { if let Some(lo) = item_snippet.chars().position(|c| c == '/') {
// 1 = `{` // 1 = `{`
@ -995,7 +991,9 @@ pub fn format_trait(context: &RewriteContext, item: &ast::Item, offset: Indent)
} }
match context.config.brace_style() { match context.config.brace_style() {
_ if last_line_contains_single_line_comment(&result) => { _ if last_line_contains_single_line_comment(&result)
|| last_line_width(&result) + 2 > context.budget(offset.width()) =>
{
result.push_str(&offset.to_string_with_newline(context.config)); result.push_str(&offset.to_string_with_newline(context.config));
} }
BraceStyle::AlwaysNextLine => { BraceStyle::AlwaysNextLine => {
@ -1003,8 +1001,8 @@ pub fn format_trait(context: &RewriteContext, item: &ast::Item, offset: Indent)
} }
BraceStyle::PreferSameLine => result.push(' '), BraceStyle::PreferSameLine => result.push(' '),
BraceStyle::SameLineWhere => { BraceStyle::SameLineWhere => {
if !where_clause_str.is_empty() if result.contains('\n')
&& (!trait_items.is_empty() || result.contains('\n')) || (!generics.where_clause.predicates.is_empty() && !trait_items.is_empty())
{ {
result.push_str(&offset.to_string_with_newline(context.config)); result.push_str(&offset.to_string_with_newline(context.config));
} else { } else {
@ -1585,16 +1583,12 @@ pub fn rewrite_associated_type(
let prefix = format!("type {}", ident); let prefix = format!("type {}", ident);
let type_bounds_str = if let Some(bounds) = ty_param_bounds_opt { let type_bounds_str = if let Some(bounds) = ty_param_bounds_opt {
// 2 = ": ".len() if bounds.is_empty() {
let shape = Shape::indented(indent, context.config).offset_left(prefix.len() + 2)?;
let bound_str = bounds
.iter()
.map(|ty_bound| ty_bound.rewrite(context, shape))
.collect::<Option<Vec<_>>>()?;
if !bounds.is_empty() {
format!(": {}", join_bounds(context, shape, &bound_str))
} else {
String::new() String::new()
} else {
// 2 = ": ".len()
let shape = Shape::indented(indent, context.config).offset_left(prefix.len() + 2)?;
bounds.rewrite(context, shape).map(|s| format!(": {}", s))?
} }
} else { } else {
String::new() String::new()
@ -2329,21 +2323,6 @@ pub fn generics_shape_from_config(config: &Config, shape: Shape, offset: usize)
} }
} }
fn rewrite_trait_bounds(
context: &RewriteContext,
bounds: &[ast::TyParamBound],
shape: Shape,
) -> Option<String> {
if bounds.is_empty() {
return Some(String::new());
}
let bound_str = bounds
.iter()
.map(|ty_bound| ty_bound.rewrite(context, shape))
.collect::<Option<Vec<_>>>()?;
Some(format!(": {}", join_bounds(context, shape, &bound_str)))
}
fn rewrite_where_clause_rfc_style( fn rewrite_where_clause_rfc_style(
context: &RewriteContext, context: &RewriteContext,
where_clause: &ast::WhereClause, where_clause: &ast::WhereClause,

View File

@ -18,7 +18,8 @@ use syntax::symbol::keywords;
use codemap::SpanUtils; use codemap::SpanUtils;
use config::{IndentStyle, TypeDensity}; use config::{IndentStyle, TypeDensity};
use expr::{rewrite_pair, rewrite_tuple, rewrite_unary_prefix, PairParts, ToExpr}; use expr::{rewrite_assign_rhs, rewrite_pair, rewrite_tuple, rewrite_unary_prefix, PairParts,
ToExpr};
use lists::{definitive_tactic, itemize_list, write_list, ListFormatting, Separator}; use lists::{definitive_tactic, itemize_list, write_list, ListFormatting, Separator};
use macros::{rewrite_macro, MacroPosition}; use macros::{rewrite_macro, MacroPosition};
use overflow; use overflow;
@ -431,64 +432,35 @@ impl Rewrite for ast::WherePredicate {
.. ..
}) => { }) => {
let type_str = bounded_ty.rewrite(context, shape)?; let type_str = bounded_ty.rewrite(context, shape)?;
let colon = type_bound_colon(context).trim_right();
let colon = type_bound_colon(context); let lhs = if let Some(lifetime_str) =
if let Some(lifetime_str) =
rewrite_lifetime_param(context, shape, bound_generic_params) rewrite_lifetime_param(context, shape, bound_generic_params)
{ {
// 6 = "for<> ".len()
let used_width = lifetime_str.len() + type_str.len() + colon.len() + 6;
let ty_shape = shape.offset_left(used_width)?;
let bounds = bounds
.iter()
.map(|ty_bound| ty_bound.rewrite(context, ty_shape))
.collect::<Option<Vec<_>>>()?;
let bounds_str = join_bounds(context, ty_shape, &bounds);
if context.config.spaces_within_parens_and_brackets() if context.config.spaces_within_parens_and_brackets()
&& !lifetime_str.is_empty() && !lifetime_str.is_empty()
{ {
format!( format!("for< {} > {}{}", lifetime_str, type_str, colon)
"for< {} > {}{}{}",
lifetime_str, type_str, colon, bounds_str
)
} else { } else {
format!("for<{}> {}{}{}", lifetime_str, type_str, colon, bounds_str) format!("for<{}> {}{}", lifetime_str, type_str, colon)
} }
} else { } else {
let used_width = type_str.len() + colon.len(); format!("{}{}", type_str, colon)
let ty_shape = match context.config.indent_style() { };
IndentStyle::Visual => shape.block_left(used_width)?,
IndentStyle::Block => shape,
};
let bounds = bounds
.iter()
.map(|ty_bound| ty_bound.rewrite(context, ty_shape))
.collect::<Option<Vec<_>>>()?;
let overhead = type_str.len() + colon.len();
let bounds_str = join_bounds(context, ty_shape.sub_width(overhead)?, &bounds);
format!("{}{}{}", type_str, colon, bounds_str) rewrite_assign_rhs(context, lhs, bounds, shape)?
}
} }
ast::WherePredicate::RegionPredicate(ast::WhereRegionPredicate { ast::WherePredicate::RegionPredicate(ast::WhereRegionPredicate {
ref lifetime, ref lifetime,
ref bounds, ref bounds,
.. ..
}) => rewrite_bounded_lifetime(lifetime, bounds.iter(), context, shape)?, }) => rewrite_bounded_lifetime(lifetime, bounds, context, shape)?,
ast::WherePredicate::EqPredicate(ast::WhereEqPredicate { ast::WherePredicate::EqPredicate(ast::WhereEqPredicate {
ref lhs_ty, ref lhs_ty,
ref rhs_ty, ref rhs_ty,
.. ..
}) => { }) => {
let lhs_ty_str = lhs_ty.rewrite(context, shape)?; let lhs_ty_str = lhs_ty.rewrite(context, shape).map(|lhs| lhs + " =")?;
// 3 = " = ".len() rewrite_assign_rhs(context, lhs_ty_str, &**rhs_ty, shape)?
let used_width = 3 + lhs_ty_str.len();
let budget = shape.width.checked_sub(used_width)?;
let rhs_ty_str =
rhs_ty.rewrite(context, Shape::legacy(budget, shape.indent + used_width))?;
format!("{} = {}", lhs_ty_str, rhs_ty_str)
} }
}; };
@ -498,35 +470,28 @@ impl Rewrite for ast::WherePredicate {
impl Rewrite for ast::LifetimeDef { impl Rewrite for ast::LifetimeDef {
fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> { fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
rewrite_bounded_lifetime(&self.lifetime, self.bounds.iter(), context, shape) rewrite_bounded_lifetime(&self.lifetime, &self.bounds, context, shape)
} }
} }
fn rewrite_bounded_lifetime<'b, I>( fn rewrite_bounded_lifetime(
lt: &ast::Lifetime, lt: &ast::Lifetime,
bounds: I, bounds: &[ast::Lifetime],
context: &RewriteContext, context: &RewriteContext,
shape: Shape, shape: Shape,
) -> Option<String> ) -> Option<String> {
where
I: ExactSizeIterator<Item = &'b ast::Lifetime>,
{
let result = lt.rewrite(context, shape)?; let result = lt.rewrite(context, shape)?;
if bounds.len() == 0 { if bounds.len() == 0 {
Some(result) Some(result)
} else { } else {
let appendix = bounds
.into_iter()
.map(|b| b.rewrite(context, shape))
.collect::<Option<Vec<_>>>()?;
let colon = type_bound_colon(context); let colon = type_bound_colon(context);
let overhead = last_line_width(&result) + colon.len(); let overhead = last_line_width(&result) + colon.len();
let result = format!( let result = format!(
"{}{}{}", "{}{}{}",
result, result,
colon, colon,
join_bounds(context, shape.sub_width(overhead)?, &appendix) join_bounds(context, shape.sub_width(overhead)?, bounds, true)?
); );
Some(result) Some(result)
} }
@ -552,12 +517,21 @@ impl Rewrite for ast::Lifetime {
} }
} }
/// A simple wrapper over type param bounds in trait.
#[derive(new)]
pub struct TraitTyParamBounds<'a> {
inner: &'a ast::TyParamBounds,
}
impl<'a> Rewrite for TraitTyParamBounds<'a> {
fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
join_bounds(context, shape, self.inner, false)
}
}
impl Rewrite for ast::TyParamBounds { impl Rewrite for ast::TyParamBounds {
fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> { fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
let strs = self.iter() join_bounds(context, shape, self, true)
.map(|b| b.rewrite(context, shape))
.collect::<Option<Vec<_>>>()?;
Some(join_bounds(context, shape, &strs))
} }
} }
@ -572,11 +546,7 @@ impl Rewrite for ast::TyParam {
result.push_str(&self.ident.to_string()); result.push_str(&self.ident.to_string());
if !self.bounds.is_empty() { if !self.bounds.is_empty() {
result.push_str(type_bound_colon(context)); result.push_str(type_bound_colon(context));
let strs = self.bounds result.push_str(&self.bounds.rewrite(context, shape)?)
.iter()
.map(|ty_bound| ty_bound.rewrite(context, shape))
.collect::<Option<Vec<_>>>()?;
result.push_str(&join_bounds(context, shape, &strs));
} }
if let Some(ref def) = self.default { if let Some(ref def) = self.default {
let eq_str = match context.config.type_punctuation_density() { let eq_str = match context.config.type_punctuation_density() {
@ -794,20 +764,44 @@ fn rewrite_bare_fn(
Some(result) Some(result)
} }
pub fn join_bounds(context: &RewriteContext, shape: Shape, type_strs: &[String]) -> String { fn join_bounds<T>(
context: &RewriteContext,
shape: Shape,
items: &[T],
need_indent: bool,
) -> Option<String>
where
T: Rewrite,
{
// Try to join types in a single line // Try to join types in a single line
let joiner = match context.config.type_punctuation_density() { let joiner = match context.config.type_punctuation_density() {
TypeDensity::Compressed => "+", TypeDensity::Compressed => "+",
TypeDensity::Wide => " + ", TypeDensity::Wide => " + ",
}; };
let type_strs = items
.iter()
.map(|item| item.rewrite(context, shape))
.collect::<Option<Vec<_>>>()?;
let result = type_strs.join(joiner); let result = type_strs.join(joiner);
if result.contains('\n') || result.len() > shape.width { if items.len() == 1 || (!result.contains('\n') && result.len() <= shape.width) {
let joiner_indent = shape.indent.block_indent(context.config); return Some(result);
let joiner = format!("{}+ ", joiner_indent.to_string_with_newline(context.config));
type_strs.join(&joiner)
} else {
result
} }
// We need to use multiple lines.
let (type_strs, offset) = if need_indent {
// Rewrite with additional indentation.
let nested_shape = shape.block_indent(context.config.tab_spaces());
let type_strs = items
.iter()
.map(|item| item.rewrite(context, nested_shape))
.collect::<Option<Vec<_>>>()?;
(type_strs, nested_shape.indent)
} else {
(type_strs, shape.indent)
};
let joiner = format!("{}+ ", offset.to_string_with_newline(context.config));
Some(type_strs.join(&joiner))
} }
pub fn can_be_overflowed_type(context: &RewriteContext, ty: &ast::Ty, len: usize) -> bool { pub fn can_be_overflowed_type(context: &RewriteContext, ty: &ast::Ty, len: usize) -> bool {

View File

@ -7,7 +7,7 @@ fn main() {
fn f1(a: Box<dyn MyTrait>) {} fn f1(a: Box<dyn MyTrait>) {}
// checks if line wrap works correctly // checks if line wrap works correctly
trait Very_______________________Long__________________Name____________________Trait { trait Very_______________________Long__________________Name_______________________________Trait {
fn method(&self) -> u64; fn method(&self) -> u64;
} }

View File

@ -56,3 +56,20 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
// ... // ...
} }
} }
// #2497
fn handle_update<'a, Tab, Conn, R, C>(executor: &Executor<PooledConnection<ConnectionManager<Conn>>>, change_set: &'a C) -> ExecutionResult
where &'a C: Identifiable + AsChangeset<Target = Tab> + HasTable<Table = Tab>,
<&'a C as AsChangeset>::Changeset: QueryFragment<Conn::Backend>,
Tab: Table + HasTable<Table = Tab>,
Tab::PrimaryKey: EqAll<<&'a C as Identifiable>::Id>,
Tab::FromClause: QueryFragment<Conn::Backend>,
Tab: FindDsl<<&'a C as Identifiable>::Id>,
Find<Tab, <&'a C as Identifiable>::Id>: IntoUpdateTarget<Table = Tab>,
<Find<Tab, <&'a C as Identifiable>::Id> as IntoUpdateTarget>::WhereClause: QueryFragment<Conn::Backend>,
Tab::Query: FilterDsl<<Tab::PrimaryKey as EqAll<<&'a C as Identifiable>::Id>>::Output>,
Filter<Tab::Query, <Tab::PrimaryKey as EqAll<<&'a C as Identifiable>::Id>>::Output>: LimitDsl,
Limit<Filter<Tab::Query, <Tab::PrimaryKey as EqAll<<&'a C as Identifiable>::Id>>::Output>>: QueryDsl + BoxedDsl< 'a, Conn::Backend, Output = BoxedSelectStatement<'a, R::SqlType, Tab, Conn::Backend>>,
R: LoadingHandler<Conn, Table = Tab, SqlType = Tab::SqlType> + GraphQLType<TypeInfo = (), Context = ()>, {
unimplemented!()
}

View File

@ -174,8 +174,8 @@ impl<#[may_dangle] K, #[may_dangle] V> Drop for RawTable<K, V> {
} }
// #1168 // #1168
pub trait Number pub trait Number:
: Copy Copy
+ Eq + Eq
+ Not<Output = Self> + Not<Output = Self>
+ Shl<u8, Output = Self> + Shl<u8, Output = Self>
@ -183,14 +183,15 @@ pub trait Number
+ BitAnd<Self, Output = Self> + BitAnd<Self, Output = Self>
+ BitOr<Self, Output = Self> + BitOr<Self, Output = Self>
+ BitAndAssign + BitAndAssign
+ BitOrAssign { + BitOrAssign
{
// test // test
fn zero() -> Self; fn zero() -> Self;
} }
// #1642 // #1642
pub trait SomeTrait pub trait SomeTrait:
: Clone Clone
+ Eq + Eq
+ PartialEq + PartialEq
+ Ord + Ord
@ -201,7 +202,8 @@ pub trait SomeTrait
+ Display + Display
+ Write + Write
+ Read + Read
+ FromStr { + FromStr
{
// comment // comment
} }

View File

@ -7,8 +7,8 @@ fn main() {
fn f1(a: Box<dyn MyTrait>) {} fn f1(a: Box<dyn MyTrait>) {}
// checks if line wrap works correctly // checks if line wrap works correctly
trait Very_______________________Long__________________Name____________________Trait trait Very_______________________Long__________________Name_______________________________Trait
{ {
fn method(&self) -> u64; fn method(&self) -> u64;
} }

View File

@ -65,8 +65,7 @@ where
{ {
} }
trait FooBar<T> trait FooBar<T>: Tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt
: Tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt
where where
J: Bar, J: Bar,
{ {
@ -106,7 +105,8 @@ trait MyTrait<
BBBBBBBBBBBBBBBBBBBB, BBBBBBBBBBBBBBBBBBBB,
CCCCCCCCCCCCCCCCCCCC, CCCCCCCCCCCCCCCCCCCC,
DDDDDDDDDDDDDDDDDDDD, DDDDDDDDDDDDDDDDDDDD,
> { >
{
fn foo() {} fn foo() {}
} }

View File

@ -126,3 +126,33 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
// ... // ...
} }
} }
// #2497
fn handle_update<'a, Tab, Conn, R, C>(
executor: &Executor<PooledConnection<ConnectionManager<Conn>>>,
change_set: &'a C,
) -> ExecutionResult
where
&'a C: Identifiable + AsChangeset<Target = Tab> + HasTable<Table = Tab>,
<&'a C as AsChangeset>::Changeset: QueryFragment<Conn::Backend>,
Tab: Table + HasTable<Table = Tab>,
Tab::PrimaryKey: EqAll<<&'a C as Identifiable>::Id>,
Tab::FromClause: QueryFragment<Conn::Backend>,
Tab: FindDsl<<&'a C as Identifiable>::Id>,
Find<Tab, <&'a C as Identifiable>::Id>: IntoUpdateTarget<Table = Tab>,
<Find<Tab, <&'a C as Identifiable>::Id> as IntoUpdateTarget>::WhereClause:
QueryFragment<Conn::Backend>,
Tab::Query: FilterDsl<<Tab::PrimaryKey as EqAll<<&'a C as Identifiable>::Id>>::Output>,
Filter<Tab::Query, <Tab::PrimaryKey as EqAll<<&'a C as Identifiable>::Id>>::Output>: LimitDsl,
Limit<Filter<Tab::Query, <Tab::PrimaryKey as EqAll<<&'a C as Identifiable>::Id>>::Output>>:
QueryDsl
+ BoxedDsl<
'a,
Conn::Backend,
Output = BoxedSelectStatement<'a, R::SqlType, Tab, Conn::Backend>,
>,
R: LoadingHandler<Conn, Table = Tab, SqlType = Tab::SqlType>
+ GraphQLType<TypeInfo = (), Context = ()>,
{
unimplemented!()
}

View File

@ -81,17 +81,17 @@ struct AlwaysOnNextLine<LongLongTypename, LongTypename, A, B, C, D, E, F>
pub trait SomeTrait<T> pub trait SomeTrait<T>
where T: Something where T: Something
+ Sync + Sync
+ Send + Send
+ Display + Display
+ Debug + Debug
+ Copy + Copy
+ Hash + Hash
+ Debug + Debug
+ Display + Display
+ Write + Write
+ Read + Read
+ FromStr + FromStr
{ {
} }