Build fixes

This includes work by engstad for cargo compatibility and rustc updates and then some updates by me for rustc updates on top of that. There isn't any new functionality.
Is this added intentionally? (Seems unrelated to this project.)