The accepted answer is wrong or perhaps just confusing. Read this article to get the rule breakdown. You can pass to yourself off of your backboard or rim, however you cannot do so on your opponent's rim. As noted in the comments on the other answer Ricky Davis's pass was called a violation by Sloan and Sloan is right.
First Ricky Davis traveled - because he caught the ball with two hands after the "shot attempt". He could have pushed the ball against the rim and continued dribbling. That being said you can push the ball 50 feet in the air and continue dribbling. Ricky Davis caught the ball with two hands so he was not continuing a dribble, he was starting one, which is a very very clear travel.
So yes for your rim, backboard, and a big no to your opponent's.
(side note and nothing to do with the question but Ricky Davis also should have had a tech for shooting on purpose on the opponent's basket - which is a tech example in rulebook revisions)