You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I also think it's a little strange that I can pass arbitrary source code to the --cfg command-line argument, and trailing source code is frequently ignored:
e.g. I think these two invocations are equivalent:
IMHO, this is a bug in libsyntax/codemap.rs:lookup_filemap_idx (reproduced below). The comment incorrectly states that we can't possibly be looking for a length zero filemap but, in this case, we're looking for a zero-length span in a zero-length filemap. I don't know if there's any clean way to fix this because of the way filemaps work. The simple fix is to say that one must not pass empty strings to parse_*_from_source_str functions. Something like (untested):
fnlookup_filemap_idx(&self,pos:BytePos) -> usize{let files = self.files.borrow();let files = &*files;let len = files.len();letmut a = 0;letmut b = len;while b - a > 1{let m = (a + b) / 2;if files[m].start_pos > pos {
b = m;}else{
a = m;}}// There can be filemaps with length 0. These have the same start_pos as// the previous filemap, but are not the filemaps we want (because they// are length 0, they cannot contain what we are looking for). So,// rewind until we find a useful filemap.loop{let lines = files[a].lines.borrow();let lines = lines;if !lines.is_empty(){break;}if a == 0{panic!("position {} does not resolve to a source location",
pos.to_usize());}
a -= 1;}if a >= len {panic!("position {} does not resolve to a source location",
pos.to_usize())}return a;}
The compiler is trying to report that the
--cfg
argument is invalid, but I guess it's not prepared to handle 0-length source code?I also think it's a little strange that I can pass arbitrary source code to the
--cfg
command-line argument, and trailing source code is frequently ignored:e.g. I think these two invocations are equivalent:
I'm also wondering if the syntax could be just
--cfg feature=A
. The quoting is inconvenient.The text was updated successfully, but these errors were encountered: