summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--disabled_tests_run-pass.txt8
-rw-r--r--src/ast/ast.hpp8
-rw-r--r--src/hir/from_ast.cpp4
-rw-r--r--src/parse/root.cpp35
-rw-r--r--src/resolve/absolute.cpp8
5 files changed, 42 insertions, 21 deletions
diff --git a/disabled_tests_run-pass.txt b/disabled_tests_run-pass.txt
index 4bf3b2b7..767acc56 100644
--- a/disabled_tests_run-pass.txt
+++ b/disabled_tests_run-pass.txt
@@ -35,8 +35,6 @@ lex-bare-cr-nondoc-comment # Don't treat \r as a new line
# PARSE
align-struct # repr(align(2)) - Need to support integers in attributes
catch-expr # MISSING: `do catch {}` syntax
-issue-37733 # for<'a> in types
-issue-39089 # for<'a> in optional traits
loop-break-value # TODO: Handle loop labels in expression position.
match-range # TODO: Exlusive ranges in patterns
paths-in-macro-invocations # TODO: Handle path macros at root.
@@ -154,6 +152,10 @@ placement-in-syntax # BUG: Can't find impl in optimise
struct-path-associated-type # HUH? `T::A { ... }` struct literal with (bounded) associated const
struct-path-self # TODO: Handle `Self` in patterns
thread-local-extern-static # TODO: #[no_mangle]
+issue-17170 # TODO: #[repr(simd)]
+simd-size-align # ^
+simd-type # ^
+simd-upgraded # ^
# TYPECHECK
associated-types-doubleendediterator-object # BUG BUG: Validation failed
@@ -313,6 +315,8 @@ type-id-higher-rank # BUG: type_id returns the same value for `for<'a> fn(&'a T)
type-id-higher-rank-2 # ^ (test failed)
unsized3 # BUG: Incorrect dst type annotation for struct containing `str`
utf8_idents # BUG: No escaping of utf8 in symbols, GCC doesn't like this
+abi-sysv64-arg-passing # ERROR: Empty struct arguments to FFI aren't actually empty
+extern-pass-empty # ^
# HIR MISC
xcrate-associated-type-defaults # type_is_specialisable - Handle missing type in impl(0x17e3018) ::"xcrate_associated_type_defaults"::Foo<u32,> for () {}, name = Out
diff --git a/src/ast/ast.hpp b/src/ast/ast.hpp
index 3d7c2dfb..5d0201d0 100644
--- a/src/ast/ast.hpp
+++ b/src/ast/ast.hpp
@@ -191,7 +191,7 @@ public:
class Trait
{
GenericParams m_params;
- ::std::vector< Spanned<AST::Path> > m_supertraits;
+ ::std::vector< Spanned<Type_TraitPath> > m_supertraits;
bool m_is_marker;
bool m_is_unsafe;
@@ -201,7 +201,7 @@ public:
m_is_marker(false),
m_is_unsafe(false)
{}
- Trait(GenericParams params, ::std::vector< Spanned<Path> > supertraits):
+ Trait(GenericParams params, ::std::vector< Spanned<Type_TraitPath> > supertraits):
m_params( mv$(params) ),
m_supertraits( mv$(supertraits) ),
m_is_marker(false),
@@ -211,8 +211,8 @@ public:
const GenericParams& params() const { return m_params; }
GenericParams& params() { return m_params; }
- const ::std::vector<Spanned<Path> >& supertraits() const { return m_supertraits; }
- ::std::vector<Spanned<Path> >& supertraits() { return m_supertraits; }
+ const ::std::vector<Spanned<Type_TraitPath> >& supertraits() const { return m_supertraits; }
+ ::std::vector<Spanned<Type_TraitPath> >& supertraits() { return m_supertraits; }
const NamedList<Item>& items() const { return m_items; }
NamedList<Item>& items() { return m_items; }
diff --git a/src/hir/from_ast.cpp b/src/hir/from_ast.cpp
index 6353a0ea..4def1a41 100644
--- a/src/hir/from_ast.cpp
+++ b/src/hir/from_ast.cpp
@@ -1108,8 +1108,8 @@ namespace {
::std::string lifetime;
::std::vector< ::HIR::TraitPath> supertraits;
for(const auto& st : f.supertraits()) {
- if( st.ent.is_valid() ) {
- supertraits.push_back( LowerHIR_TraitPath(st.sp, st.ent) );
+ if( st.ent.path.is_valid() ) {
+ supertraits.push_back( LowerHIR_TraitPath(st.sp, st.ent.path) );
}
else {
lifetime = "static";
diff --git a/src/parse/root.cpp b/src/parse/root.cpp
index 0a8d2909..4764c063 100644
--- a/src/parse/root.cpp
+++ b/src/parse/root.cpp
@@ -127,8 +127,12 @@ bool Parse_Publicity(TokenStream& lex, bool allow_restricted=true)
::AST::HigherRankedBounds rv;
GET_CHECK_TOK(tok, lex, TOK_LT);
do {
+ // Support empty lists and comma-terminated lists
+ if( lex.lookahead(0) == TOK_GT ) {
+ GET_TOK(tok, lex);
+ break;
+ }
auto attrs = Parse_ItemAttrs(lex);
- (void)attrs; // TODO: Attributes on generic params
switch(GET_TOK(tok, lex))
{
@@ -142,6 +146,18 @@ bool Parse_Publicity(TokenStream& lex, bool allow_restricted=true)
CHECK_TOK(tok, TOK_GT);
return rv;
}
+::AST::HigherRankedBounds Parse_HRB_Opt(TokenStream& lex)
+{
+ if( lex.lookahead(0) == TOK_RWORD_FOR )
+ {
+ lex.getToken(); // Consume
+ return Parse_HRB(lex);
+ }
+ else
+ {
+ return ::AST::HigherRankedBounds();
+ }
+}
namespace {
AST::LifetimeRef get_LifetimeRef(TokenStream& lex, Token tok)
@@ -170,6 +186,8 @@ void Parse_TypeBound(TokenStream& lex, AST::GenericParams& ret, TypeRef checked_
} ));
}
else if( tok.type() == TOK_QMARK ) {
+ auto hrbs = Parse_HRB_Opt(lex);
+ (void)hrbs; // The only valid ?Trait is Sized, which doesn't have any generics
ret.add_bound(AST::GenericBound::make_MaybeTrait( {
checked_type.clone(), Parse_Path(lex, PATH_GENERIC_TYPE)
} ));
@@ -623,26 +641,23 @@ AST::Trait Parse_TraitDef(TokenStream& lex, const AST::AttributeList& meta_items
}
// Trait bounds "trait Trait : 'lifetime + OtherTrait + OtherTrait2"
- ::std::vector<Spanned<AST::Path> > supertraits;
+ ::std::vector<Spanned<Type_TraitPath> > supertraits;
if(tok.type() == TOK_COLON)
{
+ // TODO: Just add these as `where Self: <foo>` (would that break typecheck?)
do {
if( GET_TOK(tok, lex) == TOK_LIFETIME ) {
// TODO: Need a better way of indiciating 'static than just an invalid path
- // TODO: Ensure that it's 'static
- supertraits.push_back( make_spanned( Span(tok.get_pos()), AST::Path() ) );
+ ASSERT_BUG(lex.point_span(), tok.str() == "static", "TODO: Support lifetimes other than 'static in trait bounds");
+ supertraits.push_back( make_spanned( Span(tok.get_pos()), Type_TraitPath{ {}, AST::Path() } ) );
}
else if( tok.type() == TOK_BRACE_OPEN ) {
break;
}
else {
PUTBACK(tok, lex);
- if( LOOK_AHEAD(lex) == TOK_RWORD_FOR )
- {
- GET_TOK(tok, lex);
- /*::std::vector< ::std::string> lifetimes =*/ Parse_HRB(lex);
- }
- supertraits.push_back( GET_SPANNED(::AST::Path, lex, Parse_Path(lex, PATH_GENERIC_TYPE)) );
+ auto hrbs = Parse_HRB_Opt(lex);
+ supertraits.push_back( GET_SPANNED(Type_TraitPath, lex, (Type_TraitPath{ mv$(hrbs), Parse_Path(lex, PATH_GENERIC_TYPE) })) );
}
} while( GET_TOK(tok, lex) == TOK_PLUS );
}
diff --git a/src/resolve/absolute.cpp b/src/resolve/absolute.cpp
index f114fd78..46a27c2d 100644
--- a/src/resolve/absolute.cpp
+++ b/src/resolve/absolute.cpp
@@ -2055,12 +2055,14 @@ void Resolve_Absolute_Trait(Context& item_context, ::AST::Trait& e)
Resolve_Absolute_Generic(item_context, e.params());
for(auto& st : e.supertraits()) {
- if( !st.ent.is_valid() ) {
+ if( !st.ent.path.is_valid() ) {
DEBUG("- ST 'static");
}
else {
- DEBUG("- ST " << st.ent);
- Resolve_Absolute_Path(item_context, st.sp, Context::LookupMode::Type, st.ent);
+ DEBUG("- ST " << st.ent.hrbs << st.ent.path);
+ item_context.push(st.ent.hrbs);
+ Resolve_Absolute_Path(item_context, st.sp, Context::LookupMode::Type, st.ent.path);
+ item_context.pop(st.ent.hrbs);
}
}