Skip to content

Commit 2c1711e

Browse files
author
Alexander Regueiro
committed
WIP
1 parent dd7cde6 commit 2c1711e

File tree

5 files changed

+15
-33
lines changed

5 files changed

+15
-33
lines changed

src/librustc/traits/select.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,7 +1634,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
16341634
ambiguous: false,
16351635
};
16361636

1637-
self.assemble_candidates_for_alias(obligation, &mut candidates)?;
1637+
self.assemble_candidates_for_trait_alias(obligation, &mut candidates)?;
16381638

16391639
// Other bounds. Consider both in-scope bounds from fn decl
16401640
// and applicable impls. There is a certain set of precedence rules here.
@@ -2254,14 +2254,14 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
22542254
}
22552255
}
22562256

2257-
fn assemble_candidates_for_alias(
2257+
fn assemble_candidates_for_trait_alias(
22582258
&mut self,
22592259
obligation: &TraitObligation<'tcx>,
22602260
candidates: &mut SelectionCandidateSet<'tcx>,
22612261
) -> Result<(), SelectionError<'tcx>> {
22622262
// OK to skip binder here because the tests we do below do not involve bound regions
22632263
let self_ty = *obligation.self_ty().skip_binder();
2264-
debug!("assemble_candidates_for_alias(self_ty={:?})", self_ty);
2264+
debug!("assemble_candidates_for_trait_alias(self_ty={:?})", self_ty);
22652265

22662266
let def_id = obligation.predicate.def_id();
22672267

@@ -2906,7 +2906,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
29062906
self.vtable_auto_impl(obligation, trait_def_id, types)
29072907
}
29082908

2909-
/// See `confirm_auto_impl_candidate`
2909+
/// See `confirm_auto_impl_candidate`.
29102910
fn vtable_auto_impl(
29112911
&mut self,
29122912
obligation: &TraitObligation<'tcx>,
@@ -2963,7 +2963,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
29632963
// this time not in a probe.
29642964
self.in_snapshot(|this, snapshot| {
29652965
let (substs, placeholder_map) = this.rematch_impl(impl_def_id, obligation, snapshot);
2966-
debug!("confirm_impl_candidate substs={:?}", substs);
2966+
debug!("confirm_impl_candidate: substs={:?}", substs);
29672967
let cause = obligation.derived_cause(ImplDerivedObligation);
29682968
this.vtable_impl(
29692969
impl_def_id,

src/librustc_passes/ast_validation.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -403,25 +403,6 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
403403
}
404404
}
405405
}
406-
ItemKind::TraitAlias(Generics { ref params, .. }, ..) => {
407-
for param in params {
408-
match param.kind {
409-
GenericParamKind::Lifetime { .. } => {}
410-
GenericParamKind::Type { ref default, .. } => {
411-
if !param.bounds.is_empty() {
412-
self.err_handler()
413-
.span_err(param.ident.span, "type parameters on the left \
414-
side of a trait alias cannot be bounded");
415-
}
416-
if !default.is_none() {
417-
self.err_handler()
418-
.span_err(param.ident.span, "type parameters on the left \
419-
side of a trait alias cannot have defaults");
420-
}
421-
}
422-
}
423-
}
424-
}
425406
ItemKind::Mod(_) => {
426407
// Ensure that `path` attributes on modules are recorded as used (c.f. #35584).
427408
attr::first_attr_value_str_by_name(&item.attrs, "path");

src/libsyntax/parse/parser.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,7 +1295,7 @@ impl<'a> Parser<'a> {
12951295
self.check_keyword(keywords::Extern) && self.is_extern_non_path()
12961296
}
12971297

1298-
/// parse a TyKind::BareFn type:
1298+
/// parse a `TyKind::BareFn` type:
12991299
fn parse_ty_bare_fn(&mut self, generic_params: Vec<GenericParam>) -> PResult<'a, TyKind> {
13001300
/*
13011301
@@ -5779,7 +5779,7 @@ impl<'a> Parser<'a> {
57795779
ast::ImplItemKind)> {
57805780
// code copied from parse_macro_use_or_failure... abstraction!
57815781
if let Some(mac) = self.parse_assoc_macro_invoc("impl", Some(vis), at_end)? {
5782-
// Method macro.
5782+
// method macro
57835783
Ok((keywords::Invalid.ident(), vec![], ast::Generics::default(),
57845784
ast::ImplItemKind::Macro(mac)))
57855785
} else {
@@ -6792,11 +6792,11 @@ impl<'a> Parser<'a> {
67926792
Ok(self.mk_item(lo.to(prev_span), invalid, ItemKind::ForeignMod(m), visibility, attrs))
67936793
}
67946794

6795-
/// Parse type Foo = Bar;
6795+
/// Parse `type Foo = Bar;`
67966796
/// or
6797-
/// existential type Foo: Bar;
6797+
/// `existential type Foo: Bar;`
67986798
/// or
6799-
/// return None without modifying the parser state
6799+
/// `return None` without modifying the parser state
68006800
fn eat_type(&mut self) -> Option<PResult<'a, (Ident, AliasKind, ast::Generics)>> {
68016801
// This parses the grammar:
68026802
// Ident ["<"...">"] ["where" ...] ("=" | ":") Ty ";"

src/test/ui/traits/trait-alias-fail1.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// gate-test-trait_alias
11+
#![feature(trait_alias)]
1212

1313
trait CloneDefault<T> = Default where T: Clone;
1414
trait BoundedAlias<T: Clone = ()> = Default;
1515

16-
trait A<T: Send> {}
17-
trait B<T> = A<T>; // FIXME: parameter T should need a bound here, or semantics should be changed
16+
trait Foo {}
17+
trait A<T: Foo> {}
18+
trait B<T> = A<T>; // T cannot be unbounded
1819

1920
impl CloneDefault for () {}
2021

src/test/ui/traits/trait-alias-fail2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// gate-test-trait_alias
11+
#![feature(trait_alias)]
1212

1313
trait EqAlias = Eq;
1414
trait IteratorAlias = Iterator;

0 commit comments

Comments
 (0)