new MetaListPaths (ident, ident_locus, std::move (path_items)));
}
- rust_error_at (Linemap::unknown_location (),
- "failed to parse any meta item inner");
+ rust_error_at (UNKNOWN_LOCATION, "failed to parse any meta item inner");
return nullptr;
}
{
/* HACK: convert vector platform-dependent size_type to string to
* use in printf */
- rust_error_at (Linemap::unknown_location (),
+ rust_error_at (UNKNOWN_LOCATION,
"cfg predicate could not be checked for "
"MetaListNameValueStr with ident of "
"'not' because there are '%s' elements, not '1'",
}
else
{
- rust_error_at (Linemap::unknown_location (),
+ rust_error_at (UNKNOWN_LOCATION,
"cfg predicate could not be checked for "
"MetaListNameValueStr with ident of "
"'%s' - ident must be 'all' or 'any'",
{
// HACK: convert vector platform-dependent size_type to string to
// use in printf
- rust_error_at (Linemap::unknown_location (),
+ rust_error_at (UNKNOWN_LOCATION,
"cfg predicate could not be checked for MetaListPaths "
"with ident of 'not' "
"because there are '%s' elements, not '1'",
}
else
{
- rust_error_at (Linemap::unknown_location (),
+ rust_error_at (UNKNOWN_LOCATION,
"cfg predicate could not be checked for "
"MetaListNameValueStr with ident of "
"'%s' - ident must be 'all' or 'any'",
{
/* HACK: convert vector platform-dependent size_type to string to
* use in printf */
- rust_error_at (Linemap::unknown_location (),
+ rust_error_at (UNKNOWN_LOCATION,
"cfg predicate could not be checked for MetaItemSeq "
"with ident of 'not' "
"because there are '%s' elements, not '1'",
else
{
rust_error_at (
- Linemap::unknown_location (),
+ UNKNOWN_LOCATION,
"cfg predicate could not be checked for MetaItemSeq with path of "
"'%s' - path must be 'all' or 'any'",
path.as_string ().c_str ());
}
// kind of a HACK to get locus depending on opening scope resolution
- Location locus = Linemap::unknown_location ();
+ Location locus = UNKNOWN_LOCATION;
if (with_opening_scope_resolution)
locus = simple_segments[0].get_locus () - 2; // minus 2 chars for ::
else
}
// kind of a HACK to get locus depending on opening scope resolution
- Location locus = Linemap::unknown_location ();
+ Location locus = UNKNOWN_LOCATION;
if (with_opening_scope_resolution)
{
locus = simple_segments[0].get_locus () - 2; // minus 2 chars for ::
{
if (lseek (fd, 0, SEEK_SET) != 0)
{
- rust_fatal_error (Linemap::unknown_location (), "lseek failed: %m");
+ rust_fatal_error (UNKNOWN_LOCATION, "lseek failed: %m");
this->set_saw_error ();
}
}
if (got < 0)
{
if (!this->saw_error ())
- rust_fatal_error (Linemap::unknown_location (), "read failed: %m");
+ rust_fatal_error (UNKNOWN_LOCATION, "read failed: %m");
this->set_saw_error ();
return false;
}
if (lseek (this->fd_, -got, SEEK_CUR) < 0)
{
if (!this->saw_error ())
- rust_fatal_error (Linemap::unknown_location (), "lseek failed: %m");
+ rust_fatal_error (UNKNOWN_LOCATION, "lseek failed: %m");
this->set_saw_error ();
return false;
}
if (lseek (this->fd_, skip, SEEK_CUR) < 0)
{
if (!this->saw_error ())
- rust_fatal_error (Linemap::unknown_location (), "lseek failed: %m");
+ rust_fatal_error (UNKNOWN_LOCATION, "lseek failed: %m");
this->set_saw_error ();
}
if (!this->data_.empty ())
Parser<ManagedTokenSource>::parse_simple_path ()
{
bool has_opening_scope_resolution = false;
- Location locus = Linemap::unknown_location ();
+ Location locus = UNKNOWN_LOCATION;
// don't parse anything if not a path upfront
if (!is_simple_path_segment (lexer.peek_token ()->get_id ())
AST::SimplePathSegment segment = parse_simple_path_segment ();
// get location if not gotten already
- if (locus == Linemap::unknown_location ())
+ if (locus == UNKNOWN_LOCATION)
locus = segment.get_locus ();
std::vector<AST::SimplePathSegment> segments;
AST::PathInExpression
Parser<ManagedTokenSource>::parse_path_in_expression ()
{
- Location locus = Linemap::unknown_location ();
+ Location locus = UNKNOWN_LOCATION;
bool has_opening_scope_resolution = false;
if (lexer.peek_token ()->get_id () == SCOPE_RESOLUTION)
{
// create segment vector
std::vector<AST::PathExprSegment> segments;
- if (locus == Linemap::unknown_location ())
+ if (locus == UNKNOWN_LOCATION)
{
locus = lexer.peek_token ()->get_locus ();
}
Location locus = pratt_parsed_loc;
/* TODO: should this actually be error? is there anywhere where this could
* be valid? */
- if (locus == Linemap::unknown_location ())
+ if (locus == UNKNOWN_LOCATION)
{
locus = lexer.peek_token ()->get_locus ();
Location pratt_parsed_loc)
{
Location locus = pratt_parsed_loc;
- if (locus == Linemap::unknown_location ())
+ if (locus == UNKNOWN_LOCATION)
{
locus = lexer.peek_token ()->get_locus ();
if (!skip_token (LEFT_CURLY))
Location pratt_parsed_loc)
{
Location locus = pratt_parsed_loc;
- if (locus == Linemap::unknown_location ())
+ if (locus == UNKNOWN_LOCATION)
{
locus = lexer.peek_token ()->get_locus ();
skip_token (RETURN_TOK);
Location pratt_parsed_loc)
{
Location locus = pratt_parsed_loc;
- if (locus == Linemap::unknown_location ())
+ if (locus == UNKNOWN_LOCATION)
{
locus = lexer.peek_token ()->get_locus ();
skip_token (BREAK);
Location pratt_parsed_loc)
{
Location locus = pratt_parsed_loc;
- if (locus == Linemap::unknown_location ())
+ if (locus == UNKNOWN_LOCATION)
{
locus = lexer.peek_token ()->get_locus ();
skip_token (CONTINUE);
{
// TODO: make having outer attributes an error?
Location locus = pratt_parsed_loc;
- if (locus == Linemap::unknown_location ())
+ if (locus == UNKNOWN_LOCATION)
{
locus = lexer.peek_token ()->get_locus ();
if (!skip_token (IF))
{
// TODO: make having outer attributes an error?
Location locus = pratt_parsed_loc;
- if (locus == Linemap::unknown_location ())
+ if (locus == UNKNOWN_LOCATION)
{
locus = lexer.peek_token ()->get_locus ();
if (!skip_token (IF))
Location pratt_parsed_loc)
{
Location locus = pratt_parsed_loc;
- if (locus == Linemap::unknown_location ())
+ if (locus == UNKNOWN_LOCATION)
{
if (label.is_error ())
locus = lexer.peek_token ()->get_locus ();
Location pratt_parsed_loc)
{
Location locus = pratt_parsed_loc;
- if (locus == Linemap::unknown_location ())
+ if (locus == UNKNOWN_LOCATION)
{
if (label.is_error ())
locus = lexer.peek_token ()->get_locus ();
Parser<ManagedTokenSource>::parse_while_let_loop_expr (AST::AttrVec outer_attrs,
AST::LoopLabel label)
{
- Location locus = Linemap::unknown_location ();
+ Location locus = UNKNOWN_LOCATION;
if (label.is_error ())
locus = lexer.peek_token ()->get_locus ();
else
Parser<ManagedTokenSource>::parse_for_loop_expr (AST::AttrVec outer_attrs,
AST::LoopLabel label)
{
- Location locus = Linemap::unknown_location ();
+ Location locus = UNKNOWN_LOCATION;
if (label.is_error ())
locus = lexer.peek_token ()->get_locus ();
else
Location pratt_parsed_loc)
{
Location locus = pratt_parsed_loc;
- if (locus == Linemap::unknown_location ())
+ if (locus == UNKNOWN_LOCATION)
{
locus = lexer.peek_token ()->get_locus ();
skip_token (MATCH_TOK);
Location pratt_parsed_loc)
{
Location locus = pratt_parsed_loc;
- if (locus == Linemap::unknown_location ())
+ if (locus == UNKNOWN_LOCATION)
{
locus = lexer.peek_token ()->get_locus ();
skip_token (UNSAFE);
Location pratt_parsed_loc)
{
Location locus = pratt_parsed_loc;
- if (locus == Linemap::unknown_location ())
+ if (locus == UNKNOWN_LOCATION)
{
locus = lexer.peek_token ()->get_locus ();
skip_token (LEFT_SQUARE);
{
// adjustment to allow Pratt parsing to reuse function without copy-paste
Location locus = pratt_parsed_loc;
- if (locus == Linemap::unknown_location ())
+ if (locus == UNKNOWN_LOCATION)
{
locus = lexer.peek_token ()->get_locus ();
skip_token (LEFT_PAREN);
std::unique_ptr<AST::RangePatternBound> upper_bound
= parse_range_pattern_bound ();
- return std::unique_ptr<AST::RangePattern> (new AST::RangePattern (
- std::move (lower_bound), std::move (upper_bound),
- Linemap::unknown_location (), has_ellipsis_syntax));
+ return std::unique_ptr<AST::RangePattern> (
+ new AST::RangePattern (std::move (lower_bound),
+ std::move (upper_bound),
+ UNKNOWN_LOCATION, has_ellipsis_syntax));
}
case EXCLAM:
return parse_macro_invocation_partial (std::move (path),
std::unique_ptr<AST::RangePatternBound> upper_bound
= parse_range_pattern_bound ();
- return std::unique_ptr<AST::RangePattern> (new AST::RangePattern (
- std::move (lower_bound), std::move (upper_bound),
- Linemap::unknown_location (), has_ellipsis_syntax));
+ return std::unique_ptr<AST::RangePattern> (
+ new AST::RangePattern (std::move (lower_bound),
+ std::move (upper_bound), UNKNOWN_LOCATION,
+ has_ellipsis_syntax));
}
case PATTERN_BIND: {
// only allow on single-segment paths
std::unique_ptr<AST::BlockExpr>
parse_block_expr (AST::AttrVec outer_attrs = AST::AttrVec (),
- Location pratt_parsed_loc = Linemap::unknown_location ());
+ Location pratt_parsed_loc = UNKNOWN_LOCATION);
std::unique_ptr<AST::Item> parse_item (bool called_from_statement);
std::unique_ptr<AST::Pattern> parse_pattern ();
// first token parsed in the expression (the parsing of that first
// token should be skipped).
parse_qualified_path_in_expression (Location pratt_parsed_loc
- = Linemap::unknown_location ());
- AST::QualifiedPathType
- parse_qualified_path_type (Location pratt_parsed_loc
- = Linemap::unknown_location ());
+ = UNKNOWN_LOCATION);
+ AST::QualifiedPathType parse_qualified_path_type (Location pratt_parsed_loc
+ = UNKNOWN_LOCATION);
AST::QualifiedPathInType parse_qualified_path_in_type ();
// Token tree or macro related
// token should be skipped).
std::unique_ptr<AST::IfExpr>
parse_if_expr (AST::AttrVec outer_attrs = AST::AttrVec (),
- Location pratt_parsed_loc = Linemap::unknown_location ());
+ Location pratt_parsed_loc = UNKNOWN_LOCATION);
std::unique_ptr<AST::IfLetExpr>
parse_if_let_expr (AST::AttrVec outer_attrs = AST::AttrVec (),
- Location pratt_parsed_loc = Linemap::unknown_location ());
+ Location pratt_parsed_loc = UNKNOWN_LOCATION);
std::unique_ptr<AST::LoopExpr>
parse_loop_expr (AST::AttrVec outer_attrs = AST::AttrVec (),
AST::LoopLabel label = AST::LoopLabel::error (),
- Location pratt_parsed_loc = Linemap::unknown_location ());
+ Location pratt_parsed_loc = UNKNOWN_LOCATION);
std::unique_ptr<AST::WhileLoopExpr>
parse_while_loop_expr (AST::AttrVec outer_attrs = AST::AttrVec (),
AST::LoopLabel label = AST::LoopLabel::error (),
- Location pratt_parsed_loc
- = Linemap::unknown_location ());
+ Location pratt_parsed_loc = UNKNOWN_LOCATION);
std::unique_ptr<AST::WhileLetLoopExpr>
parse_while_let_loop_expr (AST::AttrVec outer_attrs = AST::AttrVec (),
AST::LoopLabel label = AST::LoopLabel::error ());
AST::LoopLabel label = AST::LoopLabel::error ());
std::unique_ptr<AST::MatchExpr>
parse_match_expr (AST::AttrVec outer_attrs = AST::AttrVec (),
- Location pratt_parsed_loc = Linemap::unknown_location ());
+ Location pratt_parsed_loc = UNKNOWN_LOCATION);
AST::MatchArm parse_match_arm ();
std::vector<std::unique_ptr<AST::Pattern> >
parse_match_arm_patterns (TokenId end_token_id);
// token should be skipped).
std::unique_ptr<AST::ReturnExpr>
parse_return_expr (AST::AttrVec outer_attrs = AST::AttrVec (),
- Location pratt_parsed_loc = Linemap::unknown_location ());
+ Location pratt_parsed_loc = UNKNOWN_LOCATION);
std::unique_ptr<AST::BreakExpr>
parse_break_expr (AST::AttrVec outer_attrs = AST::AttrVec (),
- Location pratt_parsed_loc = Linemap::unknown_location ());
+ Location pratt_parsed_loc = UNKNOWN_LOCATION);
std::unique_ptr<AST::ContinueExpr>
parse_continue_expr (AST::AttrVec outer_attrs = AST::AttrVec (),
- Location pratt_parsed_loc
- = Linemap::unknown_location ());
+ Location pratt_parsed_loc = UNKNOWN_LOCATION);
std::unique_ptr<AST::UnsafeBlockExpr>
parse_unsafe_block_expr (AST::AttrVec outer_attrs = AST::AttrVec (),
- Location pratt_parsed_loc
- = Linemap::unknown_location ());
+ Location pratt_parsed_loc = UNKNOWN_LOCATION);
std::unique_ptr<AST::ArrayExpr>
parse_array_expr (AST::AttrVec outer_attrs = AST::AttrVec (),
- Location pratt_parsed_loc = Linemap::unknown_location ());
+ Location pratt_parsed_loc = UNKNOWN_LOCATION);
std::unique_ptr<AST::ExprWithoutBlock>
parse_grouped_or_tuple_expr (AST::AttrVec outer_attrs = AST::AttrVec (),
- Location pratt_parsed_loc
- = Linemap::unknown_location ());
+ Location pratt_parsed_loc = UNKNOWN_LOCATION);
std::unique_ptr<AST::StructExprField> parse_struct_expr_field ();
bool will_be_expr_with_block ();
tree type;
Location location;
- typed_identifier ()
- : name (), type (NULL_TREE), location (Linemap::unknown_location ())
+ typed_identifier () : name (), type (NULL_TREE), location (UNKNOWN_LOCATION)
{}
typed_identifier (const std::string &a_name, tree a_type,
if (nwr == -1)
{
// memory allocation failed
- rust_be_error_at (Linemap::unknown_location (),
+ rust_be_error_at (UNKNOWN_LOCATION,
"memory allocation failed in vasprintf");
rust_assert (0);
}
va_end (ap);
if (nwr == -1)
{
- rust_be_error_at (Linemap::unknown_location (),
+ rust_be_error_at (UNKNOWN_LOCATION,
"memory allocation failed in vasprintf");
rust_assert (0);
}
// Return the special Location used for predeclared identifiers.
static Location predeclared_location () { return BUILTINS_LOCATION; }
- // Return the special Location used when no location is known.
- static Location unknown_location () { return UNKNOWN_LOCATION; }
-
// Produce a human-readable description of a Location.
static std::string location_to_string (Location loc)
{
dump_lex_stream.open (kLexDumpFile);
if (dump_lex_stream.fail ())
{
- rust_error_at (Linemap::unknown_location (),
- "cannot open %s:%m; ignored", kLexDumpFile);
+ rust_error_at (UNKNOWN_LOCATION, "cannot open %s:%m; ignored",
+ kLexDumpFile);
}
auto stream = Optional<std::ofstream &>::some (dump_lex_stream);
dump_lex_opt = std::move (stream);
if (!lex.input_source_is_valid_utf8 ())
{
- rust_error_at (Linemap::unknown_location (),
+ rust_error_at (UNKNOWN_LOCATION,
"cannot read %s; stream did not contain valid UTF-8",
filename);
return;
// create "extern crate" item with the name
std::unique_ptr<AST::ExternCrate> extern_crate (
new AST::ExternCrate (*it, AST::Visibility::create_error (),
- {std::move (attr)},
- Linemap::unknown_location ()));
+ {std::move (attr)}, UNKNOWN_LOCATION));
// insert at beginning
// crate.items.insert (crate.items.begin (), std::move (extern_crate));
if (out.fail ())
{
- rust_error_at (Linemap::unknown_location (), "cannot open %s:%m; ignored",
+ rust_error_at (UNKNOWN_LOCATION, "cannot open %s:%m; ignored",
kASTDumpFile);
return;
}
out.open (kHIRDumpFile);
if (out.fail ())
{
- rust_error_at (Linemap::unknown_location (), "cannot open %s:%m; ignored",
+ rust_error_at (UNKNOWN_LOCATION, "cannot open %s:%m; ignored",
kHIRDumpFile);
return;
}
out.open (kHIRPrettyDumpFile);
if (out.fail ())
{
- rust_error_at (Linemap::unknown_location (), "cannot open %s:%m; ignored",
+ rust_error_at (UNKNOWN_LOCATION, "cannot open %s:%m; ignored",
kHIRPrettyDumpFile);
return;
}
out.open (kTargetOptionsDumpFile);
if (out.fail ())
{
- rust_error_at (Linemap::unknown_location (), "cannot open %s:%m; ignored",
+ rust_error_at (UNKNOWN_LOCATION, "cannot open %s:%m; ignored",
kTargetOptionsDumpFile);
return;
}
{
static VariantDef node
= VariantDef (UNKNOWN_HIRID, UNKNOWN_DEFID, "",
- {Resolver::CanonicalPath::create_empty (),
- Linemap::unknown_location ()},
+ {Resolver::CanonicalPath::create_empty (), UNKNOWN_LOCATION},
nullptr);
return node;