Actually, under NEC you can. You can't place a 30A receptacle on a 40A or 50A breaker, but you can protect a larger-rated set of conductors and receptacles with a smaller breaker, provided that you do not attach a load rated for higher than that.
It all gets confusing, I know... but electric stoves connected with cord-and-plug are permitted providing their nameplate only calls for a 40A circuit (and many do). However, it violates NEC to connect the Tesla to a 14-50R on a 40A breaker, because Tesla's nameplate for the system is rated at 50A.
Also, I addressed this in the same thread in the charging forum, but I'll address it here too... #8 wire is just fine for a 50A circuit as long as it's not NM-B (Romex) or flex cable -- #8 wire in conduit is rated for 50A just fine. If NM-B, you must use #6 because NEC requires you to use the 60 degC rating, despite that conductors inside are rated for 90 degC. If SOOW, things get a bit complex. You can use a 6/4 to power a Tesla because the "B" column of NEC table 400.5(A) allows for 55A rating when only 2 conductors of a 4-conductor cable are carrying current. But if you use that cord with an RV, it may not be to code because using the neutral, you have 3 current-carrying conductors and it's limited to 45A.
Bottom line, if you build an extension cord, use 14-50P and 14-50R on a 6/4 cable (SOOW preferred for flexibility -- NM-B/Romex is not rated for temporary use).